Skip to content

Commit 1cc2216

Browse files
committed
Verify the mart types pointer table length
1 parent 1fd034d commit 1cc2216

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

constants/mart_constants.asm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
const MARTTYPE_BARGAIN
66
const MARTTYPE_PHARMACY
77
const MARTTYPE_ROOFTOP
8+
DEF NUM_MART_TYPES EQU const_value
89

910
; Marts indexes (see data/items/marts.asm)
1011
const_def

engine/items/mart.asm

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,19 @@ OpenMartDialog::
1212
ld [wMartType], a
1313
call LoadMartPointer
1414
ld a, [wMartType]
15-
ld hl, .dialogs
15+
ld hl, MartTypeDialogs
1616
rst JumpTable
1717
ret
1818

19-
.dialogs
19+
MartTypeDialogs:
20+
; entries correspond to MARTTYPE_* constants
21+
table_width 2
2022
dw MartDialog
2123
dw HerbShop
2224
dw BargainShop
2325
dw Pharmacist
2426
dw RooftopSale
27+
assert_table_length NUM_MART_TYPES
2528

2629
MartDialog:
2730
ld a, MARTTYPE_STANDARD

0 commit comments

Comments
 (0)