summaryrefslogtreecommitdiff
path: root/asm/macros
diff options
context:
space:
mode:
Diffstat (limited to 'asm/macros')
-rw-r--r--asm/macros/event.inc682
-rw-r--r--asm/macros/movement.inc208
2 files changed, 530 insertions, 360 deletions
diff --git a/asm/macros/event.inc b/asm/macros/event.inc
index 19293e527..5526b1e50 100644
--- a/asm/macros/event.inc
+++ b/asm/macros/event.inc
@@ -19,59 +19,52 @@
.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
+ .macro call destination:req
.byte 0x04
.4byte \destination
.endm
@ Jumps to destination and continues script execution from there.
- .macro goto destination
+ .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, destination
+ .macro goto_if condition:req, destination:req
.byte 0x06
.byte \condition
.4byte \destination
.endm
- lt = 0
- eq = 1
- gt = 2
- le = 3
- ge = 4
- ne = 5
-
@ If the result of the last comparison matches condition (see Comparison operators), calls destination.
- .macro call_if condition, 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
+ .macro gotostd function:req
.byte 0x08
.byte \function
.endm
@ Calls the standard function at index function.
- .macro callstd 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, 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, function
+ .macro callstd_if condition:req, function:req
.byte 0x0b
.byte \condition
.byte \function
@@ -88,183 +81,181 @@
.endm
@ Sets mystery event status
- .macro setmysteryeventstatus value
+ .macro setmysteryeventstatus value:req
.byte 0x0e
.byte \value
.endm
@ Sets the specified script bank to immediate value.
- .macro loadword destination, value
+ .macro loadword destination:req, value:req
.byte 0x0f
.byte \destination
.4byte \value
.endm
@ Sets the specified script bank to immediate value.
- .macro loadbyte destination, value
+ .macro loadbyte destination:req, value:req
.byte 0x10
.byte \destination
.byte \value
.endm
@ Sets the byte at offset to value.
- .macro writebytetoaddr value, offset
+ .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, source
+ .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, 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, source
+ .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, source
+ .macro copybyte destination:req, source:req
.byte 0x15
.4byte \destination
.4byte \source
.endm
@ Changes the value of destination to value.
- .macro setvar destination, 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, value
+ .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, value
+ .macro subvar destination:req, value:req
.byte 0x18
.2byte \destination
.2byte \value
.endm
@ Copies the value of source into destination.
- .macro copyvar destination, source
+ .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, source
+ .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, byte2
+ .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, 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, 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, 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, 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, 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, value
+ .macro compare_var_to_value var:req, value:req
.byte 0x21
.2byte \var
.2byte \value
.endm
@ Compares the value of `var` to the value of `var2`.
- .macro compare_var_to_var var1, 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 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 >= 0 && \arg2 <= 0xFFFF)
- compare_var_to_value \arg1, \arg2
+ @ Any values between 0x4000 to 0x40FF and 0x8000 to 0x8014 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
- .error "Invalid arguments for 'compare'"
+ compare_var_to_value \var, \arg
.endif
.endm
@ Calls the native C function stored at `func`.
- .macro callnative 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
+ .macro gotonative func:req
.byte 0x24
.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.
- .macro special function
+ .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, function
+ .macro specialvar output:req, function:req
.byte 0x26
.2byte \output
.2byte SPECIAL_\function
@@ -276,31 +267,31 @@
.endm
@ Blocks script execution for time (frames? milliseconds?).
- .macro delay time
+ .macro delay time:req
.byte 0x28
.2byte \time
.endm
@ Sets a to 1.
- .macro setflag a
+ .macro setflag a:req
.byte 0x29
.2byte \a
.endm
@ Sets a to 0.
- .macro clearflag a
+ .macro clearflag a:req
.byte 0x2a
.2byte \a
.endm
@ Compares a to 1.
- .macro checkflag a
+ .macro checkflag a:req
.byte 0x2b
.2byte \a
.endm
@ In FireRed, this command is a nop.
- .macro initclock hour minute
+ .macro initclock hour:req minute:req
.byte 0x2c
.endm
@@ -309,13 +300,13 @@
.byte 0x2d
.endm
- @ Resets the values of variables 0x8000, 0x8001, and 0x8002.
+ @ Resets the values of variables VAR_0x8000, VAR_0x8001, and VAR_0x8002.
.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
+ .macro playse sound_number:req
.byte 0x2f
.2byte \sound_number
.endm
@@ -326,7 +317,7 @@
.endm
@ Plays the specified (fanfare_number) fanfare.
- .macro playfanfare fanfare_number
+ .macro playfanfare fanfare_number:req
.byte 0x31
.2byte \fanfare_number
.endm
@@ -337,14 +328,14 @@
.endm
@ Plays the specified (song_number) song. The byte is apparently supposed to be 0x00.
- .macro playbgm song_number, unknown
+ .macro playbgm song_number:req, unknown:req
.byte 0x33
.2byte \song_number
.byte \unknown
.endm
@ Plays the specified (song_number) song.
- .macro savebgm song_number
+ .macro savebgm song_number:req
.byte 0x34
.2byte \song_number
.endm
@@ -355,188 +346,188 @@
.endm
@ Crossfades the currently-playng song into the specified (song_number) song.
- .macro fadenewbgm song_number
+ .macro fadenewbgm song_number:req
.byte 0x36
.2byte \song_number
.endm
@ Fades out the currently-playing song.
- .macro fadeoutbgm speed
+ .macro fadeoutbgm speed:req
.byte 0x37
.byte \speed
.endm
@ Fades the currently-playing song back in.
- .macro fadeinbgm speed
+ .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, warp, X, Y
+ @ 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
+ .2byte \x
+ .2byte \y
.endm
@ Clone of warp that does not play a sound effect.
- .macro warpsilent map, warp, X, Y
+ .macro warpsilent map:req, warp:req, x:req, y:req
.byte 0x3a
map \map
.byte \warp
- .2byte \X
- .2byte \Y
+ .2byte \x
+ .2byte \y
.endm
@ Clone of warp that uses "a walking effect".
- .macro warpdoor map, warp, X, Y
+ .macro warpdoor map:req, warp:req, x:req, y:req
.byte 0x3b
map \map
.byte \warp
- .2byte \X
- .2byte \Y
+ .2byte \x
+ .2byte \y
.endm
@ Warps the player to another map using a hole animation.
- .macro warphole map
+ .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.[source]
- .macro warpteleport map, warp, X, Y
+ .macro warpteleport map:req, warp:req, x:req, y:req
.byte 0x3d
map \map
.byte \warp
- .2byte \X
- .2byte \Y
+ .2byte \x
+ .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 setwarp map, warp, X, Y
+ .macro setwarp map:req, warp:req, x:req, y:req
.byte 0x3e
map \map
.byte \warp
- .2byte \X
- .2byte \Y
+ .2byte \x
+ .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 setdynamicwarp map, warp, X, Y
+ .macro setdynamicwarp map:req, warp:req, x:req, y:req
.byte 0x3f
map \map
.byte \warp
- .2byte \X
- .2byte \Y
+ .2byte \x
+ .2byte \y
.endm
@ Clone of warp3, except that this writes data to different offsets...
- .macro setdivewarp map, warp, X, Y
+ .macro setdivewarp map:req, warp:req, x:req, y:req
.byte 0x40
map \map
.byte \warp
- .2byte \X
- .2byte \Y
+ .2byte \x
+ .2byte \x
.endm
@ Clone of warp3, except that this writes data to different offsets...
- .macro setholewarp map, warp, X, Y
+ .macro setholewarp map:req, warp:req, x:req, y:req
.byte 0x41
map \map
.byte \warp
- .2byte \X
- .2byte \Y
+ .2byte \x
+ .2byte \y
.endm
@ Retrieves the player's zero-indexed X- and Y-coordinates in the map, and stores them in the specified variables.
- .macro getplayerxy X, Y
+ .macro getplayerxy x:req, y:req
.byte 0x42
- .2byte \X
- .2byte \Y
+ .2byte \x
+ .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 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 variable 0x800D (LASTRESULT) will be set to 0x0001; otherwise, LASTRESULT is set to 0x0000.
- .macro additem index, quantity
+ @ 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, quantity
+ .macro removeitem index:req, quantity:req
.byte 0x45
.2byte \index
.2byte \quantity
.endm
- @ Checks if the player has enough space in their Bag to hold quantity more of item index. Sets variable 0x800D (LASTRESULT) to 0x0001 if there is room, or 0x0000 is there is no room.
- .macro checkitemspace index, quantity
+ @ 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 variable 0x800D (LASTRESULT) to 0x0001 if the player has enough of the item, or 0x0000 if they have fewer than quantity of the item.
- .macro checkitem index, quantity
+ @ 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 (index) item belongs in, and writes the value to variable 0x800D (LASTRESULT). This script is used to show the name of the proper Bag pocket when the player receives an item via callstd (simplified to giveitem in XSE).
- .macro checkitemtype index
+ @ 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 givepcitem index, quantity
+ .macro givepcitem 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, quantity
+ .macro checkpcitem index:req, quantity:req
.byte 0x4a
.2byte \index
.2byte \quantity
.endm
@ In FireRed, this command is a nop. (The argument is read, but not used for anything.)
- .macro adddecor decoration
+ .macro adddecor decoration:req
.byte 0x4b
.2byte \decoration
.endm
@ In FireRed, this command is a nop. (The argument is read, but not used for anything.)
- .macro removedecor decoration
+ .macro removedecor decoration:req
.byte 0x4c
.2byte \decoration
.endm
@ In FireRed, this command is a nop. (The argument is read, but not used for anything.)
- .macro hasdecor decoration
+ .macro hasdecor decoration:req
.byte 0x4d
.2byte \decoration
.endm
@ In FireRed, this command is a nop. (The argument is read, but not used for anything.)
- .macro checkdecor decoration
+ .macro checkdecor decoration:req
.byte 0x4e
.2byte \decoration
.endm
- @ Applies the movement data at movements to the specified (index) Person event. Also closes any standard message boxes that are still open.
- @ 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 applymovement index, movements, mapGroup, mapNum
+ @ 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, mapGroup, mapNum
.ifb \mapGroup
.byte 0x4f
.2byte \index
@@ -550,22 +541,23 @@
.endif
.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 waitmovement index, mapBank, mapNum
- .ifb \mapBank
+ @ 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, mapGroup, mapNum
+ .ifb \mapGroup
.byte 0x51
.2byte \index
.else
.byte 0x52
.2byte \index
- .byte \mapBank
+ .byte \mapGroup
.byte \mapNum
.endif
.endm
- @ Attempts to hide the specified (local_ID, a local ID) Person event on the specified 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.
- @ If no map is specified, then the current map is used
- .macro removeobject localId, mapGroup, mapNum
+ @ Attempts to hide the specified (localId) 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 localId:req, mapGroup, mapNum
.ifb \mapGroup
.byte 0x53
.2byte \localId
@@ -577,7 +569,7 @@
.endif
.endm
- .macro addobject localId, mapGroup, mapNum
+ .macro addobject localId:req, mapGroup, mapNum
.ifb \mapGroup
.byte 0x55
.2byte \localId
@@ -590,20 +582,20 @@
.endm
@ Sets the specified (index) Object's position on the current map.
- .macro setobjectxy index, x, y
+ .macro setobjectxy index:req, x:req, y:req
.byte 0x57
.2byte \index
.2byte \x
.2byte \y
.endm
- .macro showobject index, map
+ .macro showobject index:req, map:req
.byte 0x58
.2byte \index
map \map
.endm
- .macro hideobject index, map
+ .macro hideobject index:req, map:req
.byte 0x59
.2byte \index
map \map
@@ -614,58 +606,103 @@
.byte 0x5a
.endm
- .macro turnobject index, direction
+ .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, trainer, word, pointer1, pointer2, pointer3, pointer4
+ .macro trainerbattle type:req, trainer:req, word:req, pointer1:req, pointer2, pointer3, pointer4
.byte 0x5c
.byte \type
.2byte \trainer
.2byte \word
- .if \type == 0
+ .if \type == TRAINER_BATTLE_SINGLE
.4byte \pointer1 @ text
.4byte \pointer2 @ text
- .elseif \type == 1
+ .elseif \type == TRAINER_BATTLE_CONTINUE_SCRIPT_NO_MUSIC
.4byte \pointer1 @ text
.4byte \pointer2 @ text
.4byte \pointer3 @ event script
- .elseif \type == 2
+ .elseif \type == TRAINER_BATTLE_CONTINUE_SCRIPT
.4byte \pointer1 @ text
.4byte \pointer2 @ text
.4byte \pointer3 @ event script
- .elseif \type == 3
+ .elseif \type == TRAINER_BATTLE_SINGLE_NO_INTRO_TEXT
.4byte \pointer1 @ text
- .elseif \type == 4
+ .elseif \type == TRAINER_BATTLE_DOUBLE
.4byte \pointer1 @ text
.4byte \pointer2 @ text
.4byte \pointer3 @ text
- .elseif \type == 5
+ .elseif \type == TRAINER_BATTLE_REMATCH
.4byte \pointer1 @ text
.4byte \pointer2 @ text
- .elseif \type == 6
+ .elseif \type == TRAINER_BATTLE_CONTINUE_SCRIPT_DOUBLE
.4byte \pointer1 @ text
.4byte \pointer2 @ text
.4byte \pointer3 @ text
.4byte \pointer4 @ event script
- .elseif \type == 7
+ .elseif \type == TRAINER_BATTLE_REMATCH_DOUBLE
.4byte \pointer1 @ text
.4byte \pointer2 @ text
.4byte \pointer3 @ text
- .elseif \type == 8
+ .elseif \type == TRAINER_BATTLE_CONTINUE_SCRIPT_DOUBLE_NO_MUSIC
.4byte \pointer1 @ text
.4byte \pointer2 @ text
.4byte \pointer3 @ text
.4byte \pointer4 @ event script
- .elseif \type == 9
+ .elseif \type == TRAINER_BATTLE_TUTORIAL
.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
+
+ @
+ .macro trainerbattle_tutorial trainer:req, unk:req, intro_text:req, lose_text:req
+ trainerbattle TRAINER_BATTLE_TUTORIAL, \trainer, \unk, \intro_text, \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 battlebegin
@@ -681,36 +718,36 @@
.endm
@ Compares Flag (trainer + 0x500) to 1. (If the flag is set, then the trainer has been defeated by the player.)
- .macro checktrainerflag trainer
+ .macro checktrainerflag trainer:req
.byte 0x60
.2byte \trainer
.endm
@ Sets Flag (trainer + 0x500). (I didn't make a mistake. The command names actually are backwards.)
- .macro settrainerflag trainer
+ .macro settrainerflag trainer:req
.byte 0x61
.2byte \trainer
.endm
@ Clears Flag (trainer + 0x500). (I didn't make a mistake. The command names actually are backwards.)
- .macro cleartrainerflag trainer
+ .macro cleartrainerflag trainer:req
.byte 0x62
.2byte \trainer
.endm
- .macro setobjectxyperm index, x, y
+ .macro setobjectxyperm index:req, x:req, y:req
.byte 0x63
.2byte \index
.2byte \x
.2byte \y
.endm
- .macro moveobjectoffscreen index
+ .macro moveobjectoffscreen index:req
.byte 0x64
.2byte \index
.endm
- .macro setobjectmovementtype word, byte
+ .macro setobjectmovementtype word:req, byte:req
.byte 0x65
.2byte \word
.byte \byte
@@ -722,7 +759,7 @@
.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
+ .macro message text:req
.byte 0x67
.4byte \text
.endm
@@ -757,15 +794,15 @@
.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
+ @ 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 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
+ .macro multichoice x:req, y:req, list:req, b:req
.byte 0x6f
.byte \x
.byte \y
@@ -774,7 +811,7 @@
.endm
@ Displays a multichoice box from which the user can choose a selection, and blocks script execution until a selection is made. Lists of options are predefined and the one to be used is specified with list. The default argument determines the initial position of the cursor when the box is first opened; it is zero-indexed, and if it is too large, it is treated as 0x00. If b is set to a non-zero value, then the user will not be allowed to back out of the multichoice with the B button.
- .macro multichoicedefault x, y, list, default, b
+ .macro multichoicedefault x:req, y:req, list:req, default:req, b:req
.byte 0x70
.byte \x
.byte \y
@@ -784,20 +821,20 @@
.endm
@ Displays a multichoice box from which the user can choose a selection, and blocks script execution until a selection is made. Lists of options are predefined and the one to be used is specified with list. The per_row argument determines how many list items will be shown on a single row of the box.
- .macro multichoicegrid x, y, list, per_row, B
+ .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
+ .byte \b
.endm
.macro drawbox
.byte 0x72
.endm
- .macro erasebox byte1, byte2, byte3, byte4
+ .macro erasebox byte1:req, byte2:req, byte3:req, byte4:req
.byte 0x73
.byte \byte1
.byte \byte2
@@ -810,7 +847,7 @@
.endm
@ Displays a box containing the front sprite for the specified (species) Pokemon species.
- .macro drawmonpic species, x, y
+ .macro drawmonpic species:req, x:req, y:req
.byte 0x75
.2byte \species
.byte \x
@@ -823,132 +860,128 @@
.endm
@ Draws an image of the winner of the contest. In FireRed, this command is a nop. (The argument is discarded.)
- .macro drawcontestwinner a
+ .macro drawcontestwinner 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.
- .macro braillemessage text
+ .macro braillemessage text:req
.byte 0x78
.4byte \text
.endm
- @ RENAMED!
- @ Gives the player one of the specified (species) Pokmon at level level holding item. The unknown arguments should all be zeroes.
- .macro givemon species, level, item, unknown1, unknown2, unknown3
+ @ 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 \unknown1
- .4byte \unknown2
- .byte \unknown3
+ .4byte 0x0
+ .4byte 0x0
+ .byte 0
.endm
- .macro giveegg species
+ .macro giveegg species:req
.byte 0x7a
.2byte \species
.endm
- @ RENAMED!
- .macro setmonmove byte1, byte2, word
+ .macro setmonmove byte1:req, byte2:req, word:req
.byte 0x7b
.byte \byte1
.byte \byte2
.2byte \word
.endm
- @ Checks if at least one Pokémon 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 Pokémon that knows the move. If not, LASTRESULT is set to 0x0006. Variable 0x8004 is also set to this Pokémon's species.
- .macro checkpartymove index
+ @ 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 getspeciesname out, species
+ .macro getspeciesname out:req, species:req
.byte 0x7d
.byte \out
.2byte \species
.endm
- @ RENAMED!
@ Writes the name of the species of the first Pokémon in the player's party to the specified buffer.
- .macro getfirstpartymonname out
+ .macro getfirstpartymonname out:req
.byte 0x7e
.byte \out
.endm
- @ RENAMED!
@ 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 getpartymonname out, slot
+ .macro getpartymonname 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 getitemname out, item
+ .macro getitemname 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 getdecorname out, decoration
+ .macro getdecorname 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 getmovename out, move
+ .macro getmovename 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 getnumberstring out, input
+ .macro getnumberstring 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 data corruption.
- .macro getstdstring out, index
+ .macro getstdstring out:req, index:req
.byte 0x84
.byte \out
.2byte \index
.endm
@ Copies the string at offset to the specified buffer.
- .macro getstring out, offset
+ .macro getstring out:req, offset:req
.byte 0x85
.byte \out
.4byte \offset
.endm
@ Opens the Pokemart system, offering the specified products for sale.
- .macro pokemart products
+ .macro pokemart products:req
.byte 0x86
.4byte \products
.endm
- @ Apparent clone of pokemart.
- .macro pokemartdecor products
+ @ Opens the Pokemart system and treats the list of items as decorations.
+ .macro pokemartdecor products:req
.byte 0x87
.4byte \products
.endm
@ Apparent clone of pokemart.
- .macro pokemartbp products
+ .macro pokemartbp products:req
.byte 0x88
.4byte \products
.endm
@ Starts up the slot machine minigame.
- .macro playslotmachine word
+ .macro playslotmachine word:req
.byte 0x89
.2byte \word
.endm
@@ -978,35 +1011,35 @@
.byte 0x8e
.endm
- @ Stores a random integer between 0 and limit in variable 0x800D (LASTRESULT).
- .macro random limit
+ @ 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 givemoney value, check
+ .macro givemoney 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 takemoney value, check
+ .macro takemoney value:req, check:req
.byte 0x91
.4byte \value
.byte \check
.endm
- @ If check is 0x00, this command will check if the player has value or more money; script variable 0x800D (LASTRESULT) is set to 0x0001 if the player has enough money, or 0x0000 if the do not.
- .macro checkmoney value, check
+ @ 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, y, check
+ .macro showmoneybox x:req, y:req, check:req
.byte 0x93
.byte \x
.byte \y
@@ -1016,14 +1049,14 @@
@ Hides the secondary box spawned by showmoney.
@ The two arguments are unused.
@ They are retained here for backwards compatibility with Ruby/Sapphire.
- .macro hidemoneybox x, y
+ .macro hidemoneybox x:req, y:req
.byte 0x94
.byte \x
.byte \y
.endm
@ Updates the secondary box spawned by showmoney. Consumes but does not use arguments.
- .macro updatemoneybox x, y, check
+ .macro updatemoneybox x:req, y:req, check:req
.byte 0x95
.byte \x
.byte \y
@@ -1036,72 +1069,72 @@
.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.
- .macro fadescreen effect
+ .macro fadescreen effect:req
.byte 0x97
.byte \effect
.endm
@ Fades the screen to and from black and white. Mode 0x00 fades from black, mode 0x01 fades out to black, mode 0x2 fades in from white, and mode 0x3 fades out to white. Other modes may exist.
- .macro fadescreenspeed effect, speed
+ .macro fadescreenspeed effect:req, speed:req
.byte 0x98
.byte \effect
.byte \speed
.endm
- .macro setflashradius word
+ .macro setflashradius word:req
.byte 0x99
.2byte \word
.endm
- .macro animateflash byte
+ .macro animateflash byte:req
.byte 0x9a
.byte \byte
.endm
- .macro messageautoscroll pointer
+ .macro messageautoscroll pointer:req
.byte 0x9b
.4byte \pointer
.endm
@ Executes the specified field move animation.
- .macro dofieldeffect animation
+ .macro dofieldeffect animation:req
.byte 0x9c
.2byte \animation
.endm
@ Sets up the field effect argument argument with the value value.
- .macro setfieldeffectarg argument, param
+ .macro setfieldeffectarg argument:req, param:req
.byte 0x9d
.byte \argument
.2byte \param
.endm
@ Blocks script execution until all playing field move animations complete.
- .macro waitfieldeffect animation
+ .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 flightspot
+ .macro setrespawn heallocation:req
.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.
+ @ 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, effect
+ .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, y, metatile_number, tile_attrib
+ .macro setmetatile x:req, y:req, metatile_number:req, tile_attrib:req
.byte 0xa2
.2byte \x
.2byte \y
@@ -1115,7 +1148,7 @@
.endm
@ Queues a weather change to type weather.
- .macro setweather type
+ .macro setweather type:req
.byte 0xa4
.2byte \type
.endm
@@ -1126,30 +1159,30 @@
.endm
@ This command manages cases in which maps have tiles that change state when stepped on (specifically, cracked/breakable floors).
- .macro setstepcallback subroutine
+ .macro setstepcallback subroutine:req
.byte 0xa6
.byte \subroutine
.endm
- .macro setmaplayoutindex index
+ .macro setmaplayoutindex index:req
.byte 0xa7
.2byte \index
.endm
- .macro setobjectpriority index, map, priority
+ .macro setobjectpriority index:req, map:req, priority:req
.byte 0xa8
.2byte \index
map \map
.byte \priority
.endm
- .macro resetobjectpriority index, map
+ .macro resetobjectpriority index:req, map:req
.byte 0xa9
.2byte \index
map \map
.endm
- .macro createvobject sprite, byte2, x, y, elevation, direction
+ .macro createvobject sprite:req, byte2:req, x:req, y:req, elevation:req, direction:req
.byte 0xaa
.byte \sprite
.byte \byte2
@@ -1159,21 +1192,21 @@
.byte \direction
.endm
- .macro turnvobject index, direction
+ .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, y
+ .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, y
+ .macro closedoor x:req, y:req
.byte 0xad
.2byte \x
.2byte \y
@@ -1185,14 +1218,14 @@
.endm
@ Sets the door tile at (x, y) to be open without an animation.
- .macro setdooropen x, y
+ .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 setdoorclosed2 x, y
+ .macro setdoorclosed2 x:req, y:req
.byte 0xb0
.2byte \x
.2byte \y
@@ -1208,23 +1241,23 @@
.byte 0xb2
.endm
- .macro checkcoins out
+ .macro checkcoins out:req
.byte 0xb3
.2byte \out
.endm
- .macro givecoins count
+ .macro givecoins count:req
.byte 0xb4
.2byte \count
.endm
- .macro takecoins word
+ .macro takecoins word:req
.byte 0xb5
.2byte \word
.endm
@ Prepares to start a wild battle against a species at Level level holding item. Running this command will not affect normal wild battles. You start the prepared battle with dowildbattle.
- .macro setwildbattle species, level, item
+ .macro setwildbattle species:req, level:req, item:req
.byte 0xb6
.2byte \species
.byte \level
@@ -1236,78 +1269,78 @@
.byte 0xb7
.endm
- .macro setvaddress long
+ .macro setvaddress long:req
.byte 0xb8
.4byte \long
.endm
- .macro vgoto pointer
+ .macro vgoto pointer:req
.byte 0xb9
.4byte \pointer
.endm
- .macro vcall pointer
+ .macro vcall pointer:req
.byte 0xba
.4byte \pointer
.endm
- .macro vgoto_if byte, pointer
+ .macro vgoto_if byte:req, pointer:req
.byte 0xbb
.byte \byte
.4byte \pointer
.endm
- .macro vcall_if byte, pointer
+ .macro vcall_if byte:req, pointer:req
.byte 0xbc
.byte \byte
.4byte \pointer
.endm
- .macro vmessage pointer
+ .macro vmessage pointer:req
.byte 0xbd
.4byte \pointer
.endm
- .macro vloadptr pointer
+ .macro vloadptr pointer:req
.byte 0xbe
.4byte \pointer
.endm
- .macro vbufferstring byte, pointer
+ .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, y
+ .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, y
+ .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, y
+ .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
+ .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, warp, x, y
+ .macro setescapewarp map:req, warp:req, x:req, y:req
.byte 0xc4
map \map
.byte \warp
@@ -1321,20 +1354,20 @@
.endm
@ Writes the name of the specified (box) PC box to the specified buffer.
- .macro bufferboxname out, box
+ .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.
- .macro textcolor color
+ .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.
- .macro loadhelp pointer
+ .macro loadhelp pointer:req
.byte 0xc8
.4byte \pointer
.endm
@@ -1355,20 +1388,20 @@
.endm
@ Compares the value of a hidden variable to a dword.
- .macro comparehiddenvar a, value
+ .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
+ .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, 0x0001 is written to script variable 0x800D (LASTRESULT). If the Pokemon is obedient (or if the specified slot is empty or invalid), 0x0000 is written.
- .macro checkmonobedience slot
+ @ 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
@@ -1379,13 +1412,13 @@
.endm
@ Sets worldmapflag to 1. This allows the player to Fly to the corresponding map, if that map has a flightspot.
- .macro setworldmapflag worldmapflag
+ .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, warp, x, y
+ .macro warpteleport2 map:req, warp:req, x:req, y:req
.byte 0xd1
map \map
.byte \warp
@@ -1394,18 +1427,18 @@
.endm
@ Changes the location where the player caught the Pokemon in the specified slot of their party.
- .macro setmonmetlocation slot, location
+ .macro setmonmetlocation slot:req, location:req
.byte 0xd2
.2byte \slot
.byte \location
.endm
- .macro getbraillestringwidth pointer
+ .macro getbraillestringwidth pointer:req
.byte 0xd3
.4byte \pointer
.endm
- .macro bufferitemnameplural out, item, quantity
+ .macro bufferitemnameplural out:req, item:req, quantity:req
.byte 0xd4
.byte \out
.2byte \item
@@ -1415,42 +1448,172 @@
@ Supplementary
- .macro goto_if_eq dest
- goto_if eq, \dest
+ .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 switch var
- copyvar 0x8000, \var
+ .macro goto_if_gt dest:req @ GREATER THAN
+ goto_if 2, \dest
.endm
- .macro case condition, dest
- compare_var_to_value 0x8000, \condition
+ .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_set flag:req, dest:req
+ checkflag \flag
+ vgoto_if TRUE, \dest
+ .endm
+
+ .macro vgoto_if_unset flag:req, dest:req
+ checkflag \flag
+ vgoto_if FALSE, \dest
+ .endm
+
+ .macro goto_if_defeated trainer:req, dest:req
+ checktrainerflag \trainer
+ goto_if TRUE, \dest
+ .endm
+
+ .macro goto_if_undefeated 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_undefeated 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
- .macro msgbox text, type=4
+ .macro msgbox text:req, type=MSGBOX_DEFAULT
loadword 0, \text
callstd \type
.endm
- @ Message box types
+ @ Callstd ids
+ STD_OBTAIN_ITEM = 0
+ STD_FIND_ITEM = 1
+
+ MSGBOX_NPC = 2
+ MSGBOX_SIGN = 3
+ MSGBOX_DEFAULT = 4
MSGBOX_YESNO = 5
+ MSGBOX_AUTOCLOSE = 6
+
+ STD_OBTAIN_DECOR = 7
+ STD_PUT_ITEM_AWAY = 8
+ STD_RECEIVED_ITEM = 9
YES = 1
NO = 0
- .macro giveitem item, amount=1, function=0
- setorcopyvar 0x8000, \item
- setorcopyvar 0x8001, \amount
- callstd \function
+ .macro giveitem item:req, amount=1
+ setorcopyvar VAR_0x8000, \item
+ setorcopyvar VAR_0x8001, \amount
+ callstd STD_OBTAIN_ITEM
.endm
- .macro giveitemfanfaremsg msg, item, amount=1, fanfare=MUS_FANFA1
+ .macro finditem item:req, amount=1
+ setorcopyvar VAR_0x8000, \item
+ setorcopyvar VAR_0x8001, \amount
+ callstd STD_FIND_ITEM
+ .endm
+
+ .macro putitemaway item:req, amount=1
+ setorcopyvar VAR_0x8000, \item
+ setorcopyvar VAR_0x8001, \amount
+ callstd STD_PUT_ITEM_AWAY
+ .endm
+
+ .macro giveitem_msg msg:req, item:req, amount=1, fanfare=MUS_FANFA1
+ additem \item, \amount
+ msgreceiveditem \msg, \item, \amount, \fanfare
+ .endm
+
+ .macro msgreceiveditem msg:req, item:req, amount=1, fanfare=MUS_FANFA1
loadword 0, \msg
- setorcopyvar 0x8000, \item
- setorcopyvar 0x8001, \amount
- setorcopyvar 0x8002, \fanfare
- callstd 9
+ setorcopyvar VAR_0x8000, \item
+ setorcopyvar VAR_0x8001, \amount
+ setorcopyvar VAR_0x8002, \fanfare
+ callstd STD_RECEIVED_ITEM
.endm
.macro famechecker person:req, index:req, function=SetFlavorTextFlagFromSpecialVars
@@ -1461,5 +1624,12 @@
.macro set_gym_trainers gym:req
setvar VAR_0x8008, \gym
- call EventScript_1A6B18
+ call EventScript_SetGymTrainers
+ .endm
+
+ @ Appears frequently at start of NPC scripts. Should be used once named/understood
+ .macro unk_questlog
+ special sub_8110AB4
+ compare VAR_RESULT, 2
+ goto_if_eq EventScript_1A7AE0
.endm
diff --git a/asm/macros/movement.inc b/asm/macros/movement.inc
index 8ad5a313e..c4ca78010 100644
--- a/asm/macros/movement.inc
+++ b/asm/macros/movement.inc
@@ -6,112 +6,112 @@
.endm
enum_start 0
- create_movement step_00
- create_movement step_01
- create_movement step_02
- create_movement step_03
- create_movement slow_step_down
- create_movement slow_step_up
- create_movement slow_step_left
- create_movement slow_step_right
- create_movement step_down
- create_movement step_up
- create_movement step_left
- create_movement step_right
- create_movement fast_step_down
- create_movement fast_step_up
- create_movement fast_step_left
- create_movement fast_step_right
- create_movement step_10
- create_movement step_11
- create_movement step_12
- create_movement step_13
- create_movement step_14
- create_movement step_15
- create_movement step_16
- create_movement step_17
- create_movement step_18
- create_movement step_19
- create_movement step_1a
- create_movement step_1b
- create_movement step_1c
- create_movement step_1d
- create_movement step_1e
- create_movement step_1f
- create_movement step_20
- create_movement step_21
- create_movement step_22
- create_movement step_23
- create_movement step_24
- create_movement step_25
- create_movement step_26
- create_movement step_27
- create_movement step_28
- create_movement step_29
- create_movement step_2a
- create_movement step_2b
- create_movement step_2c
- create_movement step_2d
- create_movement step_2e
- create_movement step_2f
- create_movement step_30
- create_movement step_31
- create_movement step_32
- create_movement step_33
- create_movement step_34
- create_movement step_35
- create_movement step_36
- create_movement step_37
- create_movement step_38
- create_movement step_39
- create_movement step_3a
- create_movement step_3b
- create_movement step_3c
- create_movement step_3d
- create_movement step_3e
- create_movement step_3f
- create_movement step_40
- create_movement step_41
- create_movement step_42
- create_movement step_43
- create_movement step_44
+ create_movement face_down
+ create_movement face_up
+ create_movement face_left
+ create_movement face_right
+ create_movement face_down_fast
+ create_movement face_up_fast
+ create_movement face_left_fast
+ create_movement face_right_fast
+ create_movement walk_slowest_down
+ create_movement walk_slowest_up
+ create_movement walk_slowest_left
+ create_movement walk_slowest_right
+ create_movement walk_slow_down
+ create_movement walk_slow_up
+ create_movement walk_slow_left
+ create_movement walk_slow_right
+ create_movement walk_down
+ create_movement walk_up
+ create_movement walk_left
+ create_movement walk_right
+ create_movement jump_2_down
+ create_movement jump_2_up
+ create_movement jump_2_left
+ create_movement jump_2_right
+ create_movement delay_1
+ create_movement delay_2
+ create_movement delay_4
+ create_movement delay_8
+ create_movement delay_16
+ create_movement walk_fast_down
+ create_movement walk_fast_up
+ create_movement walk_fast_left
+ create_movement walk_fast_right
+ create_movement walk_in_place_slow_down
+ create_movement walk_in_place_slow_up
+ create_movement walk_in_place_slow_left
+ create_movement walk_in_place_slow_right
+ create_movement walk_in_place_down
+ create_movement walk_in_place_up
+ create_movement walk_in_place_left
+ create_movement walk_in_place_right
+ create_movement walk_in_place_fast_down
+ create_movement walk_in_place_fast_up
+ create_movement walk_in_place_fast_left
+ create_movement walk_in_place_fast_right
+ create_movement walk_in_place_fastest_down
+ create_movement walk_in_place_fastest_up
+ create_movement walk_in_place_fastest_left
+ create_movement walk_in_place_fastest_right
+ create_movement face_down_slow
+ create_movement face_up_slow
+ create_movement face_left_slow
+ create_movement face_right_slow
+ create_movement walk_fastest_down
+ create_movement walk_fastest_up
+ create_movement walk_fastest_left
+ create_movement walk_fastest_right
+ create_movement slide_down
+ create_movement slide_up
+ create_movement slide_left
+ create_movement slide_right
+ create_movement player_run_down
+ create_movement player_run_up
+ create_movement player_run_left
+ create_movement player_run_right
+ create_movement player_run_down_slow
+ create_movement player_run_up_slow
+ create_movement player_run_left_slow
+ create_movement player_run_right_slow
create_movement step_45
- create_movement step_46
- create_movement step_47
- create_movement step_48
- create_movement step_49
- create_movement step_4a
- create_movement step_4b
- create_movement step_4c
- create_movement step_4d
- create_movement step_4e
- create_movement step_4f
- create_movement step_50
- create_movement step_51
- create_movement step_52
- create_movement step_53
- create_movement step_54
- create_movement step_55
- create_movement step_56
- create_movement step_57
- create_movement step_58
- create_movement step_59
- create_movement step_5a
- create_movement step_5b
- create_movement step_5c
- create_movement step_5d
- create_movement step_5e
- create_movement step_5f
- create_movement step_60
- create_movement step_61
- create_movement step_62
- create_movement step_63
- create_movement step_64
- create_movement step_65
- create_movement step_66
+ create_movement jump_down_run
+ create_movement jump_up_run
+ create_movement jump_left_run
+ create_movement jump_right_run
+ create_movement face_player
+ create_movement face_away_player
+ create_movement lock_facing_direction
+ create_movement unlock_facing_direction
+ create_movement jump_down
+ create_movement jump_up
+ create_movement jump_left
+ create_movement jump_right
+ create_movement jump_in_place_down
+ create_movement jump_in_place_up
+ create_movement jump_in_place_left
+ create_movement jump_in_place_right
+ create_movement jump_in_place_down_up
+ create_movement jump_in_place_up_down
+ create_movement jump_in_place_left_right
+ create_movement jump_in_place_right_left
+ create_movement face_original_direction
+ create_movement nurse_joy_bow
+ create_movement enable_jump_landing_ground_effect
+ create_movement disable_jump_landing_ground_effect
+ create_movement disable_anim
+ create_movement restore_anim
+ create_movement set_invisible
+ create_movement set_visible
+ create_movement emote_exclamation_mark
+ create_movement emote_question_mark
+ create_movement emote_x
+ create_movement emote_double_exclamation_mark
+ create_movement emote_smile
create_movement step_67
- create_movement step_68
- create_movement step_69
+ create_movement rock_smash_break
+ create_movement cut_tree
enum_start 0x91
create_movement step_91