Use {interpolation} to generate sequences of RAM labels

Fixes #319
This commit is contained in:
Rangi 2021-04-27 15:49:59 -04:00
parent bcc4380d40
commit 6a31663c96
15 changed files with 135 additions and 115 deletions

View file

@ -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

View file

@ -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

View file

@ -113,7 +113,7 @@ GetMonSpecies:
ld hl, wBoxSpecies
jr .getSpecies
.enemyParty
ld hl, wEnemyPartyMons
ld hl, wEnemyPartySpecies
.getSpecies
ld d, 0
add hl, de

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -580,7 +580,7 @@ GetMonCountsForAllBoxes:
ld c, a
ld b, 0
add hl, bc
ld a, [wNumInBox]
ld a, [wBoxCount]
ld [hl], a
ret

View file

@ -14,7 +14,7 @@ InitPlayerData2:
ld hl, wPartyCount
call InitializeEmptyList
ld hl, wNumInBox
ld hl, wBoxCount
call InitializeEmptyList
ld hl, wNumBagItems
call InitializeEmptyList

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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}"

View file

@ -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

128
wram.asm
View file

@ -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
; wPartyMon1 - wPartyMon6
for n, 1, PARTY_LENGTH + 1
wPartyMon{d:n}:: party_struct wPartyMon{d:n}
endr
wPartyMonOT:: ds NAME_LENGTH * PARTY_LENGTH
wPartyMonNicks:: ds NAME_LENGTH * PARTY_LENGTH
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
; wEnemyMon1 - wEnemyMon6
for n, 1, PARTY_LENGTH + 1
wEnemyMon{d:n}:: party_struct wEnemyMon{d:n}
endr
wEnemyMonOT:: ds NAME_LENGTH * PARTY_LENGTH
wEnemyMonNicks:: ds NAME_LENGTH * PARTY_LENGTH
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::