[go: nahoru, domu]

Skip to content

Commit

Permalink
save-highscores: only saves when start is pressed, moved code into de…
Browse files Browse the repository at this point in the history
…faultHighScoresTable
  • Loading branch information
kirjavascript committed Dec 28, 2020
1 parent 235c267 commit fcffd0c
Showing 1 changed file with 19 additions and 27 deletions.
46 changes: 19 additions & 27 deletions save-highscores.s
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,21 @@

SRAM := $6000

; header patch to enable SRAM

.fileopt comment, "ips: 0 INES_HEADER_MOD"
.segment "INES_HEADER_MOD_HDR"
.byte 0
.dbyt 6 ; header offset
.dbyt 1 ; byte sized
.segment "INES_HEADER_MOD"

INES_MAPPER = 1 ; 0 = NROM
INES_MIRROR = 0 ; 0 = horizontal mirroring, 1 = vertical mirroring
INES_SRAM = 1 ; 1 = battery backed SRAM at $6000-7FFF

.byte INES_MIRROR | (INES_SRAM << 1) | ((INES_MAPPER & $f) << 4)

; patch to load from SRAM (and use a length instead of a terminator)

.segment "initHighScoreTable_patch"
Expand All @@ -12,26 +27,19 @@ SRAM := $6000
initHighScoreTable:
lda SRAM,x
cpx #$50
beq continueColdBootInit
sta highScoreNames,x
inx
jmp initHighScoreTable

continueColdBootInit:

; start button patch to add saving

.segment "saveHighscoreStartPressed_patch"
ips_segment "saveHighscoreStartPressed_patch",$A337
ips_segment "saveHighscoreStartPressed_patch",$A295

; saveHighscoreStartPressed_patch:
jsr saveHighScores

jmp saveHighScores

; routine for storing the high score data

.segment "saveHighScores"
ips_segment "saveHighScores",unreferenced_data4
ips_segment "saveHighScores",defaultHighScoresTable

saveHighScores:
ldx #$00
Expand All @@ -41,20 +49,4 @@ saveHighScores:
inx
cpx #$51
bne @loop
jsr updateAudioWaitForNmiAndResetOamStaging
rts

; header patch to enable SRAM

.fileopt comment, "ips: 0 INES_HEADER_MOD"
.segment "INES_HEADER_MOD_HDR"
.byte 0
.dbyt 6 ; header offset
.dbyt 1 ; byte sized
.segment "INES_HEADER_MOD"

INES_MAPPER = 1 ; 0 = NROM
INES_MIRROR = 0 ; 0 = horizontal mirroring, 1 = vertical mirroring
INES_SRAM = 1 ; 1 = battery backed SRAM at $6000-7FFF

.byte INES_MIRROR | (INES_SRAM << 1) | ((INES_MAPPER & $f) << 4)
jmp $A337

0 comments on commit fcffd0c

Please sign in to comment.