Cartridges
A cartridge has the game's ROM, and often a chip for saves. The ROM, SRAM and FlashRAM are on the parallel bus (PI).
EEPROM and a clock are on the joybus, with the controllers. This page is about files, the
parallel bus, and how n64emu finds out what a game saves to. The code is crates/n64-cart.
It rests on pages of n64brew.dev that were saved on 2026-12-01: Parallel Interface, Memory map, Flash and ROM Header. Nothing here was
compared with a console, and no game was used to write or test it.
| Page | Used | Not used, and why |
| Parallel Interface | the bus, its 16 bits, open bus, writes to the ROM, and where domain 1's settings come from | the PI's registers, DMA and timing, which are the console's |
| Memory map | where saves and ROM are | its domain for the 64DD, which is another one on Parallel Interface. The rest is the console's |
| Flash | commands, modes, times and the two chips that its authors measured | the IDs of five other chips, the bus settings, and how several chips are mapped: the last is from the SDK, and the others have no origin |
| ROM Header | the usual first four bytes, the letter at 3Eh (from a count of files), and homebrew's own header | everything else, as its origin is not clear: some of it cites libultra |
Files
A file can have its bytes in three orders. The usual first four bytes tell them apart:
| Order | First bytes | Often called |
| the console's own | 80 37 12 40 | .z64 |
| each 16 bits the other way round | 37 80 40 12 | .v64 |
| each 32 bits the other way round | 40 12 37 80 | .n64 |
The file's name does not count. A game can have other first bytes, as the last three are settings for the bus. Then the order
is a guess, and the app can say so:
- An order fits when the first byte is 80h, as in all known commercial games, and the boot address at 8h is in the
8 MB of memory (80000000h to 807FFFFFh).
- The first of the three orders that fits is used, beginning with the console's own. When none does, it is the console's own,
as n64brew says.
A file needs at least 4 KB, which is the header and the boot code. There is no other limit. If it is in one of the two other
orders and ends inside 32 bits, the missing bytes are taken as 0 before they are turned around (a guess). All of the
data, in the console's order, is what the game's id is made from. So it is the same for all three files.
| Where | What | From |
| 0 to 3h | the bus settings for domain 1 | Parallel Interface says that the PIF's boot program takes all four from there, and that official ROMs have 64, 18, 7 and 3. 80 37 12 40 shows where each is |
| 8h | the boot address, only for the byte order | PIF-NUS |
| 34h to 3Fh | what homebrew says of itself, if 3Ch has "ED" | below |
| 3Eh | a letter for the region, only to choose the console's region | a count of files |
| 40h to FFFh | the boot code (IPL3). It is copied and never looked into | PIF-NUS |
Not used: the ROM Header page gives no origin for the title, the game's code and the version, and cites libultra for the clock rate and
the version of libultra. The checksum at 10h is for the boot code itself. No field is used to recognise a game.
What homebrew says
The "Advanced Homebrew ROM Header" is homebrew's own convention. The page says that EverDrive introduced it and that the
community extended it, and names no other source for that section. It is what a developer declared:
what the game saves to, whether it uses the clock, which regions and controllers it is for, and what it does with the Expansion
Pak. 768K of SRAM with banks and 1M of SRAM can be declared, but are not emulated. n64emu then finds out for itself what
the game saves to.
The bus
The PI puts an address on the bus, and then reads or writes 16 bits at a time. The cartridge counts up by itself.
During a DMA, the PI puts a new address on the bus at each page of its settings. So read and write get the last address that
was put on the bus, and how many bytes were moved since. Nothing is remembered in between, so the console can move
that stretch in any pieces, and the data and state come out the same. A test does that with random pieces.
For example, a game reads 600 bytes from 10000100h by DMA, with pages of 512 bytes:
- The PI puts 10000100h on the bus. The next page begins at 10000200h, so it moves 256 bytes.
- At 10000200h it puts that address on the bus, and moves the other 344 bytes.
- The console can ask for these in blocks, such as 128 bytes each. The second block of step 1 is read with the address
10000100h and the offset 128.
| Address | What |
| 05000000h to 07FFFFFFh | the 64DD. It is not the cartridge's, and is not emulated yet. open_bus gives what is read there without one |
| 08000000h to 0FFFFFFFh | saves: SRAM or FlashRAM |
| 10000000h and up | ROM |
Where nothing answers, a read gives the low 16 bits of the last address on the bus, again and again. That is true for
direct reads and for DMA. Writes to the ROM or to nothing do nothing (Parallel Interface).
Guesses about the ROM:
- Past its end, nothing answers, and it does not repeat.
- It goes on counting across its own pages. The Flash page says that ROM chips have a limit of 512 bytes and SRAM one of 32 KB,
but not what happens there, or who measured that. It only matters if a game sets larger pages.
- If it ends inside 16 bits, the missing byte is 0.
SRAM
It has 32 KB, at 08000000h. Above that, nothing answers, and writes do nothing (a guess). So a write to a place that
we do not understand can never overwrite a save. It is counted. New memory has FFh in it (a guess).
SRAM of 768K has banks, and no allowed source says where they are. A game that uses it would show as writes
outside of the chip, in Counts::outside_writes, with the lowest and highest address.
FlashRAM
It has 128 KB, in 8 sectors of 128 pages, with 128 bytes each. A game writes a 32-bit command to 08010000h, and that
changes what it reads at 08000000h:
| Command | What it does |
F0000000 | reads give the memory. This is so after power-on |
E1000000 | reads give the chip's ID, 8 bytes |
D2000000 | reads give the status, as the low byte of each 16 bits |
B4000000 | reads and writes are for a buffer of 128 bytes, which starts as all FFh |
A5000ppp | programs page p with the buffer, and empties the buffer |
4B000ppp, 3C000000 | the next erase is for the sector with page p, or for the whole chip |
78000000 | erases. Without one of the two before it, it does nothing |
Bits 10 to 23 of the commands with a page are ignored. A program or an erase changes to the status by itself:
| Bit | Status |
| 7 | ready |
| 3, 2 | the last erase, and the last program, worked |
| 1, 0 | it is erasing, or programming |
The Flash page tells what its authors saw two chips do, and these two are here. A game finds out by the ID which one it has:
| MX29L1100 (the default) | MN63F8MPN |
| Addresses count | 16-bit words | bytes |
| To program, and to erase | 3.5 ms, 85 ms | 300 us, 280 ms for a sector and 300 ms for all. The page has "less than about" in front of these |
| A read of more than 8 bytes of the ID | goes on from its start | repeats its last 16 bits |
| An ID read at 08010000h | gives the ID too | gives open bus until the next command |
| A write to the buffer | puts the value there | only clears bits |
| Clearing the status | a 0 written to address 0. Both "worked" bits are then 1 | any write. They are then 0 |
On both, a status read at 08010000h gives open bus, and so does each read after it until the next command. A read that goes on past 256 pages
continues at their start. The memory is kept in the order of its bytes, which is the same for both chips.
Why a chip is the default is a guess: the page calls those that count words the older ones. A game cannot know
a chip that came after it, so an old one fits more games. These are guesses as well:
- Programming and erasing always work. The memory changes when they begin, and what reads give while the chip is busy is not known.
- Programming a page that was not erased clears more bits. While the chip is busy, other such commands are ignored.
- Any other command between the choice of what to erase and the erase takes that choice away.
- An address above the buffer is in the buffer again, and one above 0801FFFFh is nothing.
Not emulated: the page says that the MX29L1100 can need two writes before it gives the ID or the status, and that its first status read
has 16 bits of what was there before. When that happens is not clear. The page also has IDs of five other chips and bus settings, and does not
say where they are from. They are not used.
What a game saves to
The console does not know this, as the chips are simply there. A file has only the ROM. n64emu has no list of games. It looks at
what the game does, and the player can always choose.
Who decides
- The player's choice wins, and is kept with the save.
- Then it is what a homebrew game declares.
- Then it is what was found before, and kept with the save.
- Otherwise it is found out while the game runs. This only adds chips, and never takes one away.
setup puts these together when the console is turned on. Its result is an input, like the buttons, so a movie or a
test has to fix it.
What shows what
| The game does this | It has |
| writes a FlashRAM command to 08010000h, with nothing in its unused bits | FlashRAM, also when SRAM was found before |
| writes anything else to the first 32 KB of the saves | SRAM |
| reads or writes a block of the EEPROM | EEPROM |
| does so with a block above 63 | EEPROM of 16K |
Asking what is on the joybus shows nothing, and neither do reads on the parallel bus.
When one of them was written to and nothing was found on the other bus, the other one looks empty the next time that the console is turned on.
Reading is not enough for that. A game that read its EEPROM keeps it, also when it wrote to
something on the parallel bus. Otherwise it could lose the chip that it saves to. What looks empty on
the parallel bus is found again when the game writes there.
What a game could see
A real cartridge has its chips from the start, so none of this is how the console behaves. Without a choice or
a declaration, a game could see:
| What it sees | When | Who could notice |
| an EEPROM that its cartridge does not have, of 4K | at first | a game that checks that there is none, or that uses any that it finds |
| 4K where its cartridge has 16K | until it uses a block above 63 | a game that looks for 16K. It may then never use it, and cannot save. The player has to choose 16K |
| 16K where its cartridge has 4K | after it used a block above 63 | a game that expects the first 64 blocks to repeat |
| FFh on the parallel bus instead of open bus | until something is found, and also later when nothing is | a game that checks that there is no chip |
| SRAM that its cartridge does not have | after its first write there | a game that writes there to check for a chip |
| FFh in new SRAM | until it is written to | nobody should rely on it, as a real chip can have anything |
| open bus first, and then SRAM or FlashRAM | it saved to EEPROM before, and writes to the parallel bus only now | a game that read there before |
| SRAM that becomes FlashRAM | when a command comes after another write | a game with SRAM that writes such a value there itself |
An unknown chip on the parallel bus gives FFh, as both empty kinds do here. So what a game read before
its first write is still the same after it, for either kind.
How often this happens is not known yet. Counts in both crates counts each of these cases since power-on.
They are in no state and in no battery data.
No save is lost
- Each chip has its own memory. The battery data has the memory of each one that was ever written to, whatever
the type is now. If the type was wrong, choosing the right one brings its data back. A test changes the type and changes it back.
- An EEPROM of 4K is the first 512 bytes of the one of 16K, so nothing moves when it grows.
- The EEPROM is in
n64-pif's battery data. SRAM, FlashRAM and the choice are in n64-cart's. Both have a version,
and newer builds read older ones. Memory that is shorter than a chip is filled up with FFh.
- If the data is damaged, from a newer build, or larger than the chip, it is refused and nothing changes. The app must then
not write over that file.
- A savestate has the chips' memory in it. So before it loads one, the app keeps a copy of the save. A state does not
change the player's choice. After it is loaded, the counter of changes shows that the save is another one.
What is missing
- SRAM of 768K with banks, SRAM of 1M, and the 64DD.
- FlashRAM's quirks that are listed above, and its other chips.
- Importing or exporting save files of other programs.
- Every guess on this page needs a measurement. Which chip a game expects also needs a count with real games.