shithub: pokered

Download patch

ref: 55b5d3e3af5b56f18481a5cd933c662116327af4
parent: b6c7544e85a8ede00ab5f059e95d7125d1c86951
author: luckytyphlosion <alan.rj.huang@gmail.com>
date: Sun Apr 26 09:15:12 EDT 2015

Replaced all direct addresses with labels.

--- a/engine/save.asm
+++ b/engine/save.asm
@@ -37,39 +37,39 @@
 	ld a, $1
 	ld [MBC1SRamBankingMode], a
 	ld [MBC1SRamBank], a
-	ld hl, $a598 ; hero name located in SRAM
+	ld hl, S_SAVEDPLAYERNAME ; hero name located in SRAM
 	ld bc, $f8b ; but here checks the full SAV
 	call SAVCheckSum
 	ld c, a
-	ld a, [$b523] ; SAV's checksum
+	ld a, [S_SAVEDMAINDATACHECKSUM] ; SAV's checksum
 	cp c
 	jp z, .Func_73652
-	ld hl, $a598
+	ld hl, S_SAVEDPLAYERNAME
 	ld bc, $f8b
 	call SAVCheckSum
 	ld c, a
-	ld a, [$b523] ; SAV's checksum
+	ld a, [S_SAVEDMAINDATACHECKSUM] ; SAV's checksum
 	cp c
 	jp nz, SAVBadCheckSum
 
 .Func_73652 ; 73652 (1c:7652)
-	ld hl, $a598
+	ld hl, S_SAVEDPLAYERNAME
 	ld de, wPlayerName ; wd158
 	ld bc, $b
 	call CopyData
-	ld hl, $a5a3
+	ld hl, S_SAVEDMAINDATA
 	ld de, wPokedexOwned
 	ld bc, $789
 	call CopyData
 	ld hl, W_CURMAPTILESET
 	set 7, [hl]
-	ld hl, $ad2c
+	ld hl, S_SAVEDSPRITEDATA
 	ld de, wSpriteStateData1
 	ld bc, $200
 	call CopyData
-	ld a, [$b522]
+	ld a, [S_SAVEDhTilesetType]
 	ld [hTilesetType], a
-	ld hl, $b0c0
+	ld hl, S_SAVEDCURBOXDATA
 	ld de, W_NUMINBOX
 	ld bc, wBoxMonNicksEnd - W_NUMINBOX
 	call CopyData
@@ -82,14 +82,14 @@
 	ld a, $1
 	ld [MBC1SRamBankingMode], a
 	ld [MBC1SRamBank], a
-	ld hl, $a598 ; hero name located in SRAM
+	ld hl, S_SAVEDPLAYERNAME ; hero name located in SRAM
 	ld bc, $f8b  ; but here checks the full SAV
 	call SAVCheckSum
 	ld c, a
-	ld a, [$b523] ; SAV's checksum
+	ld a, [S_SAVEDMAINDATACHECKSUM] ; SAV's checksum
 	cp c
 	jr nz, SAVBadCheckSum
-	ld hl, $b0c0
+	ld hl, S_SAVEDCURBOXDATA
 	ld de, W_NUMINBOX
 	ld bc, wBoxMonNicksEnd - W_NUMINBOX
 	call CopyData
@@ -102,18 +102,18 @@
 	ld a, $1
 	ld [MBC1SRamBankingMode], a
 	ld [MBC1SRamBank], a
-	ld hl, $a598 ; hero name located in SRAM
+	ld hl, S_SAVEDPLAYERNAME ; hero name located in SRAM
 	ld bc, $f8b  ; but here checks the full SAV
 	call SAVCheckSum
 	ld c, a
-	ld a, [$b523] ; SAV's checksum
+	ld a, [S_SAVEDMAINDATACHECKSUM] ; SAV's checksum
 	cp c
 	jp nz, SAVBadCheckSum
-	ld hl, $af2c
+	ld hl, S_SAVEDPARTYDATA
 	ld de, wPartyCount ; wPartyCount
-	ld bc, $194
+	ld bc, wPokedexOwned - wPartyCount
 	call CopyData
-	ld hl, $a5a3
+	ld hl, S_SAVEDMAINDATA
 	ld de, wPokedexOwned ; wPokedexOwned
 	ld bc, wPokedexSeenEnd - wPokedexOwned
 	call CopyData
@@ -199,27 +199,27 @@
 	ld [MBC1SRamBankingMode], a
 	ld [MBC1SRamBank], a
 	ld hl, wPlayerName
-	ld de, $a598
+	ld de, S_SAVEDPLAYERNAME
 	ld bc, $b
 	call CopyData
 	ld hl, wPokedexOwned
-	ld de, $a5a3
+	ld de, S_SAVEDMAINDATA
 	ld bc, W_NUMINBOX - wPokedexOwned
 	call CopyData
 	ld hl, wSpriteStateData1
-	ld de, $ad2c
+	ld de, S_SAVEDSPRITEDATA
 	ld bc, $200
 	call CopyData
 	ld hl, W_NUMINBOX
-	ld de, $b0c0
+	ld de, S_SAVEDCURBOXDATA
 	ld bc, wBoxMonNicksEnd - W_NUMINBOX
 	call CopyData
 	ld a, [hTilesetType]
-	ld [$b522], a
-	ld hl, $a598
+	ld [S_SAVEDhTilesetType], a
+	ld hl, S_SAVEDPLAYERNAME
 	ld bc, $f8b
 	call SAVCheckSum
-	ld [$b523], a
+	ld [S_SAVEDMAINDATACHECKSUM], a
 	xor a
 	ld [MBC1SRamBankingMode], a
 	ld [MBC1SRamEnable], a
@@ -233,13 +233,13 @@
 	ld [MBC1SRamBankingMode], a
 	ld [MBC1SRamBank], a
 	ld hl, W_NUMINBOX
-	ld de, $b0c0
+	ld de, S_SAVEDCURBOXDATA
 	ld bc, wBoxMonNicksEnd - W_NUMINBOX
 	call CopyData
-	ld hl, $a598
+	ld hl, S_SAVEDPLAYERNAME
 	ld bc, $f8b
 	call SAVCheckSum
-	ld [$b523], a
+	ld [S_SAVEDMAINDATACHECKSUM], a
 	xor a
 	ld [MBC1SRamBankingMode], a
 	ld [MBC1SRamEnable], a
@@ -252,17 +252,17 @@
 	ld [MBC1SRamBankingMode], a
 	ld [MBC1SRamBank], a
 	ld hl, wPartyCount
-	ld de, $af2c
+	ld de, S_SAVEDPARTYDATA
 	ld bc, wPokedexOwned - wPartyCount
 	call CopyData
 	ld hl, wPokedexOwned ; pokédex only
-	ld de, $a5a3
+	ld de, S_SAVEDMAINDATA
 	ld bc, wPokedexSeenEnd - wPokedexOwned
 	call CopyData
-	ld hl, $a598
+	ld hl, S_SAVEDPLAYERNAME
 	ld bc, $f8b
 	call SAVCheckSum
-	ld [$b523], a
+	ld [S_SAVEDMAINDATACHECKSUM], a
 	xor a
 	ld [MBC1SRamBankingMode], a
 	ld [MBC1SRamEnable], a
@@ -292,7 +292,7 @@
 
 Func_73863: ; 73863 (1c:7863)
 	ld hl, $a000
-	ld de, $ba4d
+	ld de, S_SAVEDBOXESCHECKSUM2 ; $ba4d
 	ld b, $6
 .asm_7386b
 	push bc
@@ -402,7 +402,7 @@
 	ld hl, $a000
 	ld bc, $1a4c
 	call SAVCheckSum
-	ld [$ba4c], a
+	ld [S_SAVEDBOXESCHECKSUM], a
 	call Func_73863
 	xor a
 	ld [MBC1SRamBankingMode], a
@@ -518,22 +518,22 @@
 	ret
 
 Func_73a4b: ; 73a4b (1c:7a4b)
-	ld hl, $a000
+	ld hl, S_SAVEDBOX1
 	call Func_73a7f
-	ld hl, $a462
+	ld hl, S_SAVEDBOX2
 	call Func_73a7f
-	ld hl, $a8c4
+	ld hl, S_SAVEDBOX3
 	call Func_73a7f
-	ld hl, $ad26
+	ld hl, S_SAVEDBOX4
 	call Func_73a7f
-	ld hl, $b188
+	ld hl, S_SAVEDBOX5
 	call Func_73a7f
-	ld hl, $b5ea
+	ld hl, S_SAVEDBOX6
 	call Func_73a7f
-	ld hl, $a000
-	ld bc, $1a4c
+	ld hl, S_SAVEDBOX1
+	ld bc, $6 * (S_SAVEDBOX2 - S_SAVEDBOX1) ; $1a4c
 	call SAVCheckSum
-	ld [$ba4c], a
+	ld [S_SAVEDBOXESCHECKSUM], a
 	call Func_73863
 	ret
 
@@ -571,17 +571,17 @@
 	ret
 
 Func_73ab8: ; 73ab8 (1c:7ab8)
-	ld a, [$a000]
+	ld a, [S_SAVEDBOX1]
 	ld [hli], a
-	ld a, [$a462]
+	ld a, [S_SAVEDBOX2]
 	ld [hli], a
-	ld a, [$a8c4]
+	ld a, [S_SAVEDBOX3]
 	ld [hli], a
-	ld a, [$ad26]
+	ld a, [S_SAVEDBOX4]
 	ld [hli], a
-	ld a, [$b188]
+	ld a, [S_SAVEDBOX5]
 	ld [hli], a
-	ld a, [$b5ea]
+	ld a, [S_SAVEDBOX6]
 	ld [hli], a
 	ret
 
@@ -594,17 +594,17 @@
 	ld a,$01
 	ld [MBC1SRamBankingMode],a
 	ld [MBC1SRamBank],a
-	ld a,[$a598]
+	ld a,[S_SAVEDPLAYERNAME]
 	and a
 	jr z,.next
-	ld hl,$a598
+	ld hl,S_SAVEDPLAYERNAME
 	ld bc,$0f8b
 	call SAVCheckSum
 	ld c,a
-	ld a,[$b523]
+	ld a,[S_SAVEDMAINDATACHECKSUM]
 	cp c
 	jr nz,.next
-	ld hl,$a605
+	ld hl,S_SAVEDPLAYERID
 	ld a,[hli]
 	ld h,[hl]
 	ld l,a