User:Nethraz/Script Commands

From Terranigma Wiki
Jump to navigation Jump to search

Scripts are basically written in ASM. The 02 (COP) ASM instruction is used to execute custom script commands, with the actual command and parameters following the 02 opcode.

For example the command 07 (Modify Flag) is written as:

02 07 flag_value

where flag_value is the 2 byte flag and value encoded in little endian format, so the whole command takes up 4 bytes.

The length of every known command is shown in the following table.

Command Length Table
00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
00 5 2 4 2 2 4 5 4 6 8 6 6 9 9 13 7
10 7 10 10 5 10 2 9 7 8 16 5 4 5 4 5 2
20 2 4 6 4 5 2 6 4 4 6 6 9 6 6
30 3 3 3 2 12 3 3 4 5 5 2 2 5 5 5
40 5 8 6 6 2 9 6 4 4 7 5 6 6
50 5 3 5 5 5 3 7 7 7 8 10
60 6 8 3 4 7 7 2 3 2 4 4 5 2 2 2
70 8 8 5 6 4 3
80 3 3 4 4 5 4 4 5 5 3 3 3 2 2
90 2 2 2 10 12 7 5 7 9 11 9 11
A0 7 5 7 9 11 9 11 2 3 5 7 6 8 3 3
B0 3 4 4 6 2 2 2 2 2 2 3 3 2 2 7 5
C0 5 4 4 4 4 4 2 4 4 4 4 6 7 2 11 2
D0 18 2 7 10 10 4 5 6 5 3 11 9 7 9 3 5
E0 2 13 5 7 11 11 5 2 10 7 3


#00 - Call
#01 - Return if Called With 00
#02 - Loop Begin
#03 - Loop Next (yield)
#04 - Loop Next (no yield)
#05 - Wait On Flag
#06 - Goto New Script Origin
#07 - Modify Flag
#08 - Check Flag
#09 - Check Multiple Flags
#0A - Check Map Id
#0B - Check 0600

00 - Call

01 - Return if Called With 00

Experimental Table Layouts

Command
(Length)
Name Description
0C
(7)
TriggerOnAreaAbsolute
Direction Left Top Right Bottom JumpAddress
1 1 1 1 1 2