Skip to content

Extra Info Format

x87 edited this page Dec 11, 2020 · 7 revisions

Intro

Sanny Builder stores scripts metadata when Add extra info option is enabled. This metadata gets added at the very end of the compiled file directly following the last opcode. It exploits the fact that the last opcode must be the goto instruction or the script terminator command otherwise the game would crash here trying to read the next opcode.

Format

A script with the Extra Info section is structured in the following way

OFFSET  TYPE      DESCRIPTION
0000    byte[n]   script section (compiled opcodes)
n       byte[m]   extra info section
n+m     DWORD     extra info section start offset (n)
n+m+4   CHAR[8]   __SBFTR

__SBFTR is the null-terminated string literal (8 bytes) that signals the disassembler that the preceding chunk of data is the Sanny's extra info section. If the literal is not __SBFTR the disassembler treats the whole file as compiled code.

Extra Info Section

This section starts at the Xth byte from the beginning of the file where X is a DWORD number stored at offset 12 from the end of the file. It may contain zero to many subsections each with the following format:

OFFSET  TYPE      DESCRIPTION
0000    CHAR[n]   a null-terminated subsection signature
n       byte[nn]  extra info subsection

The order of subsections is undetermined. Currently known and supported subsection signatures are:

  • HEX
  • VAR
  • FLAG
  • SRC
  • AAA*
  • E*

* deprecated

HEX Subsection

Keeps information about HEX..END structs used in the script. Each record contains the starting offset of the struct in the code and its size.

OFFSET  TYPE      DESCRIPTION
0000    DWORD     number of records (n)
0004    Hex[n]    a list of records, see below the individual record format

Hex:
OFFSET  TYPE      DESCRIPTION
0000    DWORD     offset
0004    DWORD     size

AAA Subsection

This subsection indicates that the AAA script in the script.img is user-made (as opposed to the automatically generated AAA script that serves for compatibility with the original GTA SA scripts). Deprecated, see the Flags subsection.

E Subsection

This subsection indicates that this script is headerless, e.g. a CLEO script. Deprecated in favor of the Flags subsection. See also Skip SCM Header.

Var Subsection

This subsection keeps custom global variables used in the script along with their names.

OFFSET  TYPE        DESCRIPTION
0000    DWORD       number of variables (n)
0004    Variable[n] a list of records, see below the individual record format

Variable:
OFFSET  TYPE      DESCRIPTION
0000    CHAR[n]   a null-terminated variable name literal
n       DWORD     variable index

Flag Subsection

This section contains various DWORD numbers used to toggle different Sanny options.

OFFSET  TYPE    DESCRIPTION
0000    DWORD   the target game for the disassembler
1 = GTA 3
2 = Vice City
4 = San Andreas
8 = LCS
16 = VCS
32 = SA Mobile
0004    DWORD   custom AAA script flag (a replacement for the AAA Subsection)
0008    DWORD   is headerless script flag (a replacement for the E subsection).

SRC Subsection

This section stores the unmodified source code used as is by the disassembler.

OFFSET  TYPE      DESCRIPTION
0000    CHAR[n]   a null-terminated string representing the source code of the script