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_YELLOW EQU 1
HP_BAR_RED EQU 2 HP_BAR_RED EQU 2
; wOAMBuffer
NUM_SPRITE_OAM_STRUCTS EQU 40
; hAutoBGTransferEnabled ; hAutoBGTransferEnabled
TRANSFERTOP EQU 0 TRANSFERTOP EQU 0
TRANSFERMIDDLE EQU 1 TRANSFERMIDDLE EQU 1

View file

@ -38,6 +38,8 @@ SPRITESTATEDATA1_LENGTH EQU const_value
const SPRITESTATEDATA2_0F ; f const SPRITESTATEDATA2_0F ; f
SPRITESTATEDATA2_LENGTH EQU const_value SPRITESTATEDATA2_LENGTH EQU const_value
NUM_SPRITESTATEDATA_STRUCTS EQU 16
; different kinds of people events ; different kinds of people events
ITEM EQU $80 ITEM EQU $80
TRAINER EQU $40 TRAINER EQU $40

View file

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

View file

@ -5,7 +5,7 @@ ReadTrainer:
and a and a
ret nz ret nz
; set [wEnemyPartyCount] to 0, [wEnemyPartyMons] to FF ; set [wEnemyPartyCount] to 0, [wEnemyPartySpecies] to FF
; XXX first is total enemy pokemon? ; XXX first is total enemy pokemon?
; XXX second is species of first pokemon? ; XXX second is species of first pokemon?
ld hl, wEnemyPartyCount ld hl, wEnemyPartyCount

View file

@ -7,7 +7,7 @@ _GivePokemon::
ld a, [wPartyCount] ld a, [wPartyCount]
cp PARTY_LENGTH cp PARTY_LENGTH
jr c, .addToParty jr c, .addToParty
ld a, [wNumInBox] ld a, [wBoxCount]
cp MONS_PER_BOX cp MONS_PER_BOX
jr nc, .boxFull jr nc, .boxFull
; add to box ; add to box

View file

@ -120,7 +120,7 @@ ItemUseBall:
ld a, [wPartyCount] ; is party full? ld a, [wPartyCount] ; is party full?
cp PARTY_LENGTH cp PARTY_LENGTH
jr nz, .canUseBall jr nz, .canUseBall
ld a, [wNumInBox] ; is box full? ld a, [wBoxCount] ; is box full?
cp MONS_PER_BOX cp MONS_PER_BOX
jp z, BoxFullCannotThrowBall jp z, BoxFullCannotThrowBall
@ -2638,7 +2638,7 @@ IsKeyItem_::
INCLUDE "data/items/key_items.asm" INCLUDE "data/items/key_items.asm"
SendNewMonToBox: SendNewMonToBox:
ld de, wNumInBox ld de, wBoxCount
ld a, [de] ld a, [de]
inc a inc a
ld [de], a ld [de], a
@ -2657,7 +2657,7 @@ SendNewMonToBox:
call GetMonHeader call GetMonHeader
ld hl, wBoxMonOT ld hl, wBoxMonOT
ld bc, NAME_LENGTH ld bc, NAME_LENGTH
ld a, [wNumInBox] ld a, [wBoxCount]
dec a dec a
jr z, .asm_e7ee jr z, .asm_e7ee
dec a dec a
@ -2668,7 +2668,7 @@ SendNewMonToBox:
ld d, h ld d, h
ld e, l ld e, l
pop hl pop hl
ld a, [wNumInBox] ld a, [wBoxCount]
dec a dec a
ld b, a ld b, a
.asm_e7db .asm_e7db
@ -2689,7 +2689,7 @@ SendNewMonToBox:
ld de, wBoxMonOT ld de, wBoxMonOT
ld bc, NAME_LENGTH ld bc, NAME_LENGTH
call CopyData call CopyData
ld a, [wNumInBox] ld a, [wBoxCount]
dec a dec a
jr z, .asm_e82a jr z, .asm_e82a
ld hl, wBoxMonNicks ld hl, wBoxMonNicks
@ -2702,7 +2702,7 @@ SendNewMonToBox:
ld d, h ld d, h
ld e, l ld e, l
pop hl pop hl
ld a, [wNumInBox] ld a, [wBoxCount]
dec a dec a
ld b, a ld b, a
.asm_e817 .asm_e817
@ -2723,7 +2723,7 @@ SendNewMonToBox:
ld a, NAME_MON_SCREEN ld a, NAME_MON_SCREEN
ld [wNamingScreenType], a ld [wNamingScreenType], a
predef AskName predef AskName
ld a, [wNumInBox] ld a, [wBoxCount]
dec a dec a
jr z, .asm_e867 jr z, .asm_e867
ld hl, wBoxMons ld hl, wBoxMons
@ -2736,7 +2736,7 @@ SendNewMonToBox:
ld d, h ld d, h
ld e, l ld e, l
pop hl pop hl
ld a, [wNumInBox] ld a, [wBoxCount]
dec a dec a
ld b, a ld b, a
.asm_e854 .asm_e854

View file

@ -648,7 +648,7 @@ TradeCenter_DrawPartyLists:
ld de, wPartySpecies ld de, wPartySpecies
call TradeCenter_PrintPartyListNames call TradeCenter_PrintPartyListNames
hlcoord 2, 9 hlcoord 2, 9
ld de, wEnemyPartyMons ld de, wEnemyPartySpecies
; fall through ; fall through
TradeCenter_PrintPartyListNames: TradeCenter_PrintPartyListNames:
@ -701,7 +701,7 @@ TradeCenter_Trade:
ld bc, NAME_LENGTH ld bc, NAME_LENGTH
call CopyData call CopyData
ld a, [wTradingWhichEnemyMon] ld a, [wTradingWhichEnemyMon]
ld hl, wEnemyPartyMons ld hl, wEnemyPartySpecies
ld c, a ld c, a
ld b, 0 ld b, 0
add hl, bc add hl, bc
@ -798,7 +798,7 @@ TradeCenter_Trade:
ld a, [wTradingWhichEnemyMon] ld a, [wTradingWhichEnemyMon]
ld c, a ld c, a
ld [wWhichPokemon], a ld [wWhichPokemon], a
ld hl, wEnemyPartyMons ld hl, wEnemyPartySpecies
ld d, 0 ld d, 0
ld e, a ld e, a
add hl, de add hl, de
@ -818,7 +818,7 @@ TradeCenter_Trade:
ld a, $1 ld a, $1
ld [wForceEvolution], a ld [wForceEvolution], a
ld a, [wTradingWhichEnemyMon] ld a, [wTradingWhichEnemyMon]
ld hl, wEnemyPartyMons ld hl, wEnemyPartySpecies
ld b, 0 ld b, 0
ld c, a ld c, a
add hl, bc add hl, bc

View file

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

View file

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

View file

@ -348,7 +348,7 @@ _MoveMon::
ld hl, wDayCareMon ld hl, wDayCareMon
jr z, .findMonDataSrc jr z, .findMonDataSrc
; else it's PARTY_TO_BOX ; else it's PARTY_TO_BOX
ld hl, wNumInBox ld hl, wBoxCount
ld a, [hl] ld a, [hl]
cp MONS_PER_BOX cp MONS_PER_BOX
jr nz, .partyOrBoxNotFull jr nz, .partyOrBoxNotFull
@ -385,7 +385,7 @@ _MoveMon::
; if it's PARTY_TO_BOX ; if it's PARTY_TO_BOX
ld hl, wBoxMons ld hl, wBoxMons
ld bc, wBoxMon2 - wBoxMon1 ; $21 ld bc, wBoxMon2 - wBoxMon1 ; $21
ld a, [wNumInBox] ld a, [wBoxCount]
.addMonOffset .addMonOffset
dec a dec a
call AddNTimes call AddNTimes
@ -435,7 +435,7 @@ _MoveMon::
ld a, [wPartyCount] ld a, [wPartyCount]
jr nz, .addOToffset jr nz, .addOToffset
ld hl, wBoxMonOT ld hl, wBoxMonOT
ld a, [wNumInBox] ld a, [wBoxCount]
.addOToffset .addOToffset
dec a dec a
call SkipFixedLengthTextEntries call SkipFixedLengthTextEntries
@ -466,7 +466,7 @@ _MoveMon::
ld a, [wPartyCount] ld a, [wPartyCount]
jr nz, .addNickOffset jr nz, .addNickOffset
ld hl, wBoxMonNicks ld hl, wBoxMonNicks
ld a, [wNumInBox] ld a, [wBoxCount]
.addNickOffset .addNickOffset
dec a dec a
call SkipFixedLengthTextEntries call SkipFixedLengthTextEntries

View file

@ -212,7 +212,7 @@ BillsPCDeposit:
call PrintText call PrintText
jp BillsPCMenu jp BillsPCMenu
.partyLargeEnough .partyLargeEnough
ld a, [wNumInBox] ld a, [wBoxCount]
cp MONS_PER_BOX cp MONS_PER_BOX
jr nz, .boxNotFull jr nz, .boxNotFull
ld hl, BoxFullText ld hl, BoxFullText
@ -254,7 +254,7 @@ BillsPCDeposit:
jp BillsPCMenu jp BillsPCMenu
BillsPCWithdraw: BillsPCWithdraw:
ld a, [wNumInBox] ld a, [wBoxCount]
and a and a
jr nz, .boxNotEmpty jr nz, .boxNotEmpty
ld hl, NoMonText ld hl, NoMonText
@ -268,7 +268,7 @@ BillsPCWithdraw:
call PrintText call PrintText
jp BillsPCMenu jp BillsPCMenu
.partyNotFull .partyNotFull
ld hl, wNumInBox ld hl, wBoxCount
call DisplayMonListMenu call DisplayMonListMenu
jp c, BillsPCMenu jp c, BillsPCMenu
call DisplayDepositWithdrawMenu call DisplayDepositWithdrawMenu
@ -291,14 +291,14 @@ BillsPCWithdraw:
jp BillsPCMenu jp BillsPCMenu
BillsPCRelease: BillsPCRelease:
ld a, [wNumInBox] ld a, [wBoxCount]
and a and a
jr nz, .loop jr nz, .loop
ld hl, NoMonText ld hl, NoMonText
call PrintText call PrintText
jp BillsPCMenu jp BillsPCMenu
.loop .loop
ld hl, wNumInBox ld hl, wBoxCount
call DisplayMonListMenu call DisplayMonListMenu
jp c, BillsPCMenu jp c, BillsPCMenu
ld hl, OnceReleasedText ld hl, OnceReleasedText

View file

@ -3,7 +3,7 @@ _RemovePokemon::
ld a, [wRemoveMonFromBox] ld a, [wRemoveMonFromBox]
and a and a
jr z, .usePartyCount jr z, .usePartyCount
ld hl, wNumInBox ld hl, wBoxCount
.usePartyCount .usePartyCount
ld a, [hl] ld a, [hl]
dec a dec a

View file

@ -21,25 +21,30 @@ sTileAnimations:: ds 1
sMainDataCheckSum:: 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 SECTION "Saved Boxes 1", SRAM ; BANK 2
sBox1:: ds wBoxDataEnd - wBoxDataStart ; sBox1 - sBox6
sBox2:: ds wBoxDataEnd - wBoxDataStart boxes 6
sBox3:: ds wBoxDataEnd - wBoxDataStart
sBox4:: ds wBoxDataEnd - wBoxDataStart
sBox5:: ds wBoxDataEnd - wBoxDataStart
sBox6:: ds wBoxDataEnd - wBoxDataStart
sBank2AllBoxesChecksum:: ds 1 sBank2AllBoxesChecksum:: ds 1
sBank2IndividualBoxChecksums:: ds 6 sBank2IndividualBoxChecksums:: ds 6
SECTION "Saved Boxes 2", SRAM ; BANK 3 SECTION "Saved Boxes 2", SRAM ; BANK 3
sBox7:: ds wBoxDataEnd - wBoxDataStart ; sBox7 - sBox12
sBox8:: ds wBoxDataEnd - wBoxDataStart boxes 6
sBox9:: ds wBoxDataEnd - wBoxDataStart
sBox10:: ds wBoxDataEnd - wBoxDataStart
sBox11:: ds wBoxDataEnd - wBoxDataStart
sBox12:: ds wBoxDataEnd - wBoxDataStart
sBank3AllBoxesChecksum:: ds 1 sBank3AllBoxesChecksum:: ds 1
sBank3IndividualBoxChecksums:: ds 6 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 UNION
; generic ; generic
vChars0:: ds $800 vChars0:: ds $80 tiles
vChars1:: ds $800 vChars1:: ds $80 tiles
vChars2:: ds $800 vChars2:: ds $80 tiles
vBGMap0:: ds $400 vBGMap0:: ds BG_MAP_WIDTH * BG_MAP_HEIGHT
vBGMap1:: ds $400 vBGMap1:: ds BG_MAP_WIDTH * BG_MAP_HEIGHT
NEXTU NEXTU
; battle/menu ; battle/menu
vSprites:: ds $800 vSprites:: ds $80 tiles
vFont:: ds $800 vFont:: ds $80 tiles
vFrontPic:: ds 7 * 7 * $10 vFrontPic:: ds 7 * 7 tiles
vBackPic:: ds 7 * 7 * $10 vBackPic:: ds 7 * 7 tiles
NEXTU NEXTU
; overworld ; overworld
vNPCSprites:: ds $800 vNPCSprites:: ds $80 tiles
vNPCSprites2:: ds $800 vNPCSprites2:: ds $80 tiles
vTileset:: ds $800 vTileset:: ds $80 tiles
NEXTU NEXTU
; title ; title
ds $800 ds $80 tiles
vTitleLogo:: ds $800 vTitleLogo:: ds $80 tiles
ds 7 * 7 * $10 ds 7 * 7 tiles
vTitleLogo2:: ds $1e0 vTitleLogo2:: ds 30 tiles
ENDU ENDU

126
wram.asm
View file

@ -175,22 +175,11 @@ wSpriteStateData1::
; - D ; - D
; - E ; - E
; - F ; - F
wSpritePlayerStateData1:: spritestatedata1 wSpritePlayerStateData1 wSpritePlayerStateData1:: spritestatedata1 wSpritePlayerStateData1 ; player is struct 0
wSprite01StateData1:: spritestatedata1 wSprite01StateData1 ; wSprite02StateData1 - wSprite15StateData1
wSprite02StateData1:: spritestatedata1 wSprite02StateData1 for n, 1, NUM_SPRITESTATEDATA_STRUCTS
wSprite03StateData1:: spritestatedata1 wSprite03StateData1 wSprite{02d:n}StateData1:: spritestatedata1 wSprite{02d:n}StateData1
wSprite04StateData1:: spritestatedata1 wSprite04StateData1 endr
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
wSpriteStateData2:: wSpriteStateData2::
; more data for all sprites on the current map ; more data for all sprites on the current map
@ -213,23 +202,16 @@ wSpriteStateData2::
; - D: picture ID ; - D: picture ID
; - E: sprite image base offset (in video ram, player always has value 1, used to compute sprite image index) ; - E: sprite image base offset (in video ram, player always has value 1, used to compute sprite image index)
; - F ; - F
wSpritePlayerStateData2:: spritestatedata2 wSpritePlayerStateData2 wSpritePlayerStateData2:: spritestatedata2 wSpritePlayerStateData2 ; player is struct 0
wSprite01StateData2:: spritestatedata2 wSprite01StateData2 ; wSprite02StateData2 - wSprite15StateData2
wSprite02StateData2:: spritestatedata2 wSprite02StateData2 for n, 1, NUM_SPRITESTATEDATA_STRUCTS
wSprite03StateData2:: spritestatedata2 wSprite03StateData2 wSprite{02d:n}StateData2:: spritestatedata2 wSprite{02d:n}StateData2
wSprite04StateData2:: spritestatedata2 wSprite04StateData2 endr
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
; 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:: wSpriteDataEnd::
@ -238,7 +220,10 @@ SECTION "OAM Buffer", WRAM0
wOAMBuffer:: wOAMBuffer::
; buffer for OAM data. Copied to OAM by DMA ; 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:: wOAMBufferEnd::
wTileMap:: wTileMap::
@ -2027,7 +2012,7 @@ wRepelRemainingSteps::
wMoves:: wMoves::
; list of moves for FormatMovesString ; list of moves for FormatMovesString
ds 4 ds NUM_MOVES
wMoveNum:: wMoveNum::
ds 1 ds 1
@ -2237,19 +2222,25 @@ wPlayerName::
wPartyDataStart:: wPartyDataStart::
wPartyCount:: ds 1 wPartyCount:: ds 1
wPartySpecies:: ds PARTY_LENGTH wPartySpecies:: ds PARTY_LENGTH + 1
wPartyEnd:: ds 1
wPartyMons:: wPartyMons::
wPartyMon1:: party_struct wPartyMon1 ; wPartyMon1 - wPartyMon6
wPartyMon2:: party_struct wPartyMon2 for n, 1, PARTY_LENGTH + 1
wPartyMon3:: party_struct wPartyMon3 wPartyMon{d:n}:: party_struct wPartyMon{d:n}
wPartyMon4:: party_struct wPartyMon4 endr
wPartyMon5:: party_struct wPartyMon5
wPartyMon6:: party_struct wPartyMon6
wPartyMonOT:: ds NAME_LENGTH * PARTY_LENGTH wPartyMonOT::
wPartyMonNicks:: ds NAME_LENGTH * PARTY_LENGTH ; 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:: wPartyMonNicksEnd::
wPartyDataEnd:: wPartyDataEnd::
@ -3071,18 +3062,25 @@ wSerialEnemyDataBlock::
ds 9 ds 9
wEnemyPartyCount:: ds 1 wEnemyPartyCount:: ds 1
wEnemyPartyMons:: ds PARTY_LENGTH + 1 wEnemyPartySpecies:: ds PARTY_LENGTH + 1
wEnemyMons:: wEnemyMons::
wEnemyMon1:: party_struct wEnemyMon1 ; wEnemyMon1 - wEnemyMon6
wEnemyMon2:: party_struct wEnemyMon2 for n, 1, PARTY_LENGTH + 1
wEnemyMon3:: party_struct wEnemyMon3 wEnemyMon{d:n}:: party_struct wEnemyMon{d:n}
wEnemyMon4:: party_struct wEnemyMon4 endr
wEnemyMon5:: party_struct wEnemyMon5
wEnemyMon6:: party_struct wEnemyMon6
wEnemyMonOT:: ds NAME_LENGTH * PARTY_LENGTH wEnemyMonOT::
wEnemyMonNicks:: ds NAME_LENGTH * PARTY_LENGTH ; 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 ENDU
@ -3139,15 +3137,27 @@ wMainDataEnd::
wBoxDataStart:: wBoxDataStart::
wNumInBox:: ds 1 wBoxCount:: ds 1
wBoxSpecies:: ds MONS_PER_BOX + 1 wBoxSpecies:: ds MONS_PER_BOX + 1
wBoxMons:: wBoxMons::
wBoxMon1:: box_struct wBoxMon1
wBoxMon2:: ds BOX_STRUCT_LENGTH * (MONS_PER_BOX - 1)
wBoxMonOT:: ds NAME_LENGTH * MONS_PER_BOX ; wBoxMon1 - wBoxMon20
wBoxMonNicks:: ds NAME_LENGTH * MONS_PER_BOX 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:: wBoxMonNicksEnd::
wBoxDataEnd:: wBoxDataEnd::