The S-DD1
The S-DD1 decompresses graphics while a DMA reads them. Star Ocean and Street Fighter Alpha 2 have one. The game says
which channels may do it and starts a DMA. Each byte that it moves is then a decompressed one. Nothing else of the game
changes, and the main processor never sees the compressed data as anything but ROM.
It is in crates/snes-sdd1, and all of it is our own. All of the decompression rests on Andreas Naive's research. He
worked out the algorithm from the outside, and described it in words with its tables.
| Used for |
| Andreas Naive, his description of the algorithm | the decompression, with its table of 33 states and its 8 codes |
| Martin Korth's fullsnes, "SNES Cart S-DD1" | the registers, and what the description leaves open |
| Near, posts of 2016-04-29, with what Near measured with Star Ocean on a console. AWJ found there that the registers that cannot be read are the ROM | the memory map, and what reading the registers gives |
| Near, a post of 2013-08-27 | that the chip needs a fixed address. Near concluded this from outside, and nobody has measured it |
The code that some of these pages link to was not used.
What the main processor sees
| Address | What is there |
$4800 | which channels can decompress. It stays as it is after a DMA |
$4801 | which ones do so in the next DMA. Each bit is cleared when that is done |
$4804-$4807 | which 1 MB of the ROM is at $C0-$CF, $D0-$DF, $E0-$EF and $F0-$FF (bits 0 to 3). Bit 7 of $4805 and $4807 repeats the ROM of $00-$1F and $80-$9F in the banks from $20 and $A0 on |
$4802, $4803, $4808-$480F | they read the ROM. Writes do nothing |
$00-$3F, $80-$BF: $6000-$7FFF | 8 KB of the cartridge's RAM, the same in each bank |
$70-$73 | the cartridge's RAM |
$00-$3F, $80-$BF: $8000-$FFFF | the first 2 MB of the ROM, as LoROM |
$C0-$FF | the ROM, in blocks of 1 MB |
The registers are in banks $00-$3F and $80-$BF. The rest has nothing.
How it knows of a DMA
The chip sees the main processor's writes to the DMA's own registers, $4300 to $437F. This is how others explain
what it does, and nobody has measured it. So it knows where each channel starts, how many bytes it has, and whether its
address stays the same. In the core, two places talk to it:
| In the core | When |
the bus tells it of each write to $4300-$437F | besides doing the write. What DMA and HDMA change in their registers by themselves is not sent |
| DMA asks it for each byte from the A-bus to the B-bus | before it reads the cartridge. It gets a decompressed byte, or nothing. In that case it reads as always |
A byte takes the same 8 clocks in both cases. HDMA never asks. Its tables and data are always read as they are.
A run is what is decompressed from one start. It begins with the first byte that a channel asks for, if:
- its bit is set in
$4800 and in $4801,
- its control register says from the A-bus to the B-bus, with a fixed address, and
- the address has ROM, and is the one that was written to the channel's registers.
The compressed data starts at that address. Each later byte of the channel goes on with it. After as many bytes as were
written to the channel's count, the run ends, and its bit in $4801 is cleared. Each channel has a run of its own.
For example: 64 bytes, step by step
This is one of the core's tests. Channel 1 copies to main memory through $2180:
| Main processor | The chip |
| 1 | writes $08, $80, then $10, $00, $C1 and $40, $00 to $4310-$4316: to $2180, fixed, from $C1:0010, 64 bytes | sees each write, and keeps what it needs |
| 2 | writes 2 to $4800 and to $4801 | channel 1 may decompress, and will do so in the next DMA |
| 3 | writes where the bytes go to $2181-$2183, and 2 to $420B | |
| 4 | stops for the DMA, which asks for the first byte, from $C1:0010 | reads the first 4 bits there, which say how the data is put together, starts its decoder, and gives the first byte |
| 5 | still stopped. The DMA asks 63 more times, always with the same address | goes on with the compressed data. After the last byte, it clears bit 1 of $4801 |
| 6 | goes on. Main memory has the decompressed bytes | |
The test compares the bytes with what the crate itself gives for the same writes. If bit 1 of $4801 is clear, the same DMA copies
the byte at $C1:0010 64 times, and takes the same time. A normal read of $C1:0010 gives the byte of the ROM, also while the
chip is set up.
How it decompresses
The first 4 bits of the data say how the bits become bitplanes (tiles with 2, 4 or 8 bits for each pixel, or whole bytes), and
which earlier bits of a bitplane choose a bit's context. What follows are codewords:
- The next bit's context is whether its bitplane is odd, and 3 or 4 earlier bits of it.
- Each context has the bit that is more likely, and one of 33 states. The state says which of 8 codes to use.
- Each code has a run: some zeros, and then maybe a one. When it is used up, the next codeword is read.
- The next bit of the run is 0 for the more likely bit, and 1 for the other one.
- After the last bit of a run, the context gets its next state. The bit says which.
What is a guess, and what is not there
- At power-on and after a reset,
$4800 and $4801 are 0, and the four blocks of the ROM are 0, 1, 2 and 3.
- Everything that ends a run early: a write to
$4800, $4801 or the channel's registers, or a run of another channel. If
HDMA on the same channel ends the DMA, the rest of the run stays until then.
- Looking at the control register for the fixed address is our guess too. Near concluded that the chip needs one.
- ROM and RAM that are smaller than their place repeat. A run goes on after the end of 1 MB in the next block.
- Not there: the chip's speed. It reads at most 16 bits for each byte that it gives. With data that needs more for a long
time, it repeats a byte or hangs. Naive describes this, and says that games' data does not do it, as far as he saw. How
early a run has to be set up is not there either.
What was tested
All five releases that were tried show changing pictures and make sound: Star Ocean, and Street Fighter Alpha 2 in its
American (two releases) and European versions and as Street Fighter Zero 2 (6ac98a1, 2,400 frames each, with simple presses).
They showed 637 to 920 different pictures. Pictures of Star Ocean and Street Fighter Zero 2 were looked at, small. Their
titles, the portrait, the choice of a character and a stage look right. That does not show that each byte is right.
The decoder is tested with a compressor of our own, which turns the description around: data of each kind and length, in
every mode, comes back as it was. That cannot find a mistake that both have. The chip's tests have the map, as Near
measured it, and what begins and ends a run.