Script Format
Jump to navigation
Jump to search
Scripts are parsed bytewise.
A note about event flags
Event flags are calculated from an u16 value like this:
u16 EventFlag; Flag = (EventFlag & 0xFFF) >> 3; Value = 1 << (EventFlag & 7); IsSet = EventFlag & 0x8000
Commands
Opcode | Function | Length | Arguments | Comments | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
00 | Call | 4 | This command has no stack for return addresses. Nested calls simply overwrite any previous return address, so return is only possible to the most recent call site.
If a simple jump is desired, use command 06 for an async jump, or ASM BRA or JMP for an instantaneous jump. | ||||||||||||||||
01 | ReturnFrom00 | 1 | If not inside 00-Call, this command is ignored. | ||||||||||||||||
02 | LoopSetup( u16 Count ) | 3 | |||||||||||||||||
03 | LoopDoAsync() | 1 | |||||||||||||||||
04 | LoopDo() | 1 | |||||||||||||||||
05 | WaitOnEventFlag( u16 Flag ) | 3 | |||||||||||||||||
06 | JumpAndSetOrigin | 4 | |||||||||||||||||
07 | EventFlagModify | 3 | |||||||||||||||||
08 | EventFlagCheckJump | 5 | |||||||||||||||||
09 | EventFlagCheckMultiple | 3+2*x | |||||||||||||||||
0A | CheckMapID | 5 | |||||||||||||||||
0B | CheckDeathwarpMapID | 5 | |||||||||||||||||
0C | TriggerOnAreaAbsolute | 8 | |||||||||||||||||
0D | TriggerOnAreaRelative | 8 | |||||||||||||||||
0E | TriggerOnAreaAbsolutePixel | 12 | |||||||||||||||||
0F | TriggerOnBlockAbsolute | 6 | |||||||||||||||||
10 | TriggerOnBlockRelative | 6 | |||||||||||||||||
11 | TriggerObjectOnAreaAbsolute | 9 | First parameter is object index, which is multiplied by 40 and added to 1000 to get the object handle, for which the trigger is checked.
Remaining parameters are same as command 0C. | ||||||||||||||||
12 | TriggerObjectOnAreaRelative | 9 | Broken command.
Supposed to be 0D-counterpart of 11: it should compare the position of the object that is given as first parameter to the position of the object that executes the command, but it uses for both purposes only the object that is given as parameter, which makes it useless. | ||||||||||||||||
13 | SpriteSetPosition | 4 | |||||||||||||||||
14 | PlayerPort | 9 | |||||||||||||||||
15 | PlayerPortByEnemy | 1 | Used by Guardner to port Ark out of towers. Uses byte #15 of the extended sprite definition, see Enemy Induced Warps. | ||||||||||||||||
16 | SetBonepinWarp( u16, u8, u16, u16 ) | 8 | The bonepin warp location is stored in memory at address 7E0608 (8 bytes, right after the deathwarp location) | ||||||||||||||||
17 | SeagullTransport( u8 to, u16 src_x, u16 src_y ) | 6 | Includes automatic port to map 5, flight scene and port to the destination map, see Seagull Transport. | ||||||||||||||||
18 | RideShip( u8 route, u8 direction, u16 src_x, u16 src_y ) | 7 | Includes automatic port to map 2, ship scene and port to destination map, see Automatic Ship Routes | ||||||||||||||||
19 | RespawnSetLocation( u16 MapID, u8, u16, u16, u16, u8, u16, u16 ) | 15 | Sets the Death- and Bonepin warp location (7E0600 and 7E0608 respectively). | ||||||||||||||||
1A | DialogSwitchChoice( u8 layout, u16 choices_ptr ) | 4 | choices_ptr refers to a table with jump addresses. The text for the choices needs to be created beforehand by a normal text command.
Known layouts are:
| ||||||||||||||||
1B | PrintRelative( u16 Address ) | 3 | |||||||||||||||||
1C | PrintAbsolute( u24 Address ) | 4 | |||||||||||||||||
1D | u16 | 3 | |||||||||||||||||
1E | u8, u16 | 4 | calls 0x1D | ||||||||||||||||
1F | MessageWait | 1 | This waits for a button input for the message to continue/close | ||||||||||||||||
20 | MessageAuto | 1 | This automatically continues/closes the message | ||||||||||||||||
21 | TriggerSet | 3 | When value is 0 it is deleted | ||||||||||||||||
22 | 2 or 3 | ||||||||||||||||||
23 | 3 | ||||||||||||||||||
24 | 4 | ||||||||||||||||||
25 | Rand | 1 | |||||||||||||||||
26 | RandomMoveInArea | 5 | |||||||||||||||||
27 | u8, u8 | 3 | |||||||||||||||||
28 | 2 | Set 0x7F2018 to value | |||||||||||||||||
29 | PadButtonsEnable | 3 | |||||||||||||||||
2A | PadButtonsDisable | 3 | |||||||||||||||||
2B | PadCheckAllButtonsPressed2 | 5 | |||||||||||||||||
2C | PadCheckNoButtonPressed2 | 5 | |||||||||||||||||
2D | PadCheckButtonPressed | 8 | |||||||||||||||||
2E | PadCheckAnyButtonPressed | 5 | |||||||||||||||||
2F | PadCheckNoButtonPressed | 5 | |||||||||||||||||
30 | MusicPlay | 2 | |||||||||||||||||
31 | MusicPlayFadeOver | 2 | |||||||||||||||||
32 | MusicPlay2 | 2 | This saves the last track played via this command.
When calling it with the value set to 0xFF it plays the last played track again. | ||||||||||||||||
33 | 1 | ||||||||||||||||||
34 | APUWriteByte_F5( u8 Byte ) | 2 | Writes one byte to 0x2140 (APUI00) followed by a write with 0xF5 | ||||||||||||||||
35 | APUWriteByte_F6( u8 Byte ) | 2 | Writes one byte to 0x2140 (APUI00) followed by a write with 0xF6 | ||||||||||||||||
36 | SoundEffectPlayOnce | 2 | |||||||||||||||||
37 | SoundEffectPlay | 2 | |||||||||||||||||
38 | SoundEffect? | 3 | |||||||||||||||||
39 | SpriteGotoPositionX | 4 | This command expects to be followed by "0x8E, 0x3B, asm(BRA -11)" because once it reaches the position it is hardcoded to jump 6 bytes ahead. | ||||||||||||||||
3A | SpriteGotoPositionY | 4 | This command expects to be followed by "0x8E, 0x3B, asm(BRA -11)" because once it reaches the position it is hardcoded to jump 6 bytes ahead. | ||||||||||||||||
3B | ObjectSetSolid | 1 | |||||||||||||||||
3C | 1 | ||||||||||||||||||
3D | 4 | ||||||||||||||||||
3E | 4 | ||||||||||||||||||
3F | TriggerOnTouch( u8 MovementMask, u8 X, u8 Y ) | 4 | |||||||||||||||||
40 | 4 | ||||||||||||||||||
41 | |||||||||||||||||||
42 | 7 | ||||||||||||||||||
43 | 5 | ||||||||||||||||||
44 | 5 | ||||||||||||||||||
45 | |||||||||||||||||||
46 | MapCopyRect( u16 SizeX (Blocks), u16 SizeY (Pixels), u16 SrcX(Blocks), u16 SrcY(Blocks), u16 DstX(Blocks), u16 DstY(Blocks), u8 Unknown ) | 8 | |||||||||||||||||
47 | ObjectDeleteIfEventFlags | 1+2*x | |||||||||||||||||
48 | ObjectDeleteIfEventFlag | 3 | |||||||||||||||||
49 | ObjectDeleteIfMapID | 3 | |||||||||||||||||
4A | 6 | ||||||||||||||||||
4B | u8, u16, (u16) | 4 or 6 | |||||||||||||||||
4C | u8, u16, (u16) | 4 or 6 | |||||||||||||||||
4D | 2 or 4 | ||||||||||||||||||
4E | u16, u16 | 5 | |||||||||||||||||
4F | u16, u16 | 5 | |||||||||||||||||
50 | u16, u8 | 4 | |||||||||||||||||
51 | |||||||||||||||||||
52 | |||||||||||||||||||
53 | |||||||||||||||||||
54 | ItemAdd | 4 | |||||||||||||||||
55 | ItemDel | 2 | |||||||||||||||||
56 | |||||||||||||||||||
57 | |||||||||||||||||||
58 | JumpIf0648( u8 Value, u16 JumpAddress ) | 2 or 4 | Jump if [0648] == Value | ||||||||||||||||
59 | |||||||||||||||||||
5A | |||||||||||||||||||
5B | |||||||||||||||||||
5C | MoneyAdd | 4 | |||||||||||||||||
5D | MoneyDel | 4 | |||||||||||||||||
5E | 7 | ||||||||||||||||||
5F | SwitchOnDirection( u16 DownJump, u16 UpJump, u16 LeftJump, u16 RightJump ) | 9 | |||||||||||||||||
60 | ItemAddPlayMusic( u8 ItemID, u16 Delay, u8 MusicID ) | 5 | |||||||||||||||||
61 | |||||||||||||||||||
62 | |||||||||||||||||||
63 | 3 | ||||||||||||||||||
64 | |||||||||||||||||||
65 | HandlerRegisterOnDamage( u16 HandlerAddress, u24 ReturnAddress ) | 6 | |||||||||||||||||
66 | ReturnFromDamageHandler | 1 | |||||||||||||||||
67 | 1 | ||||||||||||||||||
68 | |||||||||||||||||||
69 | 1 | ||||||||||||||||||
6A | u8, u8 | 3 | |||||||||||||||||
6B | PrintRelative2 | 3 | |||||||||||||||||
6C | PrintAbsolute2 | 4 | |||||||||||||||||
6D | |||||||||||||||||||
6E | SceneUpdate | 1 | |||||||||||||||||
6F | 1 | ||||||||||||||||||
70 | u16, u16 | 5 | |||||||||||||||||
71 | |||||||||||||||||||
72 | u16, u8 | 4 | |||||||||||||||||
73 | 5 | Wait for unknown condition and then jump | |||||||||||||||||
74 | u8 a, u16 b | 4 | $7F2024,x = (u16)a; $7F2022,x = b; | ||||||||||||||||
75 | u16 a, u16 b | 5 | $7F2028,x = a; $7F2026,x = b; | ||||||||||||||||
76 | SystemRegisterWrite | 3 | |||||||||||||||||
77 | |||||||||||||||||||
78 | BackgroundUpdateFade | 2 | |||||||||||||||||
79 | Unused command | ||||||||||||||||||
7A | Unused command | ||||||||||||||||||
7B | Unused command | ||||||||||||||||||
7C | Unknown Command, Only implemented in JP version, FFFF in German and English | ||||||||||||||||||
7D | Unused command | ||||||||||||||||||
7E | Unused command | ||||||||||||||||||
7F | Unused command | ||||||||||||||||||
80 | AnimationSetSpriteFlagsAndResetElevationLevel( u8 SpriteFlags ) | 2 | |||||||||||||||||
81 | AnimationSetB( u8 SpriteFlags ) | 2 | |||||||||||||||||
82 | AnimationSetC( u8 SpriteFlags, u8 ) | 3 | |||||||||||||||||
83 | SpriteSetFlagsAndElevationLevel( u8 SpriteFlags, u8 EleveationLevel ) | 3 | |||||||||||||||||
84 | 4 | ||||||||||||||||||
85 | AnimationSetD | 3 | calls 80 | ||||||||||||||||
86 | AnimationSetE( u8, u8 ) | 3 | calls 81 | ||||||||||||||||
87 | ObjectMove( u8, u8, u8 ) | 4 | calls 82 | ||||||||||||||||
88 | 4 | calls 83 | |||||||||||||||||
89 | 5 | calls 84 | |||||||||||||||||
8A | 2 | ||||||||||||||||||
8B | 3 | calls 8A | |||||||||||||||||
8C | 2 | ||||||||||||||||||
8D | 3 | calls 8C | |||||||||||||||||
8E | AnimationWait | 1 | |||||||||||||||||
8F | AnimationWait2 | 1 | |||||||||||||||||
90 | 1 | wait for loop | |||||||||||||||||
91 | 1 | ||||||||||||||||||
92 | 1 | wait for loop | |||||||||||||||||
93 | 1 | ||||||||||||||||||
94 | 1 | wait for loop | |||||||||||||||||
95 | u16, u8, u16, u16, u16, u8 | 9 | |||||||||||||||||
96 | u16, u16, u16, u16, u16 | 11 | |||||||||||||||||
97 | u16, u8, u16, ? | 6 | |||||||||||||||||
98 | u16, u8, ? | 11 | Object related | ||||||||||||||||
99 | ObjectCloneInsertAtBeginSF | 6 | Insert at begin of list, set script pointer and flags | ||||||||||||||||
9A | ObjectCloneInsertBeforeSP | 4 | Insert before current object, set script pointer and parent (implied) | ||||||||||||||||
9B | ObjectCloneInsertBeforeSFP | 6 | Insert before current object, set script pointer, flags and parent (implied) | ||||||||||||||||
9C | ObjectCloneInsertBeforeSRP | 8 | Insert before current object, set script pointer, relative placement and parent (implied) | ||||||||||||||||
9D | ObjectCloneInsertBeforeSRFP | 10 | Insert before current object, set script pointer, relative placement, flags and parent (implied) | ||||||||||||||||
9E | ObjectCloneInsertBeforeSAP | 8 | Insert before current object, set script pointer, absolute placement and parent (implied) | ||||||||||||||||
9F | ObjectCloneInsertBeforeSAFP | 10 | Insert before current object, set script pointer, absolute placement, flags and parent (implied) | ||||||||||||||||
A0 | ObjectCloneInsertAtEndSFP | 6 | Insert at end of list, set script pointer, flags and parent (implied) | ||||||||||||||||
A1 | ObjectCloneInsertAfterSP | 4 | Insert after current object, set script pointer and parent (implied) | ||||||||||||||||
A2 | ObjectCloneInsertAfterSFP | 6 | Insert after current object, set script pointer, flags and parent (implied) | ||||||||||||||||
A3 | ObjectCloneInsertAfterSRP | 8 | Insert after current object, set script pointer, relative placement and parent (implied) | ||||||||||||||||
A4 | ObjectCloneInsertAfterSRFP | 10 | Insert after current object, set script pointer, relative placement, flags and parent (implied)
Same handler as 0xE8 | ||||||||||||||||
A5 | ObjectCloneInsertAfterSAP | 8 | Insert after current object, set script pointer, absolute placement and parent (implied) | ||||||||||||||||
A6 | ObjectCloneInsertAfterSAFP | 10 | Insert after current object, set script pointer, absolute placement, flags and parent (implied) | ||||||||||||||||
A7 | ObjectDelete | 1 | |||||||||||||||||
A8 | 1 | ||||||||||||||||||
A9 | |||||||||||||||||||
AA | 4 | ||||||||||||||||||
AB | |||||||||||||||||||
AC | |||||||||||||||||||
AD | |||||||||||||||||||
AE | |||||||||||||||||||
AF | 2 | ||||||||||||||||||
B0 | 2 or 5 | ||||||||||||||||||
B1 | ObjectMoveHorizontal | 3 | |||||||||||||||||
B2 | ObjectMoveVertical | 3 | |||||||||||||||||
B3 | ObjectMove | 5 | |||||||||||||||||
B4 | SpriteSetUpsideDown | 1 | |||||||||||||||||
B5 | SpriteSetDownsideUp | 1 | |||||||||||||||||
B6 | SpriteSetFacingRight | 1 | |||||||||||||||||
B7 | SpriteSetFacingLeft | 1 | |||||||||||||||||
B8 | SpriteFlipVertical | 1 | |||||||||||||||||
B9 | SpriteFlipHorizontal | 1 | |||||||||||||||||
BA | SpriteSetPriority | 2 | Allowed values: 0..3 << 4 | ||||||||||||||||
BB | SpriteSetPalette | 2 | Allowed values: 0..7 << 1 | ||||||||||||||||
BC | MarkOrigin | 1 | |||||||||||||||||
BD | MarkOriginAsync | 1 | |||||||||||||||||
BE | JumpAndSetOriginWithDelay | 6 | |||||||||||||||||
BF | JumpAndSetOriginAsync | 4 | |||||||||||||||||
C0 | SetOriginAndEraseDelay | 4 | |||||||||||||||||
C1 | Delay | 3 | |||||||||||||||||
C2 | JumpIfMapCollisionAbove | 3 | |||||||||||||||||
C3 | JumpIfMapCollisionBelow | 3 | |||||||||||||||||
C4 | JumpIfMapCollisionLeft | 3 | |||||||||||||||||
C5 | JumpIfMapCollisionRight | 3 | |||||||||||||||||
C6 | GetCurrentBlockCollision | 1 | ?? | ||||||||||||||||
C7 | CheckMapCollisionAbove | 3 or 9 | |||||||||||||||||
C8 | CheckMapCollisionBelow | 3 or 9 | |||||||||||||||||
C9 | CheckMapCollisionLeft | 3 or 9 | |||||||||||||||||
CA | CheckMapCollisionRight | 3 or 9 | |||||||||||||||||
CB | 5 | Change other object script ?? | |||||||||||||||||
CC | 6 | ||||||||||||||||||
CD | |||||||||||||||||||
CE | |||||||||||||||||||
CF | |||||||||||||||||||
D0 | |||||||||||||||||||
D1 | |||||||||||||||||||
D2 | TriggerOnSight( u8 SideRange, u8 FrontRange, u8 Direction, u16 JumpAddress ) | 6 | |||||||||||||||||
D3 | RangeCheckHorizontal | 9 | |||||||||||||||||
D4 | RangeCheckVertical | 9 | |||||||||||||||||
D5 | |||||||||||||||||||
D6 | ProximityTrigger | 4 | |||||||||||||||||
D7 | DetermineNearestAxis | 5 | |||||||||||||||||
D8 | 4 | ||||||||||||||||||
D9 | LoadFightingStats | 2 | Load pointer to index in enemy table
80: Don't load max HP | ||||||||||||||||
DA | HandlerRegisterOnWall( u16 HandlerAddress ) | 3 | Set Wall Hit Handler | ||||||||||||||||
DB | |||||||||||||||||||
DC | 6 | ||||||||||||||||||
DD | 8 | ||||||||||||||||||
DE | 2 | ||||||||||||||||||
DF | WaitOn097C_0810 | 4 | Wait For ([097C] & 0810) == 0, Then Jump | ||||||||||||||||
E0 | |||||||||||||||||||
E1 | |||||||||||||||||||
E2 | |||||||||||||||||||
E3 | |||||||||||||||||||
E4 | 1 | ||||||||||||||||||
E5 | |||||||||||||||||||
E6 | ObjectCloneDepInsertAfterSP | 4 | Like A1, but additionally makes new object depend on the old one, which mainly matters for mass deletion with command EB. | ||||||||||||||||
E7 | ObjectCloneDepInsertAfterSFP | 6 | Like A2, but additionally makes new object depend on the old one. | ||||||||||||||||
E8 | ObjectCloneDepInsertAfterSRFP | 10 | Like A4, but additionally makes new object depend on the old one. | ||||||||||||||||
E9 | ObjectCloneDepInsertAfterSAFP | 10 | Like A6, but additionally makes new object depend on the old one. | ||||||||||||||||
EA | ObjectCloneDepInsertBeforeSP | 4 | Like 9A, but additionally makes new object depend on the old one. | ||||||||||||||||
EB | DeleteAllDependingObjects | 1 | Delete all depending objects, but only if 'this' has no parent | ||||||||||||||||
EC | |||||||||||||||||||
ED | ObjectMoveRelative( u16 AnimationID, s16 X, s16 Y) | 6 | |||||||||||||||||
EE | ObjectMoveWaitRelative( u8 ) | 2 | |||||||||||||||||
EF |