Add support for pausing the resuming the game. Now, any key pressed during a game pauses the game. Pressing q from the paused game will quit the game and any other key will resume the game. So, quiting with a game in progress takes two key presses. One key press to pause the game and then the user must press q or Q to actually quit.

This commit is contained in:
Jeremy Rand 2020-12-29 00:00:39 -05:00
parent 24bce50a6e
commit 10a1d075fd
4 changed files with 260 additions and 9 deletions

View File

@ -203,7 +203,161 @@ startLevel entry
pauseGame entry pauseGame entry
; TODO - Write this code... jsl pauseSound
ldx #GAME_NUM_TILES_WIDE*4+2
_overwriteTile TILE_EMPTY
_overwriteTile TILE_EMPTY
_overwriteTile TILE_EMPTY
_overwriteTile TILE_EMPTY
_overwriteTile TILE_EMPTY
_overwriteTile TILE_EMPTY
_overwriteTile TILE_EMPTY
_overwriteTile TILE_EMPTY
_overwriteTile TILE_EMPTY
_overwriteTile TILE_EMPTY
_overwriteTile TILE_EMPTY
_overwriteTile TILE_EMPTY
_overwriteTile TILE_EMPTY
_overwriteTile TILE_EMPTY
_overwriteTile TILE_EMPTY
_overwriteTile TILE_EMPTY
_overwriteTile TILE_EMPTY
_overwriteTile TILE_EMPTY
_overwriteTile TILE_EMPTY
_overwriteTile TILE_EMPTY
_overwriteTile TILE_EMPTY
ldx #GAME_NUM_TILES_WIDE*6+2
_overwriteTile TILE_EMPTY
_overwriteTile TILE_EMPTY
_overwriteTile TILE_EMPTY
_overwriteTile TILE_EMPTY
_overwriteTile TILE_EMPTY
_overwriteTile TILE_EMPTY
_overwriteTile TILE_EMPTY
_overwriteTile TILE_LETTER_P
_overwriteTile TILE_LETTER_A
_overwriteTile TILE_LETTER_U
_overwriteTile TILE_LETTER_S
_overwriteTile TILE_LETTER_E
_overwriteTile TILE_LETTER_D
_overwriteTile TILE_EMPTY
_overwriteTile TILE_EMPTY
_overwriteTile TILE_EMPTY
_overwriteTile TILE_EMPTY
_overwriteTile TILE_EMPTY
_overwriteTile TILE_EMPTY
_overwriteTile TILE_EMPTY
_overwriteTile TILE_EMPTY
ldx #GAME_NUM_TILES_WIDE*8+2
_overwriteTile TILE_EMPTY
_overwriteTile TILE_EMPTY
_overwriteTile TILE_EMPTY
_overwriteTile TILE_EMPTY
_overwriteTile TILE_EMPTY
_overwriteTile TILE_EMPTY
_overwriteTile TILE_EMPTY
_overwriteTile TILE_EMPTY
_overwriteTile TILE_EMPTY
_overwriteTile TILE_EMPTY
_overwriteTile TILE_EMPTY
_overwriteTile TILE_EMPTY
_overwriteTile TILE_EMPTY
_overwriteTile TILE_EMPTY
_overwriteTile TILE_EMPTY
_overwriteTile TILE_EMPTY
_overwriteTile TILE_EMPTY
_overwriteTile TILE_EMPTY
_overwriteTile TILE_EMPTY
_overwriteTile TILE_EMPTY
_overwriteTile TILE_EMPTY
ldx #GAME_NUM_TILES_WIDE*10+2
_overwriteTile TILE_EMPTY
_overwriteTile TILE_EMPTY
_overwriteTile TILE_EMPTY
_overwriteTile TILE_LETTER_P
_overwriteTile TILE_LETTER_R
_overwriteTile TILE_LETTER_E
_overwriteTile TILE_LETTER_S
_overwriteTile TILE_LETTER_S
_overwriteTile TILE_EMPTY
_overwriteTile TILE_LETTER_Q
_overwriteTile TILE_EMPTY
_overwriteTile TILE_LETTER_T
_overwriteTile TILE_LETTER_O
_overwriteTile TILE_EMPTY
_overwriteTile TILE_LETTER_Q
_overwriteTile TILE_LETTER_U
_overwriteTile TILE_LETTER_I
_overwriteTile TILE_LETTER_T
_overwriteTile TILE_EMPTY
_overwriteTile TILE_EMPTY
_overwriteTile TILE_EMPTY
ldx #GAME_NUM_TILES_WIDE*12+2
_overwriteTile TILE_EMPTY
_overwriteTile TILE_LETTER_O
_overwriteTile TILE_LETTER_T
_overwriteTile TILE_LETTER_H
_overwriteTile TILE_LETTER_E
_overwriteTile TILE_LETTER_R
_overwriteTile TILE_EMPTY
_overwriteTile TILE_LETTER_K
_overwriteTile TILE_LETTER_E
_overwriteTile TILE_LETTER_Y
_overwriteTile TILE_EMPTY
_overwriteTile TILE_LETTER_T
_overwriteTile TILE_LETTER_O
_overwriteTile TILE_EMPTY
_overwriteTile TILE_LETTER_R
_overwriteTile TILE_LETTER_E
_overwriteTile TILE_LETTER_S
_overwriteTile TILE_LETTER_U
_overwriteTile TILE_LETTER_M
_overwriteTile TILE_LETTER_E
_overwriteTile TILE_EMPTY
ldx #GAME_NUM_TILES_WIDE*14+2
_overwriteTile TILE_EMPTY
_overwriteTile TILE_EMPTY
_overwriteTile TILE_EMPTY
_overwriteTile TILE_EMPTY
_overwriteTile TILE_EMPTY
_overwriteTile TILE_EMPTY
_overwriteTile TILE_EMPTY
_overwriteTile TILE_EMPTY
_overwriteTile TILE_EMPTY
_overwriteTile TILE_EMPTY
_overwriteTile TILE_EMPTY
_overwriteTile TILE_EMPTY
_overwriteTile TILE_EMPTY
_overwriteTile TILE_EMPTY
_overwriteTile TILE_EMPTY
_overwriteTile TILE_EMPTY
_overwriteTile TILE_EMPTY
_overwriteTile TILE_EMPTY
_overwriteTile TILE_EMPTY
_overwriteTile TILE_EMPTY
_overwriteTile TILE_EMPTY
short i,m
pauseGame_loop anop
lda >KEYBOARD
bpl pauseGame_loop
sta >KEYBOARD_STROBE
long i,m
and #$7f
cmp #'q'
beq pauseGame_quit
cmp #'Q'
beq pauseGame_quit
jsl unpauseSound
rtl
pauseGame_quit anop
stz shouldQuit
rtl rtl
@ -239,18 +393,14 @@ checkKey_loop2 anop
sta >KEYBOARD_STROBE sta >KEYBOARD_STROBE
long i,m long i,m
and #$007f and #$007f
ldx gameRunning
beq checkKey_pause
cmp #'q' cmp #'q'
beq checkKey_quit beq checkKey_quit
cmp #'Q' cmp #'Q'
beq checkKey_quit beq checkKey_quit
cmp #'p'
beq checkKey_pause
cmp #'P'
beq checkKey_pause
cmp #$001b
beq checkKey_pause
cmp #'1' cmp #'1'
beq checkKey_game beq checkKey_game

View File

@ -1154,6 +1154,7 @@ startFleaSound_doIt anop
lda #SOUND_REG_VOLUME+FLEA_OSC_NUM lda #SOUND_REG_VOLUME+FLEA_OSC_NUM
sta >SOUND_ADDR_LOW sta >SOUND_ADDR_LOW
lda tileRightVolume,x lda tileRightVolume,x
sta fleaVolume
sta >SOUND_DATA_REG sta >SOUND_DATA_REG
sta >SOUND_DATA_REG sta >SOUND_DATA_REG
eor #$ff eor #$ff
@ -1206,10 +1207,97 @@ stopFleaSound_doIt anop
long m long m
rtl rtl
pauseSound entry
short m
lda >SOUND_SYSTEM_VOLUME
and #$0f
ora #$20
sta >SOUND_CONTROL_REG
lda #SOUND_REG_VOLUME+SEGMENTS_OSC_NUM
sta >SOUND_ADDR_LOW
lda #0
sta >SOUND_DATA_REG
sta >SOUND_DATA_REG
sta >SOUND_DATA_REG
sta >SOUND_DATA_REG
lda #SOUND_REG_VOLUME+SPIDER_OSC_NUM
sta >SOUND_ADDR_LOW
lda #$0
sta >SOUND_DATA_REG
sta >SOUND_DATA_REG
sta >SOUND_DATA_REG
sta >SOUND_DATA_REG
lda #SOUND_REG_VOLUME+SCORPION_OSC_NUM
sta >SOUND_ADDR_LOW
lda #0
sta >SOUND_DATA_REG
sta >SOUND_DATA_REG
sta >SOUND_DATA_REG
sta >SOUND_DATA_REG
lda #SOUND_REG_VOLUME+FLEA_OSC_NUM
sta >SOUND_ADDR_LOW
lda #$0
sta >SOUND_DATA_REG
sta >SOUND_DATA_REG
sta >SOUND_DATA_REG
sta >SOUND_DATA_REG
long m
rtl
unpauseSound entry
lda segmentSoundIsPlaying
bne unpauseSound_skipSegment
short m
lda >SOUND_SYSTEM_VOLUME
and #$0f
ora #$20
sta >SOUND_CONTROL_REG
lda #SOUND_REG_VOLUME+SEGMENTS_OSC_NUM
sta >SOUND_ADDR_LOW
lda #SEGMENTS_VOLUME
sta >SOUND_DATA_REG
sta >SOUND_DATA_REG
sta >SOUND_DATA_REG
sta >SOUND_DATA_REG
long m
unpauseSound_skipSegment anop
lda fleaSoundIsPlaying
bne unpauseSound_skipFlea
short m
lda >SOUND_SYSTEM_VOLUME
and #$0f
ora #$20
sta >SOUND_CONTROL_REG
lda #SOUND_REG_VOLUME+FLEA_OSC_NUM
sta >SOUND_ADDR_LOW
lda fleaVolume
sta >SOUND_DATA_REG
sta >SOUND_DATA_REG
eor #$ff
sta >SOUND_DATA_REG
sta >SOUND_DATA_REG
long m
unpauseSound_skipFlea anop
rtl
bonusSoundOscReg dc i2'SOUND_REG_CONTROL+BONUS_OSC_NUM' bonusSoundOscReg dc i2'SOUND_REG_CONTROL+BONUS_OSC_NUM'
fleaSoundIsPlaying dc i2'1' fleaSoundIsPlaying dc i2'1'
fleaSoundFreqOffset dc i2'0' fleaSoundFreqOffset dc i2'0'
fleaVolume dc i2'0'
segmentSoundIsPlaying dc i2'1' segmentSoundIsPlaying dc i2'1'
spiderSoundIsPlaying dc i2'1' spiderSoundIsPlaying dc i2'1'
scorpionSoundIsPlaying dc i2'1' scorpionSoundIsPlaying dc i2'1'

View File

@ -127,6 +127,20 @@ _dirtyGameTile_skip&SYSCNT anop
_dirtyNonGameTile_skip&SYSCNT anop _dirtyNonGameTile_skip&SYSCNT anop
mend mend
macro
_overwriteTile &type
lda #TILE_STATE_DIRTY
sta tileDirty,x
lda #&type
ldy tileScreenOffset,x
phx
jsl drawTile
plx
inx
inx
mend
; Update the score ; Update the score

View File

@ -3,7 +3,6 @@ TODO
* Implement a high score list and save the high scores across restarts * Implement a high score list and save the high scores across restarts
* Look at supporting a global high score list for systems with an Internet connection * Look at supporting a global high score list for systems with an Internet connection
* Implement the code to support pausing the game
* Implement the code for supporting a two player game * Implement the code for supporting a two player game
* Look at supporting Versions in order to support automatic SW upgrades * Look at supporting Versions in order to support automatic SW upgrades
* So much more. * So much more.