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

Conditionals

The conditionals are of the format t1 aaaa cccc t2 bbbb

  • t1 & t2 (uint8) type of a and b resp. (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.

Comparison operators

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

Actions

The actions are of the format rrrr cccc tt mmmm

  • r (uint16) id of register
  • c (uint16) is the command
  • t (uint8) type of m (0 == register, 1 == value)
  • m (uint16) value or id of register

Commands

Known commands are:

  • FFF0 (written $r+=m): increment register $r by m or value of $m
  • FFF1 (written $r-=m): decrement register $r by m or value of $m
  • FFF2 (written $r*=m): multiply register $r by m or value of $m
  • FFF3 (written $r%=m): set register $r to $r mod m
  • FFF4 (written $r/=m): set register $r to $r div m
  • FFF5 (written $r&=m): bitwise and to register $r the value of m
  • FFF6 (written $r|=m): bitwise or to register $r the value of m
  • FFF7 (written $r^=m): bitwise xor to register $r the value of m
  • FFF8 (written Neg($r)): negate register $r.
  • FFF9 (written $r:=m): set register $r to m or value of $m
  • FFE0 (written P*(): play one random sample of the media list
  • FFE1 (written PA*(): play all samples of the media list
  • FFE8 (written P(m)): play audio referenced by the mth entry in the indices list.
  • FB00 (written PA(b-a)): play all samples from that inclusive range. a := lowbyte(m), b := highbyte(m)
  • FC00 (written P(b-a)): play one random sample from that inclusive range. a := lowbyte(m), b := highbyte(m)
  • FD00 (written G(m)): begin game m.
  • F8FF (written J(m)): jump to script m.
  • FAFF (written C): cancel game mode.
  • FF00 (written T($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).

Example for "$0==1?: P(0) [0]"

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

Missing commands

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
⚠️ **GitHub.com Fallback** ⚠️