2018-06-24 14:09:41 +00:00
|
|
|
SaveMenu:
|
2018-01-23 21:08:43 +00:00
|
|
|
call LoadStandardMenuHeader
|
2017-12-24 17:47:30 +00:00
|
|
|
farcall DisplaySaveInfoOnSave
|
2019-04-08 12:15:10 +00:00
|
|
|
call SpeechTextbox
|
2015-08-19 17:13:48 +00:00
|
|
|
call UpdateSprites
|
2017-12-24 23:11:17 +00:00
|
|
|
farcall SaveMenu_CopyTilemapAtOnce
|
2019-10-20 22:24:17 +00:00
|
|
|
ld hl, WouldYouLikeToSaveTheGameText
|
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
|
2016-05-08 18:11:24 +00:00
|
|
|
call PauseGameLogic
|
2015-08-19 17:13:48 +00:00
|
|
|
call _SavingDontTurnOffThePower
|
2016-05-08 18:11:24 +00:00
|
|
|
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
|
2020-06-21 20:27:43 +00:00
|
|
|
call GSReloadPalettes
|
2017-12-24 23:11:17 +00:00
|
|
|
farcall SaveMenu_CopyTilemapAtOnce
|
2015-08-19 17:13:48 +00:00
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
SaveAfterLinkTrade:
|
2016-05-08 18:11:24 +00:00
|
|
|
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
|
2016-05-08 18:11:24 +00:00
|
|
|
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
|
2019-10-20 22:24:17 +00:00
|
|
|
ld hl, ChangeBoxSaveText
|
2019-04-08 12:15:10 +00:00
|
|
|
call MenuTextbox
|
2015-08-19 17:13:48 +00:00
|
|
|
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
|
2016-05-08 18:11:24 +00:00
|
|
|
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
|
2016-05-08 18:11:24 +00:00
|
|
|
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
|
2016-05-08 18:11:24 +00:00
|
|
|
call PauseGameLogic
|
2015-08-19 17:13:48 +00:00
|
|
|
call _SavingDontTurnOffThePower
|
2016-05-08 18:11:24 +00:00
|
|
|
call ResumeGameLogic
|
2015-08-19 17:13:48 +00:00
|
|
|
and a
|
|
|
|
|
|
|
|
.refused
|
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
MoveMonWOMail_SaveGame:
|
2016-05-08 18:11:24 +00:00
|
|
|
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
|
2016-05-08 18:11:24 +00:00
|
|
|
call ResumeGameLogic
|
2015-08-19 17:13:48 +00:00
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
MoveMonWOMail_InsertMon_SaveGame:
|
2016-05-08 18:11:24 +00:00
|
|
|
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
|
2016-05-08 18:11:24 +00:00
|
|
|
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:
|
2019-10-20 22:24:17 +00:00
|
|
|
ld hl, MoveMonWOMailSaveText
|
2019-04-08 12:15:10 +00:00
|
|
|
call MenuTextbox
|
2015-08-19 17:13:48 +00:00
|
|
|
call YesNoBox
|
|
|
|
call ExitMenu
|
2015-11-18 04:29:14 +00:00
|
|
|
jr c, .refused
|
|
|
|
call AskOverwriteSaveFile
|
|
|
|
jr c, .refused
|
2016-05-08 18:11:24 +00:00
|
|
|
call PauseGameLogic
|
2015-08-19 17:13:48 +00:00
|
|
|
call _SavingDontTurnOffThePower
|
2016-05-08 18:11:24 +00:00
|
|
|
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:
|
2018-07-28 23:27:34 +00:00
|
|
|
ld a, TRUE
|
2016-05-08 18:11:24 +00:00
|
|
|
ld [wGameLogicPaused], a
|
2015-08-19 17:13:48 +00:00
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
ResumeGameLogic:
|
2018-07-28 23:27:34 +00:00
|
|
|
xor a ; FALSE
|
2016-05-08 18:11:24 +00:00
|
|
|
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)
|
2020-06-17 21:03:38 +00:00
|
|
|
call OpenSRAM
|
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
|
2018-03-19 15:36:14 +00:00
|
|
|
ld hl, wHallOfFamePokemonList
|
2015-08-20 04:14:15 +00:00
|
|
|
ld de, sHallOfFame
|
2018-03-19 15:36:14 +00:00
|
|
|
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:
|
2018-07-23 04:13:43 +00:00
|
|
|
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
|
2019-10-20 22:24:17 +00:00
|
|
|
ld hl, AnotherSaveFileText
|
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
|
2019-10-20 22:24:17 +00:00
|
|
|
ld hl, AlreadyASaveFileText
|
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:
|
2019-10-20 22:24:17 +00:00
|
|
|
ld b, BANK(WouldYouLikeToSaveTheGameText)
|
2015-08-19 17:13:48 +00:00
|
|
|
call MapTextbox
|
2019-04-08 12:15:10 +00:00
|
|
|
call LoadMenuTextbox
|
2015-08-19 17:13:48 +00:00
|
|
|
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
|
2015-12-25 03:58:42 +00:00
|
|
|
call CloseWindow
|
2015-08-19 17:13:48 +00:00
|
|
|
push af
|
2020-06-21 20:27:43 +00:00
|
|
|
call GSReloadPalettes
|
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)
|
2020-06-17 21:03:38 +00:00
|
|
|
call OpenSRAM
|
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:
|
2018-07-23 04:13:43 +00:00
|
|
|
call _SaveGameData
|
2015-08-19 17:13:48 +00:00
|
|
|
; wait 32 frames
|
2018-07-28 23:27:34 +00:00
|
|
|
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
|
2018-07-28 23:27:34 +00:00
|
|
|
; 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!
|
2019-10-20 22:24:17 +00:00
|
|
|
ld hl, SavedTheGameText
|
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
|
2018-07-28 23:27:34 +00:00
|
|
|
ld c, 30
|
2015-08-19 17:13:48 +00:00
|
|
|
call DelayFrames
|
|
|
|
ret
|
|
|
|
|
2018-07-23 04:13:43 +00:00
|
|
|
_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
|
2015-11-24 20:18:44 +00:00
|
|
|
ld a, BANK(sBattleTowerChallengeState)
|
2020-06-17 21:03:38 +00:00
|
|
|
call OpenSRAM
|
2015-11-24 20:18:44 +00:00
|
|
|
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
|
2015-11-24 20:18:44 +00:00
|
|
|
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)
|
2020-06-17 21:03:38 +00:00
|
|
|
call OpenSRAM
|
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.
|
2020-06-16 03:28:24 +00:00
|
|
|
ld hl, wStackBottom
|
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
|
2018-08-25 18:28:22 +00:00
|
|
|
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
|
2018-07-28 23:27:34 +00:00
|
|
|
; 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.
|
2019-10-20 22:24:17 +00:00
|
|
|
ld hl, SavingDontTurnOffThePowerText
|
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
|
2018-07-28 23:27:34 +00:00
|
|
|
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)
|
2020-06-17 21:03:38 +00:00
|
|
|
call OpenSRAM
|
2015-08-19 17:13:48 +00:00
|
|
|
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)
|
2020-06-17 21:03:38 +00:00
|
|
|
call OpenSRAM
|
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)
|
2020-06-17 21:03:38 +00:00
|
|
|
call OpenSRAM
|
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)
|
2020-06-17 21:03:38 +00:00
|
|
|
call OpenSRAM
|
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
|
|
|
|
|
2020-06-21 20:27:43 +00:00
|
|
|
Function14d18: ; unreferenced
|
2020-11-01 17:36:38 +00:00
|
|
|
ld a, BANK(s4_a007) ; MBC30 bank used by JP Crystal; inaccessible by MBC3
|
2020-06-17 21:03:38 +00:00
|
|
|
call OpenSRAM
|
2016-05-12 01:19:52 +00:00
|
|
|
ld hl, .Data
|
2019-04-27 17:50:24 +00:00
|
|
|
ld de, s4_a007
|
2020-11-01 17:36:38 +00:00
|
|
|
ld bc, 4 * 12
|
2015-08-19 17:13:48 +00:00
|
|
|
call CopyBytes
|
|
|
|
jp CloseSRAM
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
.Data:
|
2020-11-01 17:36:38 +00:00
|
|
|
db $0d, $02, $00, $05, $00, $00, $22, $02, $01, $05, $00, $00
|
|
|
|
db $03, $04, $05, $08, $03, $05, $0e, $06, $03, $02, $00, $00
|
|
|
|
db $39, $07, $07, $04, $00, $05, $04, $07, $01, $05, $00, $00
|
|
|
|
db $0f, $05, $14, $07, $05, $05, $11, $0c, $0c, $06, $06, $04
|
2015-08-19 17:13:48 +00:00
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
EraseBattleTowerStatus:
|
2015-11-24 20:18:44 +00:00
|
|
|
ld a, BANK(sBattleTowerChallengeState)
|
2020-06-17 21:03:38 +00:00
|
|
|
call OpenSRAM
|
2015-08-19 17:13:48 +00:00
|
|
|
xor a
|
2015-11-24 20:18:44 +00:00
|
|
|
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
|
|
|
|
|
2020-06-21 20:27:43 +00:00
|
|
|
Function14d6c: ; unreferenced
|
2020-06-13 22:48:26 +00:00
|
|
|
ld a, BANK(s4_a60b) ; MBC30 bank used by JP Crystal; inaccessible by MBC3
|
2020-06-17 21:03:38 +00:00
|
|
|
call OpenSRAM
|
2020-06-13 22:48:26 +00:00
|
|
|
ld a, [s4_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
|
2020-06-13 22:48:26 +00:00
|
|
|
ld [s4_a60b], a ; address of MBC30 bank
|
2015-08-19 17:13:48 +00:00
|
|
|
call CloseSRAM
|
|
|
|
ret
|
|
|
|
|
2020-06-21 20:27:43 +00:00
|
|
|
Function14d83: ; unreferenced
|
2020-06-13 22:48:26 +00:00
|
|
|
ld a, BANK(s4_a60c) ; aka BANK(s4_a60d) ; MBC30 bank used by JP Crystal; inaccessible by MBC3
|
2020-06-17 21:03:38 +00:00
|
|
|
call OpenSRAM
|
2015-08-19 17:13:48 +00:00
|
|
|
xor a
|
2020-06-13 22:48:26 +00:00
|
|
|
ld [s4_a60c], a ; address of MBC30 bank
|
|
|
|
ld [s4_a60d], a ; address of MBC30 bank
|
2015-08-19 17:13:48 +00:00
|
|
|
call CloseSRAM
|
|
|
|
ret
|
|
|
|
|
2020-06-21 20:27:43 +00:00
|
|
|
Function14d93: ; unreferenced
|
2020-06-13 22:48:26 +00:00
|
|
|
ld a, BANK(s7_a000) ; MBC30 bank used by JP Crystal; inaccessible by MBC3
|
2020-06-17 21:03:38 +00:00
|
|
|
call OpenSRAM
|
2015-08-19 17:13:48 +00:00
|
|
|
xor a
|
2020-06-13 22:48:26 +00:00
|
|
|
ld [s7_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:
|
2019-01-12 20:17:20 +00:00
|
|
|
ld a, BANK(sCheckValue1) ; aka BANK(sCheckValue2)
|
2020-06-17 21:03:38 +00:00
|
|
|
call OpenSRAM
|
2017-12-16 02:22:26 +00:00
|
|
|
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)
|
2020-06-17 21:03:38 +00:00
|
|
|
call OpenSRAM
|
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)
|
2020-06-17 21:03:38 +00:00
|
|
|
call OpenSRAM
|
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
|
2018-09-09 19:09:51 +00:00
|
|
|
ld hl, wCurMapData
|
|
|
|
ld de, sCurMapData
|
|
|
|
ld bc, wCurMapDataEnd - wCurMapData
|
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)
|
2020-06-17 21:03:38 +00:00
|
|
|
call OpenSRAM
|
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)
|
2020-06-17 21:03:38 +00:00
|
|
|
call OpenSRAM
|
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:
|
2019-01-12 20:17:20 +00:00
|
|
|
ld a, BANK(sBackupCheckValue1) ; aka BANK(sBackupCheckValue2)
|
2020-06-17 21:03:38 +00:00
|
|
|
call OpenSRAM
|
2017-12-16 02:22:26 +00:00
|
|
|
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)
|
2020-06-17 21:03:38 +00:00
|
|
|
call OpenSRAM
|
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)
|
2020-06-17 21:03:38 +00:00
|
|
|
call OpenSRAM
|
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
|
2018-09-09 19:09:51 +00:00
|
|
|
ld hl, wCurMapData
|
|
|
|
ld de, sBackupCurMapData
|
|
|
|
ld bc, wCurMapDataEnd - wCurMapData
|
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)
|
2020-06-17 21:03:38 +00:00
|
|
|
call OpenSRAM
|
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)
|
2020-06-17 21:03:38 +00:00
|
|
|
call OpenSRAM
|
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
|
2019-10-20 22:24:17 +00:00
|
|
|
ld hl, SaveFileCorruptedText
|
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)
|
2020-06-17 21:03:38 +00:00
|
|
|
call OpenSRAM
|
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
|
2017-12-28 12:15:46 +00:00
|
|
|
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)
|
2020-06-17 21:03:38 +00:00
|
|
|
call OpenSRAM
|
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
|
2017-12-28 12:15:46 +00:00
|
|
|
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
|
2020-02-16 11:20:20 +00:00
|
|
|
call ClearClock
|
2015-08-19 17:13:48 +00:00
|
|
|
ret
|
|
|
|
|
2017-12-11 18:47:58 +00:00
|
|
|
INCLUDE "data/default_options.asm"
|
2017-12-12 03:44:25 +00:00
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
CheckPrimarySaveFile:
|
2019-01-12 20:17:20 +00:00
|
|
|
ld a, BANK(sCheckValue1) ; aka BANK(sCheckValue2)
|
2020-06-17 21:03:38 +00:00
|
|
|
call OpenSRAM
|
2017-12-16 02:22:26 +00:00
|
|
|
ld a, [sCheckValue1]
|
|
|
|
cp SAVE_CHECK_VALUE_1
|
2015-08-19 17:13:48 +00:00
|
|
|
jr nz, .nope
|
2017-12-16 02:22:26 +00:00
|
|
|
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:
|
2019-01-12 20:17:20 +00:00
|
|
|
ld a, BANK(sBackupCheckValue1) ; aka BANK(sBackupCheckValue2)
|
2020-06-17 21:03:38 +00:00
|
|
|
call OpenSRAM
|
2017-12-16 02:22:26 +00:00
|
|
|
ld a, [sBackupCheckValue1]
|
|
|
|
cp SAVE_CHECK_VALUE_1
|
2015-08-19 17:13:48 +00:00
|
|
|
jr nz, .nope
|
2017-12-16 02:22:26 +00:00
|
|
|
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)
|
2020-06-17 21:03:38 +00:00
|
|
|
call OpenSRAM
|
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
|
2018-09-09 19:09:51 +00:00
|
|
|
ld hl, sCurMapData
|
|
|
|
ld de, wCurMapData
|
|
|
|
ld bc, wCurMapDataEnd - wCurMapData
|
2015-08-19 17:13:48 +00:00
|
|
|
call CopyBytes
|
|
|
|
call CloseSRAM
|
2015-11-24 20:18:44 +00:00
|
|
|
ld a, BANK(sBattleTowerChallengeState)
|
2020-06-17 21:03:38 +00:00
|
|
|
call OpenSRAM
|
2015-11-24 20:18:44 +00:00
|
|
|
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
|
2015-11-24 20:18:44 +00:00
|
|
|
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)
|
2020-06-17 21:03:38 +00:00
|
|
|
call OpenSRAM
|
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)
|
2020-06-17 21:03:38 +00:00
|
|
|
call OpenSRAM
|
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)
|
2020-06-17 21:03:38 +00:00
|
|
|
call OpenSRAM
|
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
|
2018-09-09 19:09:51 +00:00
|
|
|
ld hl, sBackupCurMapData
|
|
|
|
ld de, wCurMapData
|
|
|
|
ld bc, wCurMapDataEnd - wCurMapData
|
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)
|
2020-06-17 21:03:38 +00:00
|
|
|
call OpenSRAM
|
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)
|
2020-06-17 21:03:38 +00:00
|
|
|
call OpenSRAM
|
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)
|
2020-06-17 21:03:38 +00:00
|
|
|
call OpenSRAM
|
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
|
2020-06-21 16:21:47 +00:00
|
|
|
; BANK(sCrystalData), it instead overwrites the sixteen wEventFlags starting at 1:s4_a60e 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]
|
2019-04-27 17:50:24 +00:00
|
|
|
ld [s4_a60e + 0], a
|
2015-08-19 17:13:48 +00:00
|
|
|
ld a, [hli]
|
2019-04-27 17:50:24 +00:00
|
|
|
ld [s4_a60e + 1], 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
|
|
|
_LoadData:
|
2015-08-20 04:14:15 +00:00
|
|
|
ld a, BANK(sCrystalData)
|
2020-06-17 21:03:38 +00:00
|
|
|
call OpenSRAM
|
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
|
2019-04-27 17:50:24 +00:00
|
|
|
ld a, [s4_a60e + 0]
|
2015-08-19 17:13:48 +00:00
|
|
|
ld [hli], a
|
2019-04-27 17:50:24 +00:00
|
|
|
ld a, [s4_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:
|
2018-03-19 15:36:14 +00:00
|
|
|
; 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)
|
2020-06-17 21:03:38 +00:00
|
|
|
call OpenSRAM
|
2015-08-20 04:14:15 +00:00
|
|
|
ld hl, sBox
|
2018-03-19 15:36:14 +00:00
|
|
|
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
|
2020-06-17 21:03:38 +00:00
|
|
|
call OpenSRAM
|
2018-03-19 15:36:14 +00:00
|
|
|
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)
|
2020-06-17 21:03:38 +00:00
|
|
|
call OpenSRAM
|
2018-03-19 15:36:14 +00:00
|
|
|
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
|
|
|
|
2018-03-19 15:36:14 +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
|
2020-06-17 21:03:38 +00:00
|
|
|
call OpenSRAM
|
2018-03-19 15:36:14 +00:00
|
|
|
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)
|
2020-06-17 21:03:38 +00:00
|
|
|
call OpenSRAM
|
2018-03-19 15:36:14 +00:00
|
|
|
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
|
|
|
|
2018-03-19 15:36:14 +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.
|
2020-06-17 21:03:38 +00:00
|
|
|
call OpenSRAM
|
2018-03-19 15:36:14 +00:00
|
|
|
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:
|
2018-03-19 15:36:14 +00:00
|
|
|
; 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
|
2020-06-17 21:03:38 +00:00
|
|
|
call OpenSRAM
|
2018-03-19 15:36:14 +00:00
|
|
|
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)
|
2020-06-17 21:03:38 +00:00
|
|
|
call OpenSRAM
|
2018-03-19 15:36:14 +00:00
|
|
|
ld hl, wBoxPartialData
|
2015-08-20 04:14:15 +00:00
|
|
|
ld de, sBox
|
2018-03-19 15:36:14 +00:00
|
|
|
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
|
|
|
|
2018-03-19 15:36:14 +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
|
2020-06-17 21:03:38 +00:00
|
|
|
call OpenSRAM
|
2018-03-19 15:36:14 +00:00
|
|
|
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)
|
2020-06-17 21:03:38 +00:00
|
|
|
call OpenSRAM
|
2018-03-19 15:36:14 +00:00
|
|
|
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
|
2018-03-19 15:36:14 +00:00
|
|
|
ld de, (wBoxPartialDataEnd - wBoxPartialData)
|
2015-08-19 17:13:48 +00:00
|
|
|
add hl, de
|
2020-06-17 21:03:38 +00:00
|
|
|
call OpenSRAM
|
2018-03-19 15:36:14 +00:00
|
|
|
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)
|
2020-06-17 21:03:38 +00:00
|
|
|
call OpenSRAM
|
2018-03-19 15:36:14 +00:00
|
|
|
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]
|
2020-06-17 21:03:38 +00:00
|
|
|
call OpenSRAM
|
2015-08-19 17:13:48 +00:00
|
|
|
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
|
|
|
|
|
2019-10-20 22:24:17 +00:00
|
|
|
WouldYouLikeToSaveTheGameText:
|
|
|
|
text_far _WouldYouLikeToSaveTheGameText
|
2018-11-17 18:33:03 +00:00
|
|
|
text_end
|
2015-08-19 17:13:48 +00:00
|
|
|
|
2019-10-20 22:24:17 +00:00
|
|
|
SavingDontTurnOffThePowerText:
|
|
|
|
text_far _SavingDontTurnOffThePowerText
|
2018-11-17 18:33:03 +00:00
|
|
|
text_end
|
2015-08-19 17:13:48 +00:00
|
|
|
|
2019-10-20 22:24:17 +00:00
|
|
|
SavedTheGameText:
|
|
|
|
text_far _SavedTheGameText
|
2018-11-17 18:33:03 +00:00
|
|
|
text_end
|
2015-08-19 17:13:48 +00:00
|
|
|
|
2019-10-20 22:24:17 +00:00
|
|
|
AlreadyASaveFileText:
|
|
|
|
text_far _AlreadyASaveFileText
|
2018-11-17 18:33:03 +00:00
|
|
|
text_end
|
2015-08-19 17:13:48 +00:00
|
|
|
|
2019-10-20 22:24:17 +00:00
|
|
|
AnotherSaveFileText:
|
|
|
|
text_far _AnotherSaveFileText
|
2018-11-17 18:33:03 +00:00
|
|
|
text_end
|
2015-08-19 17:13:48 +00:00
|
|
|
|
2019-10-20 22:24:17 +00:00
|
|
|
SaveFileCorruptedText:
|
|
|
|
text_far _SaveFileCorruptedText
|
2018-11-17 18:33:03 +00:00
|
|
|
text_end
|
2015-08-19 17:13:48 +00:00
|
|
|
|
2019-10-20 22:24:17 +00:00
|
|
|
ChangeBoxSaveText:
|
|
|
|
text_far _ChangeBoxSaveText
|
2018-11-17 18:33:03 +00:00
|
|
|
text_end
|
2015-08-19 17:13:48 +00:00
|
|
|
|
2019-10-20 22:24:17 +00:00
|
|
|
MoveMonWOMailSaveText:
|
|
|
|
text_far _MoveMonWOMailSaveText
|
2018-11-17 18:33:03 +00:00
|
|
|
text_end
|