aboutsummaryrefslogtreecommitdiffstats
path: root/macros
diff options
context:
space:
mode:
authordannye <33dannye@gmail.com>2026-01-17 22:38:33 -0600
committerdannye <33dannye@gmail.com>2026-01-17 22:38:33 -0600
commitbc2354dd6626ce28bb9561547ed2107cfa56c18e (patch)
tree5902d4c3389253c76b7c3351e0d7dfecb551c28d /macros
parentIdentify characters in `_OakSpeechText2B` and `Printer_GetMonStats.IDNo` (#144) (diff)
parentUse macros for `WildMonEncounterSlotChances` (#562) (diff)
downloadpokeyellow-bc2354dd6626ce28bb9561547ed2107cfa56c18e.tar.gz
pokeyellow-bc2354dd6626ce28bb9561547ed2107cfa56c18e.tar.xz
pokeyellow-bc2354dd6626ce28bb9561547ed2107cfa56c18e.zip
Merge branch 'master' of https://github.com/pret/pokered
Diffstat (limited to 'macros')
-rw-r--r--macros/asserts.asm18
-rw-r--r--macros/code.asm8
-rw-r--r--macros/farcall.asm7
-rw-r--r--macros/ram.asm2
-rw-r--r--macros/scripts/events.asm2
5 files changed, 30 insertions, 7 deletions
diff --git a/macros/asserts.asm b/macros/asserts.asm
index e2de1505..11e0ee99 100644
--- a/macros/asserts.asm
+++ b/macros/asserts.asm
@@ -4,8 +4,8 @@ MACRO? _redef_current_label
IF DEF(\1)
PURGE \1
ENDC
- IF _NARG == 3 + (\3)
- DEF \1 EQUS "\<_NARG>"
+ IF _NARG > 2
+ DEF \1 EQUS "\3"
ELIF STRLEN(#__SCOPE__)
IF {{__SCOPE__}} - @ == 0
DEF \1 EQUS #{__SCOPE__}
@@ -19,7 +19,8 @@ ENDM
MACRO? table_width
DEF CURRENT_TABLE_WIDTH = \1
- _redef_current_label CURRENT_TABLE_START, "._table_width\@", 2, \#
+ SHIFT
+ _redef_current_label CURRENT_TABLE_START, "._table_width\@", \#
ENDM
MACRO? assert_table_length
@@ -40,11 +41,20 @@ ENDM
MACRO? list_start
DEF list_index = 0
- _redef_current_label CURRENT_LIST_START, "._list_start\@", 1, \#
+ DEF list_item_length = 0
+ IF _NARG > 0
+ DEF list_item_length = \1
+ SHIFT
+ ENDC
+ _redef_current_label CURRENT_LIST_START, "._list_start\@", \#
ENDM
MACRO? li
ASSERT STRFIND(\1, "@") == -1, "String terminator \"@\" in list entry: \1"
+ IF list_item_length
+ ASSERT CHARLEN(\1) <= list_item_length, \
+ "List entry longer than {d:list_item_length} characters: \1"
+ ENDC
db \1, "@"
DEF list_index += 1
ENDM
diff --git a/macros/code.asm b/macros/code.asm
index c972f97e..70ff4249 100644
--- a/macros/code.asm
+++ b/macros/code.asm
@@ -10,6 +10,14 @@ ENDM
; Design patterns
+MACRO ld_hli_a_string
+ FOR n, CHARLEN(\1) - 1
+ ld a, CHARVAL(STRCHAR(\1, n))
+ ld [hli], a
+ ENDR
+ ld [hl], CHARVAL(STRCHAR(\1, CHARLEN(\1) - 1))
+ENDM
+
MACRO dict
IF \1 == 0
and a
diff --git a/macros/farcall.asm b/macros/farcall.asm
index e8bf8e9c..e3e11a0f 100644
--- a/macros/farcall.asm
+++ b/macros/farcall.asm
@@ -1,3 +1,10 @@
+; Far calls to another bank
+
+; There is no difference between `farcall` and `callfar`, except the arbitrary
+; order in which they set `b` and `hl` before calling `FarCall`.
+; We use the more natural name "farcall" for the more common order.
+; The same goes for `farjp` and `jpfar`.
+
MACRO farcall
ld b, BANK(\1)
ld hl, \1
diff --git a/macros/ram.asm b/macros/ram.asm
index a8deac76..24a3a9bd 100644
--- a/macros/ram.asm
+++ b/macros/ram.asm
@@ -4,8 +4,6 @@ MACRO? flag_array
ds ((\1) + 7) / 8
ENDM
-DEF BOX_STRUCT_LENGTH EQU 25 + NUM_MOVES * 2
-
MACRO box_struct
\1Species:: db
\1HP:: dw
diff --git a/macros/scripts/events.asm b/macros/scripts/events.asm
index c5b494dd..ed01c0c7 100644
--- a/macros/scripts/events.asm
+++ b/macros/scripts/events.asm
@@ -374,7 +374,7 @@ MACRO ResetEventRange
IF event_fill_count > 1
ld hl, wEventFlags + event_fill_start
- ; force xor a if we just to wrote to it above
+ ; force xor a if we just wrote to it above
IF (_NARG < 3) || (((\1) % 8) != 0)
xor a
ENDC