2020-06-17 14:03:38 -07:00
|
|
|
OpenSRAM::
|
2013-09-07 23:50:06 -07:00
|
|
|
; if invalid bank, sram is disabled
|
|
|
|
cp NUM_SRAM_BANKS
|
2020-06-17 14:03:38 -07:00
|
|
|
jr c, .valid
|
2013-09-07 23:50:06 -07:00
|
|
|
jr CloseSRAM
|
|
|
|
|
2020-06-17 14:03:38 -07:00
|
|
|
.valid:
|
2013-09-07 23:50:06 -07:00
|
|
|
; 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
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
CloseSRAM::
|
2013-09-07 23:50:06 -07:00
|
|
|
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
|