Document hardcoded SRAM addresses.

This commit is contained in:
Adelaide Walter 2018-01-08 22:48:58 -05:00
parent d6f20ae746
commit 94f32db7bc
5 changed files with 28 additions and 17 deletions

View File

@ -21,7 +21,7 @@ CheckBattleScene: ; 4ea44
ld a, 4 ; MBC30 bank used by JP Crystal; inaccessible by MBC3
call GetSRAMBank
ld a, [$a60c]
ld a, [$a60c] ; address of MBC30 bank
ld c, a
call CloseSRAM

View File

@ -234,7 +234,7 @@ BattleTurn: ; 3c12f
MobileFn_3c1bf: mobile
ld a, 5 ; MBC30 bank used by JP Crystal; inaccessible by MBC3
call GetSRAMBank
ld hl, $a89b ; s5_a89b
ld hl, $a89b ; address of MBC30 bank
inc [hl]
jr nz, .finish
dec hl

View File

@ -1563,10 +1563,10 @@ Function10578c: ; 10578c (41:578c)
inc de
ld a, 4 ; MBC30 bank used by JP Crystal; inaccessible by MBC3
call GetSRAMBank
ld hl, $a603
ld hl, $a603 ; address of MBC30 bank
ld bc, $8
call CopyBytes
ld hl, $a007
ld hl, $a007 ; address of MBC30 bank
ld bc, $c
call CopyBytes
call CloseSRAM

View File

@ -148,12 +148,12 @@ Function140ae: ; 140ae
; mobile
ld a, 5 ; MBC30 bank used by JP Crystal; inaccessible by MBC3
call GetSRAMBank
ld a, [$aa8c]
ld a, [$aa8c] ; address of MBC30 bank
inc a
ld [$aa8c], a
ld a, [$b2fa]
ld [$aa8c], a ; address of MBC30 bank
ld a, [$b2fa] ; address of MBC30 bank
inc a
ld [$b2fa], a
ld [$b2fa], a ; address of MBC30 bank
call CloseSRAM
ret

View File

@ -421,7 +421,7 @@ Function14d18: ; 14d18
ld a, 4 ; MBC30 bank used by JP Crystal; inaccessible by MBC3
call GetSRAMBank
ld hl, .Data
ld de, $a007
ld de, $a007 ; address of MBC30 bank
ld bc, .DataEnd - .Data
call CopyBytes
jp CloseSRAM
@ -456,7 +456,7 @@ Function14d6c: ; 14d6c
; XXX
ld a, 4 ; MBC30 bank used by JP Crystal; inaccessible by MBC3
call GetSRAMBank
ld a, [$a60b]
ld a, [$a60b] ; address of MBC30 bank
ld b, $0
and a
jr z, .ok
@ -464,7 +464,7 @@ Function14d6c: ; 14d6c
.ok
ld a, b
ld [$a60b], a
ld [$a60b], a ; address of MBC30 bank
call CloseSRAM
ret
; 14d83
@ -474,8 +474,8 @@ Function14d83: ; 14d83
ld a, 4 ; MBC30 bank used by JP Crystal; inaccessible by MBC3
call GetSRAMBank
xor a
ld [$a60c], a
ld [$a60d], a
ld [$a60c], a ; address of MBC30 bank
ld [$a60d], a ; address of MBC30 bank
call CloseSRAM
ret
; 14d93
@ -485,7 +485,7 @@ Function14d93: ; 14d93
ld a, 7 ; MBC30 bank used by JP Crystal; inaccessible by MBC3
call GetSRAMBank
xor a
ld [$a000], a
ld [$a000], a ; address of MBC30 bank
call CloseSRAM
ret
; 14da0
@ -873,6 +873,11 @@ VerifyBackupChecksum: ; 1507c (5:507c)
_SaveData: ; 1509a
; This is called within two scenarios:
; a) ErasePreviousSave (the process of erasing the save from a previous game file)
; b) unused mobile functionality
; It is not part of a regular save.
ld a, BANK(sCrystalData)
call GetSRAMBank
ld hl, wCrystalData
@ -880,7 +885,11 @@ _SaveData: ; 1509a
ld bc, wCrystalDataEnd - wCrystalData
call CopyBytes
; XXX SRAM bank 7
; This block originally had some mobile functionality, but since we're still in
; BANK(sCrystalData), it instead overwrites the sixteen EventFlags starting at 1:a603 with
; garbage from wd479. This isn't an issue, since ErasePreviousSave is followed by a regular
; save that unwrites the garbage.
ld hl, wd479
ld a, [hli]
ld [$a60e + 0], a
@ -897,8 +906,10 @@ _LoadData: ; 150b9
ld de, wCrystalData
ld bc, wCrystalDataEnd - wCrystalData
call CopyBytes
; XXX SRAM bank 7
; This block originally had some mobile functionality to mirror _SaveData above, but instead it
; (harmlessly) writes the aforementioned EventFlags to the unused wd479.
ld hl, wd479
ld a, [$a60e + 0]
ld [hli], a