Jump to content

OBD:Instance file format: Difference between revisions

→‎Backwards and garbage data: let's cut to the chase
(major wording)
(→‎Backwards and garbage data: let's cut to the chase)
Line 13: Line 13:
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, which is backwards from how we typically write numbers. When Macs, which were big-endian at the time due to their PowerPC architecture, would read these files, they then had to flip each sequence of bytes in memory before they could be understood.
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, which is backwards from how we typically write numbers. When Macs, which were big-endian at the time due to their PowerPC architecture, would read these files, they then had to flip each sequence of bytes in memory before they could be understood.


An exception to this backwards-writing rule is when strings of ASCII characters were written to disk. These are not numbers and thus are not subject to endianness, so they retain their left-to-right order. Now, this may not seem to be the case as you continue reading below. The first two strings of characters which you'll see are "13RV" and "TBUS", which are meant to be read "VR31" and "SUBT". The reason these four-character strings are backwards is that Oni stored them as a 32-bit integer. Any sequence of four characters can be represented as such a number. Writing the integer 1,448,227,633 to disk results in the bytes 0x31, 0x33, 0x52, and 0x56, which produce the ASCII codes for '1', '3', 'R' and 'V' (the computer would have had to be big-endian to be able to naturally write them in the left-to-right order we would prefer to see). This practice of Bungie's provided a combination of convenient storage of a tag in memory as a number, and human-readability when organizing game assets by tag.
An exception to this backwards-writing rule is when strings of ASCII characters were written to disk. These are not numbers and thus are not subject to endianness, so they retain their left-to-right order. However, four-character codes in the data are backwards, such as "13RV", which is meant to be read "VR31". That's because Oni stored them as a 32-bit integer, not a string, and thus they were written to disk in little-endian order.


==File limits==
==File limits==