Difference between revisions of "III/VC SCM"

From GTAMods Wiki
Jump to navigation Jump to search
m (Added minor clarifications.)
m
 
(6 intermediate revisions by one other user not shown)
Line 1: Line 1:
{{Cleanup-rewrite}}
+
  (02 00 01)h + 32-bit offset    '''GOTO''' next header chunk
== Overall Format ==
+
  byte                          Target game ('l' - Liberty for III, 'm' - Miami for VC, unused at runtime)
  (02 00 01)h + 32-bit int      Jump to second segment
 
  byte                          Target game ('l' - Liberty for III, 'm' - Miami for VC)
 
 
   32-bit int                  Number of cutscene starts (VC Mobile only, unused at runtime)
 
   32-bit int                  Number of cutscene starts (VC Mobile only, unused at runtime)
   (Cutscene start array)      32-bit offset (of '''START_CUTSCENE''' command) * 300 (VC Mobile only, unused at runtime)
+
   (Cutscene start array)      32-bit offset of '''START_CUTSCENE''' command * 300 (VC Mobile only, unused at runtime)
   (Globals space)             Space for global variable storage (first global offset is 8, 1212 in VC Mobile)
+
   (Global variable space)     Space for global variable storage (first global offset is 8, 1212 in VC Mobile)
  (02 00 01)h + 32-bit int      Jump to third segment
+
  (02 00 01)h + 32-bit offset    '''GOTO''' next header chunk
  byte                          Align (always 0)
+
  byte                          Alignment (always 0, ignored)
   32-bit int                  Number of used objects
+
   32-bit int                  Number of used objects (always 1 in VC Mobile{{ref|*}})
 
   (Used object array)          24-byte object name * number of used objects (first object name is empty and therefore unused)
 
   (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 int      Jump to fourth segment
+
  (02 00 01)h + 32-bit offset    '''GOTO''' main script space (third header chunk is compiled only in script multifile)
  byte                          Align (always 0)
+
  byte                          Alignment (always 0, ignored)
 
   32-bit int                  Main script size
 
   32-bit int                  Main script size
 
   32-bit int                  Largest mission script size
 
   32-bit int                  Largest mission script size
 
   16-bit int                  Number of mission scripts (120 in total)
 
   16-bit int                  Number of mission scripts (120 in total)
 
   16-bit int                  Number of exclusive mission scripts (possibly 1 in III, 2 in VC)
 
   16-bit int                  Number of exclusive mission scripts (possibly 1 in III, 2 in VC)
   (Multi script array)        (32-bit offset - 8) * number of mission scripts
+
   (Multi script array)        32-bit offset * number of mission scripts
 
  (Main script space)            Space of main script (equal to size defined earlier)
 
  (Main script space)            Space of main script (equal to size defined earlier)
  (Mission scripts space)        Space of mission scripts (stored at offsets defined earlier)
+
  (Mission scripts space)        Space of mission scripts (each one is stored at file offsets defined earlier)
  
== Main Section ==
+
{{note|*}} Compiler-wise, the model names of level objects are picked directly from [[OBJS]] and [[TOBJ]] sections of the [[IDE]] files whose <code>IDE Filename</code> begins with <code>DATA\</code> in [[Gta.dat|gta_vc.dat]].
Made up of many opcodes one after the other. Opcodes are of the format:
 
<source lang="c">TOpcode {
 
  Opcode[2]: Word; //Opocode number in word format
 
  Parameters: Array Of TParameter;
 
}</source>
 
The number of parameters is specific for each opcode. The [http://vc-db.webtools4you.net/ opcode database] has all of the opcodes in VC, with their parameter numbers, and for most, a description of what they do.
 
Parameters are of the format:
 
<source lang="c">TParameter {
 
  ParameterType[1]: Byte; //Says which type of parameter will follow
 
  ActualParameter: varies; //The actual parameter
 
}</source>
 
The [[Mission Scripting (Overview)#Data types|parameter types]] are as follows (but there are more in SA):
 
01: 32-bit int  (DWord)
 
02: global var  (Word)
 
03: local var    (Word)
 
04: 8-bit int    (Byte)
 
05: 16-bit int  (Word)
 
06: 4-byte float (Single)
 
[[Label]]s use the type 01 (although if they address is small enough using data types 04 and 05 will also work). Global and local vars can also be used for labels.
 
Global vars reference a position in the file much like a label. There is a space at the top of the scm file filled with 00's which is space reserved for global vars. This is divided into blocks of 4 bytes, each var taking up one of these blocks. In compiled form, the global vars each point to somewhere in that block (or should do as otherwise writing to it will modify the actual code).
 
== Example ==
 
This code:
 
<source lang="scm">0001: wait 8 ms
 
0002: jump $var1
 
0050: gosub 1@
 
0051: return</source>
 
 
...compiles as:
 
01 00 04 08 //wait opcode (First 2 bytes = opcode, next byte = 04 the parameter type for 8-bit int, and 08 is the actual value)
 
02 00 02 18 00 // jump opcode. The 18 00 would mean that the global var is stored at address 0x0018
 
50 00 03 01 00 //the gosub opcode
 
51 00 //the return opcode (it has no parameters)
 
 
 
{{Script-stub}}
 
  
 +
{{N|VC|III}}
 
[[Category:Mission Script]] [[Category:File Formats]]
 
[[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 ('l' - Liberty for III, 'm' - Miami for VC, unused at runtime)
  32-bit int                   Number of cutscene starts (VC Mobile only, unused at runtime)
  (Cutscene start array)       32-bit offset of START_CUTSCENE command * 300 (VC Mobile only, unused at runtime)
  (Global variable space)      Space for global variable storage (first global offset is 8, 1212 in VC Mobile)
(02 00 01)h + 32-bit offset    GOTO next header chunk
byte                           Alignment (always 0, ignored)
  32-bit int                   Number of used objects (always 1 in VC Mobile[*])
  (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 main script space (third header chunk is compiled only in script multifile)
byte                           Alignment (always 0, ignored)
  32-bit int                   Main script size
  32-bit int                   Largest mission script size
  16-bit int                   Number of mission scripts (120 in total)
  16-bit int                   Number of exclusive mission scripts (possibly 1 in III, 2 in VC)
  (Multi script array)         32-bit offset * number of mission scripts
(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)

^ Compiler-wise, the model names of level objects are picked directly from OBJS and TOBJ sections of the IDE files whose IDE Filename begins with DATA\ in gta_vc.dat.