ref: d6f20ae74619fa4b3071867016fa7ae7253df98f
parent: ce985a09a7802d90519997de032720e6c5eca6d0
author: Adelaide Walter <adelaidekwalter@gmail.com>
date: Mon Jan 8 12:13:37 EST 2018
Use BANK for hardcoded SRAM banks (except for vestigial refs to JP's banks 4-7)
--- a/engine/battle/checkbattlescene.asm
+++ b/engine/battle/checkbattlescene.asm
@@ -19,7 +19,7 @@
and a
jr nz, .from_wram
- ld a, $4
+ ld a, 4 ; MBC30 bank used by JP Crystal; inaccessible by MBC3
call GetSRAMBank
ld a, [$a60c]
ld c, a
--- a/engine/battle/core.asm
+++ b/engine/battle/core.asm
@@ -232,7 +232,7 @@
; 3c1bf
MobileFn_3c1bf: mobile
- ld a, $5
+ ld a, 5 ; MBC30 bank used by JP Crystal; inaccessible by MBC3
call GetSRAMBank
ld hl, $a89b ; s5_a89b
inc [hl]
--- a/engine/billspc.asm
+++ b/engine/billspc.asm
@@ -2104,7 +2104,7 @@
ld hl, wBillsPC_BackupScrollPosition
add [hl]
ld [CurPartyMon], a
- ld a, $1
+ ld a, BANK(sBox)
call GetSRAMBank
ld hl, sBoxSpecies
call CopySpeciesToTemp
--- a/engine/mail_2.asm
+++ b/engine/mail_2.asm
@@ -69,7 +69,7 @@
ld h, d
ld l, e
push hl
- ld a, $0
+ ld a, BANK(sPartyMail)
call GetSRAMBank
ld de, sPartyMon1MailAuthorID - sPartyMon1Mail
add hl, de
--- a/engine/menu.asm
+++ b/engine/menu.asm
@@ -730,7 +730,7 @@
ld a, [VramState]
bit 0, a
ret z
- xor a
+ xor a ; effectively ld a, BANK(sScratch)
call GetSRAMBank
hlcoord 0, 0
ld de, sScratch
@@ -738,7 +738,7 @@
call CopyBytes
call CloseSRAM
call OverworldTextModeSwitch
- xor a
+ xor a ; effectively ld a, BANK(sScratch)
call GetSRAMBank
ld hl, sScratch
decoord 0, 0
--- a/engine/mon_stats.asm
+++ b/engine/mon_stats.asm
@@ -174,7 +174,7 @@
; sBoxMon data is read directly from SRAM.
ld a, [MonType]
cp BOXMON
- ld a, 1
+ ld a, BANK(sBox)
call z, GetSRAMBank
; Attack DV
--- a/engine/mystery_gift.asm
+++ b/engine/mystery_gift.asm
@@ -1561,7 +1561,7 @@
ld a, [sCrystalData + 0]
ld [de], a
inc de
- ld a, $4
+ ld a, 4 ; MBC30 bank used by JP Crystal; inaccessible by MBC3
call GetSRAMBank
ld hl, $a603
ld bc, $8
--- a/engine/routines/emptyallsrambanks.asm
+++ b/engine/routines/emptyallsrambanks.asm
@@ -1,11 +1,11 @@
EmptyAllSRAMBanks: ; 4cf1f
- ld a, $0
+ ld a, 0
call .EmptyBank
- ld a, $1
+ ld a, 1
call .EmptyBank
- ld a, $2
+ ld a, 2
call .EmptyBank
- ld a, $3
+ ld a, 3
call .EmptyBank
ret
--- a/engine/rtc.asm
+++ b/engine/rtc.asm
@@ -146,7 +146,7 @@
farcall ClearDailyTimers
farcall Function170923
; mobile
- ld a, $5
+ ld a, 5 ; MBC30 bank used by JP Crystal; inaccessible by MBC3
call GetSRAMBank
ld a, [$aa8c]
inc a
--- a/engine/save.asm
+++ b/engine/save.asm
@@ -418,7 +418,7 @@
Function14d18: ; 14d18
; XXX
; copy .Data to SRA4:a007
- ld a, $4
+ ld a, 4 ; MBC30 bank used by JP Crystal; inaccessible by MBC3
call GetSRAMBank
ld hl, .Data
ld de, $a007
@@ -454,7 +454,7 @@
Function14d6c: ; 14d6c
; XXX
- ld a, $4
+ ld a, 4 ; MBC30 bank used by JP Crystal; inaccessible by MBC3
call GetSRAMBank
ld a, [$a60b]
ld b, $0
@@ -471,7 +471,7 @@
Function14d83: ; 14d83
; XXX
- ld a, $4
+ ld a, 4 ; MBC30 bank used by JP Crystal; inaccessible by MBC3
call GetSRAMBank
xor a
ld [$a60c], a
@@ -482,7 +482,7 @@
Function14d93: ; 14d93
; XXX
- ld a, $7
+ ld a, 7 ; MBC30 bank used by JP Crystal; inaccessible by MBC3
call GetSRAMBank
xor a
ld [$a000], a