Difference between revisions of "SA SCM"

From GTAMods Wiki
Jump to navigation Jump to search
 
m
 
(16 intermediate revisions by 6 users not shown)
Line 1: Line 1:
  [02 00 01] + 32 bit int        jump to next section
+
  (02 00 01)h + 32-bit offset    '''GOTO''' next header chunk
  byte                           padding?? (73h)
+
  byte                           Target game ('s' - San Andreas for SA, unused at runtime)
   ...                          global vars
+
   (Global variable space)      Space for global variable storage (first global offset is 8)
  [02 00 01] + 32 bit int        jump to next section
+
  (02 00 01)h + 32-bit offset    '''GOTO''' next header chunk
  byte                           section id (0)
+
  byte                           Chunk index (always 0, unused at runtime)
   32 bit int                   num model names
+
   32-bit int                   Number of used objects (at least 1)
   ...                          24 byte model names (first = unused)
+
   (Used object array)          24-byte object name * number of used objects (first object name is empty and therefore unused)
  [02 00 01] + 32 bit int        jump to next section
+
  (02 00 01)h + 32-bit offset    '''GOTO''' next header chunk (third header chunk is compiled only in script multifile)
  byte                           section id (1)
+
  byte                           Chunk index (always 1, unused at runtime)
   32 bit int                   size of main
+
   32-bit int                   Main script size
   32 bit int                   size of largest mission
+
   32-bit int                   Largest mission script size
   32 bit int                   num missions
+
  16-bit int                  Number of mission scripts (200 in total)
   32 bit int                   highest number of local vars used in a mission or external script
+
   16-bit int                   Number of exclusive mission scripts (3 in total)
   ...                          32 bit ints = mission offsets in file
+
   32-bit int                   Largest number of mission script local variables
  [02 00 01] + 32 bit int        jump to next section
+
   (Multi script array)        32-bit offset * number of mission scripts
  byte                           section id (2)
+
  (02 00 01)h + 32-bit offset    '''GOTO''' next header chunk
   32 bit int                   size of largest external script
+
  byte                           Chunk index (always 2, unused at runtime)
   32 bit int                   num external scripts
+
   32-bit int                   Largest streamed script size
   28 bytes per external script file:
+
   32-bit int                   Number of streamed scripts
  20 bytes                     script filename
+
   (Streamed script array)      28-byte structure * number of streamed scripts (last one is '''AAA''' test script{{ref|1}})
  32 bit int                    script offset (in memory, relative to base of main.scm?)
+
    20 bytes                   Filename (without extension)
  32 bit int                   script len
+
    32-bit offset              File offset (from script multifile end onwards, mostly leftover)
  [02 00 01] + 32 bit int        jump to next section
+
    32-bit int                 Script size
  byte                           section id (3)
+
  (02 00 01)h + 32-bit offset    '''GOTO''' next header chunk{{ref|2}}
   32 bit int                   ??? (0)
+
  byte                           Chunk index (always 3, unused at runtime)
  [02 00 01] + 32 bit int        jump to next section
+
   32-bit int                   Unknown (unused at runtime)
  byte                           section id (4)
+
  (02 00 01)h + 32-bit offset    '''GOTO''' main script space{{ref|2}}
   32 bit int                   size of global var section
+
  byte                           Chunk index (always 4, unused at runtime)
   32 bit int                   ??? (862h=2146)
+
   32-bit int                   Size of global variable space (unused at runtime)
  ...                             code starts here!
+
   32-bit int                   Build number{{ref|3}} (at least 1, unused at runtime)
 +
  (Main script space)            Space of main script (equal to size defined earlier)
 +
(Mission scripts space)        Space of mission scripts (each one is stored at file offsets defined earlier)
 +
(Streamed scripts space)      Space of streamed scripts (as above but external and discontiguous for script multifile)
 +
 
 +
{{note|1}} '''AAA''' streamed script is apparently a test script, meaningful for debug builds, which contains no intermediate code and is supposed to store the 8 bytes coming with the sixth header chunk of the script multifile relevant to match the [[Cd image]] where all streamed scripts have been compiled and archived into (notoriously in [[script.img]]). It is advisable to compare data on the basis of the script size rather than of a fixed length (the way it might have been designed to);
 +
 
 +
{{note|2}} The header chunk is fetched as normal code and may be mandatory only in script multifile;
 +
 
 +
{{note|3}} The field is not confirmable at this time. The official compiler may keep track of the build number in a text file, say <code>build.txt</code>, which is updated (or created if unexisting) while compiling.
 +
 
 +
{{N|SA}}
 +
[[Category:Mission Script]] [[Category:File Formats]]

Latest revision as of 23:25, 12 January 2021

(02 00 01)h + 32-bit offset    GOTO next header chunk
byte                           Target game ('s' - San Andreas for SA, unused at runtime)
  (Global variable space)      Space for global variable storage (first global offset is 8)
(02 00 01)h + 32-bit offset    GOTO next header chunk
byte                           Chunk index (always 0, unused at runtime)
  32-bit int                   Number of used objects (at least 1)
  (Used object array)          24-byte object name * number of used objects (first object name is empty and therefore unused)
(02 00 01)h + 32-bit offset    GOTO next header chunk (third header chunk is compiled only in script multifile)
byte                           Chunk index (always 1, unused at runtime)
  32-bit int                   Main script size
  32-bit int                   Largest mission script size
  16-bit int                   Number of mission scripts (200 in total)
  16-bit int                   Number of exclusive mission scripts (3 in total)
  32-bit int                   Largest number of mission script local variables
  (Multi script array)         32-bit offset * number of mission scripts
(02 00 01)h + 32-bit offset    GOTO next header chunk
byte                           Chunk index (always 2, unused at runtime)
  32-bit int                   Largest streamed script size
  32-bit int                   Number of streamed scripts
  (Streamed script array)      28-byte structure * number of streamed scripts (last one is AAA test script[1])
    20 bytes                   Filename (without extension)
    32-bit offset              File offset (from script multifile end onwards, mostly leftover)
    32-bit int                 Script size
(02 00 01)h + 32-bit offset    GOTO next header chunk[2]
byte                           Chunk index (always 3, unused at runtime)
  32-bit int                   Unknown (unused at runtime)
(02 00 01)h + 32-bit offset    GOTO main script space[2]
byte                           Chunk index (always 4, unused at runtime)
  32-bit int                   Size of global variable space (unused at runtime)
  32-bit int                   Build number[3] (at least 1, unused at runtime)
(Main script space)            Space of main script (equal to size defined earlier)
(Mission scripts space)        Space of mission scripts (each one is stored at file offsets defined earlier)
(Streamed scripts space)       Space of streamed scripts (as above but external and discontiguous for script multifile)

^ AAA streamed script is apparently a test script, meaningful for debug builds, which contains no intermediate code and is supposed to store the 8 bytes coming with the sixth header chunk of the script multifile relevant to match the Cd image where all streamed scripts have been compiled and archived into (notoriously in script.img). It is advisable to compare data on the basis of the script size rather than of a fixed length (the way it might have been designed to);

^ The header chunk is fetched as normal code and may be mandatory only in script multifile;

^ The field is not confirmable at this time. The official compiler may keep track of the build number in a text file, say build.txt, which is updated (or created if unexisting) while compiling.