ref: 0506e5b1b9d755aad006a52d9f9c9c9baea710fb
parent: 7fd23ae918f132772e9282830b6aaa353e9e5244
author: Rangi <[email protected]>
date: Sun Mar 21 13:47:53 EDT 2021
Assert the sBox1-14 tables have NUM_BOXES entries
--- a/constants/pokemon_data_constants.asm
+++ b/constants/pokemon_data_constants.asm
@@ -135,7 +135,7 @@
; boxes
MONS_PER_BOX EQU 20
-NUM_BOXES EQU 14
+NUM_BOXES EQU 14
; hall of fame
HOF_MON_LENGTH EQU 1 + 2 + 2 + 1 + (MON_NAME_LENGTH - 1) ; species, id, dvs, level, nick
--- a/engine/debug/debug_room.asm
+++ b/engine/debug/debug_room.asm
@@ -1355,6 +1355,7 @@
.SendBox: db "SEND BOX@"
DebugRoom_BoxAddresses:
+ table_width 3, DebugRoom_BoxAddresses
dba sBox1
dba sBox2
dba sBox3
@@ -1369,6 +1370,7 @@
dba sBox12
dba sBox13
dba sBox14
+ assert_table_length NUM_BOXES
DebugRoomMenu_RTCEdit:
ld hl, .PagedValuesHeader
--- a/engine/events/lucky_number.asm
+++ b/engine/events/lucky_number.asm
@@ -192,6 +192,7 @@
ret
.BoxBankAddresses:
+ table_width 3, CheckForLuckyNumberWinners.BoxBankAddresses
dba sBox1
dba sBox2
dba sBox3
@@ -206,6 +207,7 @@
dba sBox12
dba sBox13
dba sBox14
+ assert_table_length NUM_BOXES
.LuckyNumberMatchPartyText:
text_far _LuckyNumberMatchPartyText
--- a/engine/pokemon/bills_pc.asm
+++ b/engine/pokemon/bills_pc.asm
@@ -2140,7 +2140,7 @@
dec b
ld c, b
ld b, 0
- ld hl, .boxes
+ ld hl, .BoxBankAddresses
add hl, bc
add hl, bc
add hl, bc
@@ -2151,8 +2151,8 @@
ld l, a
ret
-.boxes
- ; bank, address
+.BoxBankAddresses:
+ table_width 3, GetBoxPointer.BoxBankAddresses
dba sBox1
dba sBox2
dba sBox3
@@ -2167,6 +2167,7 @@
dba sBox12
dba sBox13
dba sBox14
+ assert_table_length NUM_BOXES
BillsPC_ApplyPalettes:
ld b, a
@@ -2319,7 +2320,7 @@
ld de, wTextDecimalByte
lb bc, 1, 2
call PrintNum
- ld de, .out_of_20
+ ld de, .OutOf20
call PlaceString
ret
@@ -2326,12 +2327,8 @@
.Pokemon:
db "#MON@"
-.out_of_20
- ; db "/20@"
- db "/"
- db "0" + MONS_PER_BOX / 10 ; "2"
- db "0" + MONS_PER_BOX % 10 ; "0"
- db "@"
+.OutOf20:
+ db "/{d:MONS_PER_BOX}@" ; "/20@"
GetBoxCount:
ld a, [wCurBox]
@@ -2342,7 +2339,7 @@
jr z, .activebox
ld c, a
ld b, 0
- ld hl, .boxbanks
+ ld hl, .BoxBankAddresses
add hl, bc
add hl, bc
add hl, bc
@@ -2374,7 +2371,8 @@
call CloseSRAM
ret
-.boxbanks
+.BoxBankAddresses:
+ table_width 3, GetBoxCount.BoxBankAddresses
dba sBox1
dba sBox2
dba sBox3
@@ -2389,6 +2387,7 @@
dba sBox12
dba sBox13
dba sBox14
+ assert_table_length NUM_BOXES
BillsPC_PrintBoxName:
hlcoord 0, 0
--- a/engine/pokemon/bills_pc_top.asm
+++ b/engine/pokemon/bills_pc_top.asm
@@ -266,7 +266,7 @@
cp b
jr z, .same_box
ld a, b
- ld hl, .BoxAddrs
+ ld hl, .BoxAddresses
ld bc, 3
call AddNTimes
ld a, [hli]
@@ -364,7 +364,8 @@
call CloseSRAM
ret
-.BoxAddrs:
+.BoxAddresses:
+ table_width 3, LoadBoxMonListing.BoxAddresses
dba sBox1
dba sBox2
dba sBox3
@@ -379,3 +380,4 @@
dba sBox12
dba sBox13
dba sBox14
+ assert_table_length NUM_BOXES
--- a/engine/pokemon/search.asm
+++ b/engine/pokemon/search.asm
@@ -113,7 +113,7 @@
jr z, .loopbox
; Load the box.
- ld hl, BoxAddressTable
+ ld hl, SearchBoxAddressTable
ld b, 0
add hl, bc
add hl, bc
@@ -244,7 +244,8 @@
scf
ret
-BoxAddressTable:
+SearchBoxAddressTable:
+ table_width 3, SearchBoxAddressTable
dba sBox1
dba sBox2
dba sBox3
@@ -259,6 +260,7 @@
dba sBox12
dba sBox13
dba sBox14
+ assert_table_length NUM_BOXES
UpdateOTPointer:
push hl
--- a/mobile/mobile_12_2.asm
+++ b/mobile/mobile_12_2.asm
@@ -51,7 +51,7 @@
and $f
cp c
jr z, .asm_4a8d1
- ld hl, .BoxAddrs
+ ld hl, .BoxAddresses
ld b, 0
add hl, bc
add hl, bc
@@ -130,7 +130,8 @@
scf
ret
-.BoxAddrs:
+.BoxAddresses:
+ table_width 3, MobileCheckOwnMonAnywhere.BoxAddresses
dba sBox1
dba sBox2
dba sBox3
@@ -145,6 +146,7 @@
dba sBox12
dba sBox13
dba sBox14
+ assert_table_length NUM_BOXES
.AdvanceOTName:
push hl