PauseRoutine
This is next in ROM space.
Not much to say here. This thing checks for a fresh start button press (The joypad reading routine will ignore start unless it is released and pressed for the most part.) If pressed and appropriate it will pause the game and delay before checking again for pause so the pause sound has time to play. PauseSoundQueue will be set to #1 when pause is pressed and #2 when pause is pressed again to unpause. If PauseSoundQueue is #2 it signals to the sound engine to continue playing sound (music). The main block in the if structure that changes the pause status will also set bit7 of GamePauseStatus to flag that that block will not be run again, but this is not needed, since the start button must be released and pressed again to register as a read in the joy pad reading routine. Next frame, bit7 will be cleared.
Worth noting: the macro code else has the option of sending it a known flag state to create a local branch (always) instruction rather then the default jmp command.
01 .proc PauseRoutine
02
03 ; Are we in Victorymode OR are we in game mode AND running game engine?
04 lda OperMode
05 if ( a = #VictoryModeValue || ( a = #GameModeValue && OperMode_Task = #$03 ))
06
07 if lda GamePauseTimer != zero ; check if pause timer is still counting down
08 dec GamePauseTimer ; if so, decrement and leave
09 rts
10 endif
11
12 if SavedJoypad1Bits & #BUTTON_START == bitset ; bitset is a .define for 'Z clear'
13
14 ; bit7 set, means this code block can't run again (residual)
15 if GamePauseStatus & #%10000000 == bitset goto Exit
16
17 mb GamePauseTimer := #$2b ; timer value
18
19 lda GamePauseStatus ; will be 0 or 1
20 tay
21 mb PauseSoundQueue := y + 1 ; set pause sfx queue, 1 or 2
22
23 mb a := a ^ #%00000001 | #%10000000 ; invert d0 and set d7
24 ; .. bit0 is used by the rest of the game to check for pause
25 else zero clear ; tell the else to use bne as unconditional
26 lda GamePauseStatus ; clear bit7 so the code above will run again (residual)
27 and #%01111111 ; is not pressed
28 endif
29
30 sta GamePauseStatus
31
32 endif
33
34 Exit:
35 rts
36 .endproc
No comments:
Post a Comment