Command Opcodes and Operands

This topic includes the command-level opcodes and the order and structure of the operands of each command. Operands can be one of the types included in the following table.

Type Description
GetVar GetVar encoding. For more information, see the topic Expressions and GetVar Codes.
Offset 32-bit offset from the start of the binary.
Byte Single-byte value.
Word Two-byte value.
Dword Four-byte value.
ASCIIZ Zero-terminated character string.
Double 8-byte double precision floating-point number.

The actual command opcodes and the operands, specified in sequential order, are included in the following table.

Opcode Operand/Description
OPCODE_END (0) Marks the logical end of the program.
OPCODE_GOTO (1) Transfer address (offset).
OPCODE_IF (2) Implements If, ElseIf, and While. False branch address (offset); expression (GetVar). If expression evaluates to False (0), branch to false address.
OPCODE_FOR_INIT (3) Initializes variable used in start through step and saves the value of end and step in the appropriate fields in the immediately following Opcode_For.
Variable (GetVar), start (GetVar), end (GetVar), step (GetVar).
OPCODE_FOR (4) Adds saved step value to variable. If the variable is greater than end value and step is positive, or the variable is less than end value and step is negative, branches to done address.
Saved end value (double), saved step value (double), done address (offset), and variable (GetVar).
OPCODE_GOSUB (5) Pushes next command address on subroutine stack and jumps to transfer address.
Transfer address (offset).
OPCODE_RETURN (6) Pops return address from subroutine stack.
OPCODE_ONGOTO (7) Number of entries in jump table (byte), control value (GetVar), N (N=number of entries in the jump table) jump table entries (offset). For example, if there are 3 entries in the jump table, 3 offsets will be stored.
OPCODE_ONGOSUB (8) Number of entries in jump table (byte), control value (GetVar), N (N=number of entries in the jump table) jump table entries (offset). For example, if there are 3 entries in the jump table, 3 offsets will be stored.
OPCODE_ASSIGN (9) Variable (GetVar), expression (GetVar).
OPCODE_ONCRASH (10) Routine address (offset); (0xFFFFFFFF means clear).
OPCODE_ONSTALL (11) Routine address (offset); (0xFFFFFFFF means clear).
OPCODE_ONKEY (12) Key value (GetVar), routine address (offset); (0xFFFF means clear).
OPCODE_PRINT (13) Print opcodes.
Note: The Print, Scroll, and Debug_Print commands use special opcodes to describe the components of the output. These opcodes make the format general enough to support the full functionality of the BASIC Print command, even though all of the features aren't currently implemented.
OPCODE_PLAY (14) File name (ASCIIZ).
OPCODE_SCROLL (16) Print opcodes.
OPCODE_WAIT (17) Time in seconds (GetVar), key press flag (0 if Keypress is not specified, 1 if Keypress is specified), (byte).
OPCODE_NORTH_LAT (18) Specifies that north latitude is positive.
OPCODE_SOUTH_LAT (19) Specifies that south latitude is positive.
OPCODE_EAST_LON (20) Specifies that east longitude is positive.
OPCODE_WEST_LON (21) Specifies that west longitude is positive.
OPCODE_SET_
POSITION (22) Latitude in degrees (GetVar), longitude in degrees (GetVar), altitude in feet (GetVar).
OPCODE_RESET_STN (23) Resets the currently loaded flight.
OPCODE_LOAD_STN (24) File name (ASCIIZ).
OPCODE_RESET_ADV (25)
OPCODE_WEATHER (26) Name (ASCIIZ), latitude in degrees (GetVar), longitude in degrees (GetVar), latitude in degrees (GetVar), longitude in degrees (GetVar).
OPCODE_WEATHER_
CHAR (27) Width in miles (GetVar), transition in miles (GetVar), course in degrees (GetVar), speed in knots (GetVar).
OPCODE_CLOUDS (28) Layer (GetVar)
add/delete flag (0=delete layer, 1=add/change layer) (byte)
Note: Further fields are omitted if flag=0.
base in feet (GetVar), top in feet (GetVar), type (user defined=0, cirrus=1, cirrostratus=2, and so on) (byte), coverage in eighths for regular or 0–2 for cumulonimbus (byte), turbulence (GetVar), deviation in feet (GetVar), icing (GetVar).
OPCODE_WINDS (29) Layer (GetVar)
add/delete flag (0=delete layer, 1=add/change layer) (byte)
Note: Further fields are omitted if flag=0.
base in feet (GetVar), top in feet (GetVar), type (steady=0, gusty=1) (byte), direction in degrees (GetVar), speed in knots (GetVar), turbulence (GetVar).
OPCODE_ TEMPERATURE (30) Layer (GetVar)
add/delete flag (0=delete layer, 1=add/change layer) (byte)
Note: Further fields are omitted if flag=0.
altitude in feet (GetVar), temperature in degrees Celsius (GetVar), variation in degrees Celsius (GetVar).
OPCODE_BARO_ PRESSURE (31) Pressure in inches of mercury (GetVar), drift (GetVar)
OPCODE_VISIBILITY (32) Visibility in miles (GetVar)
OPCODE_DEBUG_ WINDOW (33) On/off flag (0=turn off, 1=turn on) (byte)
OPCODE_DEBUG_ PRINT (34) Print opcodes.
Note: The Print, Scroll, and Debug_Print commands use special opcodes to describe the components of the output. These opcodes make the format general enough to support the full functionality of the BASIC Print command, even though all of the features aren't currently implemented.
OPCODE_PRECISION (35) Left (GetVar), right-min (GetVar), right-max (GetVar).
OPCODE_PRINT_TIME (36) Time in seconds (GetVar).
OPCODE_ADV_KEYS (37) Type (0=clear, 1=add, 2=delete) (byte)
If type is not 0:
Number of entries in list of keys (byte)
Key value 1 (GetVar)
Key value 2 (GetVar)
OPCODE_PLAY_VIDEO (38) File name (ASCIIZ).
OPCODE_ PERFORMANCE (39) Frequency of command interpretation (byte): 1 = low, 2 = medium, 3 = high, 4 = every frame, 100 = default frequency. If a nondefault frequency is used, it must be followed by a GetVar expression equal to the number of commands to be interpreted each time the interpreter is invoked.
OPCODE_ONEXP_ TRUE (40) Boolean trigger condition (GetVar), True handler subroutine (address), optional False handler subroutine (address) (-1 means no False subroutine exists).
OPCODE_ONEXP_BOOL_ CHANGE (41) Boolean trigger condition (GetVar), False-to-True handler subroutine (address), optional True-to-False handler subroutine (address) (-1 means no False subroutine exists), reserved space (double).
OPCODE_ONEXP_ CHANGE (42) Boolean trigger condition (GetVar), change handler subroutine (address), reserved space (double).
OPCODE_ONEXP_ CLEAR (43) Handler subroutine (address). Address equal to -1 clears all events.

The following opcodes are used by the Print, Scroll, and Debug_Print commands.

Opcode Description
PRINT_END (0) Value is 0x00. Marks the end of the Print command.
PRINT_NEWLINE (1) Value is 0x01. Indicates the end of a line and commits the text to the message box.
PRINT_STRING (2) Value is 0x02. Additional data, ASCIIZ. Specifies a string of characters to print.
PRINT_NUMBER (3) Value is 0x03. Additional data, GetVar. Specifies a numeric expression to print.