ref: bc1870e3f499973fd656d37d134e3f9e4757c980
parent: 27ef600ace40671a78f5bb3a71f507e42c175f50
author: PikalaxALT <PikalaxALT@gmail.com>
date: Tue Nov 17 18:29:14 EST 2015
Save, Bill's PC
--- a/engine/billspc.asm
+++ b/engine/billspc.asm
@@ -1165,13 +1165,13 @@
cp $f
jr z, .asm_e2bf5
ld b, a
- call Functione3396
+ call GetBoxPointer
ld a, b
call GetSRAMBank
push hl
- ld bc, $35
+ ld bc, sBoxMon1Level - sBox
add hl, bc
- ld bc, $20
+ ld bc, BOXMON_STRUCT_LENGTH
ld a, e
call AddNTimes
ld a, [hl]
@@ -1178,17 +1178,17 @@
ld [TempMonLevel], a
pop hl
push hl
- ld bc, $17
+ ld bc, sBoxMon1Item - sBox
add hl, bc
- ld bc, $20
+ ld bc, BOXMON_STRUCT_LENGTH
ld a, e
call AddNTimes
ld a, [hl]
ld [TempMonItem], a
pop hl
- ld bc, $2b
+ ld bc, sBoxMon1DVs - sBox
add hl, bc
- ld bc, $20
+ ld bc, BOXMON_STRUCT_LENGTH
ld a, e
call AddNTimes
ld de, TempMonDVs
@@ -1201,19 +1201,19 @@
ret
.asm_e2bc6
ld hl, PartyMon1Level
- ld bc, $30
+ ld bc, PARTYMON_STRUCT_LENGTH
ld a, e
call AddNTimes
ld a, [hl]
ld [TempMonLevel], a
ld hl, PartyMon1Item
- ld bc, $30
+ ld bc, PARTYMON_STRUCT_LENGTH
ld a, e
call AddNTimes
ld a, [hl]
ld [TempMonItem], a
ld hl, PartyMon1DVs
- ld bc, $30
+ ld bc, PARTYMON_STRUCT_LENGTH
ld a, e
call AddNTimes
ld de, TempMonDVs
@@ -1228,7 +1228,7 @@
ld a, BANK(sBox)
call GetSRAMBank
ld hl, sBoxMon1Level
- ld bc, $20
+ ld bc, BOXMON_STRUCT_LENGTH
ld a, e
call AddNTimes
ld a, [hl]
@@ -1235,7 +1235,7 @@
ld [TempMonLevel], a
ld hl, sBoxMon1Item
- ld bc, $20
+ ld bc, BOXMON_STRUCT_LENGTH
ld a, e
call AddNTimes
ld a, [hl]
@@ -1242,7 +1242,7 @@
ld [TempMonItem], a
ld hl, sBoxMon1DVs
- ld bc, $20
+ ld bc, BOXMON_STRUCT_LENGTH
ld a, e
call AddNTimes
ld de, TempMonDVs
@@ -1307,6 +1307,7 @@
ld de, String_e2c67
call PlaceString
ret
+
.asm_e2c7c
inc de
ld a, [de]
@@ -1320,13 +1321,13 @@
cp $f
jr z, .asm_e2cf1
push hl
- call Functione3396
+ call GetBoxPointer
ld a, b
call GetSRAMBank
push hl
- ld bc, $16
+ ld bc, sBoxMons - sBox
add hl, bc
- ld bc, $20
+ ld bc, BOXMON_STRUCT_LENGTH
ld a, e
call AddNTimes
ld a, [hl]
@@ -1333,13 +1334,13 @@
pop hl
and a
jr z, .asm_e2cc2
- ld bc, $372
+ ld bc, sBoxMonNicknames - sBox
add hl, bc
- ld bc, $b
+ ld bc, PKMN_NAME_LENGTH
ld a, e
call AddNTimes
ld de, StringBuffer1
- ld bc, $b
+ ld bc, PKMN_NAME_LENGTH
call CopyBytes
call CloseSRAM
pop hl
@@ -1346,10 +1347,12 @@
ld de, StringBuffer1
call PlaceString
ret
+
.asm_e2cc2
call CloseSRAM
pop hl
jr .asm_e2d23
+
.asm_e2cc8
push hl
ld hl, PartySpecies
@@ -1359,19 +1362,21 @@
and a
jr z, .asm_e2cee
ld hl, PartyMonNicknames
- ld bc, $b
+ ld bc, PKMN_NAME_LENGTH
ld a, e
call AddNTimes
ld de, StringBuffer1
- ld bc, $b
+ ld bc, PKMN_NAME_LENGTH
call CopyBytes
pop hl
ld de, StringBuffer1
call PlaceString
ret
+
.asm_e2cee
pop hl
jr .asm_e2d23
+
.asm_e2cf1
push hl
ld a, BANK(sBox)
@@ -1394,6 +1399,7 @@
ld de, StringBuffer1
call PlaceString
ret
+
.asm_e2d1f
call CloseSRAM
pop hl
@@ -1422,7 +1428,7 @@
cp $f
jr z, .asm_e2db7
ld b, a
- call Functione3396
+ call GetBoxPointer
ld a, b
call GetSRAMBank
inc hl
@@ -1447,6 +1453,7 @@
inc a
ld [wd004], a
jr .asm_e2d57
+
.asm_e2d79
call CloseSRAM
ld a, $ff
@@ -1455,6 +1462,7 @@
inc a
ld [wcb2c], a
ret
+
.asm_e2d87
ld hl, PartySpecies
.asm_e2d8a
@@ -1478,6 +1486,7 @@
inc a
ld [wd004], a
jr .asm_e2d8a
+
.asm_e2dac
ld a, $ff
ld [de], a
@@ -1485,6 +1494,7 @@
inc a
ld [wcb2c], a
ret
+
.asm_e2db7
ld a, BANK(sBox)
call GetSRAMBank
@@ -1510,6 +1520,7 @@
inc a
ld [wd004], a
jr .asm_e2dbf
+
.asm_e2de1
call CloseSRAM
ld a, $ff
@@ -1538,10 +1549,11 @@
jr nz, .asm_e2e0b
call ClearSprites
ret
+
.asm_e2e0b
ld hl, Unknown_e2e2b
ld de, Sprites
-.done1
+.loop
ld a, [hl]
cp $ff
ret z
@@ -1561,7 +1573,7 @@
ld a, [hli]
ld [de], a
inc de
- jr .done1
+ jr .loop
; e2e2b (38:6e2b)
Unknown_e2e2b: ; e2e2b
@@ -1795,11 +1807,11 @@
ld a, BANK(sBox)
call GetSRAMBank
ld hl, sBoxSpecies
- call Functione3357
+ call CopySpeciesToTemp
ld hl, sBoxMonNicknames
- call Functione3363
+ call CopyNicknameToTemp
ld hl, sBoxMonOT
- call Functione3376
+ call CopyOTNameToTemp
ld hl, sBoxMons
ld bc, BOXMON_STRUCT_LENGTH
ld a, [CurPartyMon]
@@ -1813,11 +1825,11 @@
.asm_e3020
ld hl, PartySpecies
- call Functione3357
+ call CopySpeciesToTemp
ld hl, PartyMonNicknames
- call Functione3363
+ call CopyNicknameToTemp
ld hl, PartyMonOT
- call Functione3376
+ call CopyOTNameToTemp
ld hl, PartyMons ; wdcdf (aliases: PartyMon1, PartyMon1Species)
ld bc, PARTYMON_STRUCT_LENGTH
ld a, [CurPartyMon]
@@ -1829,27 +1841,27 @@
.asm_e3048
ld b, a
- call Functione3396
+ call GetBoxPointer
ld a, b
call GetSRAMBank
push hl
inc hl
- call Functione3357
+ call CopySpeciesToTemp
pop hl
push hl
- ld bc, $372
+ ld bc, sBoxMonNicknames - sBox
add hl, bc
- call Functione3363
+ call CopyNicknameToTemp
pop hl
push hl
- ld bc, $296
+ ld bc, sBoxMonOT - sBox
add hl, bc
- call Functione3376
+ call CopyOTNameToTemp
pop hl
- ld bc, $16
+ ld bc, sBoxMons - sBox
add hl, bc
- ld bc, $20
- call Functione3389
+ ld bc, BOXMON_STRUCT_LENGTH
+ call CopyMonToTemp
call CloseSRAM
callba Function5088b
ret
@@ -2141,7 +2153,7 @@
ld a, [wcb31]
dec a
ld e, a
- callba Function14ac2
+ callba MovePkmnWOMail_SaveGame
ld a, [wcb30]
ld hl, wcb2f
add [hl]
@@ -2149,14 +2161,14 @@
ld a, $1
call GetSRAMBank
ld hl, sBoxSpecies
- call Functione3357
+ call CopySpeciesToTemp
ld hl, sBoxMonNicknames
- call Functione3363
+ call CopyNicknameToTemp
ld hl, sBoxMonOT
- call Functione3376
+ call CopyOTNameToTemp
ld hl, sBoxMons
ld bc, BOXMON_STRUCT_LENGTH
- call Functione3389
+ call CopyMonToTemp
call CloseSRAM
callba Function5088b
ld a, PC_DEPOSIT
@@ -2169,7 +2181,7 @@
ld a, [wcb2e]
dec a
ld e, a
- callba Function14ac2
+ callba MovePkmnWOMail_SaveGame
ld a, [wcb2b]
ld hl, wcb2a
add [hl]
@@ -2184,14 +2196,14 @@
add [hl]
ld [CurPartyMon], a
ld hl, PartySpecies
- call Functione3357
+ call CopySpeciesToTemp
ld hl, PartyMonNicknames
- call Functione3363
+ call CopyNicknameToTemp
ld hl, PartyMonOT
- call Functione3376
+ call CopyOTNameToTemp
ld hl, PartyMon1Species
ld bc, PARTYMON_STRUCT_LENGTH
- call Functione3389
+ call CopyMonToTemp
xor a
ld [wPokemonWithdrawDepositParameter], a
callba Functione039
@@ -2207,7 +2219,7 @@
ret
; e3357
-Functione3357: ; e3357 (38:7357)
+CopySpeciesToTemp: ; e3357 (38:7357)
ld a, [CurPartyMon]
ld c, a
ld b, $0
@@ -2216,36 +2228,36 @@
ld [CurPartySpecies], a
ret
-Functione3363: ; e3363 (38:7363)
- ld bc, $b
+CopyNicknameToTemp: ; e3363 (38:7363)
+ ld bc, PKMN_NAME_LENGTH
ld a, [CurPartyMon]
call AddNTimes
ld de, wd002
- ld bc, $b
+ ld bc, PKMN_NAME_LENGTH
call CopyBytes
ret
-Functione3376: ; e3376 (38:7376)
- ld bc, $b
+CopyOTNameToTemp: ; e3376 (38:7376)
+ ld bc, NAME_LENGTH
ld a, [CurPartyMon]
call AddNTimes
ld de, wd00d
- ld bc, $b
+ ld bc, NAME_LENGTH
call CopyBytes
ret
-Functione3389: ; e3389 (38:7389)
+CopyMonToTemp: ; e3389 (38:7389)
ld a, [CurPartyMon]
call AddNTimes
- ld de, wd018
+ ld de, wd018_Mon
call CopyBytes
ret
-Functione3396: ; e3396 (38:7396)
+GetBoxPointer: ; e3396 (38:7396)
dec b
ld c, b
ld b, 0
- ld hl, Unknown_e33a6
+ ld hl, .boxes
rept 3
add hl, bc
endr
@@ -2257,7 +2269,7 @@
ret
; e33a6 (38:73a6)
-Unknown_e33a6: ; e33a6
+.boxes: ; e33a6
; bank, address
dba sBox1
dba sBox2
@@ -2576,7 +2588,7 @@
ld a, [wCurBox]
cp e
ret z
- callba Function14a83
+ callba ChangeBoxSaveGame
ret
.asm_e3745
--- a/engine/link.asm
+++ b/engine/link.asm
@@ -3969,7 +3969,7 @@
Special_TryQuickSave: ; 29e66
ld a, [wd265]
push af
- callba Function14ab2
+ callba Link_SaveGame
ld a, $1
jr nc, .asm_29e75
xor a
--- a/engine/main_menu.asm
+++ b/engine/main_menu.asm
@@ -150,7 +150,7 @@
nop
nop
nop
- ld a, [wcfcd]
+ ld a, [wSaveFileExists]
and a
jr nz, .next
ld a, $0
@@ -220,7 +220,7 @@
; 49e09
Function49e09: ; 49e09
- ld a, [wcfcd]
+ ld a, [wSaveFileExists]
and a
ret z
xor a
@@ -256,7 +256,7 @@
Function49e3d: ; 49e3d
- ld a, [wcfcd]
+ ld a, [wSaveFileExists]
and a
ret z
call Function6e3
@@ -566,7 +566,7 @@
pop af
and a
jr nz, .asm_4a0f9
- callba Function1509a
+ callba _SaveData
.asm_4a0f9
ld c, 5
call DelayFrames
--- a/engine/save.asm
+++ b/engine/save.asm
@@ -3,11 +3,11 @@
callba Function5e9a
call SpeechTextBox
call UpdateSprites
- callba Function4cf45
+ callba SaveMenu_LoadDETile
ld hl, UnknownText_0x15283
call SaveTheGame_yesorno
jr nz, .refused
- call CheckForExistingSaveFile
+ call AskOverwriteSaveFile
jr c, .refused
call SetWRAMStateForSave
call _SavingDontTurnOffThePower
@@ -15,29 +15,30 @@
call ExitMenu
and a
ret
+
.refused
call ExitMenu
call Functiond90
- callba Function4cf45
+ callba SaveMenu_LoadDETile
scf
ret
Function14a58: ; 14a58
call SetWRAMStateForSave
- callba Function14056
- callba Function1050d9
+ callba StageRTCTimeForSave
+ callba BackupMysteryGift
call SavePokemonData
- call Function14e13
+ call SaveChecksum
call SaveBackupPokemonData
call SaveBackupChecksum
callba BackupPartyMonMail
- callba Function1406a
+ callba SaveRTC
call ClearWRAMStateAfterSave
ret
; 14a83
-Function14a83: ; 14a83 (5:4a83)
+ChangeBoxSaveGame: ; 14a83 (5:4a83)
push de
ld hl, UnknownText_0x152a1
call MenuTextBox
@@ -44,7 +45,7 @@
call YesNoBox
call ExitMenu
jr c, .refused
- call CheckForExistingSaveFile
+ call AskOverwriteSaveFile
jr c, .refused
call SetWRAMStateForSave
call SavingDontTurnOffThePower
@@ -61,8 +62,8 @@
pop de
ret
-Function14ab2: ; 14ab2
- call CheckForExistingSaveFile
+Link_SaveGame: ; 14ab2
+ call AskOverwriteSaveFile
jr c, .refused
call SetWRAMStateForSave
call _SavingDontTurnOffThePower
@@ -73,7 +74,7 @@
ret
; 14ac2
-Function14ac2: ; 14ac2
+MovePkmnWOMail_SaveGame: ; 14ac2
call SetWRAMStateForSave
push de
call SaveBox
@@ -93,14 +94,14 @@
ld a, e
ld [wCurBox], a
ld a, $1
- ld [wcfcd], a
- callba Function14056
- callba Function1050d9
+ ld [wSaveFileExists], a
+ callba StageRTCTimeForSave
+ callba BackupMysteryGift
call ValidateSave
call SaveOptions
call SavePlayerData
call SavePokemonData
- call Function14e13
+ call SaveChecksum
call ValidateBackupSave
call SaveBackupOptions
call SaveBackupPlayerData
@@ -108,24 +109,24 @@
call SaveBackupChecksum
callba BackupPartyMonMail
callba BackupMobileEventIndex
- callba Function1406a
+ callba SaveRTC
call LoadBox
call ClearWRAMStateAfterSave
ld de, SFX_SAVE
call PlaySFX
- ld c, $18
+ ld c, 24
call DelayFrames
ret
; 14b34
-Function14b34: ; 14b34
+StartMovePkmnWOMail_SaveGame: ; 14b34
ld hl, UnknownText_0x152a6
call MenuTextBox
call YesNoBox
call ExitMenu
- jr c, .asm_14b52
- call CheckForExistingSaveFile
- jr c, .asm_14b52
+ jr c, .refused
+ call AskOverwriteSaveFile
+ jr c, .refused
call SetWRAMStateForSave
call _SavingDontTurnOffThePower
call ClearWRAMStateAfterSave
@@ -132,7 +133,7 @@
and a
ret
-.asm_14b52
+.refused
scf
ret
; 14b54
@@ -177,8 +178,8 @@
ret
; 14b89
-CheckForExistingSaveFile: ; 14b89
- ld a, [wcfcd]
+AskOverwriteSaveFile: ; 14b89
+ ld a, [wSaveFileExists]
and a
jr z, .erase
call Function14bcb
@@ -269,15 +270,15 @@
SaveGameData_: ; 14c10
ld a, 1
- ld [wcfcd], a
- callba Function14056
- callba Function1050d9
+ ld [wSaveFileExists], a
+ callba StageRTCTimeForSave
+ callba BackupMysteryGift
call ValidateSave
call SaveOptions
call SavePlayerData
call SavePokemonData
call SaveBox
- call Function14e13
+ call SaveChecksum
call ValidateBackupSave
call SaveBackupOptions
call SaveBackupPlayerData
@@ -286,14 +287,14 @@
call UpdateStackTop
callba BackupPartyMonMail
callba BackupMobileEventIndex
- callba Function1406a
- ld a, BANK(s1_be45)
+ callba SaveRTC
+ ld a, BANK(sSaveType)
call GetSRAMBank
- ld a, [s1_be45]
+ ld a, [sSaveType]
cp $4
jr nz, .ok
xor a
- ld [s1_be45], a
+ ld [sSaveType], a
.ok
call CloseSRAM
ret
@@ -371,7 +372,7 @@
call EraseHallOfFame
call EraseLinkBattleStats
call EraseMysteryGift
- call Function14d68
+ call SaveData
call Function14d5c
ld a, BANK(sStackTop)
call GetSRAMBank
@@ -395,10 +396,10 @@
; 14cf4
EraseMysteryGift: ; 14cf4
- ld a, BANK(s0_abe4)
+ ld a, BANK(sBackupMysteryGiftItem)
call GetSRAMBank
- ld hl, s0_abe4
- ld bc, s0_abe4End - s0_abe4
+ ld hl, sBackupMysteryGiftItem
+ ld bc, sBackupMysteryGiftItemEnd - sBackupMysteryGiftItem
xor a
call ByteFill
jp CloseSRAM
@@ -437,15 +438,15 @@
; 14d5c
Function14d5c: ; 14d5c
- ld a, BANK(s1_be45)
+ ld a, BANK(sSaveType)
call GetSRAMBank
xor a
- ld [s1_be45], a
+ ld [sSaveType], a
jp CloseSRAM
; 14d68
-Function14d68: ; 14d68
- call Function1509a
+SaveData: ; 14d68
+ call _SaveData
ret
; 14d6c
@@ -547,7 +548,7 @@
ret
; 14e13
-Function14e13: ; 14e13
+SaveChecksum: ; 14e13
ld hl, sGameData
ld bc, sGameDataEnd - sGameData
ld a, BANK(sGameData)
@@ -632,7 +633,7 @@
call LoadBox
callba RestorePartyMonMail
callba RestoreMobileEventIndex
- callba Function1050ea
+ callba RestoreMysteryGift
call ValidateBackupSave
call SaveBackupOptions
call SaveBackupPlayerData
@@ -649,12 +650,12 @@
call LoadBox
callba RestorePartyMonMail
callba RestoreMobileEventIndex
- callba Function1050ea
+ callba RestoreMysteryGift
call ValidateSave
call SaveOptions
call SavePlayerData
call SavePokemonData
- call Function14e13
+ call SaveChecksum
and a
ret
@@ -671,11 +672,11 @@
ret
-Function14f1c: ; 14f1c
+TryLoadSaveData: ; 14f1c
xor a
- ld [wcfcd], a
- call Function14f84
- ld a, [wcfcd]
+ ld [wSaveFileExists], a
+ call CheckPrimarySaveFile
+ ld a, [wSaveFileExists]
and a
jr z, .backup
@@ -693,8 +694,8 @@
ret
.backup
- call Function14faf
- ld a, [wcfcd]
+ call CheckBackupSaveFile
+ ld a, [wSaveFileExists]
and a
jr z, .corrupt
@@ -716,7 +717,7 @@
ld de, Options
ld bc, OptionsEnd - Options
call CopyBytes
- call Function67e
+ call PanicResetClock
ret
; 14f7c
@@ -731,7 +732,7 @@
db $00
; 14f84
-Function14f84: ; 14f84
+CheckPrimarySaveFile: ; 14f84
ld a, BANK(s1_a008)
call GetSRAMBank
ld a, [s1_a008]
@@ -746,7 +747,7 @@
call CopyBytes
call CloseSRAM
ld a, $1
- ld [wcfcd], a
+ ld [wSaveFileExists], a
.nope
call CloseSRAM
@@ -753,7 +754,7 @@
ret
; 14faf
-Function14faf: ; 14faf
+CheckBackupSaveFile: ; 14faf
ld a, BANK(s0_b208)
call GetSRAMBank
ld a, [s0_b208]
@@ -767,7 +768,7 @@
ld bc, OptionsEnd - Options
call CopyBytes
ld a, $2
- ld [wcfcd], a
+ ld [wSaveFileExists], a
.nope
call CloseSRAM
@@ -787,14 +788,14 @@
ld bc, wMapDataEnd - wMapData
call CopyBytes
call CloseSRAM
- ld a, BANK(s1_be45)
+ ld a, BANK(sSaveType)
call GetSRAMBank
- ld a, [s1_be45]
+ ld a, [sSaveType]
cp $4
- jr nz, .asm_15008
+ jr nz, .not_4
ld a, $3
- ld [s1_be45], a
-.asm_15008
+ ld [sSaveType], a
+.not_4
call CloseSRAM
ret
@@ -822,10 +823,10 @@
call Checksum
ld a, [sChecksum + 0]
cp e
- jr nz, .asm_15040
+ jr nz, .fail
ld a, [sChecksum + 1]
cp d
-.asm_15040
+.fail
push af
call CloseSRAM
pop af
@@ -863,10 +864,10 @@
call Checksum
ld a, [sBackupChecksum + 0]
cp e
- jr nz, .asm_15094
+ jr nz, .fail
ld a, [sBackupChecksum + 1]
cp d
-.asm_15094
+.fail
push af
call CloseSRAM
pop af
@@ -873,7 +874,7 @@
ret
-Function1509a: ; 1509a
+_SaveData: ; 1509a
ld a, BANK(sCrystalData)
call GetSRAMBank
ld hl, wCrystalData
--- a/home/time.asm
+++ b/home/time.asm
@@ -5,10 +5,10 @@
push af
ld a, [hMobile]
and a
- jr z, .asm_59a
+ jr z, .not_mobile
call Timer
-.asm_59a
+.not_mobile
pop af
reti
; 59c
@@ -190,7 +190,7 @@
Function658:: ; 658
xor a
ld [StringBuffer2], a
- ld a, $0
+ ld a, $0 ; useless
ld [StringBuffer2 + 3], a
jr Function677
@@ -202,7 +202,7 @@
ld [StringBuffer2 + 2], a
ld a, [hSeconds]
ld [StringBuffer2 + 3], a
- jr Function677
+ jr Function677 ; useless
Function677:: ; 677
callba Function140ed
@@ -211,13 +211,13 @@
-Function67e:: ; 67e
- call Function685
+PanicResetClock:: ; 67e
+ call .ClearhRTC
call SetClock
ret
; 685
-Function685:: ; 685
+.ClearhRTC ; 685
xor a
ld [hRTCSeconds], a
ld [hRTCMinutes], a
--- a/main.asm
+++ b/main.asm
@@ -494,7 +494,7 @@
call DelayFrames
ld c, $1
callba Function4802f
- callba Function1509a
+ callba _SaveData
ld a, $8
ld [MusicFade], a
ld a, MUSIC_NONE % $100
@@ -1466,7 +1466,7 @@
; 642e
GameInit:: ; 642e
- callba Function14f1c
+ callba TryLoadSaveData
call ResetTextRelatedRAM
call ClearBGPalettes
call ClearTileMap
@@ -9924,7 +9924,7 @@
jr .quit
.no_mail
- callba Function14b34
+ callba StartMovePkmnWOMail_SaveGame
jr c, .quit
callba _MovePKMNWithoutMail
call ReturnToMapFromSubmenu
@@ -11219,7 +11219,7 @@
; 14056
-Function14056: ; 14056
+StageRTCTimeForSave: ; 14056
call UpdateTime
ld hl, wRTC
ld a, [CurDay]
@@ -11233,7 +11233,7 @@
ret
; 1406a
-Function1406a: ; 1406a
+SaveRTC: ; 1406a
ld a, $a
ld [MBC3SRamEnable], a
call LatchClock
@@ -14969,12 +14969,12 @@
call Function2c6ac
ld [de], a
inc de
- ld a, BANK(s0_abe4)
+ ld a, BANK(sBackupMysteryGiftItem)
call GetSRAMBank
- ld a, [s0_abe4]
+ ld a, [sBackupMysteryGiftItem]
ld [de], a
inc de
- ld a, [s0_abe4 + 1]
+ ld a, [sBackupMysteryGiftItem + 1]
ld [de], a
ld a, $14
ld [wca00], a
@@ -20677,7 +20677,7 @@
; 4cf45
-Function4cf45: ; 4cf45 (13:4f45)
+SaveMenu_LoadDETile: ; 4cf45 (13:4f45)
ld a, [hCGB]
and a
jp z, WaitBGMap
@@ -38369,7 +38369,7 @@
ld c, a
callba MysteryGiftGetItemHeldEffect
ld a, c
- ld [s0_abe4], a
+ ld [sBackupMysteryGiftItem], a
ld [wNamedObjectIndexBuffer], a
call CloseSRAM
call GetItemName
@@ -39434,10 +39434,10 @@
; 1050d9
-Function1050d9: ; 1050d9
+BackupMysteryGift: ; 1050d9
call GetMysteryGiftBank
ld hl, sMysteryGiftItem
- ld de, s0_abe4
+ ld de, sBackupMysteryGiftItem
ld a, [hli]
ld [de], a
inc de
@@ -39447,9 +39447,9 @@
; 1050ea
-Function1050ea: ; 1050ea (41:50ea)
+RestoreMysteryGift: ; 1050ea (41:50ea)
call GetMysteryGiftBank
- ld hl, s0_abe4
+ ld hl, sBackupMysteryGiftItem
ld de, sMysteryGiftItem
ld a, [hli]
ld [de], a
@@ -39470,7 +39470,7 @@
GetMysteryGiftBank: ; 105106
- ld a, BANK(s0_abe4)
+ ld a, BANK(sBackupMysteryGiftItem)
jp GetSRAMBank
; 10510b
--- a/misc/battle_tower_5c.asm
+++ b/misc/battle_tower_5c.asm
@@ -409,10 +409,10 @@
pop af
ld [rSVBK], a
- ld a, BANK(s1_be45)
+ ld a, BANK(sSaveType)
call GetSRAMBank
ld a, $2
- ld [s1_be45], a
+ ld [sSaveType], a
ld hl, sNrOfBeatenBattleTowerTrainers
inc [hl]
call CloseSRAM
--- a/misc/mobile_40.asm
+++ b/misc/mobile_40.asm
@@ -7965,7 +7965,7 @@
.asm_10379c
push bc
- callba Function14ab2
+ callba Link_SaveGame
pop bc
jr c, .asm_1037b5
ld a, $1
--- a/misc/mobile_5c.asm
+++ b/misc/mobile_5c.asm
@@ -652,18 +652,18 @@
ret
Function17071b: ; 17071b (5c:471b)
- ld a, BANK(s1_be45)
+ ld a, BANK(sSaveType)
call GetSRAMBank
ld a, $3
- ld [s1_be45], a
+ ld [sSaveType], a
call CloseSRAM
ret
Function170729: ; 170729 (5c:4729)
- ld a, BANK(s1_be45)
+ ld a, BANK(sSaveType)
call GetSRAMBank
ld a, $4
- ld [s1_be45], a
+ ld [sSaveType], a
call CloseSRAM
ret
@@ -704,8 +704,8 @@
ret
Function170778: ; 170778 (5c:4778)
- ld hl, s1_be45
- ld a, BANK(s1_be45)
+ ld hl, sSaveType
+ ld a, BANK(sSaveType)
call GetSRAMBank
ld a, [hl]
ld [ScriptVar], a
@@ -728,10 +728,10 @@
Function17079d: ; 17079d (5c:479d)
ld c, $0
asm_17079f: ; 17079f (5c:479f)
- ld a, BANK(s1_be45)
+ ld a, BANK(sSaveType)
call GetSRAMBank
ld a, c
- ld [s1_be45], a
+ ld [sSaveType], a
call CloseSRAM
ret
@@ -868,7 +868,7 @@
ret
Function17089a: ; 17089a
- ld a, [wcfcd]
+ ld a, [wSaveFileExists]
and a
jr z, .asm_1708ad
callba Function14bcb
--- a/misc/mobile_5f.asm
+++ b/misc/mobile_5f.asm
@@ -3111,7 +3111,7 @@
push af
ld a, $1
ld [rSVBK], a
- callba Function14e13
+ callba SaveChecksum
pop af
ld [rSVBK], a
ret
--- a/sram.asm
+++ b/sram.asm
@@ -15,15 +15,16 @@
ds 3
\1MailType:: ds 1
endm
-
+; a600
sPartyMail::
-sPartyMon1Mail:: mailmsg sPartyMon1Mail
-sPartyMon2Mail:: mailmsg sPartyMon2Mail
-sPartyMon3Mail:: mailmsg sPartyMon3Mail
-sPartyMon4Mail:: mailmsg sPartyMon4Mail
-sPartyMon5Mail:: mailmsg sPartyMon5Mail
-sPartyMon6Mail:: mailmsg sPartyMon6Mail
+sPartyMon1Mail:: mailmsg sPartyMon1Mail
+sPartyMon2Mail:: mailmsg sPartyMon2Mail
+sPartyMon3Mail:: mailmsg sPartyMon3Mail
+sPartyMon4Mail:: mailmsg sPartyMon4Mail
+sPartyMon5Mail:: mailmsg sPartyMon5Mail
+sPartyMon6Mail:: mailmsg sPartyMon6Mail
+; a71a
sPartyMailBackup::
sPartyMon1MailBackup:: mailmsg sPartyMon1MailBackup
sPartyMon2MailBackup:: mailmsg sPartyMon2MailBackup
@@ -32,35 +33,38 @@
sPartyMon5MailBackup:: mailmsg sPartyMon5MailBackup
sPartyMon6MailBackup:: mailmsg sPartyMon6MailBackup
+; a834
sMailboxCount:: ds 1
sMailbox::
-sMailbox1:: mailmsg sMailbox1
-sMailbox2:: mailmsg sMailbox2
-sMailbox3:: mailmsg sMailbox3
-sMailbox4:: mailmsg sMailbox4
-sMailbox5:: mailmsg sMailbox5
-sMailbox6:: mailmsg sMailbox6
-sMailbox7:: mailmsg sMailbox7
-sMailbox8:: mailmsg sMailbox8
-sMailbox9:: mailmsg sMailbox9
-sMailbox10:: mailmsg sMailbox10
+sMailbox1:: mailmsg sMailbox1
+sMailbox2:: mailmsg sMailbox2
+sMailbox3:: mailmsg sMailbox3
+sMailbox4:: mailmsg sMailbox4
+sMailbox5:: mailmsg sMailbox5
+sMailbox6:: mailmsg sMailbox6
+sMailbox7:: mailmsg sMailbox7
+sMailbox8:: mailmsg sMailbox8
+sMailbox9:: mailmsg sMailbox9
+sMailbox10:: mailmsg sMailbox10
+; aa0b
sMailboxCountBackup:: ds 1
sMailboxBackup::
-sMailbox1Backup:: mailmsg sMailbox1Backup
-sMailbox2Backup:: mailmsg sMailbox2Backup
-sMailbox3Backup:: mailmsg sMailbox3Backup
-sMailbox4Backup:: mailmsg sMailbox4Backup
-sMailbox5Backup:: mailmsg sMailbox5Backup
-sMailbox6Backup:: mailmsg sMailbox6Backup
-sMailbox7Backup:: mailmsg sMailbox7Backup
-sMailbox8Backup:: mailmsg sMailbox8Backup
-sMailbox9Backup:: mailmsg sMailbox9Backup
-sMailbox10Backup:: mailmsg sMailbox10Backup
+sMailbox1Backup:: mailmsg sMailbox1Backup
+sMailbox2Backup:: mailmsg sMailbox2Backup
+sMailbox3Backup:: mailmsg sMailbox3Backup
+sMailbox4Backup:: mailmsg sMailbox4Backup
+sMailbox5Backup:: mailmsg sMailbox5Backup
+sMailbox6Backup:: mailmsg sMailbox6Backup
+sMailbox7Backup:: mailmsg sMailbox7Backup
+sMailbox8Backup:: mailmsg sMailbox8Backup
+sMailbox9Backup:: mailmsg sMailbox9Backup
+sMailbox10Backup:: mailmsg sMailbox10Backup
+; abe2
sMysteryGiftItem:: ds 1
s0_abe3:: ds 1
-s0_abe4:: ds 1
+sBackupMysteryGiftItem:: ds 1
s0_abe5:: ds 1
s0_abe6:: ds 10
s0_abf0:: ds 10
@@ -71,7 +75,7 @@
s0_abfe:: ds 12
sMysteryGiftTrainer:: ds (1 + 1 + NUM_MOVES) * PARTY_LENGTH + 1
ds 1
-s0_abe4End::
+sBackupMysteryGiftItemEnd::
ds $30
@@ -145,7 +149,9 @@
sCrystalData::
ds wCrystalDataEnd - wCrystalData
sMobileEventIndexBackup:: ds 1
-s1_be45:: ds 1
+sSaveType:: ds 1
+; 0: normal
+; 2: battle tower
; data of the BattleTower must be in SRAM because you can save and leave between battles
sBattleTower:: ; be46
--- a/wram.asm
+++ b/wram.asm
@@ -1418,7 +1418,7 @@
; bit 7: battle scene off/on
ds 1
-wcfcd:: ds 1
+wSaveFileExists:: ds 1
TextBoxFrame:: ; cfce
; bits 0-2: textbox frame 0-7