shithub: pokecrystal

Download patch

ref: 4883950318b294abffbf0e29a7c41b05131d3406
parent: c7dee19a48f6ca91faf8961cac1ddc000e23835c
author: Rangi <remy.oukaour+rangi42@gmail.com>
date: Wed Aug 31 14:03:49 EDT 2022

Use `for` loops to generate box pointer tables

Fixes #996

--- a/engine/debug/debug_room.asm
+++ b/engine/debug/debug_room.asm
@@ -1356,20 +1356,9 @@
 
 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:
--- a/engine/events/lucky_number.asm
+++ b/engine/events/lucky_number.asm
@@ -193,20 +193,9 @@
 
 .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:
--- a/engine/menus/save.asm
+++ b/engine/menus/save.asm
@@ -1068,28 +1068,12 @@
 	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:
--- a/engine/pokemon/bills_pc.asm
+++ b/engine/pokemon/bills_pc.asm
@@ -2153,20 +2153,9 @@
 
 .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 @@
 
 .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:
--- a/engine/pokemon/bills_pc_top.asm
+++ b/engine/pokemon/bills_pc_top.asm
@@ -366,18 +366,7 @@
 
 .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
--- a/engine/pokemon/search_owned.asm
+++ b/engine/pokemon/search_owned.asm
@@ -253,20 +253,9 @@
 
 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:
--- a/mobile/mobile_12_2.asm
+++ b/mobile/mobile_12_2.asm
@@ -174,20 +174,9 @@
 
 .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: