Опкод

Материал из GTAModding.ru
Версия от 13:28, 8 ноября 2015; GeniusZ (обсуждение | вклад)

(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
Перейти к: навигация, поиск

Опкод - это специальная команда для выполнения скрипта, данные команды описывают функции. Многие функции являются обязательными для работы скрипта.

Each script instruction is represented by a number called operation code which is implemented using an 16 bit unsigned integer. By this number the game engine identifies an action to perform. Say, opcode 0001 tells to wait for amount of time, 0003 shakes the camera, 0053 creates a player, etc.

This is how an opcode 0001 looks in a scm file:

0100 04 00
  • First part is the opcode number in a little-endian format.
  • Second part is the data type
  • Third part is a parameter value

When a mission script is disassembled, opcodes are written in a human-readable format. The example above will look something like this:

wait 0

This is made for the end-user convenience only. The game does not know what the word wait means, but it knows what the opcode 0001 is, so when a mission script is assembled the commands are written back in raw byte form.

As it has been said, 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. More on this read there. The original unmodded game supports a way smaller amount of opcodes (maximum 0A4E for San Andreas), but there are tools adding new ones, most notably CLEO library.

After an opcode number the data types and parameter values follow[*].