Re: [stella] Climber5 source and binary

Subject: Re: [stella] Climber5 source and binary
From: Thomas Jentzsch <tjentzsch@xxxxxx>
Date: Thu, 17 Apr 2003 11:50:32 +0200
Dennis wrote:
>Also, if you find any other ways to conserve ROM, PLEASE pass 
>it along. 

Just a few minor peephole optimizations:

1. change:
   lda #HMOVE_R3  	; = $d0 = %11010000
   sta HMP0
   lda #HMOVE_R2  	; = $e0 = %11100000
   sta HMP1

into:
   lda #HMOVE_R2|%1000 	; = $e8 = %11101000
   sta HMP1
   asl		 	; = $d0 = %11010000
   sta HMP0

2. superfluous code:
   lda levelBCD		; get the level number in BCD again
;   and #$F0             ; mask lower nibbles 
   lsr                  ; shift the value down to the lower
   lsr                  ; nibble
   lsr
   lsr

3. count down to 0:
;   ldx #RESERVE_LIVES_HEIGHT
   ldx #RESERVE_LIVES_HEIGHT+1
   ldy #$00
.drawReservedLives
   ...
   dex
;   bpl .drawReservedLives
;   inx                        ; x now 0
   bne .drawReservedLives
   stx GRP0                   ; clear player graphic register

4. turn off the volume only should be as good
TurnOffGameSound
   lda #$00
   sta soundCounter
;   sta AUDC1
   sta AUDV1
;   sta AUDF1
   rts

5. superfluos sec
   bcc .setLevelColors  ; colors
   txa                 	; move to accumulator for math processing
.decrementLevelLoop
;   sec            	; this routine gets a number between the
   sbc #MAX_LEVEL+1     ; MAX_LEVEL limit for the color cycling
   cmp #MAX_LEVEL+1
   bcs .decrementLevelLoop

Maybe you want to change the loop into:
.decrementLevelLoop
   sbc #MAX_LEVEL+1     ; MAX_LEVEL limit for the color cycling
   bcs .decrementLevelLoop
   adc #MAX_LEVEL+1

This saves some cycles when the level number gets higher

6. use BIT, change:
   lda CXP0FB                 ; player0/ball collision
   and #%01000000       	; mask to get P0/BALL collision value
   bne .playerBallCollision

into:
   bit CXP0FB                 ; player0/ball collision
   bvs .playerBallCollision

7. huh???
   lda #$FF
   and allowedMotion          ; mask the allowed motion value so the
   sta allowedMotion          ; climber doesn't move

8. replace all but one
	jmp OverscanWait

with branches and branch to the remaining jmp

More if you ask for. :-)


And a potentional bug:
   eor #$FE      	; make the number negative

This does only work for odd numbers!
   1 eor $FE = $FF = -1
   2 eor $FE = $FC = -4
   3 eor $FE = $FD = -3
   ...

Have fun!	
Thomas


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


Current Thread