Re: [stella] Climber5 source and binary

Subject: Re: [stella] Climber5 source and binary
From: "Andrew Davie" <atari2600@xxxxxxxxxxxxx>
Date: Thu, 17 Apr 2003 15:18:40 +1000
Hi Dennis
Thanks for distributing the code.  Had a very brief look and noticed....

SetClimberSpeed SUBROUTINE
   ldy level                     ; get the current level number
   dey                           ; it's used as a table index
   cpy #MAX_LEVEL                ; if less than MAX_LEVEL set game speed
   bcc .setClimberSpeed
   ldy #$02

You should change that last line to ldy #MAX_LEVEL-1 at some point :)
Since we're already looking at this bit of code, let's see what we can

First, you don't really need that "dey" in there
Just access and compare with address-1 or value-1

    ldy level
    cpy #MAX_LEVEL-1        ; instead of dey/cpy #MAX_LEVEL
    bcc .setClimberSpeed
    ldy #MAX_LEVEL-1        ; ditto, we've taken 1 off the comparison
    lda NTSCGameSpeedTable-1,y        ; and access the table 1 byte earlier,

The level is assumed to run from 1 to MAX_LEVEL
So there are MAX_LEVEL actual levels, and the table is indexed using the y
register less 1

In the same routine, there's a branch/check for NTSC/PAL.  Assuming you're
using D7 of SWCHB for your switch, you could interleave (mmh, my favourite
Atari-word) the NTSC and PAL tables by rolling the PAL/NTSC onto the low bit
of the table index, and use code like this...

SetClimberSpeed SUBROUTINE

    lda level
    cmp #MAX_LEVEL
    bcc lOK
    lda #MAX_LEVEL
lOK    asl SWCHB                ; yes, SWCHB is read-only - will an ASL on
this correctly set the C?  I'm assuming so
    rol                    ; CARRY -> d0 of accumulator, simultaneously
multiplying level * 2
    tay                    ; now indexes via  (level*2) + TV_TYPE

    lda GameSpeedTable-2,y            ; interleaved PAL/NTSC table
    sta climberMotion             ; set the climber speed



The same thing could be done for SetGirderSpeed
The above (assuming the asl SWCHB works) would be 18 bytes of ROM
The original is 22 bytes of ROM.

BTW, it's very odd defining tables with the # in front of equated values
like this....   .byte #PAL_LEVEL_3_SPEED
that # is at best superfluous - on most assemblers it would generate an
error, I think.

While we're playing with MAX_LEVEL stuff, the following code is *incredibly*

   ldy level                        ; use the level number as a read offset
   dey                              ; get an and value for the start count
   tya                              ; this is used to change the frequency
   and #MAX_LEVEL-1                 ; girders start to move

That ONLY works because MAX_LEVEL currently happens to be a power of 2.  If
you added one more level, the whole thing would fall over.  This needs to be
changed - if you don't see why, I'll explain - just ask.

That's all for now.  Have fun :)


Archives (includes files) at
Unsub & more at

Current Thread