The DSP-1
The DSP-1 is a chip for mathematics in cartridges, an NEC processor with a program and data of its maker.
Super Mario Kart and Pilotwings have one. Games send it a command with some numbers, and get the results.
Its program and data are not here, and were not used or rebuilt: not from a copy, not from its test
command that sends out its data, and not from an emulator. Eight of its commands are described in public. Our
own program does those with ordinary mathematics.
This page is about our own DSP-1, which the core has by itself. The app and the lab have StackBlender's
chips in its place, which also draw the ground. They are in a crate of their own.
Our own is not enough for games that use the chip for a ground plane in mode 7. The four
commands for that are missing. The core uses the chip, so these games start, and
what they need and do not get is below.
It is in crates/snes-dsp1. Its README has every equation, the errors,
and how the results are derived.
| Used for |
| Martin Korth's fullsnes, "NEC uPD77C25 - Registers & Flags & Overview" and "BIOS Functions" | the registers, the protocol, the boards, and the commands' names |
| The SNESdev Wiki's "DSP-1", as edited on 2025-02-13 | the inputs, the outputs, the number formats, the equations and the cycles of eight commands |
| What games do | where the registers are in a LoROM cartridge with more than 1 MB |
An owner decided that the wiki's page can be a source. It does not name its own.
What is there
Numbers are 16 bits. An angle is a fraction of a turn: $4000 is 90°.
| Command | Inputs | What it gives |
$00 | a, b | a × b / 2^15 |
$10 | a number and an exponent | its inverse, as a number and an exponent |
$04 | an angle and r | r × sine, and r × cosine |
$08 | x, y, z | x² + y² + z², in 32 bits |
$18 | x, y, z, r | (x² + y² + z² − r²) / 2^15 |
$28 | x, y, z | the square root of x² + y² + z² |
$0C | an angle, x, y | the point, turned in two dimensions |
$1C | three angles, x, y, z | the point, turned in three dimensions |
fullsnes gives $20 the same name as $00, and $38 the same as $18, and nothing more. How they differ is not
known, so they are missing.
How exact is it? Each result is compared with its equation in floating point, worked out separately, for
50,000 random inputs and many edge values. $10 is compared for every number but 0. $00, $08 and $18
are exactly what their equation says, rounded down, if it fits. $04, $0C and $1C are at most 0.501 of
the last digit away from it, and $28 at most 0.5. With $10, the result times the input is 1, with an error
of at most 2^-15. This is the distance from the equation, and not from the chip. How the chip rounds,
which tables it uses, and what it gives when a result does not fit are not known. Nothing was compared with
one. For results that do not fit, the nearest value that fits is used, which is a guess. $1C is the least
certain. The wiki's equation and its text have the angles in another order. The equation is used.
All tables are made from formulas when the emulator is compiled, with whole numbers only: π by Machin's
formula, and the sines and cosines by their power series.
How a program talks to it
There is one data register of 16 bits (DR) and a status (SR). A command is one byte, and each number is two
bytes, the lower one first. In the status, bit 7 (RQM) says that the chip waits for the main processor. Bit
4 says that the first half of a number has gone through, and bit 2 that the next value has only one byte.
For example, command $00 multiplies 0.5 by 0.25. Its numbers have 15 bits after the point:
| Main processor | The chip |
| 1 | waits until bit 7 of the status is 1, and writes $00 | takes the command. It is busy for 6 of its cycles |
| 2 | waits until bit 7 is 1, and writes $00 and $40 (0.5) | has the first number, and is busy for 12 cycles |
| 3 | waits, and writes $00 and $20 (0.25) | has the second number. It is busy for 4 cycles, and then has the result in DR |
| 4 | waits, and reads $00 and $10, which is 0.125 | busy for 4 cycles. After that, DR has $80 |
The chip cannot tell a read from a write. Any complete value lets it go on. So a read while it waits for a
number takes what DR has as that number. A write while it gives its results counts as a read. $80 is in DR
when it waits for a command. It is not a command, so if a program reads too much, nothing starts.
The times are guesses in part. The cycles come from the wiki, which does not say what they are. Here they
are the chip's own, at its highest speed of 8.192 MHz. The boards' real speeds are in neither source. This
gives the shortest time that could fit. It is worked out with the NTSC console's clock, on a PAL console too. So these times are about
0.9% longer there. If a program uses a value while the chip is busy, it only changes DR,
which is a guess.
The chip uses no ROM or RAM of the cartridge, and has no interrupt. It does nothing between accesses, so it
can wait for any time.
Where its registers are
The chip is added to the cartridge's own map. Where its two registers are, the ROM is
not. The rest of the cartridge is as without a chip. The header does not say which board it is, so the core chooses by
the map and by the ROM's size:
| Cartridge | Data | Status | Where it is from |
| HiROM and ExHiROM | $00-$1F: $6000-$6FFF | $7000-$7FFF | fullsnes |
| LoROM, up to 1 MB, without RAM | $30-$3F: $8000-$BFFF | $C000-$FFFF | fullsnes, and the SNESdev Wiki |
| LoROM, up to 1 MB, with RAM (DSP-2 and DSP-3) | $20-$3F: $8000-$BFFF | $20-$3F: $C000-$FFFF | fullsnes |
| the ST010's board | $60-$67: $0000 | $60-$67: $0001 | fullsnes, but for the last bank. Its memory is at $68-$6F: $0000-$0FFF |
| LoROM, more than 1 MB | bank $60: $0000-$3FFF | $4000-$7FFF | what games do (below) |
Each is also in the banks $80 higher. ports.rs also has another layout of
fullsnes (HiROM with a MAD-2), which the core does not use.
The place that games showed
fullsnes has a layout for LoROM with 2 MB, but gives the console maker's manual as its source. It was not used.
So where the registers are in these cartridges was found from what their games do, with no document:
- Three releases have a DSP and more than 1 MB of LoROM: Super Bases Loaded 2, Super 3D Baseball and Hanguk Pro Yagu. Without a
chip there, two of them showed one picture, and one went on.
- A private copy noted what they read in banks
$60-$6F, and in the upper halves of $30-$3F, where smaller LoROM cartridges have
the chip. The only reads there were from $E0:4000-$E0:4FFF. Two of the games did that 3,468,271 times in 900 frames, as a program does that waits.
- The copy then said "ready" there. All three wrote
$FF once to $E0:0000, read $E0:4000 once, and went on. In 2,400 frames, they
showed 340, 379 and 373 different pictures. With the layout in the core, they showed the same numbers.
So the status is at $E0:4000, and the data most likely at $E0:0000. How large each place is, and that it is only in this bank and in
$60, is a guess. $FF is no command that is known. The chip takes it as any unknown one, and all three go on.
With StackBlender's chips
The app and the lab have the DSP-1 to DSP-4 and the ST010 by StackBlender, in a Rust port.
Its README says how each is used and what is missing. How they work is in that
crate, and not here, as the two sides stay apart.
All 38 releases with one of these chips were run for 4,800 frames with simple presses, with snes-nec-gpl c0aa59c (the code of its first public commit,
d607970, is the same. Only its CI, Cargo.toml, Cargo.lock and deny.toml differ). The core was the one of ab6d397. Each one showed more than 10 different pictures.
Pictures of 14 releases with a DSP and of both with an ST010 were looked at, small:
| Game | What was seen |
| Super Mario Kart (Europe) | the track, the map from above, and the other seven karts going round it, for 33 seconds. In the other two releases, the script chose a game for two players, and stayed where the second one chooses a driver. In the app (dea2f24, its Linux package, with real key presses), the release for the United States came to a race for one player. Mario drove off, and a state that was saved in the race went on after the app was closed. A build without these chips refused a state of this game |
| Pilotwings | a flight over the desert, with the place to land on the horizon |
| Battle Racers, Suzuka 8 Hours, Final Stretch, Super F1 Circus Gaiden | tracks in races, with the view that each game has |
| Top Gear 3000 (DSP-4) | the Japanese release came to a race, with the road, mountains, trees and cars. The one for the United States stayed in its menu |
| Dungeon Master (DSP-2) | the dungeon in three dimensions |
| SD Gundam GX (DSP-3) | only its first menu. So this says nothing about what the chip gives in the game |
| Exhaust Heat II and F1 ROC II (ST010) | the track in the qualifying round. Once or more, they also used "another port", which is not known. The chip reports it, and what it is was not looked at |
None of the 36 games with a DSP used a command that is not known. The fast picture and the exact one were the same in all 38, with
the sound, the memory and the processor, for 3,000 frames each. This does not show that the numbers are right, or that the
games can be played. Nobody has played one.
What is missing, and why
21 commands have only a name in public. Their number of inputs and outputs, their order, units and
formats, and their equations are not described:
| Commands | What is missing above all |
$02 sets up the projection | how it describes the camera and the screen, and what it keeps for the next three |
$0A gives the data for a line of mode 7 | how it goes on from line to line, and how it ends |
$06 projects an object, $0E finds a point on the screen | both need what $02 keeps |
$01, $11, $21 set an attitude | which angles or numbers make its matrix, in which order, and how large it is |
$0D, $1D, $2D, $03, $13, $23, $0B, $1B, $2B use one of these matrices | the matrix itself |
$14 turns an angle in three dimensions | which angle is turned by which |
$20 and $38 have the names of $00 and $18 | how they differ from those |
$0F a memory test, $2F the version | the test's inputs and outputs. For the version, fullsnes has the result, and not the inputs |
General mathematics has many forms of a perspective projection. Which one the chip uses is the question.
Writing one of them without knowing would be invented, so it is not done. $1F sends out the chip's data. It
is never answered, as that is its maker's.
Which DSP it is
The header only says that there is a DSP. The core finds out which one from the rest of the header, without a list of games:
| The cartridge | The chip | Why |
| LoROM, up to 1 MB, 32 KB of RAM | DSP-2 | fullsnes' table of boards |
| LoROM, up to 1 MB, 8 KB of RAM | DSP-3 | the same |
| LoROM, more than 512 KB and up to 1 MB, no RAM, fast ROM | DSP-4 | a guess: the board is the same as a DSP-1's. All three releases of Top Gear 3000 are like this. Pilotwings, which has a DSP-1 on such a board, has 512 KB of slow ROM |
| all others | DSP-1 | the same table |
With other sizes of RAM, a LoROM cartridge of up to 1 MB is refused.
What games send
36 releases with a DSP were run for 2,400 frames each, with simple presses (9b6b373). Five were refused then, with a DSP-2 or DSP-3: Dungeon Master (four) and
SD Gundam GX. Three have a DSP-4, and were run with a DSP-1 then. That leaves 28 with a DSP-1. All of them showed more than 10 different pictures (Super F1 Circus Gaiden: 644, with
2dc121c). The chip keeps a log of the commands it got. Only the first missing one is certain: what follows can be part of it.
| The first missing command | Releases |
$02, for the ground | 9, such as Super Mario Kart, Ace o Nerae!, Final Stretch and Suzuka 8 Hours |
$2F, the version | 7, such as Ballz 3D, Drift King Shutokou Battle 2 and Michael Andretti's Indy Car Challenge |
$0A, for the ground | 3: the releases of Pilotwings |
$0F, the memory test | 1: Soukou Kihei Votoms |
$14, which turns an angle | 1: Super F1 Circus Gaiden |
| none | 7: the three of the large LoROM cartridges, whose $FF is unknown, and 4 that sent nothing that is missing or unknown: Bike Daisuki!, Lock On and the two of Super Air Diver |
These are the first screens only. A game that sent nothing that is missing so far can still do so later. Pictures of some
of these games were looked at, small. In a race of Battle Racers, the ground is an empty area. Nobody has played one.
After a missing command, each byte of data that is read is 0, and the chip is always ready. What is written
does nothing. The first write after a read is taken as a new command. This is our own choice, so that a game
does not wait forever. Where the real command would end is not known, so what comes next can be wrong. The
chip keeps a log of the commands that came, and of the first missing one, for reports.
A way forward is to look at what games send, from outside: not only which commands, but also how
many values, and in which ranges. That does not give the answers, so public documents and games alone are not
enough for exact results. How it was made has the other open
questions.