Subject: RE: [stella] Climber5 source and binary From: Thomas Jentzsch <tjentzsch@xxxxxx> Date: Thu, 17 Apr 2003 16:02:47 +0200 |
Dennis wrote: >I thought I read some where that on a PAL machine you had to turn off >all 3 sound registers to completely turn off the sound. If not you >could get a hum. I don't know where I saw this but that's why all 3 >are done here. Hm, I have never heard that. Can anybody confirm this information? >> 6. use BIT, change: >bit was used first but I'm storing the value in playerState later in >the routine. That's why lda is used here. Oops, I missed that. >Sure, why not? That is if you have the time :) I tend to (and I'm >sure others will too) learn from my mistakes. Those are not "mistakes". I am sure you can optimize nearly endlessly and you (or somebody else) will always find at least one more byte. :-) Ok, a few more: 1. Why so complicated? lda DivisibleBy4,y beq DrawLadderGroup bne EmptyLadderKernel This works too: tya and #$03 bne DrawLadderGroup beq EmptyLadderKernel 2. waste time efficient: You are often using two or more force extensions (.w) to waste a few cycles. You can replace two of them with nop and save a byte. 3. interleave data ldx #$00 ; load color table index (assume NTSC) bit SWCHB ; check for NTSC/PAL settings bpl .loadDeathColors ldx #$02 ; load color table index for PAL .loadDeathColors ldy DeathAnimationColorTable,x lda DeathAnimationColorTable+1,x Write this ldx #$00 ; load color table index (assume NTSC) bit SWCHB ; check for NTSC/PAL settings bpl .loadDeathColors inx .loadDeathColors ldy DeathAnimationColorTable,x lda DeathAnimationColorTable+2,x and change DeathAnimationColorTable into .byte <NTSCDeathAnimationColors, <PALDeathAnimationColors .byte >NTSCDeathAnimationColors, >PALDeathAnimationColors And if you are sure both are in the same page you can save a few more bytes. The same trick works for several other PAL/NTSC and animation tables too. 4. superfluous code: ; bcc .moveClimberRight bcs .doneHorizontalCalculations ; same as jmp but saves a byte .moveClimberRight 5. use eor instead of cmp: change cmp #$FF ; if no motion allowed turn off walking bne .checkJoystickMovement ; sound lda #$00 sta walkingSoundIndex into eor #$FF ; if no motion allowed turn off walking bne .checkJoystickMovement ; sound sta walkingSoundIndex I am sure there are more places where you can use this trick 6. another simple one: from lda #$FF ; show that the select switch is held sta selectDebounce ; for the next frame ldy #$00 ; to be used to clear the attract timer lda attractMode sty attractMode ; clear the attract mode timer to ldy #$FF ; show that the select switch is held sty selectDebounce ; for the next frame iny ; to be used to clear the attract timer lda attractMode sty attractMode ; clear the attract mode timer 7. another bit trick: from ldy #$00 lda #$02 ... sta VSYNC ; start a new frame ... sty VSYNC ; end the VSYNC period to lda #$02 ... sta VSYNC ; start a new frame lsr ... sta VSYNC ; end the VSYNC period 8. more tricks with bits: >From tya ; y holds the walkway number and #%00000001 ; mask all but bit 0 asl ; multiply the value by 2 tay ; this will now be used as an index for ; odd/even walkways ldx #$00 .storeValidLadderValues lda LadderValuePointer,y ; load the ladderPointer values to sta ladderPointer,x ; determine vertical movement iny inx cpx #$04 bne .storeValidLadderValues To tya ; y holds the walkway number and #%00000001 ; mask all but bit 0 asl ; multiply the value by 2 ora #4 tay ; this will now be used as an index for ; odd/even walkways ldx #$03 .storeValidLadderValues dey lda LadderValuePointer,y ; load the ladderPointer values to sta ladderPointer,x ; determine vertical movement dex bpl .storeValidLadderValues Doesn't save ROM but a few cycles. And it's a nice example. :-) 9. if your random number generator is good and random is at least once initialized to != 0 this code is superfluous: RandomByte SUBROUTINE lda random ; bne .skipInit ; lda #$FF For the PAL/NTSC speeds I would suggest using fractional numbers for playerMotion. This also allows much finer tuning of the speeds for NTSC. Example: lda playerMotion clc sbc "currentSpeed" sta playerMotion bcs CheckPlayerState jsr SetGirderSpeed ; refresh the girder motion counter E.g. "CurrentSpeed" NTSC: $40-1, $55-1, $80-1, $100-1 ; for PAL use 6/5 of the NTSC value PAL: $4c-1, $66-1, $9a-1, ??? Alternatively you could subtact a constant value (e.g. 30) from playerMotion and add the level speeds (*30) in SetGirderSpeed This allows you to use better matching PAL values NTSC: 30*4-1, 30*3-1, 30*2-1, 30*1-1 PAL: 36*4-1, 36*3-1, 36*2-1, 36*1-1 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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [stella] Climber5 source and bi, Dennis Debro | Thread | Re: [stella] Climber5 source and bi, Eckhard Stolberg |
Re: [stella] Climber5 source and bi, Andrew Davie | Date | Re: [stella] Climber5 source and bi, Andrew Davie |
Month |