How it was made
AI agents wrote snesemu together with a person. It is not a port of another emulator, but for one small part. It was written from
public documents and tests, and from what games do. This page says how that was done, 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, and not to port an emulator | the survey before that: which documents, test data and licenses there are, what the console itself runs, and which chips games have |
| its license, MPL-2.0, before any code. And that forge is MPL-2.0 too, so that this core can use it | made sure that no crate needs anything else |
| which sources can be used, and what happens when that is not clear. Only an owner can decide to port a part | read the documents, and wrote facts down in their own words with the page of each. They asked where the rules did not settle something |
| what comes first. For example, the chips in cartridges came right after the first games ran | wrote all of the code, the tests and these pages |
| which games are there. They are the person's own. They stay where they are, and are only read | ran them without a window, counted what happened, looked at pictures, and looked for the causes |
Nobody compared anything with a console, and nobody has played a game to its end.
From scratch, and why
The documents about this console are good, and there is test data for both of its processors. That makes
it possible to write one without a base. It also means that nothing is right because another program does
it. Each rule has to rest 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.
A port starts with code that is known to work, and can be compared with its base step by step. This cannot. So
more of its time goes into tests, and its exactness has to be shown from the outside.
MPL-2.0 lets others use the core in their own work, also in programs with another license. Changes to its
own files have to stay open. It also means that code under the GPL or LGPL cannot be ported into it, so that
way is closed, whatever happens.
Which sources, and why
| Used | Not used |
| public documents about the hardware | the source of any emulator of this console, in any language, whatever its license is. A chip design for an FPGA counts as one too |
| data sheets that a chip's maker has published | the console maker's manuals and development kits, which are confidential |
| measurements that people published | the sound processor's boot ROM, the programs and data in cartridges' chips, and disassemblies of any of them |
| test data whose license allows it, read in its own file | code and tables that a document has copied from any of these |
| what games do, seen from outside | a list of games |
- Why no emulator's source, even with a license that would allow it? Its rules would come without their
reasons. A mistake in it would come too, and nobody would see that it has no evidence. And the license of
this core could depend on code whose history nobody here knows. Facts about hardware do not have this
problem.
- Facts are taken, and text and code are not. A table of numbers that is in the hardware is made from a
published formula or measurement. If there is none, there is a marked gap. The S-DSP's table for
interpolation is one. No exact description of it was used, so a curve with a similar
shape is in its place, and nothing in that curve was fitted to the chip.
- Some public documents contain what is not used, such as the code of the boot ROM. Those parts are
skipped. fullsnes also names a book as its source in places. fullsnes is a source, and the book is not.
- The rules are part of every agent's task, and it passes them on to any agent that it starts. They are
also in
AGENTS.md. They include no search for code on GitHub, no code or tables from memory, and no source
that was not really opened.
- When it was not clear if a source could be used, agents said so, with what is known about where it comes
from. Then the person decided. For example, the SNESdev Wiki's page about the DSP-1 does not
name its source, and the decision was that it can be used.
What cannot be ruled out: agents learned from a lot of text before they started. Nobody can say what was
in it, or where a thought of theirs comes from. So snesemu 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.
They do not say that something was never read. One rule shows the problem: how the sound processor's DIV is
wrong when its result is too large is in no document that was found. The agent that wrote it already knew a
rule for it. That cannot be undone. So there is a check of what the public data decides by itself, which anyone can
repeat (crates/snes-spc700/tests/division.rs). It tries 120 ways to divide by shifting and subtracting. Exactly
one agrees with all 1,000 cases, and it is the one in the code. 17 others are right whenever the result
fits, but agree with at most 3 of the 234 cases where it does not. Two limits stay: the 120 ways were chosen with the rule in mind, and
the data is another emulator's. Only a measurement on a console can show what the chip does.
The one part that is ported
The SPC7110 decompresses in three modes. Mode 0 is a port of neviksti's program, and so is the arithmetic coder
with its table, which all three modes use. In July 2008, people worked out the chip
in public, in a forum thread. He linked his program for mode 0. Three days later, he was asked if it could be used,
and answered: "Do with it as you please." The person decided that this is enough, with credit.
His programs for modes 1 and 2 came some days after that answer. The agent found no later permission. So it did not open
them, said so, and stopped. fullsnes also describes these modes, and it is a source that the person had
allowed. So the rest of these two modes was written from its description. The agent had already read posts in the thread that
describe parts of them in words, and they agree with fullsnes on the points that were used.
Two sources found a mistake that one could not. In fullsnes' pseudocode, one step of the coder subtracts 1
where neviksti's program adds 1. Both were run on fullsnes' own example for mode 0. Its way gave garbage, and his
gave the text. With his way, the examples for modes 1 and 2 come out right too. These examples are short, with 64
bytes each, and two of the 31 contexts of mode 2 are in none of them. Since then, games have shown menus from compressed data that look
right. This does not say that all of it is. The credits have the details.
How the work was split
First came what is between the parts, written down before the parts:
| Part | What was agreed on first |
| Main processor | each of its cycles is one call to a bus. The bus has the time |
| Sound processor | it does one cycle in each call, and can stop after any of them |
| S-DSP | it does one of its 32 steps in each call, and always before the processor in the same cycle |
| Picture | at each access, it is told where the beam is. It decides by itself how far it has to catch up |
| A chip in a cartridge | it runs up to a time, borrows the ROM and the RAM for each call, and says when it could next interrupt. That time can be too early, and never too late |
Then each agent wrote one part, in a crate of its own, and changed nothing else. The crates do not know
each other, so agents could work on them at the same time. The SA-1 came later, and uses the same 65C816 as
the main processor. That worked because the processor knows nothing of the console, only of its bus. The
core puts them together.
The same was asked of every part:
- All of its state is plain data, so it can be copied, compared and saved at any time, even between two
cycles.
- It can be left alone, and catch up later, with the same result. A test compares this with running step
by step, with random accesses in between.
- It has its tests before it is joined. A test is named as a sentence that has to be true, such as
a_byte_that_is_already_there_takes_25_cycles.
- No test is made weaker to make it pass. If some cases are left out or changed, the test says which ones
and why.
- At the end, the agent reports what was run with which numbers, what was not run, what fails, and what is a
guess.
The aim is to find what is wrong with a part in its own tests. If the whole then does not work, the first
thing to look at is how the parts fit together.
Test data for the processors
Both processors are tested with public data, SingleStepTests. Each case has the registers and the memory
before and after one instruction, and what is on the bus in each cycle. How to run
it says which versions are used.
| Cases | What agrees |
| 65C816 | 5,080,400 | all |
| SPC700 | 256,000 | 249,000 as they are, and 7,000 with one cycle moved |
That all cases agree does not mean that the processor is right. It means that the processor and the data
say the same. What is the data worth?
- The 65C816's cases are not measurements of a chip.
- The SPC700's data comes from another emulator. GitHub's description of it says so. It is good for
finding mistakes, as it was made apart from this code. It is no evidence where only the data says something.
- The 7,000 cases are 7 instructions that load from
[dp]+Y. In the data, their waiting cycle comes
before the pointer is read. In Bleakley's table, it comes after it. For the store with the same kind of
address, the data agrees with that table. Here they follow the table, and the test moves that one cycle of
the data. It also checks that the cycle is where it is expected before it is moved. So nothing is left
out, and a change in the data would be seen. Which one is right is not known, as no measurement was found.
- 264 cases of the 65C816 depend on an open question: in emulation mode, if the lower half of D is not 0,
where is the second byte of a pointer for
(d,X) when the first is at the end of a page? Here it is in the
next page, as in the data, the data sheet and Clark's pages. The notes of another test program say that it
is at the start of the same page. None of them names a run on a console. So all cases agree, and the
question is still open.
- The data has no interrupts and resets. The crates' own tests have these, from the documents.
Tests from the documents' numbers
The rest of the console has no such data. So the numbers in the documents became tests. Those of the bus,
DMA and interrupts were written after the first games had run. They are numbers that somebody measured or worked out, and not what the code happens to do
(crates/snesemu-core/src/bus/tests.rs). Some of them are:
- The four examples of a DMA of 3 bytes take 48, 48, 48 and 54 clocks.
- The most that HDMA takes in a line is 466 clocks.
- Refresh starts at clocks 538 and 534 in turns.
- Every second NTSC frame is 4 clocks shorter, and the NMI's flag is set 2 clocks into V-blank.
- The first automatic reading of the pads starts 298 clocks into V-blank.
They found what the games had not shown. The first automatic reading of the pads came 44 clocks late.
The first 15 games had already run with that mistake, and nobody saw it. A game can
work with it. But a movie, which is a recording of button presses, only stays in sync when such times are
right. It would have been better to have these tests before the first game.
Two ways that have to agree
Fast code is checked with slow code that follows the documents more closely. The picture is the largest
example. It normally draws lines as a whole, and only when something could tell. The second way draws each dot
by itself, with code of its own, and catches up at each access. Tests give both the same random accesses, and
compare the picture, everything that a program can read, and all of the state. Then both were run on 15 games,
for 22,500 frames in all. The pictures, the sound, the main memory and the main processor were the same.
That shows that the shortcuts change nothing. It does not show that the rules are right, as both ways have
the same ones.
Chips are checked in the same way, against something worked out apart from the code:
| Chip | What it is compared with |
| Cx4 | results that were worked out by hand from its documents. The times of nine small programs that ikari_01 measured on a console, which agree within 0.21 µs. The twelve numbers of its tables that fullsnes shows, and floating-point numbers for all 1,024 |
| Super FX | instructions that were worked out by hand. Drawing is compared with a second, slow version that puts one dot at a time where fullsnes' pictures of the tiles say |
| SA-1 | its arithmetic with exact results, its tiles with ones that the test makes from the same bitmap, and rules for two processors that wait for each other |
| DSP-1 | its equations in floating point. Its largest difference from them is known, but not its difference from the chip |
| S-DD1 | data that a compressor in the tests made. It turns the description around, so a wrong description would be in both. And games, whose pictures look right |
| SPC7110 | fullsnes' example in all three modes, and neviksti's own program for the part that is ported from it. And the games' own test |
| S-RTC | dates that are known from elsewhere, and the game's sequence of digits |
Such a reference is apart from the code, but not from the document. If a document is wrong or was misread,
both can have the same mistake. Only a measurement on the real chip, or a game, can show that. Both happened:
ikari_01's measurements replaced what another document calls unknown, and games corrected
one.
The first games
The first run had 15 games without a chip, for 1,500 frames each, with simple button presses. All 15 showed
changing pictures and made sound, in the first run. Agents looked at 75 of the pictures, small. That says
that the parts fit together. It does not say that the pictures are exact or that the sound is right. Nobody
had listened to it.
Random samples
Games that someone picks are often games that are known to work. So the next runs used random samples of
the person's library. Each had 240 retail files without a chip, with the regions in the same shares as in the
library. The seed of the random choice was written down, so it can be made again. Each file ran for 2,400
frames, with simple presses. The program counted the different pictures and the frames with sound. It also
noted where the main processor was at the end.
| More than 10 different pictures | Crashes |
| First sample | 236 of 240 | 0 |
| Second sample | 238 of 240 | 0 |
Four titles did not get that far. Two of them are in both samples:
- The XBAND is a modem, which is not there.
- Super Game Boy 2 needs a Game Boy game.
- Derby Stallion 96 and Sound Novel Tsukuru have a slot for a data pack, and another map. This is a map that fullsnes
describes, and it was not there then. With it, both go on (
2dc121c).
So each one has a likely cause that is known. Agents also looked at a picture of each game in the first
sample, small, and saw nothing that was clearly broken. Pictures did not show the most interesting
mistake. It was in a game that had pictures and no sound.
The sound boot program
This is the best example of what can be found without the thing itself. The console has a program of 64
bytes that loads all sound. It is its maker's, and is not used here. Ours
was written from the protocol, which the SNESdev Wiki has in words. It passed its tests, and the first games
made sound. Documents say that a game that wants to upload again jumps back to $FFC0, the start.
1. Something was wrong. In the first sample, ESPN Baseball Tonight showed its pictures, but was silent.
2. The question became: where do games really go back into it? Guessing from one game could have led to a
special case for that game. So agents added a log to a private copy of the emulator. Each time that the sound
processor came back into the 64 bytes from outside, the log kept the address, the stack pointer and the flags.
The other registers were looked at where that was needed. Then it ran all 3,093 retail files of the library
that load, for 2,400 frames each.
3. There were three answers, and not one. 388 files came back:
| They enter at | Files | What their registers say |
$FFC0 | 375 | nothing new. This is the one in the documents |
$FFC2 | 9, of 6 games | X is always $EF. The stack pointer that the program sets is $EF too. So the two bytes before this must be the instruction that loads $EF into X |
$FFC9 | 10, of 6 games | the stack pointer is $FB, and the program must not change it from here on. ESPN Baseball Tonight uploads a single ret and starts it. That returns to where it jumped in, and it works only if its stack is still the same |
Six files use both $FFC0 and $FFC2. At the end of the runs, the sound processor had stopped itself in 7
files. Six of them are files that enter at $FFC9. The other one is Sound Novel Tsukuru, which did not
work then, for another reason. So the log also explained why they were silent: in the first version of our program, $FFC9 was
in the middle of its setup, and the next instructions there set the stack pointer.
One thing is not shown by this. A log of both sides' ports had $AA and $BB soon after the game entered at $FFC9. They came from
our own first program, which the game had entered in the middle of its setup. So this says nothing about the console's. That the
direct page is cleared before $FFC9, and not after it, is a guess.
4. That became a rule. All of the setup has to be in the first 9 bytes, and it has to load X in the first
two. From $FFC9 on, the program may not touch the stack pointer, until a command comes. It also leaves the direct page alone, which is the guess from above.
Our program was changed to do this, with our own instructions. The numbers and the reasons are in boot.rs.
5. The rule became tests, which need no game. One starts the program at $FFC9 with another stack and a
full direct page. It checks that these stay as they are, uploads a ret, starts it, and checks that it goes
back. Another one starts it at $FFC2, with $EF in X.
6. Then the games were run again. All six that had stopped at the end made sound. The first sample was run
again too. ESPN Baseball Tonight got better, and 73 other files gave slightly different numbers. Nobody
looked into those. A boot program that takes another time changes when everything after it happens, and that
could be the cause.
What this can show, and what it cannot. Games show where the program must be entered, and what must be
true there. They were looked at from outside. X was $EF each time that a game entered at $FFC2, and the
stack pointer was $FB each time at $FFC9. They do not show the bytes of the original program, or its exact
times. A game that goes back later than 2,400 frames, or only after other presses, could still use another
place.
GETBH and GETBL
When the Super FX was joined, some of its games stopped early. Its crate has many guesses,
and any of them could be wrong. Changing several at once would not show which one mattered. So agents made a
private copy with seven switches. Each one turned one guess or rule into another, and each was run alone on
all 30 Super FX files. For each run, they counted the different pictures:
| What the switch changed | Did it matter? |
GETBH and GETBL keep the other byte of the source register (Sreg), and not of the result's register (Dreg) | yes |
| The main processor can read all registers while the chip runs | no |
| A byte from memory takes 3 cycles at the faster speed, and not 5 | no |
| The main processor can read the RAM while the chip has it | no |
| It can read and write the RAM then | no |
On a GSU-2, banks from $80 on are the same as those from $00 on | no |
| All of these cartridges have 128 KB of RAM | no |
The first one goes against fullsnes, which says that it is Dreg. With Dreg, Dirt Racer, Dirt Trax FX, Doom
and Yoshi's Island stop early or show a blank screen. With Sreg, all four go on. Star Fox, Vortex and Winter
Gold have as many different pictures as before. Nothing else was different between these runs. With that, 27
of the 30 files showed changing pictures. TIMEUP was why the other three did not. The comment in execute.rs says what was seen, and a test keeps the
rule.
This is better evidence than one game: four games need it, and others do not get worse. It is still not a
measurement of the chip. Anyone with a Super FX cartridge and a way to run their own program on it can check
it with one instruction. Give Sreg and Dreg different numbers, run GETBH, and look at the result.
That the other six made no difference does not say that they are right. It only says that they are not why
these games stopped.
TIMEUP and the cartridge's line
Stunt Race FX (in both releases) and Wild Trax showed only two different pictures. A chip and the console share one
interrupt line. When the processor enters an interrupt, a game reads $4211 (TIMEUP), to know if the console's own timer
was the cause. "Timing" in the Super Famicom Development Wiki says that TIMEUP also shows the cartridge's line.
A private copy of ece0887 had a switch for that, which ran on all 80 files with a Super FX or an SA-1. Other
switches ran alone, on the files that they could change. Without the cartridge's line in TIMEUP, the three files went from 2 pictures to 958 to 992. No other Super FX or
SA-1 file gave another number. Another change on the Super FX looked good, and was not used:
| What the switch changed | Result | What was done with it |
| TIMEUP shows only the console's own timer | the three files go on, and no other changed | it is the rule now |
| reading the lower byte of SFR also ends the Super FX's interrupt | Star Fox and Vortex show many more pictures | not used. No document says it, and why the games change was not found out |
Then a test was changed so that it failed, and the rule was put into the real code. In 362375d, the three showed 1,120 to 1,228 pictures in
2,400 frames. This goes against a document, so it is only as strong as the games. Anyone with such a cartridge can check it: let the chip ask for its
interrupt, keep the console's own timer off, and read $4211.
BW-RAM
Kirby's Dream Land 3 and its Japanese release stayed white and silent, with an SA-1. The SA-1 can protect the start of its RAM,
with one register for each side. fullsnes says only of a part of this that it is "probably" so. The bits that protect its smaller I-RAM were
tried the other way round, as the wiki has them. Many SA-1 games stopped early. So that was not the cause.
The copy also had two changes for BW-RAM: no protection at all, and none while either side's register has its writes turned on. With each of them,
the two games went from 16 pictures to 737 to 746, and no other SA-1 file changed. The second way is the one that is used, as it is the smaller change
from the documents: the RAM is protected only while both sides have their writes off. That still has no document and no measurement. It is in the
real code since 362375d, with a test that failed before it. There, the two games showed 1,131 and 1,140 pictures in 2,400 frames.
The chips that came from somebody else
The DSP-1 to DSP-4 and the ST010 run programs of their maker's, and these are never used here. What is public is only enough for
eight commands of the DSP-1. After the first sweep, Super Mario Kart still had no ground, and nine releases were refused for a chip.
The owner found StackBlender's chips, which are under the GPL, version 3 or later, and asked if their
compiled code could be used while snesemu stays MPL-2.0. The answer was no for what is built with them, and yes for the source:
| Question | What was decided |
| Is compiled code under another license than its source? | no. A program with GPL code in it is under the GPL as a whole. A plugin that is loaded later does not reliably change that |
| How can the core stay MPL-2.0? | the chips are a crate in a repository of its own, which depends on the core. The core never depends on it. Only the app and the lab use it, and so only what is built from them is GPL-3.0-or-later |
| Who may read StackBlender's code? | one agent, only for this port, after the owner had allowed it. The agent that works on the core did not open it. It only used the port's README, its credits, its manifest and the names of its functions, and its reports say nothing of how the chips work |
The agent that was to port them first looked at where the code comes from. Each project says how it was made, and that none of its code
came from a chip's program or data. The check found no contradiction, but also no records of their measurements. The main agent then held two
of the five chips back, as the check could not prove what the project says. That was too much. The owner pointed out that the
maintainer clearly says how it was made. A check like this can find a contradiction, but nobody can prove such a
statement. All five were ported. Where they are from is credited as StackBlender's own statement, and the port is not called a clean room.
What was tested:
- The port against StackBlender's C++, on random and systematic calls, with resets and savestates in between: 40 million random calls
for the DSP-3, 100 million for the ST010, and 400 million for each of the others, and for both revisions of the DSP-1. All gave the same results. This shows that
the port is faithful, and not that the chips are like the real ones.
- The interface, with a made-up chip that is in no game: which chip each kind of cartridge has, the registers, the ST010's memory with its battery,
savestates, also damaged ones, and that a state only goes into the same version of the same chip.
- The games, all 38 that have one of these chips (results). Super Mario Kart and
Pilotwings have their ground.
What is still not known: how exact the chips are where StackBlender's own numbers stop, and what games do that depend on how
long a chip takes.
A DMA that was cut off
Agents who looked at the pictures of the first sweep saw that Jumpin' Derby had stripes in its pale parts, and hardly any
text. In the race, there were only broken lines for the text and the horse. Many things were looked at before the cause:
| What it could be | What was found |
| writes to video memory that are lost while the picture is drawn | none were lost |
| results of the multiplier that are read too early | none were |
| what main memory has when the console is turned on | $00, $55 and $FF gave the same pictures |
| the SA-1's reader of bits. fullsnes says that this game uses it, and no other of four games that were compared read from it | the decompression that uses it made 338 copies, and each one ended where it should |
| the colours | they were right. The pale parts show the background colour where BG3 is transparent, and BG3's tiles were wrong |
Most of the tiles still had $FF, which is what BW-RAM has when the console is turned on. The game copies its letters
there with the SA-1's own DMA. A log showed that it turns DMA off 8 clocks after each start. Here, that ended the DMA. That was a guess.
The first fix was not right, and neither was the reason for it. With it, turning DMA off did nothing. The reason was that the game
waits for longer after a longer DMA, which the first lines of the log seemed to show. The pale parts were right then, but a letter
was still broken, and others were missing. More of the log showed why: most of the time, the next DMA starts 332 clocks after the one before,
also when that takes 2,304. So the game does not wait at all. It seems that the SA-1's processor stops until the DMA is done.
A private copy ran four rules on all 50 files with an SA-1:
| The rule | Jumpin' Derby | The other 49 |
| as it was | stripes, and no text | |
| turning DMA off does not end it | a letter is broken | all the same |
| the processor stops for a DMA from the ROM | the text can be read, and is whole | 48 the same, and Marvelous shows 903 pictures in place of 902 |
| it stops for each DMA | the same | the same as with the rule above |
The third one is used, as it is the smaller change. It also fits fullsnes: the bit that says if a DMA or the processor
comes first is only for DMAs between BW-RAM and I-RAM. That the processor also stops when the ROM's data goes to I-RAM is a guess. One
of the older tests said that the processor runs on during a DMA from the ROM, which had been a guess. It now uses a DMA
from BW-RAM. Two new tests have what the game does, and that the processor runs on between the memories. They failed before. All 50 files give the same with
whole lines as dot by dot, for 1,500 frames each.
What is still not known: what the chip does when DMA is turned off during a DMA that does not stop the processor, and whether the processor
really stops or only waits for the ROM. A program on a console with such a chip can show this, if it counts in a loop during DMAs.
When the script is the cause
Dragon Ball Z: Hyper Dimension was said to be stuck, as it showed few pictures. It is not. Without any press, the Japanese
release showed 494 different pictures in 2,400 frames, in a private copy of ece0887. With the script's presses, it stays on one screen: 48 pictures in the French and the Japanese
release (362375d). The script presses Start again and again, and that is what keeps it there. Nothing in the emulator was changed. It is a
reminder to run each game that stands out without presses too.
The place of the DSP-1
Two of three games with a DSP-1 and more than 1 MB of LoROM stayed at their first picture. fullsnes has a place for the chip's registers on
such boards, but gives the console maker's manual as its source. So that place was not used, and it was taken out of the code.
Then the games were asked:
- The game's accesses were logged, only in the two places where the DSP-1's registers are in LoROM cartridges: the upper halves of
$30-$3F, and banks $60-$6F. The only reads there were from $E0:4000-$E0:4FFF. Two of the games did so 3,468,271 times in 900 frames.
- A private copy answered "ready" there, and noted each access with its address. All three games wrote
$FF once to $E0:0000, read $E0:4000
once, and went on.
- A layout with these two places was made, and the same test as for the other boards was made for it. It failed without the layout. With it, the three
games show the same numbers of pictures as in the private copy.
The result is the same place that was left out before. But now it rests on what anyone can see in these games, and
not on the manual. What was not seen is marked as a guess: how large the places are, and in which other banks they are.
A chip that tests itself
The games with an SPC7110 have a test of the chip in their cartridge. It runs when the save memory is empty. At first, all five files said REG INIT:
NG, and OK for everything else: the RAM, the data port, the multiplier and the divider, the length of the compressed data and, in the three files of
Tengai Makyou Zero, the clock. The one line that failed is also the most useful. No one had to know what the chip does there. The test itself says when it is right.
1. The log of its accesses. A private copy noted each register that the test used. It reads each register once, in order, and the last one is $4810.
Our chip gave the first byte of the data ROM for it. It gave the same for $481A. Nobody had written to the port yet.
2. One change at a time, in all combinations, with one of the games:
| What the port gives before anything is written to it | REG INIT |
data at $4810 and $481A, as before | NG |
0 at $4810 only | NG |
0 at $481A only | NG |
| 0 at both | OK, and the test says ALL OK |
3. Which write turns it on is not known. fullsnes says that "reportedly" the port does nothing at first, and that a number other than 0 in $4813
turns it on. The games' test writes 0 to all of its registers, and then reads data. So another write has to be able to turn it on, too. Here, any
write to one of its registers does. That is a guess, and the comment says so.
4. It became a test that needs no game. It reads both registers before each of the eight writes, and after them. It failed before the change.
5. Then the games were run as a player would have to play them, with the console turned off and on in between and the battery put back.
They did not go on at once. What was learned, one step after another:
| What was tried | What happened |
| turned off and on once, with the script's usual presses | part 1 ran again |
| what is in the save was looked at | without any press, it stayed empty. With presses, 16 bytes of $11 were at the end of the RAM. This is the mark that the game looks for. After a restart, it reads all 16 |
| turned off and on, and no press after it | the games ask to press B. Tengai Makyou Zero also says that its save is broken, which is what it says of a new cartridge |
| only B was pressed | part 2 came: S-RAM BACKUP and, with the clock, RTC BACKUP, were OK |
| turned off and on a second time | the games started |
This checks code that was just written, with a test that nobody here made: that the clock goes on while the console is off. For the RAM, it was
first taken for a check too, and that was too much. In the app, B was pressed by mistake before part 1 had run. S-RAM BACKUP said OK although
no save was kept, and RTC BACKUP said NG. Only the mark of 16 bytes shows that the RAM is kept.
Two of the games came to their menus, with sound. Tengai Makyou Zero asks for the date and the time, and the script went no further.
What this does not show. The test is the chip maker's or the game's, and how it works was not looked at. Each line only shows that this one check
agreed, in runs that are always the same. A alone sets the mark, as the app showed later. Which press let part 1 come again was not tested on its own. No test
shows that all data decompresses correctly, and no game was played. The page about the chip has each line, and how to see it.
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. A result only helps when it says
which console or chip it is from, and how it was measured, so that others can repeat it:
| Question | How someone could find out |
| The 512 numbers of the S-DSP's table | a published measurement that can be used. For example, play one sample that is only one step, with different pitches, and record the digital sound of a console |
How long the console's boot program takes until $AA and $BB are there, and which numbers it takes as "ahead" around 255 and 0 | a test program for the main processor, run on a console. It reads the counters when the two bytes come, and then tries pairs of numbers for a block and for the command after it |
| What the sound clock should be | there is no single answer: consoles are different. Measurements of more consoles could show which is the most common |
Where the waiting cycle of the loads from [dp]+Y is | a program for the sound processor on a console, which lets such a load read a pointer or a byte that a timer changes at that moment |
The second byte of the pointer for (d,X) in emulation mode | a short program on a console, with different bytes in both places |
| When in its cycle the main processor reads and writes | test programs that use the picture's registers at each possible clock |
| How HDMA lines itself up, and in which order channels send and go on in their tables | HDMA from several channels to $2180, which shows the order, and counters that are latched before and after it |
| What a multiplication or division gives when it is read too early, or started again too early | a table of results from test programs on consoles. Some have been published, but not the whole rule |
| Which dots a change in the middle of a line reaches | a test program that writes a register at a known clock, and pictures of its output on a console |
| How long the SA-1's processors wait for each other, and the Super FX's exact times | programs that time themselves, in cartridges with these chips |
| Where the boards have their save memory | the boards are described. But a game's file does not say which board it has, and a list of games is not allowed here |
| The DSP-1's four commands for a ground plane | a description that can be used. Looking at what games send shows what the inputs could be, but not the exact answers |
| What TIMEUP shows of the cartridge's line, and when BW-RAM is protected | a program on a console, with a cartridge of one's own that has the chip. The games' behaviour is all that there is so far |
| How much of the bank a DSP-1 fills in a large LoROM cartridge | a program on such a board that reads all addresses of banks $60-$6F and $E0-$EF |
| Which write turns on the SPC7110's data port, and how long the chip takes for anything | a program on a console, in a cartridge with the chip |
| Why Star Fox and Vortex show more pictures when reading the Super FX's lower status byte ends its interrupt | nothing in the documents says so. The first difference between the two runs of one of these games should be found |
Whether the boot program clears the direct page before $FFC9 or after it | a program on a console that fills the direct page, jumps to $FFC9, and looks at it after the next upload. A short log of where the console's program goes would be enough too |
How to check it, or do it again
- Read a rule and its comment. It names a document, a test 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.
- Run the tests:
cargo test --workspace, and those of the
processors with their data.
- Change a number in the code that a test should know, and see if the test fails. This is a good way to
find out what a test is worth.
- Run your own games, choose them at random, and write down how they were chosen. Count something simple
that all of them have. Look at those that stand out.
- If something is wrong, change one thing for each run, and run it on all games that could be affected.
Then make a test that does not need a game.
Someone who wants to write another emulator in this way can start with the
guide. These are the points that helped
here:
- Decide the license and the sources before any code, and write both into each task.
- Agree on what is between the parts first. How time goes from one to the other is the most important part
of that.
- Take numbers from documents as tests before there is anything to play.
- Say what each kind of evidence is worth. Agreeing with another emulator's data, a document, a
measurement and many games are all different.
- Let games answer questions, and do not add special cases for them. Ask the same question of all of them.
- Mark guesses and gaps where they are. A list of them is also a list of what to find out next.