emuforge

How it was made

AI agents wrote n64emu together with a person, in December 2026. It is our own implementation, written from public documents and tests, with two parts that are ported. This page says how that was done, in order, from the survey to today, with real examples, and what it can and cannot show. It is for people who want to do the same, or who want to check it.

The general rules are in the harness. The credits name the people whose research all of this rests on. Without their documents and measurements, none of it would have been possible.

What the person decided, and what agents did

The person (an owner of emuforge)Agents
to write it from scratch under MPL-2.0, and to port two parts, each as a decision of its own: the RDP and the RSPthe survey before that: which documents, tests and licenses there are, what each part would need, and what is missing
which sources can be used, and what happens when that is not clear. For example, which pages of n64brew.dev may be used, and which parts of themread the documents, and wrote facts down in their own words with the page of each. They stopped and asked where the rules did not settle something
to save the pages of n64brew.dev from a browser, as a site's tools are not used for itworked only from the saved pages
that games with the 6105 chip start with our own replacement of what their boot code doesfound what that boot code leaves, from outside, by comparing with the other chips
that recompilers may ship, on Cranelift, when they are exact and faster, and then are the only way for playersbuilt the framework and the RSP's recompiler, and took out the processor's when it was not faster
to switch the console on and off for our measurement programswrote the programs, sent them to the console, and decoded their results
which games are there. They are the person's own. They stay where they are, and are only readran them without a window, counted what happened, and looked at some pictures
to play the first gamewrote all of the code, the tests and these pages

From scratch, and why

The survey looked at each part apart. For the main processor, NEC's public manual gives nearly all of its instructions, cycles and stalls. For the memory and the console's interfaces, n64brew.dev describes most registers. For the boot, there is no clean source for the state in which a game starts, which made it the largest risk. Those parts are ours.

There is no base for them, so nothing in them is right because another program does it. Each rule rests on something that anyone can look up or repeat: a document, a measurement, a test, or what games do. The comment at the rule says which. If sources differ, the comment says what each of them says. If there is no source, it says that the rule is a guess, and the guess is a named constant or a setting, so that a measurement can replace it.

MPL-2.0 lets others use the core in their own work, also in programs with another license. Changes to its own files stay open. It also means that code under the GPL or LGPL cannot be ported into it.

Two parts that are ported

The RDP and the VI's filters, from paraLLEl-RDP (MIT). No source that the survey read gives the whole drawing chip bit for bit. Its author says in its README that it was written from scratch by studying another program, and builds on what was learned from it, "but not code". That is his statement, and it is credited as his. Before the port, its files were checked for where their code comes from. One function, the noise, came from a shader whose license is not known, so it was not ported: someone who had not read it wrote our own.

The RSP, from ares (ISC). Most of the vector unit's instructions have one line each in public documents, and some of them, with the tables for reciprocals, were not found at all. So the RSP is a port. Its history in ares names who wrote what, and the credits name them.

Each port is a crate of its own, with a small interface that is ours and was written down first. The rest of n64emu uses only that.

Three sides that stay apart

Every agent was on one side for good, and its task said which:

SideWritesMay read
S, from scratcheverything but the two ported cratesthe allowed documents and tests, and of the ported crates only their public interface, README and credits
G, the RDP's portn64-rdpparaLLEl-RDP at its commit, and the allowed documents
R, the RSP's portn64-rsp and its recompilerares's RSP at its commit, what of ares it needs to be understood, and the allowed documents. Nothing else of ares

Notes that all sides read have only interfaces and results. Reports from sides G and R say nothing of their source's code, formulas or tables. Each side keeps its own notes apart. This page, too, is written from side S.

Which sources, and why

UsedNot used
NEC's public manual of the VR4300, and its data book of RDRAM chipsthe source of any other emulator of this console, but for the two ported parts, whatever its license. An HDL or FPGA core counts as one
n64brew.dev's pages, saved by the person (CC BY-SA 4.0): facts only, and no text, table or codethe console maker's development kits, manuals and libraries (libultra), also where a site has them openly, and anything leaked
the parts of those pages about the PIF, the security chips and setting up RDRAM, which rest on the console's own programs: the person allowed facts from them, and no listing in them was readdumps, disassemblies and decompilations of the PIF's programs, the security chips, the cartridges' boot code and games, and links to them
Appendix A of US patent 6,331,856, for the formats of RDP commands, checked against tests, as it has errorsa part of a page that rests on libultra or the maker's manuals, until it is clear that the fact comes from elsewhere
libdragon's own boot code (Unlicense), for facts: where a boot code starts, and which registers have the flags and the seedits other files, and any file with a disassembly
test programs whose license allows it, and all that they bundle, run as closed boxestest programs that bundle boot code of unknown origin, or that have an emulator's code in them
measurements on a console with our own programsa published algorithm for the 6105's answer, which was made from another emulator's data
what games do, seen from outside: counts, times, addresses and hashesa list of games, or anything that treats one game differently
  • The rules were part of every agent's task. They include no search for code, no tables from memory, and no source that was not really opened. A value that comes from an agent's training is called that, in the code and on the page, as the colour carriers of the television standards in the VI's clock are.
  • A search that has the expected answer in its words is no evidence, and neither is its summary.
  • When it was not clear whether a source could be used, agents stopped and said so, with what is known about where it comes from, and the person decided. For example, the PIF's page says that its facts rest on the PIF's own program, which was dumped. The person allowed facts from it, and nothing that links to the program.
  • What cannot be ruled out: agents learned from a lot of text before they started. Nobody can say what was in it. So n64emu is not called a clean room. It is "our own implementation, written from public documentation and tests". The credits say what was used and what was not.

The interfaces first

Before any part was written, the types between them were, with the agreement about time:

  • The whole console counts one time: ticks of 187.5 MHz. A cycle of the processor is 2 of them, and one of the RCP 3.
  • The processor leads. It runs up to a stop, and never calls the bus at or after it. What it has to do later waits in it, also in the middle of an instruction. Waiting writes keep their own, earlier times.
  • Every other part runs late, catches up when something could tell, and says when it could next be seen: too early is fine, and too late never. Two of these were kept apart from the start: when a part could next change something that others look at (they catch it up when they look), and when it could next reach out to someone (that stops the leader). The RSP's next signal is the second kind.
  • All state is plain data, saved by each crate with forge's forge-state from its first version, in sections with versions.
  • No threads, clock, files or allocation while it runs. The GPU's work in the RDP is the exception.

The signatures were committed first, so that other parts could use them at once. The pure arithmetic of the floating point unit, a crate by itself, took an agent 16 minutes, with exact tests by big integers and a list of nine guesses to measure.

The parts, and how each was tested

PartWritten fromTested with
The processorNEC's manualevery row of the manual's opcode tables, groups of instructions, the order of exceptions, the TLB, the caches and the times. Random programs cut into pieces in many ways: whole, one instruction at a time, at random, and with a state saved and loaded at each cut, with a device that changes interrupts and memory at random times. 1.3 million cuts agreed
Floating pointNEC's manual and IEEE 754exact arithmetic with whole numbers of any size, in each rounding mode, and the computer's own arithmetic where the rules are the same
The RSPits portares's own RSP, compiled by itself at the same commit: one step at a time from random states, random programs, and DMA at each cycle. The two agreed wherever they were compared
The RDPits portthe original, on 63 lists of commands of our own, on two drivers. 54 gave the same bytes as they were. With the original's undefined values set and our noise, all 63 did. 6,000 random and broken lists ran in three ways that have to agree, before any game's commands ran on a real GPU
Memory and the bus, PI, SI and AI, VI and DPCn64brew's pages, and NEC's data book for RDRAMtests from the pages' numbers, such as the times that n64brew measured, and programs of our own that set up RDRAM as the pages say
Cartridges, the PIFn64brew's pages, and libdragon's boot code for factseach command, checksum and save chip by itself, and a test for each guess, so that a change is seen

A test is named as a sentence that has to be true, such as the_memory_takes_as_long_as_n64brew_measured. No test is made weaker to pass. Where a case is left out, the test says which and why.

Two drivers are the smallest test for a GPU part. The RDP's port was run on an Intel Arc A750 and on llvmpipe, which runs on the CPU. Where they gave different bytes, each list was cut down to one draw, and the cause found: shader values that were never set. Since then, every shader variable has a defined value.

Measurements on a console

The person has a console (US, NTSC, with the Expansion Pak) and a SummerCart64 flashcart, which has USB. Our own programs, built with clang and libdragon's prebuilt boot code, are sent to the cart, and their results come back over USB as a list of words with checksums. They never read, save or show the PIF's memory, the RSP's memories at boot, or anything else of the console maker's, and each source file names the addresses that it touches. A result is that console's.

Two programs ran on 2026-12-01, and settled about 20 guesses in an hour. The person only switched the console on and off:

  • Program 1: the processor's revision (PRId 0B10, FCR0 0A00), and the time of a load from the data cache, after a miss, and around the cache. n64emu's reads were 4 ticks of Count short, and its read time was fitted (memory and the bus).
  • Program 2: four operations of CACHE, the byte lanes of the bus (n64brew's page was wrong for them), DMA times, the AI's sample period (n64brew's example was wrong), Count and Compare, 17 cases of floating point, and the ninth bits. It confirmed the default NaN and seven rules of floating point, and corrected one (−2^53 to L raises E). It showed that a byte stored by the processor gets its ninth bit from the second byte of its 16 bits, which no page said.

Where n64emu still does not fit, the page says so: when Count goes up after a write, when AI_LENGTH reads 0, and one time of a miss.

Joining the parts, and the first picture

The developer program came with the first picture, and it prints only counts, times, addresses, sizes and hashes, never a value that a game read or wrote. Its option --registers runs the boot twice for each register that no source gives, with two values, and prints the first access that differs. In the first game, it found the register that mattered (the stack pointer) in one run, without looking at any of the game's code.

From the first run of a game to its first picture took about two hours, with only numbers to look at. Each guess that the pages left open became a named setting that a run could test both ways. Super Mario 64 (USA) showed its title screen at frame 300, and Mario's face with "Press Start" at frame 600, with the RDP on llvmpipe, on a hidden screen.

forge's app was made for consoles with digital pads and no GPU. The Nintendo 64 needs sticks, rumble, a reset button, paks that are the player's own, a GPU that can fail, and its save at load. Each went into forge, for every emulator, and not into n64emu alone.

The games that need the console's own program

The games with the 6105 chip have boot code that needs the console's own boot program (IPL2) in the RSP's memory. That was found from outside: by addresses, counts and hashes, and by putting different words in that memory and seeing how far the boot code goes. n64emu does not have that program, and will not.

So the person decided that these games begin with our own start: n64emu does itself what their boot code would leave. It was found from the other chips' boot code, which runs in n64emu: a game runs twice to its entry, once with its own boot code and once with our start, and the developer program prints only where the two differ. A guess for each value was then tried, and stayed when the difference went away. Games of three other chips were compared this way. What only the 6105 does is a named guess. (The PIF has the details.)

Speed

The first builds were slow, and nobody had timed the whole app on a real game before. A profile showed where the time went: the RDP's bookkeeping sorted its lists (21%), the processor spent 60 to 85% of its cycles in loops that wait, and the RSP's interpreter took 53%. The RDP's lists became bitmaps (13 times less of the CPU there). Then the loops that wait were passed, with the same hashes in every frame: in three games, 600 frames took 29 to 54% less time (architecture).

The next round (2026-12-02) was checked frame by frame against the build before, by the hashes of memory, sound, state and picture after each frame:

  • The RSP leads the running processor up to its next use of the bus, and is taken back cheaply when something needs it earlier. The processor's stops for it fell from about 45 million to about 2 million in 900 frames.
  • The RSP's interpreter decodes blocks of steps ahead, and passes its loops that wait for the RDP's registers while they read the same.
  • The processor's interpreter fetches the next word of a line without a call, and the RDP's commands no longer wait for the GPU when the processor writes textures.

Together, this round took 22 to 45% off the computer's user cycles for 900 frames of four games (Banjo-Kazooie 73.6 G to 40.4 G, Super Mario 64 55.0 G to 41.3 G, GoldenEye 007 45.4 G to 35.4 G, Mario Kart 64 34.2 G to 26.2 G, all USA; n64emu-dev, counted by perf, on one computer). The build before had a fault that this round found (below), so Mario Kart 64's two numbers are not of the same result. Two recompilers were tried in it too, apart from each other, and both lost to their interpreters.

Then one written design, with all parts built at once. The design asked for counters before speed: how often each part is called, and how long each call runs. They showed why the recompilers had lost: the RSP ran in calls of 60 to 350 cycles, ended by its next use of the bus, so compiled code had little to run between calls (the scheduler). Each step was checked on Super Mario 64, GoldenEye 007, Banjo-Kazooie and Mario Kart 64 (all USA), 900 frames each, against a reference build:

  • A waiting processor stays parked across every event that it cannot see. Its runs fell to less than half, and no change in cycles could be measured.
  • The RSP's lead goes on across its reads of the RDP's registers where they are known ahead. In Banjo-Kazooie that took 13% off the cycles.
  • The picture is taken one frame late, so the console does not wait for the GPU, and the RDP's shaders are listed for each game and compiled before the first frame.

The recompilers. n64-jit is one framework for both processors: Cranelift, a code heap of its own, one exit protocol, code found again by the words that it was made from and never by a hash alone, and the list of a game's hot code kept on the player's machine and compiled at the start. All of its unsafe code is in that crate.

  • The RSP's recompiler (n64-rsp-jit) is exact in every check: each block against the interpreter from the same state, and the hashes of every frame. In Super Mario 64, compiled code costs 6 of the computer's cycles for each of the RSP's, against 54.5 for the interpreter with all that is around it, and the RSP's own work in play fell from about 21.9 G to 12.5 G cycles in 900 frames. A whole second run took 41.7 G cycles against 39.4 G, as compiling at the start took 2.25 s. It was then made the default in every build, and the whole run was not timed again after that.
  • The processor's recompiler was exact at every step, and never cheaper than the interpreter: at best 56 of the computer's cycles for each instruction that compiled code ran, against 46 for the interpreter with all its bookkeeping. Its units were entered once in about 6.5 instructions, and each instruction became about 80 of Cranelift's. It was taken out, and what was learned is in the processor's page.
  • Tried, measured, and left out: builds for newer x86 processors, a quicker floating point unit on the computer's own arithmetic, one flat table for all opcodes, and SIMD for the RSP's vector unit alone (13% of Super Mario 64's time). None gained what could be measured.

Render scale, and pictures with no copy

The render scale draws every batch of the RDP a second time, at 2 or 4 times the size, into a copy of RDRAM on the GPU that the game never reads. RDRAM, its ninth bits, TMEM, states and the exact picture are the same at every scale, which a test checks for every kind of list. Textures are read from TMEM as always, so they stay as sharp as the game made them.

The picture is not copied on its way to the window when the RDP's GPU is the one that the window's OpenGL draws with. The RDP writes each picture into one of three buffers whose memory it exports, weaves interlaced fields there, and OpenGL reads it. Otherwise it is read back once. The menu stays a simple picture that the CPU draws. This went into forge for every app that uses it (architecture).

What the process taught

The person asked for notes as the work went on, as n64emu is not the last emulator. These are the lessons. Some are in the harness's guides already, and the others are noted for them:

  • Ask the survey's questions as choices, with a recommendation, and ask early whether the person has the console, and how it can run tests. The answer decides what can be called exact. Two programs on a console with a USB flashcart settled about 20 guesses in an hour.
  • When a decision changes, the agents' rules change in the same step. Each ported part is a decision of its own, with its own side.
  • When a site refuses a tool, do not switch tools. Make a list of pages for the person to save.
  • Check for code from elsewhere inside each file before a port. What cannot be ported is written again by someone who did not read it.
  • Ask for a short plan of each interface before its code, with calls that cannot be forgotten and results that depend only on inputs and saved state. Write down who waits, until when, and what cannot happen after a stop, before agents start.
  • Before a GPU part runs: check the bounds of every access, run broken data on a CPU driver first, start with one small piece of work, and end at any error with no result. Never take the first GPU that is found, and keep the person's shader cache apart.
  • A model of a shader on the CPU uses the shader's own number formats, or is compared with the shader itself.
  • Look up each address and line number before it is written down. Patents too can contain reproduced manuals: read the list of sections first.
  • The developer program prints no values, only counts, times, addresses, sizes and hashes. Named settings for each guess, tried both ways, found the first picture in two hours.
  • A processor's first test covers every row of its maker's opcode tables. A test of chosen instructions missed one choice that the whole table found in one run.
  • Profile a real game in the app before the first build is handed over, and never time with checks such as hashes on.
  • Count before building. Passing the RSP's own waits was exact and gave no clear gain: they were 9% of its cycles.
  • Measure how long each call into a part runs before building a recompiler for it. Both first recompilers lost to that.
  • One written design with milestones and counters works better than separate tasks that each look for a gain.
  • Check that the result does not depend on how a run is cut, at every milestone. That check found a fault: a parked processor missed interrupt pins that changed at its stop, so Mario Kart 64 differed from frame 562 on. It is fixed, with a test.
  • A script that times or compares builds stops at the first failure, gives a nonzero exit, and counts only finished results. Builds are timed one after the other, never at the same time.
  • Give each long run a goal and a limit, and have it write its progress as it goes.

What is still not known

Many guesses are marked in the code, and each page about the hardware lists its own. These seem to matter the most. Each has a way in which somebody could find out:

QuestionHow someone could find out
What the 6105's boot code leaves, and its answer to a challengefrom clean sources only. The boot code's results can be compared from outside, as for the other chips, once a way to run it is allowed
How the RCP chooses between the processor, the RSP's DMA, the RDP and the VI when they all want RDRAMa program on a console that times one of them while the others run
How long the RDP takes for anythingRDP-Timing-Tests, or a program of ours, on a console
The serial bus's rate, and how long the PIF takesa program that times reads of the controllers on a console
What the multiplication bug of early processors givesa program on an early console, with the cases that n64brew describes
When the bytes of the RSP's DMA move, and how long its rows takethe programs that the RSP's page describes
Which of two rules for the ninth bits is right, and when Count goes up after a writemore cases in our program 2

How to check it, or do it again

  1. Read a rule and its comment. It names a document, a test, a measurement or games, or says that it is a guess. If it has a source that does not say this, that is a mistake. Please report it here.
  2. Run the tests: cargo test --workspace, with llvmpipe for those of the RDP (development).
  3. Change a number in the code that a test should know, and see whether the test fails.
  4. Run your own games with n64emu-dev --hashes, and compare two builds frame by frame.
  5. Run our measurement programs on your console, if you have a SummerCart64, and compare with what n64emu gives (development). Say which console it is.

From commit 9ba9172cfa64. Edit this page