GCX

From mgsdevwiki
Revision as of 20:07, 24 March 2018 by SolidSnake11 (talk | contribs) (How file works)
Jump to: navigation, search

Script File.

Format Specifications

This file seems to be like script to determine some aspects of each level, menu... Usually will be two gcx files per level.
No header on it.
GCX files can be split into two different sections:

  • Functions
  • Bytecode

Functions

The first section of the file. It has a table with offsets to the data. The first 4 bytes gives info of the table, with this bytes we have a lot of info.

Bytes Info
ushort {2} Offset from the beginning of the table.
ushort {2} Offset of the end of the table.

The offsets obtained, we must add +4.

The table has two colums:

Bytes Info
ushort {2} Hashed name
ushort {2} Offset of the function

We can get the number of total rows with this formula: offset_of_the_end_of_the_table / 4

Once we get the entire table, we need to load the functions. The offset on the table are the offset after the table +4, so if the table ends at 0x100, and the offset of given functions starts at 0x200, we need to do: 0x100 + 0x200 + 4. If the given result is correct, the pointed byte will be "@". If not, we have a bad offset or "NOT SCRIPT DATA!!"

Bytecode

Immediately after the functions section, this hasn't table, but works in the same way. First two bytes indicates the initial offset and the next two bytes the end of this section. Until this text is written, always has one "@".

Structure

INFO
ushort {2} Offset where functions section starts +4
ushort {2} Offset where functions's TOC ends +4
Table of Content from Functions
ushort {2} Function name Hash
ushort {2} Absolute Offset after the end of TOC
Repeat ...
byte {\0\0\0\0} End of Table of Content
MORE TO COME

How file works

The gcx script starts with 0x40 (@). If not, there isn't a script data. Let's take a look on how it works.

0x40

The start of the script, the next two bytes are the size. Inside 0x40 could be 3 commands:

Command Usage
0x30 Unknown
0x60 Code
0x70 Call function
  • 0x30

Unknown, until this text is written, we don't find it in any case.

  • 0x60

All working code is writting after that. Like 0x40, the next two bytes are the size. Inside this are stored the instructions, followed by one byte with his size. It's supposed to be a hashed name.

    • 0x0d86
      if
    • 0x226d
      menu
    • 0x22ff
      mesg
    • 0x306a
      light
    • 0x430d
      delay
    • 0x5c9e
      Unknown
    • 0x64c0
      Unknown
    • 0x698d
      sound
    • 0x7d50
      Unknown
    • 0x9a1f
      start
    • 0x9906
      chara
    • 0xa242
      demo
    • 0xc091
      map
    • 0xc8bb
      load
    • 0xcc85
      pad
    • 0xe257
      Unknown
    • 0xe43c
      restart
    • 0xeee9
      camera
  • 0x70

Calling a function with given hash name.

Tools

Actually we are writting a tool to convert to readable text.

Others

Scripts being analyzed/defined

Camera

Script ID Info Hex Values
0x5061 (Pa) Object Initialize
0x506C (Pl) Camera Field Of Vision lenght (04 01 0E D8) 04 01 (Field Of Vision Initialize) 0E D8(Field Of Vision Lenght)
0x5077 (Pw) Field Of Vision width (04 01 01 2C) 04 (Init) 01 01 2C (Field Of Vision Width)
0x5078 (Px) Camera Rotation (04 01 00 E1) 04(Init) 01 (Rotate to the left "01 enabled") 00 (Rotate to the right "00 Disabled") E1 (Maxium Rotation possible for both sides)
0x5070 (Pp) Object Coordinates 0A(Pos Start)XX XX XX XX(X-X+"Left/Right")XX(Z+/Z-"Foward/Backwards) XX (Y+/Y-(Up/Down) XX XX (Z+/Z-"Foward/Backwards)
0x5064 (Pd) Camera Facing Direction (0A 01 01 00 01 0F 00 01 00 00) 0A 01 (Init) 01 [Camera Facing Direction (00=Up 01=Front 02=Down) 00 (Unknown) 01 0F 00 01 (Camera Model direction)
0x5068 (Ph) Unknown (No apparent changes when edited) (03 02 01)
0x5065 (Pe) Unknown (No Apparent changes when edited) (04 08 9F C3 00 00)

Sentry

Script ID Info Hex Values
0x5061 (Pa) Object Initialize
0x5072 (Pr) Sentry Way Path (03 02 10) 03 02 (Init) 10 (Waypath ID)

Item

Script ID Info Hex Values
0x5061 (Pa) Object Initialize
0x5070 (Pp) Position (Same as camera)
0x5072 (Pr) Item Type (03 02 00) 03 02 (Init) 00(Itemy type,00 Weapons,01 Items,02 Ammo Type)
0x5069 (Pi) Item ID (03 02 08) 03 02(Init) 08 (Weapon ID CHAFF GRENADE)
0x506E (Pn) Amount (04 01 00 0C) 04 01(start) 00 0C (Amount)
0x506D (Pm) TEXT (09 07 06 53 4F 43 4F 4D) 09 (Script lenght) 07 (Unknown) 06 (Text Lenght) 53 4F 43 4F 4D (SOCOM)

Door (triggers)

Script ID Info Hex Values
0x5065 (Pe) Extra data(?) 06(KeycardLVL) 31 0E 11 80 00 1E 02 11(ItemToOpenWith) 31 09 31 13 31 00

GCX Diff Analysis

gcx-analysis