Save prefs.

This commit is contained in:
Randy Thiemann 2023-10-23 08:06:19 +02:00
parent dfa5e5b19b
commit c572aabefa
3 changed files with 44 additions and 3 deletions

View File

@ -4,8 +4,8 @@ GAMEID := DTGM
TITLE := DMGTRIS TITLE := DMGTRIS
LICENSEE := NR LICENSEE := NR
OLDLIC := 0x33 OLDLIC := 0x33
MBC := 0x00 MBC := 0x03
SRAMSIZE := 0x00 SRAMSIZE := 0x02
ROMNAME := out ROMNAME := out
ROMEXT := gb ROMEXT := gb
ASFLAGS += -h ASFLAGS += -h

View File

@ -40,6 +40,12 @@ wInitialH:: ds 1
wInitialL:: ds 1 wInitialL:: ds 1
SECTION "Persistent Globals", SRAM
rMagic:: ds 3
rSwapAB:: ds 1
rSimulationMode:: ds 1
SECTION "Stack", WRAM0 SECTION "Stack", WRAM0
wStack:: wStack::
ds STACK_SIZE + 1 ds STACK_SIZE + 1
@ -82,11 +88,44 @@ Main::
call SetNumberSpritePositions call SetNumberSpritePositions
call CopyOAMHandler call CopyOAMHandler
; Zero out the ram where needed. ; Enable RAM. (Not actually needed since we don't ACTUALLY use an MBC, but without this emulators shit the bed.)
ld hl, rRAMG
ld a, CART_SRAM_ENABLE
ld [hl], a
; Check for save data.
ld a, [rMagic]
cp a, "T"
jr nz, .nosavedata
ld a, [rMagic+1]
cp a, "G"
jr nz, .nosavedata
ld a, [rMagic+1]
cp a, "M"
jr nz, .nosavedata
.savedata
ld a, [rSwapAB]
ldh [hSwapAB], a
ld a, [rSimulationMode]
ldh [hSimulationMode], a
jr .otherinit
.nosavedata
ld a, "T"
ld [rMagic], a
ld a, "G"
ld [rMagic+1], a
ld a, "M"
ld [rMagic+2], a
xor a, a xor a, a
ldh [hSwapAB], a ldh [hSwapAB], a
ld [rSwapAB], a
ld a, MODE_TGM2 ld a, MODE_TGM2
ldh [hSimulationMode], a ldh [hSimulationMode], a
ld [rSimulationMode], a
.otherinit
ld hl, sSpeedCurve ld hl, sSpeedCurve
ld a, l ld a, l
ldh [hStartSpeed], a ldh [hStartSpeed], a

View File

@ -100,6 +100,7 @@ TitleEventLoopHandler::
xor a, a xor a, a
.write .write
ldh [hSimulationMode], a ldh [hSimulationMode], a
ld [rSimulationMode], a
jp EventLoopPostHandler jp EventLoopPostHandler
; Start game? ; Start game?
@ -125,6 +126,7 @@ TitleEventLoopHandler::
ldh a, [hSwapAB] ldh a, [hSwapAB]
cpl cpl
ldh [hSwapAB], a ldh [hSwapAB], a
ld [rSwapAB], a
jp EventLoopPostHandler jp EventLoopPostHandler
; Start level up? ; Start level up?