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);
Commands
| Opcode
|
argument length (byte)
|
Function
|
| 0x00
|
3
|
Jump to 24byte offset
| Offset
|
Length
|
Name
|
| 0
|
3
|
Script offset
|
|
| 0x01
|
1
|
Unknown
|
| 0x02
|
2
|
Setup a loop
| Offset
|
Length
|
Name
|
| 0
|
2
|
Loop count
|
|
| 0x03
|
1
|
Execute loop
|
| 0x04
|
4
|
Unknown
|
| 0x07
|
2
|
Unset event flag
| Offset
|
Length
|
Name
|
| 0
|
2
|
Flag+Value (see note)
|
|
| 0x08
|
4
|
Jumps to offset if flag is set
| Offset
|
Length
|
Name
|
| 0
|
2
|
Flag+Value (see note)
|
| 2
|
2
|
Offset to script location
|
|
| 0x09
|
4
|
Jumps to offset if flag is not set
| Offset
|
Length
|
Name
|
| 0
|
2
|
Flag+Value (see note)
|
| 2
|
2
|
Offset to script location
|
|
| 0x0C
|
8
|
Trigger area
| Offset
|
Length
|
Name
|
| 0
|
1
|
Movement mask
|
| 1
|
1
|
Start X
|
| 2
|
1
|
Start Y
|
| 3
|
1
|
End X
|
| 4
|
1
|
End Y
|
| 5
|
2
|
Script offset
|
| 7
|
1
|
Unknown
|
|
| 0x14
|
8
|
Port player
| Offset
|
Length
|
Name
|
| 0
|
2
|
Map ID
|
| 2
|
2
|
Map X
|
| 4
|
2
|
Map Y
|
| 6
|
2
|
Unknown
|
|
| 0x1A
|
11
|
Display choice dialog
| Offset
|
Length
|
Name
|
| 0
|
2
|
Pointer to options
|
| 3
|
2
|
Cancel option
|
| 5
|
2
|
First option
|
| 7
|
2
|
Second option
|
| 9
|
2
|
Third option
|
|
| 0x1B
|
2
|
Call text script (16 byte address)
| Offset
|
Length
|
Name
|
| 0
|
2
|
Offset
|
|
| 0x1C
|
3
|
Call text script (24 byte address)
| Offset
|
Length
|
Name
|
| 0
|
3
|
Offset
|
|
| 0x1F
|
0
|
End script
|
| 0x21
|
2
|
| Offset
|
Length
|
Name
|
| 0
|
2
|
Offset
|
|
| 0x23
|
2
|
| Offset
|
Length
|
Name
|
| 0
|
2
|
Offset
|
|
| 0x2D
|
7
|
Call code when movement mask matches
| Offset
|
Length
|
Name
|
| 0
|
2
|
Movement mask
|
| 2
|
2
|
script offset
|
| 5
|
3
|
code offset
|
|
| 0x48
|
2
|
Skip next opcode if event flag is unset
| Offset
|
Length
|
Name
|
| 0
|
2
|
Flag+Value (see note)
|
|
| 0x6E
|
1
|
Update scene
|
| 0x78
|
x
|
Update BG fade
|
| 0x80
|
x
|
Set model mode
|
| 0x87
|
x
|
Move object
|
| 0x8F
|
0
|
Unknown
|
| 0xC1
|
x
|
Set scene time
|
| 0xAA
|
x
|
Call script
|
| 0xB7
|
0
|
Unknown
|