diff options
Diffstat (limited to 'asm')
-rw-r--r-- | asm/macros/event.inc | 400 |
1 files changed, 206 insertions, 194 deletions
diff --git a/asm/macros/event.inc b/asm/macros/event.inc index 9fddd9194..f7b6930fb 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 mystery event status + .macro setmestatus value .byte 0x0e .byte \value .endm - @ Sets the specified script bank to value. - .macro loadptr destination, value + @ Sets the specified script bank to immediate value. + .macro loadword destination, value .byte 0x0f .byte \destination .4byte \value .endm - @ Sets the specified script bank to value. - .macro setbufferbyte destination, value + @ Sets the specified script bank to immediate 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,71 +171,83 @@ .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_imm 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_imm 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_imm var, value .byte 0x21 .2byte \var .2byte \value .endm @ Compares the value of `var` to the value of `var2`. - .macro comparevars var1, 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 >= 0 && \arg2 <= 0xFFFF) + compare_var_to_imm \arg1, \arg2 + .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. @@ -245,7 +257,7 @@ .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 @@ -281,33 +293,35 @@ .endm @ In FireRed, this command is a nop. - .macro compareflags + .macro initclock hour minute .byte 0x2c + .byte \hour + .byte \minute .endm @ In FireRed, this command is a nop. - .macro checkdailyflags + .macro dodailyevents .byte 0x2d .endm @ Resets the values of variables 0x8000, 0x8001, and 0x8002. Related to RTC in RSE? - .macro resetvars + .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 + .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 + .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 + .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 @@ -372,7 +386,7 @@ .endm @ Clone of warp that uses "a walking effect". - .macro warpwalk map, warp, X, Y + .macro warpdoor map, warp, X, Y .byte 0x3b map \map .byte \warp @@ -396,7 +410,7 @@ .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 + .macro setwarp map, warp, X, Y .byte 0x3e map \map .byte \warp @@ -405,7 +419,7 @@ .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 + .macro setdynamicwarp map, warp, X, Y .byte 0x3f map \map .byte \warp @@ -414,7 +428,7 @@ .endm @ Clone of warp3, except that this writes data to different offsets... - .macro warp4 map, warp, X, Y + .macro setdivewarp map, warp, X, Y .byte 0x40 map \map .byte \warp @@ -423,7 +437,7 @@ .endm @ Clone of warp3, except that this writes data to different offsets... - .macro warp5 map, warp, X, Y + .macro setholewarp map, warp, X, Y .byte 0x41 map \map .byte \warp @@ -504,7 +518,7 @@ .endm @ In FireRed, this command is a nop. (The argument is read, but not used for anything.) - .macro testdecor a + .macro hasdecor a .byte 0x4d .2byte \a .endm @@ -516,148 +530,146 @@ .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 + .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) 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 - .byte 0x57 - .2byte \word1 - .2byte \word2 - .2byte \word3 - .endm - - .macro spritevisible word, byte1, byte2 - .byte 0x58 - .2byte \word - .byte \byte1 - .byte \byte2 - .endm - - .macro spriteinvisible word, byte1, byte2 - .byte 0x59 - .2byte \word - .byte \byte1 - .byte \byte2 + .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) 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 + .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 + + .macro setobjectxy word1, word2, word3 + .byte 0x57 + .2byte \word1 + .2byte \word2 + .2byte \word3 + .endm + + .macro showobject word, byte1, byte2 + .byte 0x58 + .2byte \word + .byte \byte1 + .byte \byte2 + .endm + + .macro hideobject word, byte1, byte2 + .byte 0x59 + .2byte \word + .byte \byte1 + .byte \byte2 .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. .macro faceplayer - .byte 0x5a + .byte 0x5a .endm - .macro spriteface word, byte - .byte 0x5b - .2byte \word - .byte \byte + .macro turnobject word, byte + .byte 0x5b + .2byte \word + .byte \byte .endm @ If the Trainer flag for Trainer index is not set, this command does absolutely nothing. .macro trainerbattle type, trainer, word, pointer1, pointer2, pointer3, pointer4 - .byte 0x5c - .byte \type - .2byte \trainer - .2byte \word - .if \type == 0 - .4byte \pointer1 @ text - .4byte \pointer2 @ text - .elseif \type == 1 - .4byte \pointer1 @ text - .4byte \pointer2 @ text - .4byte \pointer3 @ event script - .elseif \type == 2 - .4byte \pointer1 @ text - .4byte \pointer2 @ text - .4byte \pointer3 @ event script - .elseif \type == 3 - .4byte \pointer1 @ text - .elseif \type == 4 - .4byte \pointer1 @ text - .4byte \pointer2 @ text - .4byte \pointer3 @ text - .elseif \type == 5 - .4byte \pointer1 @ text - .4byte \pointer2 @ text - .elseif \type == 6 - .4byte \pointer1 @ text - .4byte \pointer2 @ text - .4byte \pointer3 @ text - .4byte \pointer4 @ event script - .elseif \type == 7 - .4byte \pointer1 @ text - .4byte \pointer2 @ text - .4byte \pointer3 @ text - .elseif \type == 8 - .4byte \pointer1 @ text - .4byte \pointer2 @ text - .4byte \pointer3 @ text - .4byte \pointer4 @ event script - .endif + .byte 0x5c + .byte \type + .2byte \trainer + .2byte \word + .if \type == 0 + .4byte \pointer1 @ text + .4byte \pointer2 @ text + .elseif \type == 1 + .4byte \pointer1 @ text + .4byte \pointer2 @ text + .4byte \pointer3 @ event script + .elseif \type == 2 + .4byte \pointer1 @ text + .4byte \pointer2 @ text + .4byte \pointer3 @ event script + .elseif \type == 3 + .4byte \pointer1 @ text + .elseif \type == 4 + .4byte \pointer1 @ text + .4byte \pointer2 @ text + .4byte \pointer3 @ text + .elseif \type == 5 + .4byte \pointer1 @ text + .4byte \pointer2 @ text + .elseif \type == 6 + .4byte \pointer1 @ text + .4byte \pointer2 @ text + .4byte \pointer3 @ text + .4byte \pointer4 @ event script + .elseif \type == 7 + .4byte \pointer1 @ text + .4byte \pointer2 @ text + .4byte \pointer3 @ text + .elseif \type == 8 + .4byte \pointer1 @ text + .4byte \pointer2 @ text + .4byte \pointer3 @ text + .4byte \pointer4 @ event script + .endif .endm @ Starts a trainer battle using the battle information stored in RAM (usually by trainerbattle, which actually calls this command behind-the-scenes), and blocks script execution until the battle finishes. - .macro reptrainerbattle + .macro battlebegin .byte 0x5d .endm - .macro endtrainerbattle + .macro ontrainerbattleend .byte 0x5e .endm - .macro endtrainerbattle2 + .macro ontrainerbattleendgoto .byte 0x5f .endm @@ -668,37 +680,37 @@ .endm @ Sets Flag (trainer + 0x500). (I didn't make a mistake. The command names actually are backwards.) - .macro cleartrainerflag trainer + .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 + .macro cleartrainerflag trainer .byte 0x62 .2byte \trainer .endm - .macro movespriteperm word1, word2, word3 + .macro setobjectxyperm word1, word2, word3 .byte 0x63 .2byte \word1 .2byte \word2 .2byte \word3 .endm - .macro moveoffscreen word + .macro moveobjectoffscreen word .byte 0x64 .2byte \word .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 @@ -709,7 +721,7 @@ .endm @ Holds the current message box open until the player presses a key. The message box is then closed. - .macro closebutton + .macro closemessage .byte 0x68 .endm @@ -755,7 +767,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 multichoicedef X, Y, list, default, B + .macro multichoicedefault X, Y, list, default, B .byte 0x70 .byte \X .byte \Y @@ -765,7 +777,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 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 @@ -774,7 +786,7 @@ .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 @@ -799,7 +811,7 @@ .endm @ Displays a box containing the front sprite for the specified (species) Pokmon species. - .macro showpokepic species, X, Y + .macro drawpokepic species, X, Y .byte 0x75 .2byte \species .byte \X @@ -807,12 +819,12 @@ .endm @ Hides all boxes displayed with showpokepic. - .macro hidepokepic + .macro erasepokepic .byte 0x76 .endm @ In FireRed, this command is a nop. (The argument is discarded.) - .macro showcontestwinner a + .macro drawcontestwinner a .byte 0x77 .byte \a .endm @@ -824,7 +836,7 @@ .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 + .macro givepoke species, level, item, unknown1, unknown2, unknown3 .byte 0x79 .2byte \species .byte \level @@ -847,7 +859,7 @@ .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 + .macro checkpokemove index .byte 0x7c .2byte \index .endm @@ -1475,8 +1487,8 @@ @ Supplementary - .macro jumpeq dest - jumpif 1, \dest + .macro goto_if_eq dest + goto_if 1, \dest .endm .macro switch var @@ -1484,12 +1496,12 @@ .endm .macro case condition, dest - compare 0x8000, \condition - jumpeq \dest + compare_var_to_imm 0x8000, \condition + goto_if_eq \dest .endm .macro msgbox text, type=4 - loadptr 0, \text + loadword 0, \text callstd \type .endm |