ref: efd1006917b438ff683e8f702adbe6b4d0733a0f
parent: c5f9e25cc493ecc0e49ffd437dad73893b5529d0
author: Rangi <35663410+Rangi42@users.noreply.github.com>
date: Tue Apr 27 08:11:39 EDT 2021
Use {interpolation} to generate sequences of RAM labels This makes the table_width/assert_table_length usages unnecessary, and also keeps the labels automatically up to date if the length constants change.
--- a/constants/battle_tower_constants.asm
+++ b/constants/battle_tower_constants.asm
@@ -4,8 +4,8 @@
BATTLETOWER_NUM_UNIQUE_MON EQU 21
BATTLETOWER_NUM_UNIQUE_TRAINERS EQU 70
-BATTLETOWER_TRAINERDATALENGTH EQU $24
-BATTLE_TOWER_STRUCT_LENGTH EQU NAME_LENGTH + BATTLETOWER_PARTY_LENGTH * NICKNAMED_MON_STRUCT_LENGTH + BATTLETOWER_TRAINERDATALENGTH
+BATTLETOWER_TRAINERDATALENGTH EQU 18 * 2 ; $24
+BATTLE_TOWER_STRUCT_LENGTH EQU NAME_LENGTH + BATTLETOWER_PARTY_LENGTH * NICKNAMED_MON_STRUCT_LENGTH + BATTLETOWER_TRAINERDATALENGTH ; $e0
; BattleTowerAction setval arguments (see engine/events/battle_tower/battle_tower.asm)
const_def
--- a/constants/pokemon_data_constants.asm
+++ b/constants/pokemon_data_constants.asm
@@ -136,11 +136,15 @@
; boxes
MONS_PER_BOX EQU 20
+; box: count, species, mons, OTs, nicknames, padding
+BOX_LENGTH EQU 1 + MONS_PER_BOX + 1 + (BOXMON_STRUCT_LENGTH + NAME_LENGTH + MON_NAME_LENGTH) * MONS_PER_BOX + 2 ; $450
NUM_BOXES EQU 14
; hall of fame
-HOF_MON_LENGTH EQU 1 + 2 + 2 + 1 + (MON_NAME_LENGTH - 1) ; species, id, dvs, level, nick
-HOF_LENGTH EQU 1 + HOF_MON_LENGTH * PARTY_LENGTH + 1 ; win count, party, terminator
+; hof_mon: species, id, dvs, level, nicknames
+HOF_MON_LENGTH EQU 1 + 2 + 2 + 1 + (MON_NAME_LENGTH - 1) ; $10
+; hall_of_fame: win count, party, terminator
+HOF_LENGTH EQU 1 + HOF_MON_LENGTH * PARTY_LENGTH + 1 ; $62
NUM_HOF_TEAMS EQU 30
; evolution types (used in data/pokemon/evos_attacks.asm)
--- a/engine/battle/core.asm
+++ b/engine/battle/core.asm
@@ -6392,7 +6392,7 @@
and a
ret z
-; Update enemy nick
+; Update enemy nickname
ld hl, wStringBuffer1
ld de, wEnemyMonNickname
ld bc, MON_NAME_LENGTH
--- a/engine/battle_anims/bg_effects.asm
+++ b/engine/battle_anims/bg_effects.asm
@@ -2294,7 +2294,7 @@
ldh [hSCY], a
xor $ff
inc a
- ld [wAnimObject01YOffset], a
+ ld [wAnimObject1YOffset], a
ret
BattleBGEffect_ShakeScreenX:
--- a/engine/events/battle_tower/battle_tower.asm
+++ b/engine/events/battle_tower/battle_tower.asm
@@ -309,9 +309,9 @@
.skip_mon_3
; Add the terminator character to each of these names
ld a, "@"
- ld [wBT_OTTempMon1NameEnd - 1], a
- ld [wBT_OTTempMon2NameEnd - 1], a
- ld [wBT_OTTempMon3NameEnd - 1], a
+ ld [wBT_OTTempMon1Name + MON_NAME_LENGTH - 1], a
+ ld [wBT_OTTempMon2Name + MON_NAME_LENGTH - 1], a
+ ld [wBT_OTTempMon3Name + MON_NAME_LENGTH - 1], a
; Fix errors in the movesets
call CheckBTMonMovesForErrors
; Repair the trainer name if needed, then copy it to wOTPlayerName
--- a/macros/wram.asm
+++ b/macros/wram.asm
@@ -100,13 +100,23 @@
ENDM
box: MACRO
-\1Count:: db
-\1Species:: ds MONS_PER_BOX + 1
+\1Count:: db
+\1Species:: ds MONS_PER_BOX + 1
\1Mons::
-\1Mon1:: box_struct \1Mon1
-\1Mon2:: ds BOXMON_STRUCT_LENGTH * (MONS_PER_BOX - 1)
-\1MonOTs:: ds NAME_LENGTH * MONS_PER_BOX
-\1MonNicknames:: ds MON_NAME_LENGTH * MONS_PER_BOX
+; \1Mon1 - \1Mon20
+for n, 1, MONS_PER_BOX + 1
+\1Mon{d:n}:: box_struct \1Mon{d:n}
+endr
+\1MonOTs::
+; \1Mon1OT - \1Mon20OT
+for n, 1, MONS_PER_BOX + 1
+\1Mon{d:n}OT:: ds NAME_LENGTH
+endr
+\1MonNicknames::
+; \1Mon1Nickname - \1Mon20Nickname
+for n, 1, MONS_PER_BOX + 1
+\1Mon{d:n}Nickname:: ds MON_NAME_LENGTH
+endr
\1MonNicknamesEnd::
\1End::
ds 2 ; padding
@@ -171,15 +181,11 @@
battle_tower_struct: MACRO
\1Name:: ds NAME_LENGTH - 1
\1TrainerClass:: db
-\1Mon1:: party_struct \1Mon1
-\1Mon1Name:: ds MON_NAME_LENGTH
-\1Mon1NameEnd::
-\1Mon2:: party_struct \1Mon2
-\1Mon2Name:: ds MON_NAME_LENGTH
-\1Mon2NameEnd::
-\1Mon3:: party_struct \1Mon3
-\1Mon3Name:: ds MON_NAME_LENGTH
-\1Mon3NameEnd::
+; \1Mon1 - \1Mon3 and \1Mon1Name - \1Mon3Name
+for n, 1, BATTLETOWER_PARTY_LENGTH + 1
+\1Mon{d:n}:: party_struct \1Mon{d:n}
+\1Mon{d:n}Name:: ds MON_NAME_LENGTH
+endr
\1TrainerData:: ds BATTLETOWER_TRAINERDATALENGTH
\1TrainerEnd::
ENDM
@@ -221,12 +227,10 @@
hall_of_fame: MACRO
\1WinCount:: db
-\1Mon1:: hof_mon \1Mon1
-\1Mon2:: hof_mon \1Mon2
-\1Mon3:: hof_mon \1Mon3
-\1Mon4:: hof_mon \1Mon4
-\1Mon5:: hof_mon \1Mon5
-\1Mon6:: hof_mon \1Mon6
+; \1Mon1 - \1Mon6
+for n, 1, PARTY_LENGTH + 1
+\1Mon{d:n}:: hof_mon \1Mon{d:n}
+endr
\1End:: db
ENDM
--- a/sram.asm
+++ b/sram.asm
@@ -6,54 +6,30 @@
SECTION "SRAM Bank 0", SRAM
sPartyMail::
- table_width MAIL_STRUCT_LENGTH, sPartyMail
-sPartyMon1Mail:: mailmsg sPartyMon1Mail
-sPartyMon2Mail:: mailmsg sPartyMon2Mail
-sPartyMon3Mail:: mailmsg sPartyMon3Mail
-sPartyMon4Mail:: mailmsg sPartyMon4Mail
-sPartyMon5Mail:: mailmsg sPartyMon5Mail
-sPartyMon6Mail:: mailmsg sPartyMon6Mail
- assert_table_length PARTY_LENGTH
+; sPartyMon1Mail - sPartyMon6Mail
+for n, 1, PARTY_LENGTH + 1
+sPartyMon{d:n}Mail:: mailmsg sPartyMon{d:n}Mail
+endr
sPartyMailBackup::
- table_width MAIL_STRUCT_LENGTH, sPartyMailBackup
-sPartyMon1MailBackup:: mailmsg sPartyMon1MailBackup
-sPartyMon2MailBackup:: mailmsg sPartyMon2MailBackup
-sPartyMon3MailBackup:: mailmsg sPartyMon3MailBackup
-sPartyMon4MailBackup:: mailmsg sPartyMon4MailBackup
-sPartyMon5MailBackup:: mailmsg sPartyMon5MailBackup
-sPartyMon6MailBackup:: mailmsg sPartyMon6MailBackup
- assert_table_length PARTY_LENGTH
+; sPartyMon1MailBackup - sPartyMon6MailBackup
+for n, 1, PARTY_LENGTH + 1
+sPartyMon{d:n}MailBackup:: mailmsg sPartyMon{d:n}MailBackup
+endr
sMailboxCount:: db
sMailboxes::
- table_width MAIL_STRUCT_LENGTH, sMailboxes
-sMailbox1:: mailmsg sMailbox1
-sMailbox2:: mailmsg sMailbox2
-sMailbox3:: mailmsg sMailbox3
-sMailbox4:: mailmsg sMailbox4
-sMailbox5:: mailmsg sMailbox5
-sMailbox6:: mailmsg sMailbox6
-sMailbox7:: mailmsg sMailbox7
-sMailbox8:: mailmsg sMailbox8
-sMailbox9:: mailmsg sMailbox9
-sMailbox10:: mailmsg sMailbox10
- assert_table_length MAILBOX_CAPACITY
+; sMailbox1 - sMailbox10
+for n, 1, MAILBOX_CAPACITY + 1
+sMailbox{d:n}:: mailmsg sMailbox{d:n}
+endr
sMailboxCountBackup:: db
sMailboxesBackup::
- table_width MAIL_STRUCT_LENGTH, sMailboxesBackup
-sMailbox1Backup:: mailmsg sMailbox1Backup
-sMailbox2Backup:: mailmsg sMailbox2Backup
-sMailbox3Backup:: mailmsg sMailbox3Backup
-sMailbox4Backup:: mailmsg sMailbox4Backup
-sMailbox5Backup:: mailmsg sMailbox5Backup
-sMailbox6Backup:: mailmsg sMailbox6Backup
-sMailbox7Backup:: mailmsg sMailbox7Backup
-sMailbox8Backup:: mailmsg sMailbox8Backup
-sMailbox9Backup:: mailmsg sMailbox9Backup
-sMailbox10Backup:: mailmsg sMailbox10Backup
- assert_table_length MAILBOX_CAPACITY
+; sMailbox1Backup - sMailbox10Backup
+for n, 1, MAILBOX_CAPACITY + 1
+sMailbox{d:n}Backup:: mailmsg sMailbox{d:n}Backup
+endr
sMysteryGiftData::
sMysteryGiftItem:: db
@@ -142,13 +118,10 @@
sLinkBattleDraws:: dw
sLinkBattleRecord::
- table_width LINK_BATTLE_RECORD_LENGTH, sLinkBattleRecord
-sLinkBattleRecord1:: link_battle_record sLinkBattleRecord1
-sLinkBattleRecord2:: link_battle_record sLinkBattleRecord2
-sLinkBattleRecord3:: link_battle_record sLinkBattleRecord3
-sLinkBattleRecord4:: link_battle_record sLinkBattleRecord4
-sLinkBattleRecord5:: link_battle_record sLinkBattleRecord5
- assert_table_length NUM_LINK_BATTLE_RECORDS
+; sLinkBattleRecord1 - sLinkBattleRecord5
+for n, 1, NUM_LINK_BATTLE_RECORDS + 1
+sLinkBattleRecord{d:n}:: link_battle_record sLinkBattleRecord{d:n}
+endr
sLinkBattleStatsEnd::
@@ -155,38 +128,10 @@
SECTION "SRAM Hall of Fame", SRAM
sHallOfFame::
- table_width HOF_LENGTH, sHallOfFame
-sHallOfFame01:: hall_of_fame sHallOfFame01
-sHallOfFame02:: hall_of_fame sHallOfFame02
-sHallOfFame03:: hall_of_fame sHallOfFame03
-sHallOfFame04:: hall_of_fame sHallOfFame04
-sHallOfFame05:: hall_of_fame sHallOfFame05
-sHallOfFame06:: hall_of_fame sHallOfFame06
-sHallOfFame07:: hall_of_fame sHallOfFame07
-sHallOfFame08:: hall_of_fame sHallOfFame08
-sHallOfFame09:: hall_of_fame sHallOfFame09
-sHallOfFame10:: hall_of_fame sHallOfFame10
-sHallOfFame11:: hall_of_fame sHallOfFame11
-sHallOfFame12:: hall_of_fame sHallOfFame12
-sHallOfFame13:: hall_of_fame sHallOfFame13
-sHallOfFame14:: hall_of_fame sHallOfFame14
-sHallOfFame15:: hall_of_fame sHallOfFame15
-sHallOfFame16:: hall_of_fame sHallOfFame16
-sHallOfFame17:: hall_of_fame sHallOfFame17
-sHallOfFame18:: hall_of_fame sHallOfFame18
-sHallOfFame19:: hall_of_fame sHallOfFame19
-sHallOfFame20:: hall_of_fame sHallOfFame20
-sHallOfFame21:: hall_of_fame sHallOfFame21
-sHallOfFame22:: hall_of_fame sHallOfFame22
-sHallOfFame23:: hall_of_fame sHallOfFame23
-sHallOfFame24:: hall_of_fame sHallOfFame24
-sHallOfFame25:: hall_of_fame sHallOfFame25
-sHallOfFame26:: hall_of_fame sHallOfFame26
-sHallOfFame27:: hall_of_fame sHallOfFame27
-sHallOfFame28:: hall_of_fame sHallOfFame28
-sHallOfFame29:: hall_of_fame sHallOfFame29
-sHallOfFame30:: hall_of_fame sHallOfFame30
- assert_table_length NUM_HOF_TEAMS
+; sHallOfFame1 - sHallOfFame30
+for n, 1, NUM_HOF_TEAMS + 1
+sHallOfFame{d:n}:: hall_of_fame sHallOfFame{d:n}
+endr
sHallOfFameEnd::
@@ -214,39 +159,44 @@
sBattleTowerSaveFileFlags:: db
sBattleTowerReward:: db
-; team of previous trainer
sBTMonOfTrainers::
-sBTMonPrevTrainer1:: db
-sBTMonPrevTrainer2:: db
-sBTMonPrevTrainer3:: db
+; team of previous trainer
+; sBTMonPrevTrainer1 - sBTMonPrevTrainer3
+for n, 1, BATTLETOWER_PARTY_LENGTH + 1
+sBTMonPrevTrainer{d:n}:: db
+endr
; team of preprevious trainer
-sBTMonPrevPrevTrainer1:: db
-sBTMonPrevPrevTrainer2:: db
-sBTMonPrevPrevTrainer3:: db
+; sBTMonPrevPrevTrainer1 - sBTMonPrevPrevTrainer3
+for n, 1, BATTLETOWER_PARTY_LENGTH + 1
+sBTMonPrevPrevTrainer{d:n}:: db
+endr
+; 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}:: box sBox{d:box_n}
+endr
+ENDM
+
SECTION "Boxes 1-7", SRAM
-sBox1:: box sBox1
-sBox2:: box sBox2
-sBox3:: box sBox3
-sBox4:: box sBox4
-sBox5:: box sBox5
-sBox6:: box sBox6
-sBox7:: box sBox7
+; sBox1 - sBox7
+ boxes 7
-
SECTION "Boxes 8-14", SRAM
-sBox8:: box sBox8
-sBox9:: box sBox9
-sBox10:: box sBox10
-sBox11:: box sBox11
-sBox12:: box sBox12
-sBox13:: box sBox13
-sBox14:: box sBox14
+; sBox8 - sBox14
+ boxes 7
+; All 14 boxes fit exactly within 2 SRAM banks
+ assert box_n == NUM_BOXES, \
+ "boxes: Expected {d:NUM_BOXES} total boxes, got {d:box_n}"
+
SECTION "SRAM Mobile 1", SRAM
ds $7
@@ -280,7 +230,7 @@
SECTION "SRAM Mobile 2", SRAM
- ds 1 ; former location for sMobileEventIndex, moved to 1:BE3C in English
+ ds 1 ; JP: location of sMobileEventIndex
sTrainerRankings::
sTrainerRankingGameTimeHOF:: ds 4
@@ -328,7 +278,7 @@
sTrainerRankingsChecksum:: ds 2
sTrainerRankingsEnd::
- ds 1 ; Former location for sMobileEventIndexBackup, moved to 1:BE44 in English
+ ds 1 ; JP: location of sMobileEventIndexBackup
sTrainerRankingsBackup:: ds sTrainerRankingsEnd - sTrainerRankings
--- a/vram.asm
+++ b/vram.asm
@@ -1,16 +1,16 @@
SECTION "VRAM0", VRAM
-vTiles0:: ds $800
-vTiles1:: ds $800
-vTiles2:: ds $800
-vBGMap0:: ds $400
-vBGMap1:: ds $400
+vTiles0:: ds $80 tiles
+vTiles1:: ds $80 tiles
+vTiles2:: ds $80 tiles
+vBGMap0:: ds BG_MAP_WIDTH * BG_MAP_HEIGHT
+vBGMap1:: ds BG_MAP_WIDTH * BG_MAP_HEIGHT
SECTION "VRAM1", VRAM
-vTiles3:: ds $800
-vTiles4:: ds $800
-vTiles5:: ds $800
-vBGMap2:: ds $400
-vBGMap3:: ds $400
+vTiles3:: ds $80 tiles
+vTiles4:: ds $80 tiles
+vTiles5:: ds $80 tiles
+vBGMap2:: ds BG_MAP_WIDTH * BG_MAP_HEIGHT
+vBGMap3:: ds BG_MAP_WIDTH * BG_MAP_HEIGHT
--- a/wram.asm
+++ b/wram.asm
@@ -20,17 +20,10 @@
wMusicPlaying:: db
wAudio::
- table_width CHANNEL_STRUCT_LENGTH, wAudio
-wChannel1:: channel_struct wChannel1
-wChannel2:: channel_struct wChannel2
-wChannel3:: channel_struct wChannel3
-wChannel4:: channel_struct wChannel4
- assert_table_length NUM_MUSIC_CHANS
-wChannel5:: channel_struct wChannel5
-wChannel6:: channel_struct wChannel6
-wChannel7:: channel_struct wChannel7
-wChannel8:: channel_struct wChannel8
- assert_table_length NUM_CHANNELS
+; wChannel1 - wChannel8
+for n, 1, NUM_CHANNELS + 1
+wChannel{d:n}:: channel_struct wChannel{d:n}
+endr
ds 1
@@ -223,20 +216,12 @@
ds NUM_SPRITEANIMDICT_ENTRIES * 2
wSpriteAnimationStructs::
- table_width SPRITEANIMSTRUCT_LENGTH, wSpriteAnimationStructs
+; wSpriteAnim1 - wSpriteAnim10
+for n, 1, NUM_SPRITE_ANIM_STRUCTS + 1
; field 0: index
; fields 1-3: loaded from SpriteAnimSeqData
-wSpriteAnim1:: sprite_anim_struct wSpriteAnim1
-wSpriteAnim2:: sprite_anim_struct wSpriteAnim2
-wSpriteAnim3:: sprite_anim_struct wSpriteAnim3
-wSpriteAnim4:: sprite_anim_struct wSpriteAnim4
-wSpriteAnim5:: sprite_anim_struct wSpriteAnim5
-wSpriteAnim6:: sprite_anim_struct wSpriteAnim6
-wSpriteAnim7:: sprite_anim_struct wSpriteAnim7
-wSpriteAnim8:: sprite_anim_struct wSpriteAnim8
-wSpriteAnim9:: sprite_anim_struct wSpriteAnim9
-wSpriteAnim10:: sprite_anim_struct wSpriteAnim10
- assert_table_length NUM_SPRITE_ANIM_STRUCTS
+wSpriteAnim{d:n}:: sprite_anim_struct wSpriteAnim{d:n}
+endr
wSpriteAnimationStructsEnd::
NEXTU
@@ -323,48 +308,10 @@
SECTION "Sprites", WRAM0
wVirtualOAM::
- table_width SPRITEOAMSTRUCT_LENGTH, wVirtualOAM
-wVirtualOAMSprite00:: sprite_oam_struct wVirtualOAMSprite00
-wVirtualOAMSprite01:: sprite_oam_struct wVirtualOAMSprite01
-wVirtualOAMSprite02:: sprite_oam_struct wVirtualOAMSprite02
-wVirtualOAMSprite03:: sprite_oam_struct wVirtualOAMSprite03
-wVirtualOAMSprite04:: sprite_oam_struct wVirtualOAMSprite04
-wVirtualOAMSprite05:: sprite_oam_struct wVirtualOAMSprite05
-wVirtualOAMSprite06:: sprite_oam_struct wVirtualOAMSprite06
-wVirtualOAMSprite07:: sprite_oam_struct wVirtualOAMSprite07
-wVirtualOAMSprite08:: sprite_oam_struct wVirtualOAMSprite08
-wVirtualOAMSprite09:: sprite_oam_struct wVirtualOAMSprite09
-wVirtualOAMSprite10:: sprite_oam_struct wVirtualOAMSprite10
-wVirtualOAMSprite11:: sprite_oam_struct wVirtualOAMSprite11
-wVirtualOAMSprite12:: sprite_oam_struct wVirtualOAMSprite12
-wVirtualOAMSprite13:: sprite_oam_struct wVirtualOAMSprite13
-wVirtualOAMSprite14:: sprite_oam_struct wVirtualOAMSprite14
-wVirtualOAMSprite15:: sprite_oam_struct wVirtualOAMSprite15
-wVirtualOAMSprite16:: sprite_oam_struct wVirtualOAMSprite16
-wVirtualOAMSprite17:: sprite_oam_struct wVirtualOAMSprite17
-wVirtualOAMSprite18:: sprite_oam_struct wVirtualOAMSprite18
-wVirtualOAMSprite19:: sprite_oam_struct wVirtualOAMSprite19
-wVirtualOAMSprite20:: sprite_oam_struct wVirtualOAMSprite20
-wVirtualOAMSprite21:: sprite_oam_struct wVirtualOAMSprite21
-wVirtualOAMSprite22:: sprite_oam_struct wVirtualOAMSprite22
-wVirtualOAMSprite23:: sprite_oam_struct wVirtualOAMSprite23
-wVirtualOAMSprite24:: sprite_oam_struct wVirtualOAMSprite24
-wVirtualOAMSprite25:: sprite_oam_struct wVirtualOAMSprite25
-wVirtualOAMSprite26:: sprite_oam_struct wVirtualOAMSprite26
-wVirtualOAMSprite27:: sprite_oam_struct wVirtualOAMSprite27
-wVirtualOAMSprite28:: sprite_oam_struct wVirtualOAMSprite28
-wVirtualOAMSprite29:: sprite_oam_struct wVirtualOAMSprite29
-wVirtualOAMSprite30:: sprite_oam_struct wVirtualOAMSprite30
-wVirtualOAMSprite31:: sprite_oam_struct wVirtualOAMSprite31
-wVirtualOAMSprite32:: sprite_oam_struct wVirtualOAMSprite32
-wVirtualOAMSprite33:: sprite_oam_struct wVirtualOAMSprite33
-wVirtualOAMSprite34:: sprite_oam_struct wVirtualOAMSprite34
-wVirtualOAMSprite35:: sprite_oam_struct wVirtualOAMSprite35
-wVirtualOAMSprite36:: sprite_oam_struct wVirtualOAMSprite36
-wVirtualOAMSprite37:: sprite_oam_struct wVirtualOAMSprite37
-wVirtualOAMSprite38:: sprite_oam_struct wVirtualOAMSprite38
-wVirtualOAMSprite39:: sprite_oam_struct wVirtualOAMSprite39
- assert_table_length NUM_SPRITE_OAM_STRUCTS
+; wVirtualOAMSprite00 - wVirtualOAMSprite39
+for n, NUM_SPRITE_OAM_STRUCTS
+wVirtualOAMSprite{02d:n}:: sprite_oam_struct wVirtualOAMSprite{02d:n}
+endr
wVirtualOAMEnd::
@@ -984,66 +931,42 @@
UNION
; link player data
wLinkPlayerData::
- table_width PARTYMON_STRUCT_LENGTH, wLinkPlayerData
-wLinkPlayerPartyMon1:: party_struct wLinkPlayerPartyMon1
-wLinkPlayerPartyMon2:: party_struct wLinkPlayerPartyMon2
-wLinkPlayerPartyMon3:: party_struct wLinkPlayerPartyMon3
-wLinkPlayerPartyMon4:: party_struct wLinkPlayerPartyMon4
-wLinkPlayerPartyMon5:: party_struct wLinkPlayerPartyMon5
-wLinkPlayerPartyMon6:: party_struct wLinkPlayerPartyMon6
- assert_table_length PARTY_LENGTH
+; wLinkPlayerPartyMon1 - wLinkPlayerPartyMon6
+for n, 1, PARTY_LENGTH + 1
+wLinkPlayerPartyMon{d:n}:: party_struct wLinkPlayerPartyMon{d:n}
+endr
wLinkPlayerPartyMonOTs::
- table_width NAME_LENGTH, wLinkPlayerPartyMonOTs
-wLinkPlayerPartyMon1OT:: ds NAME_LENGTH
-wLinkPlayerPartyMon2OT:: ds NAME_LENGTH
-wLinkPlayerPartyMon3OT:: ds NAME_LENGTH
-wLinkPlayerPartyMon4OT:: ds NAME_LENGTH
-wLinkPlayerPartyMon5OT:: ds NAME_LENGTH
-wLinkPlayerPartyMon6OT:: ds NAME_LENGTH
- assert_table_length PARTY_LENGTH
+; wLinkPlayerPartyMon1OT - wLinkPlayerPartyMon6OT
+for n, 1, PARTY_LENGTH + 1
+wLinkPlayerPartyMon{d:n}OT:: ds NAME_LENGTH
+endr
wLinkPlayerPartyMonNicknames::
- table_width MON_NAME_LENGTH, wLinkPlayerPartyMonNicknames
-wLinkPlayerPartyMon1Nickname:: ds MON_NAME_LENGTH
-wLinkPlayerPartyMon2Nickname:: ds MON_NAME_LENGTH
-wLinkPlayerPartyMon3Nickname:: ds MON_NAME_LENGTH
-wLinkPlayerPartyMon4Nickname:: ds MON_NAME_LENGTH
-wLinkPlayerPartyMon5Nickname:: ds MON_NAME_LENGTH
-wLinkPlayerPartyMon6Nickname:: ds MON_NAME_LENGTH
- assert_table_length PARTY_LENGTH
+; wLinkPlayerPartyMon1Nickname - wLinkPlayerPartyMon6Nickname
+for n, 1, PARTY_LENGTH + 1
+wLinkPlayerPartyMon{d:n}Nickname:: ds MON_NAME_LENGTH
+endr
NEXTU
; time capsule party data
wTimeCapsulePlayerData::
- table_width REDMON_STRUCT_LENGTH, wTimeCapsulePlayerData
-wTimeCapsulePartyMon1:: red_party_struct wTimeCapsulePartyMon1
-wTimeCapsulePartyMon2:: red_party_struct wTimeCapsulePartyMon2
-wTimeCapsulePartyMon3:: red_party_struct wTimeCapsulePartyMon3
-wTimeCapsulePartyMon4:: red_party_struct wTimeCapsulePartyMon4
-wTimeCapsulePartyMon5:: red_party_struct wTimeCapsulePartyMon5
-wTimeCapsulePartyMon6:: red_party_struct wTimeCapsulePartyMon6
- assert_table_length PARTY_LENGTH
+; wTimeCapsulePartyMon1 - wTimeCapsulePartyMon6
+for n, 1, PARTY_LENGTH + 1
+wTimeCapsulePartyMon{d:n}:: red_party_struct wTimeCapsulePartyMon{d:n}
+endr
wTimeCapsulePartyMonOTs::
- table_width NAME_LENGTH, wTimeCapsulePartyMonOTs
-wTimeCapsulePartyMon1OT:: ds NAME_LENGTH
-wTimeCapsulePartyMon2OT:: ds NAME_LENGTH
-wTimeCapsulePartyMon3OT:: ds NAME_LENGTH
-wTimeCapsulePartyMon4OT:: ds NAME_LENGTH
-wTimeCapsulePartyMon5OT:: ds NAME_LENGTH
-wTimeCapsulePartyMon6OT:: ds NAME_LENGTH
- assert_table_length PARTY_LENGTH
+; wTimeCapsulePartyMon1OT - wTimeCapsulePartyMon6OT
+for n, 1, PARTY_LENGTH + 1
+wTimeCapsulePartyMon{d:n}OT:: ds NAME_LENGTH
+endr
wTimeCapsulePartyMonNicknames::
- table_width MON_NAME_LENGTH, wTimeCapsulePartyMonNicknames
-wTimeCapsulePartyMon1Nickname:: ds MON_NAME_LENGTH
-wTimeCapsulePartyMon2Nickname:: ds MON_NAME_LENGTH
-wTimeCapsulePartyMon3Nickname:: ds MON_NAME_LENGTH
-wTimeCapsulePartyMon4Nickname:: ds MON_NAME_LENGTH
-wTimeCapsulePartyMon5Nickname:: ds MON_NAME_LENGTH
-wTimeCapsulePartyMon6Nickname:: ds MON_NAME_LENGTH
- assert_table_length PARTY_LENGTH
+; wTimeCapsulePartyMon1Nickname - wTimeCapsulePartyMon6Nickname
+for n, 1, PARTY_LENGTH + 1
+wTimeCapsulePartyMon{d:n}Nickname:: ds MON_NAME_LENGTH
+endr
NEXTU
; link patch lists
@@ -1057,14 +980,10 @@
wCurLinkOTPartyMonTypePointer:: dw
wLinkOTPartyMonTypes::
- table_width 2, wLinkOTPartyMonTypes
-wLinkOTPartyMon1Type:: dw
-wLinkOTPartyMon2Type:: dw
-wLinkOTPartyMon3Type:: dw
-wLinkOTPartyMon4Type:: dw
-wLinkOTPartyMon5Type:: dw
-wLinkOTPartyMon6Type:: dw
- assert_table_length PARTY_LENGTH
+; wLinkOTPartyMon1Type - wLinkOTPartyMon6Type
+for n, 1, PARTY_LENGTH + 1
+wLinkOTPartyMon{d:n}Type:: dw
+endr
NEXTU
; link mail data
@@ -2612,34 +2531,22 @@
UNION
; ot party mons
wOTPartyMons::
- table_width PARTYMON_STRUCT_LENGTH, wOTPartyMons
-wOTPartyMon1:: party_struct wOTPartyMon1
-wOTPartyMon2:: party_struct wOTPartyMon2
-wOTPartyMon3:: party_struct wOTPartyMon3
-wOTPartyMon4:: party_struct wOTPartyMon4
-wOTPartyMon5:: party_struct wOTPartyMon5
-wOTPartyMon6:: party_struct wOTPartyMon6
- assert_table_length PARTY_LENGTH
+; wOTPartyMon1 - wOTPartyMon6
+for n, 1, PARTY_LENGTH + 1
+wOTPartyMon{d:n}:: party_struct wOTPartyMon{d:n}
+endr
wOTPartyMonOTs::
- table_width NAME_LENGTH, wOTPartyMonOTs
-wOTPartyMon1OT:: ds NAME_LENGTH
-wOTPartyMon2OT:: ds NAME_LENGTH
-wOTPartyMon3OT:: ds NAME_LENGTH
-wOTPartyMon4OT:: ds NAME_LENGTH
-wOTPartyMon5OT:: ds NAME_LENGTH
-wOTPartyMon6OT:: ds NAME_LENGTH
- assert_table_length PARTY_LENGTH
+; wOTPartyMon1OT - wOTPartyMon6OT
+for n, 1, PARTY_LENGTH + 1
+wOTPartyMon{d:n}OT:: ds NAME_LENGTH
+endr
wOTPartyMonNicknames::
- table_width MON_NAME_LENGTH, wOTPartyMonNicknames
-wOTPartyMon1Nickname:: ds MON_NAME_LENGTH
-wOTPartyMon2Nickname:: ds MON_NAME_LENGTH
-wOTPartyMon3Nickname:: ds MON_NAME_LENGTH
-wOTPartyMon4Nickname:: ds MON_NAME_LENGTH
-wOTPartyMon5Nickname:: ds MON_NAME_LENGTH
-wOTPartyMon6Nickname:: ds MON_NAME_LENGTH
- assert_table_length PARTY_LENGTH
+; wOTPartyMon1Nickname - wOTPartyMon6Nickname
+for n, 1, PARTY_LENGTH + 1
+wOTPartyMon{d:n}Nickname:: ds MON_NAME_LENGTH
+endr
wOTPartyDataEnd::
NEXTU
@@ -2791,21 +2698,11 @@
wFollowMovementQueue:: ds 5
wObjectStructs::
- table_width OBJECT_LENGTH, wObjectStructs
-wPlayerStruct:: object_struct wPlayer
-wObject1Struct:: object_struct wObject1
-wObject2Struct:: object_struct wObject2
-wObject3Struct:: object_struct wObject3
-wObject4Struct:: object_struct wObject4
-wObject5Struct:: object_struct wObject5
-wObject6Struct:: object_struct wObject6
-wObject7Struct:: object_struct wObject7
-wObject8Struct:: object_struct wObject8
-wObject9Struct:: object_struct wObject9
-wObject10Struct:: object_struct wObject10
-wObject11Struct:: object_struct wObject11
-wObject12Struct:: object_struct wObject12
- assert_table_length NUM_OBJECT_STRUCTS
+wPlayerStruct:: object_struct wPlayer ; player is object struct 0
+; wObjectStruct1 - wObjectStruct12
+for n, 1, NUM_OBJECT_STRUCTS
+wObject{d:n}Struct:: object_struct wObject{d:n}
+endr
wCmdQueue:: ds CMDQUEUE_CAPACITY * CMDQUEUE_ENTRY_SIZE
@@ -2812,24 +2709,11 @@
ds 40
wMapObjects::
- table_width MAPOBJECT_LENGTH, wMapObjects
-wPlayerObject:: map_object wPlayer
-wMap1Object:: map_object wMap1
-wMap2Object:: map_object wMap2
-wMap3Object:: map_object wMap3
-wMap4Object:: map_object wMap4
-wMap5Object:: map_object wMap5
-wMap6Object:: map_object wMap6
-wMap7Object:: map_object wMap7
-wMap8Object:: map_object wMap8
-wMap9Object:: map_object wMap9
-wMap10Object:: map_object wMap10
-wMap11Object:: map_object wMap11
-wMap12Object:: map_object wMap12
-wMap13Object:: map_object wMap13
-wMap14Object:: map_object wMap14
-wMap15Object:: map_object wMap15
- assert_table_length NUM_OBJECTS
+wPlayerObject:: map_object wPlayer ; player is map object 0
+; wMap1Object - wMap15Object
+for n, 1, NUM_OBJECTS
+wMap{d:n}Object:: map_object wMap{d:n}
+endr
wObjectMasks:: ds NUM_OBJECTS
@@ -3193,34 +3077,22 @@
wPartyEnd:: db ; older code doesn't check wPartyCount
wPartyMons::
- table_width PARTYMON_STRUCT_LENGTH, 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
- assert_table_length PARTY_LENGTH
+; wPartyMon1 - wPartyMon6
+for n, 1, PARTY_LENGTH + 1
+wPartyMon{d:n}:: party_struct wPartyMon{d:n}
+endr
wPartyMonOTs::
- table_width NAME_LENGTH, wPartyMonOTs
-wPartyMon1OT:: ds NAME_LENGTH
-wPartyMon2OT:: ds NAME_LENGTH
-wPartyMon3OT:: ds NAME_LENGTH
-wPartyMon4OT:: ds NAME_LENGTH
-wPartyMon5OT:: ds NAME_LENGTH
-wPartyMon6OT:: ds NAME_LENGTH
- assert_table_length PARTY_LENGTH
+; wPartyMon1OT - wPartyMon6OT
+for n, 1, PARTY_LENGTH + 1
+wPartyMon{d:n}OT:: ds NAME_LENGTH
+endr
wPartyMonNicknames::
- table_width MON_NAME_LENGTH, wPartyMonNicknames
-wPartyMon1Nickname:: ds MON_NAME_LENGTH
-wPartyMon2Nickname:: ds MON_NAME_LENGTH
-wPartyMon3Nickname:: ds MON_NAME_LENGTH
-wPartyMon4Nickname:: ds MON_NAME_LENGTH
-wPartyMon5Nickname:: ds MON_NAME_LENGTH
-wPartyMon6Nickname:: ds MON_NAME_LENGTH
- assert_table_length PARTY_LENGTH
+; wPartyMon1Nickname - wPartyMon6Nickname
+for n, 1, PARTY_LENGTH + 1
+wPartyMon{d:n}Nickname:: ds MON_NAME_LENGTH
+endr
wPartyMonNicknamesEnd::
ds 22
@@ -3437,27 +3309,16 @@
ds NUM_BATTLEANIMTILEDICT_ENTRIES * 2
wActiveAnimObjects::
- table_width BATTLEANIMSTRUCT_LENGTH, wActiveAnimObjects
-wAnimObject01:: battle_anim_struct wAnimObject01
-wAnimObject02:: battle_anim_struct wAnimObject02
-wAnimObject03:: battle_anim_struct wAnimObject03
-wAnimObject04:: battle_anim_struct wAnimObject04
-wAnimObject05:: battle_anim_struct wAnimObject05
-wAnimObject06:: battle_anim_struct wAnimObject06
-wAnimObject07:: battle_anim_struct wAnimObject07
-wAnimObject08:: battle_anim_struct wAnimObject08
-wAnimObject09:: battle_anim_struct wAnimObject09
-wAnimObject10:: battle_anim_struct wAnimObject10
- assert_table_length NUM_ANIM_OBJECTS
+; wAnimObject1 - wAnimObject10
+for n, 1, NUM_ANIM_OBJECTS + 1
+wAnimObject{d:n}:: battle_anim_struct wAnimObject{d:n}
+endr
wActiveBGEffects::
- table_width BG_EFFECT_STRUCT_LENGTH, wActiveBGEffects
-wBGEffect1:: battle_bg_effect wBGEffect1
-wBGEffect2:: battle_bg_effect wBGEffect2
-wBGEffect3:: battle_bg_effect wBGEffect3
-wBGEffect4:: battle_bg_effect wBGEffect4
-wBGEffect5:: battle_bg_effect wBGEffect5
- assert_table_length NUM_BG_EFFECTS
+; wBGEffect1 - wBGEffect5
+for n, 1, NUM_BG_EFFECTS + 1
+wBGEffect{d:n}:: battle_bg_effect wBGEffect{d:n}
+endr
wLastAnimObjectIndex:: db