From CloudModding OoT Wiki
Jump to: navigation, search
See also: Mod:Filesystem
NTSC 1.000007430?8000B140?
NTSC 1.100007430?8000B140?
PAL MQ00007170?8000AF90?

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.

Error Messages

Segment Alignment Error

  • セグメント境界をまたがってDMA転送することはできません (segment boundary exceeded, cannot transfer DMA)

This error occurs if a memory access attempts to read beyond the end bounds of a file defined in dmadata. This usually occurs due to novice modders being unaware of the need to update dmadata whenever injecting new files. This particular crash does not occur consistently in the Debug Rom due to the Crash Debugger's null pointer glitch, but a telltale sign of its occurrence is that on Project 64 1.6, the game will inexplicably crash the next time you load a new scene, regardless of what you do.

  • 圧縮されたセグメントの途中からはDMA転送することはできません (cannot transfer DMA from within compressed segment)

This error occurs when attempting to read from the middle of a compressed file.