emuforge

Controllers and the PIF

The PIF is a small chip that starts the console, and talks to the controllers and to some chips in the cartridge. It has 64 bytes of RAM, which a game writes to and reads through the serial bus (SI). This page is about that RAM, the joybus, what is connected to it, the reset button, and how a game starts without any of the maker's programs. The code is crates/n64-pif. The time that the SI itself takes is the console's.

What it rests on

SourceUsed for
n64brew.dev's PIF-NUS and CIC-NUS, saved on 2026-12-01frames, commands, the start, the reset, seeds and checksums. These two pages rest in part on the chips' own programs. The project's owner allowed facts from the pages. No listing was read, and none of their links to programs was followed
n64brew.dev's Joybus Protocol, with its picture of a controller's reply (only for the order of the buttons)commands, bits and times, devices, and checksums. Its references are for other consoles, and for the address checksum
n64brew.dev's Serial Interface, Parallel Interface, Controller Pak and Rumble Pakreads of the RAM, the bus settings, and the paks' hardware
libdragon's own boot code (IPL3), Unlicense, commit f26e1c16145e4d6ad7e391e1306513d684083c02where its boot code starts, and which registers have the flags and the seed. No code of it is used
1,189 of the owner's fileswhich letter goes with which region
n64brew.dev's ROM_Header, RDRAM and RDRAM Interface, saved on 2026-12-01our own start: the copy to the entry, the memory's size at 318h or 3F0h, and how RDRAM is set up (the RDRAM page's steps, which the owner allowed). Of ROM_Header, only the boot address was used; its other rows name libultra
n64emu's own runs of the 6102's, 6103's and 6106's boot code, compared by names and hashesthe rest of our own start

Little here was compared with a console: only Status at the start of a boot code, by our program 2 (below). Games were run to find the chip, and to find our own start. What no source says is called a guess below and in the code.

Not used: programs and dumps of the PIF, the CIC and the maker's boot code, and what the Controller Pak's page says about the SDK. What is used of the paks' pages is about their hardware.

Each page, fact by fact

PageUsedNot used, and why
PIF-NUScommands, frames, escape codes, error bits, the gaps of 7 and 520 us, seeds, checksums, the order of the start, the 5 seconds, the resetthe checksum calculations of IPL2 and IPL3, which are only links to programs. What checks a game's data (the "magic" values), as the boot code does that itself
CIC-NUSwhich chips there are and how common, the seed being the same twice, the answer of chips other than the 6105how the 6105 answers: only a link. How its signals look on the wire: no game sees that. How it was read out
Joybus Protocolcommands 00h to 08h and FFh, the times of the bits, the order of the buttons, EEPROM, the clock, both checksumscommands of devices that are not here. Three bytes of 0 for 06h without a clock: they do not fit its general rule
Serial Interfacewhat each access reaches, the locked ROM, and that a read of 64 bytes runs the joybus firstthe SI's registers, which are the console's. The iQue
Parallel Interfacewhere domain 1's settings come fromthe rest is for cartridges
Controller Pak32 KB, and nothing from 8000h up, from its pins and chipsbanks: their map is next to what the SDK does, so their origin is not clear. The file system: what it says of it is from the SDK, and it is not needed
Rumble Pakits two areas, and the value that unlocks it. It names no originJoybus Protocol's address for the motor, which is a different one
RDRAMnothinghow the boot code sets up RDRAM: it runs as it is, so the crates do not need that. The pseudocode of a libultra function was skipped

The RAM and its commands

The PIF's 2 KB of addresses repeat. Up to 7BFh is its ROM, which is locked once a game runs: it reads as 0, and writes do nothing. The RAM is from 7C0h on, and its last byte is for commands. The PIF always looks at it. It does what a bit says, and clears the bit. Here, that happens at once, as no page says how long it takes.

BitBefore the game ended the bootAfter that
01htake a joybus frame apart
02ha challenge for the security chip
04ha long wait in each exchange
08hthe boot has endedwith 04h, no stop bit

The PIF's ROM and the checksum commands (10h, 20h and 40h) are for its own boot program, so they were used before the game's boot code begins. Here, they do nothing (a guess).

A frame or a challenge from before the boot ended is not looked at until the game ends it. That is a guess, as the page has two separate tables of commands. Reads of 64 bytes do not run the joybus before that either. If it is wrong, a game that uses the joybus that early gets no answers. It finds its own frame as it was, with the bit still set. It could wait for the bit, or think that nothing is plugged in. Counts counts both cases, as a game that does this would show that the guess is wrong.

From a frame to the buttons

A game reads a controller like this:

  1. It writes 64 bytes: 01 04 01 00 00 00 00 FE, then zeros, and 01h as the last byte. That is: send 1 byte, get 4 back, send command 01h, room for the answer, and the end of the frame.
  2. The PIF takes the frame apart, and remembers where each channel's exchange is. It clears the 01h. Nothing is sent yet.
  3. The game reads 64 bytes by DMA. Now the PIF runs each channel, from channel 4 down to channel 0. It sends 01h to the controller, which answers with 4 bytes.
  4. Those 4 bytes are put into the RAM, the PIF answers the SI, and the RAM is copied.

Each further read by DMA does steps 3 and 4 again. A read of a word never does, and it gets only what is in the RAM. read_block gives the data, and how long the PIF takes for step 3. The buttons are asked for at the start of the read (a guess: on the console, that is a little later), in the order of the channels. A movie can have an answer for each time that it is asked. Its place in that movie is outside of this crate, so a state has to have it as well.

The frame

Channels 0 to 3 are the controllers, and channel 4 is the cartridge. In place of the first size, a byte can be one of these codes:

CodeWhat it does
00hnothing for this channel, and on to the next one
FDhthe reset signal for this channel, for 1 ms
FEhthe end
FFhnothing. It is skipped, and the channel stays the same

After that come the two sizes, what is sent, and room for the answer. Only the lower 6 bits are a size. The PIF looks at the others when it runs the frame: bit 7 of the first skips the exchange, and bit 6 sends the reset signal. In the second, it clears both bits and then puts in the errors. 80h is for no device, and 40h for no answer or for too short a one. An exchange that does not fit is left out, with all that follow.

Guesses:

  • The frame ends before the command byte, so it has 63 bytes.
  • What a device does at the reset signal is not known, so it does nothing. With both bits set in the first size, it is a reset.
  • If an answer is too short, the bytes that came are there. What is too long is not read. Without room for an answer, there is no error.
  • A command that is too short is not answered, and extra bytes after it are ignored. A device also answers without the console's stop bit.
  • If the game changed the sizes after the frame was taken apart, and they no longer fit, nothing happens.
  • An access to the RAM that is larger than what is left there goes on around the 2 KB.

How long it takes

A bit takes 4 us, so a byte takes 32 us. The console's stop bit takes 3 us, and the device's 4 us. Between them, the PIF waits about 7 us, or about 520 us with bit 04h. With both 04h and 08h, the console sends no stop bit. The times of all the channels are added up, and then rounded up to whole cycles of 16 ns. So a read of the buttons takes 32 + 3 + 7 + 128 + 4 = 174 us, and then the SI's time.

How long the PIF waits for a device that does not answer is a guess: it is 62.5 us here, the time in which a pak has to begin its answer. How long it needs to take a frame apart, or to answer a challenge, is not known and is 0.

Controllers

Commands 00h and FFh ask what is there. The answer is 05 00, and a status:

  • Its lower 2 bits are 2 without a pak. They are 3 for a new pak, once, and then 1. A new pak cannot be used until the game asked for this.
  • Bit 2 says that the address of a command for the pak had a bad checksum. That it is told only once, and that a good address clears it, is a guess.
  • A pak is new again when it, or its controller, gets power (a guess for the controller).

Command 01h gives the buttons and the stick. The picture on the Joybus Protocol page has this order, from the highest bit:

1514131211109876543210
ABZStartupdownleftrightRST0LRC upC downC leftC right

After them come X and Y, as signed bytes. To the right and up are positive (that direction is a guess). While L, R and Start are pressed together, RST is set, Start is not, and the stick reads 0, 0. The place where it is becomes its centre. Command FFh also makes the stick's place its centre. Here, that is its place from the last time that a game asked for it. So a frame without command 01h asks no one for buttons. That is a guess, and so is that its value stops at -128 and 127.

Paks

Commands 02h and 03h read or write 32 bytes of a pak. The address is a multiple of 32, and its lower 5 bits are a checksum:

  • The address checksum is the page's value for each bit of the address, added by XOR. These 11 values are what a CRC of 5 bits with x^5 + x^4 + x^2 + 1 gives. The code uses that formula, and a test compares each address with the page's values.
  • The data checksum is a CRC of 8 bits with 85h (x^8 + x^7 + x^2 + 1) that starts at 0. A test has values that were worked out by hand. For a read, the controller sends it after the data. For a write, it sends it as its answer.

With no pak, a pak that is still new, or a bad address checksum, a read gives 32 zeros and a write does nothing. In the answer, all bits of the data checksum are turned around.

Controller Pak

It has 32 KB. From 8000h up, writes do nothing and reads give 0, as the top address line turns its chip off. A new one is not formatted and has only zeros (a guess), and games can offer to format it. Its file system is not needed to emulate it.

Paks with more banks are missing. The Controller Pak's page has their map beside what the SDK does, and does not say whether it was measured on such a pak. If there were one, a game would see a pak of 32 KB: a write at 8000h or higher would not change the bank. So if it chose bank 1 and then used it, it would read and write bank 0. A game that looks for more banks finds only one.

Rumble Pak

The pages disagree on the address of the motor. The Rumble Pak's own page has the identification at 8000h to BFFFh, and the motor at C000h to FFFFh. Joybus Protocol has the motor at 8000h to BFFFh. What its own page says is used here, as it has more detail. Its chip also has both address lines that are needed for that. It is still a guess, and it has to be checked on a console. Write 80h to unlock it: then the identification reads as 80h. Any other value locks it, and it then reads as 0. For the motor, an odd value is on and an even one is off.

These are guesses too: the last of the 32 bytes counts, the motor runs only when it is unlocked and stops when it is locked, its status reads as 1 or 0, and nothing is below 8000h. rumbles tells the app when the motor runs.

Not emulated: the Transfer Pak, whose own page was not saved, the Bio Sensor, the mouse, the VRU, the keyboard, and other controllers.

The cartridge's channel

EEPROM

Commands 00h and FFh give 00 80 for 4K, or 00 C0 for 16K, and then 80h while it is busy. Commands 04h and 05h read and write a block of 8 bytes. One of 4K has 64 blocks, which repeat. One of 16K has 256. A write begins when the EEPROM has got it, and takes up to 6 ms. Here it always takes the whole 6 ms. During that time, the answer to another write is 80h, and that write does nothing.

Guesses: a new one has FFh in it. During a write, a read gives what is being written. Which of the two a cartridge has, if any, is found out together with the other saves.

The clock

Commands 06h to 08h are for the clock. It does not answer 00h, and it is a guess that it does not answer FFh either. It answers 00 10 to 06h, and then a status, where 80h is for stopped. It has four blocks of 8 bytes, and the upper bits of the block's number are ignored:

BlockWhat is in it
0which blocks are protected, whether the clock is stopped, and bits that do nothing
18 bytes that the battery keeps
2the time in BCD: second, minute, hour + 80h, day, day of the week (0 is Sunday), month, and the year in two bytes
30

The app gives the player's date and time when the console is turned on, in local time. Nothing here asks the computer's clock. From then on, the clock uses the console's own time. So the same input gives the same time again, and a loaded state goes on from its own clock.

The battery data keeps how far the clock is ahead of the player's time, and whether it is stopped:

  • It goes on while the console is off. A stopped clock stays at its time, and goes on from there when the game starts it.
  • If the player's time goes back, so does the clock. It is right again when the player's time is.
  • Without the player's time, that time goes on from where it was when the battery data was last taken, or from 2000-01-01 if there is none. The offset stays, so the clock is right again once the player's time is there.
  • Any number is accepted. The years go around from 2099 to 1900, so nothing is refused, and nothing is lost.

Guesses: writes take effect at once. The page tells games to wait for 20 ms, and not what happens if they do not. The clock can also be set while it runs, and a second then starts again. A new clock is running and protected. Values that are out of their range are brought into it. The crystal and battery always work.

A game that checks that there is no clock could notice one. By default, the clock answers only when a game asks for it. Other commands on the channel are as if it was not there, until a game asked for it once, and that is kept. A homebrew game can declare that it has a clock. Without an EEPROM and a clock, the channel gives the "no device" error. For 06h without a clock, the page says that three bytes of 0 come back. That does not fit its own general rule, that a device never answers a command that it does not have. The general rule is used here, which is a guess.

The security chip

Each cartridge has a security chip, the CIC. It gives the PIF a region, two seeds, and a checksum for the boot code. Both seeds are always the same. From n64brew's PIF-NUS and CIC-NUS pages:

ChipSeedChecksum of its boot code
61013Fh45CC73EE317A
6102, and 7101 for PAL3FhA536C0F1D859
71023Fh44160EC5D9AF
6103, 710378h586FD4709867
6105, 710591h8618A45BC2D3
6106, 710685h2BBAD4E6EB74

The checksum is never calculated here, as the pages only link to a program for it. The table is complete, but nothing uses these checksums. The PIF and the CIC also check each other all the time. Here that always works, so nothing of it is emulated.

With command 02h, a game sends a challenge of 15 bytes, which are at 30h in the RAM. A 6105 or 7105 answers with a secret calculation. The pages only link to programs for it, so it is not answered: the bytes stay as they are, and Counts counts it. A game that checks the answer will notice. The other chips turn around each bit, and here that answer is there at once (a guess). The pages know of no program that uses it.

How n64emu finds the chip

No game is recognised, and the boot code is neither read nor compared with anything. A cartridge's own boot code checks the first megabyte after it with the chip's seed. If the seed is wrong, it stops. So the console tries the seeds, and the cartridge itself says which one is right. boot::choose goes in this order:

  1. The player's setting, which skips the rest.
  2. A result that was kept for this game's id. A result for another game does not count.
  3. A trial of each of the four seeds, in a fixed order: 6102, 6103, 6105 and 6106. CIC-NUS says that about 88% of commercial games have a 6102 or 7101, so it is first, which makes the search faster. The others are in the order of their numbers, and nothing else speaks for it.
  4. If none passes, it is 6102, and the app should say so. This is not kept.

Each trial runs on a console of its own, with empty saves, a fixed time and no controllers. So it is the same each time, and it changes nothing of the player's. A trial passes when the game ends the boot (08h). A trial is over when the 5 seconds are over, after which the PIF would stop the game anyway. The console also ends it early when the processor can never go on: a loop that goes back to exactly the same state, when nothing from outside can change it (architecture).

  • n64brew's page and libdragon's boot code both give those 5 seconds.
  • More than one can pass, such as with homebrew that does not check anything. Then the first one wins, so the order decides. That is our choice.
  • Trials cannot tell 6101, 6102, 7101 and 7102 apart, as all four have the same seed. They do not need to: between 6102 and 7101, only the region makes the difference. That it is the region of the console is a guess.
  • The order of the steps, the fixed order of the seeds, and the limit of 5 seconds for each are all the same each time. Three wrong seeds take at most 15 emulated seconds before the game starts.

Starting a game

The console's own boot program copies the cartridge's boot code (IPL3) into the RSP's data memory, and starts it there. That program is not here. n64emu goes straight to the state in which the cartridge's boot code begins, and that code runs as it is. It sets up the memory and starts the game.

What the boot code finds

WhatValueFrom
the boot codeROM 40h to FFFh, in DMEM at the same offsetsPIF-NUS says that it is copied, but not where to. The same offsets are a guess
the startA4000040ha guess. It fits libdragon's IPL3, which is made for DMEM at A4000000h with its 64-byte header first (ipl3_prod.ld:8 and 15-19, and ipl3.c:105). The code there could also start at 44h, so it does not prove it
s3 (19)0, for a cartridgewhat libdragon's IPL3 expects (ipl3.c:84-90, README.md:147)
s4 (20)the region: 0 is PAL, 1 NTSC, and 2 MPALthe same (ipl3.c:84-90, README.md:148)
s5 (21)0 after power-on, 1 after a resetthe same (ipl3.c:84-90, README.md:149)
s6 (22)the seed. Its other bits are 0, which is a guessthe same (ipl3.c:84-90)
domain 1's settingswhat the ROM's first bytes sayParallel Interface
RDRAMnot set up after power-on: RI_SELECT is 0libdragon's IPL3 expects it (ipl3.c:278). RDRAM is the console's
the RCP, after a resetas it wasPIF-NUS
the 5 secondsfrom power-on, or the NMIPIF-NUS, and libdragon's cleanup.c:27-33

libdragon does not say where any of this is from. It shows what its own IPL3 expects, and not what the console does. Begin::known says for each register whether its value is only known from there. Only r0 is certain.

These are gaps, and all of them are in one place, boot::Unknown. They are fixed values, 0 by default but for three, so that each start is the same and other values can be tried:

  • The stack pointer (r29) is A4001FF0 by default, near the end of IMEM: a guess (boot::STACK). No source gives it. The evidence is from the developer program on the owner's files, by addresses and counts only:

    • One game's own boot code (Super Mario 64, USA) uses it at its 12th access. With 0, that access misses the TLB and the processor goes to the vector at 1FC00200. With A4000FF0, A4001FF0 and A4001FFC, it goes on, so any value in DMEM or IMEM did for that game.
    • The 6105's boot code reads at sp − FF0h in its second instruction, and walks on from there. With A4001FF0, that is IMEM's first word. With A4001FFC, A4001FE0, A4001F00 and A4000FF0, it began at 0400100C, 04000FF0, 04000F10 and 04000000. A walk that begins at the start of a memory speaks for this value, but does not prove it.
  • t3 (r11) is A4000040 by default, the boot code's own address: a guess (boot::T3). No source gives it. Only the 6105's boot code was seen to use it before setting it: with 0, its third instruction misses the TLB at BadVAddr 44h, and --registers names t3. With A4000040, that read is at DMEM 84h, right after the instructions that it ran (40h to 80h), and its loop reads on from there. The 6102's boot code gives the same accesses with any value of t3, and the trials of all of the owner's files chose the same chips with it as without it.

  • Status (COP0's register 12) is 34000000h by default: CU0, CU1 and FR set, and all else clear, BEV and ERL too (boot::STATUS).

    • Measured at our program's own start on one console, the owner's, by program 2 (tools/console/m2.c, record m2-2026-12-01), after libdragon's IPL3 (release r10). libdragon's boot/README.md says nothing of Status.
    • That the IPL3 found the same is a guess. In n64emu, n64emu-dev --exceptions shows that this IPL3 changes no bit of Status from its start to our program's, with every value that was tried (--unknown-cop0 12=VALUE).
    • Program 1 (tools/console/m1.c) had shown before that CU1 has to be set at the start: with the processor's own Status after a cold reset (00400004h), that IPL3 takes Coprocessor Unusable at its first instruction of the FPU (A4000608h, cycle 1160), and with CU1 but without FR, it later takes it for COP2 at 7FFFF818h, where there is no memory. With CU1 and FR (24400004h, the default for a while) our programs ran, and with 34000000h they run the same.
    • What games' own boot code finds is not known: they are checked on a sample of games.

    After a reset (the NMI), SR is set too, as the soft reset sets it.

  • s7, which has a version. libdragon's IPL3 uses it, but does not say its value.

  • All other registers.

  • COP0's other registers. Unknown::cop0 has none of them by default, so that they are as the processor's crate has them after a cold reset, which is what NEC's manual gives, or 0 where it says that they are undefined. That IPL3 finds them so is a guess: the PIF's own boot program runs before it.

  • DMEM before 40h, and all of IMEM. On the console, IMEM has the PIF's own boot program, and none of it is here. If a cartridge's boot code reads it, the result is different. CIC-NUS says that the 6105's protection uses the RSP at boot.

  • The PIF's RAM. PIF-NUS says that it has the region and the seeds at 24h to 27h, but not in which form.

These are gaps too, as the registers of the processor's COP0 and of the RCP, domain 2's settings, and the PIF's RAM after a reset are also not known. They are the console's, but for the RAM, which stays as it is here. The plan is to log, from outside, what a cartridge's boot code reads before it writes it, and to try values. It is a log of reads and writes with their times, addresses and sizes. It keeps no values, and no instructions: n64emu-dev's probe has none to give.

The 6105's boot code

It needs the maker's own boot program (IPL2) in IMEM, which n64emu does not have. So no game with a 6105 starts. This was found from outside, with n64emu-dev on the owner's files: only addresses, sizes, counts, times and hashes. No value that the boot code read was looked at.

Which games. Of the owner's 977 retail files, the trials find no chip for 49. 43 of them have the same boot code (a hash of ROM 40h to FFFh), with Zelda: Ocarina of Time and Majora's Mask, Banjo-Tooie and Perfect Dark among them, which are the CIC-NUS page's examples for the 6105. The others are not 6105 games:

  • 5 dumps for the Wii's Virtual Console (Mario Tennis for three regions, Mario Party 2 for Japan, Ogre Battle 64) have the 6102's boot code: it has the same hash as Super Mario 64 (USA)'s. Their own boot code stops right after it read the header's checksum at 10h, with each of the 256 values of the seed. What it checked was right: after its DMA, RDRAM from 300000h has the same hash as the ROM's first megabyte from 1000h for Mario Tennis (USA) (Wii Virtual Console). So the checksum in their headers does not fit their data, and n64emu does what their own boot code says. The other dumps of the same games start, as 6102, by trial.
  • The Nintendo 64 Modem (Japan) has a boot code of its own, which was not looked at.

What it does from its start, with t3 as A4000040 and sp as A4001FF0. It is the same for Ocarina of Time (USA, Rev 2), Mickey's Speedway USA, Perfect Dark and Banjo-Tooie (all USA):

  1. Its second instruction reads IMEM's first word (sp − FF0h), and its third a word at t3 + 44h (DMEM 84h). Then it writes that word of IMEM.
  2. It goes on, a word of IMEM and the next word from 84h on each time, about 135 cycles for each, until a word of IMEM whose bits 0 to 29 are all 0. With 0, 40000000h, 80000000h or C0000000h there, it ends after that word. With 1, 2, 7FFFFFFFh, 80000001h and FFFFFFFFh, it goes on (--unknown-imem). With 256 words of 1 before a 0, it read 257 words of IMEM and from DMEM 84h to 484h.
  3. Then it writes the next three words of IMEM, and reads two more words of its data, and runs on to DMEM 84h, the first word of the data that it read. The processor finds a reserved instruction there, not in a delay slot, and takes the exception to 80000180, where RDRAM has not been set up.

It touches no register of the RSP or the PIF before that, and reads nothing of DMEM below 40h. IMEM's first word is read before anything wrote it, and how far the boot code goes depends on what is in IMEM: on a console, that is IPL2 (n64brew, PIF-NUS: IPL1 copies IPL2 to IMEM, and IPL2 runs from there and starts the boot code). The path after step 3 was the same with every content tried: zeros, 256 words of 1, and eight random fills of 9 to 62 words. Whether the console branches away from 84h because of what IPL2 is, or something else is different, is not known.

What comes later, what it does with the RSP (CIC-NUS: the 6105 "involves the RSP at boot"), when it reads the PIF, and the challenge, was not reached, so it is not known. IPL2 is the maker's program, and n64emu will not have it. So these games begin with our own start (the owner's decision, 2026-12-01).

Our own start

For 6105 games, n64emu does itself what their boot code would leave, and starts the game at its entry. Every other game runs its own boot code. It is in boot::own_start in n64-pif (the data) and in the core (rcp.rs, machine.rs: the copy, the memory's chips, and the jump).

How it was found. The boot code of the 6102, 6103 and 6106 runs in n64emu. n64emu-dev --compare own_start=always runs a game twice to its entry, once with its own boot code and once with our start, which waits as long as the boot code took, and prints only where they differ: the name of a register, or a range of a memory with its two hashes, and in a short range the addresses of the words that differ. It never prints a value, of a register or a memory, and no instruction (docs/development.md). Each value below was a guess, from the source in its row, that was then tried with --own-start-try NAME=VALUE: a guess stayed when the difference went away.

WhatOur startRests on
where the game beginsthe header's word at 8, but 1 MiB less for a 6103, 2 MiB less for a 6106, and 80000480 for a 7102n64brew's CIC-NUS ("Game Entrypoint") and ROM_Header. In n64emu, every 6102, 6103 and 6106 game that was run got there
the game's first megabyteROM 1000h to 100FFFh, copied to that address. What is past the ROM's end is 0ROM_Header ("Boot Address"). The comparison: the same bytes and ninth bits
the processor's registersas at the boot code's start (above): sp, t3, s3 to s7sp, s3 to s7 were the same at the entry. The other registers keep what the boot code used them for, and are not done
Statusas at the boot code's startthe same at the entry
RDRAM's chipseach at its own 2 MiB in their order, Delay 28381808, RefRow 0, and Mode C6000000 with a current of 44n64brew's RDRAM page (its steps 5b, 6a and 8a). 44 is what the boot code finds with n64emu's model of the current (ENOUGH in rdram.rs, a guess): if that changes, so does this
RIRI_MODE 0Eh, RI_CONFIG 40h, RI_SELECT 14h, RI_LATENCY 0Fh, RI_REFRESH 63634h and a bit for each chip from bit 19n64brew's RDRAM Interface page (TSEL and RSEL, the usual mode and refresh) and the RDRAM page's step 11
bit 16 of RI_REFRESH set with 8 MiB, clear with 4 MiB, and RI_ERROR 5 with 8 MiB, 1 with 4 MiBthe comparison only. Bit 16 changes with each refresh, so it depends on when the boot code turned refresh on
MI0Fh bytes for a repeated writethe RDRAM page's step 5a
PIPI_DRAM_ADDR at the end of the copy, PI_CART_ADDR 1000000Cthe comparison: the last thing that the 6102's boot code reads of the cartridge is the header's word at 8
RDRAM 300h to 318h300h the TV type (s4), 304h s3, 308h B0000000, 30Ch the reset (s5), 314h s7, and the memory's size at 318h, at 3F0h for a 6105the memory's size and both places: n64brew's RDRAM page. The others: the comparison, also with other values of s7. 308h was tried as the cartridge's address through KSEG1 (Memory map); that this was tried first is from training. 310h and 31Ch are not written
DMEM0 from 40h on, and below that as at the boot code's startthe comparison
IMEMas at the boot code's start (0)the 6102's boot code does not touch it
timethe processor waits 32.6 million cycles (about 0.35 s) before the game begins, and the RCP runs onthe 6102's boot code takes 32.4 to 32.9 million cycles in n64emu, by game (120 games). --own-start-wait sets it, so that a comparison is at the same cycle
the PIFas at the boot code's start, with its 5 seconds from power-onthe comparison: the same

What our start does not do, so that it differs from the 6102's boot code in what a game could see:

  • The other general registers, HI and LO: what the boot code used them for.
  • Count and Random: the boot code writes Count, and Random goes with the number of instructions. Games that time themselves by Count see other times, which can change their sound and memory later (below).
  • The processor's caches and its write buffer: the boot code leaves its lines in them. Ours are empty, as after a cold reset.
  • RDRAM 0 to 2BFh: the boot code's own program that it ran from there (with its ninth bits). Ours has 0.
  • Two words at the start of each 2 MiB chip but the first: what the boot code wrote there to find the memory. Ours has 0.
  • Each chip's RasInterval (0 here), which the boot code sets from the chip's type. Nothing that is allowed gives its value.
  • RI_BANK_STATUS, which rows are open, and the inside of the MI and the PI (the last register write to a chip, and the PI's last block): they come from the last accesses.
  • For a 6103 and a 6106 only, besides: the word right after the copied megabyte and PI_DRAM_ADDR 4 bytes after it, the word at 310h, all of DMEM and IMEM, which their boot code fills, and bit 16 of RI_REFRESH. Their values were not found, and our start does the 6102's.

How it was checked against the other chips (2026-12-01, fca1d7e and after), with the owner's games, found by trial:

  • At the entry, 26 games: 12 of the 6102 (NTSC and PAL), 9 of the 6103 (NTSC and PAL), 5 of the 6106 (NTSC and PAL), with 8 MiB, and Super Mario 64 (USA) also with 4 MiB. For the 6102, nothing differs but the list above. For the 6103 and 6106, the same and their own items.
  • 600 frames, the same 26 games, without input, with --hashes, our start waiting as long as each game's own boot code took:
    • The boot ends at the same cycle in 25 of 26 (Bokujou Monogatari 2 (Japan): 16,000 cycles later).
    • The picture is the same in all 600 frames in 17: 11 of the 12 6102 games, and 6 of the 9 6103 games. In 64GB Checker (Japan), a test program with a 6102, frames 32 and 33 differ. In the others, 52 to 566 frames differ: 1080 Snowboarding (Europe), Excitebike 64 (Europe) and Super Smash Bros. (Australia), of the 6103, and all 5 of the 6106.
    • The sound is the same in all 600 frames in 17. The memory and the state differ in every frame in all of them, as the named differences stay in the memory. After 600 frames of Body Harvest (USA), what differs is Count and Random, two FPU registers, and 2.5 KB of RDRAM.
    • Why some differ is not proven. For the 6102, Count and the caches are the likely causes. For the 6103 and 6106, also their own items.

What is only a guess for the 6105, with its source:

Our startRests on
the seed in s691hn64brew's PIF-NUS table
where the game begins and the copythe header's word at 8, as for the 6102n64brew's CIC-NUS table
the memory's sizeat 3F0h, and not at 318hn64brew's RDRAM page
everything elseas the 6102's boot code leaves itnothing: it is the same family of chips
the RSP at bootnothing of it is done: IMEM has 0, DMEM 0 from 40h, and the RSP is haltedCIC-NUS says only that the 6105 "involves the RSP at boot"
how long it takesas for the 6102not known
the challenge (02h)not answeredX-Scale's algorithm is not approved; nothing else gives it

The setting own_start, for developers only (n64emu-dev --own_start), and not in the app's menu: off runs every game's own boot code, 6105 (the default, and always in the app) uses our start for 6105 games, and always for every game. A 6105 game is found by its behaviour: in the trials, a boot code that reads a word of IMEM before anything wrote it needs IPL2 (Trial::NeedsIpl2). If no candidate passes and one needed IPL2, the chip is a 6105 (ChosenBy::NeedsIpl2): of the known chips, only the 6105 is said to use the RSP at boot, and in the owner's files only its boot code reads IMEM. Once the processor starts a DMA of the RSP, nothing more counts, as such a DMA could write IMEM. A 6105 chosen in the CIC setting also gets our start. No game is recognised by a list or a hash. The boot code that needs IPL2 is the 6105's.

What our start does not know yet:

  • The registers s0, s1, s2, s8 and ra at a game's entry, which the 6105's boot code leaves and our start leaves as at the boot code's start. n64emu-dev --registers shows when a game's path depends on them.
  • The 6105's answer to a challenge. The PIF does not answer one, and what a game does then is not known.

The region

A console has a region, and a cartridge does not. A cartridge starts only on a console that fits its chip. Region::auto chooses the console for a cartridge by the letter at 3Eh of its ROM, and the player's setting always wins. What the letters mean is not from a table. It is what the owner's files show: in 1,189 files, that byte was compared with the region in the file's name. Only that byte and the first four were read:

LetterRegions in the files' namesConsole
J239 JapanNTSC
E429: 417 USA, 4 Europe, 3 World, 2 Brazil, 2 "USA, Europe", 1 unknownNTSC
G31 USANTSC
A1 "Japan, USA"NTSC
P284: 278 Europe, 4 Australia, 1 "Europe, Australia", 1 WorldPAL
D40: 35 Germany, 3 Europe, 2 USAPAL
F22 FrancePAL
X11: 9 Europe, 1 Australia, 1 AsiaPAL
I6: 5 Italy, 1 unknownPAL
S5 SpainPAL
U4 AustraliaPAL
Y3 EuropePAL
B3: 2 Brazil, 1 unknownMPAL
00h96, mixedNTSC, the default
eight other values1 to 3 each, mixedNTSC, the default

It is no count of what was sold: the files include prototypes, aftermarket and unlicensed games. Counts of 1 to 3 say little. That the TV standard of a country is the console's is a guess, above all for B. Two other files with Brazil in their names have E. No game is recognised by this letter.

After that

  • A game has about 5 seconds to end the boot with 08h. If it does not, the PIF stops the processor until the console is turned off.
  • The reset button does nothing until then. Once pressed, it sets an interrupt pin (Int2) as a warning, and 500 ms later the NMI comes. If the button is still held then, the NMI waits until it is let go. The boot begins again, and the game has to end it again.

next_event and event give these to the console. It is a guess that the warning ends with the NMI, that a button that is still held when the boot ends does nothing, and that the button also does nothing during a reset. The 5 seconds begin here with the boot code. On the console, they began a little earlier.

States and saves

  • A state has the RAM, where the exchanges are, the reset and its times, what is plugged in, the paks with their data, the EEPROM and the clock. So the app keeps a copy of the saves first, and of each pak's data.
  • The cartridge's EEPROM and clock are in this crate's battery data. A pak is the player's, and not the cartridge's, so its data is kept apart. When a pak is taken out, the app gets it back with its data.
  • Both formats have a version, and a test keeps the first one readable. Data that is damaged, too large or from a newer build is refused, and nothing changes. A state that is damaged never stops the program.

What is missing

  • Games with a 6105 or 7105 begin with our own start, as their boot code needs IPL2 in IMEM. What only the 6105 does is a guess.
  • A challenge to a 6105 or 7105 is not answered.
  • The gaps at the start of the boot code above. Which of them games use is known only for the stack pointer and t3, and Perfect Dark needs what the 6105's boot code leaves in some registers.
  • Paks with banks, and the other paks and controllers listed above.
  • All guesses on this page. Most can be checked with a small test program on a console.

From commit 9ba9172cfa64. Edit this page