shithub: pokecrystal

Download patch

ref: 860296f468a0a941421d5cf8ca6a66217dc01e28
parent: 9c84a3dd2245f149b361aa7603354297b3784b3e
author: yenatch <[email protected]>
date: Wed Aug 19 17:14:15 EDT 2015

Comment and label the save file.

--- a/constants/misc_constants.asm
+++ b/constants/misc_constants.asm
@@ -33,6 +33,11 @@
 MONS_PER_BOX EQU 20
 NUM_BOXES    EQU 14
 
+; hall of fame
+HOF_MON_LENGTH = 1 + 2 + 2 + 1 + (PKMN_NAME_LENGTH +- 1) ; species, id, dvs, level, nick
+HOF_LENGTH = 1 + HOF_MON_LENGTH * PARTY_LENGTH + 1 ; win count, party, terminator
+NUM_HOF_TEAMS = 30
+
 
 ; flag manipulation
 RESET_FLAG EQU 0
--- a/engine/save.asm
+++ b/engine/save.asm
@@ -26,10 +26,10 @@
 	call SetWRAMStateForSave
 	callba Function14056
 	callba Function1050d9
-	call SavePartyData
+	call SavePokemonData
 	call Function14e13
-	call LoadSavedPartyData
-	call Function14e8b
+	call SaveBackupPokemonData
+	call SaveBackupChecksum
 	callba Function44725
 	callba Function1406a
 	call ClearWRAMStateAfterSave
@@ -48,11 +48,11 @@
 	jr c, .refused
 	call SetWRAMStateForSave
 	call SavingDontTurnOffThePower
-	call Function14e0c
+	call SaveBox
 	pop de
 	ld a, e
 	ld [wCurBox], a
-	call Function15021
+	call LoadBox
 	call SavedTheGame
 	call ClearWRAMStateAfterSave
 	and a
@@ -76,11 +76,11 @@
 Function14ac2: ; 14ac2
 	call SetWRAMStateForSave
 	push de
-	call Function14e0c
+	call SaveBox
 	pop de
 	ld a, e
 	ld [wCurBox], a
-	call Function15021
+	call LoadBox
 	call ClearWRAMStateAfterSave
 	ret
 ; 14ad5
@@ -88,7 +88,7 @@
 Function14ad5: ; 14ad5
 	call SetWRAMStateForSave
 	push de
-	call Function14e0c
+	call SaveBox
 	pop de
 	ld a, e
 	ld [wCurBox], a
@@ -96,20 +96,20 @@
 	ld [wcfcd], a
 	callba Function14056
 	callba Function1050d9
-	call Function14da9
-	call SaveOptionsSelection
+	call ValidateSave
+	call SaveOptions
 	call SavePlayerData
-	call SavePartyData
+	call SavePokemonData
 	call Function14e13
-	call Function14e2d
-	call LoadSavedOptions
-	call LoadSavedPlayerData
-	call LoadSavedPartyData
-	call Function14e8b
+	call ValidateBackupSave
+	call SaveBackupOptions
+	call SaveBackupPlayerData
+	call SaveBackupPokemonData
+	call SaveBackupChecksum
 	callba Function44725
 	callba Function106187
 	callba Function1406a
-	call Function15021
+	call LoadBox
 	call ClearWRAMStateAfterSave
 	ld de, SFX_SAVE
 	call PlaySFX
@@ -150,12 +150,12 @@
 ; 14b5f
 
 
-Function14b5f: ; 14b5f
-	ld a, $1
+AddHallOfFameEntry: ; 14b5f
+	ld a, BANK(sHallOfFame)
 	call GetSRAMBank
-	ld hl, $bdd9
-	ld de, $be3b
-	ld bc, $0b1a
+	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)
 .loop
 	ld a, [hld]
 	ld [de], a
@@ -165,15 +165,15 @@
 	or b
 	jr nz, .loop
 	ld hl, OverworldMap
-	ld de, $b2c0
-	ld bc, 7 * 14
+	ld de, sHallOfFame
+	ld bc, HOF_LENGTH
 	call CopyBytes
 	call CloseSRAM
 	ret
 ; 14b85
 
-Function14b85: ; 14b85
-	call Function14c10
+SaveGameData: ; 14b85
+	call SaveGameData_
 	ret
 ; 14b89
 
@@ -180,13 +180,13 @@
 CheckForExistingSaveFile: ; 14b89
 	ld a, [wcfcd]
 	and a
-	jr z, .getridofpreviousplayersave
+	jr z, .erase
 	call Function14bcb
 	jr z, .yoursavefile
 	ld hl, UnknownText_0x15297
 	call SaveTheGame_yesorno
 	jr nz, .refused
-	jr .getridofpreviousplayersave
+	jr .erase
 
 .yoursavefile
 	ld hl, UnknownText_0x15292
@@ -194,8 +194,8 @@
 	jr nz, .refused
 	jr .ok
 
-.getridofpreviousplayersave
-	call GetRidOfPreviousPlayersSave
+.erase
+	call ErasePreviousSave
 
 .ok
 	and a
@@ -223,9 +223,9 @@
 ; 14bcb
 
 Function14bcb: ; 14bcb
-	ld a, $1
+	ld a, BANK(sPlayerData)
 	call GetSRAMBank
-	ld hl, $a009
+	ld hl, sPlayerData + (PlayerID - wPlayerData)
 	ld a, [hli]
 	ld c, [hl]
 	ld b, a
@@ -241,7 +241,7 @@
 _SavingDontTurnOffThePower: ; 14be3
 	call SavingDontTurnOffThePower
 SavedTheGame: ; 14be6
-	call Function14c10
+	call SaveGameData_
 	; wait 32 frames
 	ld c, $20
 	call DelayFrames
@@ -267,74 +267,77 @@
 ; 14c10
 
 
-Function14c10: ; 14c10
+SaveGameData_: ; 14c10
 	ld a, 1
 	ld [wcfcd], a
 	callba Function14056
 	callba Function1050d9
-	call Function14da9
-	call SaveOptionsSelection
+	call ValidateSave
+	call SaveOptions
 	call SavePlayerData
-	call SavePartyData
-	call Function14e0c
+	call SavePokemonData
+	call SaveBox
 	call Function14e13
-	call Function14e2d
-	call LoadSavedOptions
-	call LoadSavedPlayerData
-	call LoadSavedPartyData
-	call Function14e8b
-	call Function14c6b
+	call ValidateBackupSave
+	call SaveBackupOptions
+	call SaveBackupPlayerData
+	call SaveBackupPokemonData
+	call SaveBackupChecksum
+	call UpdateStackTop
 	callba Function44725
 	callba Function106187
 	callba Function1406a
-	ld a, $1
+	ld a, BANK(s1_be45)
 	call GetSRAMBank
-	ld a, [$be45]
+	ld a, [s1_be45]
 	cp $4
-	jr nz, .asm_14c67
+	jr nz, .ok
 	xor a
-	ld [$be45], a
-
-.asm_14c67
+	ld [s1_be45], a
+.ok
 	call CloseSRAM
 	ret
 ; 14c6b
 
-Function14c6b: ; 14c6b
-	call Function14c90
-	ld a, $0
+UpdateStackTop: ; 14c6b
+; sStackTop appears to be unused.
+; It could have been used to debug stack overflow during saving.
+	call FindStackTop
+	ld a, BANK(sStackTop)
 	call GetSRAMBank
-	ld a, [$bf10]
+	ld a, [sStackTop + 0]
 	ld e, a
-	ld a, [$bf11]
+	ld a, [sStackTop + 1]
 	ld d, a
 	or e
-	jr z, .asm_14c84
+	jr z, .update
 	ld a, e
 	sub l
 	ld a, d
 	sbc h
-	jr c, .asm_14c8c
+	jr c, .done
 
-.asm_14c84
+.update
 	ld a, l
-	ld [$bf10], a
+	ld [sStackTop + 0], a
 	ld a, h
-	ld [$bf11], a
+	ld [sStackTop + 1], a
 
-.asm_14c8c
+.done
 	call CloseSRAM
 	ret
 ; 14c90
 
-Function14c90: ; 14c90
-	ld hl, wc000
-.asm_14c93
+FindStackTop: ; 14c90
+; Find the furthest point that sp has traversed to.
+; This is distinct from the current value of sp.
+	ld hl, Stack - $ff
+.loop
 	ld a, [hl]
 	or a
 	ret nz
 	inc hl
-	jr .asm_14c93
+	jr .loop
 ; 14c99
 
 SavingDontTurnOffThePower: ; 14c99
@@ -363,18 +366,18 @@
 ; 14cbb
 
 
-GetRidOfPreviousPlayersSave: ; 14cbb
-	call Function151fb
-	call Function14d06
-	call Function14ce2
-	call Function14cf4
+ErasePreviousSave: ; 14cbb
+	call EraseBoxes
+	call EraseHallOfFame
+	call EraseLinkBattleStats
+	call EraseMysteryGift
 	call Function14d68
 	call Function14d5c
-	ld a, $0
+	ld a, BANK(sStackTop)
 	call GetSRAMBank
 	xor a
-	ld [$bf10], a
-	ld [$bf11], a
+	ld [sStackTop + 0], a
+	ld [sStackTop + 1], a
 	call CloseSRAM
 	ld a, $1
 	ld [wd4b4], a
@@ -381,31 +384,31 @@
 	ret
 ; 14ce2
 
-Function14ce2: ; 14ce2
-	ld a, $1
+EraseLinkBattleStats: ; 14ce2
+	ld a, BANK(sLinkBattleStats)
 	call GetSRAMBank
-	ld hl, $b260
-	ld bc, $0060
+	ld hl, sLinkBattleStats
+	ld bc, sLinkBattleStatsEnd - sLinkBattleStats
 	xor a
 	call ByteFill
 	jp CloseSRAM
 ; 14cf4
 
-Function14cf4: ; 14cf4
-	ld a, $0
+EraseMysteryGift: ; 14cf4
+	ld a, BANK(s0_abe4)
 	call GetSRAMBank
-	ld hl, $abe4
-	ld bc, $004c
+	ld hl, s0_abe4
+	ld bc, s0_abe4End - s0_abe4
 	xor a
 	call ByteFill
 	jp CloseSRAM
 ; 14d06
 
-Function14d06: ; 14d06
-	ld a, $1
+EraseHallOfFame: ; 14d06
+	ld a, BANK(sHallOfFame)
 	call GetSRAMBank
-	ld hl, $b2c0
-	ld bc, $0b7c
+	ld hl, sHallOfFame
+	ld bc, sHallOfFameEnd - sHallOfFame
 	xor a
 	call ByteFill
 	jp CloseSRAM
@@ -434,10 +437,10 @@
 ; 14d5c
 
 Function14d5c: ; 14d5c
-	ld a, $1
+	ld a, BANK(s1_be45)
 	call GetSRAMBank
 	xor a
-	ld [$be45], a
+	ld [s1_be45], a
 	jp CloseSRAM
 ; 14d68
 
@@ -486,97 +489,94 @@
 	ld a, [wd4b4]
 	and a
 	ret nz
-	call GetRidOfPreviousPlayersSave
+	call ErasePreviousSave
 	ret
 ; 14da9
 
-Function14da9: ; 14da9
-	ld a, $1
+ValidateSave: ; 14da9
+	ld a, BANK(s1_a008)
 	call GetSRAMBank
-	ld a, 99
-	ld [$a008], a
-	ld a, " "
-	ld [$ad0f], a
+	ld a, $63
+	ld [s1_a008], a
+	ld a, $7f
+	ld [s1_ad0f], a
 	jp CloseSRAM
 ; 14dbb
 
-SaveOptionsSelection: ; 14dbb
-; Copy Options to SRA1:a000
-	ld a, $1
+SaveOptions: ; 14dbb
+	ld a, BANK(sOptions)
 	call GetSRAMBank
 	ld hl, Options
-	ld de, $a000
+	ld de, sOptions
 	ld bc, OptionsEnd - Options
 	call CopyBytes
 	ld a, [Options]
 	and $ef
-	ld [$a000], a
+	ld [sOptions], a
 	jp CloseSRAM
 ; 14dd7
 
 SavePlayerData: ; 14dd7
-; Copy 2122 bytes starting at PlayerID to SRA1:a009
-	ld a, $1
+	ld a, BANK(sPlayerData)
 	call GetSRAMBank
-	ld hl, PlayerID
-	ld de, $a009
-	ld bc, VisitedSpawns - PlayerID
+	ld hl, wPlayerData
+	ld de, sPlayerData
+	ld bc, wPlayerDataEnd - wPlayerData
 	call CopyBytes
-	ld hl, VisitedSpawns
-	ld de, $a833
-	ld bc, PartyCount - VisitedSpawns
+	ld hl, wMapData
+	ld de, sMapData
+	ld bc, wMapDataEnd - wMapData
 	call CopyBytes
 	jp CloseSRAM
 ; 14df7
 
-SavePartyData: ; 14df7
-; Copy your party to SRA1:a865.
-	ld a, $1
+SavePokemonData: ; 14df7
+	ld a, BANK(sPokemonData)
 	call GetSRAMBank
-	ld hl, PartyCount
-	ld de, $a865
-	ld bc, wdff5 - PartyCount
+	ld hl, wPokemonData
+	ld de, sPokemonData
+	ld bc, wPokemonDataEnd - wPokemonData
 	call CopyBytes
 	call CloseSRAM
 	ret
 ; 14e0c
 
-Function14e0c: ; 14e0c
-	call Function150d8
-	call Function150f9
+SaveBox: ; 14e0c
+	call GetBoxAddress
+	call SaveBoxAddress
 	ret
 ; 14e13
 
 Function14e13: ; 14e13
-	ld hl, $a009
-	ld bc, $0b7a
-	ld a, $1
+	ld hl, sGameData
+	ld bc, sGameDataEnd - sGameData
+	ld a, BANK(sGameData)
 	call GetSRAMBank
-	call Function15273
+	call Checksum
 	ld a, e
-	ld [$ad0d], a
+	ld [sChecksum + 0], a
 	ld a, d
-	ld [$ad0e], a
+	ld [sChecksum + 1], a
 	call CloseSRAM
 	ret
 ; 14e2d
 
-Function14e2d: ; 14e2d
-	ld a, $0
+ValidateBackupSave: ; 14e2d
+	ld a, BANK(s0_b208)
 	call GetSRAMBank
-	ld a, 99
-	ld [$b208], a
-	ld a, " "
-	ld [$bf0f], a
+	ld a, $63
+	ld [s0_b208], a
+	ld a, $7f
+	ld [s0_bf0f], a
 	call CloseSRAM
 	ret
 ; 14e40
 
-LoadSavedOptions: ; 14e40
-	ld a, $0
+SaveBackupOptions: ; 14e40
+	ld a, BANK(sBackupOptions)
 	call GetSRAMBank
 	ld hl, Options
-	ld de, $b200
+	ld de, sBackupOptions
 	ld bc, OptionsEnd - Options
 	call CopyBytes
 	call CloseSRAM
@@ -583,42 +583,42 @@
 	ret
 ; 14e55
 
-LoadSavedPlayerData: ; 14e55
-	ld a, $0
+SaveBackupPlayerData: ; 14e55
+	ld a, BANK(sBackupPlayerData)
 	call GetSRAMBank
-	ld hl, PlayerID
-	ld de, $b209
-	ld bc, VisitedSpawns - PlayerID
+	ld hl, wPlayerData
+	ld de, sBackupPlayerData
+	ld bc, wPlayerDataEnd - wPlayerData
 	call CopyBytes
-	ld hl, VisitedSpawns
-	ld de, $ba33
-	ld bc, PartyCount - VisitedSpawns
+	ld hl, wMapData
+	ld de, sBackupMapData
+	ld bc, wMapDataEnd - wMapData
 	call CopyBytes
 	call CloseSRAM
 	ret
 ; 14e76
 
-LoadSavedPartyData: ; 14e76
-	ld a, $0
+SaveBackupPokemonData: ; 14e76
+	ld a, BANK(sBackupPokemonData)
 	call GetSRAMBank
-	ld hl, PartyCount
-	ld de, $ba65
-	ld bc, wdff5 - PartyCount
+	ld hl, wPokemonData
+	ld de, sBackupPokemonData
+	ld bc, wPokemonDataEnd - wPokemonData
 	call CopyBytes
 	call CloseSRAM
 	ret
 ; 14e8b
 
-Function14e8b: ; 14e8b
-	ld hl, $b209
-	ld bc, $0b7a
-	ld a, $0
+SaveBackupChecksum: ; 14e8b
+	ld hl, sBackupGameData
+	ld bc, sBackupGameDataEnd - sBackupGameData
+	ld a, BANK(sBackupGameData)
 	call GetSRAMBank
-	call Function15273
+	call Checksum
 	ld a, e
-	ld [$bf0d], a
+	ld [sBackupChecksum + 0], a
 	ld a, d
-	ld [$bf0e], a
+	ld [sBackupChecksum + 1], a
 	call CloseSRAM
 	ret
 ; 14ea5
@@ -625,37 +625,39 @@
 
 
 TryLoadSaveFile: ; 14ea5 (5:4ea5)
-	call Function15028
-	jr nz, .trytowrite
-	call Function14fd7
-	call Function1500c
-	call Function15021
+	call VerifyChecksum
+	jr nz, .backup
+	call LoadPlayerData
+	call LoadPokemonData
+	call LoadBox
 	callba Function44745
 	callba Function10619d
 	callba Function1050ea
-	call Function14e2d
-	call LoadSavedOptions
-	call LoadSavedPlayerData
-	call LoadSavedPartyData
-	call Function14e8b
+	call ValidateBackupSave
+	call SaveBackupOptions
+	call SaveBackupPlayerData
+	call SaveBackupPokemonData
+	call SaveBackupChecksum
 	and a
 	ret
-.trytowrite
-	call Function1507c
+
+.backup
+	call VerifyBackupChecksum
 	jr nz, .corrupt
-	call Function15046
-	call Function15067
-	call Function15021
+	call LoadBackupPlayerData
+	call LoadBackupPokemonData
+	call LoadBox
 	callba Function44745
 	callba Function10619d
 	callba Function1050ea
-	call Function14da9
-	call SaveOptionsSelection
+	call ValidateSave
+	call SaveOptions
 	call SavePlayerData
-	call SavePartyData
+	call SavePokemonData
 	call Function14e13
 	and a
 	ret
+
 .corrupt
 	ld a, [Options]
 	push af
@@ -675,14 +677,15 @@
 	call Function14f84
 	ld a, [wcfcd]
 	and a
-	jr z, .asm_14f46
-	ld a, $1
+	jr z, .backup
+
+	ld a, BANK(sPlayerData)
 	call GetSRAMBank
-	ld hl, $a044
+	ld hl, sPlayerData + StartDay - wPlayerData
 	ld de, StartDay
-	ld bc, $0008
+	ld bc, 8
 	call CopyBytes
-	ld hl, $a3da
+	ld hl, sPlayerData + StatusFlags - wPlayerData
 	ld de, StatusFlags
 	ld a, [hl]
 	ld [de], a
@@ -689,18 +692,19 @@
 	call CloseSRAM
 	ret
 
-.asm_14f46
+.backup
 	call Function14faf
 	ld a, [wcfcd]
 	and a
-	jr z, .asm_14f6c
-	ld a, $0
+	jr z, .corrupt
+
+	ld a, BANK(sBackupPlayerData)
 	call GetSRAMBank
-	ld hl, $b244
+	ld hl, sBackupPlayerData + StartDay - wPlayerData
 	ld de, StartDay
 	ld bc, 8
 	call CopyBytes
-	ld hl, $b5da
+	ld hl, sBackupPlayerData + StatusFlags - wPlayerData
 	ld de, StatusFlags
 	ld a, [hl]
 	ld [de], a
@@ -707,7 +711,7 @@
 	call CloseSRAM
 	ret
 
-.asm_14f6c
+.corrupt
 	ld hl, DefaultOptions
 	ld de, Options
 	ld bc, OptionsEnd - Options
@@ -728,15 +732,15 @@
 ; 14f84
 
 Function14f84: ; 14f84
-	ld a, $1
+	ld a, BANK(s1_a008)
 	call GetSRAMBank
-	ld a, [$a008]
-	cp 99
+	ld a, [s1_a008]
+	cp $63
 	jr nz, .nope
-	ld a, [$ad0f]
-	cp " "
+	ld a, [s1_ad0f]
+	cp $7f
 	jr nz, .nope
-	ld hl, $a000
+	ld hl, sOptions
 	ld de, Options
 	ld bc, OptionsEnd - Options
 	call CopyBytes
@@ -750,15 +754,15 @@
 ; 14faf
 
 Function14faf: ; 14faf
-	ld a, $0
+	ld a, BANK(s0_b208)
 	call GetSRAMBank
-	ld a, [$b208]
-	cp 99
+	ld a, [s0_b208]
+	cp $63
 	jr nz, .nope
-	ld a, [$bf0f]
-	cp " "
+	ld a, [s0_bf0f]
+	cp $7f
 	jr nz, .nope
-	ld hl, $b200
+	ld hl, sBackupOptions
 	ld de, Options
 	ld bc, OptionsEnd - Options
 	call CopyBytes
@@ -771,56 +775,55 @@
 ; 14fd7
 
 
-Function14fd7: ; 14fd7 (5:4fd7)
-	ld a, $1
+LoadPlayerData: ; 14fd7 (5:4fd7)
+	ld a, BANK(sPlayerData)
 	call GetSRAMBank
-	ld hl, $a009
-	ld de, PlayerID
-	ld bc, VisitedSpawns - PlayerID
+	ld hl, sPlayerData
+	ld de, wPlayerData
+	ld bc, wPlayerDataEnd - wPlayerData
 	call CopyBytes
-	ld hl, $a833
-	ld de, VisitedSpawns
-	ld bc, PartyCount - VisitedSpawns
+	ld hl, sMapData
+	ld de, wMapData
+	ld bc, wMapDataEnd - wMapData
 	call CopyBytes
 	call CloseSRAM
-	ld a, $1
+	ld a, BANK(s1_be45)
 	call GetSRAMBank
-	ld a, [$be45]
+	ld a, [s1_be45]
 	cp $4
 	jr nz, .asm_15008
 	ld a, $3
-	ld [$be45], a
+	ld [s1_be45], a
 .asm_15008
 	call CloseSRAM
 	ret
 
-Function1500c: ; 1500c
-	ld a, $1
+LoadPokemonData: ; 1500c
+	ld a, BANK(sPokemonData)
 	call GetSRAMBank
-	ld hl, $a865
-	ld de, PartyCount
-	ld bc, wdff5 - PartyCount
+	ld hl, sPokemonData
+	ld de, wPokemonData
+	ld bc, wPokemonDataEnd - wPokemonData
 	call CopyBytes
 	call CloseSRAM
 	ret
 ; 15021
 
-
-Function15021: ; 15021 (5:5021)
-	call Function150d8
-	call Function1517d
+LoadBox: ; 15021 (5:5021)
+	call GetBoxAddress
+	call LoadBoxAddress
 	ret
 
-Function15028: ; 15028 (5:5028)
-	ld hl, $a009
-	ld bc, $b7a
-	ld a, $1
+VerifyChecksum: ; 15028 (5:5028)
+	ld hl, sGameData
+	ld bc, sGameDataEnd - sGameData
+	ld a, BANK(sGameData)
 	call GetSRAMBank
-	call Function15273
-	ld a, [$ad0d]
+	call Checksum
+	ld a, [sChecksum + 0]
 	cp e
 	jr nz, .asm_15040
-	ld a, [$ad0e]
+	ld a, [sChecksum + 1]
 	cp d
 .asm_15040
 	push af
@@ -828,40 +831,40 @@
 	pop af
 	ret
 
-Function15046: ; 15046 (5:5046)
-	ld a, $0
+LoadBackupPlayerData: ; 15046 (5:5046)
+	ld a, BANK(sBackupPlayerData)
 	call GetSRAMBank
-	ld hl, $b209
-	ld de, PlayerID
-	ld bc, VisitedSpawns - PlayerID
+	ld hl, sBackupPlayerData
+	ld de, wPlayerData
+	ld bc, wPlayerDataEnd - wPlayerData
 	call CopyBytes
-	ld hl, $ba33
-	ld de, VisitedSpawns
-	ld bc, PartyCount - VisitedSpawns
+	ld hl, sBackupMapData
+	ld de, wMapData
+	ld bc, wMapDataEnd - wMapData
 	call CopyBytes
 	call CloseSRAM
 	ret
 
-Function15067: ; 15067 (5:5067)
-	ld a, $0
+LoadBackupPokemonData: ; 15067 (5:5067)
+	ld a, BANK(sBackupPokemonData)
 	call GetSRAMBank
-	ld hl, $ba65
-	ld de, PartyCount
-	ld bc, wdff5 - PartyCount
+	ld hl, sBackupPokemonData
+	ld de, wPokemonData
+	ld bc, wPokemonDataEnd - wPokemonData
 	call CopyBytes
 	call CloseSRAM
 	ret
 
-Function1507c: ; 1507c (5:507c)
-	ld hl, $b209
-	ld bc, $b7a
-	ld a, $0
+VerifyBackupChecksum: ; 1507c (5:507c)
+	ld hl, sBackupGameData
+	ld bc, sBackupGameDataEnd - sBackupGameData
+	ld a, BANK(sBackupGameData)
 	call GetSRAMBank
-	call Function15273
-	ld a, [$bf0d]
+	call Checksum
+	ld a, [sBackupChecksum + 0]
 	cp e
 	jr nz, .asm_15094
-	ld a, [$bf0e]
+	ld a, [sBackupChecksum + 1]
 	cp d
 .asm_15094
 	push af
@@ -871,47 +874,54 @@
 
 
 Function1509a: ; 1509a
-	ld a, $1
+	ld a, BANK(sCrystalData)
 	call GetSRAMBank
-	ld hl, PlayerGender
-	ld de, $be3d
-	ld bc, wd479 - PlayerGender
+	ld hl, wCrystalData
+	ld de, sCrystalData
+	ld bc, wCrystalDataEnd - wCrystalData
 	call CopyBytes
+
+	; XXX $a60e-f is a static address left over from JP Crystal.
+	; It appears to correspond to event flags 0x160-0x16f in that version.
 	ld hl, wd479
 	ld a, [hli]
-	ld [$a60e], a
+	ld [$a60e + 0], a
 	ld a, [hli]
-	ld [$a60f], a
+	ld [$a60e + 1], a
+
 	jp CloseSRAM
-; 150b9
 
 
-Function150b9: ; 150b9 (5:50b9)
-	ld a, $1
+Function150b9: ; 150b9
+	ld a, BANK(sCrystalData)
 	call GetSRAMBank
-	ld hl, $be3d
-	ld de, PlayerGender
-	ld bc, wd479 - PlayerGender
+	ld hl, sCrystalData
+	ld de, wCrystalData
+	ld bc, wCrystalDataEnd - wCrystalData
 	call CopyBytes
+
+	; XXX $a60e-f is a static address left over from JP Crystal.
+	; It appears to correspond to event flags 0x160-0x16f in that version.
 	ld hl, wd479
-	ld a, [$a60e]
+	ld a, [$a60e + 0]
 	ld [hli], a
-	ld a, [$a60f]
+	ld a, [$a60e + 1]
 	ld [hli], a
+
 	jp CloseSRAM
 
 
-Function150d8: ; 150d8
+GetBoxAddress: ; 150d8
 	ld a, [wCurBox]
 	cp NUM_BOXES
-	jr c, .asm_150e3
+	jr c, .ok
 	xor a
 	ld [wCurBox], a
 
-.asm_150e3
+.ok
 	ld e, a
 	ld d, 0
-	ld hl, Unknown_1522d
+	ld hl, BoxAddresses
 rept 5
 	add hl, de
 endr
@@ -928,129 +938,141 @@
 	ret
 ; 150f9
 
-Function150f9: ; 150f9
+SaveBoxAddress: ; 150f9
 	push hl
+
 	push af
 	push de
-	ld a, $1
+	ld a, BANK(sBox)
 	call GetSRAMBank
-	ld hl, sBoxCount
-	ld de, wc608
-	ld bc, $01e0
+	ld hl, sBox
+	ld de, wMisc
+	ld bc, (wMiscEnd - wMisc)
 	call CopyBytes
 	call CloseSRAM
 	pop de
 	pop af
+
 	push af
 	push de
 	call GetSRAMBank
-	ld hl, wc608
-	ld bc, $01e0
+	ld hl, wMisc
+	ld bc, (wMiscEnd - wMisc)
 	call CopyBytes
 	call CloseSRAM
-	ld a, $1
+	ld a, BANK(sBox)
 	call GetSRAMBank
-	ld hl, $aef0
-	ld de, wc608
-	ld bc, $01e0
+	ld hl, sBox + (wMiscEnd - wMisc)
+	ld de, wMisc
+	ld bc, (wMiscEnd - wMisc)
 	call CopyBytes
 	call CloseSRAM
 	pop de
 	pop af
-	ld hl, $01e0
+
+	ld hl, (wMiscEnd - wMisc)
 	add hl, de
 	ld e, l
 	ld d, h
+
 	push af
 	push de
 	call GetSRAMBank
-	ld hl, wc608
-	ld bc, $01e0
+	ld hl, wMisc
+	ld bc, (wMiscEnd - wMisc)
 	call CopyBytes
 	call CloseSRAM
-	ld a, $1
+	ld a, BANK(sBox)
 	call GetSRAMBank
-	ld hl, $b0d0
-	ld de, wc608
-	ld bc, $008e
+	ld hl, sBox + (wMiscEnd - wMisc) * 2
+	ld de, wMisc
+	ld bc, sBoxEnd - (sBox + (wMiscEnd - wMisc) * 2) ; $8e
 	call CopyBytes
 	call CloseSRAM
 	pop de
 	pop af
-	ld hl, $01e0
+
+	ld hl, (wMiscEnd - wMisc)
 	add hl, de
 	ld e, l
 	ld d, h
+
 	call GetSRAMBank
-	ld hl, wc608
-	ld bc, $008e
+	ld hl, wMisc
+	ld bc, sBoxEnd - (sBox + (wMiscEnd - wMisc) * 2) ; $8e
 	call CopyBytes
 	call CloseSRAM
+
 	pop hl
 	ret
 ; 1517d
 
 
-Function1517d: ; 1517d (5:517d)
+LoadBoxAddress: ; 1517d (5:517d)
 	push hl
 	ld l, e
 	ld h, d
+
 	push af
 	push hl
 	call GetSRAMBank
-	ld de, wc608
-	ld bc, $1e0
+	ld de, wMisc
+	ld bc, (wMiscEnd - wMisc)
 	call CopyBytes
 	call CloseSRAM
-	ld a, $1
+	ld a, BANK(sBox)
 	call GetSRAMBank
-	ld hl, wc608
-	ld de, $ad10
-	ld bc, $1e0
+	ld hl, wMisc
+	ld de, sBox
+	ld bc, (wMiscEnd - wMisc)
 	call CopyBytes
 	call CloseSRAM
 	pop hl
 	pop af
-	ld de, $1e0
+
+	ld de, (wMiscEnd - wMisc)
 	add hl, de
+
 	push af
 	push hl
 	call GetSRAMBank
-	ld de, wc608
-	ld bc, $1e0
+	ld de, wMisc
+	ld bc, (wMiscEnd - wMisc)
 	call CopyBytes
 	call CloseSRAM
-	ld a, $1
+	ld a, BANK(sBox)
 	call GetSRAMBank
-	ld hl, wc608
-	ld de, $aef0
-	ld bc, $1e0
+	ld hl, wMisc
+	ld de, sBox + (wMiscEnd - wMisc)
+	ld bc, (wMiscEnd - wMisc)
 	call CopyBytes
 	call CloseSRAM
 	pop hl
 	pop af
-	ld de, $1e0
+
+	ld de, (wMiscEnd - wMisc)
 	add hl, de
 	call GetSRAMBank
-	ld de, wc608
-	ld bc, $8e
+	ld de, wMisc
+	ld bc, sBoxEnd - (sBox + (wMiscEnd - wMisc) * 2) ; $8e
 	call CopyBytes
 	call CloseSRAM
-	ld a, $1
+	ld a, BANK(sBox)
 	call GetSRAMBank
-	ld hl, wc608
-	ld de, $b0d0
-	ld bc, $8e
+	ld hl, wMisc
+	ld de, sBox + (wMiscEnd - wMisc) * 2
+	ld bc, sBoxEnd - (sBox + (wMiscEnd - wMisc) * 2) ; $8e
 	call CopyBytes
 	call CloseSRAM
+
 	pop hl
 	ret
 
 
-Function151fb: ; 151fb
-	ld hl, Unknown_1522d
-	ld c, $e
-.outerloop
+EraseBoxes: ; 151fb
+	ld hl, BoxAddresses
+	ld c, NUM_BOXES
+.next
 	push bc
 	ld a, [hli]
 	call GetSRAMBank
@@ -1064,8 +1086,8 @@
 	ld a, -1
 	ld [de], a
 	inc de
-	ld bc, $044c
-.loop
+	ld bc, sBoxEnd - (sBox + 2)
+.clear
 	xor a
 	ld [de], a
 	inc de
@@ -1072,7 +1094,7 @@
 	dec bc
 	ld a, b
 	or c
-	jr nz, .loop
+	jr nz, .clear
 	ld a, [hli]
 	ld e, a
 	ld a, [hli]
@@ -1085,31 +1107,30 @@
 	call CloseSRAM
 	pop bc
 	dec c
-	jr nz, .outerloop
+	jr nz, .next
 	ret
 ; 1522d
 
-Unknown_1522d: ; 1522d
+BoxAddresses: ; 1522d
 ; dbww bank, address, address
-	dbww $02, $a000, $a44e ; 2, $a000, $a44e
-	dbww $02, $a450, $a89e ; 2, $a450, $a89e
-	dbww $02, $a8a0, $acee ; 2, $a8a0, $acee
-	dbww $02, $acf0, $b13e ; 2, $acf0, $b13e
-	dbww $02, $b140, $b58e ; 2, $b140, $b5de
-	dbww $02, $b590, $b9de ; 2, $b590, $b9de
-	dbww $02, $b9e0, $be2e ; 2, $b9e0, $be2e
-
-	dbww $03, $a000, $a44e ; 3, $a000, $a44e
-	dbww $03, $a450, $a89e ; 3, $a450, $a89e
-	dbww $03, $a8a0, $acee ; 3, $a8a0, $acee
-	dbww $03, $acf0, $b13e ; 3, $acf0, $b13e
-	dbww $03, $b140, $b58e ; 3, $b140, $b58e
-	dbww $03, $b590, $b9de ; 3, $b590, $b9de
-	dbww $03, $b9e0, $be2e ; 3, $b9e0, $be2e
+	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
 ; 15273
 
 
-Function15273: ; 15273
+Checksum: ; 15273
 	ld de, 0
 .loop
 	ld a, [hli]
--- a/main.asm
+++ b/main.asm
@@ -209,7 +209,7 @@
 
 	call SetDefaultBoxNames
 
-	ld a, 1
+	ld a, BANK(sBoxCount)
 	call GetSRAMBank
 	ld hl, sBoxCount
 	call InitList
@@ -239,9 +239,9 @@
 	ld [wRoamMon2MapNumber], a
 	ld [wRoamMon3MapNumber], a
 
-	ld a, 0
+	ld a, BANK(s0_abe2)
 	call GetSRAMBank
-	ld hl, $abe2
+	ld hl, s0_abe2
 	xor a
 	ld [hli], a
 	dec a
@@ -28832,7 +28832,7 @@
 	ld [wc2d7], a
 	pop af
 	ld [Options], a
-	callba Function1500c
+	callba LoadPokemonData
 	jp Function28b22
 
 .asm_283a9
@@ -34330,12 +34330,12 @@
 	call Function2c6ac
 	ld [de], a
 	inc de
-	ld a, $0
+	ld a, BANK(s0_abe4)
 	call GetSRAMBank
-	ld a, [$abe4]
+	ld a, [s0_abe4]
 	ld [de], a
 	inc de
-	ld a, [$abe5]
+	ld a, [s0_abe4 + 1]
 	ld [de], a
 	ld a, $14
 	ld [wca00], a
@@ -35637,9 +35637,9 @@
 	jp Function3991b
 
 .cal2
-	ld a, $0
+	ld a, BANK(sMysteryGiftTrainer)
 	call GetSRAMBank
-	ld de, $ac0a
+	ld de, sMysteryGiftTrainer
 	call TrainerType2
 	call CloseSRAM
 	jr .done
@@ -37488,48 +37488,49 @@
 	jp CloseSRAM
 ; 44725
 
+
 Function44725: ; 44725
-	ld a, $0
+	ld a, BANK(s0_a600)
 	call GetSRAMBank
-	ld hl, $a600
-	ld de, $a71a
-	ld bc, $011a
+	ld hl, s0_a600
+	ld de, s0_a71a
+	ld bc, $11a
 	call CopyBytes
-	ld hl, $a834
-	ld de, $aa0b
-	ld bc, $01d7
+	ld hl, s0_a834
+	ld de, s0_aa0b
+	ld bc, $1d7
 	call CopyBytes
 	jp CloseSRAM
 ; 44745
 
-
 Function44745: ; 44745 (11:4745)
-	ld a, $0
+	ld a, BANK(s0_a600)
 	call GetSRAMBank
-	ld hl, $a71a
-	ld de, $a600
+	ld hl, s0_a71a
+	ld de, s0_a600
 	ld bc, $11a
 	call CopyBytes
-	ld hl, $aa0b
-	ld de, $a834
+	ld hl, s0_aa0b
+	ld de, s0_a834
 	ld bc, $1d7
 	call CopyBytes
 	jp CloseSRAM
 
 Function44765: ; 44765 (11:4765)
-	ld a, $0
+	ld a, BANK(s0_a600)
 	call GetSRAMBank
 	xor a
-	ld hl, $a600
+	ld hl, s0_a600
 	ld bc, $11a
 	call ByteFill
 	xor a
-	ld hl, $a834
+	ld hl, s0_a834
 	ld bc, $1d7
 	call ByteFill
 	jp CloseSRAM
 ; 44781 (11:4781)
 
+
 Function44781: ; 44781
 	ld a, [PartyCount]
 	and a
@@ -54451,15 +54452,17 @@
 	set 6, [hl] ; hall of fame
 
 	callba Function14da0
+
 	ld hl, wd95e
 	ld a, [hl]
 	cp 200
-	jr nc, .ok ; 0x86433 $1
+	jr nc, .ok
 	inc [hl]
 .ok
-	callba Function14b85
-	call Function8653f
-	callba Function14b5f
+	callba SaveGameData
+	call GetHallOfFameParty
+	callba AddHallOfFameEntry
+
 	xor a
 	ld [wc2cd], a
 	call Function864c3
@@ -54565,7 +54568,7 @@
 	decoord 6, 5
 	ld c, $6
 	predef Functiond066e
-	ld c, $3c
+	ld c, 60
 	call DelayFrames
 	and a
 	ret
@@ -54576,9 +54579,9 @@
 ; 8653f
 
 
-Function8653f: ; 8653f
+GetHallOfFameParty: ; 8653f
 	ld hl, OverworldMap
-	ld bc, $0062
+	ld bc, HOF_LENGTH
 	xor a
 	call ByteFill
 	ld a, [wd95e]
@@ -54587,31 +54590,34 @@
 	inc de
 	ld hl, PartySpecies
 	ld c, 0
-.asm_86556
+.next
 	ld a, [hli]
 	cp $ff
-	jr z, .asm_865b1
+	jr z, .done
 	cp EGG
-	jr nz, .asm_86562
+	jr nz, .mon
 	inc c
-	jr .asm_86556
+	jr .next
 
-.asm_86562
+.mon
 	push hl
 	push de
 	push bc
+
 	ld a, c
-	ld hl, PartyMon1Species
+	ld hl, PartyMons
 	ld bc, PartyMon2 - PartyMon1
 	call AddNTimes
 	ld c, l
 	ld b, h
-	ld hl, $0000
+
+	ld hl, PartyMon1Species - PartyMon1
 	add hl, bc
 	ld a, [hl]
 	ld [de], a
 	inc de
-	ld hl, $0006
+
+	ld hl, PartyMon1ID - PartyMon1
 	add hl, bc
 	ld a, [hli]
 	ld [de], a
@@ -54619,7 +54625,8 @@
 	ld a, [hl]
 	ld [de], a
 	inc de
-	ld hl, $0015
+
+	ld hl, PartyMon1DVs - PartyMon1
 	add hl, bc
 	ld a, [hli]
 	ld [de], a
@@ -54627,30 +54634,33 @@
 	ld a, [hl]
 	ld [de], a
 	inc de
-	ld hl, $001f
+
+	ld hl, PartyMon1Level - PartyMon1
 	add hl, bc
 	ld a, [hl]
 	ld [de], a
 	inc de
+
 	pop bc
 	push bc
 	ld a, c
 	ld hl, PartyMonNicknames
-	ld bc, $000b
+	ld bc, PKMN_NAME_LENGTH
 	call AddNTimes
-	ld bc, $000a
+	ld bc, PKMN_NAME_LENGTH - 1
 	call CopyBytes
+
 	pop bc
 	inc c
 	pop de
-	ld hl, $0010
+	ld hl, HOF_MON_LENGTH
 	add hl, de
 	ld e, l
 	ld d, h
 	pop hl
-	jr .asm_86556
+	jr .next
 
-.asm_865b1
+.done
 	ld a, $ff
 	ld [de], a
 	ret
@@ -82434,7 +82444,7 @@
 	call Functione3316
 	ld a, $1
 	ld [wc2cd], a
-	callba Function14b85
+	callba SaveGameData
 	xor a
 	ld [wc2cd], a
 	call Functione32fa
@@ -89618,7 +89628,7 @@
 
 Function104a25: ; 104a25 (41:4a25)
 	call Function105106
-	ld a, [$abe5]
+	ld a, [s0_abe5]
 	cp $5
 	jp CloseSRAM
 
@@ -89628,9 +89638,9 @@
 	ld b, a
 	ld a, [wc902]
 	ld c, a
-	ld a, [$abe5]
+	ld a, [s0_abe5]
 	ld d, a
-	ld hl, $abe6
+	ld hl, s0_abe6
 .asm_104a42
 	ld a, d
 	and a
@@ -89652,10 +89662,10 @@
 
 Function104a56: ; 104a56 (41:4a56)
 	call Function105106
-	ld hl, $abe5
+	ld hl, s0_abe5
 	ld a, [hl]
 	inc [hl]
-	ld hl, $abe6
+	ld hl, s0_abe6
 	ld e, a
 	ld d, $0
 rept 2
@@ -89670,9 +89680,9 @@
 Function104a71: ; 104a71 (41:4a71)
 	call Function105106
 	ld a, $1
-	ld [$abfd], a
+	ld [s0_abfd], a
 	ld hl, wc903
-	ld de, $abfe
+	ld de, s0_abfe
 	ld bc, $b
 	call CopyBytes
 	ld a, $1
@@ -90538,7 +90548,7 @@
 	call Function105106
 	ld d, $0
 	ld b, $2
-	ld hl, $abf0
+	ld hl, s0_abf0
 	predef_id FlagPredef
 	push hl
 	push bc
@@ -90563,7 +90573,7 @@
 	push bc
 	ld d, $0
 	ld b, $2
-	ld hl, $abf0
+	ld hl, s0_abf0
 	predef FlagPredef
 	ld a, c
 	and a
@@ -90575,19 +90585,18 @@
 .asm_1050b0
 	inc c
 	ld a, c
-	cp $2b
+	cp $2a + 1
 	jr c, .asm_105096
 	jp CloseSRAM
 
 Special_UnlockMysteryGift: ; 1050b9
 	call Function105106
-	ld hl, $abe3
+	ld hl, s0_abe3
 	ld a, [hl]
 	inc a
 	jr nz, .ok
 	ld [hld], a
 	ld [hl], a
-
 .ok
 	jp CloseSRAM
 ; 1050c8
@@ -90594,12 +90603,11 @@
 
 Function1050c8: ; 1050c8
 	call Function105106
-	ld a, [$abe5]
+	ld a, [s0_abe5]
 	cp $ff
 	jr z, .asm_1050d6
 	xor a
-	ld [$abe5], a
-
+	ld [s0_abe5], a
 .asm_1050d6
 	jp CloseSRAM
 ; 1050d9
@@ -90607,8 +90615,8 @@
 
 Function1050d9: ; 1050d9
 	call Function105106
-	ld hl, $abe2
-	ld de, $abe4
+	ld hl, s0_abe2
+	ld de, s0_abe4
 	ld a, [hli]
 	ld [de], a
 	inc de
@@ -90620,8 +90628,8 @@
 
 Function1050ea: ; 1050ea (41:50ea)
 	call Function105106
-	ld hl, $abe4
-	ld de, $abe2
+	ld hl, s0_abe4
+	ld de, s0_abe2
 	ld a, [hli]
 	ld [de], a
 	inc de
@@ -90641,7 +90649,7 @@
 
 
 Function105106: ; 105106
-	ld a, $0
+	ld a, BANK(s0_abe4)
 	jp GetSRAMBank
 ; 10510b
 
--- a/misc/mobile_40.asm
+++ b/misc/mobile_40.asm
@@ -401,7 +401,7 @@
 	bit 0, [hl]
 	ret z
 	callba Function3f6d0
-	callba Function1500c
+	callba LoadPokemonData
 	ret
 ; 1002dc
 
@@ -4036,7 +4036,7 @@
 	xor a
 	ld [wc2d7], a
 	callba Function3f6d0
-	callba Function1500c
+	callba LoadPokemonData
 	call Function1013c0
 	ld a, [wcd25]
 	inc a
--- a/misc/mobile_45.asm
+++ b/misc/mobile_45.asm
@@ -16886,7 +16886,7 @@
 	call EnableLCD
 	callba Function104061
 	callba Function8cf53
-	callba Function1500c
+	callba LoadPokemonData
 	callba Function40c30
 	ld a, [rSVBK]
 	push af
@@ -22846,7 +22846,7 @@
 	call Function1702b7
 	call Function170bf7
 	predef StartBattle
-	callba Function1500c
+	callba LoadPokemonData
 	callba HealParty
 	ld a, [wd0ee]
 	ld [ScriptVar], a
@@ -23591,7 +23591,7 @@
 	ret
 
 Function170737: ; 170737 (5c:4737)
-	callba SaveOptionsSelection
+	callba SaveOptions
 	ret
 
 Function17073e: ; 17073e (5c:473e)
--- a/misc/mobile_5f.asm
+++ b/misc/mobile_5f.asm
@@ -3060,7 +3060,7 @@
 	push af
 	ld a, $1
 	ld [rSVBK], a
-	callba Function14c10
+	callba SaveGameData_
 	pop af
 	ld [rSVBK], a
 	ret
@@ -3086,7 +3086,7 @@
 	push af
 	ld a, $1
 	ld [rSVBK], a
-	callba Function14e0c
+	callba SaveBox
 	pop af
 	ld [rSVBK], a
 	ret
--- a/wram.asm
+++ b/wram.asm
@@ -69,7 +69,20 @@
 \1Type2::     db
 ENDM
 
+box: MACRO
+\1::
+\1Count::           ds 1
+\1Species::         ds MONS_PER_BOX + 1
+\1Mons::
+\1Mon1::            box_struct \1Mon1
+\1Mon2::            ds box_struct_length * (MONS_PER_BOX +- 1)
+\1MonOT::           ds NAME_LENGTH * MONS_PER_BOX
+\1MonNicknames::    ds PKMN_NAME_LENGTH * MONS_PER_BOX
+\1MonNicknamesEnd::
+\1End::             ds 2 ; padding
+ENDM
 
+
 channel_struct: MACRO
 ; Addreses are Channel1 (c101).
 \1MusicID::           dw
@@ -428,6 +441,7 @@
 
 SECTION "Battle", WRAM0
 
+wMisc::
 wBattle::
 
 wc608::
@@ -864,6 +878,9 @@
 wPokedexStatus::
 ENDC
 	ds 3
+
+wMiscEnd::
+
 wc7e8:: ds 24
 
 
@@ -1295,6 +1312,7 @@
 
 	ds 2
 OptionsEnd::
+
 wcfd4:: ds 1
 wcfd5:: ds 1
 wcfd6:: ds 1
@@ -1885,6 +1903,7 @@
 wd46c:: ds 1
 wd46d:: ds 5
 
+wCrystalData::
 PlayerGender:: ; d472
 ; bit 0:
 ;	0 male
@@ -1896,8 +1915,12 @@
 wd476:: ds 1
 wd477:: ds 1
 wd478:: ds 1
+wCrystalDataEnd::
+
 wd479:: ds 2
 
+wPlayerData::
+
 PlayerID:: ; d47b
 	ds 2
 
@@ -2124,7 +2147,7 @@
 	ds 13
 
 
-SECTION "Map Triggers", WRAMX, BANK [1]
+;SECTION "Map Triggers", WRAMX, BANK [1]
 
 wPokecenter2FTrigger::                       ds 1 ; d972
 wTradeCenterTrigger::                        ds 1 ; d973
@@ -2209,7 +2232,7 @@
 	ds 49
 
 
-SECTION "Events", WRAMX, BANK [1]
+;SECTION "Events", WRAMX, BANK [1]
 
 wJackFightCount::    ds 1
                      ds 1
@@ -2374,6 +2397,11 @@
 wdca1:: ds 3
 wdca4:: ds 1
 
+wPlayerDataEnd::
+
+
+wMapData::
+
 VisitedSpawns:: ; dca5
 	flag_array 27
 
@@ -2409,9 +2437,13 @@
 wdcbf:: ds 1
 	ds 23
 
+wMapDataEnd::
 
+
 SECTION "Party", WRAMX, BANK [1]
 
+wPokemonData::
+
 PartyCount:: ; dcd7
 	ds 1 ; number of Pokémon in party
 PartySpecies:: ; dcd8
@@ -2436,8 +2468,6 @@
 	ds 22
 
 
-SECTION "Pokedex", WRAMX, BANK [1]
-
 PokedexCaught:: ; de99
 	flag_array NUM_POKEMON
 EndPokedexCaught::
@@ -2454,8 +2484,6 @@
 wdef4:: ds 1
 
 
-SECTION "Daycare", WRAMX, BANK [1]
-
 wDaycareMan:: ; def5
 ; bit 7: active
 ; bit 6: monsters are compatible
@@ -2492,8 +2520,6 @@
 wdf9b:: ds 1
 
 
-SECTION "Misc Pokemon", WRAMX, BANK [1]
-
 wdf9c::
 wContestMon:: party_struct wContestMon ; df9c
 
@@ -2528,7 +2554,9 @@
 	ds 5
 wdff5::
 
+wPokemonDataEnd::
 
+
 SECTION "Pic Animations", WRAMX, BANK [2]
 
 w2_d000:: ds $168
@@ -2647,21 +2675,104 @@
 SECTION "Scratch", SRAM, BANK [0]
 
 
+SECTION "SRAM Bank 0", SRAM [$a600], BANK [0]
+
+s0_a600:: ds $11a
+s0_a71a:: ds $11a
+s0_a834:: ds $1d7
+s0_aa0b:: ds $1d7
+
+s0_abe2:: ds 1
+s0_abe3:: ds 1
+s0_abe4:: ds 1
+s0_abe5:: ds 1
+s0_abe6:: ds 10
+s0_abf0:: ds $d
+s0_abfd:: ds 1
+s0_abfe:: ds 12
+sMysteryGiftTrainer:: ds (1 + 1 + NUM_MOVES) * PARTY_LENGTH + 1
+	ds 1
+s0_abe4End::
+
+	ds $b200 - $ac30
+
+sBackupOptions:: ds OptionsEnd - Options
+
+s0_b208:: ds 1
+
+sBackupGameData::
+sBackupPlayerData::  ds wPlayerDataEnd - wPlayerData
+sBackupMapData::     ds wMapDataEnd - wMapData
+sBackupPokemonData:: ds wPokemonDataEnd - wPokemonData
+sBackupGameDataEnd::
+
+; bd83
+	ds $18a
+; bf0d
+
+sBackupChecksum:: ds 2
+s0_bf0f:: ds 1
+sStackTop:: ds 2
+
+
 SECTION "SRAM Bank 1", SRAM, BANK [1]
 
-SECTION "BoxMons", SRAM [$ad10], BANK [1]
+sOptions:: ds OptionsEnd - Options
 
-sBoxCount::   ds 1 ; ad10
-sBoxSpecies:: ds MONS_PER_BOX ; ad11
+s1_a008:: ds 1
+
+sGameData::
+sPlayerData::  ds wPlayerDataEnd - wPlayerData
+sMapData::     ds wMapDataEnd - wMapData
+sPokemonData:: ds wPokemonDataEnd - wPokemonData
+sGameDataEnd::
+
+; ab83
+	ds $18a
+; ad0d
+
+sChecksum::   ds 2
+s1_ad0f::     ds 1
+
+; ad10
+	box sBox
+; b160
+
+	ds $100
+
+sLinkBattleStats:: ; b260
+sLinkBattleWins::   ds 2
+sLinkBattleLosses:: ds 2
+sLinkBattleDraws::  ds 2
+	ds $5a
+sLinkBattleStatsEnd::
+
+sHallOfFame:: ; b2c0
+	ds HOF_LENGTH * NUM_HOF_TEAMS
+sHallOfFameEnd::
+
+; be3c
 	ds 1
+sCrystalData::
+	ds wCrystalDataEnd - wCrystalData
+	ds 1
+s1_be45:: ds 1
 
-sBoxMons:: ; ad26
-sBoxMon1:: box_struct sBoxMon1
-sBoxMon2::
-	ds box_struct_length * (MONS_PER_BOX +- 1)
 
-sBoxMonOT:: ds NAME_LENGTH * MONS_PER_BOX ; afa6
+SECTION "Boxes 1-7",  SRAM, BANK [2]
+	box sBox1
+	box sBox2
+	box sBox3
+	box sBox4
+	box sBox5
+	box sBox6
+	box sBox7
 
-sBoxMonNicknames:: ds PKMN_NAME_LENGTH * MONS_PER_BOX ; b082
-sBoxMonNicknamesEnd::
-; b15e
+SECTION "Boxes 8-14", SRAM, BANK [3]
+	box sBox8
+	box sBox9
+	box sBox10
+	box sBox11
+	box sBox12
+	box sBox13
+	box sBox14