summaryrefslogtreecommitdiff
path: root/asm/macros
diff options
context:
space:
mode:
authorgolem galvanize <golemgalvanize@github.com>2018-01-09 16:48:01 -0500
committergolem galvanize <golemgalvanize@github.com>2018-01-09 16:48:01 -0500
commitc7722a492017dbd8a5fb3bb216062eb62129daf5 (patch)
tree2a5c0ba6a6b9364aa93eb4a9a89b35153954ab63 /asm/macros
parent2d141bc612ffecc984f6b4238c2791ba8419a192 (diff)
parent85174ad6193d3d58b92deaaedf8c510440ed85ee (diff)
fixing merge conflicts
Diffstat (limited to 'asm/macros')
-rw-r--r--asm/macros/battle_script.inc482
-rw-r--r--asm/macros/ec.inc19
-rw-r--r--asm/macros/event.inc908
-rw-r--r--asm/macros/map.inc53
4 files changed, 794 insertions, 668 deletions
diff --git a/asm/macros/battle_script.inc b/asm/macros/battle_script.inc
index 5dd1d5a1a..e4fa0c454 100644
--- a/asm/macros/battle_script.inc
+++ b/asm/macros/battle_script.inc
@@ -34,19 +34,19 @@
.byte 0x04
.endm
- .macro atk5
+ .macro damagecalc
.byte 0x05
.endm
- .macro atk6
+ .macro typecalc
.byte 0x06
.endm
- .macro atk7
+ .macro adjustnormaldamage
.byte 0x07
.endm
- .macro atk8
+ .macro adjustnormaldamage2
.byte 0x08
.endm
@@ -58,7 +58,7 @@
.byte 0x0a
.endm
- .macro graphicalhpupdate bank
+ .macro healthbarupdate bank
.byte 0x0b
.byte \bank
.endm
@@ -72,7 +72,7 @@
.byte 0x0d
.endm
- .macro missmessage
+ .macro effectivenesssound
.byte 0x0e
.endm
@@ -85,7 +85,7 @@
.2byte \string
.endm
- .macro printstring2 string
+ .macro printselectionstring string
.byte 0x11
.2byte \string
.endm
@@ -100,41 +100,41 @@
.4byte \table
.endm
- .macro printfromtable2 table
+ .macro printselectionstringfromtable table
.byte 0x14
.4byte \table
.endm
- .macro seteffectwithchancetarget
+ .macro seteffectwithchance
.byte 0x15
.endm
- .macro seteffecttarget
+ .macro seteffectprimary
.byte 0x16
.endm
- .macro seteffectuser
+ .macro seteffectsecondary
.byte 0x17
.endm
- .macro clearstatus bank
+ .macro clearstatusfromeffect bank
.byte 0x18
.byte \bank
.endm
- .macro faintpokemon bank, param2, param3
+ .macro tryfaintmon bank, param2, param3
.byte 0x19
.byte \bank
.byte \param2
.4byte \param3
.endm
- .macro atk1a param1
+ .macro dofaintanimation param1
.byte 0x1a
.byte \param1
.endm
- .macro atk1b bank
+ .macro cleareffectsonfaint bank
.byte 0x1b
.byte \bank
.endm
@@ -146,7 +146,7 @@
.4byte \address
.endm
- .macro jumpifsecondarytstatus bank, status, address
+ .macro jumpifstatus2 bank, status, address
.byte 0x1d
.byte \bank
.4byte \status
@@ -160,7 +160,7 @@
.4byte \address
.endm
- .macro jumpifhalverset bank, status, address
+ .macro jumpifsideaffecting bank, status, address
.byte 0x1f
.byte \bank
.2byte \status
@@ -176,7 +176,7 @@
.4byte \address
.endm
- .macro jumpifspecialstatusflag bank, mask, status, address
+ .macro jumpifstatus3condition bank, mask, status, address
.byte 0x21
.byte \bank
.4byte \mask
@@ -191,7 +191,7 @@
.4byte \address
.endm
- .macro atk23 bank
+ .macro getexp bank
.byte 0x23
.byte \bank
.endm
@@ -201,21 +201,21 @@
.4byte \address
.endm
- .macro atk25
+ .macro movevaluescleanup
.byte 0x25
.endm
- .macro atk26 param1
+ .macro setmultihit param1
.byte 0x26
.byte \param1
.endm
- .macro atk27 address
+ .macro decrementmultihit address
.byte 0x27
.4byte \address
.endm
- .macro jump address
+ .macro goto address
.byte 0x28
.4byte \address
.endm
@@ -272,7 +272,7 @@
.byte \value
.endm
- .macro subtractbyte pointer, value
+ .macro subbyte pointer, value
.byte 0x30
.4byte \pointer
.byte \value
@@ -285,7 +285,7 @@
.byte \size
.endm
- .macro atk32 param1, param2, param3, byte
+ .macro copyarraywithindex param1, param2, param3, byte
.byte 0x32
.4byte \param1
.4byte \param2
@@ -334,11 +334,11 @@
.2byte \pause_duration
.endm
- .macro waitstateatk
+ .macro waitstate
.byte 0x3a
.endm
- .macro somethinghealatk3b bank
+ .macro healthbar_update bank
.byte 0x3b
.byte \bank
.endm
@@ -359,12 +359,12 @@
.byte 0x3f
.endm
- .macro atk40 address
+ .macro jumpifaffectedbyprotect address
.byte 0x40
.4byte \address
.endm
- .macro callatk address
+ .macro call address
.byte 0x41
.4byte \address
.endm
@@ -382,7 +382,7 @@
.4byte \address
.endm
- .macro atk44
+ .macro endselectionscript
.byte 0x44
.endm
@@ -393,14 +393,14 @@
.4byte \var_address
.endm
- .macro atk46 bank, address, int
+ .macro playanimation2 bank, address, int
.byte 0x46
.byte \bank
.4byte \address
.4byte \int
.endm
- .macro atk47
+ .macro setgraphicalstatchangevalues
.byte 0x47
.endm
@@ -411,37 +411,37 @@
.byte \byte
.endm
- .macro atk49 byte1, byte2
+ .macro moveend byte1, byte2
.byte 0x49
.byte \byte1
.byte \byte2
.endm
- .macro damagecalc2
+ .macro typecalc2
.byte 0x4a
.endm
- .macro atk4b
+ .macro returnatktoball
.byte 0x4b
.endm
- .macro switch1 bank
+ .macro getswitchedmondata bank
.byte 0x4c
.byte \bank
.endm
- .macro switch2 bank
+ .macro switchindataupdate bank
.byte 0x4d
.byte \bank
.endm
- .macro switch3 bank, byte
+ .macro switchinanim bank, byte
.byte 0x4e
.byte \bank
.byte \byte
.endm
- .macro jumpifcannotswitch bank, address
+ .macro jumpifcantswitch bank, address
.byte 0x4f
.byte \bank
.4byte \address
@@ -453,33 +453,33 @@
.4byte \address
.endm
- .macro atk51 bank, param2
+ .macro switchhandleorder bank, param2
.byte 0x51
.byte \bank
.byte \param2
.endm
- .macro atk52 bank
+ .macro switchineffects bank
.byte 0x52
.byte \bank
.endm
- .macro atk53 bank
+ .macro trainerslidein bank
.byte 0x53
.byte \bank
.endm
- .macro atk54 word
+ .macro playse word
.byte 0x54
.2byte \word
.endm
- .macro atk55 int
+ .macro fanfare int
.byte 0x55
- .4byte \int
+ .2byte \int
.endm
- .macro atk56 bank_or_side
+ .macro playfaintcry bank_or_side
.byte 0x56
.byte \bank_or_side
.endm
@@ -488,34 +488,34 @@
.byte 0x57
.endm
- .macro atk58 bank
+ .macro returntoball bank
.byte 0x58
.byte \bank
.endm
- .macro checkiflearnmoveinbattle param1, param2, bank_maybe
+ .macro handlelearnnewmove param1, param2, bank_maybe
.byte 0x59
.4byte \param1
.4byte \param2
.byte \bank_maybe
.endm
- .macro atk5a address
+ .macro yesnoboxlearnmove address
.byte 0x5a
.4byte \address
.endm
- .macro atk5b address
+ .macro yesnoboxstoplearningmove address
.byte 0x5b
.4byte \address
.endm
- .macro atk5c bank
+ .macro hitanimation bank
.byte 0x5c
.byte \bank
.endm
- .macro atk5d
+ .macro getmoneyreward
.byte 0x5d
.endm
@@ -528,12 +528,12 @@
.byte 0x5f
.endm
- .macro atk60 byte
+ .macro incrementgamestat byte
.byte 0x60
.byte \byte
.endm
- .macro atk61 bank_or_side
+ .macro drawpartystatussummary bank_or_side
.byte 0x61
.byte \bank_or_side
.endm
@@ -543,7 +543,7 @@
.byte \bank_or_side
.endm
- .macro jumptoattack bank
+ .macro jumptorandomattack bank
.byte 0x63
.byte \bank
.endm
@@ -553,28 +553,28 @@
.byte \bank
.endm
- .macro atk65 bank_or_side, address
+ .macro status2animation bank_or_side, address
.byte 0x65
.byte \bank_or_side
.4byte \address
.endm
- .macro atk66 bank_or_side, bank_or_side2, address
+ .macro chosenstatusanimation bank_or_side, bank_or_side2, address
.byte 0x66
.byte \bank_or_side
.byte \bank_or_side2
.4byte \address
.endm
- .macro atk67
+ .macro yesnobox
.byte 0x67
.endm
- .macro atk68
+ .macro cancelallactions
.byte 0x68
.endm
- .macro atk69
+ .macro adjustsetdamage
.byte 0x69
.endm
@@ -583,62 +583,62 @@
.byte \bank
.endm
- .macro atk6b
+ .macro atknameinbuff1
.byte 0x6b
.endm
- .macro atk6c
+ .macro drawlvlupbox
.byte 0x6c
.endm
- .macro atk6d
+ .macro resetsentmonsvalue
.byte 0x6d
.endm
- .macro atk6e
+ .macro setatktoplayer0
.byte 0x6e
.endm
- .macro atk6f bank
+ .macro makevisible bank
.byte 0x6f
.byte \bank
.endm
- .macro atk70 bank
+ .macro recordlastability bank
.byte 0x70
.byte \bank
.endm
- .macro atk71
+ .macro buffermovetolearn
.byte 0x71
.endm
- .macro atk72 address
+ .macro jumpifplayerran address
.byte 0x72
.4byte \address
.endm
- .macro atk73 bank
+ .macro hpthresholds bank
.byte 0x73
.byte \bank
.endm
- .macro atk74 bank
+ .macro hpthresholds2 bank
.byte 0x74
.byte \bank
.endm
- .macro atk75
+ .macro useitemonopponent
.byte 0x75
.endm
- .macro atk76 bank, byte
+ .macro various bank, byte
.byte 0x76
.byte \bank
.byte \byte
.endm
- .macro setprotect
+ .macro setprotectlike
.byte 0x77
.endm
@@ -646,22 +646,22 @@
.byte 0x78
.endm
- .macro setuserhptozero
+ .macro setatkhptozero
.byte 0x79
.endm
- .macro jumpwhiletargetvalid address
+ .macro jumpifnexttargetvalid address
.byte 0x7a
.4byte \address
.endm
- .macro setdamageasrestorehalfmaxhp address, byte
+ .macro tryhealhalfhealth address, byte
.byte 0x7b
.4byte \address
.byte \byte
.endm
- .macro jumptolastusedattack
+ .macro trymirrormove
.byte 0x7c
.endm
@@ -673,7 +673,7 @@
.byte 0x7e
.endm
- .macro setleechseed
+ .macro setseeded
.byte 0x7f
.endm
@@ -682,7 +682,7 @@
.byte \id
.endm
- .macro setrest address
+ .macro trysetrest address
.byte 0x81
.4byte \address
.endm
@@ -692,11 +692,11 @@
.4byte \address
.endm
- .macro nop3
+ .macro nop
.byte 0x83
.endm
- .macro jumpifcannotsleep address
+ .macro jumpifcantmakeasleep address
.byte 0x84
.4byte \address
.endm
@@ -710,7 +710,7 @@
.4byte \address
.endm
- .macro stockpiletohprecovery address
+ .macro stockpiletohpheal address
.byte 0x87
.4byte \address
.endm
@@ -737,12 +737,12 @@
.byte 0x8c
.endm
- .macro setloopcounter count
+ .macro setmultihitcounter count
.byte 0x8d
.byte \count
.endm
- .macro atk8e
+ .macro initmultihitstring
.byte 0x8e
.endm
@@ -751,12 +751,12 @@
.4byte \address
.endm
- .macro changetypestoenemyattacktype address
+ .macro tryconversiontypechange address
.byte 0x90
.4byte \address
.endm
- .macro givemoney
+ .macro givepaydaymoney
.byte 0x91
.endm
@@ -764,12 +764,12 @@
.byte 0x92
.endm
- .macro koplussomethings address
+ .macro tryKO address
.byte 0x93
.4byte \address
.endm
- .macro gethalfcurrentenemyhp
+ .macro damagetohalftargethp
.byte 0x94
.endm
@@ -781,21 +781,21 @@
.byte 0x96
.endm
- .macro tryinfatuatetarget address
+ .macro tryinfatuating address
.byte 0x97
.4byte \address
.endm
- .macro atk98 byte
+ .macro updatestatusicon byte
.byte 0x98
.byte \byte
.endm
- .macro setmisteffect
+ .macro setmist
.byte 0x99
.endm
- .macro setincreasedcriticalchance
+ .macro setfocusenergy
.byte 0x9a
.endm
@@ -803,20 +803,20 @@
.byte 0x9b
.endm
- .macro setsubstituteeffect
+ .macro setsubstitute
.byte 0x9c
.endm
- .macro copyattack address
+ .macro mimicattackcopy address
.byte 0x9d
.4byte \address
.endm
- .macro metronomeeffect
+ .macro metronome
.byte 0x9e
.endm
- .macro nightshadedamageeffect
+ .macro dmgtolevel
.byte 0x9f
.endm
@@ -839,12 +839,12 @@
.4byte \address
.endm
- .macro setencore address
+ .macro trysetencore address
.byte 0xa4
.4byte \address
.endm
- .macro painsplitdamagecalculator address
+ .macro painsplitdmgcalc address
.byte 0xa5
.4byte \address
.endm
@@ -863,16 +863,16 @@
.4byte \address
.endm
- .macro selectrandommovefromusermoves address
+ .macro trychoosesleeptalkmove address
.byte 0xa9
.4byte \address
.endm
- .macro destinybondeffect
+ .macro setdestinybond
.byte 0xaa
.endm
- .macro atkab
+ .macro trysetdestinybondtohappen
.byte 0xab
.endm
@@ -880,12 +880,12 @@
.byte 0xac
.endm
- .macro reducepprandom address
+ .macro tryspiteppreduce address
.byte 0xad
.4byte \address
.endm
- .macro clearstatusifnotsoundproofed
+ .macro healpartystatus
.byte 0xae
.endm
@@ -894,7 +894,7 @@
.4byte \address
.endm
- .macro setspikes address
+ .macro trysetspikes address
.byte 0xb0
.4byte \address
.endm
@@ -903,7 +903,7 @@
.byte 0xb1
.endm
- .macro setperishsong address
+ .macro trysetperishsong address
.byte 0xb2
.4byte \address
.endm
@@ -912,13 +912,13 @@
.byte 0xb3
.endm
- .macro jumpifconfusedandattackmaxed bank, address
+ .macro jumpifconfusedandstatmaxed bank, address
.byte 0xb4
.byte \bank
.4byte \address
.endm
- .macro furycutterdamagecalculation
+ .macro furycuttercalc
.byte 0xb5
.endm
@@ -938,7 +938,7 @@
.byte 0xb9
.endm
- .macro atkba address
+ .macro jumpifnopursuitswitchdmg address
.byte 0xba
.4byte \address
.endm
@@ -957,11 +957,11 @@
.4byte \address
.endm
- .macro breakfree
+ .macro rapidspinfree
.byte 0xbe
.endm
- .macro setcurled
+ .macro setdefensecurlbit
.byte 0xbf
.endm
@@ -970,30 +970,30 @@
.4byte \address
.endm
- .macro hiddenpowerdamagecalculation
+ .macro hiddenpowercalc
.byte 0xc1
.endm
- .macro selectnexttarget
+ .macro selectfirstvalidtarget
.byte 0xc2
.endm
- .macro setfutureattack address
+ .macro trysetfutureattack address
.byte 0xc3
.4byte \address
.endm
- .macro beatupcalculation address1, address2
+ .macro trydobeatup address1, address2
.byte 0xc4
.4byte \address1
.4byte \address2
.endm
- .macro hidepreattack
+ .macro setsemiinvulnerablebit
.byte 0xc5
.endm
- .macro unhidepostattack
+ .macro clearsemiinvulnerablebit
.byte 0xc6
.endm
@@ -1042,28 +1042,28 @@
.4byte \address
.endm
- .macro sethelpinghand address
+ .macro trysethelpinghand address
.byte 0xd1
.4byte \address
.endm
- .macro itemswap address
+ .macro tryswapitems address
.byte 0xd2
.4byte \address
.endm
- .macro copyability address
+ .macro trycopyability address
.byte 0xd3
.4byte \address
.endm
- .macro atkd4 byte, address
+ .macro trywish byte, address
.byte 0xd4
.byte \byte
.4byte \address
.endm
- .macro setroots address
+ .macro trysetroots address
.byte 0xd5
.4byte \address
.endm
@@ -1086,17 +1086,17 @@
.byte 0xd9
.endm
- .macro abilityswap address
+ .macro tryswapabilities address
.byte 0xda
.4byte \address
.endm
- .macro imprisoneffect address
+ .macro tryimprision address
.byte 0xdb
.4byte \address
.endm
- .macro setgrudge address
+ .macro trysetgrudge address
.byte 0xdc
.4byte \address
.endm
@@ -1110,45 +1110,45 @@
.4byte \address
.endm
- .macro setmagiccoat address
+ .macro trysetmagiccoat address
.byte 0xdf
.4byte \address
.endm
- .macro setstealstatchange address
+ .macro trysetsnatch address
.byte 0xe0
.4byte \address
.endm
- .macro atke1 address
+ .macro trygetintimidatetarget address
.byte 0xe1
.4byte \address
.endm
- .macro atke2 bank
+ .macro switchoutabilities bank
.byte 0xe2
.byte \bank
.endm
- .macro jumpiffainted bank, address
+ .macro jumpifhasnohp bank, address
.byte 0xe3
.byte \bank
.4byte \address
.endm
- .macro naturepowereffect
+ .macro getsecretpowereffect
.byte 0xe4
.endm
- .macro pickupitemcalculation
+ .macro pickup
.byte 0xe5
.endm
- .macro actualcastformswitch
+ .macro docastformchangeanimation
.byte 0xe6
.endm
- .macro castformswitch
+ .macro trycastformdatachange
.byte 0xe7
.endm
@@ -1157,11 +1157,11 @@
.4byte \address
.endm
- .macro seteffectbyweather
+ .macro setweatherballtype
.byte 0xe9
.endm
- .macro recycleitem address
+ .macro tryrecycleitem address
.byte 0xea
.4byte \address
.endm
@@ -1171,58 +1171,244 @@
.4byte \address
.endm
- .macro pursuitwhenswitched address
+ .macro pursuitrelated address
.byte 0xec
.4byte \address
.endm
- .macro snatchmove
+ .macro snatchsetbanks
.byte 0xed
.endm
- .macro removereflectlightscreen
+ .macro removelightscreenreflect
.byte 0xee
.endm
- .macro pokemoncatchfunction
+ .macro handleballthrow
.byte 0xef
.endm
- .macro catchpoke
+ .macro givecaughtmon
.byte 0xf0
.endm
- .macro capturesomethingf1 address
+ .macro trysetcaughtmondexflags address
.byte 0xf1
.4byte \address
.endm
- .macro capturesomethingf2
+ .macro displaydexinfo
.byte 0xf2
.endm
- .macro capturesomethingf3 address
+ .macro trygivecaughtmonnick address
.byte 0xf3
.4byte \address
.endm
- .macro removehp
+ .macro subattackerhpbydmg
.byte 0xf4
.endm
- .macro curestatusfirstword
+ .macro removeattackerstatus1
.byte 0xf5
.endm
- .macro atkf6
+ .macro finishaction
.byte 0xf6
.endm
- .macro activesidesomething
+ .macro finishturn
.byte 0xf7
.endm
- .macro atkf8 bank
+ .macro trainerslideout bank
.byte 0xf8
.byte \bank
.endm
+
+@ various command changed to more readable macros
+ .macro cancelmultiturnmoves bank
+ various \bank, VARIOUS_CANCEL_MULTI_TURN_MOVES
+ .endm
+
+ .macro setmagiccoattarget bank
+ various \bank, VARIOUS_SET_MAGIC_COAT_TARGET
+ .endm
+
+ .macro getifcantrunfrombattle bank
+ various \bank, VARIOUS_IS_RUNNING_IMPOSSIBLE
+ .endm
+
+ .macro getmovetarget bank
+ various \bank, VARIOUS_GET_MOVE_TARGET
+ .endm
+
+ .macro various4 bank
+ various \bank, 4
+ .endm
+
+ .macro resetintrimidatetracebits bank
+ various \bank, VARIOUS_RESET_INTIMIDATE_TRACE_BITS
+ .endm
+
+ .macro updatechoicemoveonlvlup bank
+ various \bank, VARIOUS_UPDATE_CHOICE_MOVE_ON_LVL_UP
+ .endm
+
+ .macro various7 bank
+ various \bank, 7
+ .endm
+
+ .macro various8 bank
+ various \bank, 8
+ .endm
+
+ .macro various9 bank
+ various \bank, 9
+ .endm
+
+ .macro various10 bank
+ various \bank, 10
+ .endm
+
+ .macro various11 bank
+ various \bank, 11
+ .endm
+
+ .macro various12 bank
+ various \bank, 12
+ .endm
+
+ .macro forfeityesnobox bank
+ various \bank, VARIOUS_EMIT_YESNOBOX
+ .endm
+
+ .macro various14 bank
+ various \bank, 14
+ .endm
+
+ .macro various15 bank
+ various \bank, 15
+ .endm
+
+ .macro various16 bank
+ various \bank, 16
+ .endm
+
+ .macro various17 bank
+ various \bank, 17
+ .endm
+
+ .macro waitcry bank
+ various \bank, VARIOUS_WAIT_CRY
+ .endm
+
+ .macro returnopponentmon1toball bank
+ various \bank, VARIOUS_RETURN_OPPONENT_MON1
+ .endm
+
+ .macro returnopponentmon2toball bank
+ various \bank, VARIOUS_RETURN_OPPONENT_MON2
+ .endm
+
+ .macro various21 bank
+ various \bank, 21
+ .endm
+
+ .macro various22 bank
+ various \bank, 22
+ .endm
+
+ .macro various23 bank
+ various \bank, 23
+ .endm
+
+ .macro various24 bank
+ various \bank, 24
+ .endm
+
+ .macro setoutcomeonteleport bank
+ various \bank, VARIOUS_SET_TELEPORT_OUTCOME
+ .endm
+
+ .macro playtrainerdefeatbgm bank
+ various \bank, VARIOUS_PLAY_TRAINER_DEFEATED_MUSIC
+ .endm
+
+@ helpful macros
+ .macro setstatchanger stat, stages, down
+ setbyte sSTATCHANGER \stat | \stages << 4 | \down << 7
+ .endm
+
+ .macro setmoveeffect effect
+ setbyte cEFFECT_CHOOSER \effect
+ .endm
+
+ .macro chosenstatus1animation bank, status
+ chosenstatusanimation \bank 0x0 \status
+ .endm
+
+ .macro chosenstatus2animation bank, status
+ chosenstatusanimation \bank 0x1 \status
+ .endm
+
+ .macro sethword dst, value
+ setbyte \dst, \value & 0xFF
+ setbyte \dst + 1, (\value >> 8) & 0xFF
+ .endm
+
+ .macro setword dst, value
+ setbyte \dst, \value & 0xFF
+ setbyte \dst + 1, (\value >> 8) & 0xFF
+ setbyte \dst + 2, (\value >> 16) & 0xFF
+ setbyte \dst + 3, (\value >> 24) & 0xFF
+ .endm
+
+ .macro copybyte dst, src
+ copyarray \dst, \src, 0x1
+ .endm
+
+ .macro copyhword dst, src
+ copyarray \dst, \src, 0x2
+ .endm
+
+ .macro copyword dst, src
+ copyarray \dst, \src, 0x4
+ .endm
+
+ .macro jumpifbytenotequal byte1, byte2, jumpptr
+ jumpifarraynotequal \byte1, \byte2, 0x1, \jumpptr
+ .endm
+
+ .macro jumpifbyteequal byte1, byte2, jumpptr
+ jumpifarrayequal \byte1, \byte2, 0x1, \jumpptr
+ .endm
+
+ .macro jumpifmove move, jumpptr
+ jumpifhalfword EQUAL, gCurrentMove, \move, \jumpptr
+ .endm
+
+ .macro jumpifnotmove move, jumpptr
+ jumpifhalfword NOT_EQUAL, gCurrentMove, \move, \jumpptr
+ .endm
+
+ .macro jumpifstatus3 bank, status, jumpptr
+ jumpifstatus3condition \bank, \status, 0x0, \jumpptr
+ .endm
+
+ .macro jumpifnostatus3 bank, status, jumpptr
+ jumpifstatus3condition \bank, \status, 0x1, \jumpptr
+ .endm
+
+ .macro jumpifmovehadnoeffect jumpptr
+ jumpifbyte COMMON_BITS, gBattleMoveFlags, MOVESTATUS_MISSED | MOVESTATUS_NOTAFFECTED | MOVESTATUS_FAILED, \jumpptr
+ .endm
+
+ .macro jumpifbattletype flags, jumpptr
+ jumpifhalfword COMMON_BITS, gBattleTypeFlags, \flags, \jumpptr
+ .endm
+
+ .macro jumpifnotbattletype flags, jumpptr
+ jumpifhalfword NO_COMMON_BITS, gBattleTypeFlags, \flags, \jumpptr
+ .endm
diff --git a/asm/macros/ec.inc b/asm/macros/ec.inc
index 44c974e53..d3fd45c2f 100644
--- a/asm/macros/ec.inc
+++ b/asm/macros/ec.inc
@@ -1,22 +1,3 @@
- .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_POKEMON_2 << 9) | SPECIES_\name
- .endm
.macro ec_duplicates count
.2byte 0xff00 + \count
diff --git a/asm/macros/event.inc b/asm/macros/event.inc
index cd2927c66..fcbd3a055 100644
--- a/asm/macros/event.inc
+++ b/asm/macros/event.inc
@@ -1,10 +1,10 @@
@ Does nothing.
- .macro snop
+ .macro nop
.byte 0x00
.endm
@ Does nothing.
- .macro snop1
+ .macro nop1
.byte 0x01
.endm
@@ -25,27 +25,27 @@
.endm
@ Jumps to destination and continues script execution from there.
- .macro jump destination
+ .macro goto destination
.byte 0x05
.4byte \destination
.endm
@ If the result of the last comparison matches condition (see Comparison operators), jumps to destination and continues script execution from there.
- .macro jumpif condition, destination
+ .macro goto_if condition, destination
.byte 0x06
.byte \condition
.4byte \destination
.endm
@ If the result of the last comparison matches condition (see Comparison operators), calls destination.
- .macro callif condition, destination
+ .macro call_if condition, destination
.byte 0x07
.byte \condition
.4byte \destination
.endm
@ Jumps to the standard function at index function.
- .macro jumpstd function
+ .macro gotostd function
.byte 0x08
.byte \function
.endm
@@ -57,58 +57,58 @@
.endm
@ If the result of the last comparison matches condition (see Comparison operators), jumps to the standard function at index function.
- .macro jumpstdif condition, function
+ .macro gotostd_if condition, function
.byte 0x0a
.byte \condition
.byte \function
.endm
@ If the result of the last comparison matches condition (see Comparison operators), calls the standard function at index function.
- .macro callstdif condition, function
+ .macro callstd_if condition, function
.byte 0x0b
.byte \condition
.byte \function
.endm
@ Executes a script stored in a default RAM location.
- .macro jumpram
+ .macro gotoram
.byte 0x0c
.endm
@ Terminates script execution and "resets the script RAM".
- .macro die
+ .macro killscript
.byte 0x0d
.endm
- @ Pads the specified value to a dword, and then writes that dword to a predefined address (0x0203AAA8).
- .macro setbyte value
+ @ Sets some status related to Mystery Event.
+ .macro setmysteryeventstatus value
.byte 0x0e
.byte \value
.endm
@ Sets the specified script bank to value.
- .macro loadptr destination, value
+ .macro loadword destination, value
.byte 0x0f
.byte \destination
.4byte \value
.endm
@ Sets the specified script bank to value.
- .macro setbufferbyte destination, value
+ .macro loadbyte destination, value
.byte 0x10
.byte \destination
.byte \value
.endm
@ Sets the byte at offset to value.
- .macro writebytetooffset value, offset
+ .macro writebytetoaddr value, offset
.byte 0x11
.byte \value
.4byte \offset
.endm
@ Copies the byte value at source into the specified script bank.
- .macro loadbytefrompointer destination, source
+ .macro loadbytefromaddr destination, source
.byte 0x12
.byte \destination
.4byte \source
@@ -122,7 +122,7 @@
.endm
@ Copies the contents of bank source into bank destination.
- .macro copybuffers destination, source
+ .macro copylocal destination, source
.byte 0x14
.byte \destination
.byte \source
@@ -171,81 +171,93 @@
.endm
@ Compares the values of script banks a and b, after forcing the values to bytes.
- .macro comparebuffers byte1, byte2
+ .macro compare_local_to_local byte1, byte2
.byte 0x1b
.byte \byte1
.byte \byte2
.endm
@ Compares the least-significant byte of the value of script bank a to a fixed byte value (b).
- .macro comparebuffertobyte a, b
+ .macro compare_local_to_value a, b
.byte 0x1c
.byte \a
.byte \b
.endm
@ Compares the least-significant byte of the value of script bank a to the byte located at offset b.
- .macro comparebuffertoptrbyte a, b
+ .macro compare_local_to_addr a, b
.byte 0x1d
.byte \a
.4byte \b
.endm
@ Compares the byte located at offset a to the least-significant byte of the value of script bank b.
- .macro compareptrbytetobuffer a, b
+ .macro compare_addr_to_local a, b
.byte 0x1e
.4byte \a
.byte \b
.endm
@ Compares the byte located at offset a to a fixed byte value (b).
- .macro compareptrbytetobyte a, b
+ .macro compare_addr_to_value a, b
.byte 0x1f
.4byte \a
.byte \b
.endm
@ Compares the byte located at offset a to the byte located at offset b.
- .macro compareptrbytes a, b
+ .macro compare_addr_to_addr a, b
.byte 0x20
.4byte \a
.4byte \b
.endm
@ Compares the value of `var` to a fixed word value (b).
- .macro compare var, value
+ .macro compare_var_to_value var, value
.byte 0x21
.2byte \var
.2byte \value
.endm
- @ Compares the value of `var` to the value of `var2`.
- .macro comparevars var1, var2
+ @ Compares the value of `var1` to the value of `var2`.
+ .macro compare_var_to_var var1, var2
.byte 0x22
.2byte \var1
.2byte \var2
.endm
- @ Calls the ASM routine stored at code. Script execution is blocked until the ASM returns (bx lr, mov pc, lr, etc.). Remember to add 1 to the offset when calling THUMB code.
- .macro callasm code
+ @ Generic compare macro which attempts to deduce argument types based on their values
+ @ Any values between 0x4000 to 0x4FFF and 0x8000 to 0x8FFF are considered event variable identifiers
+ .macro compare arg1, arg2
+ .if (((\arg1) >> 12) == 4 || ((\arg1) >> 12) == 8) && (((\arg2) >> 12) == 4 || ((\arg2) >> 12) == 8)
+ compare_var_to_var (\arg1), (\arg2)
+ .elseif (((\arg1) >> 12) == 4 || ((\arg1) >> 12) == 8) && ((\arg2) >= -0xFFFF && (\arg2) <= 0xFFFF)
+ compare_var_to_value (\arg1), ((\arg2) & 0xFFFF)
+ .else
+ .error "Invalid arguments for 'compare'"
+ .endif
+ .endm
+
+ @ Calls the native C function stored at `func`.
+ .macro callnative func
.byte 0x23
- .4byte \code
+ .4byte \func
.endm
- @ Replaces a pointer in the script engine RAM with asm_pointer.
- .macro jumpasm asm_pointer
+ @ Replaces the script with the function stored at `func`. Execution returns to the bytecode script when func returns TRUE.
+ .macro gotonative func
.byte 0x24
- .4byte \asm_pointer
+ .4byte \func
.endm
- @ Calls a special function; that is, a piece of ASM code designed for use by scripts and listed in a table of pointers.
+ @ Calls a special function; that is, a function designed for use by scripts and listed in a table of pointers.
.macro special function
.byte 0x25
.2byte SPECIAL_\function
.endm
@ Calls a special function. That function's output (if any) will be written to the variable you specify.
- .macro specialval output, function
+ .macro specialvar output, function
.byte 0x26
.2byte \output
.2byte SPECIAL_\function
@@ -257,7 +269,7 @@
.endm
@ Blocks script execution for time (frames? milliseconds?).
- .macro pause time
+ .macro delay time
.byte 0x28
.2byte \time
.endm
@@ -280,34 +292,36 @@
.2byte \a
.endm
- @ In FireRed, this command is a nop.
- .macro compareflags
+ @ Initializes the RTC`s local time offset to the given hour and minute. In FireRed, this command is a nop.
+ .macro initclock hour, minute
.byte 0x2c
+ .2byte \hour
+ .2byte \minute
.endm
- @ In FireRed, this command is a nop.
- .macro checkdailyflags
+ @ Runs time based events. In FireRed, this command is a nop.
+ .macro dodailyevents
.byte 0x2d
.endm
- @ Resets the values of variables 0x8000, 0x8001, and 0x8002. Related to RTC in RSE?
- .macro resetvars
+ @ 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 playsfx sound_number
+ .macro playse sound_number
.byte 0x2f
.2byte \sound_number
.endm
- @ Blocks script execution until the currently-playing sound (triggered by sound) finishes playing.
- .macro checksound
+ @ 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 fanfare fanfare_number
+ .macro playfanfare fanfare_number
.byte 0x31
.2byte \fanfare_number
.endm
@@ -318,37 +332,37 @@
.endm
@ Plays the specified (song_number) song. The byte is apparently supposed to be 0x00.
- .macro playmusic song_number, unknown
+ .macro playbgm song_number, unknown
.byte 0x33
.2byte \song_number
.byte \unknown
.endm
- @ Plays the specified (song_number) song.
- .macro playmusicbattle song_number
+ @ Saves the specified (song_number) song to be played later.
+ .macro savebgm song_number
.byte 0x34
.2byte \song_number
.endm
@ Crossfades the currently-playing song into the map's default song.
- .macro fadedefault
+ .macro fadedefaultbgm
.byte 0x35
.endm
@ Crossfades the currently-playng song into the specified (song_number) song.
- .macro fademusic song_number
+ .macro fadenewbgm song_number
.byte 0x36
.2byte \song_number
.endm
@ Fades out the currently-playing song.
- .macro fadeout speed
+ .macro fadeoutbgm speed
.byte 0x37
.byte \speed
.endm
- @ Fades the currently-playing song back in.
- .macro fadein speed
+ @ Fades the previously-playing song back in.
+ .macro fadeinbgm speed
.byte 0x38
.byte \speed
.endm
@@ -363,7 +377,7 @@
.endm
@ Clone of warp that does not play a sound effect.
- .macro warpmuted map, warp, X, Y
+ .macro warpsilent map, warp, X, Y
.byte 0x3a
map \map
.byte \warp
@@ -371,8 +385,8 @@
.2byte \Y
.endm
- @ Clone of warp that uses "a walking effect".
- .macro warpwalk map, warp, X, Y
+ @ Clone of warp that plays a door opening animation before stepping upwards into it.
+ .macro warpdoor map, warp, X, Y
.byte 0x3b
map \map
.byte \warp
@@ -386,7 +400,7 @@
map \map
.endm
- @ Clone of warp that uses a teleport effect. It is apparently only used in R/S/E.[source]
+ @ Clone of warp that uses a teleport effect. It is apparently only used in R/S/E.
.macro warpteleport map, warp, X, Y
.byte 0x3d
map \map
@@ -395,8 +409,8 @@
.2byte \Y
.endm
- @ Clone of warp. Used by an (unused?) Safari Zone script to return the player to the gatehouse and end the Safari Game.
- .macro warp3 map, warp, X, Y
+ @ Sets the warp destination to be used later.
+ .macro setwarp map, warp, X, Y
.byte 0x3e
map \map
.byte \warp
@@ -404,8 +418,8 @@
.2byte \Y
.endm
- @ Sets a default warp place. If a warp tries to send the player to Warp 127 on Map 127.127, they will instead be sent here. Useful when a map has warps that need to go to script-controlled locations (i.e. elevators).
- .macro warpplace map, warp, X, Y
+ @ Sets the warp destination that a warp to Warp 127 on Map 127.127 will connect to. Useful when a map has warps that need to go to script-controlled locations (i.e. elevators).
+ .macro setdynamicwarp map, warp, X, Y
.byte 0x3f
map \map
.byte \warp
@@ -413,8 +427,8 @@
.2byte \Y
.endm
- @ Clone of warp3, except that this writes data to different offsets...
- .macro warp4 map, warp, X, Y
+ @ Sets the destination that diving or emerging from a dive will take the player to.
+ .macro setdivewarp map, warp, X, Y
.byte 0x40
map \map
.byte \warp
@@ -422,8 +436,8 @@
.2byte \Y
.endm
- @ Clone of warp3, except that this writes data to different offsets...
- .macro warp5 map, warp, X, Y
+ @ Sets the destination that falling into a hole will take the player to.
+ .macro setholewarp map, warp, X, Y
.byte 0x41
map \map
.byte \warp
@@ -438,20 +452,20 @@
.2byte \Y
.endm
- @ Retrieves the number of Pokmon in the player's party, and stores that number in variable 0x800D (LASTRESULT).
- .macro countpokemon
+ @ Retrieves the number of Pokemon in the player's party, and stores that number in variable 0x800D (LASTRESULT).
+ .macro getpartysize
.byte 0x43
.endm
@ Attempts to add quantity of item index to the player's Bag. If the player has enough room, the item will be added and variable 0x800D (LASTRESULT) will be set to 0x0001; otherwise, LASTRESULT is set to 0x0000.
- .macro additem index, quantity
+ .macro giveitem index, quantity
.byte 0x44
.2byte \index
.2byte \quantity
.endm
@ Removes quantity of item index from the player's Bag.
- .macro removeitem index, quantity
+ .macro takeitem index, quantity
.byte 0x45
.2byte \index
.2byte \quantity
@@ -478,7 +492,7 @@
.endm
@ Adds a quantity amount of item index to the player's PC. Both arguments can be variables.
- .macro addpcitem index, quantity
+ .macro givepcitem index, quantity
.byte 0x49
.2byte \index
.2byte \quantity
@@ -491,117 +505,114 @@
.2byte \quantity
.endm
- @ In FireRed, this command is a nop. (The argument is read, but not used for anything.)
- .macro adddecor a
+ @ Adds decoration to the player's PC. In FireRed, this command is a nop. (The argument is read, but not used for anything.)
+ .macro givedecoration decoration
.byte 0x4b
- .2byte \a
+ .2byte \decoration
.endm
- @ In FireRed, this command is a nop. (The argument is read, but not used for anything.)
- .macro removedecor a
+ @ Removes a decoration from the player's PC. In FireRed, this command is a nop. (The argument is read, but not used for anything.)
+ .macro takedecoration decoration
.byte 0x4c
- .2byte \a
+ .2byte \decoration
.endm
- @ In FireRed, this command is a nop. (The argument is read, but not used for anything.)
- .macro testdecor a
+ @ Checks for decoration in the player's PC. In FireRed, this command is a nop. (The argument is read, but not used for anything.)
+ .macro checkdecor decoration
.byte 0x4d
- .2byte \a
+ .2byte \decoration
.endm
- @ In FireRed, this command is a nop. (The argument is read, but not used for anything.)
- .macro checkdecor a
+ @ Checks if the player has enough space in their PC to hold decoration. Sets variable 0x800D (LASTRESULT) to 0x0001 if there is room, or 0x0000 is there is no room. In FireRed, this command is a nop. (The argument is read, but not used for anything.)
+ .macro checkdecorspace decoration
.byte 0x4e
- .2byte \a
- .endm
-
- @ Applies the movement data at movements to the specified (index) Person event. Also closes any standard message boxes that are still open.
- .macro move index, movements
- .byte 0x4f
- .2byte \index
- .4byte \movements
- .endm
-
- @ Apparent clone of applymovement. Oddly, it doesn't seem to work at all if applied to any Person other than the player (0xFF), and the X and Y arguments don't seem to do anything.
- @ This command in fact uses variables to access the Person event ID. So, for example, if you setvar 0x8000 to 0x3, and then use applymovementpos 0x8000 @move1, Person event 3 will have the movements at @move1 applied to them. Thank you Shiny Quagsire for bringing this to my attention.
- .macro movecoords variable, movements, x, y
- .byte 0x50
- .2byte \variable
- .4byte \movements
- .byte \x
- .byte \y
- .endm
-
- @ Blocks script execution until the movements being applied to the specified (index) Person event finish. If the specified Person event is 0x0000, then the command will block script execution until all Person events affected by applymovement finish their movements. If the specified Person event is not currently being manipulated with applymovement, then this command does nothing.
- .macro waitmove index
- .byte 0x51
- .2byte \index
- .endm
-
- @ Apparent clone of waitmovement. Oddly, it doesn't seem to work at all if applied to any Person other than the player (0xFF), and the X and Y arguments don't seem to do anything.
- .macro waitmovexy index, X, Y
- .byte 0x52
- .2byte \index
- .byte \X
- .byte \Y
- .endm
-
- @ Attempts to hide the specified (local_ID, a local ID) Person event on the current map, by setting its visibility flag if it has a valid one. If the Person does not have a valid visibility flag, this command does nothing.
- .macro disappear local_ID
- .byte 0x53
- .2byte \local_ID
- .endm
-
- @ Clone of hidesprite that also moves the Person? Test it!
- .macro disappearxy index, X, Y
- .byte 0x54
- .2byte \index
- .byte \X
- .byte \Y
- .endm
-
- .macro reappear word
- .byte 0x55
- .2byte \word
- .endm
-
- .macro reappearxy word, byte1, byte2
- .byte 0x56
- .2byte \word
- .byte \byte1
- .byte \byte2
- .endm
-
- .macro movesprite word1, word2, word3
+ .2byte \decoration
+ .endm
+
+ @ Applies the movement data at movements to the specified (index) Object event. Also closes any standard message boxes that are still open.
+ @ This command in fact uses variables to access the Object event ID. So, for example, if you setvar 0x8000 to 0x3, and then use applymovementpos 0x8000 @move1, Object event 3 will have the movements at @move1 applied to them.
+ .macro applymovement index, movements, mapGroup, mapNum
+ .ifb \mapGroup
+ .byte 0x4f
+ .2byte \index
+ .4byte \movements
+ .else
+ .byte 0x50
+ .2byte \index
+ .4byte \movements
+ .byte \mapGroup
+ .byte \mapNum
+ .endif
+ .endm
+
+ @ Blocks script execution until the movements being applied to the specified (index) Object event finish. If the specified Object event is 0x0000, then the command will block script execution until all Object events affected by applymovement finish their movements. If the specified Object event is not currently being manipulated with applymovement, then this command does nothing.
+ .macro waitmovement index, mapBank, mapNum
+ .ifb \mapBank
+ .byte 0x51
+ .2byte \index
+ .else
+ .byte 0x52
+ .2byte \index
+ .byte \mapBank
+ .byte \mapNum
+ .endif
+ .endm
+
+ @ Attempts to hide the specified (local_ID, a local ID) Object event on the specified map, by setting its visibility flag if it has a valid one. If the Object does not have a valid visibility flag, this command does nothing.
+ @ If no map is specified, then the current map is used
+ .macro removeobject localId, mapGroup, mapNum
+ .ifb \mapGroup
+ .byte 0x53
+ .2byte \localId
+ .else
+ .byte 0x54
+ .2byte \localId
+ .byte \mapGroup
+ .byte \mapNum
+ .endif
+ .endm
+
+ .macro addobject localId, mapGroup, mapNum
+ .ifb \mapGroup
+ .byte 0x55
+ .2byte \localId
+ .else
+ .byte 0x56
+ .2byte \localId
+ .byte \mapGroup
+ .byte \mapNum
+ .endif
+ .endm
+
+ @ Sets the specified (index) Object's position on the current map.
+ .macro setobjectxy index, x, y
.byte 0x57
- .2byte \word1
- .2byte \word2
- .2byte \word3
+ .2byte \index
+ .2byte \x
+ .2byte \y
.endm
- .macro spritevisible word, byte1, byte2
+ .macro showobjectat index, map
.byte 0x58
- .2byte \word
- .byte \byte1
- .byte \byte2
+ .2byte \index
+ map \map
.endm
- .macro spriteinvisible word, byte1, byte2
+ .macro hideobjectat index, map
.byte 0x59
- .2byte \word
- .byte \byte1
- .byte \byte2
+ .2byte \index
+ map \map
.endm
- @ If the script was called by a Person event, then that Person will turn to face toward the tile that the player is stepping off of.
+ @ If the script was called by a Object event, then that Object will turn to face toward the tile that the player is stepping off of.
.macro faceplayer
.byte 0x5a
.endm
- .macro spriteface word, byte
+ .macro turnobject index, direction
.byte 0x5b
- .2byte \word
- .byte \byte
+ .2byte \index
+ .byte \direction
.endm
@ If the Trainer flag for Trainer index is not set, this command does absolutely nothing.
@@ -647,17 +658,18 @@
.endif
.endm
-
@ Starts a trainer battle using the battle information stored in RAM (usually by trainerbattle, which actually calls this command behind-the-scenes), and blocks script execution until the battle finishes.
- .macro reptrainerbattle
+ .macro trainerbattlebegin
.byte 0x5d
.endm
- .macro endtrainerbattle
+ @ Goes to address after the trainerbattle command (called by the battle functions, see battle_setup.c)
+ .macro gotopostbattlescript
.byte 0x5e
.endm
- .macro endtrainerbattle2
+ @ Goes to address specified in the trainerbattle command (called by the battle functions, see battle_setup.c)
+ .macro gotobeatenscript
.byte 0x5f
.endm
@@ -667,38 +679,38 @@
.2byte \trainer
.endm
- @ Sets Flag (trainer + 0x500). (I didn't make a mistake. The command names actually are backwards.)
- .macro cleartrainerflag trainer
+ @ Sets Flag (trainer + 0x500).
+ .macro settrainerflag trainer
.byte 0x61
.2byte \trainer
.endm
- @ Clears Flag (trainer + 0x500). (I didn't make a mistake. The command names actually are backwards.)
- .macro settrainerflag trainer
+ @ Clears Flag (trainer + 0x500).
+ .macro cleartrainerflag trainer
.byte 0x62
.2byte \trainer
.endm
- .macro movespriteperm word1, word2, word3
+ .macro setobjectxyperm index, x, y
.byte 0x63
- .2byte \word1
- .2byte \word2
- .2byte \word3
+ .2byte \index
+ .2byte \x
+ .2byte \y
.endm
- .macro moveoffscreen word
+ .macro moveobjectoffscreen index
.byte 0x64
- .2byte \word
+ .2byte \index
.endm
- .macro spritebehave word, byte
+ .macro setobjectmovementtype word, byte
.byte 0x65
.2byte \word
.byte \byte
.endm
@ If a standard message box (or its text) is being drawn on-screen, this command blocks script execution until the box and its text have been fully drawn.
- .macro waittext
+ .macro waitmessage
.byte 0x66
.endm
@@ -708,73 +720,73 @@
.4byte \text
.endm
- @ Holds the current message box open until the player presses a key. The message box is then closed.
- .macro closebutton
+ @ Closes the current message box.
+ .macro closemessage
.byte 0x68
.endm
- @ Ceases movement for all OWs on-screen.
+ @ Ceases movement for all Objects on-screen.
.macro lockall
.byte 0x69
.endm
- @ If the script was called by a Person event, then that Person's movement will cease.
+ @ 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 OWs on-screen, and closes any standard message boxes that are still open.
+ @ 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 a Person event, then that Person's movement will resume. This command also closes any standard message boxes that are still open.
+ @ 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 waitbutton
+ .macro waitbuttonpress
.byte 0x6d
.endm
@ Displays a YES/NO multichoice box at the specified coordinates, and blocks script execution until the user makes a selection. Their selection is stored in variable 0x800D (LASTRESULT); 0x0000 for "NO" or if the user pressed B, and 0x0001 for "YES".
- .macro yesnobox X, Y
+ .macro yesnobox x, y
.byte 0x6e
- .byte \X
- .byte \Y
+ .byte \x
+ .byte \y
.endm
- @ Displays a multichoice box from which the user can choose a selection, and blocks script execution until a selection is made. Lists of options are predefined and the one to be used is specified with list. If B is set to a non-zero value, then the user will not be allowed to back out of the multichoice with the B button.
- .macro multichoice X, Y, list, B
+ @ Displays a multichoice box from which the user can choose a selection, and blocks script execution until a selection is made. Lists of options are predefined and the one to be used is specified with list. If b is set to a non-zero value, then the user will not be allowed to back out of the multichoice with the B button.
+ .macro multichoice x, y, list, b
.byte 0x6f
- .byte \X
- .byte \Y
+ .byte \x
+ .byte \y
.byte \list
- .byte \B
+ .byte \b
.endm
- @ Displays a multichoice box from which the user can choose a selection, and blocks script execution until a selection is made. Lists of options are predefined and the one to be used is specified with list. The default argument determines the initial position of the cursor when the box is first opened; it is zero-indexed, and if it is too large, it is treated as 0x00. If B is set to a non-zero value, then the user will not be allowed to back out of the multichoice with the B button.
- .macro multichoicedef X, Y, list, default, B
+ @ Displays a multichoice box from which the user can choose a selection, and blocks script execution until a selection is made. Lists of options are predefined and the one to be used is specified with list. The default argument determines the initial position of the cursor when the box is first opened; it is zero-indexed, and if it is too large, it is treated as 0x00. If b is set to a non-zero value, then the user will not be allowed to back out of the multichoice with the B button.
+ .macro multichoicedefault x, y, list, default, b
.byte 0x70
- .byte \X
- .byte \Y
+ .byte \x
+ .byte \y
.byte \list
.byte \default
- .byte \B
+ .byte \b
.endm
@ Displays a multichoice box from which the user can choose a selection, and blocks script execution until a selection is made. Lists of options are predefined and the one to be used is specified with list. The per_row argument determines how many list items will be shown on a single row of the box.
- .macro multichoicerow X, Y, list, per_row, B
+ .macro multichoicegrid x, y, list, per_row, B
.byte 0x71
- .byte \X
- .byte \Y
+ .byte \x
+ .byte \y
.byte \list
.byte \per_row
.byte \B
.endm
- .macro showbox byte1, byte2, byte3, byte4
+ .macro drawbox byte1, byte2, byte3, byte4
.byte 0x72
.byte \byte1
.byte \byte2
@@ -782,7 +794,7 @@
.byte \byte4
.endm
- .macro hidebox byte1, byte2, byte3, byte4
+ .macro erasebox byte1, byte2, byte3, byte4
.byte 0x73
.byte \byte1
.byte \byte2
@@ -790,7 +802,7 @@
.byte \byte4
.endm
- .macro clearbox byte1, byte2, byte3, byte4
+ .macro drawboxtext byte1, byte2, byte3, byte4
.byte 0x74
.byte \byte1
.byte \byte2
@@ -798,33 +810,33 @@
.byte \byte4
.endm
- @ Displays a box containing the front sprite for the specified (species) Pokmon species.
- .macro showpokepic species, X, Y
+ @ Displays a box containing the front sprite for the specified (species) Pokemon species.
+ .macro drawmonpic species, x, y
.byte 0x75
.2byte \species
- .byte \X
- .byte \Y
+ .byte \x
+ .byte \y
.endm
- @ Hides all boxes displayed with showpokepic.
- .macro hidepokepic
+ @ Hides all boxes displayed with drawmonpic.
+ .macro erasemonpic
.byte 0x76
.endm
- @ In FireRed, this command is a nop. (The argument is discarded.)
- .macro showcontestwinner a
+ @ Draws an image of the winner of the contest. In FireRed, this command is a nop. (The argument is discarded.)
+ .macro drawcontestwinner a
.byte 0x77
.byte \a
.endm
@ Displays the string at pointer as braille text in a standard message box. The string must be formatted to use braille characters.
- .macro braillemsg text
+ .macro braillemessage text
.byte 0x78
.4byte \text
.endm
- @ Gives the player one of the specified (species) Pokmon at level level holding item. The unknown arguments should all be zeroes.
- .macro givepokemon species, level, item, unknown1, unknown2, unknown3
+ @ Gives the player one of the specified (species) Pokemon at level level holding item. The unknown arguments should all be zeroes.
+ .macro givemon species, level, item, unknown1, unknown2, unknown3
.byte 0x79
.2byte \species
.byte \level
@@ -834,81 +846,81 @@
.byte \unknown3
.endm
- .macro giveegg word
+ .macro giveegg species
.byte 0x7a
- .2byte \word
+ .2byte \species
.endm
- .macro setpokemove byte1, byte2, word
+ .macro setmonmove index, slot, move
.byte 0x7b
- .byte \byte1
- .byte \byte2
- .2byte \word
+ .byte \index
+ .byte \slot
+ .2byte \move
.endm
- @ Checks if at least one Pokmon in the player's party knows the specified (index) attack. If so, variable 0x800D (LASTRESULT) is set to the (zero-indexed) slot number of the Pokmon that knows the move. If not, LASTRESULT is set to 0x0006.
- .macro checkattack index
+ @ Checks if at least one Pokemon in the player's party knows the specified (index) attack. If so, variable 0x800D (LASTRESULT) is set to the (zero-indexed) slot number of the first Pokemon that knows the move. If not, LASTRESULT is set to 0x0006. Variable 0x8004 is also set to this Pokemon's species.
+ .macro checkpartymove index
.byte 0x7c
.2byte \index
.endm
- @ Writes the name of the Pokmon at index species to the specified buffer.
- .macro bufferpoke out, species
+ @ Writes the name of the Pokemon at index species to the specified buffer.
+ .macro bufferspeciesname out, species
.byte 0x7d
.byte \out
.2byte \species
.endm
- @ Writes the name of the first Pokmon in the player's party to the specified buffer.
- .macro bufferfirstpoke out
+ @ Writes the name of the species of the first Pokemon in the player's party to the specified buffer.
+ .macro bufferleadmonspeciesname out
.byte 0x7e
.byte \out
.endm
- @ Writes the name of the Pokmon 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 bufferpartypoke out, slot
+ @ Writes the nickname of the Pokemon in slot slot (zero-indexed) of the player's party to the specified buffer. If an empty or invalid slot is specified, ten spaces ("") are written to the buffer.
+ .macro bufferpartymonnick out, slot
.byte 0x7f
.byte \out
.2byte \slot
.endm
@ Writes the name of the item at index item to the specified buffer. If the specified index is larger than the number of items in the game (0x176), the name of item 0 ("????????") is buffered instead.
- .macro bufferitem out, item
+ .macro bufferitemname out, item
.byte 0x80
.byte \out
.2byte \item
.endm
- @ In FireRed, this command is a nop. (The first argument is discarded immediately. The second argument is read, but not used for anything.)
- .macro bufferdecor a, b
+ @ Writes the name of the decoration at index decoration to the specified buffer. In FireRed, this command is a nop.
+ .macro bufferdecorationname out, decoration
.byte 0x81
- .byte \a
- .2byte \b
+ .byte \out
+ .2byte \decoration
.endm
- @ Writes the name of the attack at index attack to the specified buffer.
- .macro bufferattack out, attack
+ @ Writes the name of the move at index move to the specified buffer.
+ .macro buffermovename out, move
.byte 0x82
.byte \out
- .2byte \attack
+ .2byte \move
.endm
@ Converts the value of input to a decimal string, and writes that string to the specified buffer.
- .macro buffernum out, input
+ .macro buffernumberstring out, input
.byte 0x83
.byte \out
.2byte \input
.endm
- @ Writes the standard string identified by index to the specified buffer. Specifying an invalid standard string (e.x. 0x2B) can and usually will cause data corruption (I've observed destruction of the stored player name and crashes when entering/exiting certain menu screens).
- .macro bufferstd out, index
+ @ Writes the standard string identified by index to the specified buffer. This command has no protections in place at all, so specifying an invalid standard string (e.x. 0x2B) can and usually will cause data corruption.
+ .macro bufferstdstring out, index
.byte 0x84
.byte \out
.2byte \index
.endm
@ Copies the string at offset to the specified buffer.
- .macro buffertext out, offset
+ .macro bufferstring out, offset
.byte 0x85
.byte \out
.4byte \offset
@@ -920,46 +932,49 @@
.4byte \products
.endm
- @ Apparent clone of pokemart.
- .macro pokemartdecor products
+ @ Opens the Pokemart system and treats the list of items as decorations.
+ .macro pokemartdecoration products
.byte 0x87
.4byte \products
.endm
- @ Apparent clone of pokemart.
- .macro pokemartbp products
+ @ Apparent clone of pokemartdecoration.
+ .macro pokemartdecoration2 products
.byte 0x88
.4byte \products
.endm
- .macro pokecasino word
+ @ Starts up the slot machine minigame.
+ .macro playslotmachine word
.byte 0x89
.2byte \word
.endm
- @ In FireRed, this command is a nop.
- .macro event_8a byte1, byte2, byte3
+ @ Sets a berry tree's specific berry and growth stage. In FireRed, this command is a nop.
+ .macro setberrytree tree_id, berry, growth_stage
.byte 0x8a
- .byte \byte1, \byte2, \byte3
+ .byte \tree_id
+ .byte \berry
+ .byte \growth_stage
.endm
- @ In FireRed, this command sets the byte at 0x03000EA8 to 0x01. I do not know what that means.
- .macro choosecontestpkmn
+ @ 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
- @ In FireRed, this command is a nop.
- .macro startcontest
+ @ Starts a contest. In FireRed, this command is a nop.
+ .macro startcontest
.byte 0x8c
.endm
- @ In FireRed, this command is a nop.
- .macro showcontestresults
+ @ Shows the results of a contest. In FireRed, this command is a nop.
+ .macro showcontestresults
.byte 0x8d
.endm
- @ In FireRed, this command is a nop.
- .macro contestlinktransfer
+ @ Starts a contest over a link connection. In FireRed, this command is a nop.
+ .macro contestlinktransfer
.byte 0x8e
.endm
@@ -977,7 +992,7 @@
.endm
@ If check is 0x00, this command subtracts value from the player's money.
- .macro paymoney value, check
+ .macro takemoney value, check
.byte 0x91
.4byte \value
.byte \check
@@ -991,102 +1006,103 @@
.endm
@ Spawns a secondary box showing how much money the player has.
- .macro showmoney X, Y
+ .macro showmoneybox x, y
.byte 0x93
- .byte \X
- .byte \Y
+ .byte \x
+ .byte \y
.endm
@ Hides the secondary box spawned by showmoney.
- .macro hidemoney X, Y
+ .macro hidemoneybox x, y
.byte 0x94
- .byte \X
- .byte \Y
+ .byte \x
+ .byte \y
.endm
- @ Updates the secondary box spawned by showmoney. (What does it do with its arguments?)
- .macro updatemoney X, Y
+ @ Updates the secondary box spawned by showmoney. Consumes but does not use arguments.
+ .macro updatemoneybox x, y
.byte 0x95
- .byte \X
- .byte \Y
+ .byte \x
+ .byte \y
.endm
- @ In FireRed, this command is a nop.
- .macro event_96 word
+ @ Gets the price reduction for the index given. In FireRed, this command is a nop.
+ .macro getpricereduction index
.byte 0x96
- .2byte \word
+ .2byte \index
.endm
- @ Fades the screen to black or back, using the specified effect. Effect 0x00 fades in, and effect 0x01 fades out. I don't know if other effects exist.
+ @ Fades the screen to and from black and white. Mode 0x00 fades from black, mode 0x01 fades out to black, mode 0x2 fades in from white, and mode 0x3 fades out to white.
.macro fadescreen effect
.byte 0x97
.byte \effect
.endm
- .macro fadescreendelay byte1, byte2
+ @ Fades the screen to and from black and white. Mode 0x00 fades from black, mode 0x01 fades out to black, mode 0x2 fades in from white, and mode 0x3 fades out to white. Other modes may exist.
+ .macro fadescreenspeed effect, speed
.byte 0x98
- .byte \byte1
- .byte \byte2
+ .byte \effect
+ .byte \speed
.endm
- .macro darken word
+ .macro setflashradius word
.byte 0x99
.2byte \word
.endm
- .macro lighten byte
+ .macro animateflash byte
.byte 0x9a
.byte \byte
.endm
- .macro message2 pointer
+ .macro messageautoscroll pointer
.byte 0x9b
.4byte \pointer
.endm
@ Executes the specified field move animation.
- .macro doanimation animation
+ .macro dofieldeffect animation
.byte 0x9c
.2byte \animation
.endm
- @ Tells the game which party Pokmon to use for the next field move animation.
- .macro setanimation animation, slot
+ @ Sets up the field effect argument argument with the value value.
+ .macro setfieldeffectargument argument, param
.byte 0x9d
- .byte \animation
- .2byte \slot
+ .byte \argument
+ .2byte \param
.endm
@ Blocks script execution until all playing field move animations complete.
- .macro checkanimation animation
+ .macro waitfieldeffect animation
.byte 0x9e
.2byte \animation
.endm
- @ Sets which healing place the player will return to if all of the Pokmon in their party faint. A list of available healing places can be found on PokeCommunity.
- .macro sethealplace flightspot
+ @ Sets which healing place the player will return to if all of the Pokemon in their party faint.
+ .macro setrespawn heallocation
.byte 0x9f
- .2byte \flightspot
+ .2byte \heallocation
.endm
@ Checks the player's gender. If male, then 0x0000 is stored in variable 0x800D (LASTRESULT). If female, then 0x0001 is stored in LASTRESULT.
- .macro checkgender
+ .macro checkplayergender
.byte 0xa0
.endm
- @ Plays the specified (species) Pokmon's cry. You can use waitcry to block script execution until the sound finishes.
- .macro pokecry species, effect
+ @ Plays the specified (species) Pokemon's cry. You can use waitcry to block script execution until the sound finishes.
+ .macro playmoncry species, effect
.byte 0xa1
.2byte \species
.2byte \effect
.endm
- @ Changes the tile at (X, Y) on the current map.
- .macro setmaptile X, Y, tile_number, tile_attrib
+ @ Changes the metatile at (x, y) on the current map.
+ .macro setmetatile x, y, metatile_number, tile_attrib
.byte 0xa2
- .2byte \X
- .2byte \Y
- .2byte \tile_number
+ .2byte \x
+ .2byte \y
+ .2byte \metatile_number
.2byte \tile_attrib
.endm
@@ -1107,103 +1123,101 @@
.endm
@ This command manages cases in which maps have tiles that change state when stepped on (specifically, cracked/breakable floors).
- .macro tileeffect subroutine
+ .macro setstepcallback subroutine
.byte 0xa6
.byte \subroutine
.endm
- .macro setmapfooter word
+ .macro setmaplayoutindex index
.byte 0xa7
- .2byte \word
+ .2byte \index
.endm
- .macro spritelevelup word, byte1, byte2, byte3
+ .macro setobjectpriority index, map, priority
.byte 0xa8
- .2byte \word
- .byte \byte1
- .byte \byte2
- .byte \byte3
+ .2byte \index
+ map \map
+ .byte \priority
.endm
- .macro restorespritelevel word, byte1, byte2
+ .macro resetobjectpriority index, map
.byte 0xa9
- .2byte \word
- .byte \byte1
- .byte \byte2
+ .2byte \index
+ map \map
.endm
- .macro createvsprite byte1, byte2, word1, word2, byte3, byte4
+ .macro createvobject sprite, byte2, x, y, elevation, direction
.byte 0xaa
- .byte \byte1
+ .byte \sprite
.byte \byte2
- .2byte \word1
- .2byte \word2
- .byte \byte3
- .byte \byte4
+ .2byte \x
+ .2byte \y
+ .byte \elevation
+ .byte \direction
.endm
- .macro vspriteface byte1, byte2
+ .macro turnvobject index, direction
.byte 0xab
- .byte \byte1
- .byte \byte2
+ .byte \index
+ .byte \direction
.endm
- @ Queues the opening of the door tile at (X, Y) with an animation.
- .macro setdooropened X, Y
+ @ Opens the door metatile at (X, Y) with an animation.
+ .macro opendoor x, y
.byte 0xac
- .2byte \X
- .2byte \Y
+ .2byte \x
+ .2byte \y
.endm
- @ Queues the closing of the door tile at (X, Y) with an animation.
- .macro setdoorclosed X, Y
+ @ Closes the door metatile at (X, Y) with an animation.
+ .macro closedoor x, y
.byte 0xad
- .2byte \X
- .2byte \Y
+ .2byte \x
+ .2byte \y
.endm
- @ Executes the state changes queued with setdooropened, setdoorclosed, setdooropened2, and setdoorclosed2.
- .macro doorchange
+ @ Waits for the door animation started with opendoor or closedoor to finish.
+ .macro waitdooranim
.byte 0xae
.endm
- @ Queues the opening of the door tile at (X, Y) without an animation.
- .macro setdooropened2 X, Y
+ @ Sets the door tile at (x, y) to be open without an animation.
+ .macro setdooropen x, y
.byte 0xaf
- .2byte \X
- .2byte \Y
+ .2byte \x
+ .2byte \y
.endm
- @ Queues the closing of the door tile at (X, Y) without an animation.
- .macro setdoorclosed2 X, Y
+ @ Sets the door tile at (x, y) to be closed without an animation.
+ .macro setdoorclosed x, y
.byte 0xb0
- .2byte \X
- .2byte \Y
+ .2byte \x
+ .2byte \y
.endm
@ In FireRed, this command is a nop.
- .macro event_b1
+ .macro addelevmenuitem
.byte 0xb1
.endm
- @ In FireRed, this command is a nop.
- .macro event_b2
+ @ In FireRed and Emerald, this command is a nop.
+ .macro showelevmenu
.byte 0xb2
.endm
- .macro checkcoins word
+ .macro checkcoins out
.byte 0xb3
- .2byte \word
+ .2byte \out
.endm
- .macro givecoins word
+ .macro givecoins count
.byte 0xb4
- .2byte \word
+ .2byte \count
.endm
- .macro removecoins word
+ .macro takecoins count
.byte 0xb5
- .2byte \word
+ .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.
@@ -1214,7 +1228,7 @@
.2byte \item
.endm
- @ Starts a wild battle against the Pokmon generated by setwildbattle. Blocks script execution until the battle finishes.
+ @ Starts a wild battle against the Pokemon generated by setwildbattle. Blocks script execution until the battle finishes.
.macro dowildbattle
.byte 0xb7
.endm
@@ -1225,7 +1239,7 @@
.2byte \word
.endm
- .macro vjump pointer
+ .macro vgoto pointer
.byte 0xb9
.4byte \pointer
.endm
@@ -1235,19 +1249,19 @@
.4byte \pointer
.endm
- .macro if5 byte, pointer
+ .macro vgoto_if byte, pointer
.byte 0xbb
.byte \byte
.4byte \pointer
.endm
- .macro if6 byte, pointer
+ .macro vcall_if byte, pointer
.byte 0xbc
.byte \byte
.4byte \pointer
.endm
- .macro vtext pointer
+ .macro vmessage pointer
.byte 0xbd
.4byte \pointer
.endm
@@ -1257,50 +1271,50 @@
.4byte \pointer
.endm
- .macro vbuffer byte, pointer
+ .macro vbufferstring byte, pointer
.byte 0xbf
.byte \byte
.4byte \pointer
.endm
@ Spawns a secondary box showing how many Coins the player has.
- .macro showcoins X, Y
+ .macro showcoinsbox x, y
.byte 0xc0
- .byte \X
- .byte \Y
+ .byte \x
+ .byte \y
.endm
- @ Hides the secondary box spawned by showcoins. It doesn't appear to use its arguments, but they are still required.
- .macro hidecoins X, Y
+ @ Hides the secondary box spawned by showcoins. It consumes its arguments but doesn't use them.
+ .macro hidecoinsbox x, y
.byte 0xc1
- .byte \X
- .byte \Y
+ .byte \x
+ .byte \y
.endm
- @ Updates the secondary box spawned by showcoins. (What does it do with its arguments?)
- .macro updatecoins X, Y
+ @ Updates the secondary box spawned by showcoins. It consumes its arguments but doesn't use them.
+ .macro updatecoinsbox x, y
.byte 0xc2
- .byte \X
- .byte \Y
+ .byte \x
+ .byte \y
.endm
- @ Increases the value of the specified hidden variable by 1. The hidden variable's value will not be allowed to exceed 0x00FFFFFF.
- .macro inccounter a
+ @ Increases the value of the specified game stat by 1. The stat's value will not be allowed to exceed 0x00FFFFFF.
+ .macro incrementgamestat stat
.byte 0xc3
- .byte \a
+ .byte \stat
.endm
- @ Clone of warp... Except that it doesn't appear to have any effect when used in some of FireRed's default level scripts. (If it did, Berry Forest would be impossible to enter...)
- .macro warp6 map, warp, X, Y
+ @ Sets the destination that using an Escape Rope or Dig will take the player to.
+ .macro setescapewarp map, warp, x, y
.byte 0xc4
map \map
.byte \warp
- .2byte \X
- .2byte \Y
+ .2byte \x
+ .2byte \y
.endm
@ Blocks script execution until cry finishes.
- .macro waitpokecry
+ .macro waitmoncry
.byte 0xc5
.endm
@@ -1345,161 +1359,123 @@
.4byte \value
.endm
- @ Makes the Pokmon in the specified slot of the player's party obedient. It will not randomly disobey orders in battle.
- .macro setobedience slot
- .byte 0xcd
- .2byte \slot
- .endm
-
- @ Checks if the Pokmon in the specified slot of the player's party is obedient. If the Pokmon is disobedient, 0x0001 is written to script variable 0x800D (LASTRESULT). If the Pokmon is obedient (or if the specified slot is empty or invalid), 0x0000 is written.
- .macro checkobedience slot
- .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 0x020370A4.
- .macro execram
- .byte 0xcf
- .endm
+@ Supplementary
- @ Sets worldmapflag to 1. This allows the player to Fly to the corresponding map, if that map has a flightspot.
- .macro setworldflag worldmapflag
- .byte 0xd0
- .2byte \worldmapflag
+ .macro goto_if_trainer_not_defeated opponent, dest
+ checktrainerflag \opponent
+ goto_if 0, \dest
.endm
- @ Clone of warpteleport? It is apparently only used in FR/LG, and only with specials.[source]
- .macro warpteleport2 map, warp, X, Y
- .byte 0xd1
- map \map
- .byte \warp
- .2byte \X
- .2byte \Y
+ .macro goto_if_trainer_defeated opponent, dest
+ checktrainerflag \opponent
+ goto_if 1, \dest
.endm
- @ Changes the location where the player caught the Pokmon in the specified slot of their party. A list of valid catch locations can be found on PokeCommunity.
- .macro setcatchlocale slot, location
- .byte 0xd2
- .2byte \slot
- .byte \location
+ .macro call_if_trainer_not_defeated opponent, dest
+ checktrainerflag \opponent
+ call_if 0, \dest
.endm
- .macro event_d3 unknown
- .byte 0xd3
- .2byte \unknown
+ .macro call_if_trainer_defeated opponent, dest
+ checktrainerflag \opponent
+ call_if 1, \dest
.endm
- .macro event_d4
- .byte 0xd4
+ .macro goto_if_unset flag, dest
+ checkflag \flag
+ goto_if 0, \dest
.endm
- @ In FireRed, this command is a nop.
- .macro event_d5 var
- .byte 0xd5
- .2byte \var
+ .macro goto_if_set flag, dest
+ checkflag \flag
+ goto_if 1, \dest
.endm
- .macro event_d6
- .byte 0xd6
- .endm
+ .macro goto_if_lt dest @ LESS THAN
+ goto_if 0, \dest
+ .endm
- .macro warp7 map, byte, word1, word2
- .byte 0xd7
- map \map
- .byte \byte
- .2byte \word1
- .2byte \word2
+ .macro goto_if_eq dest @ EQUAL
+ goto_if 1, \dest
.endm
- .macro event_d8
- .byte 0xd8
+ .macro goto_if_gt dest @ GREATER THAN
+ goto_if 2, \dest
.endm
- .macro event_d9
- .byte 0xd9
+ .macro goto_if_le dest @ LESS THAN OR EQUAL
+ goto_if 3, \dest
.endm
- .macro hidebox2
- .byte 0xda
+ .macro goto_if_ge dest @ GREATER THAN OR EQUAL
+ goto_if 4, \dest
.endm
- .macro message3 pointer
- .byte 0xdb
- .4byte \pointer
+ .macro goto_if_ne dest @ NOT EQUAL
+ goto_if 5, \dest
.endm
- .macro fadescreen3 byte
- .byte 0xdc
- .byte \byte
+ .macro call_if_unset flag, dest
+ checkflag \flag
+ call_if 0, \dest
.endm
- .macro buffertrainerclass byte, word
- .byte 0xdd
- .byte \byte
- .2byte \word
+ .macro call_if_set flag, dest
+ checkflag \flag
+ call_if 1, \dest
.endm
- .macro buffertrainername byte, word
- .byte 0xde
- .byte \byte
- .2byte \word
+ .macro call_if_lt dest @ LESS THAN
+ call_if 0, \dest
.endm
- .macro pokenavcall pointer
- .byte 0xdf
- .4byte \pointer
+ .macro call_if_eq dest @ EQUAL
+ call_if 1, \dest
.endm
- .macro warp8 map, byte, word1, word2
- .byte 0xe0
- map \map
- .byte \byte
- .2byte \word1
- .2byte \word2
+ .macro call_if_gt dest @ GREATER THAN
+ call_if 2, \dest
.endm
- .macro buffercontesttype byte, word
- .byte 0xe1
- .byte \byte
- .2byte \word
+ .macro call_if_le dest @ LESS THAN OR EQUAL
+ call_if 3, \dest
.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 storeitems out, item, quantity
- .byte 0xe2
- .byte \out
- .2byte \item
- .2byte \quantity
+ .macro call_if_ge dest @ GREATER THAN OR EQUAL
+ call_if 4, \dest
.endm
-
-@ Supplementary
-
- .macro jumpeq dest
- jumpif 1, \dest
+ .macro call_if_ne dest @ NOT EQUAL
+ call_if 5, \dest
.endm
.macro switch var
- copyvar 0x8000, \var
+ copyvar VAR_SPECIAL_0, \var
.endm
.macro case condition, dest
- compare 0x8000, \condition
- jumpeq \dest
+ compare_var_to_value VAR_SPECIAL_0, \condition
+ goto_if_eq \dest
.endm
.macro msgbox text, type=4
- loadptr 0, \text
+ loadword 0, \text
callstd \type
.endm
- .macro giveitem item, amount=1, function=0
- setorcopyvar 0x8000, \item
- setorcopyvar 0x8001, \amount
+ @ Message box types
+ MSGBOX_YESNO = 5
+
+ YES = 1
+ NO = 0
+
+ .macro giveitem_std item, amount=1, function=0
+ setorcopyvar VAR_SPECIAL_0, \item
+ setorcopyvar VAR_SPECIAL_1, \amount
callstd \function
.endm
- .macro givedecoration decoration
- setorcopyvar 0x8000, \decoration
+ .macro givedecoration_std decoration
+ setorcopyvar VAR_SPECIAL_0, \decoration
callstd 7
.endm
diff --git a/asm/macros/map.inc b/asm/macros/map.inc
index 41844b5cd..db37d9346 100644
--- a/asm/macros/map.inc
+++ b/asm/macros/map.inc
@@ -1,38 +1,8 @@
- .macro new_map_group
- inc cur_map_group
- .set cur_map_num, 0
+ .macro map map_id
+ .byte \map_id >> 8 @ map group
+ .byte \map_id & 0xFF @ map num
.endm
- .macro map_group map_name
- .set GROUP_\map_name, cur_map_group
- .set MAP_\map_name, cur_map_num
- inc cur_map_num
- .endm
-
- .macro map map_name
- .byte GROUP_\map_name
- .byte MAP_\map_name
- .endm
-
- .macro warp_map map_name
- .byte MAP_\map_name
- .byte GROUP_\map_name
- .endm
-
- .macro heal_location map_name, x, y
- .byte GROUP_\map_name
- .byte MAP_\map_name
- .2byte \x
- .2byte \y
- .space 2
- .endm
-
- .equiv GROUP_NONE, 0x7f
- .equiv MAP_NONE, 0x7f
-
- .equiv GROUP_UNDEFINED, 0xff
- .equiv MAP_UNDEFINED, 0xff
-
.macro map_script type, address
.byte \type
.4byte \address
@@ -54,10 +24,11 @@
inc _num_npcs
.endm
- .macro warp_def x, y, byte, warp, map
+ .macro warp_def x, y, byte, warp, map_id
.2byte \x, \y
.byte \byte, \warp
- warp_map \map
+ .byte \map_id & 0xFF @ map num
+ .byte \map_id >> 8 @ map group
inc _num_warps
.endm
@@ -69,6 +40,10 @@
inc _num_traps
.endm
+ .macro coord_weather_event x, y, height, weather
+ coord_event \x, \y, \height, 0, \weather, 0, 0, 0x0
+ .endm
+
.macro bg_event x, y, byte, kind, word, arg6, arg7, arg8
.2byte \x, \y
.byte \byte, \kind
@@ -82,6 +57,14 @@
inc _num_signs
.endm
+ .macro bg_hidden_item_event x, y, height, item, flag
+ bg_event \x, \y, \height, 7, 0, \item, ((\flag) - FLAG_HIDDEN_ITEMS_START), 0
+ .endm
+
+ .macro bg_secret_base_event x, y, height, secret_base_id
+ bg_event \x, \y, \height, 8, 0, \secret_base_id, 0, 0
+ .endm
+
.macro map_events npcs, warps, traps, signs
.byte _num_npcs, _num_warps, _num_traps, _num_signs
.4byte \npcs, \warps, \traps, \signs