Re: [stella] Help (Timing problems?)

Subject: Re: [stella] Help (Timing problems?)
From: "Thomas Jentzsch" <tjentzsch@xxxxxx>
Date: Tue, 31 Jul 2001 09:23:55 +0200
Wade Brown wrote:
> I am working on a "shell" that I can use to flesh out some ideas I have - 
> the idea being to have basic semi-reusable functions such as: b/w color 
> selection, screen saver timer, and score digits.

That's a good idea, if you want to start programming the 2600. Later on, you will find, that often you need more specialized or optimized code. 


> BTW, I was trying to get a fairly optimal way to read diagonals from the 
> joystick - anyone out there see how I can improve this approach or has a 
> different take, I would really like to see...

The code below is a bit more compact than yours:

; check joystick:
    lda SWCHA
    asl
    bcc .noRight
    inc Player1X
    bcs .withJoy    ;3      always taken branch, saves 1 byte compared to jmp
.noRight:
    asl
    bcc .noLeft
    inc Player1X
    bcs .withJoy    ;3      always taken branch, saves 1 byte compared to jmp
.noLeft:
    asl
    bcc .noDown
    ...
    bcs .withJoy    ;3      always taken branch, saves 1 byte compared to jmp
.noDown:
    asl
    bcc .noJoy
    ...
.withJoy:
    ldy #0          ;       joystick moved
    sty SaverTimer
.noJoy:


> I would especially appreciate any help in the 
> area of boundary detection (i.e detecting when the player/enemy is at the 
> edge of the screen).

Here is a slightly better solution: 

; check x-bounds:
; I LOVE to use constants, because that makes the code more readable (for me:) and I can much easier change the parameters
LEFT_BOUND      =  20
RIGHT_BOUND     = 140

    lda Player1X
    cmp #LEFT_BOUND
    bcc .outOfLeftBound
    cmp #RIGHT_BOUND+1    
    bcc .inXBounds
    lda #RIGHT_BOUND
    .byte $2c       ;       opcode for bit.w, this hides the next instruction
.outOfLeftBound:
    lda #LEFT_BOUND
    sta Player1X
.inXBounds:

You could also combine the joystick and boundary routines. This might give you more optimal solutions. But that's mixing two different basic functions and doesn't fit into your concept.

Have fun!
Thomas

BTW: I don't think a screensaver mode is necessary any more. And it "wastes" a lot of valuable space.
_______________________________________________________
Thomas Jentzsch         | *** Every bit is sacred ! ***
tjentzsch at web dot de |


______________________________________________________________________________
Jetzt und nur hier Ihr original PREMIERE WORLD SportPaket 
plus 100 Euro ExtraPrämie: http://premiere.web.de


-
Archives (includes files) at http://www.biglist.com/lists/stella/archives/
Unsub & more at http://www.biglist.com/lists/stella/

Current Thread