From 4883950318b294abffbf0e29a7c41b05131d3406 Mon Sep 17 00:00:00 2001 From: Rangi Date: Wed, 31 Aug 2022 18:03:49 -0400 Subject: [PATCH] Use `for` loops to generate box pointer tables Fixes #996 --- engine/debug/debug_room.asm | 17 +++-------------- engine/events/lucky_number.asm | 17 +++-------------- engine/menus/save.asm | 24 ++++------------------- engine/pokemon/bills_pc.asm | 34 ++++++--------------------------- engine/pokemon/bills_pc_top.asm | 17 +++-------------- engine/pokemon/search_owned.asm | 17 +++-------------- mobile/mobile_12_2.asm | 17 +++-------------- 7 files changed, 25 insertions(+), 118 deletions(-) diff --git a/engine/debug/debug_room.asm b/engine/debug/debug_room.asm index f464d7ada..245f31d9b 100644 --- a/engine/debug/debug_room.asm +++ b/engine/debug/debug_room.asm @@ -1356,20 +1356,9 @@ DebugRoom_BoxStructStrings: DebugRoom_BoxAddresses: table_width 3, DebugRoom_BoxAddresses - dba sBox1 - dba sBox2 - dba sBox3 - dba sBox4 - dba sBox5 - dba sBox6 - dba sBox7 - dba sBox8 - dba sBox9 - dba sBox10 - dba sBox11 - dba sBox12 - dba sBox13 - dba sBox14 +for n, 1, NUM_BOXES + 1 + dba sBox{d:n} +endr assert_table_length NUM_BOXES DebugRoomMenu_RTCEdit: diff --git a/engine/events/lucky_number.asm b/engine/events/lucky_number.asm index ea0c55e08..375b817b8 100644 --- a/engine/events/lucky_number.asm +++ b/engine/events/lucky_number.asm @@ -193,20 +193,9 @@ CheckForLuckyNumberWinners: .BoxBankAddresses: table_width 3, CheckForLuckyNumberWinners.BoxBankAddresses - dba sBox1 - dba sBox2 - dba sBox3 - dba sBox4 - dba sBox5 - dba sBox6 - dba sBox7 - dba sBox8 - dba sBox9 - dba sBox10 - dba sBox11 - dba sBox12 - dba sBox13 - dba sBox14 +for n, 1, NUM_BOXES + 1 + dba sBox{d:n} +endr assert_table_length NUM_BOXES .LuckyNumberMatchPartyText: diff --git a/engine/menus/save.asm b/engine/menus/save.asm index 5057f427e..00076de1b 100644 --- a/engine/menus/save.asm +++ b/engine/menus/save.asm @@ -1068,28 +1068,12 @@ EraseBoxes: jr nz, .next ret -MACRO box_address - assert BANK(\1) == BANK(\2) - db BANK(\1) - dw \1, \2 -ENDM - BoxAddresses: table_width 5, BoxAddresses - box_address sBox1, sBox1End - box_address sBox2, sBox2End - box_address sBox3, sBox3End - box_address sBox4, sBox4End - box_address sBox5, sBox5End - box_address sBox6, sBox6End - box_address sBox7, sBox7End - box_address sBox8, sBox8End - box_address sBox9, sBox9End - box_address sBox10, sBox10End - box_address sBox11, sBox11End - box_address sBox12, sBox12End - box_address sBox13, sBox13End - box_address sBox14, sBox14End +for n, 1, NUM_BOXES + 1 + db BANK(sBox{d:n}) ; aka BANK(sBox{d:n}End) + dw sBox{d:n}, sBox{d:n}End +endr assert_table_length NUM_BOXES Checksum: diff --git a/engine/pokemon/bills_pc.asm b/engine/pokemon/bills_pc.asm index 7f23e698b..d569ff749 100644 --- a/engine/pokemon/bills_pc.asm +++ b/engine/pokemon/bills_pc.asm @@ -2153,20 +2153,9 @@ GetBoxPointer: .BoxBankAddresses: table_width 3, GetBoxPointer.BoxBankAddresses - dba sBox1 - dba sBox2 - dba sBox3 - dba sBox4 - dba sBox5 - dba sBox6 - dba sBox7 - dba sBox8 - dba sBox9 - dba sBox10 - dba sBox11 - dba sBox12 - dba sBox13 - dba sBox14 +for n, 1, NUM_BOXES + 1 + dba sBox{d:n} +endr assert_table_length NUM_BOXES BillsPC_ApplyPalettes: @@ -2371,20 +2360,9 @@ GetBoxCount: .BoxBankAddresses: table_width 3, GetBoxCount.BoxBankAddresses - dba sBox1 - dba sBox2 - dba sBox3 - dba sBox4 - dba sBox5 - dba sBox6 - dba sBox7 - dba sBox8 - dba sBox9 - dba sBox10 - dba sBox11 - dba sBox12 - dba sBox13 - dba sBox14 +for n, 1, NUM_BOXES + 1 + dba sBox{d:n} +endr assert_table_length NUM_BOXES BillsPC_PrintBoxName: diff --git a/engine/pokemon/bills_pc_top.asm b/engine/pokemon/bills_pc_top.asm index 480adefa1..fa5833aef 100644 --- a/engine/pokemon/bills_pc_top.asm +++ b/engine/pokemon/bills_pc_top.asm @@ -366,18 +366,7 @@ LoadBoxMonListing: ; unreferenced .BoxAddresses: table_width 3, LoadBoxMonListing.BoxAddresses - dba sBox1 - dba sBox2 - dba sBox3 - dba sBox4 - dba sBox5 - dba sBox6 - dba sBox7 - dba sBox8 - dba sBox9 - dba sBox10 - dba sBox11 - dba sBox12 - dba sBox13 - dba sBox14 +for n, 1, NUM_BOXES + 1 + dba sBox{d:n} +endr assert_table_length NUM_BOXES diff --git a/engine/pokemon/search_owned.asm b/engine/pokemon/search_owned.asm index 706634c73..2edb987eb 100644 --- a/engine/pokemon/search_owned.asm +++ b/engine/pokemon/search_owned.asm @@ -253,20 +253,9 @@ endr SearchBoxAddressTable: table_width 3, SearchBoxAddressTable - dba sBox1 - dba sBox2 - dba sBox3 - dba sBox4 - dba sBox5 - dba sBox6 - dba sBox7 - dba sBox8 - dba sBox9 - dba sBox10 - dba sBox11 - dba sBox12 - dba sBox13 - dba sBox14 +for n, 1, NUM_BOXES + 1 + dba sBox{d:n} +endr assert_table_length NUM_BOXES UpdateOTPointer: diff --git a/mobile/mobile_12_2.asm b/mobile/mobile_12_2.asm index c57bc8a78..1171f6b89 100644 --- a/mobile/mobile_12_2.asm +++ b/mobile/mobile_12_2.asm @@ -174,20 +174,9 @@ MobileCheckOwnMonAnywhere: .BoxAddresses: table_width 3, MobileCheckOwnMonAnywhere.BoxAddresses - dba sBox1 - dba sBox2 - dba sBox3 - dba sBox4 - dba sBox5 - dba sBox6 - dba sBox7 - dba sBox8 - dba sBox9 - dba sBox10 - dba sBox11 - dba sBox12 - dba sBox13 - dba sBox14 +for n, 1, NUM_BOXES + 1 + dba sBox{d:n} +endr assert_table_length NUM_BOXES .AdvanceOTName: