ref: 1df1e9181e2f3d95f57c98e0ea6e38ce4261fb2a
parent: dfc152d667e3695f83eb0fbabb839b0fad275ceb
author: dannye <corrnondacqb@yahoo.com>
date: Mon Aug 10 19:03:31 EDT 2015
Use better wram labels in sram this way, sram doesn't have to refer to the actual content of wram
--- a/engine/save.asm
+++ b/engine/save.asm
@@ -60,20 +60,20 @@
ld bc, 11
call CopyData
ld hl, sMainData
- ld de, wPokedexOwned
- ld bc, sSpriteData - sMainData
+ ld de, wMainDataStart
+ ld bc, wMainDataEnd - wMainDataStart
call CopyData
ld hl, W_CURMAPTILESET
set 7, [hl]
ld hl, sSpriteData
- ld de, wSpriteStateData1
- ld bc, sPartyData - sSpriteData
+ ld de, wSpriteDataStart
+ ld bc, wSpriteDataEnd - wSpriteDataStart
call CopyData
ld a, [sTilesetType]
ld [hTilesetType], a
ld hl, sCurBoxData
- ld de, W_NUMINBOX
- ld bc, wBoxMonNicksEnd - W_NUMINBOX
+ ld de, wBoxDataStart
+ ld bc, wBoxDataEnd - wBoxDataStart
call CopyData
and a
jp SAVGoodChecksum
@@ -92,8 +92,8 @@
cp c
jr nz, SAVBadCheckSum
ld hl, sCurBoxData
- ld de, W_NUMINBOX
- ld bc, wBoxMonNicksEnd - W_NUMINBOX
+ ld de, wBoxDataStart
+ ld bc, wBoxDataEnd - wBoxDataStart
call CopyData
and a
jp SAVGoodChecksum
@@ -112,8 +112,8 @@
cp c
jp nz, SAVBadCheckSum
ld hl, sPartyData
- ld de, wPartyCount
- ld bc, wPokedexOwned - wPartyCount
+ ld de, wPartyDataStart
+ ld bc, wPartyDataEnd - wPartyDataStart
call CopyData
ld hl, sMainData
ld de, wPokedexOwned
@@ -205,17 +205,17 @@
ld de, sPlayerName
ld bc, 11
call CopyData
- ld hl, wPokedexOwned
+ ld hl, wMainDataStart
ld de, sMainData
- ld bc, W_NUMINBOX - wPokedexOwned
+ ld bc, wMainDataEnd - wMainDataStart
call CopyData
- ld hl, wSpriteStateData1
+ ld hl, wSpriteDataStart
ld de, sSpriteData
- ld bc, sPartyData - sSpriteData
+ ld bc, wSpriteDataEnd - wSpriteDataStart
call CopyData
- ld hl, W_NUMINBOX
+ ld hl, wBoxDataStart
ld de, sCurBoxData
- ld bc, wBoxMonNicksEnd - W_NUMINBOX
+ ld bc, wBoxDataEnd - wBoxDataStart
call CopyData
ld a, [hTilesetType]
ld [sTilesetType], a
@@ -235,9 +235,9 @@
ld a, $1
ld [MBC1SRamBankingMode], a
ld [MBC1SRamBank], a
- ld hl, W_NUMINBOX
+ ld hl, wBoxDataStart
ld de, sCurBoxData
- ld bc, wBoxMonNicksEnd - W_NUMINBOX
+ ld bc, wBoxDataEnd - wBoxDataStart
call CopyData
ld hl, sPlayerName
ld bc, sMainDataCheckSum - sPlayerName
@@ -254,9 +254,9 @@
ld a, $1
ld [MBC1SRamBankingMode], a
ld [MBC1SRamBank], a
- ld hl, wPartyCount
+ ld hl, wPartyDataStart
ld de, sPartyData
- ld bc, wPokedexOwned - wPartyCount
+ ld bc, wPartyDataEnd - wPartyDataStart
call CopyData
ld hl, wPokedexOwned ; pokédex only
ld de, sMainData
@@ -300,7 +300,7 @@
.loop
push bc
push de
- ld bc, wBoxMonNicksEnd - W_NUMINBOX
+ ld bc, wBoxDataEnd - wBoxDataStart
call SAVCheckSum
pop de
ld [de], a
@@ -361,13 +361,13 @@
call GetBoxSRAMLocation
ld e, l
ld d, h
- ld hl, W_NUMINBOX
+ ld hl, wBoxDataStart
call CopyBoxToOrFromSRAM ; copy old box from WRAM to SRAM
ld a, [wCurrentMenuItem]
set 7, a
ld [wCurrentBoxNum], a
call GetBoxSRAMLocation
- ld de, W_NUMINBOX
+ ld de, wBoxDataStart
call CopyBoxToOrFromSRAM ; copy new box from SRAM to WRAM
ld hl, W_MAPTEXTPTR
ld de, wChangeBoxSavedMapTextPointer
@@ -398,7 +398,7 @@
ld [MBC1SRamBankingMode], a
ld a, b
ld [MBC1SRamBank], a
- ld bc, wBoxMonNicksEnd - W_NUMINBOX
+ ld bc, wBoxDataEnd - wBoxDataStart
call CopyData
pop hl
--- a/sram.asm
+++ b/sram.asm
@@ -13,10 +13,10 @@
ds $598
sPlayerName:: ds 11 ; a598
-sMainData:: ds W_NUMINBOX - wPokedexOwned ; a5a3
-sSpriteData:: ds $200 ; wOAMBuffer - wSpriteStateData1 ; ad2c
-sPartyData:: ds wPokedexOwned - wPartyCount ; af2c
-sCurBoxData:: ds wBoxMonNicksEnd - W_NUMINBOX ; b0c0
+sMainData:: ds wMainDataEnd - wMainDataStart ; a5a3
+sSpriteData:: ds wSpriteDataEnd - wSpriteDataStart ; ad2c
+sPartyData:: ds wPartyDataEnd - wPartyDataStart ; af2c
+sCurBoxData:: ds wBoxDataEnd - wBoxDataStart ; b0c0
sTilesetType:: ds 1 ; b522
sMainDataCheckSum:: ds 1 ; b523
@@ -23,12 +23,12 @@
SECTION "Saved Boxes 1", SRAM, BANK[2]
-sBox1:: ds wBoxMonNicksEnd - W_NUMINBOX ; a000
-sBox2:: ds wBoxMonNicksEnd - W_NUMINBOX ; a462
-sBox3:: ds wBoxMonNicksEnd - W_NUMINBOX ; a8c4
-sBox4:: ds wBoxMonNicksEnd - W_NUMINBOX ; ad26
-sBox5:: ds wBoxMonNicksEnd - W_NUMINBOX ; b188
-sBox6:: ds wBoxMonNicksEnd - W_NUMINBOX ; b5ea
+sBox1:: ds wBoxDataEnd - wBoxDataStart ; a000
+sBox2:: ds wBoxDataEnd - wBoxDataStart ; a462
+sBox3:: ds wBoxDataEnd - wBoxDataStart ; a8c4
+sBox4:: ds wBoxDataEnd - wBoxDataStart ; ad26
+sBox5:: ds wBoxDataEnd - wBoxDataStart ; b188
+sBox6:: ds wBoxDataEnd - wBoxDataStart ; b5ea
sBank2AllBoxesChecksum:: ds 1 ; ba4c
sBank2IndividualBoxChecksums:: ds 6 ; ba4d
@@ -35,11 +35,11 @@
SECTION "Saved Boxes 2", SRAM, BANK[3]
-sBox7:: ds wBoxMonNicksEnd - W_NUMINBOX ; a000
-sBox8:: ds wBoxMonNicksEnd - W_NUMINBOX ; a462
-sBox9:: ds wBoxMonNicksEnd - W_NUMINBOX ; a8c4
-sBox10:: ds wBoxMonNicksEnd - W_NUMINBOX ; ad26
-sBox11:: ds wBoxMonNicksEnd - W_NUMINBOX ; b188
-sBox12:: ds wBoxMonNicksEnd - W_NUMINBOX ; b5ea
+sBox7:: ds wBoxDataEnd - wBoxDataStart ; a000
+sBox8:: ds wBoxDataEnd - wBoxDataStart ; a462
+sBox9:: ds wBoxDataEnd - wBoxDataStart ; a8c4
+sBox10:: ds wBoxDataEnd - wBoxDataStart ; ad26
+sBox11:: ds wBoxDataEnd - wBoxDataStart ; b188
+sBox12:: ds wBoxDataEnd - wBoxDataStart ; b5ea
sBank3AllBoxesChecksum:: ds 1 ; ba4c
sBank3IndividualBoxChecksums:: ds 6 ; ba4d
--- a/wram.asm
+++ b/wram.asm
@@ -205,6 +205,8 @@
SECTION "Sprite State Data", WRAM0[$c100]
+wSpriteDataStart::
+
wSpriteStateData1:: ; c100
; data for all sprites on the current map
; holds info for 16 sprites with $10 bytes each
@@ -228,7 +230,7 @@
ds $10 * $10
-SECTION "Sprite State Data 2", WRAM0[$c200]
+;SECTION "Sprite State Data 2", WRAM0[$c200]
wSpriteStateData2:: ; c200
; more data for all sprites on the current map
@@ -252,7 +254,9 @@
; C2xF
ds $10 * $10
+wSpriteDataEnd::
+
SECTION "OAM Buffer", WRAM0[$c300]
wOAMBuffer:: ; c300
@@ -2162,6 +2166,9 @@
wPlayerName:: ; d158
ds 11
+
+wPartyDataStart::
+
wPartyCount:: ds 1 ; d163
wPartySpecies:: ds PARTY_LENGTH ; d164
wPartyEnd:: ds 1 ; d16a
@@ -2177,7 +2184,11 @@
wPartyMonOT:: ds 11 * PARTY_LENGTH ; d273
wPartyMonNicks:: ds 11 * PARTY_LENGTH ; d2b5
+wPartyDataEnd::
+
+wMainDataStart::
+
wPokedexOwned:: ; d2f7
flag_array NUM_POKEMON
wPokedexOwnedEnd::
@@ -3000,7 +3011,11 @@
wDayCareMon:: box_struct wDayCareMon ; da5f
+wMainDataEnd::
+
+wBoxDataStart::
+
W_NUMINBOX:: ds 1 ; da80
wBoxSpecies:: ds MONS_PER_BOX + 1
@@ -3011,6 +3026,8 @@
wBoxMonOT:: ds 11 * MONS_PER_BOX ; dd2a
wBoxMonNicks:: ds 11 * MONS_PER_BOX ; de06
wBoxMonNicksEnd:: ; dee2
+
+wBoxDataEnd::
SECTION "Stack", WRAMX[$dfff], BANK[1]