Use constants in compare macro

This commit is contained in:
GriffinR 2019-12-18 19:12:09 -05:00
parent 3b240b2ad4
commit d137a1a0c1
2 changed files with 10 additions and 8 deletions

View File

@ -233,14 +233,12 @@
.endm .endm
@ Generic compare macro which attempts to deduce argument types based on their values @ Generic compare macro which attempts to deduce argument types based on their values
@ Any values between 0x4000 to 0x4FFF and 0x8000 to 0x8FFF are considered event variable identifiers @ Any values between 0x4000 to 0x40FF and 0x8000 to 0x8015 are considered event variable identifiers
.macro compare arg1:req, arg2:req .macro compare var:req, arg:req
.if ((\arg1 >> 12) == 4 || (\arg1 >> 12) == 8) && ((\arg2 >> 12) == 4 || (\arg2 >> 12) == 8) .if (\arg >= VARS_START && \arg <= VARS_END) || (\arg >= SPECIAL_VARS_START && \arg <= SPECIAL_VARS_END)
compare_var_to_var \arg1, \arg2 compare_var_to_var \var, \arg
.elseif ((\arg1 >> 12) == 4 || (\arg1 >> 12) == 8) && (\arg2 >= 0 && \arg2 <= 0xFFFF)
compare_var_to_value \arg1, \arg2
.else .else
.error "Invalid arguments for 'compare'" compare_var_to_value \var, \arg
.endif .endif
.endm .endm

View File

@ -273,6 +273,8 @@
#define VAR_UNUSED_0x40FE 0x40FE // Unused Var #define VAR_UNUSED_0x40FE 0x40FE // Unused Var
#define VAR_UNUSED_0x40FF 0x40FF // Unused Var #define VAR_UNUSED_0x40FF 0x40FF // Unused Var
#define VARS_END 0x40FF
#define SPECIAL_VARS_START 0x8000 #define SPECIAL_VARS_START 0x8000
// special vars // special vars
// They are commonly used as parameters to commands, or return values from commands. // They are commonly used as parameters to commands, or return values from commands.
@ -299,4 +301,6 @@
#define VAR_UNUSED_0x8014 0x8014 #define VAR_UNUSED_0x8014 0x8014
#define VAR_TRAINER_BATTLE_OPPONENT_A 0x8015 // Alias of gTrainerBattleOpponent_A #define VAR_TRAINER_BATTLE_OPPONENT_A 0x8015 // Alias of gTrainerBattleOpponent_A
#define SPECIAL_VARS_END 0x8015
#endif // GUARD_CONSTANTS_VARS_H #endif // GUARD_CONSTANTS_VARS_H