From 844546f8495030b66e79aa30d96405065e2019dd Mon Sep 17 00:00:00 2001 From: yenatch Date: Sun, 8 Sep 2013 02:50:06 -0400 Subject: split sram access asm into common/sram.asm --- common/sram.asm | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 common/sram.asm (limited to 'common/sram.asm') diff --git a/common/sram.asm b/common/sram.asm new file mode 100644 index 000000000..3c42e7618 --- /dev/null +++ b/common/sram.asm @@ -0,0 +1,34 @@ +GetSRAMBank: ; 2fcb +; load sram bank a +; if invalid bank, sram is disabled + cp NUM_SRAM_BANKS + jr c, OpenSRAM + jr CloseSRAM +; 2fd1 + +OpenSRAM: ; 2fd1 +; switch to sram bank a + push af +; latch clock data + ld a, 1 + ld [MBC3LatchClock], a +; enable sram/clock write + ld a, SRAM_ENABLE + ld [MBC3SRamEnable], a +; select sram bank + pop af + ld [MBC3SRamBank], a + ret +; 2fe1 + +CloseSRAM: ; 2fe1 + push af + ld a, SRAM_DISABLE +; reset clock latch for next time + ld [MBC3LatchClock], a +; disable sram/clock write + ld [MBC3SRamEnable], a + pop af + ret +; 2fec + -- cgit v1.2.3