From 8edbad78e5787ffd5632a30cb8d38f5bf88dce5e Mon Sep 17 00:00:00 2001 From: Deokishisu Date: Wed, 19 Dec 2018 12:20:38 -0500 Subject: Add requirements to the fields of the object_event macro With these changes, the compiler will yell at you if you screw up the number of fields for your event objects while manually editing a map's events.inc. Making these fields required will prevent event corruption of all map events that are included after the map with the messed up fields. --- asm/macros/map.inc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'asm/macros') diff --git a/asm/macros/map.inc b/asm/macros/map.inc index 9a028b2e5..aabcc1bd5 100644 --- a/asm/macros/map.inc +++ b/asm/macros/map.inc @@ -14,8 +14,7 @@ .4byte \address .endm - .macro object_event index, gfx, replacement, x, y, elevation, movement_type, x_radius, y_radius, trainer_type, sight_radius_tree_etc, script, event_flag - .byte \index, \gfx, \replacement, 0 + .macro object_event index:req, gfx:req, replacement:req, x:req, y:req, elevation:req, movement_type:req, x_radius:req, y_radius:req, trainer_type:req, sight_radius_tree_etc:req, script:req, event_flag:req .2byte \x .2byte \y .byte \elevation, \movement_type, ((\y_radius << 4) | \x_radius), 0 -- cgit v1.2.3 From e15c7fc7cf770231548de57ef55f0747e6d63fd7 Mon Sep 17 00:00:00 2001 From: Deokishisu Date: Wed, 19 Dec 2018 12:28:37 -0500 Subject: Fix deleted line --- asm/macros/map.inc | 1 + 1 file changed, 1 insertion(+) (limited to 'asm/macros') diff --git a/asm/macros/map.inc b/asm/macros/map.inc index aabcc1bd5..94caeb697 100644 --- a/asm/macros/map.inc +++ b/asm/macros/map.inc @@ -15,6 +15,7 @@ .endm .macro object_event index:req, gfx:req, replacement:req, x:req, y:req, elevation:req, movement_type:req, x_radius:req, y_radius:req, trainer_type:req, sight_radius_tree_etc:req, script:req, event_flag:req + .byte \index, \gfx, \replacement, 0 .2byte \x .2byte \y .byte \elevation, \movement_type, ((\y_radius << 4) | \x_radius), 0 -- cgit v1.2.3 From ac2e4adf2da2f30a741556e20e5bc9a494997581 Mon Sep 17 00:00:00 2001 From: Melody Date: Fri, 21 Dec 2018 20:28:24 -0500 Subject: improve goto_if macros --- asm/macros/event.inc | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) (limited to 'asm/macros') diff --git a/asm/macros/event.inc b/asm/macros/event.inc index c815f3753..074a22443 100644 --- a/asm/macros/event.inc +++ b/asm/macros/event.inc @@ -1557,17 +1557,47 @@ @ Supplementary - .macro goto_eq dest:req + .macro goto_if_unset flag, dest + checkflag \flag + goto_if 0, \dest + .endm + + .macro goto_if_set flag, dest + checkflag \flag goto_if 1, \dest .endm + .macro goto_if_lt dest @ LESS THAN + goto_if 0, \dest + .endm + + .macro goto_if_eq dest @ EQUAL + goto_if 1, \dest + .endm + + .macro goto_if_gt dest @ GREATER THAN + goto_if 2, \dest + .endm + + .macro goto_if_le dest @ LESS THAN OR EQUAL + goto_if 3, \dest + .endm + + .macro goto_if_ge dest @ GREATER THAN OR EQUAL + goto_if 4, \dest + .endm + + .macro goto_if_ne dest @ NOT EQUAL + goto_if 5, \dest + .endm + .macro switch var:req copyvar 0x8000, \var .endm .macro case condition:req, dest:req compare 0x8000, \condition - goto_eq \dest + goto_if_eq \dest .endm @ Message box types -- cgit v1.2.3 From 55005f1588fed924bb86c420458371bf99a88e0e Mon Sep 17 00:00:00 2001 From: Melody Date: Fri, 21 Dec 2018 21:32:45 -0500 Subject: improve call_if macros --- asm/macros/event.inc | 50 ++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 42 insertions(+), 8 deletions(-) (limited to 'asm/macros') diff --git a/asm/macros/event.inc b/asm/macros/event.inc index 074a22443..ba851d70a 100644 --- a/asm/macros/event.inc +++ b/asm/macros/event.inc @@ -1557,40 +1557,74 @@ @ Supplementary - .macro goto_if_unset flag, dest + .macro goto_if_unset flag:req, dest:req checkflag \flag goto_if 0, \dest .endm - .macro goto_if_set flag, dest + .macro goto_if_set flag:req, dest:req checkflag \flag goto_if 1, \dest .endm - .macro goto_if_lt dest @ LESS THAN + .macro goto_if_lt dest:req @ LESS THAN goto_if 0, \dest .endm - .macro goto_if_eq dest @ EQUAL + .macro goto_if_eq dest:req @ EQUAL goto_if 1, \dest .endm - .macro goto_if_gt dest @ GREATER THAN + .macro goto_if_gt dest:req @ GREATER THAN goto_if 2, \dest .endm - .macro goto_if_le dest @ LESS THAN OR EQUAL + .macro goto_if_le dest:req @ LESS THAN OR EQUAL goto_if 3, \dest .endm - .macro goto_if_ge dest @ GREATER THAN OR EQUAL + .macro goto_if_ge dest:req @ GREATER THAN OR EQUAL goto_if 4, \dest .endm - .macro goto_if_ne dest @ NOT EQUAL + .macro goto_if_ne dest:req @ NOT EQUAL goto_if 5, \dest .endm + .macro call_if_unset flag:req, dest:req + checkflag \flag + call_if 0, \dest + .endm + + .macro call_if_set flag:req, dest:req + checkflag \flag + call_if 1, \dest + .endm + + .macro call_if_lt dest:req @ LESS THAN + call_if 0, \dest + .endm + + .macro call_if_eq dest:req @ EQUAL + call_if 1, \dest + .endm + + .macro call_if_gt dest:req @ GREATER THAN + call_if 2, \dest + .endm + + .macro call_if_le dest:req @ LESS THAN OR EQUAL + call_if 3, \dest + .endm + + .macro call_if_ge dest:req @ GREATER THAN OR EQUAL + call_if 4, \dest + .endm + + .macro call_if_ne dest:req @ NOT EQUAL + call_if 5, \dest + .endm + .macro switch var:req copyvar 0x8000, \var .endm -- cgit v1.2.3