Each instruction is represented by a number – opcode, which is UINT16.
By that number the game engine(.exe) identifies an action to perform. And the opcode will do what it is made for, if used correctly.
Here is how a opcode in SCM looks like:
0100 04 00
0200 04 @Label
- First 4 digits is the opcode number in a little-endian format.
- Second part is the data type
- Third part is a parameter(s) value
When a mission script is disassembled, the opcodes are written in a readable format, in which humans, can read better. The examples above will look something like this:
The comment opcode words(wait, jump,) are made only so the user can understand the opcode better. The game does not know what the words mean, it knows the data number(0001: for example) and it knows the parameters and this is the only thing which is important(for example you do not need the word "wait" you can just put 0001: 0) (0001 is the data, and 0 is the parameter of that opcode for example). So when a mission script is assembled the commands are written back in raw byte form.
An opcode is UINT16 number. It means the minimum opcode is 0000 and maximum opcode is 0xFFFF. However due to a specific of the SCM language, any numbers above 0x7FFF denote negative conditional opcodes. The original un-modded game supports a way smaller amount of opcodes (maximum 0A4E for San Andreas).
Data type is a single byte written before any parameter. The purpose of it is to tell to the game how much bytes to read next and what kind of data it is, that depends on what opcode it is.
--Data type-- --Parameter Length (bytes)--
The games engine knows amount of parameters for each opcode, (and it knows the data type, as stated above as well). The parameter of a opcode, could be one of the following:
- Immediate values
- integer numbers
- floating-point numbers
- short strings (up to 7 characters and null-terminator byte)
- San Andreas long strings (up to 15 characters and length byte)
- global variables
- local variables
- For information on arrays see here.
0006: 0@ = 0
0007: 0@ = 0.0
You can see this topic for information on them.