OBD:Instance file format: Difference between revisions

added section to directly address the different engine versions, though I feel like this might be best on another page; improved wording of blank space/garbage data section
m (wording)
(added section to directly address the different engine versions, though I feel like this might be best on another page; improved wording of blank space/garbage data section)
Line 6: Line 6:
Files in GameDataFolder/ named "level[0-19]_Final.dat", together with ".raw" and sometimes ".sep" counterparts, contain the game data for Oni. These are called "instance files" internally, but a more common-sense name for them is level data files. The format described below was also used for the tool files which supplied the GUI for the in-game editor, however the retail Oni game application refuses to load tool files; for the story behind the tool files, see [[level0_Tools]].
Files in GameDataFolder/ named "level[0-19]_Final.dat", together with ".raw" and sometimes ".sep" counterparts, contain the game data for Oni. These are called "instance files" internally, but a more common-sense name for them is level data files. The format described below was also used for the tool files which supplied the GUI for the in-game editor, however the retail Oni game application refuses to load tool files; for the story behind the tool files, see [[level0_Tools]].


The level 0 files do not contain resources for a specific level but rather resources (instances) shared across all levels. Level 0 is loaded when the game starts and is never unloaded. All other level files, 1-19, are only loaded when their corresponding level starts and then unloaded when it ends. Oni can only hold two level files in memory concurrently. Thus, resources have to be duplicated on disk whenever a character class, sound effect, etc. occurs in more than one level. For instance, although there are only 2,380 unique sounds in the game, there are 7,386 sounds stored across all level data files.
The level 0 files do not contain resources for a specific level but rather resources (instances) shared across all levels. Level 0 is loaded when the game starts and is never unloaded. All other level files, 1-19, are only loaded when their corresponding level starts and then unloaded when it ends. Oni can only hold two level files in memory concurrently, thus resources have to be duplicated on disk whenever a character class, sound effect, etc. occurs in more than one level. For instance, although there are only 2,380 unique sounds in the game, there are 7,386 sounds stored across all level data files.
{{TOClimit}}
{{TOClimit}}
==Backwards and garbage data==
==Engine versions==
As mentioned, the game's developers used the in-game editor to create AIs, particles, etc. in a level. When one of these developers saved his work, the contents of the level, stored in his PC's RAM, were flushed directly to disk. Thus the structure of the .dat/.raw/.sep files reflects the way in which Bungie West chose to store levels in memory. So when we read the data in the files with a hex editor, we can see eccentricities such as blank space (coming from unused fields and byte-alignment padding) and garbage data (such as now-meaningless pointer values). [[OBD:Raw and separate file formats#Gaps|Further gaps]], mostly representing orphaned obsolete resources, add up to about 25 MB for the whole game.
There are three versions of Oni's engine found in released versions of the game. They are very similar but contain small differences which we sometimes need to note on this page and on the individual [[OBD:File types|OBD file type pages]]:
*Windows retail: This version of the engine can be identified as '''v1.0''' from [[Oni (folder)/readme.txt|its read-me]] but is often referred to as the "Windows" or "PC" engine. This version of the engine was used for all localized Windows releases translated into non-English languages as well.
*Mac retail/demo, Windows demo: This version can be identified as '''v1.1''' from [[Oni (folder)/Oni ReadMe|the Mac read-me]], and underwent another month of development after v1.0. It was also used for the Windows demo, but is sometimes referred to as the "Mac" engine. <!--[[OniX]] is built on this version of the engine.--> Its most obvious difference is the addition of .sep files to the GameDataFolder, but some templates were changed as well.
*PlayStation 2: This version also uses .sep files but makes additional changes to templates. It went through another 1-2 months of development after the Mac version and could possibly be thought of as v1.2, but is probably best understood as a fork of the v1.1 engine made for PS2 compatibility.


Additionally, because the levels were built on Intel-based machines, which use a little-endian architecture, sequences of bytes which represent numbers were written from least-significant to most-significant byte. [[wp:FourCC|FourCCs]] in the data are stored "backwards", such as "13RV" which is meant to be read "VR31", because Bungie defined those four bytes as a 32-bit integer, not a string, causing them to be written to disk in little-endian order.
==Blank space and garbage==
The structure of the level data files files reflects the way in which Bungie West chose to store levels in memory. So when we read the data in the files with a hex editor we can see eccentricities such as blank space coming from unused fields and byte-alignment padding, and garbage data such as now-meaningless pointer values and random RAM contents from uninitialized memory. There are also [[OBD:Raw and separate file formats#Gaps|gaps in the .raw/.sep files]], mostly representing orphaned obsolete resources, which add up to about 25 MB for the whole game.
 
==Backwards tags==
Because the levels were built on Intel-based machines, which use a little-endian architecture, sequences of bytes which represent numbers were written from least-significant to most-significant byte. [[wp:FourCC|FourCCs]] in the data are stored "backwards" (e.g. "13RV" which is meant to be read "VR31") because Bungie defined those four bytes as a 32-bit integer, not a string, causing them to be written to disk in little-endian order.


==File limits==
==File limits==
*Max level number: 127
*Max level number: 127
*Max number of instance files in GameDataFolder: 512 (Windows), 16 (Windows demo, Mac)
*Max number of instance files in GameDataFolder: 512 (Windows retail), 16 (Windows demo, Mac)
*Max number of simultaneously loaded instance files: 64
*Max number of simultaneously loaded instance files: 64
*Max number of instances in a file: 131071
*Max number of instances in a file: 131071
Line 26: Line 33:
{{OBD_Table_Header}}
{{OBD_Table_Header}}
{{OBDtr| 0x00 | uint64  | | 1F 27 DC 33 DF BC 03 00 | 0x0003BCDF33DC271F | Total template checksum (main indicator of engine compatibility):
{{OBDtr| 0x00 | uint64  | | 1F 27 DC 33 DF BC 03 00 | 0x0003BCDF33DC271F | Total template checksum (main indicator of engine compatibility):
*0x0003BCDF33DC271F (PC v1.0) - templates compatible with Windows retail engine
*0x0003BCDF33DC271F - templates compatible with v1.0 engine (Windows retail)
*0x0003BCDF23C13061 (PC v1.1) - templates compatible with Windows demo and Mac engines
*0x0003BCDF23C13061 - templates compatible with v1.1 engine (Windows demo and Mac)
*0x0003BA70A8DBAE11 (PS2) - templates compatible with PlayStation 2 engine
*0x0003BA70A8DBAE11 - templates compatible with PlayStation 2 engine
<!--*0x0000000000000000 (blank) - for use with [[OniX]] engine, which instead handle data versioning using the 0x3C field below-->
<!--*0x0000000000000000 (blank) - for use with [[OniX]] engine, which instead handles data versioning using the 0x3C field below-->
OniSplit's .oni files use PC 1.0 checksum by default and 1.1 checksums when holding data that is stored differently in the 1.1 format (SNDD, TXMP, AGQG, M3GM, IGSt, TSFT/TSGA, TRAM/TREX) }}
OniSplit's .oni files use PC 1.0 checksum by default and 1.1 checksums when holding data that is stored differently in the 1.1 format (SNDD, TXMP, AGQG, M3GM, IGSt, TSFT/TSGA, TRAM/TREX) }}
{{OBDtr| 0x08 | uint32  | | 31 33 52 56 | '13RV'    | .dat version (meant to be read as "VR31")<br>OniSplit's .oni files use '23RV' ("VR32") instead<!--<br>OniX's [[Oni (folder)|GDFX]] uses '33RV' ("VR33") to signify that the new data versioning system is in use--> }}
{{OBDtr| 0x08 | uint32  | | 31 33 52 56 | '13RV'    | .dat version (meant to be read as "VR31")<br>OniSplit's .oni files use '23RV' ("VR32") instead<!--<br>OniX's [[Oni (folder)|GDFX]] uses '33RV' ("VR33") to signify that the new data versioning system is in use--> }}
Line 256: Line 263:
{{OBDtr| 0x00 | res_id  | | 01 0B 04 00 | 1035 | instance descriptor index }}
{{OBDtr| 0x00 | res_id  | | 01 0B 04 00 | 1035 | instance descriptor index }}
{{OBDtr| 0x04 | lev_id  | | 01 00 00 06 |    3 | level number }}
{{OBDtr| 0x04 | lev_id  | | 01 00 00 06 |    3 | level number }}
{{OBDtr| 0x08 | ...    | | ...        | ...  | [[OBD:File types|type-specific data]]... }}
{{OBDtr| 0x08 | ...    | | ...        | ...  | type-specific data... }}
|}
|}