Merge pull request #183 from cassidoxa/sram_checksum

Compute and write save checksum on new file creation
This commit is contained in:
Lexi Rose
2023-02-21 15:13:49 -06:00
committed by GitHub
4 changed files with 19 additions and 7 deletions

View File

@@ -105,13 +105,11 @@ OnFileCreation:
; Set validity value and do some cleanup. Jump to checksum.
LDA.w #$55AA : STA.l FileValiditySRAM
JSL.l WriteNewFileChecksum
STZ.b Scrap00
STZ.b Scrap01
LDX.b Scrap00
LDY.w #$0000
TYA
JML.l InitializeSaveFile_build_checksum
JML.l InitializeSaveFile_done
;--------------------------------------------------------------------------------
OnFileLoad:
REP #$10 ; set 16 bit index registers

View File

@@ -175,7 +175,6 @@ macro BottomHalf(address)
endmacro
;--------------------------------------------------------------------------------
FullInventoryExternal:
LDA.l StatsLocked : BEQ + : RTL : +
PHA : PHX : PHP : JMP AddInventory_incrementCounts
;--------------------------------------------------------------------------------
AddInventory:
@@ -225,8 +224,6 @@ AddInventory:
+
.incrementCounts
LDA.l StatsLocked : BEQ + : JMP .done : +
; don't count any of this stuff
CPY.b #$20 : BNE + : JMP .itemCounts : + ; Crystal
CPY.b #$26 : BNE + : JMP .itemCounts : + ; Heart Piece Completion Heart

View File

@@ -67,6 +67,21 @@ ValidateSRAM:
SEP #$30
RTL
;--------------------------------------------------------------------------------
WriteNewFileChecksum:
LDX.w #$0000 : TXA : - ; Checksum first $04FE bytes
CLC : ADC.l CartridgeSRAM, X
INX #2
CPX.w #$04FE : BNE -
LDX.w #$0000 : - ; Checksum extended save data
CLC : ADC.l ExtendedFileNameSRAM, X
INX #2
CPX.w #$0FFE : BNE -
STA.b Scrap00
LDA.w #$5A5A
SEC : SBC.b Scrap00
STA.l InverseChecksumSRAM
RTL
;--------------------------------------------------------------------------------
ClearExtendedSaveFile:
STA.l $700400, X ; what we wrote over
STA.l $700500, X

View File

@@ -14,6 +14,7 @@ Vram_EraseTilemaps_triforce = 008333
Sound_LoadLightWorldSongBank = $008913
Sound_LoadLightWorldSongBank_do_load = $00891D
EnableForceBlank = $00893D
SaveGameFile = $00894A ; long
DungeonMask = $0098C0
DecompSwordGfx = $00D308
DecompShieldGfx = $00D348
@@ -75,6 +76,7 @@ OverworldMap_LoadSprGfx = $0ABAB9
NameFile_MakeScreenVisible = $0CD7D1
InitializeSaveFile = $0CDB3E
InitializeSaveFile_build_checksum = $0CDBC0
InitializeSaveFile_done = $0CDBDB
GetRandomInt = $0DBA71
OAM_AllocateFromRegionA = $0DBA80
OAM_AllocateFromRegionB = $0DBA84