Filesystem

From CloudModding OoT Wiki
Jump to: navigation, search
See also: Mod:Filesystem

Ocarina of Time, Majora's Mask, and all of their seperate versions & ports use an identical filesystem. The filesystem helps the game differentiate between compressed and decompressed data, and keep the files in order. It also allows for quick editing should something be misplaced. The filesystem (rather the file offset table part) begins right after the ROM creator and build date. If you would like to see for yourself, you can find the filesystem at the following offsets:

Debug ROM OoT NTSC 1.0 MM (U) MM (J)
0x012F40 0x007400 0x01A4D0 0x01C0E0

If you, for some reason, have a different version, just search for "zelda@", and with any luck, you'll find it! An interesting note: the filename table refers to the file offset table as "dmadata". The file offset table also refers to itself, which is quite extraordinary.

File Offset Table

For a listing of files within a specific build, see File List.

The file offset table begins exactly 0x30 bytes from the creator/build date. The first entry of the file table is always the location 0x00000000 - 0x00001060, which is referred to as "makerom" in the filename table. This is not related to this article, but that file it the header for the N64 ROM.

One entry for a file is 16 bytes (or 0x10 bytes; one line in a hex editor). You can split this up into 2 parts to find out the two offset pairs, and then you can split those two pairs in half to find the start/end offset for said pair. Here is a tiny diagram:

Virtual Address (VRom) Physical Address (Rom)
Start End Start End
00000000 00000000 00000000 00000000

The virtual (rom) address assigns a file a virtual location, and sets the file's size. This address is used to identify and fetch a file within the rom, regardless of whether or not the file is compressed. In a fully decompressed rom, a file's virtual address will be the same as it's physical address. The physical (rom) address points to where the file is actually stored in rom. A physical address either points to an uncompressed file, a file compressed with the Yaz compression algorithm, or no file at all (Majora's Mask).

  • If a file is compressed, the start and end physical addresses will be set to the start/end of the compressed file in the rom.
  • If a file is not compressed, the start physical address will point to rom, but the end address will be 0.
  • If a file does not exist, both start and end physical addresses will be FFFFFFFF.

Consider this excerpt from the NTSC 1.0 version:

Offset 0x0001C1F0 in NTSC 1.0
Virtual Address (VRom) Physical Address (Rom)
00A65000 00A86DE0 00A40A60 00000000
00A87000 00B8AD30 00A62840 00AFD890
00B8AD30 00B9DA40 00AFD890 00B07590

File 00A65000 is decompressed, as it's physical end address pointer is set to 00000000. Since the size of the virtual file is the same as the one mapped in ROM, the last pointer can be set to 00000000 without losing information. In short: the game calculates the size of the block via the virtual address (when dealing with decompressed data). However, the physical end address address for files 00A87000 and 00B8AD30 is non-zero, meaning that these files are compressed, and that their physical start addresses points to a Yaz block in the ROM, which is then decompressed and mapped to the location in the first offset pair.

Furthermore, note that the physical start address is not the same as the virtual start in either case.

Filename Table

Since the Debug ROM is meant for debugging the game, the developers were nice enough to leave all of the filenames for OoT's resources intact. They can be found in the main code block or at offset 0xBE80. The filenames are separated by 1-4 null (0x00) bytes (for four-byte alignment), and they match up perfectly with the data referenced by the file offset table. The Debug ROM is the only Zelda 64 game to have a complete file listing. Majora's Mask has one too (following a similar format), but it only lists the names of the scene files, and some of the scenes it refers to are removed.