summaryrefslogtreecommitdiff
path: root/include/macros
diff options
context:
space:
mode:
authorPikalaxALT <pikalaxalt@gmail.com>2018-01-12 10:15:31 -0500
committerPikalaxALT <pikalaxalt@gmail.com>2018-01-12 10:15:31 -0500
commitcce4c9e92bfe7e10be3a0cf4940299e84701dba0 (patch)
tree514282760474bf038fb734f87e4f84ac3fb0df12 /include/macros
parent3b8f6133865af6ede3628f3df8dd71648b43b3bc (diff)
parent6a2e39eb97db47b542eea76c1e45df37184a0705 (diff)
Merge branch 'master' into pokemon_storage_system
Diffstat (limited to 'include/macros')
-rw-r--r--include/macros/asm.inc17
-rw-r--r--include/macros/battle_ai_script.inc554
-rw-r--r--include/macros/battle_anim.inc266
-rw-r--r--include/macros/battle_script.inc1414
-rw-r--r--include/macros/contest_ai_script.inc506
-rw-r--r--include/macros/ec.inc8
-rw-r--r--include/macros/event.inc1481
-rw-r--r--include/macros/field_effect_script.inc42
-rw-r--r--include/macros/function.inc29
-rw-r--r--include/macros/m4a.inc13
-rw-r--r--include/macros/map.inc96
-rw-r--r--include/macros/movement.inc116
-rw-r--r--include/macros/music_voice.inc125
-rw-r--r--include/macros/pokemon_data.inc57
14 files changed, 4724 insertions, 0 deletions
diff --git a/include/macros/asm.inc b/include/macros/asm.inc
new file mode 100644
index 000000000..26b2707ca
--- /dev/null
+++ b/include/macros/asm.inc
@@ -0,0 +1,17 @@
+ .ifndef GUARD_ASM_MACROS_ASM_INC
+ .set GUARD_ASM_MACROS_ASM_INC, 1
+
+ .macro inc x
+ .set \x, \x + 1
+ .endm
+
+ .macro enum_start x=0
+ .set __enum__, \x
+ .endm
+
+ .macro enum constant
+ .equiv \constant, __enum__
+ inc __enum__
+ .endm
+
+ .endif @ GUARD_ASM_MACROS_ASM_INC
diff --git a/include/macros/battle_ai_script.inc b/include/macros/battle_ai_script.inc
new file mode 100644
index 000000000..679e30340
--- /dev/null
+++ b/include/macros/battle_ai_script.inc
@@ -0,0 +1,554 @@
+ .macro if_random_less_than percent, address
+ .byte 0x00
+ .byte \percent
+ .4byte \address
+ .endm
+
+ @ unused
+ .macro if_random_greater_than percent, address
+ .byte 0x01
+ .byte \percent
+ .4byte \address
+ .endm
+
+ @ unused
+ .macro if_random_equal address
+ .byte 0x02
+ .4byte \address
+ .endm
+
+ @ unused
+ .macro if_random_not_equal address
+ .byte 0x03
+ .4byte \address
+ .endm
+
+ .macro score score
+ .byte 0x04
+ .byte \score
+ .endm
+
+ .macro if_hp_less_than target, percent, address
+ .byte 0x05
+ .byte \target
+ .byte \percent
+ .4byte \address
+ .endm
+
+ .macro if_hp_more_than target, percent, address
+ .byte 0x06
+ .byte \target
+ .byte \percent
+ .4byte \address
+ .endm
+
+ .macro if_hp_equal target, percent, address
+ .byte 0x07
+ .byte \target
+ .byte \percent
+ .4byte \address
+ .endm
+
+ .macro if_hp_not_equal target, percent, address
+ .byte 0x08
+ .byte \target
+ .byte \percent
+ .4byte \address
+ .endm
+
+ .macro if_status target, status, address
+ .byte 0x09
+ .byte \target
+ .4byte \status
+ .4byte \address
+ .endm
+
+ .macro if_not_status target, status, address
+ .byte 0x0a
+ .byte \target
+ .4byte \status
+ .4byte \address
+ .endm
+
+ .macro if_status2 target, status, address
+ .byte 0x0b
+ .byte \target
+ .4byte \status
+ .4byte \address
+ .endm
+
+ .macro if_not_status2 target, status, address
+ .byte 0x0c
+ .byte \target
+ .4byte \status
+ .4byte \address
+ .endm
+
+ .macro if_status3 target, status, address
+ .byte 0x0d
+ .byte \target
+ .4byte \status
+ .4byte \address
+ .endm
+
+ .macro if_not_status3 target, status, address
+ .byte 0x0e
+ .byte \target
+ .4byte \status
+ .4byte \address
+ .endm
+
+ .macro if_status4 target, status, address
+ .byte 0x0f
+ .byte \target
+ .4byte \status
+ .4byte \address
+ .endm
+
+ .macro if_not_status4 target, status, address
+ .byte 0x10
+ .byte \target
+ .4byte \status
+ .4byte \address
+ .endm
+
+ .macro if_less_than value, address
+ .byte 0x11
+ .byte \value
+ .4byte \address
+ .endm
+
+ .macro if_more_than value, address
+ .byte 0x12
+ .byte \value
+ .4byte \address
+ .endm
+
+ .macro if_equal value, address
+ .byte 0x13
+ .byte \value
+ .4byte \address
+ .endm
+
+ .macro if_not_equal value, address
+ .byte 0x14
+ .byte \value
+ .4byte \address
+ .endm
+
+ .macro if_less_than_32 value, address
+ .byte 0x15
+ .4byte \value
+ .4byte \address
+ .endm
+
+ .macro if_more_than_32 value, address
+ .byte 0x16
+ .4byte \value
+ .4byte \address
+ .endm
+
+ .macro if_equal_32 value, address
+ .byte 0x17
+ .4byte \value
+ .4byte \address
+ .endm
+
+ .macro if_not_equal_32 value, address
+ .byte 0x18
+ .4byte \value
+ .4byte \address
+ .endm
+
+ .macro if_move move, address
+ .byte 0x19
+ .2byte \move
+ .4byte \address
+ .endm
+
+ .macro if_not_move move, address
+ .byte 0x1a
+ .2byte \move
+ .4byte \address
+ .endm
+
+ .macro if_in_bytes list, address
+ .byte 0x1b
+ .4byte \list
+ .4byte \address
+ .endm
+
+ .macro if_not_in_bytes list, address
+ .byte 0x1c
+ .4byte \list
+ .4byte \address
+ .endm
+
+ .macro if_in_words list, address
+ .byte 0x1d
+ .4byte \list
+ .4byte \address
+ .endm
+
+ .macro if_not_in_words list, address
+ .byte 0x1e
+ .4byte \list
+ .4byte \address
+ .endm
+
+ .macro if_user_can_damage address
+ .byte 0x1f
+ .4byte \address
+ .endm
+
+ .macro if_user_cant_damage address
+ .byte 0x20
+ .4byte \address
+ .endm
+
+ .macro get_turn_count
+ .byte 0x21
+ .endm
+
+ .macro get_type byte
+ .byte 0x22
+ .byte \byte
+ .endm
+
+ @ unused
+ .macro get_move_power
+ .byte 0x23
+ .endm
+
+ .macro is_most_powerful_move
+ .byte 0x24
+ .endm
+
+ .macro get_move target
+ .byte 0x25
+ .byte \target
+ .endm
+
+ .macro if_arg_equal type, address
+ .byte 0x26
+ .byte \type
+ .4byte \address
+ .endm
+
+ @ unused
+ .macro if_arg_not_equal type, address
+ .byte 0x27
+ .byte \type
+ .4byte \address
+ .endm
+
+ .macro if_would_go_first target, address
+ .byte 0x28
+ .byte \target
+ .4byte \address
+ .endm
+
+ .macro if_would_not_go_first target, address
+ .byte 0x29
+ .byte \target
+ .4byte \address
+ .endm
+
+ @ nullsub
+ .macro ai_2a
+ .byte 0x2a
+ .endm
+
+ @ nullsub
+ .macro ai_2b
+ .byte 0x2b
+ .endm
+
+ .macro count_alive_pokemon target
+ .byte 0x2c
+ .byte \target
+ .endm
+
+ @ unused
+ .macro get_considered_move
+ .byte 0x2d
+ .endm
+
+ .macro get_effect
+ .byte 0x2e
+ .endm
+
+ .macro get_ability target
+ .byte 0x2f
+ .byte \target
+ .endm
+
+ @ unused
+ .macro get_highest_possible_damage
+ .byte 0x30
+ .endm
+
+ .macro if_damage_bonus value, address
+ .byte 0x31
+ .byte \value
+ .4byte \address
+ .endm
+
+ @ nullsub
+ .macro ai_32
+ .byte 0x32
+ .endm
+
+ @ nullsub
+ .macro ai_33
+ .byte 0x33
+ .endm
+
+ .macro if_status_in_party target, status, address
+ .byte 0x34
+ .byte \target
+ .4byte \status
+ .4byte \address
+ .endm
+
+ @ bugged
+ .macro if_status_not_in_party target, status, address
+ .byte 0x35
+ .byte \target
+ .4byte \status
+ .4byte \address
+ .endm
+
+ .macro get_weather
+ .byte 0x36
+ .endm
+
+ .macro if_effect byte, address
+ .byte 0x37
+ .byte \byte
+ .4byte \address
+ .endm
+
+ .macro if_not_effect byte, address
+ .byte 0x38
+ .byte \byte
+ .4byte \address
+ .endm
+
+ .macro if_stat_level_less_than target, stat, level, address
+ .byte 0x39
+ .byte \target
+ .byte \stat
+ .byte \level
+ .4byte \address
+ .endm
+
+ .macro if_stat_level_more_than target, stat, level, address
+ .byte 0x3a
+ .byte \target
+ .byte \stat
+ .byte \level
+ .4byte \address
+ .endm
+
+ .macro if_stat_level_equal target, stat, level, address
+ .byte 0x3b
+ .byte \target
+ .byte \stat
+ .byte \level
+ .4byte \address
+ .endm
+
+ .macro if_stat_level_not_equal target, stat, level, address
+ .byte 0x3c
+ .byte \target
+ .byte \stat
+ .byte \level
+ .4byte \address
+ .endm
+
+ .macro if_can_faint address
+ .byte 0x3d
+ .4byte \address
+ .endm
+
+ .macro if_cant_faint address
+ .byte 0x3e
+ .4byte \address
+ .endm
+
+ @ unused
+ .macro if_has_move, target, move, address
+ .byte 0x3f
+ .byte \target
+ .2byte \move
+ .4byte \address
+ .endm
+
+ @ unused
+ .macro if_dont_have_move, target, move, address
+ .byte 0x40
+ .byte \target
+ .2byte \move
+ .4byte \address
+ .endm
+
+ .macro if_move_effect target, effect, address
+ .byte 0x41
+ .byte \target
+ .byte \effect
+ .4byte \address
+ .endm
+
+ .macro if_not_move_effect target, effect, address
+ .byte 0x42
+ .byte \target
+ .byte \effect
+ .4byte \address
+ .endm
+
+ .macro if_last_move_did_damage target, byte, address
+ .byte 0x43
+ .byte \target
+ .byte \byte
+ .4byte \address
+ .endm
+
+ .macro if_encored target, address
+ .byte 0x44
+ .byte \target
+ .4byte \address
+ .endm
+
+ .macro flee
+ .byte 0x45
+ .endm
+
+ .macro if_random_100 address
+ .byte 0x46
+ .4byte \address
+ .endm
+
+ .macro watch
+ .byte 0x47
+ .endm
+
+ .macro get_hold_effect target
+ .byte 0x48
+ .byte \target
+ .endm
+
+ .macro get_gender target
+ .byte 0x49
+ .byte \target
+ .endm
+
+ .macro is_first_turn target
+ .byte 0x4a
+ .byte \target
+ .endm
+
+ .macro get_stockpile_count target
+ .byte 0x4b
+ .byte \target
+ .endm
+
+ .macro is_double_battle
+ .byte 0x4c
+ .endm
+
+ .macro get_item target
+ .byte 0x4d
+ .byte \target
+ .endm
+
+ .macro get_move_type_from_result
+ .byte 0x4e
+ .endm
+
+ .macro get_move_power_from_result
+ .byte 0x4f
+ .endm
+
+ .macro get_move_effect_from_result
+ .byte 0x50
+ .endm
+
+ .macro get_protect_count target
+ .byte 0x51
+ .byte \target
+ .endm
+
+ @ nullsub
+ .macro ai_52
+ .byte 0x52
+ .endm
+
+ @ nullsub
+ .macro ai_53
+ .byte 0x53
+ .endm
+
+ @ nullsub
+ .macro ai_54
+ .byte 0x54
+ .endm
+
+ @ nullsub
+ .macro ai_55
+ .byte 0x55
+ .endm
+
+ @ nullsub
+ .macro ai_56
+ .byte 0x56
+ .endm
+
+ @ nullsub
+ .macro ai_57
+ .byte 0x57
+ .endm
+
+ @ unused
+ .macro call address
+ .byte 0x58
+ .4byte \address
+ .endm
+
+ .macro jump address
+ .byte 0x59
+ .4byte \address
+ .endm
+
+ .macro end
+ .byte 0x5a
+ .endm
+
+ .macro if_level_cond cond, address
+ .byte 0x5b
+ .byte \cond
+ .4byte \address
+ .endm
+
+ .macro if_user_higher_level address
+ if_level_cond 0, \address
+ .endm
+
+ .macro if_target_higher_level address
+ if_level_cond 1, \address
+ .endm
+
+ .macro if_equal_levels address
+ if_level_cond 2, \address
+ .endm
+
+ @ unused
+ .macro if_taunted address
+ .byte 0x5c
+ .4byte \address
+ .endm
+
+ .macro if_not_taunted address
+ .byte 0x5d
+ .4byte \address
+ .endm
diff --git a/include/macros/battle_anim.inc b/include/macros/battle_anim.inc
new file mode 100644
index 000000000..4ff845032
--- /dev/null
+++ b/include/macros/battle_anim.inc
@@ -0,0 +1,266 @@
+ .macro loadsprite id
+ .byte 0x00
+ .2byte \id
+ .endm
+
+ .macro unloadsprite id
+ .byte 0x01
+ .2byte \id
+ .endm
+
+ .macro sprite template, priority, argv:vararg
+ .byte 0x02
+ .4byte \template
+ .byte \priority
+ .byte (.Lsprite_\@_2 - .Lsprite_\@_1) / 2
+.Lsprite_\@_1:
+ .2byte \argv
+.Lsprite_\@_2:
+ .endm
+
+ .macro createtask addr, priority, argv:vararg
+ .byte 0x03
+ .4byte \addr
+ .byte \priority
+ .byte (.Lcreatetask_\@_2 - .Lcreatetask_\@_1) / 2
+.Lcreatetask_\@_1:
+ .2byte \argv
+.Lcreatetask_\@_2:
+ .endm
+
+ .macro pause delay
+ .byte 0x04
+ .byte \delay
+ .endm
+
+ .macro wait
+ .byte 0x05
+ .endm
+
+ .macro hang1
+ .byte 0x06
+ .endm
+
+ .macro hang2
+ .byte 0x07
+ .endm
+
+ .macro end
+ .byte 0x08
+ .endm
+
+ .macro playse id
+ .byte 0x09
+ .2byte \id
+ .endm
+
+ .macro monbg which
+ .byte 0x0A
+ .byte \which
+ .endm
+
+ .macro clearmonbg which
+ .byte 0x0B
+ .byte \which
+ .endm
+
+ .macro setalpha eva, evb
+ .byte 0x0C
+ .2byte ((\evb) << 8) | (\eva)
+ .endm
+
+ .macro blendoff
+ .byte 0x0D
+ .endm
+
+ .macro call addr
+ .byte 0x0E
+ .4byte \addr
+ .endm
+
+ .macro ret
+ .byte 0x0F
+ .endm
+
+ .macro setvar var_num, value
+ .byte 0x10
+ .byte \var_num
+ .2byte \value
+ .endm
+
+ .macro ifelse addr1, addr2
+ .byte 0x11
+ .4byte \addr1
+ .4byte \addr2
+ .endm
+
+ .macro jumpif cond, addr
+ .byte 0x12
+ .byte \cond
+ .4byte \addr
+ .endm
+
+ .macro jump addr
+ .byte 0x13
+ .4byte \addr
+ .endm
+
+ .macro fadetobg id
+ .byte 0x14
+ .byte \id
+ .endm
+
+ .macro restorebg
+ .byte 0x15
+ .endm
+
+ .macro waitbgfadeout
+ .byte 0x16
+ .endm
+
+ .macro waitbgfadein
+ .byte 0x17
+ .endm
+
+ .macro changebg id
+ .byte 0x18
+ .byte \id
+ .endm
+
+ .macro panse_19 id, pan
+ .byte 0x19
+ .2byte \id
+ .byte \pan
+ .endm
+
+ .macro setpan pan
+ .byte 0x1A
+ .byte \pan
+ .endm
+
+ .macro panse_1B id, pan_start, pan_end, step, delay
+ .byte 0x1B
+ .2byte \id
+ .byte \pan_start
+ .byte \pan_end
+ .byte \step
+ .byte \delay
+ .endm
+
+ .macro panse_1C id, pan, delay, count
+ .byte 0x1C
+ .2byte \id
+ .byte \pan
+ .byte \delay
+ .byte \count
+ .endm
+
+ .macro panse_1D id, pan, count
+ .byte 0x1D
+ .2byte \id
+ .byte \pan
+ .byte \count
+ .endm
+
+ .macro setbldcnt bldcnt
+ .byte 0x1E
+ .2byte \bldcnt
+ .endm
+
+ .macro createtask_1F addr, argv:vararg
+ .byte 0x1F
+ .4byte \addr
+ .byte (.Lcreatetask_1F_\@_2 - .Lcreatetask_1F_\@_1) / 2
+.Lcreatetask_1F_\@_1:
+ .2byte \argv
+.Lcreatetask_1F_\@_2:
+ .endm
+
+ .macro waitsound
+ .byte 0x20
+ .endm
+
+ .macro jumpvareq var_num, value, addr
+ .byte 0x21
+ .byte \var_num
+ .2byte \value
+ .4byte \addr
+ .endm
+
+ .macro monbg_22 unk
+ .byte 0x22
+ .byte \unk
+ .endm
+
+ .macro clearmonbg_23 unk
+ .byte 0x23
+ .byte \unk
+ .endm
+
+ .macro jumpunkcond addr
+ .byte 0x24
+ .4byte \addr
+ .endm
+
+ .macro fadetobg_25 a, b, c
+ .byte 0x25
+ .byte \a
+ .byte \b
+ .byte \c
+ .endm
+
+ .macro panse_26 id, pan_start, pan_end, step, delay
+ .byte 0x26
+ .2byte \id
+ .byte \pan_start
+ .byte \pan_end
+ .byte \step
+ .byte \delay
+ .endm
+
+ .macro panse_27 id, pan_start, pan_end, step, delay
+ .byte 0x27
+ .2byte \id
+ .byte \pan_start
+ .byte \pan_end
+ .byte \step
+ .byte \delay
+ .endm
+
+ .macro monbgprio_28 unk
+ .byte 0x28
+ .byte \unk
+ .endm
+
+ .macro monbgprio_29
+ .byte 0x29
+ .endm
+
+ .macro monbgprio_2A unk
+ .byte 0x2A
+ .byte \unk
+ .endm
+
+ .macro invisible side
+ .byte 0x2B
+ .byte \side
+ .endm
+
+ .macro visible side
+ .byte 0x2C
+ .byte \side
+ .endm
+
+ .macro doublebattle_2D unk
+ .byte 0x2D
+ .byte \unk
+ .endm
+
+ .macro doublebattle_2E unk
+ .byte 0x2E
+ .byte \unk
+ .endm
+
+ .macro stopsound
+ .byte 0x2F
+ .endm
diff --git a/include/macros/battle_script.inc b/include/macros/battle_script.inc
new file mode 100644
index 000000000..e4fa0c454
--- /dev/null
+++ b/include/macros/battle_script.inc
@@ -0,0 +1,1414 @@
+@ 0 ==
+@ 1 !=
+@ 2 <
+@ 3 >
+@ 4 &=
+
+ .macro calculatedamage
+ critical
+ atk5
+ atk6
+ atk7
+ .endm
+
+
+ .macro attackcanceler
+ .byte 0x00
+ .endm
+
+ .macro accuracycheck address, param1
+ .byte 0x01
+ .4byte \address
+ .2byte \param1
+ .endm
+
+ .macro attackstring
+ .byte 0x02
+ .endm
+
+ .macro ppreduce
+ .byte 0x03
+ .endm
+
+ .macro critcalc
+ .byte 0x04
+ .endm
+
+ .macro damagecalc
+ .byte 0x05
+ .endm
+
+ .macro typecalc
+ .byte 0x06
+ .endm
+
+ .macro adjustnormaldamage
+ .byte 0x07
+ .endm
+
+ .macro adjustnormaldamage2
+ .byte 0x08
+ .endm
+
+ .macro attackanimation
+ .byte 0x09
+ .endm
+
+ .macro waitanimation
+ .byte 0x0a
+ .endm
+
+ .macro healthbarupdate bank
+ .byte 0x0b
+ .byte \bank
+ .endm
+
+ .macro datahpupdate bank
+ .byte 0x0c
+ .byte \bank
+ .endm
+
+ .macro critmessage
+ .byte 0x0d
+ .endm
+
+ .macro effectivenesssound
+ .byte 0x0e
+ .endm
+
+ .macro resultmessage
+ .byte 0x0f
+ .endm
+
+ .macro printstring string
+ .byte 0x10
+ .2byte \string
+ .endm
+
+ .macro printselectionstring string
+ .byte 0x11
+ .2byte \string
+ .endm
+
+ .macro waitmessage delay
+ .byte 0x12
+ .2byte \delay
+ .endm
+
+ .macro printfromtable table
+ .byte 0x13
+ .4byte \table
+ .endm
+
+ .macro printselectionstringfromtable table
+ .byte 0x14
+ .4byte \table
+ .endm
+
+ .macro seteffectwithchance
+ .byte 0x15
+ .endm
+
+ .macro seteffectprimary
+ .byte 0x16
+ .endm
+
+ .macro seteffectsecondary
+ .byte 0x17
+ .endm
+
+ .macro clearstatusfromeffect bank
+ .byte 0x18
+ .byte \bank
+ .endm
+
+ .macro tryfaintmon bank, param2, param3
+ .byte 0x19
+ .byte \bank
+ .byte \param2
+ .4byte \param3
+ .endm
+
+ .macro dofaintanimation param1
+ .byte 0x1a
+ .byte \param1
+ .endm
+
+ .macro cleareffectsonfaint bank
+ .byte 0x1b
+ .byte \bank
+ .endm
+
+ .macro jumpifstatus bank, status, address
+ .byte 0x1c
+ .byte \bank
+ .4byte \status
+ .4byte \address
+ .endm
+
+ .macro jumpifstatus2 bank, status, address
+ .byte 0x1d
+ .byte \bank
+ .4byte \status
+ .4byte \address
+ .endm
+
+ .macro jumpifability bank, ability, address
+ .byte 0x1e
+ .byte \bank
+ .byte \ability
+ .4byte \address
+ .endm
+
+ .macro jumpifsideaffecting bank, status, address
+ .byte 0x1f
+ .byte \bank
+ .2byte \status
+ .4byte \address
+ .endm
+
+ .macro jumpifstat bank, flag, quantity, statid, address
+ .byte 0x20
+ .byte \bank
+ .byte \flag
+ .byte \quantity
+ .byte \statid
+ .4byte \address
+ .endm
+
+ .macro jumpifstatus3condition bank, mask, status, address
+ .byte 0x21
+ .byte \bank
+ .4byte \mask
+ .byte \status
+ .4byte \address
+ .endm
+
+ .macro jumpiftype bank, type, address
+ .byte 0x22
+ .byte \bank
+ .byte \type
+ .4byte \address
+ .endm
+
+ .macro getexp bank
+ .byte 0x23
+ .byte \bank
+ .endm
+
+ .macro atk24 address
+ .byte 0x24
+ .4byte \address
+ .endm
+
+ .macro movevaluescleanup
+ .byte 0x25
+ .endm
+
+ .macro setmultihit param1
+ .byte 0x26
+ .byte \param1
+ .endm
+
+ .macro decrementmultihit address
+ .byte 0x27
+ .4byte \address
+ .endm
+
+ .macro goto address
+ .byte 0x28
+ .4byte \address
+ .endm
+
+ .macro jumpifbyte ifflag, checkaddr, compare, address
+ .byte 0x29
+ .byte \ifflag
+ .4byte \checkaddr
+ .byte \compare
+ .4byte \address
+ .endm
+
+ .macro jumpifhalfword ifflag, checkaddr, compare, address
+ .byte 0x2a
+ .byte \ifflag
+ .4byte \checkaddr
+ .2byte \compare
+ .4byte \address
+ .endm
+
+ .macro jumpifword ifflag, checkaddr, compare, address
+ .byte 0x2b
+ .byte \ifflag
+ .4byte \checkaddr
+ .4byte \compare
+ .4byte \address
+ .endm
+
+ .macro jumpifarrayequal mem1, mem2, size, address
+ .byte 0x2c
+ .4byte \mem1
+ .4byte \mem2
+ .byte \size
+ .4byte \address
+ .endm
+
+ .macro jumpifarraynotequal mem1, mem2, size, address
+ .byte 0x2d
+ .4byte \mem1
+ .4byte \mem2
+ .byte \size
+ .4byte \address
+ .endm
+
+ .macro setbyte pointer, value
+ .byte 0x2e
+ .4byte \pointer
+ .byte \value
+ .endm
+
+ .macro addbyte pointer, value
+ .byte 0x2f
+ .4byte \pointer
+ .byte \value
+ .endm
+
+ .macro subbyte pointer, value
+ .byte 0x30
+ .4byte \pointer
+ .byte \value
+ .endm
+
+ .macro copyarray destination, source, size
+ .byte 0x31
+ .4byte \destination
+ .4byte \source
+ .byte \size
+ .endm
+
+ .macro copyarraywithindex param1, param2, param3, byte
+ .byte 0x32
+ .4byte \param1
+ .4byte \param2
+ .4byte \param3
+ .byte \byte
+ .endm
+
+ .macro orbyte pointer, value
+ .byte 0x33
+ .4byte \pointer
+ .byte \value
+ .endm
+
+ .macro orhalfword pointer, value
+ .byte 0x34
+ .4byte \pointer
+ .2byte \value
+ .endm
+
+ .macro orword pointer, value
+ .byte 0x35
+ .4byte \pointer
+ .4byte \value
+ .endm
+
+ .macro bicbyte pointer, value
+ .byte 0x36
+ .4byte \pointer
+ .byte \value
+ .endm
+
+ .macro bichalfword pointer, value
+ .byte 0x37
+ .4byte \pointer
+ .2byte \value
+ .endm
+
+ .macro bicword pointer, value
+ .byte 0x38
+ .4byte \pointer
+ .4byte \value
+ .endm
+
+ .macro pause pause_duration
+ .byte 0x39
+ .2byte \pause_duration
+ .endm
+
+ .macro waitstate
+ .byte 0x3a
+ .endm
+
+ .macro healthbar_update bank
+ .byte 0x3b
+ .byte \bank
+ .endm
+
+ .macro return
+ .byte 0x3c
+ .endm
+
+ .macro end
+ .byte 0x3d
+ .endm
+
+ .macro end2
+ .byte 0x3e
+ .endm
+
+ .macro end3
+ .byte 0x3f
+ .endm
+
+ .macro jumpifaffectedbyprotect address
+ .byte 0x40
+ .4byte \address
+ .endm
+
+ .macro call address
+ .byte 0x41
+ .4byte \address
+ .endm
+
+ .macro jumpiftype2 bank, type, address
+ .byte 0x42
+ .byte \bank
+ .byte \type
+ .4byte \address
+ .endm
+
+ .macro jumpifabilitypresent ability, address
+ .byte 0x43
+ .byte \ability
+ .4byte \address
+ .endm
+
+ .macro endselectionscript
+ .byte 0x44
+ .endm
+
+ .macro playanimation bank, animation, var_address
+ .byte 0x45
+ .byte \bank
+ .byte \animation
+ .4byte \var_address
+ .endm
+
+ .macro playanimation2 bank, address, int
+ .byte 0x46
+ .byte \bank
+ .4byte \address
+ .4byte \int
+ .endm
+
+ .macro setgraphicalstatchangevalues
+ .byte 0x47
+ .endm
+
+ .macro playstatchangeanimation bank, color, byte
+ .byte 0x48
+ .byte \bank
+ .byte \color
+ .byte \byte
+ .endm
+
+ .macro moveend byte1, byte2
+ .byte 0x49
+ .byte \byte1
+ .byte \byte2
+ .endm
+
+ .macro typecalc2
+ .byte 0x4a
+ .endm
+
+ .macro returnatktoball
+ .byte 0x4b
+ .endm
+
+ .macro getswitchedmondata bank
+ .byte 0x4c
+ .byte \bank
+ .endm
+
+ .macro switchindataupdate bank
+ .byte 0x4d
+ .byte \bank
+ .endm
+
+ .macro switchinanim bank, byte
+ .byte 0x4e
+ .byte \bank
+ .byte \byte
+ .endm
+
+ .macro jumpifcantswitch bank, address
+ .byte 0x4f
+ .byte \bank
+ .4byte \address
+ .endm
+
+ .macro openpartyscreen bank, address
+ .byte 0x50
+ .byte \bank
+ .4byte \address
+ .endm
+
+ .macro switchhandleorder bank, param2
+ .byte 0x51
+ .byte \bank
+ .byte \param2
+ .endm
+
+ .macro switchineffects bank
+ .byte 0x52
+ .byte \bank
+ .endm
+
+ .macro trainerslidein bank
+ .byte 0x53
+ .byte \bank
+ .endm
+
+ .macro playse word
+ .byte 0x54
+ .2byte \word
+ .endm
+
+ .macro fanfare int
+ .byte 0x55
+ .2byte \int
+ .endm
+
+ .macro playfaintcry bank_or_side
+ .byte 0x56
+ .byte \bank_or_side
+ .endm
+
+ .macro atk57
+ .byte 0x57
+ .endm
+
+ .macro returntoball bank
+ .byte 0x58
+ .byte \bank
+ .endm
+
+ .macro handlelearnnewmove param1, param2, bank_maybe
+ .byte 0x59
+ .4byte \param1
+ .4byte \param2
+ .byte \bank_maybe
+ .endm
+
+ .macro yesnoboxlearnmove address
+ .byte 0x5a
+ .4byte \address
+ .endm
+
+ .macro yesnoboxstoplearningmove address
+ .byte 0x5b
+ .4byte \address
+ .endm
+
+ .macro hitanimation bank
+ .byte 0x5c
+ .byte \bank
+ .endm
+
+ .macro getmoneyreward
+ .byte 0x5d
+ .endm
+
+ .macro atk5e bank
+ .byte 0x5e
+ .byte \bank
+ .endm
+
+ .macro atk5f
+ .byte 0x5f
+ .endm
+
+ .macro incrementgamestat byte
+ .byte 0x60
+ .byte \byte
+ .endm
+
+ .macro drawpartystatussummary bank_or_side
+ .byte 0x61
+ .byte \bank_or_side
+ .endm
+
+ .macro atk62 bank_or_side
+ .byte 0x62
+ .byte \bank_or_side
+ .endm
+
+ .macro jumptorandomattack bank
+ .byte 0x63
+ .byte \bank
+ .endm
+
+ .macro statusanimation bank
+ .byte 0x64
+ .byte \bank
+ .endm
+
+ .macro status2animation bank_or_side, address
+ .byte 0x65
+ .byte \bank_or_side
+ .4byte \address
+ .endm
+
+ .macro chosenstatusanimation bank_or_side, bank_or_side2, address
+ .byte 0x66
+ .byte \bank_or_side
+ .byte \bank_or_side2
+ .4byte \address
+ .endm
+
+ .macro yesnobox
+ .byte 0x67
+ .endm
+
+ .macro cancelallactions
+ .byte 0x68
+ .endm
+
+ .macro adjustsetdamage
+ .byte 0x69
+ .endm
+
+ .macro removeitem bank
+ .byte 0x6a
+ .byte \bank
+ .endm
+
+ .macro atknameinbuff1
+ .byte 0x6b
+ .endm
+
+ .macro drawlvlupbox
+ .byte 0x6c
+ .endm
+
+ .macro resetsentmonsvalue
+ .byte 0x6d
+ .endm
+
+ .macro setatktoplayer0
+ .byte 0x6e
+ .endm
+
+ .macro makevisible bank
+ .byte 0x6f
+ .byte \bank
+ .endm
+
+ .macro recordlastability bank
+ .byte 0x70
+ .byte \bank
+ .endm
+
+ .macro buffermovetolearn
+ .byte 0x71
+ .endm
+
+ .macro jumpifplayerran address
+ .byte 0x72
+ .4byte \address
+ .endm
+
+ .macro hpthresholds bank
+ .byte 0x73
+ .byte \bank
+ .endm
+
+ .macro hpthresholds2 bank
+ .byte 0x74
+ .byte \bank
+ .endm
+
+ .macro useitemonopponent
+ .byte 0x75
+ .endm
+
+ .macro various bank, byte
+ .byte 0x76
+ .byte \bank
+ .byte \byte
+ .endm
+
+ .macro setprotectlike
+ .byte 0x77
+ .endm
+
+ .macro faintifabilitynotdamp
+ .byte 0x78
+ .endm
+
+ .macro setatkhptozero
+ .byte 0x79
+ .endm
+
+ .macro jumpifnexttargetvalid address
+ .byte 0x7a
+ .4byte \address
+ .endm
+
+ .macro tryhealhalfhealth address, byte
+ .byte 0x7b
+ .4byte \address
+ .byte \byte
+ .endm
+
+ .macro trymirrormove
+ .byte 0x7c
+ .endm
+
+ .macro setrain
+ .byte 0x7d
+ .endm
+
+ .macro setreflect
+ .byte 0x7e
+ .endm
+
+ .macro setseeded
+ .byte 0x7f
+ .endm
+
+ .macro manipulatedamage id
+ .byte 0x80
+ .byte \id
+ .endm
+
+ .macro trysetrest address
+ .byte 0x81
+ .4byte \address
+ .endm
+
+ .macro jumpifnotfirstturn address
+ .byte 0x82
+ .4byte \address
+ .endm
+
+ .macro nop
+ .byte 0x83
+ .endm
+
+ .macro jumpifcantmakeasleep address
+ .byte 0x84
+ .4byte \address
+ .endm
+
+ .macro stockpile
+ .byte 0x85
+ .endm
+
+ .macro stockpiletobasedamage address
+ .byte 0x86
+ .4byte \address
+ .endm
+
+ .macro stockpiletohpheal address
+ .byte 0x87
+ .4byte \address
+ .endm
+
+ .macro negativedamage
+ .byte 0x88
+ .endm
+
+ .macro statbuffchange target, address
+ .byte 0x89
+ .byte \target
+ .4byte \address
+ .endm
+
+ .macro normalisebuffs
+ .byte 0x8a
+ .endm
+
+ .macro setbide
+ .byte 0x8b
+ .endm
+
+ .macro confuseifrepeatingattackends
+ .byte 0x8c
+ .endm
+
+ .macro setmultihitcounter count
+ .byte 0x8d
+ .byte \count
+ .endm
+
+ .macro initmultihitstring
+ .byte 0x8e
+ .endm
+
+ .macro forcerandomswitch address
+ .byte 0x8f
+ .4byte \address
+ .endm
+
+ .macro tryconversiontypechange address
+ .byte 0x90
+ .4byte \address
+ .endm
+
+ .macro givepaydaymoney
+ .byte 0x91
+ .endm
+
+ .macro setlightscreen
+ .byte 0x92
+ .endm
+
+ .macro tryKO address
+ .byte 0x93
+ .4byte \address
+ .endm
+
+ .macro damagetohalftargethp
+ .byte 0x94
+ .endm
+
+ .macro setsandstorm
+ .byte 0x95
+ .endm
+
+ .macro weatherdamage
+ .byte 0x96
+ .endm
+
+ .macro tryinfatuating address
+ .byte 0x97
+ .4byte \address
+ .endm
+
+ .macro updatestatusicon byte
+ .byte 0x98
+ .byte \byte
+ .endm
+
+ .macro setmist
+ .byte 0x99
+ .endm
+
+ .macro setfocusenergy
+ .byte 0x9a
+ .endm
+
+ .macro transformdataexecution
+ .byte 0x9b
+ .endm
+
+ .macro setsubstitute
+ .byte 0x9c
+ .endm
+
+ .macro mimicattackcopy address
+ .byte 0x9d
+ .4byte \address
+ .endm
+
+ .macro metronome
+ .byte 0x9e
+ .endm
+
+ .macro dmgtolevel
+ .byte 0x9f
+ .endm
+
+ .macro psywavedamageeffect
+ .byte 0xa0
+ .endm
+
+ .macro counterdamagecalculator address
+ .byte 0xa1
+ .4byte \address
+ .endm
+
+ .macro mirrorcoatdamagecalculator address
+ .byte 0xa2
+ .4byte \address
+ .endm
+
+ .macro disablelastusedattack address
+ .byte 0xa3
+ .4byte \address
+ .endm
+
+ .macro trysetencore address
+ .byte 0xa4
+ .4byte \address
+ .endm
+
+ .macro painsplitdmgcalc address
+ .byte 0xa5
+ .4byte \address
+ .endm
+
+ .macro settypetorandomresistance address
+ .byte 0xa6
+ .4byte \address
+ .endm
+
+ .macro setalwayshitflag
+ .byte 0xa7
+ .endm
+
+ .macro copymovepermanently address
+ .byte 0xa8
+ .4byte \address
+ .endm
+
+ .macro trychoosesleeptalkmove address
+ .byte 0xa9
+ .4byte \address
+ .endm
+
+ .macro setdestinybond
+ .byte 0xaa
+ .endm
+
+ .macro trysetdestinybondtohappen
+ .byte 0xab
+ .endm
+
+ .macro remaininghptopower
+ .byte 0xac
+ .endm
+
+ .macro tryspiteppreduce address
+ .byte 0xad
+ .4byte \address
+ .endm
+
+ .macro healpartystatus
+ .byte 0xae
+ .endm
+
+ .macro cursetarget address
+ .byte 0xaf
+ .4byte \address
+ .endm
+
+ .macro trysetspikes address
+ .byte 0xb0
+ .4byte \address
+ .endm
+
+ .macro setforesight
+ .byte 0xb1
+ .endm
+
+ .macro trysetperishsong address
+ .byte 0xb2
+ .4byte \address
+ .endm
+
+ .macro rolloutdamagecalculation
+ .byte 0xb3
+ .endm
+
+ .macro jumpifconfusedandstatmaxed bank, address
+ .byte 0xb4
+ .byte \bank
+ .4byte \address
+ .endm
+
+ .macro furycuttercalc
+ .byte 0xb5
+ .endm
+
+ .macro happinesstodamagecalculation
+ .byte 0xb6
+ .endm
+
+ .macro presentdamagecalculation
+ .byte 0xb7
+ .endm
+
+ .macro setsafeguard
+ .byte 0xb8
+ .endm
+
+ .macro magnitudedamagecalculation
+ .byte 0xb9
+ .endm
+
+ .macro jumpifnopursuitswitchdmg address
+ .byte 0xba
+ .4byte \address
+ .endm
+
+ .macro setsunny
+ .byte 0xbb
+ .endm
+
+ .macro maxattackhalvehp address
+ .byte 0xbc
+ .4byte \address
+ .endm
+
+ .macro copyfoestats address
+ .byte 0xbd
+ .4byte \address
+ .endm
+
+ .macro rapidspinfree
+ .byte 0xbe
+ .endm
+
+ .macro setdefensecurlbit
+ .byte 0xbf
+ .endm
+
+ .macro recoverbasedonsunlight address
+ .byte 0xc0
+ .4byte \address
+ .endm
+
+ .macro hiddenpowercalc
+ .byte 0xc1
+ .endm
+
+ .macro selectfirstvalidtarget
+ .byte 0xc2
+ .endm
+
+ .macro trysetfutureattack address
+ .byte 0xc3
+ .4byte \address
+ .endm
+
+ .macro trydobeatup address1, address2
+ .byte 0xc4
+ .4byte \address1
+ .4byte \address2
+ .endm
+
+ .macro setsemiinvulnerablebit
+ .byte 0xc5
+ .endm
+
+ .macro clearsemiinvulnerablebit
+ .byte 0xc6
+ .endm
+
+ .macro setminimize
+ .byte 0xc7
+ .endm
+
+ .macro sethail
+ .byte 0xc8
+ .endm
+
+ .macro jumpifattackandspecialattackcannotfall address
+ .byte 0xc9
+ .4byte \address
+ .endm
+
+ .macro setforcedtarget
+ .byte 0xca
+ .endm
+
+ .macro setcharge
+ .byte 0xcb
+ .endm
+
+ .macro callterrainattack
+ .byte 0xcc
+ .endm
+
+ .macro cureifburnedparalysedorpoisoned address
+ .byte 0xcd
+ .4byte \address
+ .endm
+
+ .macro settorment address
+ .byte 0xce
+ .4byte \address
+ .endm
+
+ .macro jumpifnodamage address
+ .byte 0xcf
+ .4byte \address
+ .endm
+
+ .macro settaunt address
+ .byte 0xd0
+ .4byte \address
+ .endm
+
+ .macro trysethelpinghand address
+ .byte 0xd1
+ .4byte \address
+ .endm
+
+ .macro tryswapitems address
+ .byte 0xd2
+ .4byte \address
+ .endm
+
+ .macro trycopyability address
+ .byte 0xd3
+ .4byte \address
+ .endm
+
+ .macro trywish byte, address
+ .byte 0xd4
+ .byte \byte
+ .4byte \address
+ .endm
+
+ .macro trysetroots address
+ .byte 0xd5
+ .4byte \address
+ .endm
+
+ .macro doubledamagedealtifdamaged
+ .byte 0xd6
+ .endm
+
+ .macro setyawn address
+ .byte 0xd7
+ .4byte \address
+ .endm
+
+ .macro setdamagetohealthdifference address
+ .byte 0xd8
+ .4byte \address
+ .endm
+
+ .macro scaledamagebyhealthratio
+ .byte 0xd9
+ .endm
+
+ .macro tryswapabilities address
+ .byte 0xda
+ .4byte \address
+ .endm
+
+ .macro tryimprision address
+ .byte 0xdb
+ .4byte \address
+ .endm
+
+ .macro trysetgrudge address
+ .byte 0xdc
+ .4byte \address
+ .endm
+
+ .macro weightdamagecalculation
+ .byte 0xdd
+ .endm
+
+ .macro assistattackselect address
+ .byte 0xde
+ .4byte \address
+ .endm
+
+ .macro trysetmagiccoat address
+ .byte 0xdf
+ .4byte \address
+ .endm
+
+ .macro trysetsnatch address
+ .byte 0xe0
+ .4byte \address
+ .endm
+
+ .macro trygetintimidatetarget address
+ .byte 0xe1
+ .4byte \address
+ .endm
+
+ .macro switchoutabilities bank
+ .byte 0xe2
+ .byte \bank
+ .endm
+
+ .macro jumpifhasnohp bank, address
+ .byte 0xe3
+ .byte \bank
+ .4byte \address
+ .endm
+
+ .macro getsecretpowereffect
+ .byte 0xe4
+ .endm
+
+ .macro pickup
+ .byte 0xe5
+ .endm
+
+ .macro docastformchangeanimation
+ .byte 0xe6
+ .endm
+
+ .macro trycastformdatachange
+ .byte 0xe7
+ .endm
+
+ .macro settypebasedhalvers address
+ .byte 0xe8
+ .4byte \address
+ .endm
+
+ .macro setweatherballtype
+ .byte 0xe9
+ .endm
+
+ .macro tryrecycleitem address
+ .byte 0xea
+ .4byte \address
+ .endm
+
+ .macro settypetoterrain address
+ .byte 0xeb
+ .4byte \address
+ .endm
+
+ .macro pursuitrelated address
+ .byte 0xec
+ .4byte \address
+ .endm
+
+ .macro snatchsetbanks
+ .byte 0xed
+ .endm
+
+ .macro removelightscreenreflect
+ .byte 0xee
+ .endm
+
+ .macro handleballthrow
+ .byte 0xef
+ .endm
+
+ .macro givecaughtmon
+ .byte 0xf0
+ .endm
+
+ .macro trysetcaughtmondexflags address
+ .byte 0xf1
+ .4byte \address
+ .endm
+
+ .macro displaydexinfo
+ .byte 0xf2
+ .endm
+
+ .macro trygivecaughtmonnick address
+ .byte 0xf3
+ .4byte \address
+ .endm
+
+ .macro subattackerhpbydmg
+ .byte 0xf4
+ .endm
+
+ .macro removeattackerstatus1
+ .byte 0xf5
+ .endm
+
+ .macro finishaction
+ .byte 0xf6
+ .endm
+
+ .macro finishturn
+ .byte 0xf7
+ .endm
+
+ .macro trainerslideout bank
+ .byte 0xf8
+ .byte \bank
+ .endm
+
+@ various command changed to more readable macros
+ .macro cancelmultiturnmoves bank
+ various \bank, VARIOUS_CANCEL_MULTI_TURN_MOVES
+ .endm
+
+ .macro setmagiccoattarget bank
+ various \bank, VARIOUS_SET_MAGIC_COAT_TARGET
+ .endm
+
+ .macro getifcantrunfrombattle bank
+ various \bank, VARIOUS_IS_RUNNING_IMPOSSIBLE
+ .endm
+
+ .macro getmovetarget bank
+ various \bank, VARIOUS_GET_MOVE_TARGET
+ .endm
+
+ .macro various4 bank
+ various \bank, 4
+ .endm
+
+ .macro resetintrimidatetracebits bank
+ various \bank, VARIOUS_RESET_INTIMIDATE_TRACE_BITS
+ .endm
+
+ .macro updatechoicemoveonlvlup bank
+ various \bank, VARIOUS_UPDATE_CHOICE_MOVE_ON_LVL_UP
+ .endm
+
+ .macro various7 bank
+ various \bank, 7
+ .endm
+
+ .macro various8 bank
+ various \bank, 8
+ .endm
+
+ .macro various9 bank
+ various \bank, 9
+ .endm
+
+ .macro various10 bank
+ various \bank, 10
+ .endm
+
+ .macro various11 bank
+ various \bank, 11
+ .endm
+
+ .macro various12 bank
+ various \bank, 12
+ .endm
+
+ .macro forfeityesnobox bank
+ various \bank, VARIOUS_EMIT_YESNOBOX
+ .endm
+
+ .macro various14 bank
+ various \bank, 14
+ .endm
+
+ .macro various15 bank
+ various \bank, 15
+ .endm
+
+ .macro various16 bank
+ various \bank, 16
+ .endm
+
+ .macro various17 bank
+ various \bank, 17
+ .endm
+
+ .macro waitcry bank
+ various \bank, VARIOUS_WAIT_CRY
+ .endm
+
+ .macro returnopponentmon1toball bank
+ various \bank, VARIOUS_RETURN_OPPONENT_MON1
+ .endm
+
+ .macro returnopponentmon2toball bank
+ various \bank, VARIOUS_RETURN_OPPONENT_MON2
+ .endm
+
+ .macro various21 bank
+ various \bank, 21
+ .endm
+
+ .macro various22 bank
+ various \bank, 22
+ .endm
+
+ .macro various23 bank
+ various \bank, 23
+ .endm
+
+ .macro various24 bank
+ various \bank, 24
+ .endm
+
+ .macro setoutcomeonteleport bank
+ various \bank, VARIOUS_SET_TELEPORT_OUTCOME
+ .endm
+
+ .macro playtrainerdefeatbgm bank
+ various \bank, VARIOUS_PLAY_TRAINER_DEFEATED_MUSIC
+ .endm
+
+@ helpful macros
+ .macro setstatchanger stat, stages, down
+ setbyte sSTATCHANGER \stat | \stages << 4 | \down << 7
+ .endm
+
+ .macro setmoveeffect effect
+ setbyte cEFFECT_CHOOSER \effect
+ .endm
+
+ .macro chosenstatus1animation bank, status
+ chosenstatusanimation \bank 0x0 \status
+ .endm
+
+ .macro chosenstatus2animation bank, status
+ chosenstatusanimation \bank 0x1 \status
+ .endm
+
+ .macro sethword dst, value
+ setbyte \dst, \value & 0xFF
+ setbyte \dst + 1, (\value >> 8) & 0xFF
+ .endm
+
+ .macro setword dst, value
+ setbyte \dst, \value & 0xFF
+ setbyte \dst + 1, (\value >> 8) & 0xFF
+ setbyte \dst + 2, (\value >> 16) & 0xFF
+ setbyte \dst + 3, (\value >> 24) & 0xFF
+ .endm
+
+ .macro copybyte dst, src
+ copyarray \dst, \src, 0x1
+ .endm
+
+ .macro copyhword dst, src
+ copyarray \dst, \src, 0x2
+ .endm
+
+ .macro copyword dst, src
+ copyarray \dst, \src, 0x4
+ .endm
+
+ .macro jumpifbytenotequal byte1, byte2, jumpptr
+ jumpifarraynotequal \byte1, \byte2, 0x1, \jumpptr
+ .endm
+
+ .macro jumpifbyteequal byte1, byte2, jumpptr
+ jumpifarrayequal \byte1, \byte2, 0x1, \jumpptr
+ .endm
+
+ .macro jumpifmove move, jumpptr
+ jumpifhalfword EQUAL, gCurrentMove, \move, \jumpptr
+ .endm
+
+ .macro jumpifnotmove move, jumpptr
+ jumpifhalfword NOT_EQUAL, gCurrentMove, \move, \jumpptr
+ .endm
+
+ .macro jumpifstatus3 bank, status, jumpptr
+ jumpifstatus3condition \bank, \status, 0x0, \jumpptr
+ .endm
+
+ .macro jumpifnostatus3 bank, status, jumpptr
+ jumpifstatus3condition \bank, \status, 0x1, \jumpptr
+ .endm
+
+ .macro jumpifmovehadnoeffect jumpptr
+ jumpifbyte COMMON_BITS, gBattleMoveFlags, MOVESTATUS_MISSED | MOVESTATUS_NOTAFFECTED | MOVESTATUS_FAILED, \jumpptr
+ .endm
+
+ .macro jumpifbattletype flags, jumpptr
+ jumpifhalfword COMMON_BITS, gBattleTypeFlags, \flags, \jumpptr
+ .endm
+
+ .macro jumpifnotbattletype flags, jumpptr
+ jumpifhalfword NO_COMMON_BITS, gBattleTypeFlags, \flags, \jumpptr
+ .endm
diff --git a/include/macros/contest_ai_script.inc b/include/macros/contest_ai_script.inc
new file mode 100644
index 000000000..05d70e351
--- /dev/null
+++ b/include/macros/contest_ai_script.inc
@@ -0,0 +1,506 @@
+@ Add a positive/negative value to the score of the move being evaluated.
+
+ .macro score score
+ .byte 0x00
+ .byte \score
+ .endm
+
+@ turn (AKA "Appeal No.")
+
+ .macro get_turn
+ .byte 0x01
+ .endm
+
+ .macro if_turn_less_than param, addr
+ .byte 0x02
+ .byte \param
+ .4byte \addr
+ .endm
+
+ .macro if_turn_more_than param, addr
+ .byte 0x03
+ .byte \param
+ .4byte \addr
+ .endm
+
+ .macro if_turn_eq param, addr
+ .byte 0x04
+ .byte \param
+ .4byte \addr
+ .endm
+
+ .macro if_turn_not_eq param, addr
+ .byte 0x05
+ .byte \param
+ .4byte \addr
+ .endm
+
+@ audience excitement
+
+ .macro get_excitement
+ .byte 0x06
+ .endm
+
+ .macro if_excitement_less_than param, addr
+ .byte 0x07
+ .byte \param
+ .4byte \addr
+ .endm
+
+ .macro if_excitement_more_than param, addr
+ .byte 0x08
+ .byte \param
+ .4byte \addr
+ .endm
+
+ .macro if_excitement_eq param, addr
+ .byte 0x09
+ .byte \param
+ .4byte \addr
+ .endm
+
+ .macro if_excitement_not_eq param, addr
+ .byte 0x0A
+ .byte \param
+ .4byte \addr
+ .endm
+
+@ the order that the user goes in the current turn
+
+ .macro get_user_order
+ .byte 0x0B
+ .endm
+
+ .macro if_user_order_less_than param addr
+ .byte 0x0C
+ .byte \param
+ .4byte \addr
+ .endm
+
+ .macro if_user_order_more_than param addr
+ .byte 0x0D
+ .byte \param
+ .4byte \addr
+ .endm
+
+ .macro if_user_order_eq param addr
+ .byte 0x0E
+ .byte \param
+ .4byte \addr
+ .endm
+
+ .macro if_user_order_not_eq param addr
+ .byte 0x0F
+ .byte \param
+ .4byte \addr
+ .endm
+
+@ user condition
+
+ .macro get_user_condition
+ .byte 0x10
+ .endm
+
+ .macro if_user_condition_less_than param, addr
+ .byte 0x11
+ .byte \param
+ .4byte \addr
+ .endm
+
+ .macro if_user_condition_more_than param, addr
+ .byte 0x12
+ .byte \param
+ .4byte \addr
+ .endm
+
+ .macro if_user_condition_eq param, addr
+ .byte 0x13
+ .byte \param
+ .4byte \addr
+ .endm
+
+ .macro if_user_condition_not_eq param, addr
+ .byte 0x14
+ .byte \param
+ .4byte \addr
+ .endm
+
+@ 15
+@ 16
+@ 17
+@ 18
+@ 19
+@ 1A
+@ 1B
+@ 1C
+@ 1D
+@ 1E
+
+@ contest type
+
+ .macro get_contest_type
+ .byte 0x1F
+ .endm
+
+ .macro if_contest_type_eq param, addr
+ .byte 0x20
+ .byte \param
+ .4byte \addr
+ .endm
+
+ .macro if_contest_type_not_eq param, addr
+ .byte 0x21
+ .byte \param
+ .4byte \addr
+ .endm
+
+@ move excitement (change in excitement due to move)
+
+ .macro get_move_excitement
+ .byte 0x22
+ .endm
+
+ .macro if_move_excitement_less_than param, addr
+ .byte 0x23
+ .byte \param
+ .4byte \addr
+ .endm
+
+ .macro if_move_excitement_more_than param, addr
+ .byte 0x24
+ .byte \param
+ .4byte \addr
+ .endm
+
+ .macro if_move_excitement_eq param, addr
+ .byte 0x25
+ .byte \param
+ .4byte \addr
+ .endm
+
+ .macro if_move_excitement_not_eq param, addr
+ .byte 0x26
+ .byte \param
+ .4byte \addr
+ .endm
+
+@ move effect
+
+ .macro get_effect
+ .byte 0x27
+ .endm
+
+ .macro if_effect_eq param, addr
+ .byte 0x28
+ .byte \param
+ .4byte \addr
+ .endm
+
+ .macro if_effect_not_eq param, addr
+ .byte 0x29
+ .byte \param
+ .4byte \addr
+ .endm
+
+@ move effect type
+
+ .macro get_effect_type
+ .byte 0x2A
+ .endm
+
+ .macro if_effect_type_eq param, addr
+ .byte 0x2B
+ .byte \param
+ .4byte \addr
+ .endm
+
+ .macro if_effect_type_not_eq param, addr
+ .byte 0x2C
+ .byte \param
+ .4byte \addr
+ .endm
+
+@ whether the current move is the most appealing in the user's moveset
+
+ .macro check_most_appealing_move
+ .byte 0x2D
+ .endm
+
+ .macro if_most_appealing_move addr
+ .byte 0x2E
+ .4byte \addr
+ .endm
+
+@ 2F
+@ 30
+@ 31
+@ 32
+@ 33
+@ 34
+@ 35
+@ 36
+@ 37
+@ 38
+@ 39
+@ 3A
+
+@ number of times current move has been used
+
+ .macro get_move_used_count
+ .byte 0x3B
+ .endm
+
+ .macro if_move_used_count_less_than param, addr
+ .byte 0x3C
+ .byte \param
+ .4byte \addr
+ .endm
+
+ .macro if_move_used_count_more_than param, addr
+ .byte 0x3D
+ .byte \param
+ .4byte \addr
+ .endm
+
+ .macro if_move_used_count_eq param, addr
+ .byte 0x3E
+ .byte \param
+ .4byte \addr
+ .endm
+
+ .macro if_move_used_count_not_eq param, addr
+ .byte 0x3F
+ .byte \param
+ .4byte \addr
+ .endm
+
+@ whether the current move is a combo starter (with another move in the moveset)
+
+ .macro check_combo_starter
+ .byte 0x40
+ .endm
+
+ .macro if_combo_starter addr
+ .byte 0x41
+ .4byte \addr
+ .endm
+
+ .macro if_not_combo_starter addr
+ .byte 0x42
+ .4byte \addr
+ .endm
+
+@ whether the current move is a combo finisher (with another move in the moveset)
+
+ .macro check_combo_finisher
+ .byte 0x43
+ .endm
+
+ .macro if_combo_finisher addr
+ .byte 0x44
+ .4byte \addr
+ .endm
+
+ .macro if_not_combo_finisher addr
+ .byte 0x45
+ .4byte \addr
+ .endm
+
+@ whether the current move would finish a combo
+
+ .macro check_would_finish_combo
+ .byte 0x46
+ .endm
+
+ .macro if_would_finish_combo addr
+ .byte 0x47
+ .4byte \addr
+ .endm
+
+ .macro if_would_not_finish_combo addr
+ .byte 0x48
+ .4byte \addr
+ .endm
+
+@ condition of mon (indexed by order)
+
+ .macro get_condition mon
+ .byte 0x49
+ .byte \mon
+ .endm
+
+ .macro if_condition_less_than mon, value, addr
+ .byte 0x4A
+ .byte \mon
+ .byte \value
+ .4byte \addr
+ .endm
+
+ .macro if_condition_more_than mon, value, addr
+ .byte 0x4B
+ .byte \mon
+ .byte \value
+ .4byte \addr
+ .endm
+
+ .macro if_condition_eq mon, value, addr
+ .byte 0x4C
+ .byte \mon
+ .byte \value
+ .4byte \addr
+ .endm
+
+ .macro if_condition_not_eq mon, value, addr
+ .byte 0x4D
+ .byte \mon
+ .byte \value
+ .4byte \addr
+ .endm
+
+@ whether the mon used a combo starter move
+@ Even though this value is always 1 or 0 (i.e. TRUE/FALSE),
+@ there are less-than and greater-than comparison operations for some reason.
+
+ .macro get_used_combo_starter mon
+ .byte 0x4E
+ .byte \mon
+ .endm
+
+ .macro if_used_combo_starter_less_than mon, value, addr
+ .byte 0x4F
+ .byte \mon
+ .byte \value
+ .4byte \addr
+ .endm
+
+ .macro if_used_combo_starter_more_than mon, value, addr
+ .byte 0x50
+ .byte \mon
+ .byte \value
+ .4byte \addr
+ .endm
+
+
+ .macro if_used_combo_starter_eq mon, value, addr
+ .byte 0x51
+ .byte \mon
+ .byte \value
+ .4byte \addr
+ .endm
+
+ .macro if_used_combo_starter_not_eq mon, value, addr
+ .byte 0x52
+ .byte \mon
+ .byte \value
+ .4byte \addr
+ .endm
+
+@ whether the mon can make an appeal
+
+ .macro check_can_participate mon
+ .byte 0x53
+ .byte \mon
+ .endm
+
+ .macro if_can_participate mon, addr
+ .byte 0x54
+ .byte \mon
+ .4byte \addr
+ .endm
+
+ .macro if_cannot_participate mon, addr
+ .byte 0x55
+ .byte \mon
+ .4byte \addr
+ .endm
+
+@ 56
+@ 57
+
+ .macro contest_58 param addr
+ .byte 0x58
+ .byte \param
+ .4byte \addr
+ .endm
+
+@ 59
+@ 5A
+@ 5B
+@ 5C
+@ 5D
+@ 5E
+@ 5F
+@ 60
+@ 61
+@ 62
+@ 63
+@ 64
+@ 65
+@ 66
+@ 67
+@ 68
+@ 69
+@ 6A
+@ 6B
+@ 6C
+@ 6D
+@ 6E
+@ 6F
+@ 70
+@ 71
+@ 72
+@ 73
+@ 74
+@ 75
+@ 76
+@ 77
+@ 78
+@ 79
+@ 7A
+@ 7B
+@ 7C
+
+ .macro if_random param addr
+ .byte 0x7D
+ .byte \param
+ .4byte \addr
+ .endm
+
+@ 7E
+
+ .macro jump addr
+ .byte 0x7F
+ .4byte \addr
+ .endm
+
+ .macro call addr
+ .byte 0x80
+ .4byte \addr
+ .endm
+
+ .macro end
+ .byte 0x81
+ .endm
+
+ .macro check_user_has_exciting_move
+ .byte 0x82
+ .endm
+
+ .macro if_user_has_exciting_move addr
+ .byte 0x83
+ .4byte \addr
+ .endm
+
+ .macro if_user_doesnt_have_exciting_move addr
+ .byte 0x84
+ .4byte \addr
+ .endm
+
+@ 85
+@ 86
+
+ .macro if_effect_in_user_moveset param addr
+ .byte 0x87
+ .2byte \param
+ .4byte \addr
+ .endm
diff --git a/include/macros/ec.inc b/include/macros/ec.inc
new file mode 100644
index 000000000..d3fd45c2f
--- /dev/null
+++ b/include/macros/ec.inc
@@ -0,0 +1,8 @@
+
+ .macro ec_duplicates count
+ .2byte 0xff00 + \count
+ .endm
+
+ .macro ec_words_by_letter label
+ .2byte (gEasyChatWordsByLetter_\label - gEasyChatWordsAlphabetized) / 2
+ .endm
diff --git a/include/macros/event.inc b/include/macros/event.inc
new file mode 100644
index 000000000..fcbd3a055
--- /dev/null
+++ b/include/macros/event.inc
@@ -0,0 +1,1481 @@
+ @ Does nothing.
+ .macro nop
+ .byte 0x00
+ .endm
+
+ @ Does nothing.
+ .macro nop1
+ .byte 0x01
+ .endm
+
+ @ Terminates script execution.
+ .macro end
+ .byte 0x02
+ .endm
+
+ @ Jumps back to after the last-executed call statement, and continues script execution from there.
+ .macro return
+ .byte 0x03
+ .endm
+
+ @ Jumps to destination and continues script execution from there. The location of the calling script is remembered and can be returned to later.
+ .macro call destination
+ .byte 0x04
+ .4byte \destination
+ .endm
+
+ @ Jumps to destination and continues script execution from there.
+ .macro goto destination
+ .byte 0x05
+ .4byte \destination
+ .endm
+
+ @ If the result of the last comparison matches condition (see Comparison operators), jumps to destination and continues script execution from there.
+ .macro goto_if condition, destination
+ .byte 0x06
+ .byte \condition
+ .4byte \destination
+ .endm
+
+ @ If the result of the last comparison matches condition (see Comparison operators), calls destination.
+ .macro call_if condition, destination
+ .byte 0x07
+ .byte \condition
+ .4byte \destination
+ .endm
+
+ @ Jumps to the standard function at index function.
+ .macro gotostd function
+ .byte 0x08
+ .byte \function
+ .endm
+
+ @ Calls the standard function at index function.
+ .macro callstd function
+ .byte 0x09
+ .byte \function
+ .endm
+
+ @ If the result of the last comparison matches condition (see Comparison operators), jumps to the standard function at index function.
+ .macro gotostd_if condition, function
+ .byte 0x0a
+ .byte \condition
+ .byte \function
+ .endm
+
+ @ If the result of the last comparison matches condition (see Comparison operators), calls the standard function at index function.
+ .macro callstd_if condition, function
+ .byte 0x0b
+ .byte \condition
+ .byte \function
+ .endm
+
+ @ Executes a script stored in a default RAM location.
+ .macro gotoram
+ .byte 0x0c
+ .endm
+
+ @ Terminates script execution and "resets the script RAM".
+ .macro killscript
+ .byte 0x0d
+ .endm
+
+ @ Sets some status related to Mystery Event.
+ .macro setmysteryeventstatus value
+ .byte 0x0e
+ .byte \value
+ .endm
+
+ @ Sets the specified script bank to value.
+ .macro loadword destination, value
+ .byte 0x0f
+ .byte \destination
+ .4byte \value
+ .endm
+
+ @ Sets the specified script bank to value.
+ .macro loadbyte destination, value
+ .byte 0x10
+ .byte \destination
+ .byte \value
+ .endm
+
+ @ Sets the byte at offset to value.
+ .macro writebytetoaddr value, offset
+ .byte 0x11
+ .byte \value
+ .4byte \offset
+ .endm
+
+ @ Copies the byte value at source into the specified script bank.
+ .macro loadbytefromaddr destination, source
+ .byte 0x12
+ .byte \destination
+ .4byte \source
+ .endm
+
+ @ Not sure. Judging from XSE's description I think it takes the least-significant byte in bank source and writes it to destination.
+ .macro setptrbyte source, destination
+ .byte 0x13
+ .byte \source
+ .4byte \destination
+ .endm
+
+ @ Copies the contents of bank source into bank destination.
+ .macro copylocal destination, source
+ .byte 0x14
+ .byte \destination
+ .byte \source
+ .endm
+
+ @ Copies the byte at source to destination, replacing whatever byte was previously there.
+ .macro copybyte destination, source
+ .byte 0x15
+ .4byte \destination
+ .4byte \source
+ .endm
+
+ @ Changes the value of destination to value.
+ .macro setvar destination, value
+ .byte 0x16
+ .2byte \destination
+ .2byte \value
+ .endm
+
+ @ Changes the value of destination by adding value to it. Overflow is not prevented (0xFFFF + 1 = 0x0000).
+ .macro addvar destination, value
+ .byte 0x17
+ .2byte \destination
+ .2byte \value
+ .endm
+
+ @ Changes the value of destination by subtracting value to it. Overflow is not prevented (0x0000 - 1 = 0xFFFF).
+ .macro subvar destination, value
+ .byte 0x18
+ .2byte \destination
+ .2byte \value
+ .endm
+
+ @ Copies the value of source into destination.
+ .macro copyvar destination, source
+ .byte 0x19
+ .2byte \destination
+ .2byte \source
+ .endm
+
+ @ If source is not a variable, then this function acts like setvar. Otherwise, it acts like copyvar.
+ .macro setorcopyvar destination, source
+ .byte 0x1a
+ .2byte \destination
+ .2byte \source
+ .endm
+
+ @ Compares the values of script banks a and b, after forcing the values to bytes.
+ .macro compare_local_to_local byte1, byte2
+ .byte 0x1b
+ .byte \byte1
+ .byte \byte2
+ .endm
+
+ @ Compares the least-significant byte of the value of script bank a to a fixed byte value (b).
+ .macro compare_local_to_value a, b
+ .byte 0x1c
+ .byte \a
+ .byte \b
+ .endm
+
+ @ Compares the least-significant byte of the value of script bank a to the byte located at offset b.
+ .macro compare_local_to_addr a, b
+ .byte 0x1d
+ .byte \a
+ .4byte \b
+ .endm
+
+ @ Compares the byte located at offset a to the least-significant byte of the value of script bank b.
+ .macro compare_addr_to_local a, b
+ .byte 0x1e
+ .4byte \a
+ .byte \b
+ .endm
+
+ @ Compares the byte located at offset a to a fixed byte value (b).
+ .macro compare_addr_to_value a, b
+ .byte 0x1f
+ .4byte \a
+ .byte \b
+ .endm
+
+ @ Compares the byte located at offset a to the byte located at offset b.
+ .macro compare_addr_to_addr a, b
+ .byte 0x20
+ .4byte \a
+ .4byte \b
+ .endm
+
+ @ Compares the value of `var` to a fixed word value (b).
+ .macro compare_var_to_value var, value
+ .byte 0x21
+ .2byte \var
+ .2byte \value
+ .endm
+
+ @ Compares the value of `var1` to the value of `var2`.
+ .macro compare_var_to_var var1, var2
+ .byte 0x22
+ .2byte \var1
+ .2byte \var2
+ .endm
+
+ @ 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
+ .macro compare arg1, arg2
+ .if (((\arg1) >> 12) == 4 || ((\arg1) >> 12) == 8) && (((\arg2) >> 12) == 4 || ((\arg2) >> 12) == 8)
+ compare_var_to_var (\arg1), (\arg2)
+ .elseif (((\arg1) >> 12) == 4 || ((\arg1) >> 12) == 8) && ((\arg2) >= -0xFFFF && (\arg2) <= 0xFFFF)
+ compare_var_to_value (\arg1), ((\arg2) & 0xFFFF)
+ .else
+ .error "Invalid arguments for 'compare'"
+ .endif
+ .endm
+
+ @ Calls the native C function stored at `func`.
+ .macro callnative func
+ .byte 0x23
+ .4byte \func
+ .endm
+
+ @ Replaces the script with the function stored at `func`. Execution returns to the bytecode script when func returns TRUE.
+ .macro gotonative func
+ .byte 0x24
+ .4byte \func
+ .endm
+
+ @ Calls a special function; that is, a function designed for use by scripts and listed in a table of pointers.
+ .macro special function
+ .byte 0x25
+ .2byte SPECIAL_\function
+ .endm
+
+ @ Calls a special function. That function's output (if any) will be written to the variable you specify.
+ .macro specialvar output, function
+ .byte 0x26
+ .2byte \output
+ .2byte SPECIAL_\function
+ .endm
+
+ @ Blocks script execution until a command or ASM code manually unblocks it. Generally used with specific commands and specials. If this command runs, and a subsequent command or piece of ASM does not unblock state, the script will remain blocked indefinitely (essentially a hang).
+ .macro waitstate
+ .byte 0x27
+ .endm
+
+ @ Blocks script execution for time (frames? milliseconds?).
+ .macro delay time
+ .byte 0x28
+ .2byte \time
+ .endm
+
+ @ Sets a to 1.
+ .macro setflag a
+ .byte 0x29
+ .2byte \a
+ .endm
+
+ @ Sets a to 0.
+ .macro clearflag a
+ .byte 0x2a
+ .2byte \a
+ .endm
+
+ @ Compares a to 1.
+ .macro checkflag a
+ .byte 0x2b
+ .2byte \a
+ .endm
+
+ @ Initializes the RTC`s local time offset to the given hour and minute. In FireRed, this command is a nop.
+ .macro initclock hour, minute
+ .byte 0x2c
+ .2byte \hour
+ .2byte \minute
+ .endm
+
+ @ Runs time based events. In FireRed, this command is a nop.
+ .macro dodailyevents
+ .byte 0x2d
+ .endm
+
+ @ Sets the values of variables 0x8000, 0x8001, and 0x8002 to the current hour, minute, and second. In FRLG, this command sets those variables to zero.
+ .macro gettime
+ .byte 0x2e
+ .endm
+
+ @ Plays the specified (sound_number) sound. Only one sound may play at a time, with newer ones interrupting older ones.
+ .macro playse sound_number
+ .byte 0x2f
+ .2byte \sound_number
+ .endm
+
+ @ Blocks script execution until the currently-playing sound (triggered by playse) finishes playing.
+ .macro waitse
+ .byte 0x30
+ .endm
+
+ @ Plays the specified (fanfare_number) fanfare.
+ .macro playfanfare fanfare_number
+ .byte 0x31
+ .2byte \fanfare_number
+ .endm
+
+ @ Blocks script execution until all currently-playing fanfares finish.
+ .macro waitfanfare
+ .byte 0x32
+ .endm
+
+ @ Plays the specified (song_number) song. The byte is apparently supposed to be 0x00.
+ .macro playbgm song_number, unknown
+ .byte 0x33
+ .2byte \song_number
+ .byte \unknown
+ .endm
+
+ @ Saves the specified (song_number) song to be played later.
+ .macro savebgm song_number
+ .byte 0x34
+ .2byte \song_number
+ .endm
+
+ @ Crossfades the currently-playing song into the map's default song.
+ .macro fadedefaultbgm
+ .byte 0x35
+ .endm
+
+ @ Crossfades the currently-playng song into the specified (song_number) song.
+ .macro fadenewbgm song_number
+ .byte 0x36
+ .2byte \song_number
+ .endm
+
+ @ Fades out the currently-playing song.
+ .macro fadeoutbgm speed
+ .byte 0x37
+ .byte \speed
+ .endm
+
+ @ Fades the previously-playing song back in.
+ .macro fadeinbgm speed
+ .byte 0x38
+ .byte \speed
+ .endm
+
+ @ Sends the player to Warp warp on Map bank.map. If the specified warp is 0xFF, then the player will instead be sent to (X, Y) on the map.
+ .macro warp map, warp, X, Y
+ .byte 0x39
+ map \map
+ .byte \warp
+ .2byte \X
+ .2byte \Y
+ .endm
+
+ @ Clone of warp that does not play a sound effect.
+ .macro warpsilent map, warp, X, Y
+ .byte 0x3a
+ map \map
+ .byte \warp
+ .2byte \X
+ .2byte \Y
+ .endm
+
+ @ Clone of warp that plays a door opening animation before stepping upwards into it.
+ .macro warpdoor map, warp, X, Y
+ .byte 0x3b
+ map \map
+ .byte \warp
+ .2byte \X
+ .2byte \Y
+ .endm
+
+ @ Warps the player to another map using a hole animation.
+ .macro warphole map
+ .byte 0x3c
+ map \map
+ .endm
+
+ @ Clone of warp that uses a teleport effect. It is apparently only used in R/S/E.
+ .macro warpteleport map, warp, X, Y
+ .byte 0x3d
+ map \map
+ .byte \warp
+ .2byte \X
+ .2byte \Y
+ .endm
+
+ @ Sets the warp destination to be used later.
+ .macro setwarp map, warp, X, Y
+ .byte 0x3e
+ map \map
+ .byte \warp
+ .2byte \X
+ .2byte \Y
+ .endm
+
+ @ Sets the warp destination that a warp to Warp 127 on Map 127.127 will connect to. Useful when a map has warps that need to go to script-controlled locations (i.e. elevators).
+ .macro setdynamicwarp map, warp, X, Y
+ .byte 0x3f
+ map \map
+ .byte \warp
+ .2byte \X
+ .2byte \Y
+ .endm
+
+ @ Sets the destination that diving or emerging from a dive will take the player to.
+ .macro setdivewarp map, warp, X, Y
+ .byte 0x40
+ map \map
+ .byte \warp
+ .2byte \X
+ .2byte \Y
+ .endm
+
+ @ Sets the destination that falling into a hole will take the player to.
+ .macro setholewarp map, warp, X, Y
+ .byte 0x41
+ map \map
+ .byte \warp
+ .2byte \X
+ .2byte \Y
+ .endm
+
+ @ Retrieves the player's zero-indexed X- and Y-coordinates in the map, and stores them in the specified variables.
+ .macro getplayerxy X, Y
+ .byte 0x42
+ .2byte \X
+ .2byte \Y
+ .endm
+
+ @ Retrieves the number of Pokemon in the player's party, and stores that number in variable 0x800D (LASTRESULT).
+ .macro getpartysize
+ .byte 0x43
+ .endm
+
+ @ Attempts to add quantity of item index to the player's Bag. If the player has enough room, the item will be added and variable 0x800D (LASTRESULT) will be set to 0x0001; otherwise, LASTRESULT is set to 0x0000.
+ .macro giveitem index, quantity
+ .byte 0x44
+ .2byte \index
+ .2byte \quantity
+ .endm
+
+ @ Removes quantity of item index from the player's Bag.
+ .macro takeitem index, quantity
+ .byte 0x45
+ .2byte \index
+ .2byte \quantity
+ .endm
+
+ @ Checks if the player has enough space in their Bag to hold quantity more of item index. Sets variable 0x800D (LASTRESULT) to 0x0001 if there is room, or 0x0000 is there is no room.
+ .macro checkitemspace index, quantity
+ .byte 0x46
+ .2byte \index
+ .2byte \quantity
+ .endm
+
+ @ Checks if the player has quantity or more of item index in their Bag. Sets variable 0x800D (LASTRESULT) to 0x0001 if the player has enough of the item, or 0x0000 if they have fewer than quantity of the item.
+ .macro checkitem index, quantity
+ .byte 0x47
+ .2byte \index
+ .2byte \quantity
+ .endm
+
+ @ Checks which Bag pocket the specified (index) item belongs in, and writes the value to variable 0x800D (LASTRESULT). This script is used to show the name of the proper Bag pocket when the player receives an item via callstd (simplified to giveitem in XSE).
+ .macro checkitemtype index
+ .byte 0x48
+ .2byte \index
+ .endm
+
+ @ Adds a quantity amount of item index to the player's PC. Both arguments can be variables.
+ .macro givepcitem index, quantity
+ .byte 0x49
+ .2byte \index
+ .2byte \quantity
+ .endm
+
+ @ Checks for quantity amount of item index in the player's PC. Both arguments can be variables.
+ .macro checkpcitem index, quantity
+ .byte 0x4a
+ .2byte \index
+ .2byte \quantity
+ .endm
+
+ @ Adds decoration to the player's PC. In FireRed, this command is a nop. (The argument is read, but not used for anything.)
+ .macro givedecoration decoration
+ .byte 0x4b
+ .2byte \decoration
+ .endm
+
+ @ Removes a decoration from the player's PC. In FireRed, this command is a nop. (The argument is read, but not used for anything.)
+ .macro takedecoration decoration
+ .byte 0x4c
+ .2byte \decoration
+ .endm
+
+ @ Checks for decoration in the player's PC. In FireRed, this command is a nop. (The argument is read, but not used for anything.)
+ .macro checkdecor decoration
+ .byte 0x4d
+ .2byte \decoration
+ .endm
+
+ @ Checks if the player has enough space in their PC to hold decoration. Sets variable 0x800D (LASTRESULT) to 0x0001 if there is room, or 0x0000 is there is no room. In FireRed, this command is a nop. (The argument is read, but not used for anything.)
+ .macro checkdecorspace decoration
+ .byte 0x4e
+ .2byte \decoration
+ .endm
+
+ @ Applies the movement data at movements to the specified (index) Object event. Also closes any standard message boxes that are still open.
+ @ This command in fact uses variables to access the Object event ID. So, for example, if you setvar 0x8000 to 0x3, and then use applymovementpos 0x8000 @move1, Object event 3 will have the movements at @move1 applied to them.
+ .macro applymovement index, movements, mapGroup, mapNum
+ .ifb \mapGroup
+ .byte 0x4f
+ .2byte \index
+ .4byte \movements
+ .else
+ .byte 0x50
+ .2byte \index
+ .4byte \movements
+ .byte \mapGroup
+ .byte \mapNum
+ .endif
+ .endm
+
+ @ Blocks script execution until the movements being applied to the specified (index) Object event finish. If the specified Object event is 0x0000, then the command will block script execution until all Object events affected by applymovement finish their movements. If the specified Object event is not currently being manipulated with applymovement, then this command does nothing.
+ .macro waitmovement index, mapBank, mapNum
+ .ifb \mapBank
+ .byte 0x51
+ .2byte \index
+ .else
+ .byte 0x52
+ .2byte \index
+ .byte \mapBank
+ .byte \mapNum
+ .endif
+ .endm
+
+ @ Attempts to hide the specified (local_ID, a local ID) Object event on the specified map, by setting its visibility flag if it has a valid one. If the Object does not have a valid visibility flag, this command does nothing.
+ @ If no map is specified, then the current map is used
+ .macro removeobject localId, mapGroup, mapNum
+ .ifb \mapGroup
+ .byte 0x53
+ .2byte \localId
+ .else
+ .byte 0x54
+ .2byte \localId
+ .byte \mapGroup
+ .byte \mapNum
+ .endif
+ .endm
+
+ .macro addobject localId, mapGroup, mapNum
+ .ifb \mapGroup
+ .byte 0x55
+ .2byte \localId
+ .else
+ .byte 0x56
+ .2byte \localId
+ .byte \mapGroup
+ .byte \mapNum
+ .endif
+ .endm
+
+ @ Sets the specified (index) Object's position on the current map.
+ .macro setobjectxy index, x, y
+ .byte 0x57
+ .2byte \index
+ .2byte \x
+ .2byte \y
+ .endm
+
+ .macro showobjectat index, map
+ .byte 0x58
+ .2byte \index
+ map \map
+ .endm
+
+ .macro hideobjectat index, map
+ .byte 0x59
+ .2byte \index
+ map \map
+ .endm
+
+ @ If the script was called by a Object event, then that Object will turn to face toward the tile that the player is stepping off of.
+ .macro faceplayer
+ .byte 0x5a
+ .endm
+
+ .macro turnobject index, direction
+ .byte 0x5b
+ .2byte \index
+ .byte \direction
+ .endm
+
+ @ If the Trainer flag for Trainer index is not set, this command does absolutely nothing.
+ .macro trainerbattle type, trainer, word, pointer1, pointer2, pointer3, pointer4
+ .byte 0x5c
+ .byte \type
+ .2byte \trainer
+ .2byte \word
+ .if \type == 0
+ .4byte \pointer1 @ text
+ .4byte \pointer2 @ text
+ .elseif \type == 1
+ .4byte \pointer1 @ text
+ .4byte \pointer2 @ text
+ .4byte \pointer3 @ event script
+ .elseif \type == 2
+ .4byte \pointer1 @ text
+ .4byte \pointer2 @ text
+ .4byte \pointer3 @ event script
+ .elseif \type == 3
+ .4byte \pointer1 @ text
+ .elseif \type == 4
+ .4byte \pointer1 @ text
+ .4byte \pointer2 @ text
+ .4byte \pointer3 @ text
+ .elseif \type == 5
+ .4byte \pointer1 @ text
+ .4byte \pointer2 @ text
+ .elseif \type == 6
+ .4byte \pointer1 @ text
+ .4byte \pointer2 @ text
+ .4byte \pointer3 @ text
+ .4byte \pointer4 @ event script
+ .elseif \type == 7
+ .4byte \pointer1 @ text
+ .4byte \pointer2 @ text
+ .4byte \pointer3 @ text
+ .elseif \type == 8
+ .4byte \pointer1 @ text
+ .4byte \pointer2 @ text
+ .4byte \pointer3 @ text
+ .4byte \pointer4 @ event script
+ .endif
+ .endm
+
+ @ Starts a trainer battle using the battle information stored in RAM (usually by trainerbattle, which actually calls this command behind-the-scenes), and blocks script execution until the battle finishes.
+ .macro trainerbattlebegin
+ .byte 0x5d
+ .endm
+
+ @ Goes to address after the trainerbattle command (called by the battle functions, see battle_setup.c)
+ .macro gotopostbattlescript
+ .byte 0x5e
+ .endm
+
+ @ Goes to address specified in the trainerbattle command (called by the battle functions, see battle_setup.c)
+ .macro gotobeatenscript
+ .byte 0x5f
+ .endm
+
+ @ Compares Flag (trainer + 0x500) to 1. (If the flag is set, then the trainer has been defeated by the player.)
+ .macro checktrainerflag trainer
+ .byte 0x60
+ .2byte \trainer
+ .endm
+
+ @ Sets Flag (trainer + 0x500).
+ .macro settrainerflag trainer
+ .byte 0x61
+ .2byte \trainer
+ .endm
+
+ @ Clears Flag (trainer + 0x500).
+ .macro cleartrainerflag trainer
+ .byte 0x62
+ .2byte \trainer
+ .endm
+
+ .macro setobjectxyperm index, x, y
+ .byte 0x63
+ .2byte \index
+ .2byte \x
+ .2byte \y
+ .endm
+
+ .macro moveobjectoffscreen index
+ .byte 0x64
+ .2byte \index
+ .endm
+
+ .macro setobjectmovementtype word, byte
+ .byte 0x65
+ .2byte \word
+ .byte \byte
+ .endm
+
+ @ If a standard message box (or its text) is being drawn on-screen, this command blocks script execution until the box and its text have been fully drawn.
+ .macro waitmessage
+ .byte 0x66
+ .endm
+
+ @ Starts displaying a standard message box containing the specified text. If text is a pointer, then the string at that offset will be loaded and used. If text is script bank 0, then the value of script bank 0 will be treated as a pointer to the text. (You can use loadpointer to place a string pointer in a script bank.)
+ .macro message text
+ .byte 0x67
+ .4byte \text
+ .endm
+
+ @ Closes the current message box.
+ .macro closemessage
+ .byte 0x68
+ .endm
+
+ @ Ceases movement for all Objects on-screen.
+ .macro lockall
+ .byte 0x69
+ .endm
+
+ @ If the script was called by an Object, then that Object's movement will cease.
+ .macro lock
+ .byte 0x6a
+ .endm
+
+ @ Resumes normal movement for all Objects on-screen, and closes any standard message boxes that are still open.
+ .macro releaseall
+ .byte 0x6b
+ .endm
+
+ @ If the script was called by an Object, then that Object's movement will resume. This command also closes any standard message boxes that are still open.
+ .macro release
+ .byte 0x6c
+ .endm
+
+ @ Blocks script execution until the player presses any key.
+ .macro waitbuttonpress
+ .byte 0x6d
+ .endm
+
+ @ Displays a YES/NO multichoice box at the specified coordinates, and blocks script execution until the user makes a selection. Their selection is stored in variable 0x800D (LASTRESULT); 0x0000 for "NO" or if the user pressed B, and 0x0001 for "YES".
+ .macro yesnobox x, y
+ .byte 0x6e
+ .byte \x
+ .byte \y
+ .endm
+
+ @ Displays a multichoice box from which the user can choose a selection, and blocks script execution until a selection is made. Lists of options are predefined and the one to be used is specified with list. If b is set to a non-zero value, then the user will not be allowed to back out of the multichoice with the B button.
+ .macro multichoice x, y, list, b
+ .byte 0x6f
+ .byte \x
+ .byte \y
+ .byte \list
+ .byte \b
+ .endm
+
+ @ Displays a multichoice box from which the user can choose a selection, and blocks script execution until a selection is made. Lists of options are predefined and the one to be used is specified with list. The default argument determines the initial position of the cursor when the box is first opened; it is zero-indexed, and if it is too large, it is treated as 0x00. If b is set to a non-zero value, then the user will not be allowed to back out of the multichoice with the B button.
+ .macro multichoicedefault x, y, list, default, b
+ .byte 0x70
+ .byte \x
+ .byte \y
+ .byte \list
+ .byte \default
+ .byte \b
+ .endm
+
+ @ Displays a multichoice box from which the user can choose a selection, and blocks script execution until a selection is made. Lists of options are predefined and the one to be used is specified with list. The per_row argument determines how many list items will be shown on a single row of the box.
+ .macro multichoicegrid x, y, list, per_row, B
+ .byte 0x71
+ .byte \x
+ .byte \y
+ .byte \list
+ .byte \per_row
+ .byte \B
+ .endm
+
+ .macro drawbox byte1, byte2, byte3, byte4
+ .byte 0x72
+ .byte \byte1
+ .byte \byte2
+ .byte \byte3
+ .byte \byte4
+ .endm
+
+ .macro erasebox byte1, byte2, byte3, byte4
+ .byte 0x73
+ .byte \byte1
+ .byte \byte2
+ .byte \byte3
+ .byte \byte4
+ .endm
+
+ .macro drawboxtext byte1, byte2, byte3, byte4
+ .byte 0x74
+ .byte \byte1
+ .byte \byte2
+ .byte \byte3
+ .byte \byte4
+ .endm
+
+ @ Displays a box containing the front sprite for the specified (species) Pokemon species.
+ .macro drawmonpic species, x, y
+ .byte 0x75
+ .2byte \species
+ .byte \x
+ .byte \y
+ .endm
+
+ @ Hides all boxes displayed with drawmonpic.
+ .macro erasemonpic
+ .byte 0x76
+ .endm
+
+ @ Draws an image of the winner of the contest. In FireRed, this command is a nop. (The argument is discarded.)
+ .macro drawcontestwinner a
+ .byte 0x77
+ .byte \a
+ .endm
+
+ @ Displays the string at pointer as braille text in a standard message box. The string must be formatted to use braille characters.
+ .macro braillemessage text
+ .byte 0x78
+ .4byte \text
+ .endm
+
+ @ Gives the player one of the specified (species) Pokemon at level level holding item. The unknown arguments should all be zeroes.
+ .macro givemon species, level, item, unknown1, unknown2, unknown3
+ .byte 0x79
+ .2byte \species
+ .byte \level
+ .2byte \item
+ .4byte \unknown1
+ .4byte \unknown2
+ .byte \unknown3
+ .endm
+
+ .macro giveegg species
+ .byte 0x7a
+ .2byte \species
+ .endm
+
+ .macro setmonmove index, slot, move
+ .byte 0x7b
+ .byte \index
+ .byte \slot
+ .2byte \move
+ .endm
+
+ @ Checks if at least one Pokemon in the player's party knows the specified (index) attack. If so, variable 0x800D (LASTRESULT) is set to the (zero-indexed) slot number of the first Pokemon that knows the move. If not, LASTRESULT is set to 0x0006. Variable 0x8004 is also set to this Pokemon's species.
+ .macro checkpartymove index
+ .byte 0x7c
+ .2byte \index
+ .endm
+
+ @ Writes the name of the Pokemon at index species to the specified buffer.
+ .macro bufferspeciesname out, species
+ .byte 0x7d
+ .byte \out
+ .2byte \species
+ .endm
+
+ @ Writes the name of the species of the first Pokemon in the player's party to the specified buffer.
+ .macro bufferleadmonspeciesname out
+ .byte 0x7e
+ .byte \out
+ .endm
+
+ @ Writes the nickname of the Pokemon in slot slot (zero-indexed) of the player's party to the specified buffer. If an empty or invalid slot is specified, ten spaces ("") are written to the buffer.
+ .macro bufferpartymonnick out, slot
+ .byte 0x7f
+ .byte \out
+ .2byte \slot
+ .endm
+
+ @ Writes the name of the item at index item to the specified buffer. If the specified index is larger than the number of items in the game (0x176), the name of item 0 ("????????") is buffered instead.
+ .macro bufferitemname out, item
+ .byte 0x80
+ .byte \out
+ .2byte \item
+ .endm
+
+ @ Writes the name of the decoration at index decoration to the specified buffer. In FireRed, this command is a nop.
+ .macro bufferdecorationname out, decoration
+ .byte 0x81
+ .byte \out
+ .2byte \decoration
+ .endm
+
+ @ Writes the name of the move at index move to the specified buffer.
+ .macro buffermovename out, move
+ .byte 0x82
+ .byte \out
+ .2byte \move
+ .endm
+
+ @ Converts the value of input to a decimal string, and writes that string to the specified buffer.
+ .macro buffernumberstring out, input
+ .byte 0x83
+ .byte \out
+ .2byte \input
+ .endm
+
+ @ Writes the standard string identified by index to the specified buffer. This command has no protections in place at all, so specifying an invalid standard string (e.x. 0x2B) can and usually will cause data corruption.
+ .macro bufferstdstring out, index
+ .byte 0x84
+ .byte \out
+ .2byte \index
+ .endm
+
+ @ Copies the string at offset to the specified buffer.
+ .macro bufferstring out, offset
+ .byte 0x85
+ .byte \out
+ .4byte \offset
+ .endm
+
+ @ Opens the Pokemart system, offering the specified products for sale.
+ .macro pokemart products
+ .byte 0x86
+ .4byte \products
+ .endm
+
+ @ Opens the Pokemart system and treats the list of items as decorations.
+ .macro pokemartdecoration products
+ .byte 0x87
+ .4byte \products
+ .endm
+
+ @ Apparent clone of pokemartdecoration.
+ .macro pokemartdecoration2 products
+ .byte 0x88
+ .4byte \products
+ .endm
+
+ @ Starts up the slot machine minigame.
+ .macro playslotmachine word
+ .byte 0x89
+ .2byte \word
+ .endm
+
+ @ Sets a berry tree's specific berry and growth stage. In FireRed, this command is a nop.
+ .macro setberrytree tree_id, berry, growth_stage
+ .byte 0x8a
+ .byte \tree_id
+ .byte \berry
+ .byte \growth_stage
+ .endm
+
+ @ This allows you to choose a Pokemon to use in a contest. In FireRed, this command sets the byte at 0x03000EA8 to 0x01.
+ .macro choosecontestmon
+ .byte 0x8b
+ .endm
+
+ @ Starts a contest. In FireRed, this command is a nop.
+ .macro startcontest
+ .byte 0x8c
+ .endm
+
+ @ Shows the results of a contest. In FireRed, this command is a nop.
+ .macro showcontestresults
+ .byte 0x8d
+ .endm
+
+ @ Starts a contest over a link connection. In FireRed, this command is a nop.
+ .macro contestlinktransfer
+ .byte 0x8e
+ .endm
+
+ @ Stores a random integer between 0 and limit in variable 0x800D (LASTRESULT).
+ .macro random limit
+ .byte 0x8f
+ .2byte \limit
+ .endm
+
+ @ If check is 0x00, this command adds value to the player's money.
+ .macro givemoney value, check
+ .byte 0x90
+ .4byte \value
+ .byte \check
+ .endm
+
+ @ If check is 0x00, this command subtracts value from the player's money.
+ .macro takemoney value, check
+ .byte 0x91
+ .4byte \value
+ .byte \check
+ .endm
+
+ @ If check is 0x00, this command will check if the player has value or more money; script variable 0x800D (LASTRESULT) is set to 0x0001 if the player has enough money, or 0x0000 if the do not.
+ .macro checkmoney value, check
+ .byte 0x92
+ .4byte \value
+ .byte \check
+ .endm
+
+ @ Spawns a secondary box showing how much money the player has.
+ .macro showmoneybox x, y
+ .byte 0x93
+ .byte \x
+ .byte \y
+ .endm
+
+ @ Hides the secondary box spawned by showmoney.
+ .macro hidemoneybox x, y
+ .byte 0x94
+ .byte \x
+ .byte \y
+ .endm
+
+ @ Updates the secondary box spawned by showmoney. Consumes but does not use arguments.
+ .macro updatemoneybox x, y
+ .byte 0x95
+ .byte \x
+ .byte \y
+ .endm
+
+ @ Gets the price reduction for the index given. In FireRed, this command is a nop.
+ .macro getpricereduction index
+ .byte 0x96
+ .2byte \index
+ .endm
+
+ @ Fades the screen to and from black and white. Mode 0x00 fades from black, mode 0x01 fades out to black, mode 0x2 fades in from white, and mode 0x3 fades out to white.
+ .macro fadescreen effect
+ .byte 0x97
+ .byte \effect
+ .endm
+
+ @ Fades the screen to and from black and white. Mode 0x00 fades from black, mode 0x01 fades out to black, mode 0x2 fades in from white, and mode 0x3 fades out to white. Other modes may exist.
+ .macro fadescreenspeed effect, speed
+ .byte 0x98
+ .byte \effect
+ .byte \speed
+ .endm
+
+ .macro setflashradius word
+ .byte 0x99
+ .2byte \word
+ .endm
+
+ .macro animateflash byte
+ .byte 0x9a
+ .byte \byte
+ .endm
+
+ .macro messageautoscroll pointer
+ .byte 0x9b
+ .4byte \pointer
+ .endm
+
+ @ Executes the specified field move animation.
+ .macro dofieldeffect animation
+ .byte 0x9c
+ .2byte \animation
+ .endm
+
+ @ Sets up the field effect argument argument with the value value.
+ .macro setfieldeffectargument argument, param
+ .byte 0x9d
+ .byte \argument
+ .2byte \param
+ .endm
+
+ @ Blocks script execution until all playing field move animations complete.
+ .macro waitfieldeffect animation
+ .byte 0x9e
+ .2byte \animation
+ .endm
+
+ @ Sets which healing place the player will return to if all of the Pokemon in their party faint.
+ .macro setrespawn heallocation
+ .byte 0x9f
+ .2byte \heallocation
+ .endm
+
+ @ Checks the player's gender. If male, then 0x0000 is stored in variable 0x800D (LASTRESULT). If female, then 0x0001 is stored in LASTRESULT.
+ .macro checkplayergender
+ .byte 0xa0
+ .endm
+
+ @ Plays the specified (species) Pokemon's cry. You can use waitcry to block script execution until the sound finishes.
+ .macro playmoncry species, effect
+ .byte 0xa1
+ .2byte \species
+ .2byte \effect
+ .endm
+
+ @ Changes the metatile at (x, y) on the current map.
+ .macro setmetatile x, y, metatile_number, tile_attrib
+ .byte 0xa2
+ .2byte \x
+ .2byte \y
+ .2byte \metatile_number
+ .2byte \tile_attrib
+ .endm
+
+ @ Queues a weather change to the default weather for the map.
+ .macro resetweather
+ .byte 0xa3
+ .endm
+
+ @ Queues a weather change to type weather.
+ .macro setweather type
+ .byte 0xa4
+ .2byte \type
+ .endm
+
+ @ Executes the weather change queued with resetweather or setweather. The current weather will smoothly fade into the queued weather.
+ .macro doweather
+ .byte 0xa5
+ .endm
+
+ @ This command manages cases in which maps have tiles that change state when stepped on (specifically, cracked/breakable floors).
+ .macro setstepcallback subroutine
+ .byte 0xa6
+ .byte \subroutine
+ .endm
+
+ .macro setmaplayoutindex index
+ .byte 0xa7
+ .2byte \index
+ .endm
+
+ .macro setobjectpriority index, map, priority
+ .byte 0xa8
+ .2byte \index
+ map \map
+ .byte \priority
+ .endm
+
+ .macro resetobjectpriority index, map
+ .byte 0xa9
+ .2byte \index
+ map \map
+ .endm
+
+ .macro createvobject sprite, byte2, x, y, elevation, direction
+ .byte 0xaa
+ .byte \sprite
+ .byte \byte2
+ .2byte \x
+ .2byte \y
+ .byte \elevation
+ .byte \direction
+ .endm
+
+ .macro turnvobject index, direction
+ .byte 0xab
+ .byte \index
+ .byte \direction
+ .endm
+
+ @ Opens the door metatile at (X, Y) with an animation.
+ .macro opendoor x, y
+ .byte 0xac
+ .2byte \x
+ .2byte \y
+ .endm
+
+ @ Closes the door metatile at (X, Y) with an animation.
+ .macro closedoor x, y
+ .byte 0xad
+ .2byte \x
+ .2byte \y
+ .endm
+
+ @ Waits for the door animation started with opendoor or closedoor to finish.
+ .macro waitdooranim
+ .byte 0xae
+ .endm
+
+ @ Sets the door tile at (x, y) to be open without an animation.
+ .macro setdooropen x, y
+ .byte 0xaf
+ .2byte \x
+ .2byte \y
+ .endm
+
+ @ Sets the door tile at (x, y) to be closed without an animation.
+ .macro setdoorclosed x, y
+ .byte 0xb0
+ .2byte \x
+ .2byte \y
+ .endm
+
+ @ In FireRed, this command is a nop.
+ .macro addelevmenuitem
+ .byte 0xb1
+ .endm
+
+ @ In FireRed and Emerald, this command is a nop.
+ .macro showelevmenu
+ .byte 0xb2
+ .endm
+
+ .macro checkcoins out
+ .byte 0xb3
+ .2byte \out
+ .endm
+
+ .macro givecoins count
+ .byte 0xb4
+ .2byte \count
+ .endm
+
+ .macro takecoins count
+ .byte 0xb5
+ .2byte \count
+ .endm
+
+ @ Prepares to start a wild battle against a species at Level level holding item. Running this command will not affect normal wild battles. You start the prepared battle with dowildbattle.
+ .macro setwildbattle species, level, item
+ .byte 0xb6
+ .2byte \species
+ .byte \level
+ .2byte \item
+ .endm
+
+ @ Starts a wild battle against the Pokemon generated by setwildbattle. Blocks script execution until the battle finishes.
+ .macro dowildbattle
+ .byte 0xb7
+ .endm
+
+ .macro setvaddress long, word
+ .byte 0xb8
+ .4byte \long
+ .2byte \word
+ .endm
+
+ .macro vgoto pointer
+ .byte 0xb9
+ .4byte \pointer
+ .endm
+
+ .macro vcall pointer
+ .byte 0xba
+ .4byte \pointer
+ .endm
+
+ .macro vgoto_if byte, pointer
+ .byte 0xbb
+ .byte \byte
+ .4byte \pointer
+ .endm
+
+ .macro vcall_if byte, pointer
+ .byte 0xbc
+ .byte \byte
+ .4byte \pointer
+ .endm
+
+ .macro vmessage pointer
+ .byte 0xbd
+ .4byte \pointer
+ .endm
+
+ .macro vloadptr pointer
+ .byte 0xbe
+ .4byte \pointer
+ .endm
+
+ .macro vbufferstring byte, pointer
+ .byte 0xbf
+ .byte \byte
+ .4byte \pointer
+ .endm
+
+ @ Spawns a secondary box showing how many Coins the player has.
+ .macro showcoinsbox x, y
+ .byte 0xc0
+ .byte \x
+ .byte \y
+ .endm
+
+ @ Hides the secondary box spawned by showcoins. It consumes its arguments but doesn't use them.
+ .macro hidecoinsbox x, y
+ .byte 0xc1
+ .byte \x
+ .byte \y
+ .endm
+
+ @ Updates the secondary box spawned by showcoins. It consumes its arguments but doesn't use them.
+ .macro updatecoinsbox x, y
+ .byte 0xc2
+ .byte \x
+ .byte \y
+ .endm
+
+ @ Increases the value of the specified game stat by 1. The stat's value will not be allowed to exceed 0x00FFFFFF.
+ .macro incrementgamestat stat
+ .byte 0xc3
+ .byte \stat
+ .endm
+
+ @ Sets the destination that using an Escape Rope or Dig will take the player to.
+ .macro setescapewarp map, warp, x, y
+ .byte 0xc4
+ map \map
+ .byte \warp
+ .2byte \x
+ .2byte \y
+ .endm
+
+ @ Blocks script execution until cry finishes.
+ .macro waitmoncry
+ .byte 0xc5
+ .endm
+
+ @ Writes the name of the specified (box) PC box to the specified buffer.
+ .macro bufferboxname out, box
+ .byte 0xc6
+ .byte \out
+ .2byte \box
+ .endm
+
+ @ Sets the color of the text in standard message boxes. 0x00 produces blue (male) text, 0x01 produces red (female) text, 0xFF resets the color to the default for the current OW's gender, and all other values produce black text.
+ .macro textcolor color
+ .byte 0xc7
+ .byte \color
+ .endm
+
+ @ The exact purpose of this command is unknown, but it is related to the blue help-text box that appears on the bottom of the screen when the Main Menu is opened.
+ .macro loadhelp pointer
+ .byte 0xc8
+ .4byte \pointer
+ .endm
+
+ @ The exact purpose of this command is unknown, but it is related to the blue help-text box that appears on the bottom of the screen when the Main Menu is opened.
+ .macro unloadhelp
+ .byte 0xc9
+ .endm
+
+ @ After using this command, all standard message boxes will use the signpost frame.
+ .macro signmsg
+ .byte 0xca
+ .endm
+
+ @ Ends the effects of signmsg, returning message box frames to normal.
+ .macro normalmsg
+ .byte 0xcb
+ .endm
+
+ @ Compares the value of a hidden variable to a dword.
+ .macro comparehiddenvar a, value
+ .byte 0xcc
+ .byte \a
+ .4byte \value
+ .endm
+
+@ Supplementary
+
+ .macro goto_if_trainer_not_defeated opponent, dest
+ checktrainerflag \opponent
+ goto_if 0, \dest
+ .endm
+
+ .macro goto_if_trainer_defeated opponent, dest
+ checktrainerflag \opponent
+ goto_if 1, \dest
+ .endm
+
+ .macro call_if_trainer_not_defeated opponent, dest
+ checktrainerflag \opponent
+ call_if 0, \dest
+ .endm
+
+ .macro call_if_trainer_defeated opponent, dest
+ checktrainerflag \opponent
+ call_if 1, \dest
+ .endm
+
+ .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 call_if_unset flag, dest
+ checkflag \flag
+ call_if 0, \dest
+ .endm
+
+ .macro call_if_set flag, dest
+ checkflag \flag
+ call_if 1, \dest
+ .endm
+
+ .macro call_if_lt dest @ LESS THAN
+ call_if 0, \dest
+ .endm
+
+ .macro call_if_eq dest @ EQUAL
+ call_if 1, \dest
+ .endm
+
+ .macro call_if_gt dest @ GREATER THAN
+ call_if 2, \dest
+ .endm
+
+ .macro call_if_le dest @ LESS THAN OR EQUAL
+ call_if 3, \dest
+ .endm
+
+ .macro call_if_ge dest @ GREATER THAN OR EQUAL
+ call_if 4, \dest
+ .endm
+
+ .macro call_if_ne dest @ NOT EQUAL
+ call_if 5, \dest
+ .endm
+
+ .macro switch var
+ copyvar VAR_SPECIAL_0, \var
+ .endm
+
+ .macro case condition, dest
+ compare_var_to_value VAR_SPECIAL_0, \condition
+ goto_if_eq \dest
+ .endm
+
+ .macro msgbox text, type=4
+ loadword 0, \text
+ callstd \type
+ .endm
+
+ @ Message box types
+ MSGBOX_YESNO = 5
+
+ YES = 1
+ NO = 0
+
+ .macro giveitem_std item, amount=1, function=0
+ setorcopyvar VAR_SPECIAL_0, \item
+ setorcopyvar VAR_SPECIAL_1, \amount
+ callstd \function
+ .endm
+
+ .macro givedecoration_std decoration
+ setorcopyvar VAR_SPECIAL_0, \decoration
+ callstd 7
+ .endm
diff --git a/include/macros/field_effect_script.inc b/include/macros/field_effect_script.inc
new file mode 100644
index 000000000..d5895b0ef
--- /dev/null
+++ b/include/macros/field_effect_script.inc
@@ -0,0 +1,42 @@
+ .macro loadtiles address
+ .byte 0
+ .4byte \address
+ .endm
+
+ .macro loadfadedpal address
+ .byte 1
+ .4byte \address
+ .endm
+
+ .macro loadpal address
+ .byte 2
+ .4byte \address
+ .endm
+
+ .macro callnative address
+ .byte 3
+ .4byte \address
+ .endm
+
+ .macro end
+ .byte 4
+ .endm
+
+ .macro loadgfx_callnative tiles_address, palette_address, function_address
+ .byte 5
+ .4byte \tiles_address
+ .4byte \palette_address
+ .4byte \function_address
+ .endm
+
+ .macro loadtiles_callnative tiles_address, function_address
+ .byte 6
+ .4byte \tiles_address
+ .4byte \function_address
+ .endm
+
+ .macro loadfadedpal_callnative palette_address, function_address
+ .byte 7
+ .4byte \palette_address
+ .4byte \function_address
+ .endm
diff --git a/include/macros/function.inc b/include/macros/function.inc
new file mode 100644
index 000000000..67fb373a8
--- /dev/null
+++ b/include/macros/function.inc
@@ -0,0 +1,29 @@
+ .macro arm_func_start name
+ .align 2, 0
+ .global \name
+ .arm
+ .type \name, function
+ .endm
+
+ .macro arm_func_end name
+ .size \name, .-\name
+ .endm
+
+ .macro thumb_func_start name
+ .align 2, 0
+ .global \name
+ .thumb
+ .thumb_func
+ .type \name, function
+ .endm
+
+ .macro non_word_aligned_thumb_func_start name
+ .global \name
+ .thumb
+ .thumb_func
+ .type \name, function
+ .endm
+
+ .macro thumb_func_end name
+ .size \name, .-\name
+ .endm
diff --git a/include/macros/m4a.inc b/include/macros/m4a.inc
new file mode 100644
index 000000000..6c5abc09b
--- /dev/null
+++ b/include/macros/m4a.inc
@@ -0,0 +1,13 @@
+ .macro song label, music_player, unknown
+ .4byte \label
+ .2byte \music_player
+ .2byte \unknown
+ .endm
+
+ .macro music_player info_struct, track_struct, unknown_1, unknown_2
+ .4byte \info_struct
+ .4byte \track_struct
+ .byte \unknown_1
+ .space 1
+ .2byte \unknown_2
+ .endm
diff --git a/include/macros/map.inc b/include/macros/map.inc
new file mode 100644
index 000000000..db37d9346
--- /dev/null
+++ b/include/macros/map.inc
@@ -0,0 +1,96 @@
+ .macro map map_id
+ .byte \map_id >> 8 @ map group
+ .byte \map_id & 0xFF @ map num
+ .endm
+
+ .macro map_script type, address
+ .byte \type
+ .4byte \address
+ .endm
+
+ .macro map_script_2 word1, word2, address
+ .2byte \word1
+ .2byte \word2
+ .4byte \address
+ .endm
+
+ .macro object_event byte1, word1, byte2, byte3, byte4, byte5, byte6, byte7, byte8, byte9, byte10, byte11, byte12, byte13, byte14, script, word2, byte15, byte16
+ .byte \byte1
+ .2byte \word1
+ .byte \byte2, \byte3, \byte4, \byte5, \byte6, \byte7, \byte8, \byte9, \byte10, \byte11, \byte12, \byte13, \byte14
+ .4byte \script
+ .2byte \word2
+ .byte \byte15, \byte16
+ inc _num_npcs
+ .endm
+
+ .macro warp_def x, y, byte, warp, map_id
+ .2byte \x, \y
+ .byte \byte, \warp
+ .byte \map_id & 0xFF @ map num
+ .byte \map_id >> 8 @ map group
+ inc _num_warps
+ .endm
+
+ .macro coord_event x, y, byte1, byte2, word1, word2, word3, script
+ .2byte \x, \y
+ .byte \byte1, \byte2
+ .2byte \word1, \word2, \word3
+ .4byte \script
+ inc _num_traps
+ .endm
+
+ .macro coord_weather_event x, y, height, weather
+ coord_event \x, \y, \height, 0, \weather, 0, 0, 0x0
+ .endm
+
+ .macro bg_event x, y, byte, kind, word, arg6, arg7, arg8
+ .2byte \x, \y
+ .byte \byte, \kind
+ .2byte \word
+ .if \kind < 5
+ .4byte \arg6
+ .else
+ .2byte \arg6
+ .byte \arg7, \arg8
+ .endif
+ inc _num_signs
+ .endm
+
+ .macro bg_hidden_item_event x, y, height, item, flag
+ bg_event \x, \y, \height, 7, 0, \item, ((\flag) - FLAG_HIDDEN_ITEMS_START), 0
+ .endm
+
+ .macro bg_secret_base_event x, y, height, secret_base_id
+ bg_event \x, \y, \height, 8, 0, \secret_base_id, 0, 0
+ .endm
+
+ .macro map_events npcs, warps, traps, signs
+ .byte _num_npcs, _num_warps, _num_traps, _num_signs
+ .4byte \npcs, \warps, \traps, \signs
+ reset_map_events
+ .endm
+
+ .macro reset_map_events
+ .set _num_npcs, 0
+ .set _num_warps, 0
+ .set _num_traps, 0
+ .set _num_signs, 0
+ .endm
+
+ reset_map_events
+
+
+ .equiv connection_down, 1
+ .equiv connection_up, 2
+ .equiv connection_left, 3
+ .equiv connection_right, 4
+ .equiv connection_dive, 5
+ .equiv connection_emerge, 6
+
+ .macro connection direction, offset, map, filler
+ .4byte connection_\direction
+ .4byte \offset
+ map \map
+ .space 2
+ .endm
diff --git a/include/macros/movement.inc b/include/macros/movement.inc
new file mode 100644
index 000000000..674ce7169
--- /dev/null
+++ b/include/macros/movement.inc
@@ -0,0 +1,116 @@
+ .macro create_movement name
+ enum _\name
+ .macro \name
+ .byte _\name
+ .endm
+ .endm
+
+ enum_start
+ create_movement step_00
+ create_movement step_01
+ create_movement step_02
+ create_movement step_03
+ create_movement slow_step_down
+ create_movement slow_step_up
+ create_movement slow_step_left
+ create_movement slow_step_right
+ create_movement step_down
+ create_movement step_up
+ create_movement step_left
+ create_movement step_right
+ create_movement fast_step_down
+ create_movement fast_step_up
+ create_movement fast_step_left
+ create_movement fast_step_right
+ create_movement step_10
+ create_movement step_11
+ create_movement step_12
+ create_movement step_13
+ create_movement step_14
+ create_movement step_15
+ create_movement step_16
+ create_movement step_17
+ create_movement step_18
+ create_movement step_19
+ create_movement step_1a
+ create_movement step_1b
+ create_movement step_1c
+ create_movement step_1d
+ create_movement step_1e
+ create_movement step_1f
+ create_movement step_20
+ create_movement step_21
+ create_movement step_22
+ create_movement step_23
+ create_movement step_24
+ create_movement step_25
+ create_movement step_26
+ create_movement step_27
+ create_movement step_28
+ create_movement step_29
+ create_movement step_2a
+ create_movement step_2b
+ create_movement step_2c
+ create_movement step_2d
+ create_movement step_2e
+ create_movement step_2f
+ create_movement step_30
+ create_movement step_31
+ create_movement step_32
+ create_movement step_33
+ create_movement step_34
+ create_movement step_35
+ create_movement step_36
+ create_movement step_37
+ create_movement step_38
+ create_movement step_39
+ create_movement step_3a
+ create_movement step_3b
+ create_movement step_3c
+ create_movement step_3d
+ create_movement step_3e
+ create_movement step_3f
+ create_movement step_40
+ create_movement step_41
+ create_movement step_42
+ create_movement step_43
+ create_movement step_44
+ create_movement step_45
+ create_movement step_46
+ create_movement step_47
+ create_movement step_48
+ create_movement step_49
+ create_movement step_4a
+ create_movement step_4b
+ create_movement step_4c
+ create_movement step_4d
+ create_movement step_4e
+ create_movement step_4f
+ create_movement step_50
+ create_movement step_51
+ create_movement step_52
+ create_movement step_53
+ create_movement step_54
+ create_movement step_55
+ create_movement step_56
+ create_movement step_57
+ create_movement step_58
+ create_movement step_59
+ create_movement step_5a
+ create_movement step_5b
+ create_movement step_5c
+ create_movement step_5d
+ create_movement step_5e
+ create_movement step_5f
+ create_movement step_60
+ create_movement step_61
+
+ enum_start 0x91
+ create_movement step_91
+ create_movement step_92
+
+ enum_start 0x96
+ create_movement step_96
+
+ enum_start 0xfe
+ create_movement step_end
diff --git a/include/macros/music_voice.inc b/include/macros/music_voice.inc
new file mode 100644
index 000000000..b7a9e7f8d
--- /dev/null
+++ b/include/macros/music_voice.inc
@@ -0,0 +1,125 @@
+ .macro voice_directsound base_midi_key, pan, sample_data_pointer, attack, decay, sustain, release
+ .byte 0
+ _voice_directsound \base_midi_key, \pan, \sample_data_pointer, \attack, \decay, \sustain, \release
+ .endm
+
+ .macro voice_directsound_no_resample base_midi_key, pan, sample_data_pointer, attack, decay, sustain, release
+ .byte 8
+ _voice_directsound \base_midi_key, \pan, \sample_data_pointer, \attack, \decay, \sustain, \release
+ .endm
+
+ .macro voice_directsound_alt base_midi_key, pan, sample_data_pointer, attack, decay, sustain, release
+ .byte 16
+ _voice_directsound \base_midi_key, \pan, \sample_data_pointer, \attack, \decay, \sustain, \release
+ .endm
+
+ .macro _voice_directsound base_midi_key, pan, sample_data_pointer, attack, decay, sustain, release
+ .byte \base_midi_key
+ .byte 0
+ .if \pan != 0
+ .byte (0x80 | \pan)
+ .else
+ .byte 0
+ .endif
+ .4byte \sample_data_pointer
+ .byte \attack
+ .byte \decay
+ .byte \sustain
+ .byte \release
+ .endm
+
+ .macro voice_square_1 sweep, duty_cycle, attack, decay, sustain, release
+ _voice_square_1 1, \sweep, \duty_cycle, \attack, \decay, \sustain, \release
+ .endm
+
+ .macro voice_square_1_alt sweep, duty_cycle, attack, decay, sustain, release
+ _voice_square_1 9, \sweep, \duty_cycle, \attack, \decay, \sustain, \release
+ .endm
+
+ .macro _voice_square_1 type, sweep, duty_cycle, attack, decay, sustain, release
+ .byte \type, 60, 0
+ .byte \sweep
+ .byte (\duty_cycle & 0x3)
+ .byte 0, 0, 0
+ .byte (\attack & 0x7)
+ .byte (\decay & 0x7)
+ .byte (\sustain & 0xF)
+ .byte (\release & 0x7)
+ .endm
+
+ .macro voice_square_2 duty_cycle, attack, decay, sustain, release
+ _voice_square_2 2, \duty_cycle, \attack, \decay, \sustain, \release
+ .endm
+
+ .macro voice_square_2_alt duty_cycle, attack, decay, sustain, release
+ _voice_square_2 10, \duty_cycle, \attack, \decay, \sustain, \release
+ .endm
+
+ .macro _voice_square_2 type, duty_cycle, attack, decay, sustain, release
+ .byte \type, 60, 0, 0
+ .byte (\duty_cycle & 0x3)
+ .byte 0, 0, 0
+ .byte (\attack & 0x7)
+ .byte (\decay & 0x7)
+ .byte (\sustain & 0xF)
+ .byte (\release & 0x7)
+ .endm
+
+ .macro voice_programmable_wave wave_samples_pointer, attack, decay, sustain, release
+ _voice_programmable_wave 3, \wave_samples_pointer, \attack, \decay, \sustain, \release
+ .endm
+
+ .macro voice_programmable_wave_alt wave_samples_pointer, attack, decay, sustain, release
+ _voice_programmable_wave 11, \wave_samples_pointer, \attack, \decay, \sustain, \release
+ .endm
+
+ .macro _voice_programmable_wave type, wave_samples_pointer, attack, decay, sustain, release
+ .byte \type, 60, 0, 0
+ .4byte \wave_samples_pointer
+ .byte (\attack & 0x7)
+ .byte (\decay & 0x7)
+ .byte (\sustain & 0xF)
+ .byte (\release & 0x7)
+ .endm
+
+ .macro voice_noise period, attack, decay, sustain, release
+ _voice_noise 4, \period, \attack, \decay, \sustain, \release
+ .endm
+
+ .macro voice_noise_alt period, attack, decay, sustain, release
+ _voice_noise 12, \period, \attack, \decay, \sustain, \release
+ .endm
+
+ .macro _voice_noise type, period, attack, decay, sustain, release
+ .byte \type, 60, 0, 0
+ .byte (\period & 0x1)
+ .byte 0, 0, 0
+ .byte (\attack & 0x7)
+ .byte (\decay & 0x7)
+ .byte (\sustain & 0xF)
+ .byte (\release & 0x7)
+ .endm
+
+ .macro voice_keysplit voice_group_pointer, keysplit_table_pointer
+ .byte 0x40, 0, 0, 0
+ .4byte \voice_group_pointer
+ .4byte \keysplit_table_pointer
+ .endm
+
+ .macro voice_keysplit_all voice_group_pointer
+ .byte 0x80, 0, 0, 0
+ .4byte \voice_group_pointer
+ .4byte 0
+ .endm
+
+ .macro cry sample
+ .byte 0x20, 60, 0, 0
+ .4byte \sample
+ .byte 0xff, 0, 0xff, 0
+ .endm
+
+ .macro cry2 sample
+ .byte 0x30, 60, 0, 0
+ .4byte \sample
+ .byte 0xff, 0, 0xff, 0
+ .endm
diff --git a/include/macros/pokemon_data.inc b/include/macros/pokemon_data.inc
new file mode 100644
index 000000000..b0a5f22e3
--- /dev/null
+++ b/include/macros/pokemon_data.inc
@@ -0,0 +1,57 @@
+ .macro pokedex_entry pokemon_name, height, weight, pokemon_scale, pokemon_offset, trainer_scale, trainer_offset
+ .2byte \height @ in decimeters
+ .2byte \weight @ in hectograms
+ .4byte DexDescription_\pokemon_name\()_1
+ .4byte DexDescription_\pokemon_name\()_2
+ .2byte 0 @ unused
+ .2byte \pokemon_scale
+ .2byte \pokemon_offset
+ .2byte \trainer_scale
+ .2byte \trainer_offset
+ .2byte 0 @ padding
+ .endm
+
+ .macro base_stats hp, attack, defense, speed, sp_attack, sp_defense
+ .byte \hp
+ .byte \attack
+ .byte \defense
+ .byte \speed
+ .byte \sp_attack
+ .byte \sp_defense
+ .endm
+
+ .macro ev_yield hp, attack, defense, speed, sp_attack, sp_defense
+ .2byte (\sp_defense << 10) | (\sp_attack << 8) | (\speed << 6) | (\defense << 4) | (\attack << 2) | \hp
+ .endm
+
+ .macro level_up_move level, move
+ .2byte (\level << 9) | \move
+ .endm
+
+ .macro evo_entry method, parameter, target_species
+ .2byte \method
+ .2byte \parameter
+ .2byte \target_species
+ .2byte 0 @ padding
+ .endm
+
+ .macro empty_evo_entries count
+ .fill 8 * \count, 1, 0
+ .endm
+
+ .macro egg_moves_begin species
+ .2byte 20000 + \species
+ .endm
+
+@ If the min level equals the max level, only one level argument is needed.
+ .macro wild_mon species, min_level, max_level
+ .byte \min_level
+
+ .ifb \max_level
+ .byte \min_level
+ .else
+ .byte \max_level
+ .endif
+
+ .2byte SPECIES_\species
+ .endm