code:
@ commands
	.macro attackcanceler
	.byte 0x0
	.endm

	.macro accuracycheck param0:req, param1:req
	.byte 0x1
	.4byte \param0
	.2byte \param1
	.endm

	.macro attackstring
	.byte 0x2
	.endm

	.macro ppreduce
	.byte 0x3
	.endm

	.macro critcalc
	.byte 0x4
	.endm

	.macro damagecalc
	.byte 0x5
	.endm

	.macro typecalc
	.byte 0x6
	.endm

	.macro adjustnormaldamage
	.byte 0x7
	.endm

	.macro adjustnormaldamage2
	.byte 0x8
	.endm

	.macro attackanimation
	.byte 0x9
	.endm

	.macro waitanimation
	.byte 0xa
	.endm

	.macro healthbarupdate battler:req
	.byte 0xb
	.byte \battler
	.endm

	.macro datahpupdate battler:req
	.byte 0xc
	.byte \battler
	.endm

	.macro critmessage
	.byte 0xd
	.endm

	.macro effectivenesssound
	.byte 0xe
	.endm

	.macro resultmessage
	.byte 0xf
	.endm

	.macro printstring id:req
	.byte 0x10
	.2byte \id
	.endm

	.macro printselectionstring id:req
	.byte 0x11
	.2byte \id
	.endm

	.macro waitmessage param0:req
	.byte 0x12
	.2byte \param0
	.endm

	.macro printfromtable ptr:req
	.byte 0x13
	.4byte \ptr
	.endm

	.macro printselectionstringfromtable ptr:req
	.byte 0x14
	.4byte \ptr
	.endm

	.macro seteffectwithchance
	.byte 0x15
	.endm

	.macro seteffectprimary
	.byte 0x16
	.endm

	.macro seteffectsecondary
	.byte 0x17
	.endm

	.macro clearstatusfromeffect battler:req
	.byte 0x18
	.byte \battler
	.endm

	.macro tryfaintmon battler:req, param1:req, ptr:req
	.byte 0x19
	.byte \battler
	.byte \param1
	.4byte \ptr
	.endm

	.macro dofaintanimation battler:req
	.byte 0x1a
	.byte \battler
	.endm

	.macro cleareffectsonfaint battler:req
	.byte 0x1b
	.byte \battler
	.endm

	.macro jumpifstatus battler:req, status1:req, ptr:req
	.byte 0x1c
	.byte \battler
	.4byte \status1
	.4byte \ptr
	.endm

	.macro jumpifstatus2 battler:req, status2:req, ptr:req
	.byte 0x1d
	.byte \battler
	.4byte \status2
	.4byte \ptr
	.endm

	.macro jumpifability param0:req, ability:req, ptr:req
	.byte 0x1e
	.byte \param0
	.byte \ability
	.4byte \ptr
	.endm

	.macro jumpifsideaffecting battler:req, sidestatus:req, ptr:req
	.byte 0x1f
	.byte \battler
	.2byte \sidestatus
	.4byte \ptr
	.endm

	.macro jumpifstat battler:req, ifflag:req, stat:req, value:req, ptr
	.byte 0x20
	.byte \battler
	.byte \ifflag
	.byte \stat
	.byte \value
	.4byte \ptr
	.endm

	.macro jumpifstatus3condition battler:req, status3:req, param2:req, ptr:req
	.byte 0x21
	.byte \battler
	.4byte \status3
	.byte \param2
	.4byte \ptr
	.endm

	.macro jumpiftype battler:req, type:req, ptr:req
	.byte 0x22
	.byte \battler
	.byte \type
	.4byte \ptr
	.endm

	.macro getexp battler:req
	.byte 0x23
	.byte \battler
	.endm

	.macro atk24 ptr:req
	.byte 0x24
	.4byte \ptr
	.endm

	.macro movevaluescleanup
	.byte 0x25
	.endm

	.macro setmultihit value:req
	.byte 0x26
	.byte \value
	.endm

	.macro decrementmultihit value:req
	.byte 0x27
	.4byte \value
	.endm

	.macro goto ptr:req
	.byte 0x28
	.4byte \ptr
	.endm

	.macro jumpifbyte ifflag:req, param1:req, param2:req, param3:req
	.byte 0x29
	.byte \ifflag
	.4byte \param1
	.byte \param2
	.4byte \param3
	.endm

	.macro jumpifhalfword ifflag:req, param1:req, param2:req, param3:req
	.byte 0x2a
	.byte \ifflag
	.4byte \param1
	.2byte \param2
	.4byte \param3
	.endm

	.macro jumpifword ifflag:req, param1:req, param2:req, param3:req
	.byte 0x2b
	.byte \ifflag
	.4byte \param1
	.4byte \param2
	.4byte \param3
	.endm

	.macro jumpifarrayequal param0:req, param1:req, param2:req, param3:req
	.byte 0x2c
	.4byte \param0
	.4byte \param1
	.byte \param2
	.4byte \param3
	.endm

	.macro jumpifarraynotequal param0:req, param1:req, param2:req, param3:req
	.byte 0x2d
	.4byte \param0
	.4byte \param1
	.byte \param2
	.4byte \param3
	.endm

	.macro setbyte ptr:req, param1:req
	.byte 0x2e
	.4byte \ptr
	.byte \param1
	.endm

	.macro addbyte ptr:req, param1:req
	.byte 0x2f
	.4byte \ptr
	.byte \param1
	.endm

	.macro subbyte ptr:req, param1:req
	.byte 0x30
	.4byte \ptr
	.byte \param1
	.endm

	.macro copyarray param0:req, param1:req, param2:req
	.byte 0x31
	.4byte \param0
	.4byte \param1
	.byte \param2
	.endm

	.macro copyarraywithindex param0:req, param1:req, param2:req, param3:req
	.byte 0x32
	.4byte \param0
	.4byte \param1
	.4byte \param2
	.byte \param3
	.endm

	.macro orbyte ptr:req, param1:req
	.byte 0x33
	.4byte \ptr
	.byte \param1
	.endm

	.macro orhalfword ptr:req, param1:req
	.byte 0x34
	.4byte \ptr
	.2byte \param1
	.endm

	.macro orword ptr:req, param1:req
	.byte 0x35
	.4byte \ptr
	.4byte \param1
	.endm

	.macro bicbyte ptr:req, param1:req
	.byte 0x36
	.4byte \ptr
	.byte \param1
	.endm

	.macro bichalfword ptr:req, param1:req
	.byte 0x37
	.4byte \ptr
	.2byte \param1
	.endm

	.macro bicword ptr:req, param1:req
	.byte 0x38
	.4byte \ptr
	.4byte \param1
	.endm

	.macro pause param0:req
	.byte 0x39
	.2byte \param0
	.endm

	.macro waitstate
	.byte 0x3a
	.endm

	.macro healthbar_update battler:req
	.byte 0x3b
	.byte \battler
	.endm

	.macro return
	.byte 0x3c
	.endm

	.macro end
	.byte 0x3d
	.endm

	.macro end2
	.byte 0x3e
	.endm

	.macro end3
	.byte 0x3f
	.endm

	.macro jumpifaffectedbyprotect ptr:req
	.byte 0x40
	.4byte \ptr
	.endm

	.macro call ptr:req
	.byte 0x41
	.4byte \ptr
	.endm

	.macro jumpiftype2 battler:req, type:req, ptr:req
	.byte 0x42
	.byte \battler
	.byte \type
	.4byte \ptr
	.endm

	.macro jumpifabilitypresent ability:req, ptr:req
	.byte 0x43
	.byte \ability
	.4byte \ptr
	.endm

	.macro endselectionscript
	.byte 0x44
	.endm

	.macro playanimation battler:req, param1:req, param2:req
	.byte 0x45
	.byte \battler
	.byte \param1
	.4byte \param2
	.endm

	.macro playanimation2 battler:req, param1:req, param2:req
	.byte 0x46
	.byte \battler
	.4byte \param1
	.4byte \param2
	.endm

	.macro setgraphicalstatchangevalues
	.byte 0x47
	.endm

	.macro playstatchangeanimation battler:req, stats:req, statchange:req
	.byte 0x48
	.byte \battler
	.byte \stats
	.byte \statchange
	.endm

	.macro moveend param0:req, param1:req
	.byte 0x49
	.byte \param0
	.byte \param1
	.endm

	@ Help macros for 5 uses of moveend command

	@ All cases
	.macro moveendall
	setbyte sMOVEEND_STATE, 0
	moveend 0, 0
	.endm

	@ Chosen case
	.macro moveendcase case:req
	setbyte sMOVEEND_STATE, \case
	moveend 1, 0
	.endm

	@ All cases from (inclusive)
	.macro moveendfrom from:req
	setbyte sMOVEEND_STATE, \from
	moveend 0, 0
	.endm

	@ All cases from 0 to (not inclusive)
	.macro moveendto to:req
	setbyte sMOVEEND_STATE, 0
	moveend 2, \to
	.endm

	@ Cases from (inclusive) to (not inclusive)
	.macro moveendfromto from:req, to:req
	setbyte sMOVEEND_STATE, \from
	moveend 2, \to
	.endm

	.macro typecalc2
	.byte 0x4a
	.endm

	.macro returnatktoball
	.byte 0x4b
	.endm

	.macro getswitchedmondata battler:req
	.byte 0x4c
	.byte \battler
	.endm

	.macro switchindataupdate battler:req
	.byte 0x4d
	.byte \battler
	.endm

	.macro switchinanim battler:req, dontclearsubstitutebit:req
	.byte 0x4e
	.byte \battler
	.byte \dontclearsubstitutebit
	.endm

	.macro jumpifcantswitch battler:req, ptr:req
	.byte 0x4f
	.byte \battler
	.4byte \ptr
	.endm

	.macro openpartyscreen param0:req, param1:req
	.byte 0x50
	.byte \param0
	.4byte \param1
	.endm

	.macro switchhandleorder battler:req, param1:req
	.byte 0x51
	.byte \battler
	.byte \param1
	.endm

	.macro switchineffects battler:req
	.byte 0x52
	.byte \battler
	.endm

	.macro trainerslidein battler:req
	.byte 0x53
	.byte \battler
	.endm

	.macro playse param0:req
	.byte 0x54
	.2byte \param0
	.endm

	.macro fanfare param0:req
	.byte 0x55
	.2byte \param0
	.endm

	.macro playfaintcry battler:req
	.byte 0x56
	.byte \battler
	.endm

	.macro atk57
	.byte 0x57
	.endm

	.macro returntoball battler:req
	.byte 0x58
	.byte \battler
	.endm

	.macro handlelearnnewmove param0:req, param1:req, param2:req
	.byte 0x59
	.4byte \param0
	.4byte \param1
	.byte \param2
	.endm

	.macro yesnoboxlearnmove param0:req
	.byte 0x5a
	.4byte \param0
	.endm

	.macro yesnoboxstoplearningmove param0:req
	.byte 0x5b
	.4byte \param0
	.endm

	.macro hitanimation battler:req
	.byte 0x5c
	.byte \battler
	.endm

	.macro getmoneyreward
	.byte 0x5d
	.endm

	.macro atk5E battler:req
	.byte 0x5e
	.byte \battler
	.endm

	.macro swapattackerwithtarget
	.byte 0x5f
	.endm

	.macro incrementgamestat param0:req
	.byte 0x60
	.byte \param0
	.endm

	.macro drawpartystatussummary battler:req
	.byte 0x61
	.byte \battler
	.endm

	.macro hidepartystatussummary battler:req
	.byte 0x62
	.byte \battler
	.endm

	.macro jumptocalledmove param0:req
	.byte 0x63
	.byte \param0
	.endm

	.macro statusanimation battler:req
	.byte 0x64
	.byte \battler
	.endm

	.macro status2animation battler:req, status2:req
	.byte 0x65
	.byte \battler
	.4byte \status2
	.endm

	.macro chosenstatusanimation battler:req, param1:req, param2:req
	.byte 0x66
	.byte \battler
	.byte \param1
	.4byte \param2
	.endm

	.macro yesnobox
	.byte 0x67
	.endm

	.macro cancelallactions
	.byte 0x68
	.endm

	.macro adjustsetdamage
	.byte 0x69
	.endm

	.macro removeitem battler:req
	.byte 0x6a
	.byte \battler
	.endm

	.macro atknameinbuff1
	.byte 0x6b
	.endm

	.macro drawlvlupbox
	.byte 0x6c
	.endm

	.macro resetsentmonsvalue
	.byte 0x6d
	.endm

	.macro setatktoplayer0
	.byte 0x6e
	.endm

	.macro makevisible battler:req
	.byte 0x6f
	.byte \battler
	.endm

	.macro recordlastability battler:req
	.byte 0x70
	.byte \battler
	.endm

	.macro buffermovetolearn
	.byte 0x71
	.endm

	.macro jumpifplayerran ptr:req
	.byte 0x72
	.4byte \ptr
	.endm

	.macro hpthresholds battler:req
	.byte 0x73
	.byte \battler
	.endm

	.macro hpthresholds2 battler:req
	.byte 0x74
	.byte \battler
	.endm

	.macro useitemonopponent
	.byte 0x75
	.endm

	.macro various battler:req, param1:req
	.byte 0x76
	.byte \battler
	.byte \param1
	.endm

	.macro setprotectlike
	.byte 0x77
	.endm

	.macro faintifabilitynotdamp
	.byte 0x78
	.endm

	.macro setatkhptozero
	.byte 0x79
	.endm

	.macro jumpifnexttargetvalid ptr:req
	.byte 0x7a
	.4byte \ptr
	.endm

	.macro tryhealhalfhealth param0:req, battler:req
	.byte 0x7b
	.4byte \param0
	.byte \battler
	.endm

	.macro trymirrormove
	.byte 0x7c
	.endm

	.macro setrain
	.byte 0x7d
	.endm

	.macro setreflect
	.byte 0x7e
	.endm

	.macro setseeded
	.byte 0x7f
	.endm

	.macro manipulatedamage param0:req
	.byte 0x80
	.byte \param0
	.endm

	.macro trysetrest param0:req
	.byte 0x81
	.4byte \param0
	.endm

	.macro jumpifnotfirstturn ptr:req
	.byte 0x82
	.4byte \ptr
	.endm

	.macro nop
	.byte 0x83
	.endm

	.macro jumpifcantmakeasleep param0:req
	.byte 0x84
	.4byte \param0
	.endm

	.macro stockpile
	.byte 0x85
	.endm

	.macro stockpiletobasedamage param0:req
	.byte 0x86
	.4byte \param0
	.endm

	.macro stockpiletohpheal param0:req
	.byte 0x87
	.4byte \param0
	.endm

	.macro negativedamage
	.byte 0x88
	.endm

	.macro statbuffchange flags:req, jumpptr:req
	.byte 0x89
	.byte \flags
	.4byte \jumpptr
	.endm

	.macro normalisebuffs
	.byte 0x8a
	.endm

	.macro setbide
	.byte 0x8b
	.endm

	.macro confuseifrepeatingattackends
	.byte 0x8c
	.endm

	.macro setmultihitcounter param0:req
	.byte 0x8d
	.byte \param0
	.endm

	.macro initmultihitstring
	.byte 0x8e
	.endm

	.macro forcerandomswitch param0:req
	.byte 0x8f
	.4byte \param0
	.endm

	.macro tryconversiontypechange param0:req
	.byte 0x90
	.4byte \param0
	.endm

	.macro givepaydaymoney
	.byte 0x91
	.endm

	.macro setlightscreen
	.byte 0x92
	.endm

	.macro tryKO param0:req
	.byte 0x93
	.4byte \param0
	.endm

	.macro damagetohalftargethp
	.byte 0x94
	.endm

	.macro setsandstorm
	.byte 0x95
	.endm

	.macro weatherdamage
	.byte 0x96
	.endm

	.macro tryinfatuating param0:req
	.byte 0x97
	.4byte \param0
	.endm

	.macro updatestatusicon battler:req
	.byte 0x98
	.byte \battler
	.endm

	.macro setmist
	.byte 0x99
	.endm

	.macro setfocusenergy
	.byte 0x9a
	.endm

	.macro transformdataexecution
	.byte 0x9b
	.endm

	.macro setsubstitute
	.byte 0x9c
	.endm

	.macro mimicattackcopy param0:req
	.byte 0x9d
	.4byte \param0
	.endm

	.macro metronome
	.byte 0x9e
	.endm

	.macro dmgtolevel
	.byte 0x9f
	.endm

	.macro psywavedamageeffect
	.byte 0xa0
	.endm

	.macro counterdamagecalculator param0:req
	.byte 0xa1
	.4byte \param0
	.endm

	.macro mirrorcoatdamagecalculator param0:req
	.byte 0xa2
	.4byte \param0
	.endm

	.macro disablelastusedattack param0:req
	.byte 0xa3
	.4byte \param0
	.endm

	.macro trysetencore param0:req
	.byte 0xa4
	.4byte \param0
	.endm

	.macro painsplitdmgcalc param0:req
	.byte 0xa5
	.4byte \param0
	.endm

	.macro settypetorandomresistance param0:req
	.byte 0xa6
	.4byte \param0
	.endm

	.macro setalwayshitflag
	.byte 0xa7
	.endm

	.macro copymovepermanently param0:req
	.byte 0xa8
	.4byte \param0
	.endm

	.macro trychoosesleeptalkmove param0:req
	.byte 0xa9
	.4byte \param0
	.endm

	.macro setdestinybond
	.byte 0xaa
	.endm

	.macro trysetdestinybondtohappen
	.byte 0xab
	.endm

	.macro remaininghptopower
	.byte 0xac
	.endm

	.macro tryspiteppreduce param0:req
	.byte 0xad
	.4byte \param0
	.endm

	.macro healpartystatus
	.byte 0xae
	.endm

	.macro cursetarget param0:req
	.byte 0xaf
	.4byte \param0
	.endm

	.macro trysetspikes param0:req
	.byte 0xb0
	.4byte \param0
	.endm

	.macro setforesight
	.byte 0xb1
	.endm

	.macro trysetperishsong param0:req
	.byte 0xb2
	.4byte \param0
	.endm

	.macro rolloutdamagecalculation
	.byte 0xb3
	.endm

	.macro jumpifconfusedandstatmaxed stat:req, ptr:req
	.byte 0xb4
	.byte \stat
	.4byte \ptr
	.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 param0:req
	.byte 0xba
	.4byte \param0
	.endm

	.macro setsunny
	.byte 0xbb
	.endm

	.macro maxattackhalvehp param0:req
	.byte 0xbc
	.4byte \param0
	.endm

	.macro copyfoestats param0:req
	.byte 0xbd
	.4byte \param0
	.endm

	.macro rapidspinfree
	.byte 0xbe
	.endm

	.macro setdefensecurlbit
	.byte 0xbf
	.endm

	.macro recoverbasedonsunlight param0:req
	.byte 0xc0
	.4byte \param0
	.endm

	.macro hiddenpowercalc
	.byte 0xc1
	.endm

	.macro selectfirstvalidtarget
	.byte 0xc2
	.endm

	.macro trysetfutureattack param0:req
	.byte 0xc3
	.4byte \param0
	.endm

	.macro trydobeatup param0:req, param1:req
	.byte 0xc4
	.4byte \param0
	.4byte \param1
	.endm

	.macro setsemiinvulnerablebit
	.byte 0xc5
	.endm

	.macro clearsemiinvulnerablebit
	.byte 0xc6
	.endm

	.macro setminimize
	.byte 0xc7
	.endm

	.macro sethail
	.byte 0xc8
	.endm

	.macro jumpifattackandspecialattackcannotfall ptr:req
	.byte 0xc9
	.4byte \ptr
	.endm

	.macro setforcedtarget
	.byte 0xca
	.endm

	.macro setcharge
	.byte 0xcb
	.endm

	.macro callterrainattack
	.byte 0xcc
	.endm

	.macro cureifburnedparalysedorpoisoned param0:req
	.byte 0xcd
	.4byte \param0
	.endm

	.macro settorment param0:req
	.byte 0xce
	.4byte \param0
	.endm

	.macro jumpifnodamage param0:req
	.byte 0xcf
	.4byte \param0
	.endm

	.macro settaunt param0:req
	.byte 0xd0
	.4byte \param0
	.endm

	.macro trysethelpinghand param0:req
	.byte 0xd1
	.4byte \param0
	.endm

	.macro tryswapitems param0:req
	.byte 0xd2
	.4byte \param0
	.endm

	.macro trycopyability param0:req
	.byte 0xd3
	.4byte \param0
	.endm

	.macro trywish param0:req, param1:req
	.byte 0xd4
	.byte \param0
	.4byte \param1
	.endm

	.macro trysetroots param0:req
	.byte 0xd5
	.4byte \param0
	.endm

	.macro doubledamagedealtifdamaged
	.byte 0xd6
	.endm

	.macro setyawn param0:req
	.byte 0xd7
	.4byte \param0
	.endm

	.macro setdamagetohealthdifference param0:req
	.byte 0xd8
	.4byte \param0
	.endm

	.macro scaledamagebyhealthratio
	.byte 0xd9
	.endm

	.macro tryswapabilities param0:req
	.byte 0xda
	.4byte \param0
	.endm

	.macro tryimprison param0:req
	.byte 0xdb
	.4byte \param0
	.endm

	.macro trysetgrudge param0:req
	.byte 0xdc
	.4byte \param0
	.endm

	.macro weightdamagecalculation
	.byte 0xdd
	.endm

	.macro assistattackselect param0:req
	.byte 0xde
	.4byte \param0
	.endm

	.macro trysetmagiccoat param0:req
	.byte 0xdf
	.4byte \param0
	.endm

	.macro trysetsnatch param0:req
	.byte 0xe0
	.4byte \param0
	.endm

	.macro trygetintimidatetarget param0:req
	.byte 0xe1
	.4byte \param0
	.endm

	.macro switchoutabilities battler:req
	.byte 0xe2
	.byte \battler
	.endm

	.macro jumpifhasnohp battler:req, param1:req
	.byte 0xe3
	.byte \battler
	.4byte \param1
	.endm

	.macro getsecretpowereffect
	.byte 0xe4
	.endm

	.macro pickup
	.byte 0xe5
	.endm

	.macro docastformchangeanimation
	.byte 0xe6
	.endm

	.macro trycastformdatachange
	.byte 0xe7
	.endm

	.macro settypebasedhalvers param0:req
	.byte 0xe8
	.4byte \param0
	.endm

	.macro setweatherballtype
	.byte 0xe9
	.endm

	.macro tryrecycleitem param0:req
	.byte 0xea
	.4byte \param0
	.endm

	.macro settypetoterrain param0:req
	.byte 0xeb
	.4byte \param0
	.endm

	.macro pursuitrelated param0:req
	.byte 0xec
	.4byte \param0
	.endm

	.macro snatchsetbattlers
	.byte 0xed
	.endm

	.macro removelightscreenreflect
	.byte 0xee
	.endm

	.macro handleballthrow
	.byte 0xef
	.endm

	.macro givecaughtmon
	.byte 0xf0
	.endm

	.macro trysetcaughtmondexflags param0:req
	.byte 0xf1
	.4byte \param0
	.endm

	.macro displaydexinfo
	.byte 0xf2
	.endm

	.macro trygivecaughtmonnick param0:req
	.byte 0xf3
	.4byte \param0
	.endm

	.macro subattackerhpbydmg
	.byte 0xf4
	.endm

	.macro removeattackerstatus1
	.byte 0xf5
	.endm

	.macro finishaction
	.byte 0xf6
	.endm

	.macro finishturn
	.byte 0xf7
	.endm

	.macro trainerslideout param0:req
	.byte 0xf8
	.byte \param0
	.endm

@ various command changed to more readable macros
	.macro cancelmultiturnmoves battler:req
	various \battler, VARIOUS_CANCEL_MULTI_TURN_MOVES
	.endm

	.macro setmagiccoattarget battler:req
	various \battler, VARIOUS_SET_MAGIC_COAT_TARGET
	.endm

	.macro getifcantrunfrombattle battler:req
	various \battler, VARIOUS_IS_RUNNING_IMPOSSIBLE
	.endm

	.macro getmovetarget battler:req
	various \battler, VARIOUS_GET_MOVE_TARGET
	.endm

	.macro getbattlerfainted battler:req
	various \battler, VARIOUS_GET_BATTLER_FAINTED
	.endm

	.macro resetintimidatetracebits battler:req
	various \battler, VARIOUS_RESET_INTIMIDATE_TRACE_BITS
	.endm

	.macro updatechoicemoveonlvlup battler:req
	various \battler, VARIOUS_UPDATE_CHOICE_MOVE_ON_LVL_UP
	.endm

	.macro various7 battler:req
	various \battler, 7
	.endm

	.macro palaceflavortext battler:req
	various \battler, VARIOUS_PALACE_FLAVOR_TEXT
	.endm

	.macro arenajudgmentwindow
	various BS_ATTACKER, VARIOUS_ARENA_JUDGMENT_WINDOW
	.endm

	.macro arenaopponentmonlost
	various BS_ATTACKER, VARIOUS_ARENA_OPPONENT_MON_LOST
	.endm

	.macro arenaplayermonlost
	various BS_ATTACKER, VARIOUS_ARENA_PLAYER_MON_LOST
	.endm

	.macro arenabothmonlost
	various BS_ATTACKER, VARIOUS_ARENA_BOTH_MONS_LOST
	.endm

	.macro forfeityesnobox battler:req
	various \battler, VARIOUS_EMIT_YESNOBOX
	.endm

	.macro various14 battler:req
	various \battler, 14
	.endm

	.macro various15 battler:req
	various \battler, 15
	.endm

	.macro arenajudmengtstring id:req
	various \id, VARIOUS_ARENA_JUDGMENT_STRING
	.endm

	.macro arenawaitmessage id:req
	various \id, VARIOUS_ARENA_WAIT_STRING
	.endm

	.macro waitcry battler:req
	various \battler, VARIOUS_WAIT_CRY
	.endm

	.macro returnopponentmon1toball battler:req
	various \battler, VARIOUS_RETURN_OPPONENT_MON1
	.endm

	.macro returnopponentmon2toball battler:req
	various \battler, VARIOUS_RETURN_OPPONENT_MON2
	.endm

	.macro volumedown
	various BS_ATTACKER, VARIOUS_VOLUME_DOWN
	.endm

	.macro volumeup
	various BS_ATTACKER, VARIOUS_VOLUME_UP
	.endm

	.macro setalreadystatusedmoveattempt battler:req
	various \battler, 23
	.endm

	.macro various24 battler:req
	various \battler, 24
	.endm

	.macro setoutcomeonteleport battler:req
	various \battler, VARIOUS_SET_TELEPORT_OUTCOME
	.endm

	.macro playtrainerdefeatbgm battler:req
	various \battler, VARIOUS_PLAY_TRAINER_DEFEATED_MUSIC
	.endm

@ helpful macros
	.macro setstatchanger stat:req, stages:req, down:req
	setbyte sSTATCHANGER \stat | \stages << 4 | \down << 7
	.endm

	.macro setmoveeffect effect:req
	setbyte cEFFECT_CHOOSER \effect
	.endm

	.macro chosenstatus1animation battler:req, status:req
	chosenstatusanimation \battler, 0x0, \status
	.endm

	.macro chosenstatus2animation battler:req, status:req
	chosenstatusanimation \battler, 0x1, \status
	.endm

	.macro sethword dst:req, value:req
	setbyte \dst, (\value) & 0xFF
	setbyte \dst + 1, ((\value) >> 8) & 0xFF
	.endm

	.macro setword dst:req, value:req
	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:req, src:req
	copyarray \dst, \src, 0x1
	.endm

	.macro copyhword dst:req, src:req
	copyarray \dst, \src, 0x2
	.endm

	.macro copyword dst:req, src:req
	copyarray \dst, \src, 0x4
	.endm

	.macro jumpifbytenotequal byte1:req, byte2:req, jumpptr:req
	jumpifarraynotequal \byte1, \byte2, 0x1, \jumpptr
	.endm

	.macro jumpifbyteequal byte1:req, byte2:req, jumpptr:req
	jumpifarrayequal \byte1, \byte2, 0x1, \jumpptr
	.endm

	.macro jumpifmove move:req, jumpptr:req
	jumpifhalfword CMP_EQUAL, gCurrentMove, \move, \jumpptr
	.endm

	.macro jumpifnotmove move:req, jumpptr:req
	jumpifhalfword CMP_NOT_EQUAL, gCurrentMove, \move, \jumpptr
	.endm

	.macro jumpifstatus3 battler:req, status:req, jumpptr:req
	jumpifstatus3condition \battler, \status, 0x0, \jumpptr
	.endm

	.macro jumpifnostatus3 battler:req, status:req, jumpptr:req
	jumpifstatus3condition \battler, \status, 0x1, \jumpptr
	.endm

	.macro jumpifmovehadnoeffect jumpptr:req
	jumpifbyte CMP_COMMON_BITS, gMoveResultFlags, MOVE_RESULT_NO_EFFECT, \jumpptr
	.endm

	.macro jumpifbattletype flags:req, jumpptr:req
	jumpifword CMP_COMMON_BITS, gBattleTypeFlags, \flags, \jumpptr
	.endm

	.macro jumpifnotbattletype flags:req, jumpptr:req
	jumpifword CMP_NO_COMMON_BITS, gBattleTypeFlags, \flags, \jumpptr
	.endm


code:
@ Verdanturf Tent

	@ Initialize the Verdanturf Battle Tent challenge
	.macro verdanturftent_init
	setvar VAR_0x8004, VERDANTURF_TENT_FUNC_INIT
	special CallVerdanturfTentFunction
	.endm

	@ Get the current prize item id
	.macro verdanturftent_getprize
	setvar VAR_0x8004, VERDANTURF_TENT_FUNC_GET_PRIZE
	special CallVerdanturfTentFunction
	.endm

	@ Unused. Set the prize item to be given
	.macro verdanturftent_setprize unusedArg:req, itemId:req
	setvar VAR_0x8004, VERDANTURF_TENT_FUNC_SET_PRIZE
	setvar VAR_0x8005, \unusedArg
	setvar VAR_0x8006, \itemId
	special CallVerdanturfTentFunction
	.endm

	@ Unused. Set the opponent trainer and gfx. SetNextBattleTentOpponent is used through tower_setopponent instead
	.macro verdanturftent_setopponentgfx
	setvar VAR_0x8004, VERDANTURF_TENT_FUNC_SET_OPPONENT_GFX
	special CallVerdanturfTentFunction
	.endm

	@ Buffers the opponents intro speech to STR_VAR_4. Despite being a Verdanturf Tent function, it serves the same purpose for all 3 tents.
	.macro battletent_getopponentintro
	setvar VAR_0x8004, VERDANTURF_TENT_FUNC_GET_OPPONENT_INTRO
	special CallVerdanturfTentFunction
	.endm

	@ Save the game and set the challenge status
	.macro verdanturftent_save challengeStatus:req
	setvar VAR_0x8004, VERDANTURF_TENT_FUNC_SAVE
	setvar VAR_0x8005, \challengeStatus
	special CallVerdanturfTentFunction
	.endm

	@ Set the prize item as randomly selected from a list. Randomness unnecessary, as the list is only 1 item
	.macro verdanturftent_setrandomprize
	setvar VAR_0x8004, VERDANTURF_TENT_FUNC_SET_RANDOM_PRIZE
	special CallVerdanturfTentFunction
	.endm

	@ Give the current prize item. FALSE if no room for prize
	.macro verdanturftent_giveprize
	setvar VAR_0x8004, VERDANTURF_TENT_FUNC_GIVE_PRIZE
	special CallVerdanturfTentFunction
	.endm

@ Fallarbor Tent

	@ Initialize the Fallarbor Battle Tent challenge
	.macro fallarbortent_init
	setvar VAR_0x8004, FALLARBOR_TENT_FUNC_INIT
	special CallFallarborTentFunction
	.endm

	@ Get the current prize item id
	.macro fallarbortent_getprize
	setvar VAR_0x8004, FALLARBOR_TENT_FUNC_GET_PRIZE
	special CallFallarborTentFunction
	.endm

	@ Unused. Set the prize item to be given
	.macro fallarbortent_setprize unusedArg:req, itemId:req
	setvar VAR_0x8004, FALLARBOR_TENT_FUNC_SET_PRIZE
	setvar VAR_0x8005, \unusedArg
	setvar VAR_0x8006, \itemId
	special CallFallarborTentFunction
	.endm

	@ Save the game and set the challenge status
	.macro fallarbortent_save challengeStatus:req
	setvar VAR_0x8004, FALLARBOR_TENT_FUNC_SAVE
	setvar VAR_0x8005, \challengeStatus
	special CallFallarborTentFunction
	.endm

	@ Set the prize item as randomly selected from a list. Randomness unnecessary, as the list is only 1 item
	.macro fallarbortent_setrandomprize
	setvar VAR_0x8004, FALLARBOR_TENT_FUNC_SET_RANDOM_PRIZE
	special CallFallarborTentFunction
	.endm

	@ Give the current prize item. FALSE if no room for prize
	.macro fallarbortent_giveprize
	setvar VAR_0x8004, FALLARBOR_TENT_FUNC_GIVE_PRIZE
	special CallFallarborTentFunction
	.endm

	@ Buffer the opponent trainers name to STR_VAR_1
	.macro fallarbortent_getopponentname
	setvar VAR_0x8004, FALLARBOR_TENT_FUNC_GET_OPPONENT_NAME
	special CallFallarborTentFunction
	.endm

@ Slateport Tent

	@ Initialize the Slateport Battle Tent challenge
	.macro slateporttent_init
	setvar VAR_0x8004, SLATEPORT_TENT_FUNC_INIT
	special CallSlateportTentFunction
	.endm

	@ Get the current prize item id
	.macro slateporttent_getprize
	setvar VAR_0x8004, SLATEPORT_TENT_FUNC_GET_PRIZE
	special CallSlateportTentFunction
	.endm

	@ Unused. Set the prize item to be given
	.macro slateporttent_setprize unusedArg:req, itemId:req
	setvar VAR_0x8004, SLATEPORT_TENT_FUNC_SET_PRIZE
	setvar VAR_0x8005, \unusedArg
	setvar VAR_0x8006, \itemId
	special CallSlateportTentFunction
	.endm

	@ Save the game and set the challenge status
	.macro slateporttent_save challengeStatus:req
	setvar VAR_0x8004, SLATEPORT_TENT_FUNC_SAVE
	setvar VAR_0x8005, \challengeStatus
	special CallSlateportTentFunction
	.endm

	@ Set the prize item as randomly selected from a list. Randomness unnecessary, as the list is only 1 item
	.macro slateporttent_setrandomprize
	setvar VAR_0x8004, SLATEPORT_TENT_FUNC_SET_RANDOM_PRIZE
	special CallSlateportTentFunction
	.endm

	@ Give the current prize item. FALSE if no room for prize
	.macro slateporttent_giveprize
	setvar VAR_0x8004, SLATEPORT_TENT_FUNC_GIVE_PRIZE
	special CallSlateportTentFunction
	.endm

	@ Slateport Tent's version of factory_rentmons
	.macro slateporttent_rentmons
	setvar VAR_0x8004, SLATEPORT_TENT_FUNC_SELECT_RENT_MONS
	special CallSlateportTentFunction
	.endm

	@ Slateport Tent's version of factory_swapmons
	.macro slateporttent_swapmons
	setvar VAR_0x8004, SLATEPORT_TENT_FUNC_SWAP_RENT_MONS
	special CallSlateportTentFunction
	.endm

	@ Slateport Tent's version of factory_generateopponentmons
	.macro slateporttent_generateopponentmons
	setvar VAR_0x8004, SLATEPORT_TENT_FUNC_GENERATE_OPPONENT_MONS
	special CallSlateportTentFunction
	.endm

	@ Slateport Tent's version of factory_generaterentalmons
	.macro slateporttent_generaterentalmons
	setvar VAR_0x8004, SLATEPORT_TENT_FUNC_GENERATE_RENTAL_MONS
	special CallSlateportTentFunction
	.endm

repo_name: Lunos/pokeemerald

license: mit


code:
@ A large number of the Contest AI commands go unused, so their corresponding macros in this file are similarly unused

@ Add a positive/negative value to the score of the move being evaluated.

	.macro score score:req
	.byte 0x00
	.byte \score
	.endm

	.macro get_appeal_num
	.byte 0x01
	.endm

	.macro if_appeal_num_less_than num:req, destination:req
	.byte 0x02
	.byte \num
	.4byte \destination
	.endm

	.macro if_appeal_num_more_than num:req, destination:req
	.byte 0x03
	.byte \num
	.4byte \destination
	.endm

	.macro if_appeal_num_eq num:req, destination:req
	.byte 0x04
	.byte \num
	.4byte \destination
	.endm

	.macro if_appeal_num_not_eq num:req, destination:req
	.byte 0x05
	.byte \num
	.4byte \destination
	.endm

	.macro if_last_appeal destination:req
	if_appeal_num_eq CONTEST_LAST_APPEAL, \destination
	.endm

	.macro if_not_last_appeal destination:req
	if_appeal_num_not_eq CONTEST_LAST_APPEAL, \destination
	.endm

@ audience excitement

	.macro get_excitement
	.byte 0x06
	.endm

	.macro if_excitement_less_than num:req, destination:req
	.byte 0x07
	.byte \num
	.4byte \destination
	.endm

	.macro if_excitement_more_than num:req, destination:req
	.byte 0x08
	.byte \num
	.4byte \destination
	.endm

	.macro if_excitement_eq num:req, destination:req
	.byte 0x09
	.byte \num
	.4byte \destination
	.endm

	.macro if_excitement_not_eq num:req, destination:req
	.byte 0x0A
	.byte \num
	.4byte \destination
	.endm

@ the order that the user goes in the current appeal

	.macro get_user_order
	.byte 0x0B
	.endm

	.macro if_user_order_less_than num:req, destination:req
	.byte 0x0C
	.byte \num
	.4byte \destination
	.endm

	.macro if_user_order_more_than num:req, destination:req
	.byte 0x0D
	.byte \num
	.4byte \destination
	.endm

	.macro if_user_order_eq num:req, destination:req
	.byte 0x0E
	.byte \num
	.4byte \destination
	.endm

	.macro if_user_order_not_eq num:req, destination:req
	.byte 0x0F
	.byte \num
	.4byte \destination
	.endm

@ user condition

	.macro get_user_condition
	.byte 0x10
	.endm

	.macro if_user_condition_less_than num:req, destination:req
	.byte 0x11
	.byte \num
	.4byte \destination
	.endm

	.macro if_user_condition_more_than num:req, destination:req
	.byte 0x12
	.byte \num
	.4byte \destination
	.endm

	.macro if_user_condition_eq num:req, destination:req
	.byte 0x13
	.byte \num
	.4byte \destination
	.endm

	.macro if_user_condition_not_eq num:req, destination:req
	.byte 0x14
	.byte \num
	.4byte \destination
	.endm

@ appeal points

	.macro get_point_total
	.byte 0x15
	.endm

	.macro if_points_less_than num:req, destination:req
	.byte 0x16
	.byte \num
	.4byte \destination
	.endm

	.macro if_points_more_than num:req, destination:req
	.byte 0x17
	.byte \num
	.4byte \destination
	.endm

	.macro if_points_eq num:req, destination:req
	.byte 0x18
	.byte \num
	.4byte \destination
	.endm

	.macro if_points_not_eq num:req, destination:req
	.byte 0x19
	.byte \num
	.4byte \destination
	.endm

@ preliminary (pre-appeal) judging points

	.macro get_preliminary_points
	.byte 0x1A
	.endm

	.macro if_preliminary_points_less_than num:req, destination:req
	.byte 0x1B
	.byte \num
	.4byte \destination
	.endm

	.macro if_preliminary_points_more_than num:req, destination:req
	.byte 0x1C
	.byte \num
	.4byte \destination
	.endm

	.macro if_preliminary_points_eq num:req, destination:req
	.byte 0x1D
	.byte \num
	.4byte \destination
	.endm

	.macro if_preliminary_points_not_eq num:req, destination:req
	.byte 0x1E
	.byte \num
	.4byte \destination
	.endm

@ contest type

	.macro get_contest_type
	.byte 0x1F
	.endm

	.macro if_contest_type_eq type:req, destination:req
	.byte 0x20
	.byte \type
	.4byte \destination
	.endm

	.macro if_contest_type_not_eq type:req, destination:req
	.byte 0x21
	.byte \type
	.4byte \destination
	.endm

@ move excitement (change in excitement due to move)

	.macro get_move_excitement
	.byte 0x22
	.endm

	.macro if_move_excitement_less_than num:req, destination:req
	.byte 0x23
	.byte \num
	.4byte \destination
	.endm

	.macro if_move_excitement_more_than num:req, destination:req
	.byte 0x24
	.byte \num
	.4byte \destination
	.endm

	.macro if_move_excitement_eq num:req, destination:req
	.byte 0x25
	.byte \num
	.4byte \destination
	.endm

	.macro if_move_excitement_not_eq num:req, destination:req
	.byte 0x26
	.byte \num
	.4byte \destination
	.endm

@ move effect

	.macro get_effect
	.byte 0x27
	.endm

	.macro if_effect_eq effect:req, destination:req
	.byte 0x28
	.byte \effect
	.4byte \destination
	.endm

	.macro if_effect_not_eq effect:req, destination:req
	.byte 0x29
	.byte \effect
	.4byte \destination
	.endm

@ move effect type

	.macro get_effect_type
	.byte 0x2A
	.endm

	.macro if_effect_type_eq type:req, destination:req
	.byte 0x2B
	.byte \type
	.4byte \destination
	.endm

	.macro if_effect_type_not_eq type:req, destination:req
	.byte 0x2C
	.byte \type
	.4byte \destination
	.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 destination:req
	.byte 0x2E
	.4byte \destination
	.endm

@ whether the current move is the most jamming in the user's moveset

	.macro check_most_jamming_move
	.byte 0x2F
	.endm

	.macro if_most_jamming_move destination:req
	.byte 0x30
	.4bye \destination
	.endm

@ number of hearts the current move's appeal would provide

	.macro get_num_move_hearts
	.byte 0x31
	.endm

	.macro if_num_move_hearts_less_than num:req, destination:req
	.byte 0x32
	.byte \num
	.4byte \destination
	.endm

	.macro if_num_move_hearts_more_than num:req, destination:req
	.byte 0x33
	.byte \num
	.4byte \destination
	.endm

	.macro if_num_move_hearts_eq num:req, destination:req
	.byte 0x34
	.byte \num
	.4byte \destination
	.endm

	.macro if_num_move_hearts_not_eq num:req, destination:req
	.byte 0x35
	.byte \num
	.4byte \destination
	.endm

@ number of hearts the current move's jam would remove

	.macro get_num_move_jam_hearts
	.byte 0x36
	.endm

	.macro if_num_move_jam_hearts_less_than num:req, destination:req
	.byte 0x37
	.byte \num
	.4byte \destination
	.endm

	.macro if_num_move_jam_hearts_more_than num:req, destination:req
	.byte 0x38
	.byte \num
	.4byte \destination
	.endm

	.macro if_num_move_jam_hearts_eq num:req, destination:req
	.byte 0x39
	.byte \num
	.4byte \destination
	.endm

	.macro if_num_move_jam_hearts_not_eq num:req, destination:req
	.byte 0x3A
	.byte \num
	.4byte \destination
	.endm

@ number of times current move has been used

	.macro get_move_used_count
	.byte 0x3B
	.endm

	.macro if_move_used_count_less_than num:req, destination:req
	.byte 0x3C
	.byte \num
	.4byte \destination
	.endm

	.macro if_move_used_count_more_than num:req, destination:req
	.byte 0x3D
	.byte \num
	.4byte \destination
	.endm

	.macro if_move_used_count_eq num:req, destination:req
	.byte 0x3E
	.byte \num
	.4byte \destination
	.endm

	.macro if_move_used_count_not_eq num:req, destination:req
	.byte 0x3F
	.byte \num
	.4byte \destination
	.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 destination:req
	.byte 0x41
	.4byte \destination
	.endm

	.macro if_not_combo_starter destination:req
	.byte 0x42
	.4byte \destination
	.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 destination:req
	.byte 0x44
	.4byte \destination
	.endm

	.macro if_not_combo_finisher destination:req
	.byte 0x45
	.4byte \destination
	.endm

@ whether the current move would finish a combo

	.macro check_would_finish_combo
	.byte 0x46
	.endm

	.macro if_would_finish_combo destination:req
	.byte 0x47
	.4byte \destination
	.endm

	.macro if_would_not_finish_combo destination:req
	.byte 0x48
	.4byte \destination
	.endm

@ condition of mon (indexed by order)

	.macro get_condition mon:req
	.byte 0x49
	.byte \mon
	.endm

	.macro if_condition_less_than mon:req, num:req destination:req
	.byte 0x4A
	.byte \mon
	.byte \num
	.4byte \destination
	.endm

	.macro if_condition_more_than mon:req, num:req, destination:req
	.byte 0x4B
	.byte \mon
	.byte \num
	.4byte \destination
	.endm

	.macro if_condition_eq mon:req, num:req, destination:req
	.byte 0x4C
	.byte \mon
	.byte \num
	.4byte \destination
	.endm

	.macro if_condition_not_eq mon:req, num:req, destination:req
	.byte 0x4D
	.byte \mon
	.byte \num
	.4byte \destination
	.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:req
	.byte 0x4E
	.byte \mon
	.endm

	.macro if_used_combo_starter_less_than mon:req, num:req, destination:req
	.byte 0x4F
	.byte \mon
	.byte \num
	.4byte \destination
	.endm

	.macro if_used_combo_starter_more_than mon:req, num:req, destination:req
	.byte 0x50
	.byte \mon
	.byte \num
	.4byte \destination
	.endm

	.macro if_used_combo_starter_eq mon:req, num:req, destination:req
	.byte 0x51
	.byte \mon
	.byte \num
	.4byte \destination
	.endm

	.macro if_used_combo_starter_not_eq mon:req, num:req, destination:req
	.byte 0x52
	.byte \mon
	.byte \num
	.4byte \destination
	.endm

	.macro if_used_combo_starter mon:req, destination:req
	if_used_combo_starter_eq \mon, TRUE, \destination
	.endm

	.macro if_not_used_combo_starter mon:req, destination:req
	if_used_combo_starter_eq \mon, FALSE, \destination
	.endm

@ whether the mon can make an appeal

	.macro check_can_participate mon:req
	.byte 0x53
	.byte \mon
	.endm

	.macro if_can_participate mon:req, destination:req
	.byte 0x54
	.byte \mon
	.4byte \destination
	.endm

	.macro if_cannot_participate mon:req, destination:req
	.byte 0x55
	.byte \mon
	.4byte \destination
	.endm

@ whether the mon just completed a combo

	.macro get_completed_combo mon:req
	.byte 0x56
	.byte \mon
	.4byte \destination
	.endm

	.macro if_completed_combo mon:req, destination:req
	.byte 0x57
	.byte \mon
	.4byte \destination
	.endm

	.macro if_not_completed_combo mon:req destination:req
	.byte 0x58
	.byte \mon
	.4byte \destination
	.endm

@ comparing appeal points to another mon

	.macro get_points_diff mon:req
	.byte 0x59
	.byte \mon
	.endm

	.macro if_points_more_than_mon mon:req, destination:req
	.byte 0x5A
	.byte \mon
	.4byte \destination
	.endm

	.macro if_points_less_than_mon mon:req, destination:req
	.byte 0x5B
	.byte \mon
	.4byte \destination
	.endm

	.macro if_points_eq_mon mon:req, destination:req
	.byte 0x5C
	.byte \mon
	.4byte \destination
	.endm

	.macro if_points_not_eq_mon mon:req, destination:req
	.byte 0x5D
	.byte \mon
	.4byte \destination
	.endm

@ comparing preliminary judging points to another mon

	.macro get_preliminary_points_diff mon:req
	.byte 0x5E
	.byte \mon
	.endm

	.macro if_preliminary_points_more_than_mon mon:req, destination:req
	.byte 0x5F
	.byte \mon
	.4byte \destination
	.endm

	.macro if_preliminary_points_less_than_mon mon:req, destination:req
	.byte 0x60
	.byte \mon
	.4byte \destination
	.endm

	.macro if_preliminary_points_eq_mon mon:req, destination:req
	.byte 0x61
	.byte \mon
	.4byte \destination
	.endm

	.macro if_preliminary_points_not_eq_mon mon:req, destination:req
	.byte 0x62
	.byte \mon
	.4byte \destination
	.endm

@ checking move history for move effect

	.macro get_used_moves_effect mon:req, round:req
	.byte 0x63
	.byte \mon
	.byte \round
	.endm

	.macro if_used_moves_effect_less_than mon:req, round:req, effect:req, destination:req
	.byte 0x64
	.byte \mon
	.byte \round
	.byte \effect
	.4byte \destination
	.endm

	.macro if_used_moves_effect_more_than mon:req, round:req, effect:req, destination:req
	.byte 0x65
	.byte \mon
	.byte \round
	.byte \effect
	.4byte \destination
	.endm

	.macro if_used_moves_effect_eq mon:req, round:req, effect:req, destination:req
	.byte 0x66
	.byte \mon
	.byte \round
	.byte \effect
	.4byte \destination
	.endm

	.macro if_used_moves_effect_not_eq mon:req, round:req, effect:req, destination:req
	.byte 0x67
	.byte \mon
	.byte \round
	.byte \effect
	.4byte \destination
	.endm

@ checking move history for excitement

	.macro get_used_moves_excitement mon:req, round:req
	.byte 0x68
	.byte \mon
	.byte \round
	.endm

	.macro if_used_moves_excitement_less_than mon:req, round:req, num:req, destination:req
	.byte 0x69
	.byte \mon
	.byte \round
	.byte \num
	.4byte \destination
	.endm

	.macro if_used_moves_excitement_more_than mon:req, round:req, num:req, destination:req
	.byte 0x6A
	.byte \mon
	.byte \round
	.byte \num
	.4byte \destination
	.endm

	.macro if_used_moves_excitement_eq mon:req, round:req, num:req, destination:req
	.byte 0x6B
	.byte \mon
	.byte \round
	.byte \num
	.4byte \destination
	.endm

	.macro if_used_moves_excitement_not_eq mon:req, round:req, num:req, destination:req
	.byte 0x6C
	.byte \mon
	.byte \round
	.byte \num
	.4byte \destination
	.endm

@ checking move history for effect type

	.macro get_used_moves_effect_type mon:req, round:req
	.byte 0x6D
	.byte \mon
	.byte \round
	.endm

	.macro if_used_moves_effect_type_eq mon:req, round:req, type:req, destination:req
	.byte 0x6E
	.byte \mon
	.byte \round
	.byte \type
	.4byte \destination
	.endm

	.macro if_used_moves_effect_type_not_eq mon:req, round:req, type:req, destination:req
	.byte 0x6F
	.byte \mon
	.byte \round
	.byte \type
	.4byte \destination
	.endm

@ generic commands

	.macro save_result varId:req
	.byte 0x70
	.byte \varId
	.endm

	.macro setvar varId:req, num:req
	.byte 0x71
	.byte \varId
	.2byte \num
	.endm

	.macro add varId:req, num:req
	.byte 0x72
	.byte \varId
	.2byte \num
	.endm

	.macro addvar varId1:req, varId2:req
	.byte 0x73
	.byte \varId1
	.byte \varId2
	.endm

	@ Duplicate of above
	.macro addvar_duplicate varId1:req, varId2:req
	.byte 0x74
	.byte \varId1
	.byte \varId2
	.endm

	.macro if_less_than varId:req, num:req, destination:req
	.byte 0x75
	.byte \varId
	.2byte \num
	.4byte \destination
	.endm

	.macro if_greater_than varId:req, num:req, destination:req
	.byte 0x76
	.byte \varId
	.2byte \num
	.4byte \destination
	.endm

	.macro if_eq varId:req, num:req, destination:req
	.byte 0x77
	.byte \varId
	.2byte \num
	.4byte \destination
	.endm

	.macro if_not_eq varId:req, num:req, destination:req
	.byte 0x78
	.byte \varId
	.2byte \num
	.4byte \destination
	.endm

	.macro if_less_than_var varId1:req, varId2:req, destination:req
	.byte 0x79
	.byte \varId1
	.byte \varId2
	.4byte \destination
	.endm

	.macro if_greater_than_var varId1:req, varId2:req, destination:req
	.byte 0x7A
	.byte \varId1
	.byte \varId2
	.4byte \destination
	.endm

	.macro if_eq_var varId1:req, varId2:req, destination:req
	.byte 0x7B
	.byte \varId1
	.byte \varId2
	.4byte \destination
	.endm

	.macro if_not_eq_var varId1:req, varId2:req, destination:req
	.byte 0x7C
	.byte \varId1
	.byte \varId2
	.4byte \destination
	.endm

	@ NOTE: The random commands are broken (see ContestAICmd_if_random_less_than)
	.macro if_random_less_than num:req, destination:req
	.byte 0x7D
	.byte \num
	.4byte \destination
	.endm

	.macro if_random_greater_than num:req, destination:req
	.byte 0x7E
	.byte \num
	.4byte \destination
	.endm

	.macro goto destination:req
	.byte 0x7F
	.4byte \destination
	.endm

	.macro call destination:req
	.byte 0x80
	.4byte \destination
	.endm

	.macro end
	.byte 0x81
	.endm

	.macro check_user_has_exciting_move
	.byte 0x82
	.endm

	.macro if_user_has_exciting_move destination:req
	.byte 0x83
	.4byte \destination
	.endm

	.macro if_user_doesnt_have_exciting_move destination:req
	.byte 0x84
	.4byte \destination
	.endm

	@ This is used incorrectly to check for an effect; see ContestAICmd_check_user_has_move
	.macro check_user_has_move move:req
	.byte 0x85
	.2byte \move
	.endm

	.macro if_user_has_move move:req, destination:req
	.byte 0x86
	.2byte \move
	.4byte \destination
	.endm

	.macro if_user_doesnt_have_move move:req, destination:req
	.byte 0x87
	.2byte \move
	.4byte \destination
	.endm


code:
	.macro ec_word word
	.2byte EC_WORD_\word
	.endm

	.macro ec_move1 name
	.2byte (EC_GROUP_MOVE_1 << 9) | MOVE_\name
	.endm

	.macro ec_move2 name
	.2byte (EC_GROUP_MOVE_2 << 9) | MOVE_\name
	.endm

	.macro ec_pokemon1 name
	.2byte (EC_GROUP_POKEMON << 9) | SPECIES_\name
	.endm

	.macro ec_pokemon2 name
	.2byte (EC_GROUP_POKEMON2 << 9) | SPECIES_\name
	.endm


code:
	@ 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:req
	.byte 0x04
	.4byte \destination
	.endm

	@ Jumps to destination and continues script execution from there.
	.macro goto destination:req
	.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:req, destination:req
	.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:req, destination:req
	.byte 0x07
	.byte \condition
	.4byte \destination
	.endm

	@ Jumps to the standard function at index function.
	.macro gotostd function:req
	.byte 0x08
	.byte \function
	.endm

	@ callstd function names
	STD_OBTAIN_ITEM = 0
	STD_FIND_ITEM = 1
	STD_OBTAIN_DECORATION = 7
	STD_REGISTER_MATCH_CALL = 8

	@ Calls the standard function at index function.
	.macro callstd function:req
	.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:req, function:req
	.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:req, function:req
	.byte 0x0b
	.byte \condition
	.byte \function
	.endm

	@ Executes a script stored in a default RAM location.
	.macro returnram
	.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:req
	.byte 0x0e
	.byte \value
	.endm

	@ Sets the specified script bank to value.
	.macro loadword destination:req, value:req
	.byte 0x0f
	.byte \destination
	.4byte \value
	.endm

	@ Sets the specified script bank to value.
	.macro loadbyte destination:req, value:req
	.byte 0x10
	.byte \destination
	.byte \value
	.endm

	@ Sets the byte at offset to value.
	.macro writebytetoaddr value:req, offset:req
	.byte 0x11
	.byte \value
	.4byte \offset
	.endm

	@ Copies the byte value at source into the specified script bank.
	.macro loadbytefromaddr destination:req, source:req
	.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:req, destination:req
	.byte 0x13
	.byte \source
	.4byte \destination
	.endm

	@ Copies the contents of bank source into bank destination.
	.macro copylocal destination:req, source:req
	.byte 0x14
	.byte \destination
	.byte \source
	.endm

	@ Copies the byte at source to destination, replacing whatever byte was previously there.
	.macro copybyte destination:req, source:req
	.byte 0x15
	.4byte \destination
	.4byte \source
	.endm

	@ Changes the value of destination to value.
	.macro setvar destination:req, value:req
	.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:req, value:req
	.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:req, value:req
	.byte 0x18
	.2byte \destination
	.2byte \value
	.endm

	@ Copies the value of source into destination.
	.macro copyvar destination:req, source:req
	.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:req, source:req
	.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:req, byte2:req
	.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:req, b:req
	.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:req, b:req
	.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:req, b:req
	.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:req, b:req
	.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:req, b:req
	.byte 0x20
	.4byte \a
	.4byte \b
	.endm

	@ Compares the value of `var` to a fixed word value (b).
	.macro compare_var_to_value var:req, value:req
	.byte 0x21
	.2byte \var
	.2byte \value
	.endm

	@ Compares the value of `var1` to the value of `var2`.
	.macro compare_var_to_var var1:req, var2:req
	.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 0x40FF and 0x8000 to 0x8015 are considered event variable identifiers
	.macro compare var:req, arg:req
		.if ((\arg >= VARS_START && \arg <= VARS_END) || (\arg >= SPECIAL_VARS_START && \arg <= SPECIAL_VARS_END))
			compare_var_to_var \var, \arg
		.else
			compare_var_to_value \var, \arg
		.endif
	.endm

	@ Calls the native C function stored at `func`.
	.macro callnative func:req
	.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:req
	.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:req
	.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:req, function:req
	.byte 0x26
	.2byte \output
	.2byte SPECIAL_\function
	.endm

	@ temporary solution
	.macro specialvar_ output:req, functionId:req
	.byte 0x26
	.2byte \output
	.2byte \functionId
	.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 frames. (Pokemon Emerald runs at just shy of 60 frames per second.)
	.macro delay frames:req
	.byte 0x28
	.2byte \frames
	.endm

	@ Sets a to 1.
	.macro setflag a:req
	.byte 0x29
	.2byte \a
	.endm

	@ Sets a to 0.
	.macro clearflag a:req
	.byte 0x2a
	.2byte \a
	.endm

	@ Compares a to 1.
	.macro checkflag a:req
	.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:req, minute:req
	.byte 0x2c
	.2byte \hour
	.2byte \minute
	.endm

	@ Runs time based events. In FireRed, this command is a nop.
	.macro dotimebasedevents
	.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:req
	.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:req
	.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:req, unknown:req
	.byte 0x33
	.2byte \song_number
	.byte \unknown
	.endm

	@ Saves the specified (song_number) song to be played later.
	.macro savebgm song_number:req
	.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:req
	.byte 0x36
	.2byte \song_number
	.endm

	@ Fades out the currently-playing song.
	.macro fadeoutbgm speed:req
	.byte 0x37
	.byte \speed
	.endm

	@ Fades the previously-playing song back in.
	.macro fadeinbgm speed:req
	.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:req, warp:req, X:req, Y:req
	.byte 0x39
	map \map
	.byte \warp
	.2byte \X
	.2byte \Y
	.endm

	@ Clone of warp that does not play a sound effect.
	.macro warpsilent map:req, warp:req, X:req, Y:req
	.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:req, warp:req, X:req, Y:req
	.byte 0x3b
	map \map
	.byte \warp
	.2byte \X
	.2byte \Y
	.endm

	@ Warps the player to another map using a hole animation.
	.macro warphole map:req
	.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:req, warp:req, X:req, Y:req
	.byte 0x3d
	map \map
	.byte \warp
	.2byte \X
	.2byte \Y
	.endm

	@ Sets the warp destination to be used later.
	.macro setwarp map:req, warp:req, X:req, Y:req
	.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:req, warp:req, X:req, Y:req
	.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:req, warp:req, X:req, Y:req
	.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:req, warp:req, X:req, Y:req
	.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:req, Y:req
	.byte 0x42
	.2byte \X
	.2byte \Y
	.endm

	@ Retrieves the number of Pokemon in the player's party, and stores that number in VAR_RESULT.
	.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
	@ VAR_RESULT will be set to TRUE; otherwise, VAR_RESULT is set to FALSE.
	.macro additem index:req, quantity=1
	.byte 0x44
	.2byte \index
	.2byte \quantity
	.endm

	@ Removes quantity of item index from the player's Bag.
	.macro removeitem index:req, quantity=1
	.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 VAR_RESULT to
	@ TRUE if there is room, or FALSE is there is no room.
	.macro checkitemspace index:req, quantity:req
	.byte 0x46
	.2byte \index
	.2byte \quantity
	.endm

	@ Checks if the player has quantity or more of item index in their Bag. Sets VAR_RESULT to TRUE if the player has
	@ enough of the item, or FALSE if they have fewer than quantity of the item.
	.macro checkitem index:req, quantity:req
	.byte 0x47
	.2byte \index
	.2byte \quantity
	.endm

	@ Checks which Bag pocket the specified item belongs in, and writes the pocket value (POCKET_*) to VAR_RESULT.
	@ 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:req
	.byte 0x48
	.2byte \index
	.endm

	@ Adds a quantity amount of item index to the player's PC. Both arguments can be variables.
	.macro addpcitem index:req, quantity:req
	.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:req, quantity:req
	.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 adddecoration decoration:req
	.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 removedecoration decoration:req
	.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:req
	.byte 0x4d
	.2byte \decoration
	.endm

	@ Checks if the player has enough space in their PC to hold decoration. Sets VAR_RESULT to TRUE if there is room, or
	@ FALSE is there is no room. In FireRed, this command is a nop. (The argument is read, but not used for anything.)
	.macro checkdecorspace decoration:req
	.byte 0x4e
	.2byte \decoration
	.endm

	@ Applies the movement data at movements to the specified (index) Object. Also closes any standard message boxes that are still open.
	@ If no map is specified, then the current map is used.
	.macro applymovement index:req, movements:req, map
		.ifb \map
			.byte 0x4f
			.2byte \index
			.4byte \movements
		.else
			@ Really only useful if the object has followed from one map to another (e.g. Wally during the catching event).
			.byte 0x50
			.2byte \index
			.4byte \movements
			map \map
		.endif
	.endm

	@ Blocks script execution until the movements being applied to the specified (index) Object finish.
	@ If the specified Object is 0x0000, then the command will block script execution until all Objects
	@ affected by applymovement finish their movements. If the specified Object is not currently being
	@ manipulated with applymovement, then this command does nothing.
	@ If no map is specified, then the current map is used.
	.macro waitmovement index:req, map
		.ifb \map
			.byte 0x51
			.2byte \index
		.else
			.byte 0x52
			.2byte \index
			map \map
		.endif
	.endm

	@ Attempts to hide the specified (index) Object on the specified (map_group, map_num) 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 index:req, map
		.ifb \map
			.byte 0x53
			.2byte \index
		.else
			.byte 0x54
			.2byte \index
			map \map
		.endif
	.endm

	@ Unsets the specified (index) Object's visibility flag on the specified (map_group, map_num) map 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 addobject index:req, map
		.ifb \map
			.byte 0x55
			.2byte \index
		.else
			.byte 0x56
			.2byte \index
			map \map
		.endif
	.endm

	@ Sets the specified (index) Object's position on the current map.
	.macro setobjectxy index:req, x:req, y:req
	.byte 0x57
	.2byte \index
	.2byte \x
	.2byte \y
	.endm

	.macro showobjectat index:req, map:req
	.byte 0x58
	.2byte \index
	map \map
	.endm

	.macro hideobjectat index:req, map:req
	.byte 0x59
	.2byte \index
	map \map
	.endm

	@ If the script was called by an Object, then that Object will turn to face toward the metatile that the player is standing on.
	.macro faceplayer
	.byte 0x5a
	.endm

	.macro turnobject index:req, direction:req
	.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:req, trainer:req, local_id:req, pointer1:req, pointer2, pointer3, pointer4
	.byte 0x5c
	.byte \type
	.2byte \trainer
	.2byte \local_id
	.if \type == TRAINER_BATTLE_SINGLE
		.4byte \pointer1 @ text
		.4byte \pointer2 @ text
	.elseif \type == TRAINER_BATTLE_CONTINUE_SCRIPT_NO_MUSIC
		.4byte \pointer1 @ text
		.4byte \pointer2 @ text
		.4byte \pointer3 @ event script
	.elseif \type == TRAINER_BATTLE_CONTINUE_SCRIPT
		.4byte \pointer1 @ text
		.4byte \pointer2 @ text
		.4byte \pointer3 @ event script
	.elseif \type == TRAINER_BATTLE_SINGLE_NO_INTRO_TEXT
		.4byte \pointer1 @ text
	.elseif \type == TRAINER_BATTLE_DOUBLE
		.4byte \pointer1 @ text
		.4byte \pointer2 @ text
		.4byte \pointer3 @ text
	.elseif \type == TRAINER_BATTLE_REMATCH
		.4byte \pointer1 @ text
		.4byte \pointer2 @ text
	.elseif \type == TRAINER_BATTLE_CONTINUE_SCRIPT_DOUBLE
		.4byte \pointer1 @ text
		.4byte \pointer2 @ text
		.4byte \pointer3 @ text
		.4byte \pointer4 @ event script
	.elseif \type == TRAINER_BATTLE_REMATCH_DOUBLE
		.4byte \pointer1 @ text
		.4byte \pointer2 @ text
		.4byte \pointer3 @ text
	.elseif \type == TRAINER_BATTLE_CONTINUE_SCRIPT_DOUBLE_NO_MUSIC
		.4byte \pointer1 @ text
		.4byte \pointer2 @ text
		.4byte \pointer3 @ text
		.4byte \pointer4 @ event script
	.elseif \type == TRAINER_BATTLE_PYRAMID
		.4byte \pointer1 @ text
		.4byte \pointer2 @ text
	.elseif \type == TRAINER_BATTLE_SET_TRAINER_A
		.4byte \pointer1 @ text
		.4byte \pointer2 @ text
	.elseif \type == TRAINER_BATTLE_SET_TRAINER_B
		.4byte \pointer1 @ text
		.4byte \pointer2 @ text
	.elseif \type == TRAINER_BATTLE_HILL
		.4byte \pointer1 @ text
		.4byte \pointer2 @ text
	.endif
	.endm

	NO_MUSIC = FALSE

	@ Starts a single trainer battle, takes a trainer, intro text, loss text, and an optional event script
	@ when used with an event script, you can also pass in an optional flag to disable music
	.macro trainerbattle_single trainer:req, intro_text:req, lose_text:req, event_script=FALSE, music=TRUE
	.if \event_script == FALSE
	trainerbattle TRAINER_BATTLE_SINGLE, \trainer, 0, \intro_text, \lose_text
	.elseif \music == TRUE
	trainerbattle TRAINER_BATTLE_CONTINUE_SCRIPT, \trainer, 0, \intro_text, \lose_text, \event_script
	.else
	trainerbattle TRAINER_BATTLE_CONTINUE_SCRIPT_NO_MUSIC, \trainer, 0, \intro_text, \lose_text, \event_script
	.endif
	.endm

	@ Starts a double trainer battle, takes a trainer, intro text, loss text, text for when you have too few pokemon
	@ and an optional event script, when used with an event script you can pass in an optional flag to disable music
	.macro trainerbattle_double trainer:req, intro_text:req, lose_text:req, not_enough_pkmn_text:req, event_script=FALSE, music=TRUE
	.if \event_script == FALSE
	trainerbattle TRAINER_BATTLE_DOUBLE, \trainer, 0, \intro_text, \lose_text, \not_enough_pkmn_text
	.elseif \music == TRUE
	trainerbattle TRAINER_BATTLE_CONTINUE_SCRIPT_DOUBLE, \trainer, 0, \intro_text, \lose_text, \not_enough_pkmn_text, \event_script
	.else
	trainerbattle TRAINER_BATTLE_CONTINUE_SCRIPT_DOUBLE_NO_MUSIC, \trainer, 0, \intro_text, \lose_text, \not_enough_pkmn_text, \event_script
	.endif
	.endm

	@ Starts a rematch battle, takes a trainer, intro text and loss text
	.macro trainerbattle_rematch trainer:req, intro_text:req, lose_text:req
	trainerbattle TRAINER_BATTLE_REMATCH, \trainer, 0, \intro_text, \lose_text
	.endm

	@ Starts a rematch double battle, takes a trainer, intro text, loss text, and text for when you have too few pokemon
	.macro trainerbattle_rematch_double trainer:req, intro_text:req, lose_text:req, not_enough_pkmn_text:req
	trainerbattle TRAINER_BATTLE_REMATCH_DOUBLE, \trainer, 0, \intro_text, \lose_text, \not_enough_pkmn_text
	.endm

	@ Starts a trainer battle, skipping intro text, takes a trainer and loss text
	.macro trainerbattle_no_intro trainer:req, lose_text:req
	trainerbattle TRAINER_BATTLE_SINGLE_NO_INTRO_TEXT, \trainer, 0, \lose_text
	.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:req
	.byte 0x60
	.2byte \trainer
	.endm

	@ Sets Flag (trainer + 0x500).
	.macro settrainerflag trainer:req
	.byte 0x61
	.2byte \trainer
	.endm

	@ Clears Flag (trainer + 0x500).
	.macro cleartrainerflag trainer:req
	.byte 0x62
	.2byte \trainer
	.endm

	.macro setobjectxyperm index:req, x:req, y:req
	.byte 0x63
	.2byte \index
	.2byte \x
	.2byte \y
	.endm

	@ Copies a live object event's xy position to its template, so that if the sprite goes off screen,
	@ it'll still be there when it comes back on screen.
	.macro copyobjectxytoperm index:req
	.byte 0x64
	.2byte \index
	.endm

	.macro setobjectmovementtype word:req, byte:req
	.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:req
	.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 VAR_RESULT as NO (0) or YES (1). Pressing B is equivalent to answering NO
	.macro yesnobox x:req, y:req
	.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 (sMultichoiceLists) 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:req, y:req, list:req, b:req
	.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 (sMultichoiceLists) 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:req, y:req, list:req, default:req, b:req
	.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 (sMultichoiceLists) 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:req, y:req, list:req, per_row:req, B:req
	.byte 0x71
	.byte \x
	.byte \y
	.byte \list
	.byte \per_row
	.byte \B
	.endm

	@ Nopped in Emerald.
	.macro drawbox
	.byte 0x72
	.endm

	@ Nopped in Emerald, but still consumes parameters.
	.macro erasebox byte1:req, byte2:req, byte3:req, byte4:req
	.byte 0x73
	.byte \byte1
	.byte \byte2
	.byte \byte3
	.byte \byte4
	.endm

	@ Nopped in Emerald, but still consumes parameters.
	.macro drawboxtext byte1:req, byte2:req, byte3:req, byte4:req
	.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 showmonpic species:req, x:req, y:req
	.byte 0x75
	.2byte \species
	.byte \x
	.byte \y
	.endm

	@ Hides all boxes displayed with showmonpic.
	.macro hidemonpic
	.byte 0x76
	.endm

	@ Draws an image of the winner of the contest. In FireRed, this command is a nop. (The argument is discarded.)
	.macro showcontestwinner a:req
	.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 and needs to provide six extra starting characters that are skipped (in RS, these characters determined the
	@ box's size and position, but in Emerald these are calculated automatically).
	.macro braillemessage text:req
	.byte 0x78
	.4byte \text
	.endm

	@ Gives the player one of the specified (species) Pokemon at level level holding item. The trailing 0s are unused parameters
	.macro givemon species:req, level:req, item:req
	.byte 0x79
	.2byte \species
	.byte \level
	.2byte \item
	.4byte 0x0
	.4byte 0x0
	.byte 0
	.endm

	.macro giveegg species:req
	.byte 0x7a
	.2byte \species
	.endm

	.macro setmonmove index:req, slot:req, move:req
	.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, VAR_RESULT is set to the
	@ (zero-indexed) slot number of the first Pokemon that knows the move. If not, VAR_RESULT is set to PARTY_SIZE.
	@ VAR_0x8004 is also set to this Pokemon's species.
	.macro checkpartymove index:req
	.byte 0x7c
	.2byte \index
	.endm

	@ Writes the name of the Pokemon at index species to the specified buffer.
	.macro bufferspeciesname out:req, species:req
	.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:req
	.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:req, slot:req
	.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:req, item:req
	.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:req, decoration:req
	.byte 0x81
	.byte \out
	.2byte \decoration
	.endm

	@ Writes the name of the move at index move to the specified buffer.
	.macro buffermovename out:req, move:req
	.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:req, input:req
	.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 crashes or garbage characters.
	.macro bufferstdstring out:req, index:req
	.byte 0x84
	.byte \out
	.2byte \index
	.endm

	@ Copies the string at offset to the specified buffer.
	.macro bufferstring out:req, offset:req
	.byte 0x85
	.byte \out
	.4byte \offset
	.endm

	@ Opens the Pokemart system, offering the specified products for sale.
	.macro pokemart products:req
	.byte 0x86
	.4byte \products
	.endm

	@ Opens the Pokemart system and treats the list of items as decorations.
	.macro pokemartdecoration products:req
	.byte 0x87
	.4byte \products
	.endm

	@ Apparent clone of pokemartdecoration.
	.macro pokemartdecoration2 products:req
	.byte 0x88
	.4byte \products
	.endm

	@ Starts up the slot machine minigame.
	.macro playslotmachine word:req
	.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:req, berry:req, growth_stage:req
	.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 VAR_RESULT.
	.macro random limit:req
	.byte 0x8f
	.2byte \limit
	.endm

	@ If check is 0x00, this command adds value to the player's money.
	.macro addmoney value:req, check:req
	.byte 0x90
	.4byte \value
	.byte \check
	.endm

	@ If check is 0x00, this command subtracts value from the player's money.
	.macro removemoney value:req, check:req
	.byte 0x91
	.4byte \value
	.byte \check
	.endm

	@ If check is 0x00, this command will check if the player has money >= value; VAR_RESULT is set to TRUE if the player
	@ has enough money, or FALSE if they do not.
	.macro checkmoney value:req, check:req
	.byte 0x92
	.4byte \value
	.byte \check
	.endm

	@ Spawns a secondary box showing how much money the player has.
	.macro showmoneybox x:req, y:req, check:req
	.byte 0x93
	.byte \x
	.byte \y
	.byte \check
	.endm

	@ Hides the secondary box spawned by showmoney. Consumption of the x and y arguments was dummied out.
	.macro hidemoneybox
	.byte 0x94
	.byte 0  @ \x
	.byte 0  @ \y
	.endm

	@ Updates the secondary box spawned by showmoney. Consumes but does not use arguments.
	.macro updatemoneybox x:req, y:req
	.byte 0x95
	.byte \x
	.byte \y
	.byte 0 @ 1 = don't perform this command. Always 0 in vanilla. Why this is a thing is beyond me.
	.endm

	@ Gets the price reduction for the index given. In FireRed, this command is a nop.
	.macro getpricereduction index:req
	.byte 0x96
	.2byte \index
	.endm

	@ Fades the screen to and from black and white. Modes are FADE_(TO/FROM)_(WHITE/BLACK)
	.macro fadescreen mode:req
	.byte 0x97
	.byte \mode
	.endm

	@ Fades the screen to and from black and white. Modes are FADE_(TO/FROM)_(WHITE/BLACK)
	.macro fadescreenspeed mode:req, speed:req
	.byte 0x98
	.byte \mode
	.byte \speed
	.endm

	.macro setflashradius word:req
	.byte 0x99
	.2byte \word
	.endm

	.macro animateflash byte:req
	.byte 0x9a
	.byte \byte
	.endm

	.macro messageautoscroll pointer:req
	.byte 0x9b
	.4byte \pointer
	.endm

	@ Executes the specified field move animation.
	.macro dofieldeffect animation:req
	.byte 0x9c
	.2byte \animation
	.endm

	@ Sets up the field effect argument argument with the value value.
	.macro setfieldeffectargument argument:req, param:req
	.byte 0x9d
	.byte \argument
	.2byte \param
	.endm

	@ Blocks script execution until all playing field move animations complete.
	.macro waitfieldeffect animation:req
	.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:req
	.byte 0x9f
	.2byte \heallocation
	.endm

	@ Checks the player's gender. If male, then MALE (0) is stored in VAR_RESULT. If female, then FEMALE (1) is stored in VAR_RESULT.
	.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:req, effect:req
	.byte 0xa1
	.2byte \species
	.2byte \effect
	.endm

	@ Changes the metatile at (x, y) on the current map.
	.macro setmetatile x:req, y:req, metatile_number:req, has_collision:req
	.byte 0xa2
	.2byte \x
	.2byte \y
	.2byte \metatile_number
	.2byte \has_collision
	.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:req
	.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:req
	.byte 0xa6
	.byte \subroutine
	.endm

	.macro setmaplayoutindex index:req
	.byte 0xa7
	.2byte \index
	.endm

	.macro setobjectpriority index:req, map:req, priority:req
	.byte 0xa8
	.2byte \index
	map \map
	.byte \priority
	.endm

	.macro resetobjectpriority index:req, map:req
	.byte 0xa9
	.2byte \index
	map \map
	.endm

	.macro createvobject sprite:req, byte2:req, x:req, y:req, elevation, direction
	.byte 0xaa
	.byte \sprite
	.byte \byte2
	.2byte \x
	.2byte \y
	.byte \elevation
	.byte \direction
	.endm

	.macro turnvobject index:req, direction:req
	.byte 0xab
	.byte \index
	.byte \direction
	.endm

	@ Opens the door metatile at (X, Y) with an animation.
	.macro opendoor x:req, y:req
	.byte 0xac
	.2byte \x
	.2byte \y
	.endm

	@ Closes the door metatile at (X, Y) with an animation.
	.macro closedoor x:req, y:req
	.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:req, y:req
	.byte 0xaf
	.2byte \x
	.2byte \y
	.endm

	@ Sets the door tile at (x, y) to be closed without an animation.
	.macro setdoorclosed x:req, y:req
	.byte 0xb0
	.2byte \x
	.2byte \y
	.endm

	@ In Emerald, this command consumes its parameters and does nothing. In FireRed, this command is a nop.
	.macro addelevmenuitem a:req, b:req, c:req, d:req
	.byte 0xb1
	.byte \a
	.2byte \b
	.2byte \c
	.2byte \d
	.endm

	@ In FireRed and Emerald, this command is a nop.
	.macro showelevmenu
	.byte 0xb2
	.endm

	.macro checkcoins out:req
	.byte 0xb3
	.2byte \out
	.endm

	.macro addcoins count:req
	.byte 0xb4
	.2byte \count
	.endm

	.macro removecoins count:req
	.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:req, level:req, item:req
	.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 pointer:req
	.byte 0xb8
	.4byte \pointer
	.endm

	.macro vgoto pointer:req
	.byte 0xb9
	.4byte \pointer
	.endm

	.macro vcall pointer:req
	.byte 0xba
	.4byte \pointer
	.endm

	.macro vgoto_if byte:req, pointer:req
	.byte 0xbb
	.byte \byte
	.4byte \pointer
	.endm

	.macro vcall_if byte:req, pointer:req
	.byte 0xbc
	.byte \byte
	.4byte \pointer
	.endm

	.macro vmessage pointer:req
	.byte 0xbd
	.4byte \pointer
	.endm

	.macro vloadptr pointer:req
	.byte 0xbe
	.4byte \pointer
	.endm

	.macro vbufferstring byte:req, pointer:req
	.byte 0xbf
	.byte \byte
	.4byte \pointer
	.endm

	@ Spawns a secondary box showing how many Coins the player has.
	.macro showcoinsbox x:req, y:req
	.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:req, y:req
	.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:req, y:req
	.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:req
	.byte 0xc3
	.byte \stat
	.endm

	@ Sets the destination that using an Escape Rope or Dig will take the player to.
	.macro setescapewarp map:req, warp:req, x:req, y:req
	.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:req, box:req
	.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.
	@ Used only in FireRed/LeafGreen, does nothing in Emerald.
	.macro textcolor color:req
	.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.
	@ Used only in FireRed/LeafGreen, does nothing in Emerald.
	.macro loadhelp pointer:req
	.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.
	@ Used only in FireRed/LeafGreen, does nothing in Emerald.
	.macro unloadhelp
	.byte 0xc9
	.endm

	@ After using this command, all standard message boxes will use the signpost frame.
	@ Used only in FireRed/LeafGreen, does nothing in Emerald.
	.macro signmsg
	.byte 0xca
	.endm

	@ Ends the effects of signmsg, returning message box frames to normal.
	@ Used only in FireRed/LeafGreen, does nothing in Emerald.
	.macro normalmsg
	.byte 0xcb
	.endm

	@ Compares the value of a hidden variable to a dword.
	@ Used only in FireRed/LeafGreen, does nothing in Emerald.
	.macro comparehiddenvar a:req, value:req
	.byte 0xcc
	.byte \a
	.4byte \value
	.endm

	@ Makes the Pokemon in the specified slot of the player's party obedient. It will not randomly disobey orders in battle.
	.macro setmonobedient slot:req
	.byte 0xcd
	.2byte \slot
	.endm

	@ Checks if the Pokemon in the specified slot of the player's party is obedient. If the Pokemon is disobedient,
	@ VAR_RESULT is TRUE. If the Pokemon is obedient (or if the specified slot is empty or invalid), VAR_RESULT is FALSE.
	.macro checkmonobedience slot:req
	.byte 0xce
	.2byte \slot
	.endm

	@ Depending on factors I haven't managed to understand yet, this command may cause script execution to jump to the
	@ offset specified by the pointer at 0x020375C0.
	.macro gotoram
	.byte 0xcf
	.endm

	@ Sets worldmapflag to 1. This allows the player to Fly to the corresponding map, if that map has a flightspot.
	@ Used only in FireRed/LeafGreen, does nothing in Emerald.
	.macro setworldmapflag worldmapflag:req
	.byte 0xd0
	.2byte \worldmapflag
	.endm

	@ Clone of warpteleport? It is apparently only used in FR/LG, and only with specials.[source]
	.macro warpteleport2 map:req, warp:req, x:req, y:req
	.byte 0xd1
	map \map
	.byte \warp
	.2byte \x
	.2byte \y
	.endm

	@ Changes the location where the player caught the Pokemon in the specified slot of their party.
	.macro setmonmetlocation slot:req, location:req
	.byte 0xd2
	.2byte \slot
	.byte \location
	.endm

	@ For the rotating tile puzzles in Mossdeep Gym/Trick House Room 7. Moves the objects on the colored puzzle
	@ specified by puzzleNumber one rotation
	.macro moverotatingtileobjects puzzleNumber:req
	.byte 0xd3
	.2byte \puzzleNumber
	.endm

	@ For the rotating tile puzzles in Mossdeep Gym/Trick House Room 7. Updates the facing direction of all objects on the puzzle tiles
	.macro turnrotatingtileobjects
	.byte 0xd4
	.endm

	@ For the rotating tile puzzles in Mossdeep Gym/Trick House Room 7. Allocates memory for the puzzle objects.
	@ isTrickHouse is needed to determine which of the two maps the puzzle is on, in order to know where in the tileset
	@ the puzzle tiles start. In FireRed, this command is a nop.
	.macro initrotatingtilepuzzle isTrickHouse:req
	.byte 0xd5
	.2byte \isTrickHouse
	.endm

	@ For the rotating tile puzzles in Mossdeep Gym/Trick House Room 7. Frees the memory allocated for the puzzle objects.
	.macro freerotatingtilepuzzle
	.byte 0xd6
	.endm

	.macro warpmossdeepgym map:req, warpId:req, x:req, y:req
	.byte 0xd7
	map \map
	.byte \warpId
	.2byte \x
	.2byte \y
	.endm

	.macro cmdD8
	.byte 0xd8
	.endm

	.macro cmdD9
	.byte 0xd9
	.endm

	.macro closebraillemessage
	.byte 0xda
	.endm

	.macro message3 pointer:req
	.byte 0xdb
	.4byte \pointer
	.endm

	.macro fadescreenswapbuffers mode:req
	.byte 0xdc
	.byte \mode
	.endm

	.macro buffertrainerclassname out:req, class:req
	.byte 0xdd
	.byte \out
	.2byte \class
	.endm

	.macro buffertrainername out:req, trainer:req
	.byte 0xde
	.byte \out
	.2byte \trainer
	.endm

	.macro pokenavcall pointer:req
	.byte 0xdf
	.4byte \pointer
	.endm

	.macro warpsootopolislegend map:req, byte:req, word1:req, word2:req
	.byte 0xe0
	map \map
	.byte \byte
	.2byte \word1
	.2byte \word2
	.endm

	.macro buffercontesttypestring out:req, word:req
	.byte 0xe1
	.byte \out
	.2byte \word
	.endm

	@ Writes the name of the specified (item) item to the specified buffer. If the specified item is a Berry (0x85 - 0xAE) or
	@ Poke Ball (0x4) and if the quantity is 2 or more, the buffered string will be pluralized ("IES" or "S" appended).
	@ If the specified item is the Enigma Berry, I have no idea what this command does (but testing showed no pluralization).
	@ If the specified index is larger than the number of items in the game (0x176), the name of item 0 ("????????") is buffered instead.
	.macro bufferitemnameplural out:req, item:req, quantity:req
	.byte 0xe2
	.byte \out
	.2byte \item
	.2byte \quantity
	.endm

@ Supplementary

	.macro goto_if_unset flag:req, dest:req
	checkflag \flag
	goto_if FALSE, \dest
	.endm

	.macro goto_if_set flag:req, dest:req
	checkflag \flag
	goto_if TRUE, \dest
	.endm

	.macro goto_if_lt dest:req @ LESS THAN
	goto_if 0, \dest
	.endm

	.macro goto_if_eq dest:req @ EQUAL
	goto_if 1, \dest
	.endm

	.macro goto_if_gt dest:req @ GREATER THAN
	goto_if 2, \dest
	.endm

	.macro goto_if_le dest:req @ LESS THAN OR EQUAL
	goto_if 3, \dest
	.endm

	.macro goto_if_ge dest:req @ GREATER THAN OR EQUAL
	goto_if 4, \dest
	.endm

	.macro goto_if_ne dest:req @ NOT EQUAL
	goto_if 5, \dest
	.endm

	.macro call_if_unset flag:req, dest:req
	checkflag \flag
	call_if FALSE, \dest
	.endm

	.macro call_if_set flag:req, dest:req
	checkflag \flag
	call_if TRUE, \dest
	.endm

	.macro call_if_lt dest:req @ LESS THAN
	call_if 0, \dest
	.endm

	.macro call_if_eq dest:req @ EQUAL
	call_if 1, \dest
	.endm

	.macro call_if_gt dest:req @ GREATER THAN
	call_if 2, \dest
	.endm

	.macro call_if_le dest:req @ LESS THAN OR EQUAL
	call_if 3, \dest
	.endm

	.macro call_if_ge dest:req @ GREATER THAN OR EQUAL
	call_if 4, \dest
	.endm

	.macro call_if_ne dest:req @ NOT EQUAL
	call_if 5, \dest
	.endm

	.macro vgoto_if_eq dest:req
	vgoto_if TRUE, \dest
	.endm

	.macro vgoto_if_ne dest:req
	vgoto_if FALSE, \dest
	.endm

	.macro vgoto_if_unset flag:req, dest:req
	checkflag \flag
	vgoto_if FALSE, \dest
	.endm

	.macro vgoto_if_set flag:req, dest:req
	checkflag \flag
	vgoto_if TRUE, \dest
	.endm

	.macro goto_if_defeated trainer:req, dest:req
	checktrainerflag \trainer
	goto_if TRUE, \dest
	.endm

	.macro goto_if_not_defeated trainer:req, dest:req
	checktrainerflag \trainer
	goto_if FALSE, \dest
	.endm

	.macro call_if_defeated trainer:req, dest:req
	checktrainerflag \trainer
	call_if TRUE, \dest
	.endm

	.macro call_if_not_defeated trainer:req, dest:req
	checktrainerflag \trainer
	call_if FALSE, \dest
	.endm

	.macro switch var:req
	copyvar VAR_0x8000, \var
	.endm

	.macro case condition:req, dest:req
	compare VAR_0x8000, \condition
	goto_if_eq \dest
	.endm

	@ Message box types
	MSGBOX_NPC = 2
	MSGBOX_SIGN = 3
	MSGBOX_DEFAULT = 4
	MSGBOX_YESNO = 5
	MSGBOX_AUTOCLOSE = 6
	MSGBOX_GETPOINTS = 9

	YES = 1
	NO  = 0

	.macro msgbox text:req, type=MSGBOX_DEFAULT
	loadword 0, \text
	callstd \type
	.endm

	.macro giveitem item:req, amount=1
	setorcopyvar VAR_0x8000, \item
	setorcopyvar VAR_0x8001, \amount
	callstd STD_OBTAIN_ITEM
	.endm

	.macro finditem item:req, amount=1
	setorcopyvar VAR_0x8000, \item
	setorcopyvar VAR_0x8001, \amount
	callstd STD_FIND_ITEM
	.endm

	.macro givedecoration decoration:req
	setorcopyvar VAR_0x8000, \decoration
	callstd STD_OBTAIN_DECORATION
	.endm

	.macro register_matchcall trainer:req
	setvar VAR_0x8004, \trainer
	special SetMatchCallRegisteredFlag
	setorcopyvar VAR_0x8000, \trainer
	callstd STD_REGISTER_MATCH_CALL
	.endm

	.macro dofieldeffectsparkle x:req, y:req, priority:req
	setfieldeffectargument 0, \x
	setfieldeffectargument 1, \y
	setfieldeffectargument 2, \priority
	dofieldeffect FLDEFF_SPARKLE
	.endm


code:
	.macro field_eff_loadtiles address
	.byte 0
	.4byte \address
	.endm

	.macro field_eff_loadfadedpal address
	.byte 1
	.4byte \address
	.endm

	.macro field_eff_loadpal address
	.byte 2
	.4byte \address
	.endm

	.macro field_eff_callnative address
	.byte 3
	.4byte \address
	.endm

	.macro field_eff_end
	.byte 4
	.endm

	.macro field_eff_loadgfx_callnative tiles_address, palette_address, function_address
	.byte 5
	.4byte \tiles_address
	.4byte \palette_address
	.4byte \function_address
	.endm

	.macro field_eff_loadtiles_callnative tiles_address, function_address
	.byte 6
	.4byte \tiles_address
	.4byte \function_address
	.endm

	.macro field_eff_loadfadedpal_callnative palette_address, function_address
	.byte 7
	.4byte \palette_address
	.4byte \function_address
	.endm


code:
	.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


code:
	.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


code:
	.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 index:req, gfx:req, replacement:req, x:req, y:req, elevation:req, movement_type:req, x_radius:req, y_radius:req, trainer_type:req, sight_radius_tree_etc:req, script:req, event_flag:req
	.byte \index, \gfx, \replacement, 0
	.2byte \x
	.2byte \y
	.byte \elevation, \movement_type, ((\y_radius << 4) | \x_radius), 0
    .2byte \trainer_type, \sight_radius_tree_etc
	.4byte \script
	.2byte \event_flag
	.2byte 0
	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, elevation, trigger, index, script
	.2byte \x, \y
	.byte \elevation, 0
	.2byte \trigger, \index, 0
	.4byte \script
	inc _num_traps
	.endm

	.macro coord_weather_event x, y, elevation, weather
	.2byte \x, \y
	.byte \elevation, 0
	.2byte \weather
	.2byte 0, 0
	.4byte 0
	inc _num_traps
	.endm

	.macro bg_event x, y, elevation, kind, arg6, arg7, arg8
	.2byte \x, \y
	.byte \elevation, \kind
	.2byte 0
	.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, \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, \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
	.4byte connection_\direction
	.4byte \offset
	map \map
	.space 2
	.endm

	.macro map_header_flags allow_cycling:req, allow_escaping:req, allow_running:req, show_map_name:req
	.byte ((\show_map_name & 1) << 3) | ((\allow_running & 1) << 2) | ((\allow_escaping & 1) << 1) | \allow_cycling
	.endm


code:
	.macro create_movement_action name
	enum _\name
	.macro \name
	.byte _\name
	.endm
	.endm

	enum_start
	create_movement_action face_down
	create_movement_action face_up
	create_movement_action face_left
	create_movement_action face_right
	create_movement_action walk_slow_down
	create_movement_action walk_slow_up
	create_movement_action walk_slow_left
	create_movement_action walk_slow_right
	create_movement_action walk_down
	create_movement_action walk_up
	create_movement_action walk_left
	create_movement_action walk_right
	create_movement_action jump_2_down
	create_movement_action jump_2_up
	create_movement_action jump_2_left
	create_movement_action jump_2_right
	create_movement_action delay_1
	create_movement_action delay_2
	create_movement_action delay_4
	create_movement_action delay_8
	create_movement_action delay_16
	create_movement_action walk_fast_down
	create_movement_action walk_fast_up
	create_movement_action walk_fast_left
	create_movement_action walk_fast_right
	create_movement_action walk_in_place_slow_down
	create_movement_action walk_in_place_slow_up
	create_movement_action walk_in_place_slow_left
	create_movement_action walk_in_place_slow_right
	create_movement_action walk_in_place_down
	create_movement_action walk_in_place_up
	create_movement_action walk_in_place_left
	create_movement_action walk_in_place_right
	create_movement_action walk_in_place_fast_down
	create_movement_action walk_in_place_fast_up
	create_movement_action walk_in_place_fast_left
	create_movement_action walk_in_place_fast_right
	create_movement_action walk_in_place_fastest_down
	create_movement_action walk_in_place_fastest_up
	create_movement_action walk_in_place_fastest_left
	create_movement_action walk_in_place_fastest_right
	create_movement_action ride_water_current_down
	create_movement_action ride_water_current_up
	create_movement_action ride_water_current_left
	create_movement_action ride_water_current_right
	create_movement_action walk_fastest_down
	create_movement_action walk_fastest_up
	create_movement_action walk_fastest_left
	create_movement_action walk_fastest_right
	create_movement_action slide_down
	create_movement_action slide_up
	create_movement_action slide_left
	create_movement_action slide_right
	create_movement_action player_run_down
	create_movement_action player_run_up
	create_movement_action player_run_left
	create_movement_action player_run_right
	create_movement_action start_anim_in_direction
	create_movement_action jump_special_down
	create_movement_action jump_special_up
	create_movement_action jump_special_left
	create_movement_action jump_special_right
	create_movement_action face_player
	create_movement_action face_away_player
	create_movement_action lock_facing_direction
	create_movement_action unlock_facing_direction
	create_movement_action jump_down
	create_movement_action jump_up
	create_movement_action jump_left
	create_movement_action jump_right
	create_movement_action jump_in_place_down
	create_movement_action jump_in_place_up
	create_movement_action jump_in_place_left
	create_movement_action jump_in_place_right
	create_movement_action jump_in_place_down_up
	create_movement_action jump_in_place_up_down
	create_movement_action jump_in_place_left_right
	create_movement_action jump_in_place_right_left
	create_movement_action face_original_direction
	create_movement_action nurse_joy_bow
	create_movement_action enable_jump_landing_ground_effect
	create_movement_action disable_jump_landing_ground_effect
	create_movement_action disable_anim
	create_movement_action restore_anim
	create_movement_action set_invisible
	create_movement_action set_visible
	create_movement_action emote_exclamation_mark
	create_movement_action emote_question_mark
	create_movement_action emote_heart
	create_movement_action reveal_trainer
	create_movement_action rock_smash_break
	create_movement_action cut_tree
	create_movement_action set_fixed_priority
	create_movement_action clear_fixed_priority
	create_movement_action init_affine_anim
	create_movement_action clear_affine_anim
	create_movement_action hide_reflection
	create_movement_action show_reflection
	create_movement_action walk_down_start_affine
	create_movement_action walk_down_affine

	enum_start 0x8C
	create_movement_action walk_diag_northwest
	create_movement_action walk_diag_northeast
	create_movement_action walk_diag_southwest
	create_movement_action walk_diag_southeast
	create_movement_action walk_slow_diag_northwest
	create_movement_action walk_slow_diag_northeast
	create_movement_action walk_slow_diag_southwest
	create_movement_action walk_slow_diag_southeast
	create_movement_action store_lock_anim
	create_movement_action free_unlock_anim
	create_movement_action walk_left_affine
	create_movement_action walk_right_affine
	create_movement_action levitate
	create_movement_action stop_levitate
	create_movement_action destroy_extra_task
	create_movement_action figure_8
	create_movement_action fly_up
	create_movement_action fly_down

	enum_start 0xfe
	create_movement_action step_end