mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2025-01-13 15:13:42 +01:00
Allow compare + goto_if/call_if as a single statement
This commit is contained in:
parent
6c6487dd7a
commit
c57efdba5d
@ -1028,13 +1028,13 @@
|
|||||||
@ replaced with their charmap values, they are just passed as the literal characters "STR_VAR_#".
|
@ replaced with their charmap values, they are just passed as the literal characters "STR_VAR_#".
|
||||||
.macro stringvar id:req
|
.macro stringvar id:req
|
||||||
.if \id == STR_VAR_1
|
.if \id == STR_VAR_1
|
||||||
.byte 0
|
.byte 0
|
||||||
.elseif \id == STR_VAR_2
|
.elseif \id == STR_VAR_2
|
||||||
.byte 1
|
.byte 1
|
||||||
.elseif \id == STR_VAR_3
|
.elseif \id == STR_VAR_3
|
||||||
.byte 2
|
.byte 2
|
||||||
.else
|
.else
|
||||||
.byte \id
|
.byte \id
|
||||||
.endif
|
.endif
|
||||||
.endm
|
.endm
|
||||||
|
|
||||||
@ -1743,28 +1743,48 @@
|
|||||||
goto_if TRUE, \dest
|
goto_if TRUE, \dest
|
||||||
.endm
|
.endm
|
||||||
|
|
||||||
.macro goto_if_lt dest:req @ LESS THAN
|
@ Allows 'compare' followed by a conditional goto/call to be combined into a single statement.
|
||||||
goto_if 0, \dest
|
@ The following are examples of the two acceptable formats this facilitates:
|
||||||
|
@ compare VAR_RESULT, TRUE
|
||||||
|
@ goto_if_eq MyScript
|
||||||
|
@ - or -
|
||||||
|
@ goto_if_eq VAR_RESULT, TRUE, MyScript
|
||||||
|
@
|
||||||
|
@ The first two arguments to this macro are the base command, e.g. 'goto_if 1' for goto_if_eq.
|
||||||
|
@ The remaining arguments 'a, b, c' depend on the format:
|
||||||
|
@ For a single statement, 'a' and 'b' are the values to compare and 'c' is the destination pointer.
|
||||||
|
@ For a statement preceded by a compare, 'a' is the destination pointer and 'b/c' are not provided.
|
||||||
|
.macro trycompare jump:req, condition:req, a:req, b, c
|
||||||
|
.ifnb \c
|
||||||
|
compare \a, \b
|
||||||
|
\jump \condition, \c
|
||||||
|
.else
|
||||||
|
\jump \condition, \a
|
||||||
|
.endif
|
||||||
.endm
|
.endm
|
||||||
|
|
||||||
.macro goto_if_eq dest:req @ EQUAL
|
.macro goto_if_lt a:req, b, c @ LESS THAN
|
||||||
goto_if 1, \dest
|
trycompare goto_if, 0, \a, \b, \c
|
||||||
.endm
|
.endm
|
||||||
|
|
||||||
.macro goto_if_gt dest:req @ GREATER THAN
|
.macro goto_if_eq a:req, b, c @ EQUAL
|
||||||
goto_if 2, \dest
|
trycompare goto_if, 1, \a, \b, \c
|
||||||
.endm
|
.endm
|
||||||
|
|
||||||
.macro goto_if_le dest:req @ LESS THAN OR EQUAL
|
.macro goto_if_gt a:req, b, c @ GREATER THAN
|
||||||
goto_if 3, \dest
|
trycompare goto_if, 2, \a, \b, \c
|
||||||
.endm
|
.endm
|
||||||
|
|
||||||
.macro goto_if_ge dest:req @ GREATER THAN OR EQUAL
|
.macro goto_if_le a:req, b, c @ LESS THAN OR EQUAL
|
||||||
goto_if 4, \dest
|
trycompare goto_if, 3, \a, \b, \c
|
||||||
.endm
|
.endm
|
||||||
|
|
||||||
.macro goto_if_ne dest:req @ NOT EQUAL
|
.macro goto_if_ge a:req, b, c @ GREATER THAN OR EQUAL
|
||||||
goto_if 5, \dest
|
trycompare goto_if, 4, \a, \b, \c
|
||||||
|
.endm
|
||||||
|
|
||||||
|
.macro goto_if_ne a:req, b, c @ NOT EQUAL
|
||||||
|
trycompare goto_if, 5, \a, \b, \c
|
||||||
.endm
|
.endm
|
||||||
|
|
||||||
.macro call_if_unset flag:req, dest:req
|
.macro call_if_unset flag:req, dest:req
|
||||||
@ -1777,36 +1797,36 @@
|
|||||||
call_if TRUE, \dest
|
call_if TRUE, \dest
|
||||||
.endm
|
.endm
|
||||||
|
|
||||||
.macro call_if_lt dest:req @ LESS THAN
|
.macro call_if_lt a:req, b, c @ LESS THAN
|
||||||
call_if 0, \dest
|
trycompare call_if, 0, \a, \b, \c
|
||||||
.endm
|
.endm
|
||||||
|
|
||||||
.macro call_if_eq dest:req @ EQUAL
|
.macro call_if_eq a:req, b, c @ EQUAL
|
||||||
call_if 1, \dest
|
trycompare call_if, 1, \a, \b, \c
|
||||||
.endm
|
.endm
|
||||||
|
|
||||||
.macro call_if_gt dest:req @ GREATER THAN
|
.macro call_if_gt a:req, b, c @ GREATER THAN
|
||||||
call_if 2, \dest
|
trycompare call_if, 2, \a, \b, \c
|
||||||
.endm
|
.endm
|
||||||
|
|
||||||
.macro call_if_le dest:req @ LESS THAN OR EQUAL
|
.macro call_if_le a:req, b, c @ LESS THAN OR EQUAL
|
||||||
call_if 3, \dest
|
trycompare call_if, 3, \a, \b, \c
|
||||||
.endm
|
.endm
|
||||||
|
|
||||||
.macro call_if_ge dest:req @ GREATER THAN OR EQUAL
|
.macro call_if_ge a:req, b, c @ GREATER THAN OR EQUAL
|
||||||
call_if 4, \dest
|
trycompare call_if, 4, \a, \b, \c
|
||||||
.endm
|
.endm
|
||||||
|
|
||||||
.macro call_if_ne dest:req @ NOT EQUAL
|
.macro call_if_ne a:req, b, c @ NOT EQUAL
|
||||||
call_if 5, \dest
|
trycompare call_if, 5, \a, \b, \c
|
||||||
.endm
|
.endm
|
||||||
|
|
||||||
.macro vgoto_if_eq dest:req
|
.macro vgoto_if_eq a:req, b, c
|
||||||
vgoto_if TRUE, \dest
|
trycompare vgoto_if, TRUE, \a, \b, \c
|
||||||
.endm
|
.endm
|
||||||
|
|
||||||
.macro vgoto_if_ne dest:req
|
.macro vgoto_if_ne a:req, b, c
|
||||||
vgoto_if FALSE, \dest
|
trycompare vgoto_if, FALSE, \a, \b, \c
|
||||||
.endm
|
.endm
|
||||||
|
|
||||||
.macro vgoto_if_unset flag:req, dest:req
|
.macro vgoto_if_unset flag:req, dest:req
|
||||||
|
Loading…
x
Reference in New Issue
Block a user