shithub: pokered

Download patch

ref: 063900c7d707dd5bfc3ba2f1c45b1d2b5d83fb14
parent: f702fc7840e30f00c840ce619a1ea15d763438de
parent: b97d571e8e3de28f705b709d1446e0748678eb8c
author: dannye <corrnondacqb@yahoo.com>
date: Sat Jul 4 23:49:31 EDT 2015

Merge pull request https://github.com/iimarckus/pokered/pull/95 from luckytyphlosion/master
and related bug fixes

--- 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
 	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
-	ld bc, $194
+	ld bc, wPokedexOwned - wPartyCount
 	call CopyData
-	ld hl, $a5a3
+	ld hl, S_SAVEDMAINDATA
 	ld de, 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_SAVEDBOXES1CHECKSUM2 ; S_SAVEDBOXES2CHECKSUM2
 	ld b, $6
 .asm_7386b
 	push bc
@@ -327,12 +327,12 @@
 	ret
 
 PointerTable_73895: ; 73895 (1c:7895)
-	dw $A000
-	dw $A462
-	dw $A8C4
-	dw $AD26
-	dw $B188
-	dw $B5EA
+	dw S_SAVEDBOX1 ; S_SAVEDBOX7
+	dw S_SAVEDBOX2 ; S_SAVEDBOX8
+	dw S_SAVEDBOX3 ; S_SAVEDBOX9
+	dw S_SAVEDBOX4 ; S_SAVEDBOX10
+	dw S_SAVEDBOX5 ; S_SAVEDBOX11
+	dw S_SAVEDBOX6 ; S_SAVEDBOX12
 
 ChangeBox:: ; 738a1 (1c:78a1)
 	ld hl, WhenYouChangeBoxText
@@ -402,7 +402,7 @@
 	ld hl, $a000
 	ld bc, $1a4c
 	call SAVCheckSum
-	ld [$ba4c], a
+	ld [S_SAVEDBOXES1CHECKSUM], a ; S_SAVEDBOXES2CHECKSUM
 	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 ; S_SAVEDBOX7
 	call Func_73a7f
-	ld hl, $a462
+	ld hl, S_SAVEDBOX2 ; S_SAVEDBOX8
 	call Func_73a7f
-	ld hl, $a8c4
+	ld hl, S_SAVEDBOX3 ; S_SAVEDBOX9
 	call Func_73a7f
-	ld hl, $ad26
+	ld hl, S_SAVEDBOX4 ; S_SAVEDBOX10
 	call Func_73a7f
-	ld hl, $b188
+	ld hl, S_SAVEDBOX5 ; S_SAVEDBOX11
 	call Func_73a7f
-	ld hl, $b5ea
+	ld hl, S_SAVEDBOX6 ; S_SAVEDBOX12
 	call Func_73a7f
-	ld hl, $a000
-	ld bc, $1a4c
+	ld hl, S_SAVEDBOX1 ; S_SAVEDBOX7
+	ld bc, $6 * (S_SAVEDBOX2 - S_SAVEDBOX1) ; $1a4c
 	call SAVCheckSum
-	ld [$ba4c], a
+	ld [S_SAVEDBOXES1CHECKSUM], a ; S_SAVEDBOXES2CHECKSUM
 	call Func_73863
 	ret
 
@@ -571,17 +571,17 @@
 	ret
 
 Func_73ab8: ; 73ab8 (1c:7ab8)
-	ld a, [$a000]
+	ld a, [S_SAVEDBOX1] ; S_SAVEDBOX7
 	ld [hli], a
-	ld a, [$a462]
+	ld a, [S_SAVEDBOX2] ; S_SAVEDBOX8
 	ld [hli], a
-	ld a, [$a8c4]
+	ld a, [S_SAVEDBOX3] ; S_SAVEDBOX9
 	ld [hli], a
-	ld a, [$ad26]
+	ld a, [S_SAVEDBOX4] ; S_SAVEDBOX10
 	ld [hli], a
-	ld a, [$b188]
+	ld a, [S_SAVEDBOX5] ; S_SAVEDBOX11
 	ld [hli], a
-	ld a, [$b5ea]
+	ld a, [S_SAVEDBOX6] ; S_SAVEDBOX12
 	ld [hli], a
 	ret
 
@@ -588,23 +588,23 @@
 SAVCheckRandomID: ; 73ad1 (1c:7ad1)
 ;checks if Sav file is the same by checking player's name 1st letter ($a598)
 ; and the two random numbers generated at game beginning
-;(which are stored at wPlayerID)
+;(which are stored at wPlayerID)s
 	ld a,$0a
 	ld [$0000],a
 	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_SAVEDMAINDATA + 98 ; player ID
 	ld a,[hli]
 	ld h,[hl]
 	ld l,a
--- /dev/null
+++ b/sram.asm
@@ -1,0 +1,45 @@
+SECTION "Sprite Buffers", SRAM, BANK[0]
+
+S_SPRITEBUFFER0:: ds SPRITEBUFFERSIZE ; a000
+S_SPRITEBUFFER1:: ds SPRITEBUFFERSIZE ; a188
+S_SPRITEBUFFER2:: ds SPRITEBUFFERSIZE ; a310
+
+	ds $100
+
+sHallOfFame:: ds HOF_TEAM * NUM_HOF_TEAMS ; a598
+
+
+SECTION "Save Data", SRAM, BANK[1]
+	ds $598
+
+S_SAVEDPLAYERNAME:: ds 11 ; a598
+S_SAVEDMAINDATA:: ds W_NUMINBOX - wPokedexOwned ; a5a3
+S_SAVEDSPRITEDATA:: ds $200 ; wOAMBuffer - wSpriteStateData1 ; ad2c
+S_SAVEDPARTYDATA:: ds wPokedexOwned - wPartyCount ; af2c
+S_SAVEDCURBOXDATA:: ds wBoxMonNicksEnd - W_NUMINBOX ; b0c0
+S_SAVEDhTilesetType:: ds 1 ; b522
+S_SAVEDMAINDATACHECKSUM:: ds 1 ; b523
+
+
+SECTION "Saved Boxes 1", SRAM, BANK[2]
+
+S_SAVEDBOX1:: ds wBoxMonNicksEnd - W_NUMINBOX ; a000
+S_SAVEDBOX2:: ds wBoxMonNicksEnd - W_NUMINBOX ; a462
+S_SAVEDBOX3:: ds wBoxMonNicksEnd - W_NUMINBOX ; a8c4
+S_SAVEDBOX4:: ds wBoxMonNicksEnd - W_NUMINBOX ; ad26
+S_SAVEDBOX5:: ds wBoxMonNicksEnd - W_NUMINBOX ; b188
+S_SAVEDBOX6:: ds wBoxMonNicksEnd - W_NUMINBOX ; b5ea
+S_SAVEDBOXES1CHECKSUM:: ds 1 ; ba4c
+S_SAVEDBOXES1CHECKSUM2:: ds 6 ; ba4d
+
+
+SECTION "Saved Boxes 2", SRAM, BANK[3]
+
+S_SAVEDBOX7::  ds wBoxMonNicksEnd - W_NUMINBOX ; a000
+S_SAVEDBOX8::  ds wBoxMonNicksEnd - W_NUMINBOX ; a462
+S_SAVEDBOX9::  ds wBoxMonNicksEnd - W_NUMINBOX ; a8c4
+S_SAVEDBOX10:: ds wBoxMonNicksEnd - W_NUMINBOX ; ad26
+S_SAVEDBOX11:: ds wBoxMonNicksEnd - W_NUMINBOX ; b188
+S_SAVEDBOX12:: ds wBoxMonNicksEnd - W_NUMINBOX ; b5ea
+S_SAVEDBOXES2CHECKSUM:: ds 1 ; ba4c
+S_SAVEDBOXES2CHECKSUM2:: ds 6 ; ba4d
--- a/wram.asm
+++ b/wram.asm
@@ -2296,12 +2296,4 @@
 	ds -$100
 
 
-SECTION "Sprite Buffers", SRAM, BANK[0]
-
-S_SPRITEBUFFER0:: ds SPRITEBUFFERSIZE ; a000
-S_SPRITEBUFFER1:: ds SPRITEBUFFERSIZE ; a188
-S_SPRITEBUFFER2:: ds SPRITEBUFFERSIZE ; a310
-
-	ds $100
-
-sHallOfFame:: ds HOF_TEAM * NUM_HOF_TEAMS ; a598
+INCLUDE "sram.asm"