GME Script line - entropia/tip-toi-reveng GitHub Wiki
A script line consists of a list of conditionals, a list of actions, and a so called playlist consisting media file table indices.
A script line has the format aaaa conditionals... bbbb actions... cccc media... where
-
a(uint16) is the number of conditionals. Each conditional consists of 8 bytes. -
b(uint16) is the number of actions. Each action is 7 bytes. -
c(uint16) is a playlist
The conditionals are of the format t1 aaaa cccc t2 bbbb
-
t1&t2(uint8) type ofaandbresp. (0 == register, 1 == value) -
a&b(uint16) value or id of register -
c(uint16) is the comparison operator The rest of the line is only considered when the comparison between the register and the value or other register holds.
Known comparison operators are:
-
FFF9(written$r==m?in tttool's output and the yaml files): Equality -
FFFA(written$r>m?in tttool's output): Greather than -
FFFB(written$r<m?in tttool's output): Less than -
FFFD(written$r>=m?in tttool's output): Greater or equal -
FFFE(written$r<=?in tttool's output): Less or equal -
FFFF(written$r!=m?in tttool's output): Not equal
The actions are of the format rrrr cccc tt mmmm
-
r(uint16) id of register -
c(uint16) is the command -
t(uint8) type ofm(0 == register, 1 == value) -
m(uint16) value or id of register
Known commands are:
-
FFF0(written$r+=m): increment register$rbymor value of$m -
FFF1(written$r-=m): decrement register$rbymor value of$m -
FFF2(written$r*=m): multiply register$rbymor value of$m -
FFF3(written$r%=m): set register$rto$rmodm -
FFF4(written$r/=m): set register$rto$rdivm -
FFF5(written$r&=m): bitwise and to register$rthe value ofm -
FFF6(written$r|=m): bitwise or to register$rthe value ofm -
FFF7(written$r^=m): bitwise xor to register$rthe value ofm -
FFF8(writtenNeg($r)): negate register$r. -
FFF9(written$r:=m): set register$rtomor value of$m -
FFE0(writtenP*(): play one random sample of the media list -
FFE1(writtenPA*(): play all samples of the media list -
FFE8(writtenP(m)): play audio referenced by themth entry in the indices list. -
FB00(writtenPA(b-a)): play all samples from that inclusive range.a:= lowbyte(m),b:= highbyte(m) -
FC00(writtenP(b-a)): play one random sample from that inclusive range.a:= lowbyte(m),b:= highbyte(m) -
FD00(writtenG(m)): begin gamem. -
F8FF(writtenJ(m)): jump to scriptm. -
FAFF(writtenC): cancel game mode. -
FF00(writtenT($register,123)): Timer action.
Currently unknown commands are FE00 and FF00 (in theory there can be more but these have been seen in the wild, at least). FE00 seems to have something to do with timers and random numbers.
The commands P, G , J and C seem to ignore their registers, C also its parameter (which always is FFFF).
Scriptline:
"01 00 | 00 00 00 F9 FF 01 01 00 | 01 00 | 00 00 E8 FF 01 00 00 | 01 00 | 00 00"
Please take into account that the numbers are stored in little endian format!
Number of conditionals: "01 00"
0x0001 = 1 -> one conditional is defined
Conditional 1: "00 00 00 F9 FF 01 01 00"
0x00 = 0 -> the first operand a is a register
0x0000 = 0 -> the number of this register is 0, i.e. the first operand a is the value in register 0
0xFFF9 -> the comparison is equality
0x01 = 1 -> the second operand b is an absolute value
0x0001 = 1 -> the value of the second operand b is 1
Number of actions: "01 00"
0x0001 = 1 -> one action is defined
Action 1: "00 00 E8 FF 01 00 00"
0x0000 = 0 -> use register 0
0xFFE8 -> Command "Play (m)"
0x01 = 1 -> the argument m is an absolute value
0x0000 = 0 -> the value of the argument m is 0
Number of items in playlist: "01 00"
0x0001 = 1 -> one item in the playlist
Item 1 in the playlist: "00 00"
0x0000 = 0 -> reference to audio file 0
Commands that are expected to exist but have not been found or verified yet:
- random number generation
- timer programming
- loops
- play that determines what to play from a register
- sleep