aboutsummaryrefslogtreecommitdiffstats
path: root/home/bankswitch2.asm
diff options
context:
space:
mode:
authorRangi <remy.oukaour+rangi42@gmail.com>2020-11-04 15:16:20 -0500
committerRangi <remy.oukaour+rangi42@gmail.com>2020-11-04 19:44:31 -0500
commitaae999f72bd81a3156c7e00da4ebf499f52da5a6 (patch)
tree32fef70a31af3a0b5ad2b0d34042c312574fb42d /home/bankswitch2.asm
parentMerge branch 'master' of https://github.com/pret/pokered (diff)
downloadpokeyellow-aae999f72bd81a3156c7e00da4ebf499f52da5a6.tar.gz
pokeyellow-aae999f72bd81a3156c7e00da4ebf499f52da5a6.tar.xz
pokeyellow-aae999f72bd81a3156c7e00da4ebf499f52da5a6.zip
Start reorganizing pokeyellow
Diffstat (limited to 'home/bankswitch2.asm')
-rw-r--r--home/bankswitch2.asm39
1 files changed, 39 insertions, 0 deletions
diff --git a/home/bankswitch2.asm b/home/bankswitch2.asm
new file mode 100644
index 00000000..cc7169cd
--- /dev/null
+++ b/home/bankswitch2.asm
@@ -0,0 +1,39 @@
+BankswitchCommon::
+ ldh [hLoadedROMBank], a
+ ld [MBC1RomBank], a
+ ret
+
+Bankswitch::
+; self-contained bankswitch, use this when not in the home bank
+; switches to the bank in b
+ ldh a, [hLoadedROMBank]
+ push af
+ ld a, b
+ ldh [hLoadedROMBank], a
+ ld [MBC1RomBank], a
+ call JumpToAddress
+ pop bc
+ ld a, b
+ ldh [hLoadedROMBank], a
+ ld [MBC1RomBank], a
+ ret
+JumpToAddress::
+ jp hl
+
+SwitchSRAMBankAndLatchClockData::
+ push af
+ ld a, $1
+ ld [MBC1SRamBankingMode], a
+ ld a, SRAM_ENABLE
+ ld [MBC1SRamEnable], a
+ pop af
+ ld [MBC1SRamBank], a
+ ret
+
+PrepareRTCDataAndDisableSRAM::
+ push af
+ ld a, $0
+ ld [MBC1SRamBankingMode], a
+ ld [MBC1SRamEnable], a
+ pop af
+ ret