Move non-game code out of the main segment to make more room for more high score code.

This commit is contained in:
Jeremy Rand 2021-06-28 22:33:01 -04:00
parent 08be64a61c
commit 701585df1a
4 changed files with 283 additions and 264 deletions

View File

@ -18,6 +18,7 @@
; more on-screen action. ; more on-screen action.
case on case on
datachk off
mcopy game.macros mcopy game.macros
keep game keep game
@ -344,7 +345,7 @@ updateGameState_doneBonus anop
stz isSinglePlayer stz isSinglePlayer
bra updateGameState_twoPlayer bra updateGameState_twoPlayer
updateGameState_isSinglePlayer anop updateGameState_isSinglePlayer anop
jmp setGameNotRunning jmp >setGameNotRunning
updateGameState_notHighScore anop updateGameState_notHighScore anop
lda isSinglePlayer lda isSinglePlayer
beq updateGameState_isSinglePlayer beq updateGameState_isSinglePlayer
@ -514,6 +515,94 @@ copyFromPlayer2Tiles_skip anop
rtl rtl
checkKeyboard entry
checkKey_loop2 anop
short i,m
lda >KEYBOARD
bpl checkKey_done
sta >KEYBOARD_STROBE
long i,m
and #$007f
ldx gameState
bne checkKey_pause
cmp #'q'
beq checkKey_quit
cmp #'Q'
beq checkKey_quit
cmp #'1'
beq checkKey_game
cmp #'2'
beq checkKey_game
cmp #'s'
beq checkKey_swapStereo
cmp #'S'
beq checkKey_swapStereo
checkKey_done anop
long i,m
rtl
checkKey_pause anop
jmp >pauseGame
checkKey_quit anop
stz shouldQuit
rtl
checkKey_game anop
sec
sbc #'1'
jmp startGame
checkKey_swapStereo anop
jsl swapStereoSettings
jmp >staticGameBoard
waitForBeam entry
beamLoop anop
lda >VERTICAL_COUNTER ; load the counter value
and #$80ff ; mask out the VBL bits
asl a ; shift the word around
adc #0 ; move MSB -> LSB
cmp #$1c8
bge beamLoop
rtl
waitForVbl entry
vblLoop1 anop
short m
lda #$fe
cmp >READ_VBL
bpl vblLoop1
vblLoop2 anop
cmp >READ_VBL
bmi vblLoop2
long m
rtl
borderColour dc i2'0'
frameCount dc i2'0'
shouldPreloadSound dc i2'0'
highScoreCountdown dc i2'0'
end
gameExtras start extraSeg
using globalData
using tileData
using playerData
overwriteGameTile entry overwriteGameTile entry
phy phy
tay tay
@ -527,8 +616,7 @@ overwriteGameTile entry
inx inx
inx inx
ply ply
rts rtl
pauseGame entry pauseGame entry
jsl pauseSound jsl pauseSound
@ -698,9 +786,9 @@ setGameTile entry
setGameTile_skip anop setGameTile_skip anop
inx inx
inx inx
rts rtl
; This must come before staticGameBoard because it falls into it.
setGameNotRunning entry setGameNotRunning entry
lda #GAME_STATE_NOT_RUNNING lda #GAME_STATE_NOT_RUNNING
sta gameState sta gameState
@ -710,9 +798,7 @@ setGameNotRunning entry
jsl fleaInitLevel jsl fleaInitLevel
jsl addRandomMushrooms jsl addRandomMushrooms
stz displayGlobalHighScores stz displayGlobalHighScores
jmp staticGameBoard ; Fall through into staticGameBoard...
staticGameBoard entry staticGameBoard entry
lda #TILE_PLAYER lda #TILE_PLAYER
sta tileType+RHS_FIRST_TILE_OFFSET-GAME_NUM_TILES_WIDE-1 sta tileType+RHS_FIRST_TILE_OFFSET-GAME_NUM_TILES_WIDE-1
@ -1153,55 +1239,6 @@ displayConnectionString entry
rtl rtl
checkKeyboard entry
checkKey_loop2 anop
short i,m
lda >KEYBOARD
bpl checkKey_done
sta >KEYBOARD_STROBE
long i,m
and #$007f
ldx gameState
bne checkKey_pause
cmp #'q'
beq checkKey_quit
cmp #'Q'
beq checkKey_quit
cmp #'1'
beq checkKey_game
cmp #'2'
beq checkKey_game
cmp #'s'
beq checkKey_swapStereo
cmp #'S'
beq checkKey_swapStereo
checkKey_done anop
long i,m
rtl
checkKey_pause anop
jmp pauseGame
checkKey_quit anop
stz shouldQuit
rtl
checkKey_game anop
sec
sbc #'1'
jmp startGame
checkKey_swapStereo anop
jsl swapStereoSettings
jmp staticGameBoard
waitForKey entry waitForKey entry
short m short m
waitForKey_loop anop waitForKey_loop anop
@ -1213,35 +1250,4 @@ waitForKey_loop anop
rtl rtl
waitForBeam entry
beamLoop anop
lda >VERTICAL_COUNTER ; load the counter value
and #$80ff ; mask out the VBL bits
asl a ; shift the word around
adc #0 ; move MSB -> LSB
cmp #$1c8
bge beamLoop
rtl
waitForVbl entry
vblLoop1 anop
short m
lda #$fe
cmp >READ_VBL
bpl vblLoop1
vblLoop2 anop
cmp >READ_VBL
bmi vblLoop2
long m
rtl
shouldQuit dc i2'1'
borderColour dc i2'0'
frameCount dc i2'0'
shouldPreloadSound dc i2'0'
displayGlobalHighScores dc i2'0'
highScoreCountdown dc i2'0'
end end

View File

@ -137,14 +137,14 @@ _dirtyNonGameTile_skip&SYSCNT anop
macro macro
_overwriteGameTile &type _overwriteGameTile &type
lda #&type lda #&type
jsr overwriteGameTile jsl overwriteGameTile
mend mend
macro macro
_setGameTile &type _setGameTile &type
lda #&type lda #&type
jsr setGameTile jsl setGameTile
mend mend
@ -153,70 +153,70 @@ _dirtyNonGameTile_skip&SYSCNT anop
ldy #SETTINGS_HIGH_SCORE_OFFSET+HIGH_SCORE_SCORE_TEXT_OFFSET+&nthScore*SETTINGS_HIGH_SCORE_SIZE ldy #SETTINGS_HIGH_SCORE_OFFSET+HIGH_SCORE_SCORE_TEXT_OFFSET+&nthScore*SETTINGS_HIGH_SCORE_SIZE
lda settings,y lda settings,y
jsl asciiToTileType jsl asciiToTileType
jsr setGameTile jsl setGameTile
iny iny
lda settings,y lda settings,y
jsl asciiToTileType jsl asciiToTileType
jsr setGameTile jsl setGameTile
iny iny
lda settings,y lda settings,y
jsl asciiToTileType jsl asciiToTileType
jsr setGameTile jsl setGameTile
iny iny
lda settings,y lda settings,y
jsl asciiToTileType jsl asciiToTileType
jsr setGameTile jsl setGameTile
iny iny
lda settings,y lda settings,y
jsl asciiToTileType jsl asciiToTileType
jsr setGameTile jsl setGameTile
iny iny
lda settings,y lda settings,y
jsl asciiToTileType jsl asciiToTileType
jsr setGameTile jsl setGameTile
iny iny
lda settings,y lda settings,y
jsl asciiToTileType jsl asciiToTileType
jsr setGameTile jsl setGameTile
iny iny
lda settings,y lda settings,y
jsl asciiToTileType jsl asciiToTileType
jsr setGameTile jsl setGameTile
iny iny
lda settings,y lda settings,y
jsl asciiToTileType jsl asciiToTileType
jsr setGameTile jsl setGameTile
iny iny
lda settings,y lda settings,y
jsl asciiToTileType jsl asciiToTileType
jsr setGameTile jsl setGameTile
lda #TILE_EMPTY lda #TILE_EMPTY
jsr setGameTile jsl setGameTile
iny iny
lda settings,y lda settings,y
jsl asciiToTileType jsl asciiToTileType
jsr setGameTile jsl setGameTile
iny iny
lda settings,y lda settings,y
jsl asciiToTileType jsl asciiToTileType
jsr setGameTile jsl setGameTile
iny iny
lda settings,y lda settings,y
jsl asciiToTileType jsl asciiToTileType
jsr setGameTile jsl setGameTile
mend mend
@ -225,70 +225,70 @@ _dirtyNonGameTile_skip&SYSCNT anop
ldy #2+&nthScore*SETTINGS_HIGH_SCORE_SIZE ldy #2+&nthScore*SETTINGS_HIGH_SCORE_SIZE
lda highScoreResponse,y lda highScoreResponse,y
jsl asciiToTileType jsl asciiToTileType
jsr setGameTile jsl setGameTile
iny iny
lda highScoreResponse,y lda highScoreResponse,y
jsl asciiToTileType jsl asciiToTileType
jsr setGameTile jsl setGameTile
iny iny
lda highScoreResponse,y lda highScoreResponse,y
jsl asciiToTileType jsl asciiToTileType
jsr setGameTile jsl setGameTile
iny iny
lda highScoreResponse,y lda highScoreResponse,y
jsl asciiToTileType jsl asciiToTileType
jsr setGameTile jsl setGameTile
iny iny
lda highScoreResponse,y lda highScoreResponse,y
jsl asciiToTileType jsl asciiToTileType
jsr setGameTile jsl setGameTile
iny iny
lda highScoreResponse,y lda highScoreResponse,y
jsl asciiToTileType jsl asciiToTileType
jsr setGameTile jsl setGameTile
iny iny
lda highScoreResponse,y lda highScoreResponse,y
jsl asciiToTileType jsl asciiToTileType
jsr setGameTile jsl setGameTile
iny iny
lda highScoreResponse,y lda highScoreResponse,y
jsl asciiToTileType jsl asciiToTileType
jsr setGameTile jsl setGameTile
iny iny
lda highScoreResponse,y lda highScoreResponse,y
jsl asciiToTileType jsl asciiToTileType
jsr setGameTile jsl setGameTile
iny iny
lda highScoreResponse,y lda highScoreResponse,y
jsl asciiToTileType jsl asciiToTileType
jsr setGameTile jsl setGameTile
lda #TILE_EMPTY lda #TILE_EMPTY
jsr setGameTile jsl setGameTile
iny iny
lda highScoreResponse,y lda highScoreResponse,y
jsl asciiToTileType jsl asciiToTileType
jsr setGameTile jsl setGameTile
iny iny
lda highScoreResponse,y lda highScoreResponse,y
jsl asciiToTileType jsl asciiToTileType
jsr setGameTile jsl setGameTile
iny iny
lda highScoreResponse,y lda highScoreResponse,y
jsl asciiToTileType jsl asciiToTileType
jsr setGameTile jsl setGameTile
mend mend

View File

@ -193,6 +193,9 @@ backupStack dc i2'0'
collision dc i2'0' collision dc i2'0'
collisionAddr dc i2'0' collisionAddr dc i2'0'
numSegments dc i2'0' numSegments dc i2'0'
displayGlobalHighScores dc i2'0'
shouldQuit dc i2'1'
scoreIndex dc i2'0'
tileJumpTable dc a4'solid0' tileJumpTable dc a4'solid0'

View File

@ -8,6 +8,7 @@
case on case on
datachk off
mcopy score.macros mcopy score.macros
keep score keep score
@ -16,78 +17,6 @@ score start
using tileData using tileData
updateHighScore entry
ldx #HIGH_SCORE_ONES_OFFSET
lda settings+SETTINGS_HIGH_SCORE_OFFSET+HIGH_SCORE_SCORE_TEXT_OFFSET+9
jsl asciiToTileType
sta tileType,x
_dirtyNonGameTile
dex
dex
lda settings+SETTINGS_HIGH_SCORE_OFFSET+HIGH_SCORE_SCORE_TEXT_OFFSET+8
jsl asciiToTileType
sta tileType,x
_dirtyNonGameTile
dex
dex
lda settings+SETTINGS_HIGH_SCORE_OFFSET+HIGH_SCORE_SCORE_TEXT_OFFSET+7
jsl asciiToTileType
sta tileType,x
_dirtyNonGameTile
dex
dex
lda settings+SETTINGS_HIGH_SCORE_OFFSET+HIGH_SCORE_SCORE_TEXT_OFFSET+6
jsl asciiToTileType
sta tileType,x
_dirtyNonGameTile
dex
dex
lda settings+SETTINGS_HIGH_SCORE_OFFSET+HIGH_SCORE_SCORE_TEXT_OFFSET+5
jsl asciiToTileType
sta tileType,x
_dirtyNonGameTile
dex
dex
lda settings+SETTINGS_HIGH_SCORE_OFFSET+HIGH_SCORE_SCORE_TEXT_OFFSET+4
jsl asciiToTileType
sta tileType,x
_dirtyNonGameTile
dex
dex
lda settings+SETTINGS_HIGH_SCORE_OFFSET+HIGH_SCORE_SCORE_TEXT_OFFSET+3
jsl asciiToTileType
sta tileType,x
_dirtyNonGameTile
dex
dex
lda settings+SETTINGS_HIGH_SCORE_OFFSET+HIGH_SCORE_SCORE_TEXT_OFFSET+2
jsl asciiToTileType
sta tileType,x
_dirtyNonGameTile
dex
dex
lda settings+SETTINGS_HIGH_SCORE_OFFSET+HIGH_SCORE_SCORE_TEXT_OFFSET+1
jsl asciiToTileType
sta tileType,x
_dirtyNonGameTile
dex
dex
lda settings+SETTINGS_HIGH_SCORE_OFFSET+HIGH_SCORE_SCORE_TEXT_OFFSET
jsl asciiToTileType
sta tileType,x
_dirtyNonGameTile
rtl
scoreStartGame entry scoreStartGame entry
stz gameScore stz gameScore
stz gameScore+2 stz gameScore+2
@ -380,6 +309,90 @@ scoreAddOneThousand_skipZeroHundreds anop
jmp scoreAddOneToTile jmp scoreAddOneToTile
end
scoreExtras start extraSeg
using globalData
using tileData
using playerData
updateHighScore entry
ldx #HIGH_SCORE_ONES_OFFSET
lda settings+SETTINGS_HIGH_SCORE_OFFSET+HIGH_SCORE_SCORE_TEXT_OFFSET+9
jsl asciiToTileType
sta tileType,x
_dirtyNonGameTile
dex
dex
lda settings+SETTINGS_HIGH_SCORE_OFFSET+HIGH_SCORE_SCORE_TEXT_OFFSET+8
jsl asciiToTileType
sta tileType,x
_dirtyNonGameTile
dex
dex
lda settings+SETTINGS_HIGH_SCORE_OFFSET+HIGH_SCORE_SCORE_TEXT_OFFSET+7
jsl asciiToTileType
sta tileType,x
_dirtyNonGameTile
dex
dex
lda settings+SETTINGS_HIGH_SCORE_OFFSET+HIGH_SCORE_SCORE_TEXT_OFFSET+6
jsl asciiToTileType
sta tileType,x
_dirtyNonGameTile
dex
dex
lda settings+SETTINGS_HIGH_SCORE_OFFSET+HIGH_SCORE_SCORE_TEXT_OFFSET+5
jsl asciiToTileType
sta tileType,x
_dirtyNonGameTile
dex
dex
lda settings+SETTINGS_HIGH_SCORE_OFFSET+HIGH_SCORE_SCORE_TEXT_OFFSET+4
jsl asciiToTileType
sta tileType,x
_dirtyNonGameTile
dex
dex
lda settings+SETTINGS_HIGH_SCORE_OFFSET+HIGH_SCORE_SCORE_TEXT_OFFSET+3
jsl asciiToTileType
sta tileType,x
_dirtyNonGameTile
dex
dex
lda settings+SETTINGS_HIGH_SCORE_OFFSET+HIGH_SCORE_SCORE_TEXT_OFFSET+2
jsl asciiToTileType
sta tileType,x
_dirtyNonGameTile
dex
dex
lda settings+SETTINGS_HIGH_SCORE_OFFSET+HIGH_SCORE_SCORE_TEXT_OFFSET+1
jsl asciiToTileType
sta tileType,x
_dirtyNonGameTile
dex
dex
lda settings+SETTINGS_HIGH_SCORE_OFFSET+HIGH_SCORE_SCORE_TEXT_OFFSET
jsl asciiToTileType
sta tileType,x
_dirtyNonGameTile
rtl
checkHighScore entry checkHighScore entry
ldy #0 ldy #0
checkHighScore_loop anop checkHighScore_loop anop
@ -740,7 +753,7 @@ checkHighScore_isValid anop
sta settings+SETTINGS_HIGH_SCORE_OFFSET+HIGH_SCORE_WHO_OFFSET,y sta settings+SETTINGS_HIGH_SCORE_OFFSET+HIGH_SCORE_WHO_OFFSET,y
iny iny
jsl asciiToTileType jsl asciiToTileType
jsr overwriteGameTile jsl overwriteGameTile
_overwriteGameTile TILE_SOLID2 _overwriteGameTile TILE_SOLID2
dex dex
dex dex
@ -867,7 +880,4 @@ uploadSpin3 entry
_overwriteGameTile TILE_SOLID1 _overwriteGameTile TILE_SOLID1
rtl rtl
scoreIndex dc i2'0'
end end