pokecrystal/engine/menus/save.asm

1137 lines
21 KiB
NASM
Raw Normal View History

2018-06-24 14:09:41 +00:00
SaveMenu:
call LoadStandardMenuHeader
2017-12-24 17:47:30 +00:00
farcall DisplaySaveInfoOnSave
2015-08-19 17:13:48 +00:00
call SpeechTextBox
call UpdateSprites
farcall SaveMenu_CopyTilemapAtOnce
ld hl, Text_WouldYouLikeToSaveTheGame
2015-08-19 17:13:48 +00:00
call SaveTheGame_yesorno
jr nz, .refused
2015-11-18 04:29:14 +00:00
call AskOverwriteSaveFile
2015-08-19 17:13:48 +00:00
jr c, .refused
call PauseGameLogic
2015-08-19 17:13:48 +00:00
call _SavingDontTurnOffThePower
call ResumeGameLogic
2015-08-19 17:13:48 +00:00
call ExitMenu
and a
ret
2015-11-18 04:29:14 +00:00
2015-08-19 17:13:48 +00:00
.refused
call ExitMenu
2015-12-09 16:38:40 +00:00
call ret_d90
farcall SaveMenu_CopyTilemapAtOnce
2015-08-19 17:13:48 +00:00
scf
ret
2018-06-24 14:09:41 +00:00
SaveAfterLinkTrade:
call PauseGameLogic
2017-12-24 17:47:30 +00:00
farcall StageRTCTimeForSave
farcall BackupMysteryGift
2015-08-20 04:14:15 +00:00
call SavePokemonData
2015-11-18 04:29:14 +00:00
call SaveChecksum
2015-08-20 04:14:15 +00:00
call SaveBackupPokemonData
call SaveBackupChecksum
2017-12-24 17:47:30 +00:00
farcall BackupPartyMonMail
farcall SaveRTC
call ResumeGameLogic
2015-08-19 17:13:48 +00:00
ret
2018-06-24 14:09:41 +00:00
ChangeBoxSaveGame:
2015-08-19 17:13:48 +00:00
push de
ld hl, Text_SaveOnBoxSwitch
2015-08-19 17:13:48 +00:00
call MenuTextBox
call YesNoBox
call ExitMenu
jr c, .refused
2015-11-18 04:29:14 +00:00
call AskOverwriteSaveFile
2015-08-19 17:13:48 +00:00
jr c, .refused
call PauseGameLogic
2015-08-19 17:13:48 +00:00
call SavingDontTurnOffThePower
2015-08-20 04:14:15 +00:00
call SaveBox
2015-08-19 17:13:48 +00:00
pop de
ld a, e
ld [wCurBox], a
2015-08-20 04:14:15 +00:00
call LoadBox
2015-08-19 17:13:48 +00:00
call SavedTheGame
call ResumeGameLogic
2015-08-19 17:13:48 +00:00
and a
ret
.refused
pop de
ret
2018-06-24 14:09:41 +00:00
Link_SaveGame:
2015-11-18 04:29:14 +00:00
call AskOverwriteSaveFile
2015-08-19 17:13:48 +00:00
jr c, .refused
call PauseGameLogic
2015-08-19 17:13:48 +00:00
call _SavingDontTurnOffThePower
call ResumeGameLogic
2015-08-19 17:13:48 +00:00
and a
.refused
ret
2018-06-24 14:09:41 +00:00
MoveMonWOMail_SaveGame:
call PauseGameLogic
2015-08-19 17:13:48 +00:00
push de
2015-08-20 04:14:15 +00:00
call SaveBox
2015-08-19 17:13:48 +00:00
pop de
ld a, e
ld [wCurBox], a
2015-08-20 04:14:15 +00:00
call LoadBox
call ResumeGameLogic
2015-08-19 17:13:48 +00:00
ret
2018-06-24 14:09:41 +00:00
MoveMonWOMail_InsertMon_SaveGame:
call PauseGameLogic
2015-08-19 17:13:48 +00:00
push de
2015-08-20 04:14:15 +00:00
call SaveBox
2015-08-19 17:13:48 +00:00
pop de
ld a, e
ld [wCurBox], a
2018-07-04 06:50:27 +00:00
ld a, TRUE
2015-11-18 04:29:14 +00:00
ld [wSaveFileExists], a
2017-12-24 17:47:30 +00:00
farcall StageRTCTimeForSave
farcall BackupMysteryGift
2015-08-20 04:14:15 +00:00
call ValidateSave
call SaveOptions
2015-08-19 17:13:48 +00:00
call SavePlayerData
2015-08-20 04:14:15 +00:00
call SavePokemonData
2015-11-18 04:29:14 +00:00
call SaveChecksum
2015-08-20 04:14:15 +00:00
call ValidateBackupSave
call SaveBackupOptions
call SaveBackupPlayerData
call SaveBackupPokemonData
call SaveBackupChecksum
2017-12-24 17:47:30 +00:00
farcall BackupPartyMonMail
farcall BackupMobileEventIndex
farcall SaveRTC
2015-08-20 04:14:15 +00:00
call LoadBox
call ResumeGameLogic
2015-08-19 17:13:48 +00:00
ld de, SFX_SAVE
call PlaySFX
2015-11-18 04:29:14 +00:00
ld c, 24
2015-08-19 17:13:48 +00:00
call DelayFrames
ret
2018-06-24 14:09:41 +00:00
StartMoveMonWOMail_SaveGame:
ld hl, Text_SaveOnMoveMonWOMail
2015-08-19 17:13:48 +00:00
call MenuTextBox
call YesNoBox
call ExitMenu
2015-11-18 04:29:14 +00:00
jr c, .refused
call AskOverwriteSaveFile
jr c, .refused
call PauseGameLogic
2015-08-19 17:13:48 +00:00
call _SavingDontTurnOffThePower
call ResumeGameLogic
2015-08-19 17:13:48 +00:00
and a
ret
2015-11-18 04:29:14 +00:00
.refused
2015-08-19 17:13:48 +00:00
scf
ret
2018-06-24 14:09:41 +00:00
PauseGameLogic:
ld a, TRUE
ld [wGameLogicPaused], a
2015-08-19 17:13:48 +00:00
ret
2018-06-24 14:09:41 +00:00
ResumeGameLogic:
xor a ; FALSE
ld [wGameLogicPaused], a
2015-08-19 17:13:48 +00:00
ret
2018-06-24 14:09:41 +00:00
AddHallOfFameEntry:
2015-08-20 04:14:15 +00:00
ld a, BANK(sHallOfFame)
2015-08-19 17:13:48 +00:00
call GetSRAMBank
2015-08-20 04:14:15 +00:00
ld hl, sHallOfFame + HOF_LENGTH * (NUM_HOF_TEAMS - 1) - 1
ld de, sHallOfFame + HOF_LENGTH * NUM_HOF_TEAMS - 1
ld bc, HOF_LENGTH * (NUM_HOF_TEAMS - 1)
2015-08-19 17:13:48 +00:00
.loop
ld a, [hld]
ld [de], a
dec de
dec bc
ld a, c
or b
jr nz, .loop
ld hl, wHallOfFamePokemonList
2015-08-20 04:14:15 +00:00
ld de, sHallOfFame
ld bc, wHallOfFamePokemonListEnd - wHallOfFamePokemonList + 1
2015-08-19 17:13:48 +00:00
call CopyBytes
call CloseSRAM
ret
2018-06-24 14:09:41 +00:00
SaveGameData:
call _SaveGameData
2015-08-19 17:13:48 +00:00
ret
2018-06-24 14:09:41 +00:00
AskOverwriteSaveFile:
2015-11-18 04:29:14 +00:00
ld a, [wSaveFileExists]
2015-08-19 17:13:48 +00:00
and a
2015-08-20 04:14:15 +00:00
jr z, .erase
2015-11-27 02:05:32 +00:00
call CompareLoadedAndSavedPlayerID
2015-08-19 17:13:48 +00:00
jr z, .yoursavefile
ld hl, Text_AnotherSaveFile
2015-08-19 17:13:48 +00:00
call SaveTheGame_yesorno
jr nz, .refused
2015-08-20 04:14:15 +00:00
jr .erase
2015-08-19 17:13:48 +00:00
.yoursavefile
ld hl, Text_AlreadyASaveFile
2015-08-19 17:13:48 +00:00
call SaveTheGame_yesorno
jr nz, .refused
jr .ok
2015-08-20 04:14:15 +00:00
.erase
call ErasePreviousSave
2015-08-19 17:13:48 +00:00
.ok
and a
ret
.refused
scf
ret
2018-06-24 14:09:41 +00:00
SaveTheGame_yesorno:
ld b, BANK(Text_WouldYouLikeToSaveTheGame)
2015-08-19 17:13:48 +00:00
call MapTextbox
call LoadMenuTextBox
lb bc, 0, 7
call PlaceYesNoBox
2015-12-15 23:59:49 +00:00
ld a, [wMenuCursorY]
2015-08-19 17:13:48 +00:00
dec a
call CloseWindow
2015-08-19 17:13:48 +00:00
push af
2015-12-09 16:38:40 +00:00
call ret_d90
2015-08-19 17:13:48 +00:00
pop af
and a
ret
2018-06-24 14:09:41 +00:00
CompareLoadedAndSavedPlayerID:
2015-08-20 04:14:15 +00:00
ld a, BANK(sPlayerData)
2015-08-19 17:13:48 +00:00
call GetSRAMBank
2018-01-23 22:39:09 +00:00
ld hl, sPlayerData + (wPlayerID - wPlayerData)
2015-08-19 17:13:48 +00:00
ld a, [hli]
ld c, [hl]
ld b, a
call CloseSRAM
2018-01-23 22:39:09 +00:00
ld a, [wPlayerID]
2015-08-19 17:13:48 +00:00
cp b
ret nz
2018-01-23 22:39:09 +00:00
ld a, [wPlayerID + 1]
2015-08-19 17:13:48 +00:00
cp c
ret
2018-06-24 14:09:41 +00:00
_SavingDontTurnOffThePower:
2015-08-19 17:13:48 +00:00
call SavingDontTurnOffThePower
2018-06-24 14:09:41 +00:00
SavedTheGame:
call _SaveGameData
2015-08-19 17:13:48 +00:00
; wait 32 frames
ld c, 32
2015-08-19 17:13:48 +00:00
call DelayFrames
; copy the original text speed setting to the stack
2018-01-23 22:39:09 +00:00
ld a, [wOptions]
2015-08-19 17:13:48 +00:00
push af
; set text speed to medium
ld a, TEXT_DELAY_MED
2018-01-23 22:39:09 +00:00
ld [wOptions], a
2015-08-19 17:13:48 +00:00
; <PLAYER> saved the game!
ld hl, Text_PlayerSavedTheGame
2015-08-19 17:13:48 +00:00
call PrintText
; restore the original text speed setting
pop af
2018-01-23 22:39:09 +00:00
ld [wOptions], a
2015-08-19 17:13:48 +00:00
ld de, SFX_SAVE
call WaitPlaySFX
call WaitSFX
; wait 30 frames
ld c, 30
2015-08-19 17:13:48 +00:00
call DelayFrames
ret
_SaveGameData:
2018-07-04 06:50:27 +00:00
ld a, TRUE
2015-11-18 04:29:14 +00:00
ld [wSaveFileExists], a
2017-12-24 17:47:30 +00:00
farcall StageRTCTimeForSave
farcall BackupMysteryGift
2015-08-20 04:14:15 +00:00
call ValidateSave
call SaveOptions
2015-08-19 17:13:48 +00:00
call SavePlayerData
2015-08-20 04:14:15 +00:00
call SavePokemonData
call SaveBox
2015-11-18 04:29:14 +00:00
call SaveChecksum
2015-08-20 04:14:15 +00:00
call ValidateBackupSave
call SaveBackupOptions
call SaveBackupPlayerData
call SaveBackupPokemonData
call SaveBackupChecksum
call UpdateStackTop
2017-12-24 17:47:30 +00:00
farcall BackupPartyMonMail
farcall BackupMobileEventIndex
farcall SaveRTC
ld a, BANK(sBattleTowerChallengeState)
2015-08-19 17:13:48 +00:00
call GetSRAMBank
ld a, [sBattleTowerChallengeState]
2015-11-27 02:05:32 +00:00
cp BATTLETOWER_RECEIVED_REWARD
2015-08-20 04:14:15 +00:00
jr nz, .ok
2015-08-19 17:13:48 +00:00
xor a
ld [sBattleTowerChallengeState], a
2015-08-20 04:14:15 +00:00
.ok
2015-08-19 17:13:48 +00:00
call CloseSRAM
ret
2018-06-24 14:09:41 +00:00
UpdateStackTop:
2015-08-20 04:14:15 +00:00
; sStackTop appears to be unused.
; It could have been used to debug stack overflow during saving.
call FindStackTop
ld a, BANK(sStackTop)
2015-08-19 17:13:48 +00:00
call GetSRAMBank
2015-08-20 04:14:15 +00:00
ld a, [sStackTop + 0]
2015-08-19 17:13:48 +00:00
ld e, a
2015-08-20 04:14:15 +00:00
ld a, [sStackTop + 1]
2015-08-19 17:13:48 +00:00
ld d, a
or e
2015-08-20 04:14:15 +00:00
jr z, .update
2015-08-19 17:13:48 +00:00
ld a, e
sub l
ld a, d
sbc h
2015-08-20 04:14:15 +00:00
jr c, .done
2015-08-19 17:13:48 +00:00
2015-08-20 04:14:15 +00:00
.update
2015-08-19 17:13:48 +00:00
ld a, l
2015-08-20 04:14:15 +00:00
ld [sStackTop + 0], a
2015-08-19 17:13:48 +00:00
ld a, h
2015-08-20 04:14:15 +00:00
ld [sStackTop + 1], a
2015-08-19 17:13:48 +00:00
2015-08-20 04:14:15 +00:00
.done
2015-08-19 17:13:48 +00:00
call CloseSRAM
ret
2018-06-24 14:09:41 +00:00
FindStackTop:
2015-08-20 04:14:15 +00:00
; Find the furthest point that sp has traversed to.
; This is distinct from the current value of sp.
2018-01-23 21:49:58 +00:00
ld hl, wStack - $ff
2015-08-20 04:14:15 +00:00
.loop
2015-08-19 17:13:48 +00:00
ld a, [hl]
or a
ret nz
inc hl
2015-08-20 04:14:15 +00:00
jr .loop
2015-08-19 17:13:48 +00:00
2018-06-24 14:09:41 +00:00
SavingDontTurnOffThePower:
2015-08-19 17:13:48 +00:00
; Prevent joypad interrupts
xor a
ldh [hJoypadReleased], a
ldh [hJoypadPressed], a
ldh [hJoypadSum], a
ldh [hJoypadDown], a
2015-08-19 17:13:48 +00:00
; Save the text speed setting to the stack
2018-01-23 22:39:09 +00:00
ld a, [wOptions]
2015-08-19 17:13:48 +00:00
push af
; Set the text speed to medium
ld a, TEXT_DELAY_MED
2018-01-23 22:39:09 +00:00
ld [wOptions], a
2015-08-19 17:13:48 +00:00
; SAVING... DON'T TURN OFF THE POWER.
ld hl, Text_SavingDontTurnOffThePower
2015-08-19 17:13:48 +00:00
call PrintText
; Restore the text speed setting
pop af
2018-01-23 22:39:09 +00:00
ld [wOptions], a
2015-08-19 17:13:48 +00:00
; Wait for 16 frames
ld c, 16
2015-08-19 17:13:48 +00:00
call DelayFrames
ret
2018-06-24 14:09:41 +00:00
ErasePreviousSave:
2015-08-20 04:14:15 +00:00
call EraseBoxes
call EraseHallOfFame
call EraseLinkBattleStats
call EraseMysteryGift
2015-11-18 04:29:14 +00:00
call SaveData
2015-11-27 02:05:32 +00:00
call EraseBattleTowerStatus
2015-08-20 04:14:15 +00:00
ld a, BANK(sStackTop)
2015-08-19 17:13:48 +00:00
call GetSRAMBank
xor a
2015-08-20 04:14:15 +00:00
ld [sStackTop + 0], a
ld [sStackTop + 1], a
2015-08-19 17:13:48 +00:00
call CloseSRAM
ld a, $1
2015-10-16 17:35:43 +00:00
ld [wSavedAtLeastOnce], a
2015-08-19 17:13:48 +00:00
ret
2018-06-24 14:09:41 +00:00
EraseLinkBattleStats:
2015-08-20 04:14:15 +00:00
ld a, BANK(sLinkBattleStats)
2015-08-19 17:13:48 +00:00
call GetSRAMBank
2015-08-20 04:14:15 +00:00
ld hl, sLinkBattleStats
ld bc, sLinkBattleStatsEnd - sLinkBattleStats
2015-08-19 17:13:48 +00:00
xor a
call ByteFill
jp CloseSRAM
2018-06-24 14:09:41 +00:00
EraseMysteryGift:
2015-11-18 04:29:14 +00:00
ld a, BANK(sBackupMysteryGiftItem)
2015-08-19 17:13:48 +00:00
call GetSRAMBank
2015-11-18 04:29:14 +00:00
ld hl, sBackupMysteryGiftItem
ld bc, sBackupMysteryGiftItemEnd - sBackupMysteryGiftItem
2015-08-19 17:13:48 +00:00
xor a
call ByteFill
jp CloseSRAM
2018-06-24 14:09:41 +00:00
EraseHallOfFame:
2015-08-20 04:14:15 +00:00
ld a, BANK(sHallOfFame)
2015-08-19 17:13:48 +00:00
call GetSRAMBank
2015-08-20 04:14:15 +00:00
ld hl, sHallOfFame
ld bc, sHallOfFameEnd - sHallOfFame
2015-08-19 17:13:48 +00:00
xor a
call ByteFill
jp CloseSRAM
2018-06-24 14:09:41 +00:00
Unreferenced_Function14d18:
; copy .Data to SRA4:a007
ld a, 4 ; MBC30 bank used by JP Crystal; inaccessible by MBC3
2015-08-19 17:13:48 +00:00
call GetSRAMBank
ld hl, .Data
2018-01-09 03:48:58 +00:00
ld de, $a007 ; address of MBC30 bank
ld bc, .DataEnd - .Data
2015-08-19 17:13:48 +00:00
call CopyBytes
jp CloseSRAM
2018-06-24 14:09:41 +00:00
.Data:
2015-08-19 17:13:48 +00:00
db $0d, $02, $00, $05, $00, $00
db $22, $02, $01, $05, $00, $00
db $03, $04, $05, $08, $03, $05
db $0e, $06, $03, $02, $00, $00
db $39, $07, $07, $04, $00, $05
db $04, $07, $01, $05, $00, $00
db $0f, $05, $14, $07, $05, $05
db $11, $0c, $0c, $06, $06, $04
.DataEnd
2015-08-19 17:13:48 +00:00
2018-06-24 14:09:41 +00:00
EraseBattleTowerStatus:
ld a, BANK(sBattleTowerChallengeState)
2015-08-19 17:13:48 +00:00
call GetSRAMBank
xor a
ld [sBattleTowerChallengeState], a
2015-08-19 17:13:48 +00:00
jp CloseSRAM
2018-06-24 14:09:41 +00:00
SaveData:
2015-11-18 04:29:14 +00:00
call _SaveData
2015-08-19 17:13:48 +00:00
ret
2018-06-24 14:09:41 +00:00
Unreferenced_Function14d6c:
ld a, 4 ; MBC30 bank used by JP Crystal; inaccessible by MBC3
2015-08-19 17:13:48 +00:00
call GetSRAMBank
2018-01-09 03:48:58 +00:00
ld a, [$a60b] ; address of MBC30 bank
2015-08-19 17:13:48 +00:00
ld b, $0
and a
jr z, .ok
ld b, $2
.ok
ld a, b
2018-01-09 03:48:58 +00:00
ld [$a60b], a ; address of MBC30 bank
2015-08-19 17:13:48 +00:00
call CloseSRAM
ret
2018-06-24 14:09:41 +00:00
Unreferenced_Function14d83:
ld a, 4 ; MBC30 bank used by JP Crystal; inaccessible by MBC3
2015-08-19 17:13:48 +00:00
call GetSRAMBank
xor a
2018-01-09 03:48:58 +00:00
ld [$a60c], a ; address of MBC30 bank
ld [$a60d], a ; address of MBC30 bank
2015-08-19 17:13:48 +00:00
call CloseSRAM
ret
2018-06-24 14:09:41 +00:00
Unreferenced_Function14d93:
ld a, 7 ; MBC30 bank used by JP Crystal; inaccessible by MBC3
2015-08-19 17:13:48 +00:00
call GetSRAMBank
xor a
2018-01-09 03:48:58 +00:00
ld [$a000], a ; address of MBC30 bank
2015-08-19 17:13:48 +00:00
call CloseSRAM
ret
2018-06-24 14:09:41 +00:00
HallOfFame_InitSaveIfNeeded:
2015-10-16 17:35:43 +00:00
ld a, [wSavedAtLeastOnce]
2015-08-19 17:13:48 +00:00
and a
ret nz
2015-08-20 04:14:15 +00:00
call ErasePreviousSave
2015-08-19 17:13:48 +00:00
ret
2018-06-24 14:09:41 +00:00
ValidateSave:
ld a, BANK(sCheckValue1) ; BANK(sCheckValue2)
2015-08-19 17:13:48 +00:00
call GetSRAMBank
ld a, SAVE_CHECK_VALUE_1
ld [sCheckValue1], a
ld a, SAVE_CHECK_VALUE_2
ld [sCheckValue2], a
2015-08-19 17:13:48 +00:00
jp CloseSRAM
2018-06-24 14:09:41 +00:00
SaveOptions:
2015-08-20 04:14:15 +00:00
ld a, BANK(sOptions)
2015-08-19 17:13:48 +00:00
call GetSRAMBank
2018-01-23 22:39:09 +00:00
ld hl, wOptions
2015-08-20 04:14:15 +00:00
ld de, sOptions
2018-01-23 22:39:09 +00:00
ld bc, wOptionsEnd - wOptions
2015-08-19 17:13:48 +00:00
call CopyBytes
2018-01-23 22:39:09 +00:00
ld a, [wOptions]
2015-11-27 02:05:32 +00:00
and $ff ^ (1 << NO_TEXT_SCROLL)
2015-08-20 04:14:15 +00:00
ld [sOptions], a
2015-08-19 17:13:48 +00:00
jp CloseSRAM
2018-06-24 14:09:41 +00:00
SavePlayerData:
2015-08-20 04:14:15 +00:00
ld a, BANK(sPlayerData)
2015-08-19 17:13:48 +00:00
call GetSRAMBank
2015-08-20 04:14:15 +00:00
ld hl, wPlayerData
ld de, sPlayerData
ld bc, wPlayerDataEnd - wPlayerData
2015-08-19 17:13:48 +00:00
call CopyBytes
ld hl, wCurrMapData
ld de, sCurrMapData
ld bc, wCurrMapDataEnd - wCurrMapData
2015-08-19 17:13:48 +00:00
call CopyBytes
jp CloseSRAM
2018-06-24 14:09:41 +00:00
SavePokemonData:
2015-08-20 04:14:15 +00:00
ld a, BANK(sPokemonData)
2015-08-19 17:13:48 +00:00
call GetSRAMBank
2015-08-20 04:14:15 +00:00
ld hl, wPokemonData
ld de, sPokemonData
ld bc, wPokemonDataEnd - wPokemonData
2015-08-19 17:13:48 +00:00
call CopyBytes
call CloseSRAM
ret
2018-06-24 14:09:41 +00:00
SaveBox:
2015-08-20 04:14:15 +00:00
call GetBoxAddress
call SaveBoxAddress
2015-08-19 17:13:48 +00:00
ret
2018-06-24 14:09:41 +00:00
SaveChecksum:
2015-08-20 04:14:15 +00:00
ld hl, sGameData
ld bc, sGameDataEnd - sGameData
ld a, BANK(sGameData)
2015-08-19 17:13:48 +00:00
call GetSRAMBank
2015-08-20 04:14:15 +00:00
call Checksum
2015-08-19 17:13:48 +00:00
ld a, e
2015-08-20 04:14:15 +00:00
ld [sChecksum + 0], a
2015-08-19 17:13:48 +00:00
ld a, d
2015-08-20 04:14:15 +00:00
ld [sChecksum + 1], a
2015-08-19 17:13:48 +00:00
call CloseSRAM
ret
2018-06-24 14:09:41 +00:00
ValidateBackupSave:
ld a, BANK(sBackupCheckValue1) ; BANK(sBackupCheckValue2)
2015-08-19 17:13:48 +00:00
call GetSRAMBank
ld a, SAVE_CHECK_VALUE_1
ld [sBackupCheckValue1], a
ld a, SAVE_CHECK_VALUE_2
ld [sBackupCheckValue2], a
2015-08-19 17:13:48 +00:00
call CloseSRAM
ret
2018-06-24 14:09:41 +00:00
SaveBackupOptions:
2015-08-20 04:14:15 +00:00
ld a, BANK(sBackupOptions)
2015-08-19 17:13:48 +00:00
call GetSRAMBank
2018-01-23 22:39:09 +00:00
ld hl, wOptions
2015-08-20 04:14:15 +00:00
ld de, sBackupOptions
2018-01-23 22:39:09 +00:00
ld bc, wOptionsEnd - wOptions
2015-08-19 17:13:48 +00:00
call CopyBytes
call CloseSRAM
ret
2018-06-24 14:09:41 +00:00
SaveBackupPlayerData:
2015-08-20 04:14:15 +00:00
ld a, BANK(sBackupPlayerData)
2015-08-19 17:13:48 +00:00
call GetSRAMBank
2015-08-20 04:14:15 +00:00
ld hl, wPlayerData
ld de, sBackupPlayerData
ld bc, wPlayerDataEnd - wPlayerData
2015-08-19 17:13:48 +00:00
call CopyBytes
ld hl, wCurrMapData
ld de, sBackupCurrMapData
ld bc, wCurrMapDataEnd - wCurrMapData
2015-08-19 17:13:48 +00:00
call CopyBytes
call CloseSRAM
ret
2018-06-24 14:09:41 +00:00
SaveBackupPokemonData:
2015-08-20 04:14:15 +00:00
ld a, BANK(sBackupPokemonData)
2015-08-19 17:13:48 +00:00
call GetSRAMBank
2015-08-20 04:14:15 +00:00
ld hl, wPokemonData
ld de, sBackupPokemonData
ld bc, wPokemonDataEnd - wPokemonData
2015-08-19 17:13:48 +00:00
call CopyBytes
call CloseSRAM
ret
2018-06-24 14:09:41 +00:00
SaveBackupChecksum:
2015-08-20 04:14:15 +00:00
ld hl, sBackupGameData
ld bc, sBackupGameDataEnd - sBackupGameData
ld a, BANK(sBackupGameData)
2015-08-19 17:13:48 +00:00
call GetSRAMBank
2015-08-20 04:14:15 +00:00
call Checksum
2015-08-19 17:13:48 +00:00
ld a, e
2015-08-20 04:14:15 +00:00
ld [sBackupChecksum + 0], a
2015-08-19 17:13:48 +00:00
ld a, d
2015-08-20 04:14:15 +00:00
ld [sBackupChecksum + 1], a
2015-08-19 17:13:48 +00:00
call CloseSRAM
ret
2018-06-24 14:09:41 +00:00
TryLoadSaveFile:
2015-08-20 04:14:15 +00:00
call VerifyChecksum
jr nz, .backup
call LoadPlayerData
call LoadPokemonData
call LoadBox
2017-12-24 17:47:30 +00:00
farcall RestorePartyMonMail
farcall RestoreMobileEventIndex
farcall RestoreMysteryGift
2015-08-20 04:14:15 +00:00
call ValidateBackupSave
call SaveBackupOptions
call SaveBackupPlayerData
call SaveBackupPokemonData
call SaveBackupChecksum
2015-08-19 17:13:48 +00:00
and a
ret
2015-08-20 04:14:15 +00:00
.backup
call VerifyBackupChecksum
2015-08-19 17:13:48 +00:00
jr nz, .corrupt
2015-08-20 04:14:15 +00:00
call LoadBackupPlayerData
call LoadBackupPokemonData
call LoadBox
2017-12-24 17:47:30 +00:00
farcall RestorePartyMonMail
farcall RestoreMobileEventIndex
farcall RestoreMysteryGift
2015-08-20 04:14:15 +00:00
call ValidateSave
call SaveOptions
2015-08-19 17:13:48 +00:00
call SavePlayerData
2015-08-20 04:14:15 +00:00
call SavePokemonData
2015-11-18 04:29:14 +00:00
call SaveChecksum
2015-08-19 17:13:48 +00:00
and a
ret
2015-08-20 04:14:15 +00:00
2015-08-19 17:13:48 +00:00
.corrupt
2018-01-23 22:39:09 +00:00
ld a, [wOptions]
2015-08-19 17:13:48 +00:00
push af
2015-11-16 16:53:26 +00:00
set NO_TEXT_SCROLL, a
2018-01-23 22:39:09 +00:00
ld [wOptions], a
ld hl, Text_SaveFileCorrupted
2015-08-19 17:13:48 +00:00
call PrintText
pop af
2018-01-23 22:39:09 +00:00
ld [wOptions], a
2015-08-19 17:13:48 +00:00
scf
ret
2018-06-24 14:09:41 +00:00
TryLoadSaveData:
2018-07-04 06:50:27 +00:00
xor a ; FALSE
2015-11-18 04:29:14 +00:00
ld [wSaveFileExists], a
call CheckPrimarySaveFile
ld a, [wSaveFileExists]
2015-08-19 17:13:48 +00:00
and a
2015-08-20 04:14:15 +00:00
jr z, .backup
ld a, BANK(sPlayerData)
2015-08-19 17:13:48 +00:00
call GetSRAMBank
2018-01-23 22:39:09 +00:00
ld hl, sPlayerData + wStartDay - wPlayerData
ld de, wStartDay
2015-08-20 04:14:15 +00:00
ld bc, 8
2015-08-19 17:13:48 +00:00
call CopyBytes
ld hl, sPlayerData + wStatusFlags - wPlayerData
ld de, wStatusFlags
2015-08-19 17:13:48 +00:00
ld a, [hl]
ld [de], a
call CloseSRAM
ret
2015-08-20 04:14:15 +00:00
.backup
2015-11-18 04:29:14 +00:00
call CheckBackupSaveFile
ld a, [wSaveFileExists]
2015-08-19 17:13:48 +00:00
and a
2015-08-20 04:14:15 +00:00
jr z, .corrupt
ld a, BANK(sBackupPlayerData)
2015-08-19 17:13:48 +00:00
call GetSRAMBank
2018-01-23 22:39:09 +00:00
ld hl, sBackupPlayerData + wStartDay - wPlayerData
ld de, wStartDay
2015-08-19 17:13:48 +00:00
ld bc, 8
call CopyBytes
ld hl, sBackupPlayerData + wStatusFlags - wPlayerData
ld de, wStatusFlags
2015-08-19 17:13:48 +00:00
ld a, [hl]
ld [de], a
call CloseSRAM
ret
2015-08-20 04:14:15 +00:00
.corrupt
2015-08-19 17:13:48 +00:00
ld hl, DefaultOptions
2018-01-23 22:39:09 +00:00
ld de, wOptions
ld bc, wOptionsEnd - wOptions
2015-08-19 17:13:48 +00:00
call CopyBytes
2015-11-18 04:29:14 +00:00
call PanicResetClock
2015-08-19 17:13:48 +00:00
ret
INCLUDE "data/default_options.asm"
2018-06-24 14:09:41 +00:00
CheckPrimarySaveFile:
ld a, BANK(sCheckValue1) ; BANK(sCheckValue2)
2015-08-19 17:13:48 +00:00
call GetSRAMBank
ld a, [sCheckValue1]
cp SAVE_CHECK_VALUE_1
2015-08-19 17:13:48 +00:00
jr nz, .nope
ld a, [sCheckValue2]
cp SAVE_CHECK_VALUE_2
2015-08-19 17:13:48 +00:00
jr nz, .nope
2015-08-20 04:14:15 +00:00
ld hl, sOptions
2018-01-23 22:39:09 +00:00
ld de, wOptions
ld bc, wOptionsEnd - wOptions
2015-08-19 17:13:48 +00:00
call CopyBytes
call CloseSRAM
2018-07-04 06:50:27 +00:00
ld a, TRUE
2015-11-18 04:29:14 +00:00
ld [wSaveFileExists], a
2015-08-19 17:13:48 +00:00
.nope
call CloseSRAM
ret
2018-06-24 14:09:41 +00:00
CheckBackupSaveFile:
ld a, BANK(sBackupCheckValue1) ; BANK(sBackupCheckValue2)
2015-08-19 17:13:48 +00:00
call GetSRAMBank
ld a, [sBackupCheckValue1]
cp SAVE_CHECK_VALUE_1
2015-08-19 17:13:48 +00:00
jr nz, .nope
ld a, [sBackupCheckValue2]
cp SAVE_CHECK_VALUE_2
2015-08-19 17:13:48 +00:00
jr nz, .nope
2015-08-20 04:14:15 +00:00
ld hl, sBackupOptions
2018-01-23 22:39:09 +00:00
ld de, wOptions
ld bc, wOptionsEnd - wOptions
2015-08-19 17:13:48 +00:00
call CopyBytes
ld a, $2
2015-11-18 04:29:14 +00:00
ld [wSaveFileExists], a
2015-08-19 17:13:48 +00:00
.nope
call CloseSRAM
ret
2018-06-24 14:09:41 +00:00
LoadPlayerData:
2015-08-20 04:14:15 +00:00
ld a, BANK(sPlayerData)
2015-08-19 17:13:48 +00:00
call GetSRAMBank
2015-08-20 04:14:15 +00:00
ld hl, sPlayerData
ld de, wPlayerData
ld bc, wPlayerDataEnd - wPlayerData
2015-08-19 17:13:48 +00:00
call CopyBytes
ld hl, sCurrMapData
ld de, wCurrMapData
ld bc, wCurrMapDataEnd - wCurrMapData
2015-08-19 17:13:48 +00:00
call CopyBytes
call CloseSRAM
ld a, BANK(sBattleTowerChallengeState)
2015-08-19 17:13:48 +00:00
call GetSRAMBank
ld a, [sBattleTowerChallengeState]
2015-11-27 02:05:32 +00:00
cp BATTLETOWER_RECEIVED_REWARD
2015-11-18 04:29:14 +00:00
jr nz, .not_4
2015-11-27 02:05:32 +00:00
ld a, BATTLETOWER_WON_CHALLENGE
ld [sBattleTowerChallengeState], a
2015-11-18 04:29:14 +00:00
.not_4
2015-08-19 17:13:48 +00:00
call CloseSRAM
ret
2018-06-24 14:09:41 +00:00
LoadPokemonData:
2015-08-20 04:14:15 +00:00
ld a, BANK(sPokemonData)
2015-08-19 17:13:48 +00:00
call GetSRAMBank
2015-08-20 04:14:15 +00:00
ld hl, sPokemonData
ld de, wPokemonData
ld bc, wPokemonDataEnd - wPokemonData
2015-08-19 17:13:48 +00:00
call CopyBytes
call CloseSRAM
ret
2018-06-24 14:09:41 +00:00
LoadBox:
2015-08-20 04:14:15 +00:00
call GetBoxAddress
call LoadBoxAddress
2015-08-19 17:13:48 +00:00
ret
2018-06-24 14:09:41 +00:00
VerifyChecksum:
2015-08-20 04:14:15 +00:00
ld hl, sGameData
ld bc, sGameDataEnd - sGameData
ld a, BANK(sGameData)
2015-08-19 17:13:48 +00:00
call GetSRAMBank
2015-08-20 04:14:15 +00:00
call Checksum
ld a, [sChecksum + 0]
2015-08-19 17:13:48 +00:00
cp e
2015-11-18 04:29:14 +00:00
jr nz, .fail
2015-08-20 04:14:15 +00:00
ld a, [sChecksum + 1]
2015-08-19 17:13:48 +00:00
cp d
2015-11-18 04:29:14 +00:00
.fail
2015-08-19 17:13:48 +00:00
push af
call CloseSRAM
pop af
ret
2018-06-24 14:09:41 +00:00
LoadBackupPlayerData:
2015-08-20 04:14:15 +00:00
ld a, BANK(sBackupPlayerData)
2015-08-19 17:13:48 +00:00
call GetSRAMBank
2015-08-20 04:14:15 +00:00
ld hl, sBackupPlayerData
ld de, wPlayerData
ld bc, wPlayerDataEnd - wPlayerData
2015-08-19 17:13:48 +00:00
call CopyBytes
ld hl, sBackupCurrMapData
ld de, wCurrMapData
ld bc, wCurrMapDataEnd - wCurrMapData
2015-08-19 17:13:48 +00:00
call CopyBytes
call CloseSRAM
ret
2018-06-24 14:09:41 +00:00
LoadBackupPokemonData:
2015-08-20 04:14:15 +00:00
ld a, BANK(sBackupPokemonData)
2015-08-19 17:13:48 +00:00
call GetSRAMBank
2015-08-20 04:14:15 +00:00
ld hl, sBackupPokemonData
ld de, wPokemonData
ld bc, wPokemonDataEnd - wPokemonData
2015-08-19 17:13:48 +00:00
call CopyBytes
call CloseSRAM
ret
2018-06-24 14:09:41 +00:00
VerifyBackupChecksum:
2015-08-20 04:14:15 +00:00
ld hl, sBackupGameData
ld bc, sBackupGameDataEnd - sBackupGameData
ld a, BANK(sBackupGameData)
2015-08-19 17:13:48 +00:00
call GetSRAMBank
2015-08-20 04:14:15 +00:00
call Checksum
ld a, [sBackupChecksum + 0]
2015-08-19 17:13:48 +00:00
cp e
2015-11-18 04:29:14 +00:00
jr nz, .fail
2015-08-20 04:14:15 +00:00
ld a, [sBackupChecksum + 1]
2015-08-19 17:13:48 +00:00
cp d
2015-11-18 04:29:14 +00:00
.fail
2015-08-19 17:13:48 +00:00
push af
call CloseSRAM
pop af
ret
2018-06-24 14:09:41 +00:00
_SaveData:
2018-01-09 03:48:58 +00:00
; This is called within two scenarios:
; a) ErasePreviousSave (the process of erasing the save from a previous game file)
; b) unused mobile functionality
; It is not part of a regular save.
2018-01-19 02:48:52 +00:00
2015-08-20 04:14:15 +00:00
ld a, BANK(sCrystalData)
2015-08-19 17:13:48 +00:00
call GetSRAMBank
2015-08-20 04:14:15 +00:00
ld hl, wCrystalData
ld de, sCrystalData
ld bc, wCrystalDataEnd - wCrystalData
2015-08-19 17:13:48 +00:00
call CopyBytes
2015-08-20 04:14:15 +00:00
2018-01-09 03:48:58 +00:00
; This block originally had some mobile functionality, but since we're still in
2018-01-23 22:39:09 +00:00
; BANK(sCrystalData), it instead overwrites the sixteen wEventFlags starting at 1:a603 with
2018-01-09 03:48:58 +00:00
; garbage from wd479. This isn't an issue, since ErasePreviousSave is followed by a regular
; save that unwrites the garbage.
2018-01-19 02:48:52 +00:00
2015-08-19 17:13:48 +00:00
ld hl, wd479
ld a, [hli]
2015-08-20 04:14:15 +00:00
ld [$a60e + 0], a
2015-08-19 17:13:48 +00:00
ld a, [hli]
2015-08-20 04:14:15 +00:00
ld [$a60e + 1], a
2015-08-19 17:13:48 +00:00
jp CloseSRAM
2018-06-24 14:09:41 +00:00
_LoadData:
2015-08-20 04:14:15 +00:00
ld a, BANK(sCrystalData)
2015-08-19 17:13:48 +00:00
call GetSRAMBank
2015-08-20 04:14:15 +00:00
ld hl, sCrystalData
ld de, wCrystalData
ld bc, wCrystalDataEnd - wCrystalData
2015-08-19 17:13:48 +00:00
call CopyBytes
2018-01-19 02:48:52 +00:00
2018-01-09 03:48:58 +00:00
; This block originally had some mobile functionality to mirror _SaveData above, but instead it
2018-01-23 22:39:09 +00:00
; (harmlessly) writes the aforementioned wEventFlags to the unused wd479.
2018-01-19 02:48:52 +00:00
2015-08-19 17:13:48 +00:00
ld hl, wd479
2015-08-20 04:14:15 +00:00
ld a, [$a60e + 0]
2015-08-19 17:13:48 +00:00
ld [hli], a
2015-08-20 04:14:15 +00:00
ld a, [$a60e + 1]
2015-08-19 17:13:48 +00:00
ld [hli], a
2015-08-20 04:14:15 +00:00
2015-08-19 17:13:48 +00:00
jp CloseSRAM
2018-06-24 14:09:41 +00:00
GetBoxAddress:
2015-08-19 17:13:48 +00:00
ld a, [wCurBox]
cp NUM_BOXES
2015-08-20 04:14:15 +00:00
jr c, .ok
2015-08-19 17:13:48 +00:00
xor a
ld [wCurBox], a
2015-08-20 04:14:15 +00:00
.ok
2015-08-19 17:13:48 +00:00
ld e, a
ld d, 0
2015-08-20 04:14:15 +00:00
ld hl, BoxAddresses
2015-08-19 17:13:48 +00:00
rept 5
add hl, de
endr
ld a, [hli]
push af
ld a, [hli]
ld e, a
ld a, [hli]
ld d, a
ld a, [hli]
ld h, [hl]
ld l, a
pop af
ret
2018-06-24 14:09:41 +00:00
SaveBoxAddress:
; Save box via wBoxPartialData.
; We do this in three steps because the size of wBoxPartialData is less than
2015-12-15 01:06:41 +00:00
; the size of sBox.
2015-08-19 17:13:48 +00:00
push hl
2015-12-15 01:06:41 +00:00
; Load the first part of the active box.
2015-08-19 17:13:48 +00:00
push af
push de
2015-08-20 04:14:15 +00:00
ld a, BANK(sBox)
2015-08-19 17:13:48 +00:00
call GetSRAMBank
2015-08-20 04:14:15 +00:00
ld hl, sBox
ld de, wBoxPartialData
ld bc, (wBoxPartialDataEnd - wBoxPartialData)
2015-08-19 17:13:48 +00:00
call CopyBytes
call CloseSRAM
pop de
pop af
2015-12-15 01:06:41 +00:00
; Save it to the target box.
2015-08-19 17:13:48 +00:00
push af
push de
call GetSRAMBank
ld hl, wBoxPartialData
ld bc, (wBoxPartialDataEnd - wBoxPartialData)
2015-08-19 17:13:48 +00:00
call CopyBytes
call CloseSRAM
2015-12-15 01:06:41 +00:00
; Load the second part of the active box.
2015-08-20 04:14:15 +00:00
ld a, BANK(sBox)
2015-08-19 17:13:48 +00:00
call GetSRAMBank
ld hl, sBox + (wBoxPartialDataEnd - wBoxPartialData)
ld de, wBoxPartialData
ld bc, (wBoxPartialDataEnd - wBoxPartialData)
2015-08-19 17:13:48 +00:00
call CopyBytes
call CloseSRAM
pop de
pop af
2015-08-20 04:14:15 +00:00
ld hl, (wBoxPartialDataEnd - wBoxPartialData)
2015-08-19 17:13:48 +00:00
add hl, de
ld e, l
ld d, h
2015-12-15 01:06:41 +00:00
; Save it to the next part of the target box.
2015-08-19 17:13:48 +00:00
push af
push de
call GetSRAMBank
ld hl, wBoxPartialData
ld bc, (wBoxPartialDataEnd - wBoxPartialData)
2015-08-19 17:13:48 +00:00
call CopyBytes
call CloseSRAM
2015-12-15 01:06:41 +00:00
; Load the third and final part of the active box.
2015-08-20 04:14:15 +00:00
ld a, BANK(sBox)
2015-08-19 17:13:48 +00:00
call GetSRAMBank
ld hl, sBox + (wBoxPartialDataEnd - wBoxPartialData) * 2
ld de, wBoxPartialData
ld bc, sBoxEnd - (sBox + (wBoxPartialDataEnd - wBoxPartialData) * 2) ; $8e
2015-08-19 17:13:48 +00:00
call CopyBytes
call CloseSRAM
pop de
pop af
2015-08-20 04:14:15 +00:00
ld hl, (wBoxPartialDataEnd - wBoxPartialData)
2015-08-19 17:13:48 +00:00
add hl, de
ld e, l
ld d, h
2015-12-15 01:06:41 +00:00
; Save it to the final part of the target box.
2015-08-19 17:13:48 +00:00
call GetSRAMBank
ld hl, wBoxPartialData
ld bc, sBoxEnd - (sBox + (wBoxPartialDataEnd - wBoxPartialData) * 2) ; $8e
2015-08-19 17:13:48 +00:00
call CopyBytes
call CloseSRAM
2015-08-20 04:14:15 +00:00
2015-08-19 17:13:48 +00:00
pop hl
ret
2018-06-24 14:09:41 +00:00
LoadBoxAddress:
; Load box via wBoxPartialData.
; We do this in three steps because the size of wBoxPartialData is less than
2015-12-15 01:06:41 +00:00
; the size of sBox.
2015-08-19 17:13:48 +00:00
push hl
ld l, e
ld h, d
2015-12-15 01:06:41 +00:00
; Load part 1
2015-08-19 17:13:48 +00:00
push af
push hl
call GetSRAMBank
ld de, wBoxPartialData
ld bc, (wBoxPartialDataEnd - wBoxPartialData)
2015-08-19 17:13:48 +00:00
call CopyBytes
call CloseSRAM
2015-08-20 04:14:15 +00:00
ld a, BANK(sBox)
2015-08-19 17:13:48 +00:00
call GetSRAMBank
ld hl, wBoxPartialData
2015-08-20 04:14:15 +00:00
ld de, sBox
ld bc, (wBoxPartialDataEnd - wBoxPartialData)
2015-08-19 17:13:48 +00:00
call CopyBytes
call CloseSRAM
pop hl
pop af
2015-08-20 04:14:15 +00:00
ld de, (wBoxPartialDataEnd - wBoxPartialData)
2015-08-19 17:13:48 +00:00
add hl, de
2015-12-15 01:06:41 +00:00
; Load part 2
2015-08-19 17:13:48 +00:00
push af
push hl
call GetSRAMBank
ld de, wBoxPartialData
ld bc, (wBoxPartialDataEnd - wBoxPartialData)
2015-08-19 17:13:48 +00:00
call CopyBytes
call CloseSRAM
2015-08-20 04:14:15 +00:00
ld a, BANK(sBox)
2015-08-19 17:13:48 +00:00
call GetSRAMBank
ld hl, wBoxPartialData
ld de, sBox + (wBoxPartialDataEnd - wBoxPartialData)
ld bc, (wBoxPartialDataEnd - wBoxPartialData)
2015-08-19 17:13:48 +00:00
call CopyBytes
call CloseSRAM
pop hl
pop af
2015-12-15 01:06:41 +00:00
; Load part 3
ld de, (wBoxPartialDataEnd - wBoxPartialData)
2015-08-19 17:13:48 +00:00
add hl, de
call GetSRAMBank
ld de, wBoxPartialData
ld bc, sBoxEnd - (sBox + (wBoxPartialDataEnd - wBoxPartialData) * 2) ; $8e
2015-08-19 17:13:48 +00:00
call CopyBytes
call CloseSRAM
2015-08-20 04:14:15 +00:00
ld a, BANK(sBox)
2015-08-19 17:13:48 +00:00
call GetSRAMBank
ld hl, wBoxPartialData
ld de, sBox + (wBoxPartialDataEnd - wBoxPartialData) * 2
ld bc, sBoxEnd - (sBox + (wBoxPartialDataEnd - wBoxPartialData) * 2) ; $8e
2015-08-19 17:13:48 +00:00
call CopyBytes
call CloseSRAM
2015-08-20 04:14:15 +00:00
2015-08-19 17:13:48 +00:00
pop hl
ret
2018-06-24 14:09:41 +00:00
EraseBoxes:
2015-08-20 04:14:15 +00:00
ld hl, BoxAddresses
ld c, NUM_BOXES
.next
2015-08-19 17:13:48 +00:00
push bc
ld a, [hli]
call GetSRAMBank
ld a, [hli]
ld e, a
ld a, [hli]
ld d, a
xor a
ld [de], a
inc de
ld a, -1
ld [de], a
inc de
2015-08-20 04:14:15 +00:00
ld bc, sBoxEnd - (sBox + 2)
.clear
2015-08-19 17:13:48 +00:00
xor a
ld [de], a
inc de
dec bc
ld a, b
or c
2015-08-20 04:14:15 +00:00
jr nz, .clear
2015-08-19 17:13:48 +00:00
ld a, [hli]
ld e, a
ld a, [hli]
ld d, a
ld a, -1
ld [de], a
inc de
xor a
ld [de], a
call CloseSRAM
pop bc
dec c
2015-08-20 04:14:15 +00:00
jr nz, .next
2015-08-19 17:13:48 +00:00
ret
2018-06-24 14:09:41 +00:00
BoxAddresses:
2015-08-19 17:13:48 +00:00
; dbww bank, address, address
2015-08-20 04:14:15 +00:00
dbww BANK(sBox1), sBox1, sBox1End
dbww BANK(sBox2), sBox2, sBox2End
dbww BANK(sBox3), sBox3, sBox3End
dbww BANK(sBox4), sBox4, sBox4End
dbww BANK(sBox5), sBox5, sBox5End
dbww BANK(sBox6), sBox6, sBox6End
dbww BANK(sBox7), sBox7, sBox7End
dbww BANK(sBox8), sBox8, sBox8End
dbww BANK(sBox9), sBox9, sBox9End
dbww BANK(sBox10), sBox10, sBox10End
dbww BANK(sBox11), sBox11, sBox11End
dbww BANK(sBox12), sBox12, sBox12End
dbww BANK(sBox13), sBox13, sBox13End
dbww BANK(sBox14), sBox14, sBox14End
2015-08-19 17:13:48 +00:00
2018-06-24 14:09:41 +00:00
Checksum:
2015-08-19 17:13:48 +00:00
ld de, 0
.loop
ld a, [hli]
add e
ld e, a
ld a, 0
adc d
ld d, a
dec bc
ld a, b
or c
jr nz, .loop
ret
Text_WouldYouLikeToSaveTheGame:
2015-08-19 17:13:48 +00:00
; Would you like to save the game?
text_jump UnknownText_0x1c454b
db "@"
Text_SavingDontTurnOffThePower:
2015-08-19 17:13:48 +00:00
; SAVING… DON'T TURN OFF THE POWER.
text_jump UnknownText_0x1c456d
db "@"
Text_PlayerSavedTheGame:
2015-08-19 17:13:48 +00:00
; saved the game.
text_jump UnknownText_0x1c4590
db "@"
Text_AlreadyASaveFile:
2015-08-19 17:13:48 +00:00
; There is already a save file. Is it OK to overwrite?
text_jump UnknownText_0x1c45a3
db "@"
Text_AnotherSaveFile:
2015-08-19 17:13:48 +00:00
; There is another save file. Is it OK to overwrite?
text_jump UnknownText_0x1c45d9
db "@"
Text_SaveFileCorrupted:
2015-08-19 17:13:48 +00:00
; The save file is corrupted!
text_jump UnknownText_0x1c460d
db "@"
Text_SaveOnBoxSwitch:
2015-08-19 17:13:48 +00:00
; When you change a #MON BOX, data will be saved. OK?
text_jump UnknownText_0x1c462a
db "@"
Text_SaveOnMoveMonWOMail:
2015-08-19 17:13:48 +00:00
; Each time you move a #MON, data will be saved. OK?
text_jump UnknownText_0x1c465f
db "@"