summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRangi <remy.oukaour+rangi42@gmail.com>2021-04-27 15:49:59 -0400
committerRangi <remy.oukaour+rangi42@gmail.com>2021-04-27 15:49:59 -0400
commit6a31663c960a5c1da9dbbf12d49e0252860b96d0 (patch)
tree74c333d90fda4297a40748ddf0dd11771feb0832
parentbcc4380d40767983a0b253d486bb3c82f0f1fd07 (diff)
Use {interpolation} to generate sequences of RAM labels
Fixes #319
-rw-r--r--constants/gfx_constants.asm3
-rw-r--r--constants/map_object_constants.asm2
-rw-r--r--engine/battle/misc.asm2
-rw-r--r--engine/battle/read_trainer_party.asm2
-rw-r--r--engine/events/give_pokemon.asm2
-rw-r--r--engine/items/item_effects.asm16
-rw-r--r--engine/link/cable_club.asm8
-rw-r--r--engine/menus/save.asm2
-rw-r--r--engine/movie/oak_speech/init_player_data.asm2
-rw-r--r--engine/pokemon/add_mon.asm8
-rw-r--r--engine/pokemon/bills_pc.asm10
-rw-r--r--engine/pokemon/remove_mon.asm2
-rw-r--r--sram.asm31
-rw-r--r--vram.asm32
-rw-r--r--wram.asm132
15 files changed, 137 insertions, 117 deletions
diff --git a/constants/gfx_constants.asm b/constants/gfx_constants.asm
index 19f935f6..91463e7c 100644
--- a/constants/gfx_constants.asm
+++ b/constants/gfx_constants.asm
@@ -17,6 +17,9 @@ HP_BAR_GREEN EQU 0
HP_BAR_YELLOW EQU 1
HP_BAR_RED EQU 2
+; wOAMBuffer
+NUM_SPRITE_OAM_STRUCTS EQU 40
+
; hAutoBGTransferEnabled
TRANSFERTOP EQU 0
TRANSFERMIDDLE EQU 1
diff --git a/constants/map_object_constants.asm b/constants/map_object_constants.asm
index 9993a6a9..899e01f0 100644
--- a/constants/map_object_constants.asm
+++ b/constants/map_object_constants.asm
@@ -38,6 +38,8 @@ SPRITESTATEDATA1_LENGTH EQU const_value
const SPRITESTATEDATA2_0F ; f
SPRITESTATEDATA2_LENGTH EQU const_value
+NUM_SPRITESTATEDATA_STRUCTS EQU 16
+
; different kinds of people events
ITEM EQU $80
TRAINER EQU $40
diff --git a/engine/battle/misc.asm b/engine/battle/misc.asm
index 33af6f6f..524ec161 100644
--- a/engine/battle/misc.asm
+++ b/engine/battle/misc.asm
@@ -113,7 +113,7 @@ GetMonSpecies:
ld hl, wBoxSpecies
jr .getSpecies
.enemyParty
- ld hl, wEnemyPartyMons
+ ld hl, wEnemyPartySpecies
.getSpecies
ld d, 0
add hl, de
diff --git a/engine/battle/read_trainer_party.asm b/engine/battle/read_trainer_party.asm
index a0132a4f..a9e09a30 100644
--- a/engine/battle/read_trainer_party.asm
+++ b/engine/battle/read_trainer_party.asm
@@ -5,7 +5,7 @@ ReadTrainer:
and a
ret nz
-; set [wEnemyPartyCount] to 0, [wEnemyPartyMons] to FF
+; set [wEnemyPartyCount] to 0, [wEnemyPartySpecies] to FF
; XXX first is total enemy pokemon?
; XXX second is species of first pokemon?
ld hl, wEnemyPartyCount
diff --git a/engine/events/give_pokemon.asm b/engine/events/give_pokemon.asm
index ef01ef99..14dcea42 100644
--- a/engine/events/give_pokemon.asm
+++ b/engine/events/give_pokemon.asm
@@ -7,7 +7,7 @@ _GivePokemon::
ld a, [wPartyCount]
cp PARTY_LENGTH
jr c, .addToParty
- ld a, [wNumInBox]
+ ld a, [wBoxCount]
cp MONS_PER_BOX
jr nc, .boxFull
; add to box
diff --git a/engine/items/item_effects.asm b/engine/items/item_effects.asm
index 0448866e..38ea37c0 100644
--- a/engine/items/item_effects.asm
+++ b/engine/items/item_effects.asm
@@ -120,7 +120,7 @@ ItemUseBall:
ld a, [wPartyCount] ; is party full?
cp PARTY_LENGTH
jr nz, .canUseBall
- ld a, [wNumInBox] ; is box full?
+ ld a, [wBoxCount] ; is box full?
cp MONS_PER_BOX
jp z, BoxFullCannotThrowBall
@@ -2638,7 +2638,7 @@ IsKeyItem_::
INCLUDE "data/items/key_items.asm"
SendNewMonToBox:
- ld de, wNumInBox
+ ld de, wBoxCount
ld a, [de]
inc a
ld [de], a
@@ -2657,7 +2657,7 @@ SendNewMonToBox:
call GetMonHeader
ld hl, wBoxMonOT
ld bc, NAME_LENGTH
- ld a, [wNumInBox]
+ ld a, [wBoxCount]
dec a
jr z, .asm_e7ee
dec a
@@ -2668,7 +2668,7 @@ SendNewMonToBox:
ld d, h
ld e, l
pop hl
- ld a, [wNumInBox]
+ ld a, [wBoxCount]
dec a
ld b, a
.asm_e7db
@@ -2689,7 +2689,7 @@ SendNewMonToBox:
ld de, wBoxMonOT
ld bc, NAME_LENGTH
call CopyData
- ld a, [wNumInBox]
+ ld a, [wBoxCount]
dec a
jr z, .asm_e82a
ld hl, wBoxMonNicks
@@ -2702,7 +2702,7 @@ SendNewMonToBox:
ld d, h
ld e, l
pop hl
- ld a, [wNumInBox]
+ ld a, [wBoxCount]
dec a
ld b, a
.asm_e817
@@ -2723,7 +2723,7 @@ SendNewMonToBox:
ld a, NAME_MON_SCREEN
ld [wNamingScreenType], a
predef AskName
- ld a, [wNumInBox]
+ ld a, [wBoxCount]
dec a
jr z, .asm_e867
ld hl, wBoxMons
@@ -2736,7 +2736,7 @@ SendNewMonToBox:
ld d, h
ld e, l
pop hl
- ld a, [wNumInBox]
+ ld a, [wBoxCount]
dec a
ld b, a
.asm_e854
diff --git a/engine/link/cable_club.asm b/engine/link/cable_club.asm
index b6389fe3..f3bf3b5d 100644
--- a/engine/link/cable_club.asm
+++ b/engine/link/cable_club.asm
@@ -648,7 +648,7 @@ TradeCenter_DrawPartyLists:
ld de, wPartySpecies
call TradeCenter_PrintPartyListNames
hlcoord 2, 9
- ld de, wEnemyPartyMons
+ ld de, wEnemyPartySpecies
; fall through
TradeCenter_PrintPartyListNames:
@@ -701,7 +701,7 @@ TradeCenter_Trade:
ld bc, NAME_LENGTH
call CopyData
ld a, [wTradingWhichEnemyMon]
- ld hl, wEnemyPartyMons
+ ld hl, wEnemyPartySpecies
ld c, a
ld b, 0
add hl, bc
@@ -798,7 +798,7 @@ TradeCenter_Trade:
ld a, [wTradingWhichEnemyMon]
ld c, a
ld [wWhichPokemon], a
- ld hl, wEnemyPartyMons
+ ld hl, wEnemyPartySpecies
ld d, 0
ld e, a
add hl, de
@@ -818,7 +818,7 @@ TradeCenter_Trade:
ld a, $1
ld [wForceEvolution], a
ld a, [wTradingWhichEnemyMon]
- ld hl, wEnemyPartyMons
+ ld hl, wEnemyPartySpecies
ld b, 0
ld c, a
add hl, bc
diff --git a/engine/menus/save.asm b/engine/menus/save.asm
index dc2e27c2..07eb5acb 100644
--- a/engine/menus/save.asm
+++ b/engine/menus/save.asm
@@ -580,7 +580,7 @@ GetMonCountsForAllBoxes:
ld c, a
ld b, 0
add hl, bc
- ld a, [wNumInBox]
+ ld a, [wBoxCount]
ld [hl], a
ret
diff --git a/engine/movie/oak_speech/init_player_data.asm b/engine/movie/oak_speech/init_player_data.asm
index 53ca24f3..f722ebff 100644
--- a/engine/movie/oak_speech/init_player_data.asm
+++ b/engine/movie/oak_speech/init_player_data.asm
@@ -14,7 +14,7 @@ InitPlayerData2:
ld hl, wPartyCount
call InitializeEmptyList
- ld hl, wNumInBox
+ ld hl, wBoxCount
call InitializeEmptyList
ld hl, wNumBagItems
call InitializeEmptyList
diff --git a/engine/pokemon/add_mon.asm b/engine/pokemon/add_mon.asm
index 46a8b2b9..611aebf4 100644
--- a/engine/pokemon/add_mon.asm
+++ b/engine/pokemon/add_mon.asm
@@ -348,7 +348,7 @@ _MoveMon::
ld hl, wDayCareMon
jr z, .findMonDataSrc
; else it's PARTY_TO_BOX
- ld hl, wNumInBox
+ ld hl, wBoxCount
ld a, [hl]
cp MONS_PER_BOX
jr nz, .partyOrBoxNotFull
@@ -385,7 +385,7 @@ _MoveMon::
; if it's PARTY_TO_BOX
ld hl, wBoxMons
ld bc, wBoxMon2 - wBoxMon1 ; $21
- ld a, [wNumInBox]
+ ld a, [wBoxCount]
.addMonOffset
dec a
call AddNTimes
@@ -435,7 +435,7 @@ _MoveMon::
ld a, [wPartyCount]
jr nz, .addOToffset
ld hl, wBoxMonOT
- ld a, [wNumInBox]
+ ld a, [wBoxCount]
.addOToffset
dec a
call SkipFixedLengthTextEntries
@@ -466,7 +466,7 @@ _MoveMon::
ld a, [wPartyCount]
jr nz, .addNickOffset
ld hl, wBoxMonNicks
- ld a, [wNumInBox]
+ ld a, [wBoxCount]
.addNickOffset
dec a
call SkipFixedLengthTextEntries
diff --git a/engine/pokemon/bills_pc.asm b/engine/pokemon/bills_pc.asm
index f83ed434..7aba8001 100644
--- a/engine/pokemon/bills_pc.asm
+++ b/engine/pokemon/bills_pc.asm
@@ -212,7 +212,7 @@ BillsPCDeposit:
call PrintText
jp BillsPCMenu
.partyLargeEnough
- ld a, [wNumInBox]
+ ld a, [wBoxCount]
cp MONS_PER_BOX
jr nz, .boxNotFull
ld hl, BoxFullText
@@ -254,7 +254,7 @@ BillsPCDeposit:
jp BillsPCMenu
BillsPCWithdraw:
- ld a, [wNumInBox]
+ ld a, [wBoxCount]
and a
jr nz, .boxNotEmpty
ld hl, NoMonText
@@ -268,7 +268,7 @@ BillsPCWithdraw:
call PrintText
jp BillsPCMenu
.partyNotFull
- ld hl, wNumInBox
+ ld hl, wBoxCount
call DisplayMonListMenu
jp c, BillsPCMenu
call DisplayDepositWithdrawMenu
@@ -291,14 +291,14 @@ BillsPCWithdraw:
jp BillsPCMenu
BillsPCRelease:
- ld a, [wNumInBox]
+ ld a, [wBoxCount]
and a
jr nz, .loop
ld hl, NoMonText
call PrintText
jp BillsPCMenu
.loop
- ld hl, wNumInBox
+ ld hl, wBoxCount
call DisplayMonListMenu
jp c, BillsPCMenu
ld hl, OnceReleasedText
diff --git a/engine/pokemon/remove_mon.asm b/engine/pokemon/remove_mon.asm
index c85b96bf..60ec8c27 100644
--- a/engine/pokemon/remove_mon.asm
+++ b/engine/pokemon/remove_mon.asm
@@ -3,7 +3,7 @@ _RemovePokemon::
ld a, [wRemoveMonFromBox]
and a
jr z, .usePartyCount
- ld hl, wNumInBox
+ ld hl, wBoxCount
.usePartyCount
ld a, [hl]
dec a
diff --git a/sram.asm b/sram.asm
index 48542dc7..f6bac35c 100644
--- a/sram.asm
+++ b/sram.asm
@@ -21,25 +21,30 @@ sTileAnimations:: ds 1
sMainDataCheckSum:: ds 1
+; The PC boxes will not fit into one SRAM bank,
+; so they use multiple SECTIONs
+box_n = 0
+boxes: MACRO
+rept \1
+box_n = box_n + 1
+sBox{d:box_n}:: ds wBoxDataEnd - wBoxDataStart
+endr
+ENDM
+
SECTION "Saved Boxes 1", SRAM ; BANK 2
-sBox1:: ds wBoxDataEnd - wBoxDataStart
-sBox2:: ds wBoxDataEnd - wBoxDataStart
-sBox3:: ds wBoxDataEnd - wBoxDataStart
-sBox4:: ds wBoxDataEnd - wBoxDataStart
-sBox5:: ds wBoxDataEnd - wBoxDataStart
-sBox6:: ds wBoxDataEnd - wBoxDataStart
+; sBox1 - sBox6
+ boxes 6
sBank2AllBoxesChecksum:: ds 1
sBank2IndividualBoxChecksums:: ds 6
-
SECTION "Saved Boxes 2", SRAM ; BANK 3
-sBox7:: ds wBoxDataEnd - wBoxDataStart
-sBox8:: ds wBoxDataEnd - wBoxDataStart
-sBox9:: ds wBoxDataEnd - wBoxDataStart
-sBox10:: ds wBoxDataEnd - wBoxDataStart
-sBox11:: ds wBoxDataEnd - wBoxDataStart
-sBox12:: ds wBoxDataEnd - wBoxDataStart
+; sBox7 - sBox12
+ boxes 6
sBank3AllBoxesChecksum:: ds 1
sBank3IndividualBoxChecksums:: ds 6
+
+; All 12 boxes fit within 2 SRAM banks
+ assert box_n == NUM_BOXES, \
+ "boxes: Expected {d:NUM_BOXES} total boxes, got {d:box_n}"
diff --git a/vram.asm b/vram.asm
index d69d3f44..21230ac0 100644
--- a/vram.asm
+++ b/vram.asm
@@ -2,30 +2,30 @@ SECTION "VRAM", VRAM
UNION
; generic
-vChars0:: ds $800
-vChars1:: ds $800
-vChars2:: ds $800
-vBGMap0:: ds $400
-vBGMap1:: ds $400
+vChars0:: ds $80 tiles
+vChars1:: ds $80 tiles
+vChars2:: ds $80 tiles
+vBGMap0:: ds BG_MAP_WIDTH * BG_MAP_HEIGHT
+vBGMap1:: ds BG_MAP_WIDTH * BG_MAP_HEIGHT
NEXTU
; battle/menu
-vSprites:: ds $800
-vFont:: ds $800
-vFrontPic:: ds 7 * 7 * $10
-vBackPic:: ds 7 * 7 * $10
+vSprites:: ds $80 tiles
+vFont:: ds $80 tiles
+vFrontPic:: ds 7 * 7 tiles
+vBackPic:: ds 7 * 7 tiles
NEXTU
; overworld
-vNPCSprites:: ds $800
-vNPCSprites2:: ds $800
-vTileset:: ds $800
+vNPCSprites:: ds $80 tiles
+vNPCSprites2:: ds $80 tiles
+vTileset:: ds $80 tiles
NEXTU
; title
- ds $800
-vTitleLogo:: ds $800
- ds 7 * 7 * $10
-vTitleLogo2:: ds $1e0
+ ds $80 tiles
+vTitleLogo:: ds $80 tiles
+ ds 7 * 7 tiles
+vTitleLogo2:: ds 30 tiles
ENDU
diff --git a/wram.asm b/wram.asm
index ce354a2d..e8ea699c 100644
--- a/wram.asm
+++ b/wram.asm
@@ -175,22 +175,11 @@ wSpriteStateData1::
; - D
; - E
; - F
-wSpritePlayerStateData1:: spritestatedata1 wSpritePlayerStateData1
-wSprite01StateData1:: spritestatedata1 wSprite01StateData1
-wSprite02StateData1:: spritestatedata1 wSprite02StateData1
-wSprite03StateData1:: spritestatedata1 wSprite03StateData1
-wSprite04StateData1:: spritestatedata1 wSprite04StateData1
-wSprite05StateData1:: spritestatedata1 wSprite05StateData1
-wSprite06StateData1:: spritestatedata1 wSprite06StateData1
-wSprite07StateData1:: spritestatedata1 wSprite07StateData1
-wSprite08StateData1:: spritestatedata1 wSprite08StateData1
-wSprite09StateData1:: spritestatedata1 wSprite09StateData1
-wSprite10StateData1:: spritestatedata1 wSprite10StateData1
-wSprite11StateData1:: spritestatedata1 wSprite11StateData1
-wSprite12StateData1:: spritestatedata1 wSprite12StateData1
-wSprite13StateData1:: spritestatedata1 wSprite13StateData1
-wSprite14StateData1:: spritestatedata1 wSprite14StateData1
-wSprite15StateData1:: spritestatedata1 wSprite15StateData1
+wSpritePlayerStateData1:: spritestatedata1 wSpritePlayerStateData1 ; player is struct 0
+; wSprite02StateData1 - wSprite15StateData1
+for n, 1, NUM_SPRITESTATEDATA_STRUCTS
+wSprite{02d:n}StateData1:: spritestatedata1 wSprite{02d:n}StateData1
+endr
wSpriteStateData2::
; more data for all sprites on the current map
@@ -213,23 +202,16 @@ wSpriteStateData2::
; - D: picture ID
; - E: sprite image base offset (in video ram, player always has value 1, used to compute sprite image index)
; - F
-wSpritePlayerStateData2:: spritestatedata2 wSpritePlayerStateData2
-wSprite01StateData2:: spritestatedata2 wSprite01StateData2
-wSprite02StateData2:: spritestatedata2 wSprite02StateData2
-wSprite03StateData2:: spritestatedata2 wSprite03StateData2
-wSprite04StateData2:: spritestatedata2 wSprite04StateData2
-wSprite05StateData2:: spritestatedata2 wSprite05StateData2
-wSprite06StateData2:: spritestatedata2 wSprite06StateData2
-wSprite07StateData2:: spritestatedata2 wSprite07StateData2
-wSprite08StateData2:: spritestatedata2 wSprite08StateData2
-wSprite09StateData2:: spritestatedata2 wSprite09StateData2
-wSprite10StateData2:: spritestatedata2 wSprite10StateData2
-wSprite11StateData2:: spritestatedata2 wSprite11StateData2
-wSprite12StateData2:: spritestatedata2 wSprite12StateData2
-wSprite13StateData2:: spritestatedata2 wSprite13StateData2
-wSprite14StateData2:: spritestatedata2 wSprite14StateData2
-wSprite15StateData2:: spritestatedata2 wSprite15StateData2
+wSpritePlayerStateData2:: spritestatedata2 wSpritePlayerStateData2 ; player is struct 0
+; wSprite02StateData2 - wSprite15StateData2
+for n, 1, NUM_SPRITESTATEDATA_STRUCTS
+wSprite{02d:n}StateData2:: spritestatedata2 wSprite{02d:n}StateData2
+endr
+; The high byte of a pointer to anywhere within wSpriteStateData1 can be incremented
+; to reach within wSpriteStateData2, and vice-versa for decrementing.
+assert HIGH(wSpriteStateData1) + 1 == HIGH(wSpriteStateData2)
+assert LOW(wSpriteStateData1) == 0
wSpriteDataEnd::
@@ -238,7 +220,10 @@ SECTION "OAM Buffer", WRAM0
wOAMBuffer::
; buffer for OAM data. Copied to OAM by DMA
- ds 4 * 40
+; wOAMBufferSprite00 - wOAMBufferSprite39
+for n, NUM_SPRITE_OAM_STRUCTS
+wOAMBufferSprite{02d:n}:: ds 4
+endr
wOAMBufferEnd::
wTileMap::
@@ -2027,7 +2012,7 @@ wRepelRemainingSteps::
wMoves::
; list of moves for FormatMovesString
- ds 4
+ ds NUM_MOVES
wMoveNum::
ds 1
@@ -2236,20 +2221,26 @@ wPlayerName::
wPartyDataStart::
-wPartyCount:: ds 1
-wPartySpecies:: ds PARTY_LENGTH
-wPartyEnd:: ds 1
+wPartyCount:: ds 1
+wPartySpecies:: ds PARTY_LENGTH + 1
wPartyMons::
-wPartyMon1:: party_struct wPartyMon1
-wPartyMon2:: party_struct wPartyMon2
-wPartyMon3:: party_struct wPartyMon3
-wPartyMon4:: party_struct wPartyMon4
-wPartyMon5:: party_struct wPartyMon5
-wPartyMon6:: party_struct wPartyMon6
-
-wPartyMonOT:: ds NAME_LENGTH * PARTY_LENGTH
-wPartyMonNicks:: ds NAME_LENGTH * PARTY_LENGTH
+; wPartyMon1 - wPartyMon6
+for n, 1, PARTY_LENGTH + 1
+wPartyMon{d:n}:: party_struct wPartyMon{d:n}
+endr
+
+wPartyMonOT::
+; wPartyMon1OT - wPartyMon6OT
+for n, 1, PARTY_LENGTH + 1
+wPartyMon{d:n}OT:: ds NAME_LENGTH
+endr
+
+wPartyMonNicks::
+; wPartyMon1Nick - wPartyMon6Nick
+for n, 1, PARTY_LENGTH + 1
+wPartyMon{d:n}Nick:: ds NAME_LENGTH
+endr
wPartyMonNicksEnd::
wPartyDataEnd::
@@ -3071,18 +3062,25 @@ wSerialEnemyDataBlock::
ds 9
wEnemyPartyCount:: ds 1
-wEnemyPartyMons:: ds PARTY_LENGTH + 1
+wEnemyPartySpecies:: ds PARTY_LENGTH + 1
wEnemyMons::
-wEnemyMon1:: party_struct wEnemyMon1
-wEnemyMon2:: party_struct wEnemyMon2
-wEnemyMon3:: party_struct wEnemyMon3
-wEnemyMon4:: party_struct wEnemyMon4
-wEnemyMon5:: party_struct wEnemyMon5
-wEnemyMon6:: party_struct wEnemyMon6
-
-wEnemyMonOT:: ds NAME_LENGTH * PARTY_LENGTH
-wEnemyMonNicks:: ds NAME_LENGTH * PARTY_LENGTH
+; wEnemyMon1 - wEnemyMon6
+for n, 1, PARTY_LENGTH + 1
+wEnemyMon{d:n}:: party_struct wEnemyMon{d:n}
+endr
+
+wEnemyMonOT::
+; wEnemyMon1OT - wEnemyMon6OT
+for n, 1, PARTY_LENGTH + 1
+wEnemyMon{d:n}OT:: ds NAME_LENGTH
+endr
+
+wEnemyMonNicks::
+; wEnemyMon1Nick - wEnemyMon6Nick
+for n, 1, PARTY_LENGTH + 1
+wEnemyMon{d:n}Nick:: ds NAME_LENGTH
+endr
ENDU
@@ -3139,15 +3137,27 @@ wMainDataEnd::
wBoxDataStart::
-wNumInBox:: ds 1
+wBoxCount:: ds 1
wBoxSpecies:: ds MONS_PER_BOX + 1
wBoxMons::
-wBoxMon1:: box_struct wBoxMon1
-wBoxMon2:: ds BOX_STRUCT_LENGTH * (MONS_PER_BOX - 1)
-wBoxMonOT:: ds NAME_LENGTH * MONS_PER_BOX
-wBoxMonNicks:: ds NAME_LENGTH * MONS_PER_BOX
+; wBoxMon1 - wBoxMon20
+for n, 1, MONS_PER_BOX + 1
+wBoxMon{d:n}:: box_struct wBoxMon{d:n}
+endr
+
+wBoxMonOT::
+; wBoxMon1OT - wBoxMon20OT
+for n, 1, MONS_PER_BOX + 1
+wBoxMon{d:n}OT:: ds NAME_LENGTH
+endr
+
+wBoxMonNicks::
+; wBoxMon1Nick - wBoxMon20Nick
+for n, 1, MONS_PER_BOX + 1
+wBoxMon{d:n}Nick:: ds NAME_LENGTH
+endr
wBoxMonNicksEnd::
wBoxDataEnd::