2018-06-24 07:09:41 -07:00
|
|
|
SaveMenu:
|
2018-01-23 13:08:43 -08:00
|
|
|
call LoadStandardMenuHeader
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall DisplaySaveInfoOnSave
|
2019-04-08 05:15:10 -07:00
|
|
|
call SpeechTextbox
|
2015-08-19 10:13:48 -07:00
|
|
|
call UpdateSprites
|
2017-12-24 15:11:17 -08:00
|
|
|
farcall SaveMenu_CopyTilemapAtOnce
|
2019-10-20 15:24:17 -07:00
|
|
|
ld hl, WouldYouLikeToSaveTheGameText
|
2015-08-19 10:13:48 -07:00
|
|
|
call SaveTheGame_yesorno
|
|
|
|
jr nz, .refused
|
2015-11-17 20:29:14 -08:00
|
|
|
call AskOverwriteSaveFile
|
2015-08-19 10:13:48 -07:00
|
|
|
jr c, .refused
|
2016-05-08 11:11:24 -07:00
|
|
|
call PauseGameLogic
|
2015-08-19 10:13:48 -07:00
|
|
|
call _SavingDontTurnOffThePower
|
2016-05-08 11:11:24 -07:00
|
|
|
call ResumeGameLogic
|
2015-08-19 10:13:48 -07:00
|
|
|
call ExitMenu
|
|
|
|
and a
|
|
|
|
ret
|
2015-11-17 20:29:14 -08:00
|
|
|
|
2015-08-19 10:13:48 -07:00
|
|
|
.refused
|
|
|
|
call ExitMenu
|
2020-06-21 13:27:43 -07:00
|
|
|
call GSReloadPalettes
|
2017-12-24 15:11:17 -08:00
|
|
|
farcall SaveMenu_CopyTilemapAtOnce
|
2015-08-19 10:13:48 -07:00
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
SaveAfterLinkTrade:
|
2016-05-08 11:11:24 -07:00
|
|
|
call PauseGameLogic
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall StageRTCTimeForSave
|
|
|
|
farcall BackupMysteryGift
|
2015-08-19 21:14:15 -07:00
|
|
|
call SavePokemonData
|
2015-11-17 20:29:14 -08:00
|
|
|
call SaveChecksum
|
2015-08-19 21:14:15 -07:00
|
|
|
call SaveBackupPokemonData
|
|
|
|
call SaveBackupChecksum
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall BackupPartyMonMail
|
|
|
|
farcall SaveRTC
|
2016-05-08 11:11:24 -07:00
|
|
|
call ResumeGameLogic
|
2015-08-19 10:13:48 -07:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
ChangeBoxSaveGame:
|
2015-08-19 10:13:48 -07:00
|
|
|
push de
|
2019-10-20 15:24:17 -07:00
|
|
|
ld hl, ChangeBoxSaveText
|
2019-04-08 05:15:10 -07:00
|
|
|
call MenuTextbox
|
2015-08-19 10:13:48 -07:00
|
|
|
call YesNoBox
|
|
|
|
call ExitMenu
|
|
|
|
jr c, .refused
|
2015-11-17 20:29:14 -08:00
|
|
|
call AskOverwriteSaveFile
|
2015-08-19 10:13:48 -07:00
|
|
|
jr c, .refused
|
2016-05-08 11:11:24 -07:00
|
|
|
call PauseGameLogic
|
2015-08-19 10:13:48 -07:00
|
|
|
call SavingDontTurnOffThePower
|
2015-08-19 21:14:15 -07:00
|
|
|
call SaveBox
|
2015-08-19 10:13:48 -07:00
|
|
|
pop de
|
|
|
|
ld a, e
|
|
|
|
ld [wCurBox], a
|
2015-08-19 21:14:15 -07:00
|
|
|
call LoadBox
|
2015-08-19 10:13:48 -07:00
|
|
|
call SavedTheGame
|
2016-05-08 11:11:24 -07:00
|
|
|
call ResumeGameLogic
|
2015-08-19 10:13:48 -07:00
|
|
|
and a
|
|
|
|
ret
|
|
|
|
.refused
|
|
|
|
pop de
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
Link_SaveGame:
|
2015-11-17 20:29:14 -08:00
|
|
|
call AskOverwriteSaveFile
|
2015-08-19 10:13:48 -07:00
|
|
|
jr c, .refused
|
2016-05-08 11:11:24 -07:00
|
|
|
call PauseGameLogic
|
2015-08-19 10:13:48 -07:00
|
|
|
call _SavingDontTurnOffThePower
|
2016-05-08 11:11:24 -07:00
|
|
|
call ResumeGameLogic
|
2015-08-19 10:13:48 -07:00
|
|
|
and a
|
|
|
|
|
|
|
|
.refused
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
MoveMonWOMail_SaveGame:
|
2016-05-08 11:11:24 -07:00
|
|
|
call PauseGameLogic
|
2015-08-19 10:13:48 -07:00
|
|
|
push de
|
2015-08-19 21:14:15 -07:00
|
|
|
call SaveBox
|
2015-08-19 10:13:48 -07:00
|
|
|
pop de
|
|
|
|
ld a, e
|
|
|
|
ld [wCurBox], a
|
2015-08-19 21:14:15 -07:00
|
|
|
call LoadBox
|
2016-05-08 11:11:24 -07:00
|
|
|
call ResumeGameLogic
|
2015-08-19 10:13:48 -07:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
MoveMonWOMail_InsertMon_SaveGame:
|
2016-05-08 11:11:24 -07:00
|
|
|
call PauseGameLogic
|
2015-08-19 10:13:48 -07:00
|
|
|
push de
|
2015-08-19 21:14:15 -07:00
|
|
|
call SaveBox
|
2015-08-19 10:13:48 -07:00
|
|
|
pop de
|
|
|
|
ld a, e
|
|
|
|
ld [wCurBox], a
|
2018-07-03 23:50:27 -07:00
|
|
|
ld a, TRUE
|
2015-11-17 20:29:14 -08:00
|
|
|
ld [wSaveFileExists], a
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall StageRTCTimeForSave
|
|
|
|
farcall BackupMysteryGift
|
2015-08-19 21:14:15 -07:00
|
|
|
call ValidateSave
|
|
|
|
call SaveOptions
|
2015-08-19 10:13:48 -07:00
|
|
|
call SavePlayerData
|
2015-08-19 21:14:15 -07:00
|
|
|
call SavePokemonData
|
2015-11-17 20:29:14 -08:00
|
|
|
call SaveChecksum
|
2015-08-19 21:14:15 -07:00
|
|
|
call ValidateBackupSave
|
|
|
|
call SaveBackupOptions
|
|
|
|
call SaveBackupPlayerData
|
|
|
|
call SaveBackupPokemonData
|
|
|
|
call SaveBackupChecksum
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall BackupPartyMonMail
|
|
|
|
farcall BackupMobileEventIndex
|
|
|
|
farcall SaveRTC
|
2015-08-19 21:14:15 -07:00
|
|
|
call LoadBox
|
2016-05-08 11:11:24 -07:00
|
|
|
call ResumeGameLogic
|
2015-08-19 10:13:48 -07:00
|
|
|
ld de, SFX_SAVE
|
|
|
|
call PlaySFX
|
2015-11-17 20:29:14 -08:00
|
|
|
ld c, 24
|
2015-08-19 10:13:48 -07:00
|
|
|
call DelayFrames
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
StartMoveMonWOMail_SaveGame:
|
2019-10-20 15:24:17 -07:00
|
|
|
ld hl, MoveMonWOMailSaveText
|
2019-04-08 05:15:10 -07:00
|
|
|
call MenuTextbox
|
2015-08-19 10:13:48 -07:00
|
|
|
call YesNoBox
|
|
|
|
call ExitMenu
|
2015-11-17 20:29:14 -08:00
|
|
|
jr c, .refused
|
|
|
|
call AskOverwriteSaveFile
|
|
|
|
jr c, .refused
|
2016-05-08 11:11:24 -07:00
|
|
|
call PauseGameLogic
|
2015-08-19 10:13:48 -07:00
|
|
|
call _SavingDontTurnOffThePower
|
2016-05-08 11:11:24 -07:00
|
|
|
call ResumeGameLogic
|
2015-08-19 10:13:48 -07:00
|
|
|
and a
|
|
|
|
ret
|
|
|
|
|
2015-11-17 20:29:14 -08:00
|
|
|
.refused
|
2015-08-19 10:13:48 -07:00
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
PauseGameLogic:
|
2018-07-28 16:27:34 -07:00
|
|
|
ld a, TRUE
|
2016-05-08 11:11:24 -07:00
|
|
|
ld [wGameLogicPaused], a
|
2015-08-19 10:13:48 -07:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
ResumeGameLogic:
|
2018-07-28 16:27:34 -07:00
|
|
|
xor a ; FALSE
|
2016-05-08 11:11:24 -07:00
|
|
|
ld [wGameLogicPaused], a
|
2015-08-19 10:13:48 -07:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
AddHallOfFameEntry:
|
2015-08-19 21:14:15 -07:00
|
|
|
ld a, BANK(sHallOfFame)
|
2020-06-17 14:03:38 -07:00
|
|
|
call OpenSRAM
|
2015-08-19 21:14:15 -07: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 10:13:48 -07:00
|
|
|
.loop
|
|
|
|
ld a, [hld]
|
|
|
|
ld [de], a
|
|
|
|
dec de
|
|
|
|
dec bc
|
|
|
|
ld a, c
|
|
|
|
or b
|
|
|
|
jr nz, .loop
|
2018-03-19 08:36:14 -07:00
|
|
|
ld hl, wHallOfFamePokemonList
|
2015-08-19 21:14:15 -07:00
|
|
|
ld de, sHallOfFame
|
2018-03-19 08:36:14 -07:00
|
|
|
ld bc, wHallOfFamePokemonListEnd - wHallOfFamePokemonList + 1
|
2015-08-19 10:13:48 -07:00
|
|
|
call CopyBytes
|
|
|
|
call CloseSRAM
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
SaveGameData:
|
2018-07-22 21:13:43 -07:00
|
|
|
call _SaveGameData
|
2015-08-19 10:13:48 -07:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
AskOverwriteSaveFile:
|
2015-11-17 20:29:14 -08:00
|
|
|
ld a, [wSaveFileExists]
|
2015-08-19 10:13:48 -07:00
|
|
|
and a
|
2015-08-19 21:14:15 -07:00
|
|
|
jr z, .erase
|
2015-11-26 18:05:32 -08:00
|
|
|
call CompareLoadedAndSavedPlayerID
|
2015-08-19 10:13:48 -07:00
|
|
|
jr z, .yoursavefile
|
2019-10-20 15:24:17 -07:00
|
|
|
ld hl, AnotherSaveFileText
|
2015-08-19 10:13:48 -07:00
|
|
|
call SaveTheGame_yesorno
|
|
|
|
jr nz, .refused
|
2015-08-19 21:14:15 -07:00
|
|
|
jr .erase
|
2015-08-19 10:13:48 -07:00
|
|
|
|
|
|
|
.yoursavefile
|
2019-10-20 15:24:17 -07:00
|
|
|
ld hl, AlreadyASaveFileText
|
2015-08-19 10:13:48 -07:00
|
|
|
call SaveTheGame_yesorno
|
|
|
|
jr nz, .refused
|
|
|
|
jr .ok
|
|
|
|
|
2015-08-19 21:14:15 -07:00
|
|
|
.erase
|
|
|
|
call ErasePreviousSave
|
2015-08-19 10:13:48 -07:00
|
|
|
|
|
|
|
.ok
|
|
|
|
and a
|
|
|
|
ret
|
|
|
|
|
|
|
|
.refused
|
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
SaveTheGame_yesorno:
|
2019-10-20 15:24:17 -07:00
|
|
|
ld b, BANK(WouldYouLikeToSaveTheGameText)
|
2015-08-19 10:13:48 -07:00
|
|
|
call MapTextbox
|
2019-04-08 05:15:10 -07:00
|
|
|
call LoadMenuTextbox
|
2015-08-19 10:13:48 -07:00
|
|
|
lb bc, 0, 7
|
|
|
|
call PlaceYesNoBox
|
2015-12-15 15:59:49 -08:00
|
|
|
ld a, [wMenuCursorY]
|
2015-08-19 10:13:48 -07:00
|
|
|
dec a
|
2015-12-24 19:58:42 -08:00
|
|
|
call CloseWindow
|
2015-08-19 10:13:48 -07:00
|
|
|
push af
|
2020-06-21 13:27:43 -07:00
|
|
|
call GSReloadPalettes
|
2015-08-19 10:13:48 -07:00
|
|
|
pop af
|
|
|
|
and a
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
CompareLoadedAndSavedPlayerID:
|
2015-08-19 21:14:15 -07:00
|
|
|
ld a, BANK(sPlayerData)
|
2020-06-17 14:03:38 -07:00
|
|
|
call OpenSRAM
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, sPlayerData + (wPlayerID - wPlayerData)
|
2015-08-19 10:13:48 -07:00
|
|
|
ld a, [hli]
|
|
|
|
ld c, [hl]
|
|
|
|
ld b, a
|
|
|
|
call CloseSRAM
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wPlayerID]
|
2015-08-19 10:13:48 -07:00
|
|
|
cp b
|
|
|
|
ret nz
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wPlayerID + 1]
|
2015-08-19 10:13:48 -07:00
|
|
|
cp c
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
_SavingDontTurnOffThePower:
|
2015-08-19 10:13:48 -07:00
|
|
|
call SavingDontTurnOffThePower
|
2018-06-24 07:09:41 -07:00
|
|
|
SavedTheGame:
|
2018-07-22 21:13:43 -07:00
|
|
|
call _SaveGameData
|
2015-08-19 10:13:48 -07:00
|
|
|
; wait 32 frames
|
2018-07-28 16:27:34 -07:00
|
|
|
ld c, 32
|
2015-08-19 10:13:48 -07:00
|
|
|
call DelayFrames
|
|
|
|
; copy the original text speed setting to the stack
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wOptions]
|
2015-08-19 10:13:48 -07:00
|
|
|
push af
|
2018-07-28 16:27:34 -07:00
|
|
|
; set text speed to medium
|
|
|
|
ld a, TEXT_DELAY_MED
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wOptions], a
|
2015-08-19 10:13:48 -07:00
|
|
|
; <PLAYER> saved the game!
|
2019-10-20 15:24:17 -07:00
|
|
|
ld hl, SavedTheGameText
|
2015-08-19 10:13:48 -07:00
|
|
|
call PrintText
|
|
|
|
; restore the original text speed setting
|
|
|
|
pop af
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wOptions], a
|
2015-08-19 10:13:48 -07:00
|
|
|
ld de, SFX_SAVE
|
|
|
|
call WaitPlaySFX
|
|
|
|
call WaitSFX
|
|
|
|
; wait 30 frames
|
2018-07-28 16:27:34 -07:00
|
|
|
ld c, 30
|
2015-08-19 10:13:48 -07:00
|
|
|
call DelayFrames
|
|
|
|
ret
|
|
|
|
|
2018-07-22 21:13:43 -07:00
|
|
|
_SaveGameData:
|
2018-07-03 23:50:27 -07:00
|
|
|
ld a, TRUE
|
2015-11-17 20:29:14 -08:00
|
|
|
ld [wSaveFileExists], a
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall StageRTCTimeForSave
|
|
|
|
farcall BackupMysteryGift
|
2015-08-19 21:14:15 -07:00
|
|
|
call ValidateSave
|
|
|
|
call SaveOptions
|
2015-08-19 10:13:48 -07:00
|
|
|
call SavePlayerData
|
2015-08-19 21:14:15 -07:00
|
|
|
call SavePokemonData
|
|
|
|
call SaveBox
|
2015-11-17 20:29:14 -08:00
|
|
|
call SaveChecksum
|
2015-08-19 21:14:15 -07:00
|
|
|
call ValidateBackupSave
|
|
|
|
call SaveBackupOptions
|
|
|
|
call SaveBackupPlayerData
|
|
|
|
call SaveBackupPokemonData
|
|
|
|
call SaveBackupChecksum
|
|
|
|
call UpdateStackTop
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall BackupPartyMonMail
|
|
|
|
farcall BackupMobileEventIndex
|
|
|
|
farcall SaveRTC
|
2015-11-24 12:18:44 -08:00
|
|
|
ld a, BANK(sBattleTowerChallengeState)
|
2020-06-17 14:03:38 -07:00
|
|
|
call OpenSRAM
|
2015-11-24 12:18:44 -08:00
|
|
|
ld a, [sBattleTowerChallengeState]
|
2015-11-26 18:05:32 -08:00
|
|
|
cp BATTLETOWER_RECEIVED_REWARD
|
2015-08-19 21:14:15 -07:00
|
|
|
jr nz, .ok
|
2015-08-19 10:13:48 -07:00
|
|
|
xor a
|
2015-11-24 12:18:44 -08:00
|
|
|
ld [sBattleTowerChallengeState], a
|
2015-08-19 21:14:15 -07:00
|
|
|
.ok
|
2015-08-19 10:13:48 -07:00
|
|
|
call CloseSRAM
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
UpdateStackTop:
|
2015-08-19 21:14:15 -07: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 14:03:38 -07:00
|
|
|
call OpenSRAM
|
2015-08-19 21:14:15 -07:00
|
|
|
ld a, [sStackTop + 0]
|
2015-08-19 10:13:48 -07:00
|
|
|
ld e, a
|
2015-08-19 21:14:15 -07:00
|
|
|
ld a, [sStackTop + 1]
|
2015-08-19 10:13:48 -07:00
|
|
|
ld d, a
|
|
|
|
or e
|
2015-08-19 21:14:15 -07:00
|
|
|
jr z, .update
|
2015-08-19 10:13:48 -07:00
|
|
|
ld a, e
|
|
|
|
sub l
|
|
|
|
ld a, d
|
|
|
|
sbc h
|
2015-08-19 21:14:15 -07:00
|
|
|
jr c, .done
|
2015-08-19 10:13:48 -07:00
|
|
|
|
2015-08-19 21:14:15 -07:00
|
|
|
.update
|
2015-08-19 10:13:48 -07:00
|
|
|
ld a, l
|
2015-08-19 21:14:15 -07:00
|
|
|
ld [sStackTop + 0], a
|
2015-08-19 10:13:48 -07:00
|
|
|
ld a, h
|
2015-08-19 21:14:15 -07:00
|
|
|
ld [sStackTop + 1], a
|
2015-08-19 10:13:48 -07:00
|
|
|
|
2015-08-19 21:14:15 -07:00
|
|
|
.done
|
2015-08-19 10:13:48 -07:00
|
|
|
call CloseSRAM
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
FindStackTop:
|
2015-08-19 21:14:15 -07:00
|
|
|
; Find the furthest point that sp has traversed to.
|
|
|
|
; This is distinct from the current value of sp.
|
2020-06-15 20:28:24 -07:00
|
|
|
ld hl, wStackBottom
|
2015-08-19 21:14:15 -07:00
|
|
|
.loop
|
2015-08-19 10:13:48 -07:00
|
|
|
ld a, [hl]
|
|
|
|
or a
|
|
|
|
ret nz
|
|
|
|
inc hl
|
2015-08-19 21:14:15 -07:00
|
|
|
jr .loop
|
2015-08-19 10:13:48 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
SavingDontTurnOffThePower:
|
2015-08-19 10:13:48 -07:00
|
|
|
; Prevent joypad interrupts
|
|
|
|
xor a
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hJoypadReleased], a
|
|
|
|
ldh [hJoypadPressed], a
|
|
|
|
ldh [hJoypadSum], a
|
|
|
|
ldh [hJoypadDown], a
|
2015-08-19 10:13:48 -07:00
|
|
|
; Save the text speed setting to the stack
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wOptions]
|
2015-08-19 10:13:48 -07:00
|
|
|
push af
|
2018-07-28 16:27:34 -07:00
|
|
|
; Set the text speed to medium
|
|
|
|
ld a, TEXT_DELAY_MED
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wOptions], a
|
2015-08-19 10:13:48 -07:00
|
|
|
; SAVING... DON'T TURN OFF THE POWER.
|
2019-10-20 15:24:17 -07:00
|
|
|
ld hl, SavingDontTurnOffThePowerText
|
2015-08-19 10:13:48 -07:00
|
|
|
call PrintText
|
|
|
|
; Restore the text speed setting
|
|
|
|
pop af
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wOptions], a
|
2015-08-19 10:13:48 -07:00
|
|
|
; Wait for 16 frames
|
2018-07-28 16:27:34 -07:00
|
|
|
ld c, 16
|
2015-08-19 10:13:48 -07:00
|
|
|
call DelayFrames
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
ErasePreviousSave:
|
2015-08-19 21:14:15 -07:00
|
|
|
call EraseBoxes
|
|
|
|
call EraseHallOfFame
|
|
|
|
call EraseLinkBattleStats
|
|
|
|
call EraseMysteryGift
|
2015-11-17 20:29:14 -08:00
|
|
|
call SaveData
|
2015-11-26 18:05:32 -08:00
|
|
|
call EraseBattleTowerStatus
|
2015-08-19 21:14:15 -07:00
|
|
|
ld a, BANK(sStackTop)
|
2020-06-17 14:03:38 -07:00
|
|
|
call OpenSRAM
|
2015-08-19 10:13:48 -07:00
|
|
|
xor a
|
2015-08-19 21:14:15 -07:00
|
|
|
ld [sStackTop + 0], a
|
|
|
|
ld [sStackTop + 1], a
|
2015-08-19 10:13:48 -07:00
|
|
|
call CloseSRAM
|
|
|
|
ld a, $1
|
2015-10-16 10:35:43 -07:00
|
|
|
ld [wSavedAtLeastOnce], a
|
2015-08-19 10:13:48 -07:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
EraseLinkBattleStats:
|
2015-08-19 21:14:15 -07:00
|
|
|
ld a, BANK(sLinkBattleStats)
|
2020-06-17 14:03:38 -07:00
|
|
|
call OpenSRAM
|
2015-08-19 21:14:15 -07:00
|
|
|
ld hl, sLinkBattleStats
|
|
|
|
ld bc, sLinkBattleStatsEnd - sLinkBattleStats
|
2015-08-19 10:13:48 -07:00
|
|
|
xor a
|
|
|
|
call ByteFill
|
|
|
|
jp CloseSRAM
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
EraseMysteryGift:
|
2015-11-17 20:29:14 -08:00
|
|
|
ld a, BANK(sBackupMysteryGiftItem)
|
2020-06-17 14:03:38 -07:00
|
|
|
call OpenSRAM
|
2015-11-17 20:29:14 -08:00
|
|
|
ld hl, sBackupMysteryGiftItem
|
|
|
|
ld bc, sBackupMysteryGiftItemEnd - sBackupMysteryGiftItem
|
2015-08-19 10:13:48 -07:00
|
|
|
xor a
|
|
|
|
call ByteFill
|
|
|
|
jp CloseSRAM
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
EraseHallOfFame:
|
2015-08-19 21:14:15 -07:00
|
|
|
ld a, BANK(sHallOfFame)
|
2020-06-17 14:03:38 -07:00
|
|
|
call OpenSRAM
|
2015-08-19 21:14:15 -07:00
|
|
|
ld hl, sHallOfFame
|
|
|
|
ld bc, sHallOfFameEnd - sHallOfFame
|
2015-08-19 10:13:48 -07:00
|
|
|
xor a
|
|
|
|
call ByteFill
|
|
|
|
jp CloseSRAM
|
|
|
|
|
2020-06-21 13:27:43 -07:00
|
|
|
Function14d18: ; unreferenced
|
2020-11-01 09:36:38 -08:00
|
|
|
ld a, BANK(s4_a007) ; MBC30 bank used by JP Crystal; inaccessible by MBC3
|
2020-06-17 14:03:38 -07:00
|
|
|
call OpenSRAM
|
2016-05-11 18:19:52 -07:00
|
|
|
ld hl, .Data
|
2019-04-27 10:50:24 -07:00
|
|
|
ld de, s4_a007
|
2020-11-01 09:36:38 -08:00
|
|
|
ld bc, 4 * 12
|
2015-08-19 10:13:48 -07:00
|
|
|
call CopyBytes
|
|
|
|
jp CloseSRAM
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
.Data:
|
2020-11-01 09:36:38 -08: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 10:13:48 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
EraseBattleTowerStatus:
|
2015-11-24 12:18:44 -08:00
|
|
|
ld a, BANK(sBattleTowerChallengeState)
|
2020-06-17 14:03:38 -07:00
|
|
|
call OpenSRAM
|
2015-08-19 10:13:48 -07:00
|
|
|
xor a
|
2015-11-24 12:18:44 -08:00
|
|
|
ld [sBattleTowerChallengeState], a
|
2015-08-19 10:13:48 -07:00
|
|
|
jp CloseSRAM
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
SaveData:
|
2015-11-17 20:29:14 -08:00
|
|
|
call _SaveData
|
2015-08-19 10:13:48 -07:00
|
|
|
ret
|
|
|
|
|
2020-06-21 13:27:43 -07:00
|
|
|
Function14d6c: ; unreferenced
|
2020-06-13 15:48:26 -07:00
|
|
|
ld a, BANK(s4_a60b) ; MBC30 bank used by JP Crystal; inaccessible by MBC3
|
2020-06-17 14:03:38 -07:00
|
|
|
call OpenSRAM
|
2020-06-13 15:48:26 -07:00
|
|
|
ld a, [s4_a60b] ; address of MBC30 bank
|
2015-08-19 10:13:48 -07:00
|
|
|
ld b, $0
|
|
|
|
and a
|
|
|
|
jr z, .ok
|
|
|
|
ld b, $2
|
|
|
|
|
|
|
|
.ok
|
|
|
|
ld a, b
|
2020-06-13 15:48:26 -07:00
|
|
|
ld [s4_a60b], a ; address of MBC30 bank
|
2015-08-19 10:13:48 -07:00
|
|
|
call CloseSRAM
|
|
|
|
ret
|
|
|
|
|
2020-06-21 13:27:43 -07:00
|
|
|
Function14d83: ; unreferenced
|
2020-06-13 15:48:26 -07:00
|
|
|
ld a, BANK(s4_a60c) ; aka BANK(s4_a60d) ; MBC30 bank used by JP Crystal; inaccessible by MBC3
|
2020-06-17 14:03:38 -07:00
|
|
|
call OpenSRAM
|
2015-08-19 10:13:48 -07:00
|
|
|
xor a
|
2020-06-13 15:48:26 -07:00
|
|
|
ld [s4_a60c], a ; address of MBC30 bank
|
|
|
|
ld [s4_a60d], a ; address of MBC30 bank
|
2015-08-19 10:13:48 -07:00
|
|
|
call CloseSRAM
|
|
|
|
ret
|
|
|
|
|
2020-06-21 13:27:43 -07:00
|
|
|
Function14d93: ; unreferenced
|
2020-06-13 15:48:26 -07:00
|
|
|
ld a, BANK(s7_a000) ; MBC30 bank used by JP Crystal; inaccessible by MBC3
|
2020-06-17 14:03:38 -07:00
|
|
|
call OpenSRAM
|
2015-08-19 10:13:48 -07:00
|
|
|
xor a
|
2020-06-13 15:48:26 -07:00
|
|
|
ld [s7_a000], a ; address of MBC30 bank
|
2015-08-19 10:13:48 -07:00
|
|
|
call CloseSRAM
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
HallOfFame_InitSaveIfNeeded:
|
2015-10-16 10:35:43 -07:00
|
|
|
ld a, [wSavedAtLeastOnce]
|
2015-08-19 10:13:48 -07:00
|
|
|
and a
|
|
|
|
ret nz
|
2015-08-19 21:14:15 -07:00
|
|
|
call ErasePreviousSave
|
2015-08-19 10:13:48 -07:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
ValidateSave:
|
2019-01-12 12:17:20 -08:00
|
|
|
ld a, BANK(sCheckValue1) ; aka BANK(sCheckValue2)
|
2020-06-17 14:03:38 -07:00
|
|
|
call OpenSRAM
|
2017-12-15 18:22:26 -08:00
|
|
|
ld a, SAVE_CHECK_VALUE_1
|
|
|
|
ld [sCheckValue1], a
|
|
|
|
ld a, SAVE_CHECK_VALUE_2
|
|
|
|
ld [sCheckValue2], a
|
2015-08-19 10:13:48 -07:00
|
|
|
jp CloseSRAM
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
SaveOptions:
|
2015-08-19 21:14:15 -07:00
|
|
|
ld a, BANK(sOptions)
|
2020-06-17 14:03:38 -07:00
|
|
|
call OpenSRAM
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wOptions
|
2015-08-19 21:14:15 -07:00
|
|
|
ld de, sOptions
|
2018-01-23 14:39:09 -08:00
|
|
|
ld bc, wOptionsEnd - wOptions
|
2015-08-19 10:13:48 -07:00
|
|
|
call CopyBytes
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wOptions]
|
2015-11-26 18:05:32 -08:00
|
|
|
and $ff ^ (1 << NO_TEXT_SCROLL)
|
2015-08-19 21:14:15 -07:00
|
|
|
ld [sOptions], a
|
2015-08-19 10:13:48 -07:00
|
|
|
jp CloseSRAM
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
SavePlayerData:
|
2015-08-19 21:14:15 -07:00
|
|
|
ld a, BANK(sPlayerData)
|
2020-06-17 14:03:38 -07:00
|
|
|
call OpenSRAM
|
2015-08-19 21:14:15 -07:00
|
|
|
ld hl, wPlayerData
|
|
|
|
ld de, sPlayerData
|
|
|
|
ld bc, wPlayerDataEnd - wPlayerData
|
2015-08-19 10:13:48 -07:00
|
|
|
call CopyBytes
|
2018-09-09 12:09:51 -07:00
|
|
|
ld hl, wCurMapData
|
|
|
|
ld de, sCurMapData
|
|
|
|
ld bc, wCurMapDataEnd - wCurMapData
|
2015-08-19 10:13:48 -07:00
|
|
|
call CopyBytes
|
|
|
|
jp CloseSRAM
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
SavePokemonData:
|
2015-08-19 21:14:15 -07:00
|
|
|
ld a, BANK(sPokemonData)
|
2020-06-17 14:03:38 -07:00
|
|
|
call OpenSRAM
|
2015-08-19 21:14:15 -07:00
|
|
|
ld hl, wPokemonData
|
|
|
|
ld de, sPokemonData
|
|
|
|
ld bc, wPokemonDataEnd - wPokemonData
|
2015-08-19 10:13:48 -07:00
|
|
|
call CopyBytes
|
|
|
|
call CloseSRAM
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
SaveBox:
|
2015-08-19 21:14:15 -07:00
|
|
|
call GetBoxAddress
|
|
|
|
call SaveBoxAddress
|
2015-08-19 10:13:48 -07:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
SaveChecksum:
|
2015-08-19 21:14:15 -07:00
|
|
|
ld hl, sGameData
|
|
|
|
ld bc, sGameDataEnd - sGameData
|
|
|
|
ld a, BANK(sGameData)
|
2020-06-17 14:03:38 -07:00
|
|
|
call OpenSRAM
|
2015-08-19 21:14:15 -07:00
|
|
|
call Checksum
|
2015-08-19 10:13:48 -07:00
|
|
|
ld a, e
|
2015-08-19 21:14:15 -07:00
|
|
|
ld [sChecksum + 0], a
|
2015-08-19 10:13:48 -07:00
|
|
|
ld a, d
|
2015-08-19 21:14:15 -07:00
|
|
|
ld [sChecksum + 1], a
|
2015-08-19 10:13:48 -07:00
|
|
|
call CloseSRAM
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
ValidateBackupSave:
|
2019-01-12 12:17:20 -08:00
|
|
|
ld a, BANK(sBackupCheckValue1) ; aka BANK(sBackupCheckValue2)
|
2020-06-17 14:03:38 -07:00
|
|
|
call OpenSRAM
|
2017-12-15 18:22:26 -08:00
|
|
|
ld a, SAVE_CHECK_VALUE_1
|
|
|
|
ld [sBackupCheckValue1], a
|
|
|
|
ld a, SAVE_CHECK_VALUE_2
|
|
|
|
ld [sBackupCheckValue2], a
|
2015-08-19 10:13:48 -07:00
|
|
|
call CloseSRAM
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
SaveBackupOptions:
|
2015-08-19 21:14:15 -07:00
|
|
|
ld a, BANK(sBackupOptions)
|
2020-06-17 14:03:38 -07:00
|
|
|
call OpenSRAM
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wOptions
|
2015-08-19 21:14:15 -07:00
|
|
|
ld de, sBackupOptions
|
2018-01-23 14:39:09 -08:00
|
|
|
ld bc, wOptionsEnd - wOptions
|
2015-08-19 10:13:48 -07:00
|
|
|
call CopyBytes
|
|
|
|
call CloseSRAM
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
SaveBackupPlayerData:
|
2015-08-19 21:14:15 -07:00
|
|
|
ld a, BANK(sBackupPlayerData)
|
2020-06-17 14:03:38 -07:00
|
|
|
call OpenSRAM
|
2015-08-19 21:14:15 -07:00
|
|
|
ld hl, wPlayerData
|
|
|
|
ld de, sBackupPlayerData
|
|
|
|
ld bc, wPlayerDataEnd - wPlayerData
|
2015-08-19 10:13:48 -07:00
|
|
|
call CopyBytes
|
2018-09-09 12:09:51 -07:00
|
|
|
ld hl, wCurMapData
|
|
|
|
ld de, sBackupCurMapData
|
|
|
|
ld bc, wCurMapDataEnd - wCurMapData
|
2015-08-19 10:13:48 -07:00
|
|
|
call CopyBytes
|
|
|
|
call CloseSRAM
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
SaveBackupPokemonData:
|
2015-08-19 21:14:15 -07:00
|
|
|
ld a, BANK(sBackupPokemonData)
|
2020-06-17 14:03:38 -07:00
|
|
|
call OpenSRAM
|
2015-08-19 21:14:15 -07:00
|
|
|
ld hl, wPokemonData
|
|
|
|
ld de, sBackupPokemonData
|
|
|
|
ld bc, wPokemonDataEnd - wPokemonData
|
2015-08-19 10:13:48 -07:00
|
|
|
call CopyBytes
|
|
|
|
call CloseSRAM
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
SaveBackupChecksum:
|
2015-08-19 21:14:15 -07:00
|
|
|
ld hl, sBackupGameData
|
|
|
|
ld bc, sBackupGameDataEnd - sBackupGameData
|
|
|
|
ld a, BANK(sBackupGameData)
|
2020-06-17 14:03:38 -07:00
|
|
|
call OpenSRAM
|
2015-08-19 21:14:15 -07:00
|
|
|
call Checksum
|
2015-08-19 10:13:48 -07:00
|
|
|
ld a, e
|
2015-08-19 21:14:15 -07:00
|
|
|
ld [sBackupChecksum + 0], a
|
2015-08-19 10:13:48 -07:00
|
|
|
ld a, d
|
2015-08-19 21:14:15 -07:00
|
|
|
ld [sBackupChecksum + 1], a
|
2015-08-19 10:13:48 -07:00
|
|
|
call CloseSRAM
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
TryLoadSaveFile:
|
2015-08-19 21:14:15 -07:00
|
|
|
call VerifyChecksum
|
|
|
|
jr nz, .backup
|
|
|
|
call LoadPlayerData
|
|
|
|
call LoadPokemonData
|
|
|
|
call LoadBox
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall RestorePartyMonMail
|
|
|
|
farcall RestoreMobileEventIndex
|
|
|
|
farcall RestoreMysteryGift
|
2015-08-19 21:14:15 -07:00
|
|
|
call ValidateBackupSave
|
|
|
|
call SaveBackupOptions
|
|
|
|
call SaveBackupPlayerData
|
|
|
|
call SaveBackupPokemonData
|
|
|
|
call SaveBackupChecksum
|
2015-08-19 10:13:48 -07:00
|
|
|
and a
|
|
|
|
ret
|
2015-08-19 21:14:15 -07:00
|
|
|
|
|
|
|
.backup
|
|
|
|
call VerifyBackupChecksum
|
2015-08-19 10:13:48 -07:00
|
|
|
jr nz, .corrupt
|
2015-08-19 21:14:15 -07:00
|
|
|
call LoadBackupPlayerData
|
|
|
|
call LoadBackupPokemonData
|
|
|
|
call LoadBox
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall RestorePartyMonMail
|
|
|
|
farcall RestoreMobileEventIndex
|
|
|
|
farcall RestoreMysteryGift
|
2015-08-19 21:14:15 -07:00
|
|
|
call ValidateSave
|
|
|
|
call SaveOptions
|
2015-08-19 10:13:48 -07:00
|
|
|
call SavePlayerData
|
2015-08-19 21:14:15 -07:00
|
|
|
call SavePokemonData
|
2015-11-17 20:29:14 -08:00
|
|
|
call SaveChecksum
|
2015-08-19 10:13:48 -07:00
|
|
|
and a
|
|
|
|
ret
|
2015-08-19 21:14:15 -07:00
|
|
|
|
2015-08-19 10:13:48 -07:00
|
|
|
.corrupt
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wOptions]
|
2015-08-19 10:13:48 -07:00
|
|
|
push af
|
2015-11-16 08:53:26 -08:00
|
|
|
set NO_TEXT_SCROLL, a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wOptions], a
|
2019-10-20 15:24:17 -07:00
|
|
|
ld hl, SaveFileCorruptedText
|
2015-08-19 10:13:48 -07:00
|
|
|
call PrintText
|
|
|
|
pop af
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wOptions], a
|
2015-08-19 10:13:48 -07:00
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
TryLoadSaveData:
|
2018-07-03 23:50:27 -07:00
|
|
|
xor a ; FALSE
|
2015-11-17 20:29:14 -08:00
|
|
|
ld [wSaveFileExists], a
|
|
|
|
call CheckPrimarySaveFile
|
|
|
|
ld a, [wSaveFileExists]
|
2015-08-19 10:13:48 -07:00
|
|
|
and a
|
2015-08-19 21:14:15 -07:00
|
|
|
jr z, .backup
|
|
|
|
|
|
|
|
ld a, BANK(sPlayerData)
|
2020-06-17 14:03:38 -07:00
|
|
|
call OpenSRAM
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, sPlayerData + wStartDay - wPlayerData
|
|
|
|
ld de, wStartDay
|
2015-08-19 21:14:15 -07:00
|
|
|
ld bc, 8
|
2015-08-19 10:13:48 -07:00
|
|
|
call CopyBytes
|
2017-12-28 04:15:46 -08:00
|
|
|
ld hl, sPlayerData + wStatusFlags - wPlayerData
|
|
|
|
ld de, wStatusFlags
|
2015-08-19 10:13:48 -07:00
|
|
|
ld a, [hl]
|
|
|
|
ld [de], a
|
|
|
|
call CloseSRAM
|
|
|
|
ret
|
|
|
|
|
2015-08-19 21:14:15 -07:00
|
|
|
.backup
|
2015-11-17 20:29:14 -08:00
|
|
|
call CheckBackupSaveFile
|
|
|
|
ld a, [wSaveFileExists]
|
2015-08-19 10:13:48 -07:00
|
|
|
and a
|
2015-08-19 21:14:15 -07:00
|
|
|
jr z, .corrupt
|
|
|
|
|
|
|
|
ld a, BANK(sBackupPlayerData)
|
2020-06-17 14:03:38 -07:00
|
|
|
call OpenSRAM
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, sBackupPlayerData + wStartDay - wPlayerData
|
|
|
|
ld de, wStartDay
|
2015-08-19 10:13:48 -07:00
|
|
|
ld bc, 8
|
|
|
|
call CopyBytes
|
2017-12-28 04:15:46 -08:00
|
|
|
ld hl, sBackupPlayerData + wStatusFlags - wPlayerData
|
|
|
|
ld de, wStatusFlags
|
2015-08-19 10:13:48 -07:00
|
|
|
ld a, [hl]
|
|
|
|
ld [de], a
|
|
|
|
call CloseSRAM
|
|
|
|
ret
|
|
|
|
|
2015-08-19 21:14:15 -07:00
|
|
|
.corrupt
|
2015-08-19 10:13:48 -07:00
|
|
|
ld hl, DefaultOptions
|
2018-01-23 14:39:09 -08:00
|
|
|
ld de, wOptions
|
|
|
|
ld bc, wOptionsEnd - wOptions
|
2015-08-19 10:13:48 -07:00
|
|
|
call CopyBytes
|
2020-02-16 03:20:20 -08:00
|
|
|
call ClearClock
|
2015-08-19 10:13:48 -07:00
|
|
|
ret
|
|
|
|
|
2017-12-11 10:47:58 -08:00
|
|
|
INCLUDE "data/default_options.asm"
|
2017-12-11 19:44:25 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
CheckPrimarySaveFile:
|
2019-01-12 12:17:20 -08:00
|
|
|
ld a, BANK(sCheckValue1) ; aka BANK(sCheckValue2)
|
2020-06-17 14:03:38 -07:00
|
|
|
call OpenSRAM
|
2017-12-15 18:22:26 -08:00
|
|
|
ld a, [sCheckValue1]
|
|
|
|
cp SAVE_CHECK_VALUE_1
|
2015-08-19 10:13:48 -07:00
|
|
|
jr nz, .nope
|
2017-12-15 18:22:26 -08:00
|
|
|
ld a, [sCheckValue2]
|
|
|
|
cp SAVE_CHECK_VALUE_2
|
2015-08-19 10:13:48 -07:00
|
|
|
jr nz, .nope
|
2015-08-19 21:14:15 -07:00
|
|
|
ld hl, sOptions
|
2018-01-23 14:39:09 -08:00
|
|
|
ld de, wOptions
|
|
|
|
ld bc, wOptionsEnd - wOptions
|
2015-08-19 10:13:48 -07:00
|
|
|
call CopyBytes
|
|
|
|
call CloseSRAM
|
2018-07-03 23:50:27 -07:00
|
|
|
ld a, TRUE
|
2015-11-17 20:29:14 -08:00
|
|
|
ld [wSaveFileExists], a
|
2015-08-19 10:13:48 -07:00
|
|
|
|
|
|
|
.nope
|
|
|
|
call CloseSRAM
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
CheckBackupSaveFile:
|
2019-01-12 12:17:20 -08:00
|
|
|
ld a, BANK(sBackupCheckValue1) ; aka BANK(sBackupCheckValue2)
|
2020-06-17 14:03:38 -07:00
|
|
|
call OpenSRAM
|
2017-12-15 18:22:26 -08:00
|
|
|
ld a, [sBackupCheckValue1]
|
|
|
|
cp SAVE_CHECK_VALUE_1
|
2015-08-19 10:13:48 -07:00
|
|
|
jr nz, .nope
|
2017-12-15 18:22:26 -08:00
|
|
|
ld a, [sBackupCheckValue2]
|
|
|
|
cp SAVE_CHECK_VALUE_2
|
2015-08-19 10:13:48 -07:00
|
|
|
jr nz, .nope
|
2015-08-19 21:14:15 -07:00
|
|
|
ld hl, sBackupOptions
|
2018-01-23 14:39:09 -08:00
|
|
|
ld de, wOptions
|
|
|
|
ld bc, wOptionsEnd - wOptions
|
2015-08-19 10:13:48 -07:00
|
|
|
call CopyBytes
|
|
|
|
ld a, $2
|
2015-11-17 20:29:14 -08:00
|
|
|
ld [wSaveFileExists], a
|
2015-08-19 10:13:48 -07:00
|
|
|
|
|
|
|
.nope
|
|
|
|
call CloseSRAM
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
LoadPlayerData:
|
2015-08-19 21:14:15 -07:00
|
|
|
ld a, BANK(sPlayerData)
|
2020-06-17 14:03:38 -07:00
|
|
|
call OpenSRAM
|
2015-08-19 21:14:15 -07:00
|
|
|
ld hl, sPlayerData
|
|
|
|
ld de, wPlayerData
|
|
|
|
ld bc, wPlayerDataEnd - wPlayerData
|
2015-08-19 10:13:48 -07:00
|
|
|
call CopyBytes
|
2018-09-09 12:09:51 -07:00
|
|
|
ld hl, sCurMapData
|
|
|
|
ld de, wCurMapData
|
|
|
|
ld bc, wCurMapDataEnd - wCurMapData
|
2015-08-19 10:13:48 -07:00
|
|
|
call CopyBytes
|
|
|
|
call CloseSRAM
|
2015-11-24 12:18:44 -08:00
|
|
|
ld a, BANK(sBattleTowerChallengeState)
|
2020-06-17 14:03:38 -07:00
|
|
|
call OpenSRAM
|
2015-11-24 12:18:44 -08:00
|
|
|
ld a, [sBattleTowerChallengeState]
|
2015-11-26 18:05:32 -08:00
|
|
|
cp BATTLETOWER_RECEIVED_REWARD
|
2015-11-17 20:29:14 -08:00
|
|
|
jr nz, .not_4
|
2015-11-26 18:05:32 -08:00
|
|
|
ld a, BATTLETOWER_WON_CHALLENGE
|
2015-11-24 12:18:44 -08:00
|
|
|
ld [sBattleTowerChallengeState], a
|
2015-11-17 20:29:14 -08:00
|
|
|
.not_4
|
2015-08-19 10:13:48 -07:00
|
|
|
call CloseSRAM
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
LoadPokemonData:
|
2015-08-19 21:14:15 -07:00
|
|
|
ld a, BANK(sPokemonData)
|
2020-06-17 14:03:38 -07:00
|
|
|
call OpenSRAM
|
2015-08-19 21:14:15 -07:00
|
|
|
ld hl, sPokemonData
|
|
|
|
ld de, wPokemonData
|
|
|
|
ld bc, wPokemonDataEnd - wPokemonData
|
2015-08-19 10:13:48 -07:00
|
|
|
call CopyBytes
|
|
|
|
call CloseSRAM
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
LoadBox:
|
2015-08-19 21:14:15 -07:00
|
|
|
call GetBoxAddress
|
|
|
|
call LoadBoxAddress
|
2015-08-19 10:13:48 -07:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
VerifyChecksum:
|
2015-08-19 21:14:15 -07:00
|
|
|
ld hl, sGameData
|
|
|
|
ld bc, sGameDataEnd - sGameData
|
|
|
|
ld a, BANK(sGameData)
|
2020-06-17 14:03:38 -07:00
|
|
|
call OpenSRAM
|
2015-08-19 21:14:15 -07:00
|
|
|
call Checksum
|
|
|
|
ld a, [sChecksum + 0]
|
2015-08-19 10:13:48 -07:00
|
|
|
cp e
|
2015-11-17 20:29:14 -08:00
|
|
|
jr nz, .fail
|
2015-08-19 21:14:15 -07:00
|
|
|
ld a, [sChecksum + 1]
|
2015-08-19 10:13:48 -07:00
|
|
|
cp d
|
2015-11-17 20:29:14 -08:00
|
|
|
.fail
|
2015-08-19 10:13:48 -07:00
|
|
|
push af
|
|
|
|
call CloseSRAM
|
|
|
|
pop af
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
LoadBackupPlayerData:
|
2015-08-19 21:14:15 -07:00
|
|
|
ld a, BANK(sBackupPlayerData)
|
2020-06-17 14:03:38 -07:00
|
|
|
call OpenSRAM
|
2015-08-19 21:14:15 -07:00
|
|
|
ld hl, sBackupPlayerData
|
|
|
|
ld de, wPlayerData
|
|
|
|
ld bc, wPlayerDataEnd - wPlayerData
|
2015-08-19 10:13:48 -07:00
|
|
|
call CopyBytes
|
2018-09-09 12:09:51 -07:00
|
|
|
ld hl, sBackupCurMapData
|
|
|
|
ld de, wCurMapData
|
|
|
|
ld bc, wCurMapDataEnd - wCurMapData
|
2015-08-19 10:13:48 -07:00
|
|
|
call CopyBytes
|
|
|
|
call CloseSRAM
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
LoadBackupPokemonData:
|
2015-08-19 21:14:15 -07:00
|
|
|
ld a, BANK(sBackupPokemonData)
|
2020-06-17 14:03:38 -07:00
|
|
|
call OpenSRAM
|
2015-08-19 21:14:15 -07:00
|
|
|
ld hl, sBackupPokemonData
|
|
|
|
ld de, wPokemonData
|
|
|
|
ld bc, wPokemonDataEnd - wPokemonData
|
2015-08-19 10:13:48 -07:00
|
|
|
call CopyBytes
|
|
|
|
call CloseSRAM
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
VerifyBackupChecksum:
|
2015-08-19 21:14:15 -07:00
|
|
|
ld hl, sBackupGameData
|
|
|
|
ld bc, sBackupGameDataEnd - sBackupGameData
|
|
|
|
ld a, BANK(sBackupGameData)
|
2020-06-17 14:03:38 -07:00
|
|
|
call OpenSRAM
|
2015-08-19 21:14:15 -07:00
|
|
|
call Checksum
|
|
|
|
ld a, [sBackupChecksum + 0]
|
2015-08-19 10:13:48 -07:00
|
|
|
cp e
|
2015-11-17 20:29:14 -08:00
|
|
|
jr nz, .fail
|
2015-08-19 21:14:15 -07:00
|
|
|
ld a, [sBackupChecksum + 1]
|
2015-08-19 10:13:48 -07:00
|
|
|
cp d
|
2015-11-17 20:29:14 -08:00
|
|
|
.fail
|
2015-08-19 10:13:48 -07:00
|
|
|
push af
|
|
|
|
call CloseSRAM
|
|
|
|
pop af
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
_SaveData:
|
2018-01-08 19:48:58 -08: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-18 18:48:52 -08:00
|
|
|
|
2015-08-19 21:14:15 -07:00
|
|
|
ld a, BANK(sCrystalData)
|
2020-06-17 14:03:38 -07:00
|
|
|
call OpenSRAM
|
2015-08-19 21:14:15 -07:00
|
|
|
ld hl, wCrystalData
|
|
|
|
ld de, sCrystalData
|
|
|
|
ld bc, wCrystalDataEnd - wCrystalData
|
2015-08-19 10:13:48 -07:00
|
|
|
call CopyBytes
|
2015-08-19 21:14:15 -07:00
|
|
|
|
2018-01-08 19:48:58 -08:00
|
|
|
; This block originally had some mobile functionality, but since we're still in
|
2020-06-21 09:21:47 -07:00
|
|
|
; BANK(sCrystalData), it instead overwrites the sixteen wEventFlags starting at 1:s4_a60e with
|
2018-01-08 19:48:58 -08:00
|
|
|
; garbage from wd479. This isn't an issue, since ErasePreviousSave is followed by a regular
|
|
|
|
; save that unwrites the garbage.
|
2018-01-18 18:48:52 -08:00
|
|
|
|
2015-08-19 10:13:48 -07:00
|
|
|
ld hl, wd479
|
|
|
|
ld a, [hli]
|
2019-04-27 10:50:24 -07:00
|
|
|
ld [s4_a60e + 0], a
|
2015-08-19 10:13:48 -07:00
|
|
|
ld a, [hli]
|
2019-04-27 10:50:24 -07:00
|
|
|
ld [s4_a60e + 1], a
|
2015-08-19 21:14:15 -07:00
|
|
|
|
2015-08-19 10:13:48 -07:00
|
|
|
jp CloseSRAM
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
_LoadData:
|
2015-08-19 21:14:15 -07:00
|
|
|
ld a, BANK(sCrystalData)
|
2020-06-17 14:03:38 -07:00
|
|
|
call OpenSRAM
|
2015-08-19 21:14:15 -07:00
|
|
|
ld hl, sCrystalData
|
|
|
|
ld de, wCrystalData
|
|
|
|
ld bc, wCrystalDataEnd - wCrystalData
|
2015-08-19 10:13:48 -07:00
|
|
|
call CopyBytes
|
2018-01-18 18:48:52 -08:00
|
|
|
|
2018-01-08 19:48:58 -08:00
|
|
|
; This block originally had some mobile functionality to mirror _SaveData above, but instead it
|
2018-01-23 14:39:09 -08:00
|
|
|
; (harmlessly) writes the aforementioned wEventFlags to the unused wd479.
|
2018-01-18 18:48:52 -08:00
|
|
|
|
2015-08-19 10:13:48 -07:00
|
|
|
ld hl, wd479
|
2019-04-27 10:50:24 -07:00
|
|
|
ld a, [s4_a60e + 0]
|
2015-08-19 10:13:48 -07:00
|
|
|
ld [hli], a
|
2019-04-27 10:50:24 -07:00
|
|
|
ld a, [s4_a60e + 1]
|
2015-08-19 10:13:48 -07:00
|
|
|
ld [hli], a
|
2015-08-19 21:14:15 -07:00
|
|
|
|
2015-08-19 10:13:48 -07:00
|
|
|
jp CloseSRAM
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
GetBoxAddress:
|
2015-08-19 10:13:48 -07:00
|
|
|
ld a, [wCurBox]
|
|
|
|
cp NUM_BOXES
|
2015-08-19 21:14:15 -07:00
|
|
|
jr c, .ok
|
2015-08-19 10:13:48 -07:00
|
|
|
xor a
|
|
|
|
ld [wCurBox], a
|
|
|
|
|
2015-08-19 21:14:15 -07:00
|
|
|
.ok
|
2015-08-19 10:13:48 -07:00
|
|
|
ld e, a
|
|
|
|
ld d, 0
|
2015-08-19 21:14:15 -07:00
|
|
|
ld hl, BoxAddresses
|
2015-08-19 10:13:48 -07: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 07:09:41 -07:00
|
|
|
SaveBoxAddress:
|
2018-03-19 08:36:14 -07:00
|
|
|
; Save box via wBoxPartialData.
|
|
|
|
; We do this in three steps because the size of wBoxPartialData is less than
|
2015-12-14 17:06:41 -08:00
|
|
|
; the size of sBox.
|
2015-08-19 10:13:48 -07:00
|
|
|
push hl
|
2015-12-14 17:06:41 -08:00
|
|
|
; Load the first part of the active box.
|
2015-08-19 10:13:48 -07:00
|
|
|
push af
|
|
|
|
push de
|
2015-08-19 21:14:15 -07:00
|
|
|
ld a, BANK(sBox)
|
2020-06-17 14:03:38 -07:00
|
|
|
call OpenSRAM
|
2015-08-19 21:14:15 -07:00
|
|
|
ld hl, sBox
|
2018-03-19 08:36:14 -07:00
|
|
|
ld de, wBoxPartialData
|
|
|
|
ld bc, (wBoxPartialDataEnd - wBoxPartialData)
|
2015-08-19 10:13:48 -07:00
|
|
|
call CopyBytes
|
|
|
|
call CloseSRAM
|
|
|
|
pop de
|
|
|
|
pop af
|
2015-12-14 17:06:41 -08:00
|
|
|
; Save it to the target box.
|
2015-08-19 10:13:48 -07:00
|
|
|
push af
|
|
|
|
push de
|
2020-06-17 14:03:38 -07:00
|
|
|
call OpenSRAM
|
2018-03-19 08:36:14 -07:00
|
|
|
ld hl, wBoxPartialData
|
|
|
|
ld bc, (wBoxPartialDataEnd - wBoxPartialData)
|
2015-08-19 10:13:48 -07:00
|
|
|
call CopyBytes
|
|
|
|
call CloseSRAM
|
2015-12-14 17:06:41 -08:00
|
|
|
|
|
|
|
; Load the second part of the active box.
|
2015-08-19 21:14:15 -07:00
|
|
|
ld a, BANK(sBox)
|
2020-06-17 14:03:38 -07:00
|
|
|
call OpenSRAM
|
2018-03-19 08:36:14 -07:00
|
|
|
ld hl, sBox + (wBoxPartialDataEnd - wBoxPartialData)
|
|
|
|
ld de, wBoxPartialData
|
|
|
|
ld bc, (wBoxPartialDataEnd - wBoxPartialData)
|
2015-08-19 10:13:48 -07:00
|
|
|
call CopyBytes
|
|
|
|
call CloseSRAM
|
|
|
|
pop de
|
|
|
|
pop af
|
2015-08-19 21:14:15 -07:00
|
|
|
|
2018-03-19 08:36:14 -07:00
|
|
|
ld hl, (wBoxPartialDataEnd - wBoxPartialData)
|
2015-08-19 10:13:48 -07:00
|
|
|
add hl, de
|
|
|
|
ld e, l
|
|
|
|
ld d, h
|
2015-12-14 17:06:41 -08:00
|
|
|
; Save it to the next part of the target box.
|
2015-08-19 10:13:48 -07:00
|
|
|
push af
|
|
|
|
push de
|
2020-06-17 14:03:38 -07:00
|
|
|
call OpenSRAM
|
2018-03-19 08:36:14 -07:00
|
|
|
ld hl, wBoxPartialData
|
|
|
|
ld bc, (wBoxPartialDataEnd - wBoxPartialData)
|
2015-08-19 10:13:48 -07:00
|
|
|
call CopyBytes
|
|
|
|
call CloseSRAM
|
2015-12-14 17:06:41 -08:00
|
|
|
|
|
|
|
; Load the third and final part of the active box.
|
2015-08-19 21:14:15 -07:00
|
|
|
ld a, BANK(sBox)
|
2020-06-17 14:03:38 -07:00
|
|
|
call OpenSRAM
|
2018-03-19 08:36:14 -07:00
|
|
|
ld hl, sBox + (wBoxPartialDataEnd - wBoxPartialData) * 2
|
|
|
|
ld de, wBoxPartialData
|
|
|
|
ld bc, sBoxEnd - (sBox + (wBoxPartialDataEnd - wBoxPartialData) * 2) ; $8e
|
2015-08-19 10:13:48 -07:00
|
|
|
call CopyBytes
|
|
|
|
call CloseSRAM
|
|
|
|
pop de
|
|
|
|
pop af
|
2015-08-19 21:14:15 -07:00
|
|
|
|
2018-03-19 08:36:14 -07:00
|
|
|
ld hl, (wBoxPartialDataEnd - wBoxPartialData)
|
2015-08-19 10:13:48 -07:00
|
|
|
add hl, de
|
|
|
|
ld e, l
|
|
|
|
ld d, h
|
2015-12-14 17:06:41 -08:00
|
|
|
; Save it to the final part of the target box.
|
2020-06-17 14:03:38 -07:00
|
|
|
call OpenSRAM
|
2018-03-19 08:36:14 -07:00
|
|
|
ld hl, wBoxPartialData
|
|
|
|
ld bc, sBoxEnd - (sBox + (wBoxPartialDataEnd - wBoxPartialData) * 2) ; $8e
|
2015-08-19 10:13:48 -07:00
|
|
|
call CopyBytes
|
|
|
|
call CloseSRAM
|
2015-08-19 21:14:15 -07:00
|
|
|
|
2015-08-19 10:13:48 -07:00
|
|
|
pop hl
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
LoadBoxAddress:
|
2018-03-19 08:36:14 -07:00
|
|
|
; Load box via wBoxPartialData.
|
|
|
|
; We do this in three steps because the size of wBoxPartialData is less than
|
2015-12-14 17:06:41 -08:00
|
|
|
; the size of sBox.
|
2015-08-19 10:13:48 -07:00
|
|
|
push hl
|
|
|
|
ld l, e
|
|
|
|
ld h, d
|
2015-12-14 17:06:41 -08:00
|
|
|
; Load part 1
|
2015-08-19 10:13:48 -07:00
|
|
|
push af
|
|
|
|
push hl
|
2020-06-17 14:03:38 -07:00
|
|
|
call OpenSRAM
|
2018-03-19 08:36:14 -07:00
|
|
|
ld de, wBoxPartialData
|
|
|
|
ld bc, (wBoxPartialDataEnd - wBoxPartialData)
|
2015-08-19 10:13:48 -07:00
|
|
|
call CopyBytes
|
|
|
|
call CloseSRAM
|
2015-08-19 21:14:15 -07:00
|
|
|
ld a, BANK(sBox)
|
2020-06-17 14:03:38 -07:00
|
|
|
call OpenSRAM
|
2018-03-19 08:36:14 -07:00
|
|
|
ld hl, wBoxPartialData
|
2015-08-19 21:14:15 -07:00
|
|
|
ld de, sBox
|
2018-03-19 08:36:14 -07:00
|
|
|
ld bc, (wBoxPartialDataEnd - wBoxPartialData)
|
2015-08-19 10:13:48 -07:00
|
|
|
call CopyBytes
|
|
|
|
call CloseSRAM
|
|
|
|
pop hl
|
|
|
|
pop af
|
2015-08-19 21:14:15 -07:00
|
|
|
|
2018-03-19 08:36:14 -07:00
|
|
|
ld de, (wBoxPartialDataEnd - wBoxPartialData)
|
2015-08-19 10:13:48 -07:00
|
|
|
add hl, de
|
2015-12-14 17:06:41 -08:00
|
|
|
; Load part 2
|
2015-08-19 10:13:48 -07:00
|
|
|
push af
|
|
|
|
push hl
|
2020-06-17 14:03:38 -07:00
|
|
|
call OpenSRAM
|
2018-03-19 08:36:14 -07:00
|
|
|
ld de, wBoxPartialData
|
|
|
|
ld bc, (wBoxPartialDataEnd - wBoxPartialData)
|
2015-08-19 10:13:48 -07:00
|
|
|
call CopyBytes
|
|
|
|
call CloseSRAM
|
2015-08-19 21:14:15 -07:00
|
|
|
ld a, BANK(sBox)
|
2020-06-17 14:03:38 -07:00
|
|
|
call OpenSRAM
|
2018-03-19 08:36:14 -07:00
|
|
|
ld hl, wBoxPartialData
|
|
|
|
ld de, sBox + (wBoxPartialDataEnd - wBoxPartialData)
|
|
|
|
ld bc, (wBoxPartialDataEnd - wBoxPartialData)
|
2015-08-19 10:13:48 -07:00
|
|
|
call CopyBytes
|
|
|
|
call CloseSRAM
|
|
|
|
pop hl
|
|
|
|
pop af
|
2015-12-14 17:06:41 -08:00
|
|
|
; Load part 3
|
2018-03-19 08:36:14 -07:00
|
|
|
ld de, (wBoxPartialDataEnd - wBoxPartialData)
|
2015-08-19 10:13:48 -07:00
|
|
|
add hl, de
|
2020-06-17 14:03:38 -07:00
|
|
|
call OpenSRAM
|
2018-03-19 08:36:14 -07:00
|
|
|
ld de, wBoxPartialData
|
|
|
|
ld bc, sBoxEnd - (sBox + (wBoxPartialDataEnd - wBoxPartialData) * 2) ; $8e
|
2015-08-19 10:13:48 -07:00
|
|
|
call CopyBytes
|
|
|
|
call CloseSRAM
|
2015-08-19 21:14:15 -07:00
|
|
|
ld a, BANK(sBox)
|
2020-06-17 14:03:38 -07:00
|
|
|
call OpenSRAM
|
2018-03-19 08:36:14 -07:00
|
|
|
ld hl, wBoxPartialData
|
|
|
|
ld de, sBox + (wBoxPartialDataEnd - wBoxPartialData) * 2
|
|
|
|
ld bc, sBoxEnd - (sBox + (wBoxPartialDataEnd - wBoxPartialData) * 2) ; $8e
|
2015-08-19 10:13:48 -07:00
|
|
|
call CopyBytes
|
|
|
|
call CloseSRAM
|
2015-08-19 21:14:15 -07:00
|
|
|
|
2015-08-19 10:13:48 -07:00
|
|
|
pop hl
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
EraseBoxes:
|
2015-08-19 21:14:15 -07:00
|
|
|
ld hl, BoxAddresses
|
|
|
|
ld c, NUM_BOXES
|
|
|
|
.next
|
2015-08-19 10:13:48 -07:00
|
|
|
push bc
|
|
|
|
ld a, [hli]
|
2020-06-17 14:03:38 -07:00
|
|
|
call OpenSRAM
|
2015-08-19 10:13:48 -07: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-19 21:14:15 -07:00
|
|
|
ld bc, sBoxEnd - (sBox + 2)
|
|
|
|
.clear
|
2015-08-19 10:13:48 -07:00
|
|
|
xor a
|
|
|
|
ld [de], a
|
|
|
|
inc de
|
|
|
|
dec bc
|
|
|
|
ld a, b
|
|
|
|
or c
|
2015-08-19 21:14:15 -07:00
|
|
|
jr nz, .clear
|
2015-08-19 10:13:48 -07: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-19 21:14:15 -07:00
|
|
|
jr nz, .next
|
2015-08-19 10:13:48 -07:00
|
|
|
ret
|
|
|
|
|
2021-05-30 12:51:49 -07:00
|
|
|
box_address: MACRO
|
|
|
|
assert BANK(\1) == BANK(\2)
|
|
|
|
db BANK(\1)
|
|
|
|
dw \1, \2
|
|
|
|
ENDM
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
BoxAddresses:
|
2021-05-30 12:51:49 -07:00
|
|
|
table_width 5, BoxAddresses
|
|
|
|
box_address sBox1, sBox1End
|
|
|
|
box_address sBox2, sBox2End
|
|
|
|
box_address sBox3, sBox3End
|
|
|
|
box_address sBox4, sBox4End
|
|
|
|
box_address sBox5, sBox5End
|
|
|
|
box_address sBox6, sBox6End
|
|
|
|
box_address sBox7, sBox7End
|
|
|
|
box_address sBox8, sBox8End
|
|
|
|
box_address sBox9, sBox9End
|
|
|
|
box_address sBox10, sBox10End
|
|
|
|
box_address sBox11, sBox11End
|
|
|
|
box_address sBox12, sBox12End
|
|
|
|
box_address sBox13, sBox13End
|
|
|
|
box_address sBox14, sBox14End
|
|
|
|
assert_table_length NUM_BOXES
|
2015-08-19 10:13:48 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
Checksum:
|
2015-08-19 10:13:48 -07: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 15:24:17 -07:00
|
|
|
WouldYouLikeToSaveTheGameText:
|
|
|
|
text_far _WouldYouLikeToSaveTheGameText
|
2018-11-17 10:33:03 -08:00
|
|
|
text_end
|
2015-08-19 10:13:48 -07:00
|
|
|
|
2019-10-20 15:24:17 -07:00
|
|
|
SavingDontTurnOffThePowerText:
|
|
|
|
text_far _SavingDontTurnOffThePowerText
|
2018-11-17 10:33:03 -08:00
|
|
|
text_end
|
2015-08-19 10:13:48 -07:00
|
|
|
|
2019-10-20 15:24:17 -07:00
|
|
|
SavedTheGameText:
|
|
|
|
text_far _SavedTheGameText
|
2018-11-17 10:33:03 -08:00
|
|
|
text_end
|
2015-08-19 10:13:48 -07:00
|
|
|
|
2019-10-20 15:24:17 -07:00
|
|
|
AlreadyASaveFileText:
|
|
|
|
text_far _AlreadyASaveFileText
|
2018-11-17 10:33:03 -08:00
|
|
|
text_end
|
2015-08-19 10:13:48 -07:00
|
|
|
|
2019-10-20 15:24:17 -07:00
|
|
|
AnotherSaveFileText:
|
|
|
|
text_far _AnotherSaveFileText
|
2018-11-17 10:33:03 -08:00
|
|
|
text_end
|
2015-08-19 10:13:48 -07:00
|
|
|
|
2019-10-20 15:24:17 -07:00
|
|
|
SaveFileCorruptedText:
|
|
|
|
text_far _SaveFileCorruptedText
|
2018-11-17 10:33:03 -08:00
|
|
|
text_end
|
2015-08-19 10:13:48 -07:00
|
|
|
|
2019-10-20 15:24:17 -07:00
|
|
|
ChangeBoxSaveText:
|
|
|
|
text_far _ChangeBoxSaveText
|
2018-11-17 10:33:03 -08:00
|
|
|
text_end
|
2015-08-19 10:13:48 -07:00
|
|
|
|
2019-10-20 15:24:17 -07:00
|
|
|
MoveMonWOMailSaveText:
|
|
|
|
text_far _MoveMonWOMailSaveText
|
2018-11-17 10:33:03 -08:00
|
|
|
text_end
|