Binary Files: Difference between revisions
Created page with "In Sonic Adventure 1/2 and its ports most assets are compiled into the game's executable or other binary files. The formats of these files can differ depending on the platform and the version of the game. SA Tools allow to rip ("split") the assets from binary files automatically for several supported titles. See the [SA-Tools-Hub SA Tools Hub] for getting started with creating projects which split content out of the currently supported titles and versions. You can also w..." |
No edit summary |
||
| (4 intermediate revisions by one other user not shown) | |||
| Line 1: | Line 1: | ||
In Sonic Adventure 1/2 and its ports most assets are compiled into the game's executable or other binary files. The formats of these files can differ depending on the platform and the version of the game. SA Tools allow to rip ("split") the assets from binary files automatically for several supported titles. See | In Sonic Adventure 1/2 and its ports most assets are compiled into the game's executable or other binary files. The formats of these files can differ depending on the platform and the version of the game. SA Tools allow to rip ("split") the assets from binary files automatically for several supported titles. See [[SA Tools Hub]] for getting started with creating projects which split content out of the currently supported titles and versions. You can also work with binary files directly. | ||
To open a level, a model or an animation stored in a binary file, you need to know several things, which are explained below. | To open a level, a model or an animation stored in a binary file, you need to know several things, which are explained below. | ||
| Line 7: | Line 7: | ||
If the file has a PRS extension, it is compressed. You can still open the file directly in the tools, but if you want to inspect it in a HEX editor you will need to decompress it first. Some REL files in SADX Gamecube are also compressed. You can tell the REL file is compressed by the presence of the <code>SaCompGC</code> ASCII string near the beginning of the file. | If the file has a PRS extension, it is compressed. You can still open the file directly in the tools, but if you want to inspect it in a HEX editor you will need to decompress it first. Some REL files in SADX Gamecube are also compressed. You can tell the REL file is compressed by the presence of the <code>SaCompGC</code> ASCII string near the beginning of the file. | ||
You can use ArchiveTool from command line tools to decompress PRS and REL files. If you use SAMDL to open models from these files, they will be decompressed automatically. | You can use ArchiveTool from [[Command Line Tools|command line tools]] to decompress PRS and REL files. If you use [[SAMDL]] to open models from these files, they will be decompressed automatically. | ||
=== Address and Key === | === Address and Key === | ||
The tools need the address (offset) of the level or model in the binary file to be able to open it. In addition, a binary key is needed. The binary key is the address where the binary file is loaded in memory in the actual game. Some of the keys are listed below: | The tools need the address (offset) of the level or model in the binary file to be able to open it. In addition, a binary key is needed. The binary key is the address where the binary file is loaded in memory in the actual game. Some of the keys are listed below: | ||
==== Sonic Adventure ==== | |||
{| class="wikitable" | {| class="wikitable" | ||
|- | |- | ||
| Line 58: | Line 60: | ||
| Other files | | Other files | ||
| C900000 | | C900000 | ||
| | |} | ||
| File (SA2 DC) | |||
==== Sonic Adventure 2 ==== | |||
{| class="wikitable" | |||
!File (SA2 DC) | |||
| Key | | Key | ||
|- | |- | ||
| SA2 STG files | | SA2 STG files | ||
| Line 70: | Line 72: | ||
| Event (EV_) files | | Event (EV_) files | ||
| C600000 | | C600000 | ||
|} | |||
==== Other games ==== | |||
{| class="wikitable" | |||
|'''Other Files''' | |||
|'''Key''' | |||
|- | |- | ||
| | |sonic.exe (SADX) | ||
| | |400000 | ||
|- | |- | ||
| | |DLL files | ||
| | |10000000 | ||
|- | |- | ||
| | |1ST_READ.BIN (Dreamcast) | ||
| | |8C010000 | ||
|- | |- | ||
| | |REL files (Gamecube) | ||
| | |C900000 | ||
|- | |- | ||
|SonicApp.exe (X360) | |||
|82000000 | |||
| SonicApp.exe (X360) | |||
| 82000000 | |||
|} | |} | ||
SA Tools use a fixed key of <code>0xC900000</code> for fixing REL pointers. Use this key for any REL file from any game. | SA Tools use a fixed key of <code>0xC900000</code> for fixing REL pointers. Use this key for any REL file from any game. | ||
=== Start offset === | === Start offset === | ||
In SADX X360, the actual data starts at <code>0xC800</code> rather than <code>0x0</code>. The "Start Offset" field in SAMDL can be used to specify where the data starts without changing the key. | In the [[SADX X360 prototype with symbols]], the actual data starts at <code>0xC800</code> rather than <code>0x0</code>. The "Start Offset" field in [[SAMDL]] can be used to specify where the data starts without changing the key. | ||
=== Byte order === | === Byte order === | ||
| Line 105: | Line 107: | ||
* Some chunk models in SA2B Gamecube and SA2 PC (such as Chao Garden trees) store vertex colors as RGBA (SA2B) or ARGB (SA2 PC). | * Some chunk models in SA2B Gamecube and SA2 PC (such as Chao Garden trees) store vertex colors as RGBA (SA2B) or ARGB (SA2 PC). | ||
Use the "Reverse" checkbox in SAMDL when you want to open such models. | Use the "Reverse" checkbox in [[SAMDL]] when you want to open such models. | ||
=== Level and Model Formats === | === Level and Model Formats === | ||
| Line 111: | Line 113: | ||
There are several level and model formats used in these games. Some games use more than one model format. Here is a brief overview: | There are several level and model formats used in these games. Some games use more than one model format. Here is a brief overview: | ||
==== Basic format (SA1 format) ==== | |||
This is the Ninja Basic format described in | This is the Ninja Basic format described in [[Katana SDK]]. It's used in the following games: | ||
* SA1 Dreamcast | * SA1 Dreamcast | ||
* SADX Gamecube, including the prototypes (colors are stored as RGBA and UVs are stored as VU) | * SADX Gamecube, including the prototypes (colors are stored as RGBA and UVs are stored as VU) | ||
| Line 119: | Line 121: | ||
* SA2 PC (collision only) | * SA2 PC (collision only) | ||
==== Basic+ format (also known as "BasicDX" or "SADX" format) ==== | |||
This is a variation of the Basic format that adds several fields to the meshset and model structures. It's used in the following games: | This is a variation of the Basic format that adds several fields to the meshset and model structures. It's used in the following games: | ||
* SADX PC (2004) | * SADX PC (2004) | ||
| Line 128: | Line 130: | ||
Although this format is also known as "BasicDX", the Gamecube version of SADX uses the regular Basic format instead. The "DX" format only applies to the 2004 PC port and its derivatives. | Although this format is also known as "BasicDX", the Gamecube version of SADX uses the regular Basic format instead. The "DX" format only applies to the 2004 PC port and its derivatives. | ||
==== Chunk format ==== | |||
This is another model format from | This is another model format from [[Katana SDK]]. It's used in the following games: | ||
* SA2 Dreamcast | * SA2 Dreamcast | ||
* SA2B | * SA2B | ||
* SA2 PC | * SA2 PC | ||
* SADX (Cream cameo and Chao related models only | * SADX (Cream cameo and Chao related models only | ||
==== Ginja format (also known as "GC" or "SA2B" format) ==== | |||
This is a proprietary format used in Billy Hatcher and some other Gamecube titles. It's used in the following games: | This is a proprietary format used in Billy Hatcher and some other Gamecube titles. It's used in the following games: | ||
* SA2B | * SA2B | ||
| Line 143: | Line 145: | ||
=== Data structures === | === Data structures === | ||
==== Model (Attach) ==== | |||
This is <code> | This structure contains the model radius for clipping as well as pointers to vertex and material data. The exact layout of the structure is different depending on the model format. See <code>NJS_MODEL</code> for Basic, <code>NJS_MODEL_SADX</code> for Basic+, <code>NJS_CNK_MODEL</code> for Chunk. | ||
==== Object ==== | |||
This is <code> | This is <code>NJS_OBJECT</code> from [[Katana SDK]]. This structure contains a pointer to the Model (Attach) structure, as well as object flags and position, rotation and scale data. Objects support a node-based hierarchy so they can have "child" and "sibling" objects. | ||
==== Motion ==== | |||
This is <code>NJS_ACTION</code> from Katana SDK. It consists of a pointer to an <code> | This is <code>NJS_MOTION</code> from [[Katana SDK]]. It contains node animation data. | ||
==== Action ==== | |||
This is <code>NJS_ACTION</code> from [[Katana SDK]]. It consists of a pointer to an <code>NJS_OBJECT</code> and another pointer to an <code>NJS_MOTION</code>''.'' | |||
== Finding assets in binary files when the address is unknown == | == Finding assets in binary files when the address is unknown == | ||
If you know the binary key but don't know the address of the asset you're looking for, you can use the Scanner in [ | If you know the binary key but don't know the address of the asset you're looking for, you can use the Scanner in [[Data Toolbox]] to scan the binary file and extract assets from it. | ||
{{SAToolsNavbox}} | |||
Latest revision as of 23:33, 29 October 2025
In Sonic Adventure 1/2 and its ports most assets are compiled into the game's executable or other binary files. The formats of these files can differ depending on the platform and the version of the game. SA Tools allow to rip ("split") the assets from binary files automatically for several supported titles. See SA Tools Hub for getting started with creating projects which split content out of the currently supported titles and versions. You can also work with binary files directly.
To open a level, a model or an animation stored in a binary file, you need to know several things, which are explained below.
Compression
If the file has a PRS extension, it is compressed. You can still open the file directly in the tools, but if you want to inspect it in a HEX editor you will need to decompress it first. Some REL files in SADX Gamecube are also compressed. You can tell the REL file is compressed by the presence of the SaCompGC ASCII string near the beginning of the file.
You can use ArchiveTool from command line tools to decompress PRS and REL files. If you use SAMDL to open models from these files, they will be decompressed automatically.
Address and Key
The tools need the address (offset) of the level or model in the binary file to be able to open it. In addition, a binary key is needed. The binary key is the address where the binary file is loaded in memory in the actual game. Some of the keys are listed below:
Sonic Adventure
| File (SA1 DC) | Key |
|---|---|
| Level (STG) files | C900000 |
| ADV0100.BIN | C920000 |
| ADV0130.BIN | C920000 |
| AL_GARDEN00.BIN | CB80000 |
| AL_GARDEN01.BIN | CB80000 |
| AL_GARDEN02.BIN | CB80000 |
| Cutscene (EV_) files | CB80000 |
| AL_RACE.BIN | CB80000 |
| ADVERTISE.BIN | 8C900000 |
| MOVIE.BIN | 8CEB0000 |
| TIKAL_PROG.BIN | CB00000 |
| S_SBMOT.BIN | CB08000 |
| Other MOT files | CC00000 |
| Other files | C900000 |
Sonic Adventure 2
| File (SA2 DC) | Key |
|---|---|
| SA2 STG files | 8C500000 |
| Event (EV_) files | C600000 |
Other games
| Other Files | Key |
| sonic.exe (SADX) | 400000 |
| DLL files | 10000000 |
| 1ST_READ.BIN (Dreamcast) | 8C010000 |
| REL files (Gamecube) | C900000 |
| SonicApp.exe (X360) | 82000000 |
SA Tools use a fixed key of 0xC900000 for fixing REL pointers. Use this key for any REL file from any game.
Start offset
In the SADX X360 prototype with symbols, the actual data starts at 0xC800 rather than 0x0. The "Start Offset" field in SAMDL can be used to specify where the data starts without changing the key.
Byte order
All Dreamcast and most PC files are Little Endian. Gamecube, X360 and PS3 files are Big Endian. Some files in SA2 PC are Big Endian.
"Reversed" byte order for colors and UVs
- In SADX Gamecube basic models, material and vertex colors are stored as RGBA as opposed to the regular Big Endian order of ARGB or the regular Little Endian order of BGRA.
- In SADX Gamecube basic models, UVs are stored in the Little Endian order: VU.
- Some chunk models in SA2B Gamecube and SA2 PC (such as Chao Garden trees) store vertex colors as RGBA (SA2B) or ARGB (SA2 PC).
Use the "Reverse" checkbox in SAMDL when you want to open such models.
Level and Model Formats
There are several level and model formats used in these games. Some games use more than one model format. Here is a brief overview:
Basic format (SA1 format)
This is the Ninja Basic format described in Katana SDK. It's used in the following games:
- SA1 Dreamcast
- SADX Gamecube, including the prototypes (colors are stored as RGBA and UVs are stored as VU)
- SA2 Dreamcast (collision only)
- SA2B (collision only)
- SA2 PC (collision only)
Basic+ format (also known as "BasicDX" or "SADX" format)
This is a variation of the Basic format that adds several fields to the meshset and model structures. It's used in the following games:
- SADX PC (2004)
- SADX PC (Steam)
- SADX X360
- SADX PS3
Although this format is also known as "BasicDX", the Gamecube version of SADX uses the regular Basic format instead. The "DX" format only applies to the 2004 PC port and its derivatives.
Chunk format
This is another model format from Katana SDK. It's used in the following games:
- SA2 Dreamcast
- SA2B
- SA2 PC
- SADX (Cream cameo and Chao related models only
Ginja format (also known as "GC" or "SA2B" format)
This is a proprietary format used in Billy Hatcher and some other Gamecube titles. It's used in the following games:
- SA2B
- SA2 PC
Although this format is sometimes called "GC", SADX Gamecube doesn't use it. SA2B and SA2 PC use both Chunk and Ginja models, as well as Basic models for level collision. In SA2B and SA2PC the levels can also be in the old "SA2" format, which doesn't use Ginja models, and in the new "SA2B" format, which uses both Chunk and Ginja models.
Data structures
Model (Attach)
This structure contains the model radius for clipping as well as pointers to vertex and material data. The exact layout of the structure is different depending on the model format. See NJS_MODEL for Basic, NJS_MODEL_SADX for Basic+, NJS_CNK_MODEL for Chunk.
Object
This is NJS_OBJECT from Katana SDK. This structure contains a pointer to the Model (Attach) structure, as well as object flags and position, rotation and scale data. Objects support a node-based hierarchy so they can have "child" and "sibling" objects.
Motion
This is NJS_MOTION from Katana SDK. It contains node animation data.
Action
This is NJS_ACTION from Katana SDK. It consists of a pointer to an NJS_OBJECT and another pointer to an NJS_MOTION.
Finding assets in binary files when the address is unknown
If you know the binary key but don't know the address of the asset you're looking for, you can use the Scanner in Data Toolbox to scan the binary file and extract assets from it.
| General Tools | SALVL • SAMDL • SAFontEdit • Texture Editor • Data Toolbox • SA Tools Hub |
|---|---|
| Sonic Adventure (DX) Tools | SADXTweaker2 • SADXSndSharp • SASave • PL Tool • VMS Editor |
| Sonic Adventure 2 (Battle) Tools | SA2 Event Viewer • SA2 Cutscene Text Editor • SA2 Message File Editor • SA2 Stage Select Editor • SA2 Cutscene Effect Editor • SA2 Light/Fog Editor |
| Other | Command Line Tools • Working with Binary Files |