Yabanjin design notes
Yabanjin is a libretro Sega Saturn core for ARM64 handhelds. It renders in software, and it is tuned on the Anbernic RG ARC-S, a handheld with four Cortex-A55 cores. These notes follow it from the code it inherits to 0.5.3, its first public release: what was kept, what was replaced, what each change was measured to cost, and what is still open.
Where it comes from
Yabanjin is the fifth step of one line of Saturn emulators. Each step kept the tree of the one before and added to it.
Yabause is the root. Its libretro port made it a core. Yabadabadoo, by ProRapSuperstarOriginalMaster, tuned that core for small handhelds. elderica's aarch64-dynarec branch of Yabadabadoo brought Ari64's SH-2 recompiler to ARM64. Yabanjin starts from that branch.
The aim is the Saturn's 2D library at full speed without a GPU renderer, and as much of the 3D one as the A55 cores allow. Games that stop, hang or play wrong are fixed one at a time. Each fix takes Mednafen's behaviour as the reference and is checked on the device.
Making it a core of its own
Games were fixed on the inherited code first. Then Yabanjin became a hard fork: a libretro core only, with the code no build uses removed, a new sound model and a new CD drive.
What changed, in order
- The first fixes were in the SH-2 recompiler and the SCU: TRAPA, writes to SR, branches in delay slots, the DSP's DMA. Three games needed an effect of the SH-2's cache modelled for them: Astal, Dark Savior and Dragon Force II.
- Code the game writes over is invalidated block by block. A changed word takes out only the blocks that hold it. This brought Marvel Super Heroes vs. Street Fighter and X-Men vs. Street Fighter to full speed.
- Two DSP recompilers for ARM64 followed, one for the SCU's DSP and one for the sound chip's effect DSP. With both, Grandia went from 13.4 to 9.0 ms a frame.
- The sound model was replaced. Yabause's old model is gone. The only model works per sample: it is d356's, as YabaSanshiro 1.20.55 brought it. Its levels and its effect DSP were made to agree with Mednafen's.
- The CD drive follows Mednafen's model: a state machine on the drive's own clock, with seeks timed by their distance.
- The fork and the prune removed the other front ends, the OpenGL renderers, the other CPU cores and the low-level CD block. About 1,370 files became 731.
- Every VDP1 list is timed. The per-game list of games that needed it is gone.
- Builds for play use profile guidance (PGO) and link-time optimisation (LTO). The profile comes from the 98 test games, chosen because Mednafen and Ymir single them out.
Subsystem by subsystem
The same history, laid out by chip. Each row reads left to right: what Yabause had, what Yabadabadoo and elderica added, and what Yabanjin did up to 0.5.3. The later chapters explain the larger items.
-ffast-math offDrawing the picture
The Saturn's VDP2 chip mixes up to six layers into a picture. This chapter is a design study of four ways to do that in software. One was inherited, one was tried and turned off, one ships, and one is the reference emulator's.
Each timeline is one frame in wall-clock time, drawn to the same scale. A shorter row means a shorter frame for the main thread. A Saturn frame starts at VBlank-OUT. 224 display lines follow. VBlank-IN marks the end of the display. Then come 38 VBlank lines until the next VBlank-OUT.
Whole-frame layers inherited · replaced as the default
Compositing during the VBlank tried · a switch, off
retro_run as before. The wait for the layer threads and the RAM traffic are unchanged, so the gain is bounded by the VBlank lines' share of the frame, about a seventh. Measured on the ARC-S at 1.104 GHz over thirteen heavy games: −1.2 % in plain builds. In play it tripled the audio that Marvel vs. SF drops in a heavy scene, so it stays off.Bands ships
| ms a frame | No band workers | Three band workers |
|---|---|---|
| Panzer Dragoon Saga | 8.49 | 6.61 |
| Metal Slug | 6.26 | 5.59 |
| Fighters Megamix | 7.46 | 6.84 |
| Virtua Fighter 2 | 9.76 | 9.29 |
| Grandia | 9.70 | 9.31 |
| Burning Rangers | 7.33 | 7.08 |
| Sega Rally | 6.94 | 6.81 |
| Daytona USA CE | 7.96 | 7.93 |
| Panzer Dragoon II | 7.13 | 7.16 |
| Duke Nukem 3D | 6.59 | 6.69 |
| Quake | 6.58 | 6.70 |
| Radiant Silvergun | 8.35 | 8.55 |
ARC-S at 1.104 GHz, two runs each. The twelve games together: −4.3 %. The 98 test games give the same pictures as the renderer without bands. Where the bands lose, the emulation thread waits longer for the sound thread: seven threads are busy on four cores.
Mednafen's line renderer reference · not built here
Where the layer pixels live
Side by side
| Whole-frame layers | Compositing during the VBlank | Bands | Mednafen | |
|---|---|---|---|---|
| Unit of work | a whole layer, whole frame | same | all layers of a band of lines | all layers of one line |
| Threads | 6 layer, 5 compositing, plus the main thread's share | 6 layer, 5 compositing | 3 band workers | 1 render thread |
| Layer data | 3.4 MB, through RAM | 3.4 MB, through RAM | ≈ 240 KB for a 16-line band, in the shared cache | ≈ 35 KB, in L1 |
| Main thread at VBlank-IN | stops: waits for layers, composites | waits for layers, then emulates on while compositing runs | goes on; the workers draw while it emulates | never stops; it only queues lines |
| Mid-frame changes | registers captured per line; VRAM as at the frame's start | same | same | exact: every write replayed in order |
| Picture shows | the previous frame's display (a frame behind, like VDP1's) | same | same | the frame just emulated |
| Status | inherited; still the path on fewer than four cores | tried; a switch, off | ships: the default on four cores or more | reference; not built here |
One more idea was tried and dropped: NEON for the compositing loops, four pixels at a time. It was exact, and slower on the ARC-S in five of six games. Virtua Fighter 2's compositing went from 3.03 to 4.5 ms a frame.
Speed, build by build
The new sound model and CD drive cost speed. This chapter follows each PGO build across those two rewrites on the ARC-S: what each change cost and what the work after it took back.
Across the sound and CD rewrites ARC-S · 1.104 GHz locked · ms a frame
What moved it
| Build | What changed | Six games | Change | Where it went |
|---|---|---|---|---|
47a00f41 | Before both rewrites: Yabause's sound model and CD block, PGO on 21950a2f's profile. | 6.69 | — | The reference. |
0780e110 | The per-sample sound model at Mednafen's levels, its effect DSP bit for bit. | 7.85 | ▲ +17.4 % | Every game slower: Sega Rally +2.36 ms, Panzer Dragoon II +1.49, Megamix +1.26, Silvergun +1.08. The profile was trained before this code existed. |
583e2d8f | The CD drive on Mednafen's model, with the sound model. | 7.83 | • −0.3 % | No measurable cost. |
0bf3b162 | Deep Fear's DMA fix, Leynos 2's reset, a per-game VDP1 list (Metal Slug, Dark Savior); still 21950a2f's profile. | 8.13 | ▲ +3.9 % | Sega Rally +0.86 ms, Panzer Dragoon II +0.55; not traced to one change. |
7158ea44 | Every timed VDP1 list drawn at its end (no per-game list), fast math off, small speedups (−1.4 % on their own), a profile retrained on all 98 games. | 7.60 | ▼ −6.6 % | All six faster. Virtua Fighter 2 +2.39 ms and Fighting Vipers +3.27 ms: the VDP1 timing's race check. |
62bdc053 | The race check skipped for lists drawn at their start (fc4caa75). | 7.64 | • +0.5 % | Virtua Fighter 2 and Fighting Vipers back, each about 0.2 ms over 0bf3b162. All 98 games: 7.27 → 6.79 ms against 0bf3b162 (−6.6 %). |
8910eeb6 | 62bdc053's code with compositing during the VBlank's lines (0120e464). | 7.57 | • −0.9 % | Grandia −0.22 ms. Turned off: in play it tripled the audio Marvel vs. SF drops. |
d569b453 | Profile retrained (source f5195737). Speed: silent sound slots skip their stages, the sound DSP recompiler's sign extensions (Burning Rangers' DSP −35 %), the 68K idle skip in Marvel's loop. Fixes: the TRAPA block end, jumps into delay slots (Leynos 2), Burning Rangers' fires, the sprite layer's reuse, the disc LED. | 7.13 | ▼ −6.6 % | Every game faster. Its last fixes (the fires, the reuse key, the stream rule) cost 0 to 2 % on 12 games, and 2.5 ms a frame in Burning Rangers' hangar, which the bench scene doesn't reach (14.6 → 17.1 ms, plain builds). |
Change is against the build before on the line. For 8910eeb6 it is against 62bdc053, which it was built on. Each build was timed in its own session, two or three runs, alternated with the build it replaced. Runs of one core agree within about 0.05 ms. The headless bench plays each game's own scene and reports the emulator's work per shown frame. 16.7 ms is full speed.
Game by game
| ms a frame | 47a00f41before | 0780e110sound model | 583e2d8fCD drive | 0bf3b162game fixes | 7158ea44retrained | 62bdc053race check | 8910eeb6VBlank mix | d569b453speed work |
|---|---|---|---|---|---|---|---|---|
| Burning Rangers | 7.01 | 7.36 | 7.29 | 7.33 | 7.19 | 7.24 | 7.13 | 6.88 |
| Fighters Megamix | 6.32 | 7.58 | 7.64 | 7.72 | 7.50 | 7.53 | 7.58 | 6.91 |
| Grandia | 9.29 | 9.74 | 9.73 | 9.88 | 9.49 | 9.51 | 9.29 | 8.93 |
| Panzer Dragoon II | 5.53 | 7.02 | 7.10 | 7.65 | 6.82 | 6.87 | 6.81 | 6.38 |
| Radiant Silvergun | 7.20 | 8.28 | 8.21 | 8.35 | 7.97 | 8.02 | 8.03 | 7.50 |
| Sega Rally | 4.77 | 7.13 | 7.01 | 7.87 | 6.63 | 6.67 | 6.59 | 6.20 |
| Virtua Fighter 2 | 8.41 | 9.47 | 9.39 | 9.35 | 11.74 | 9.59 | 9.57 | 9.01 |
| Fighting Vipers | – | – | – | 10.03 | 13.30 | 10.24 | 10.13 | – |
| Mean of the six | 6.69 | 7.85 | 7.83 | 8.13 | 7.60 | 7.64 | 7.57 | 7.13 |
Virtua Fighter 2 and Fighting Vipers were not in every run (– where not timed).
The chart stops before the band renderer of chapter 3, which came next. So did block-by-block invalidation for Burning Rangers' rewritten code, which chapter 6 takes up.
Every chip checked against two references
With the core playing its test games, six chips were checked one at a time against Mednafen and Ymir: the SH-2 and its recompiler, VDP2, VDP1, the SCSP's voices, the 68000 and the SCU DSP. Each chip has a harness that runs the same cases through all three emulators. Then the whole machine was checked.
How a fault was found and a fix accepted
The harnesses
| Harness | Chip | Against | What it runs |
|---|---|---|---|
sh2fuzz | SH-2, interpreter and recompiler | Mednafen's and Ymir's SH-2 | Random programs and hand-written sets, registers and memory compared at the end; Ymir's divider and MAC vectors. A difference is shrunk to its shortest program. The recompiler's stress modes put junk in dead registers and take every cycle stub. |
vdp2fuzz | VDP2 renderer | Mednafen, Ymir | Whole fields drawn from the same registers and memory: generated classes (line scroll, rotation, shadows, colour calculation, offsets…) and 1,090 states captured from the bench's games. Also: x86 instruction counts per state, and a two-field test for the line reuse. |
vdp1fuzz | VDP1 | Mednafen, Ymir | Command lists drawn into the framebuffer: generated classes (lines, polygons, scaled and distorted sprites, colour modes, end codes) and 582 lists captured from 35 games. |
scspmdfn | SCSP voices | Mednafen's SCSP | The 32 slots sample by sample: loop modes, pitch, envelopes, FM by sounding slots, noise. |
scudspmdfn, scudspfuzz | SCU DSP | Mednafen; its own interpreter | Random DSP programs by class; the recompiler against the interpreter in lockstep. |
m68ktest | 68000 (Musashi) | SingleStepTests 680x0 | A million single instructions with registers and memory before and after. |
sat-bench.py | the whole machine | the build before | The 98 test games under QEMU, the device's build: pictures every 300 frames, sound, endings. Each fix had to change only the pictures its own feature draws. |
The harnesses and the test games are kept outside the repository: the games are commercial.
Order of authority
- Mednafen and Ymir together. Two emulators written apart, both from hardware tests. Where they agree, that is the chip.
- The manuals, where they disagree: Renesas' SH-1/SH-2 software manual, Hitachi's SH7604 hardware manual, Sega's VDP1, VDP2, SCU and SCSP manuals and technical bulletins. A 1994 Sega manual loses to two references that agree: it was written before the Saturn shipped.
- MiSTer's RTL as the tie-breaker: the chip described as logic. It settled the divider's −231 and the VDP1's table boundaries, and backed the VDP2's cell timing rule.
- For the 68000, Tom Harte's SingleStepTests, except where the test set alone disagrees with Motorola's manual, Musashi, Mednafen and Ymir.
- For speed, the device. x86 instruction counts first. They move up to 2 % with code layout alone, so the ARC-S decides: plain builds with functions aligned to 64 bytes, the CPU locked at 1.104 GHz, rounds interleaved. A fix pays only where its feature is used. One with a cost and nothing to show for it is held back or reworked.
Every fix, chip by chip
Cost is on the ARC-S where it was timed (ms a frame, before → after); otherwise the x86 count, with "none" where the fix adds no work to a path a game takes. Games are those whose pictures or sound change in the 98-game bench. A bar at a row's left marks three fixes that were each timed on their own.
SH-2 and its recompiler20 fixes · 4 commits, and the stress modes
| Fix | What was wrong | Shown by | Games | Cost |
|---|---|---|---|---|
| Delay slots as the chip runs them | ||||
| RTE pops PC and SR before its slot | The slot ran first, with the handler's SR and stack, and its writes to SR, T or R15 were lost to the pop (manual 6.1.51). | 79 of the 177 recompiler differences in 1,000 random programs | Marvel vs. SF: seven RTEs with rotl r14 in the slot | none |
| PC-relative loads in the slots of BT/S, BF/S and register jumps | Addressed from the slot, not the branch's target, except after BRA and BSR. | 72 hand programs: 30 wrong → 0 | — | none |
| A MAC in a delay slot | MACH and MACL lost their dirty bits at the branch: the sum was never written back. | 6 hand programs | Virtua Fighter 2, Fighting Vipers: their matrix sums written back | none |
| T in a slot assembled after its branch | The slot got no register for SR: NEGC, ADDC and compares read or wrote a wrong one. | 4 of 4,796 random → 0 | — | none |
| JSR and BSRF give their slot the new PR | A slot that also changes the jump register read the old PR. | hand programs | — | none |
| A call's slot loading PR from a constant address | The return address overwrote the host pointer: a crash. | 50 hand programs: 5 crashed → 0 | — | none |
| A branch into a delay slot | The slot's copy loaded neither SR nor the memory map: TAS.B crashed. | 120 hand programs: 4 wrong → 0 | — | none |
| A jump whose slot reloads its register | RTEMP took the load's map register: a crash. | two random programs that crashed | — | none |
| Registers and constants | ||||
| TAS.B, AND.B, OR.B, XOR.B at a constant address outside work RAM | Work RAM code emitted with no map register: a crash. | 13 of 2,416 random crashed → 0 | — | none |
mov Rn,@-Rn with a constant Rn | The decrement was skipped. | hand programs | — | none |
mov @Rm+,Rm with a constant Rm | Read 1, 2 or 4 bytes before the address. | 5 of 6,392 random → 0 | — | none |
| A block's last instruction | Its liveness came from whatever block was compiled before it: the same code compiled differently by history. | 7 of 4,796 random → 0 | — | none |
| DMULU.L and DMULS.L with no register for MACL | The product's low word went into SR's register. | 704 hand programs: 14 wrong → 0 | — | none |
| Register jumps, cycle counts and block links | ||||
| A register jump forgets a target only the first pass saw | A live register counted as dead and was never stored. | 8 hand programs: 5 wrong → 0 | — | none |
| A register jump's cycle stub reloads the jump's own register | After a slice ended there it jumped to junk: an endless loop. | a random program, shrunk | — | none |
| TRAPA reads the cycle count back | It added its cycles to another register's value: a slice cut short or run on. | 8 of 3,270 random → 0 | — | none |
check_addr's expiry test in 32 bits | In 64 bits it passed for every block: a branch could link into code about to be freed. | read, not reproduced | — | none |
| The SH-2 itself, interpreter and recompiler | ||||
| An invalid opcode stacks its own address | Both cores stacked the next one (hardware manual 4.5.4). | eight opcodes with a handler | — | none |
| The divider's exact −231 does not overflow | Overflow for every quotient of −231, as Mednafen's. Ymir and MiSTer's divider say it fits. | Ymir's vectors 5,011 of 5,012 → all | — | none |
| The divider's interrupt level from the CPU's own IPRA | The slave took the master's. | read, not played | — | none |
The stress modes (YAB_DRC_JUNK, YAB_DRC_STUBS, YAB_DRC_TINY) compile nothing unless set. With junk and every stub taken, 97 of the 98 games give the same pictures; Whizz parts from frame 2,100. Timing, PGO+LTO with a profile of their own against the build before the checks: Quake −7.0 %, Sega Rally −6.6 %, Panzer Dragoon Saga −6.4 %, Duke Nukem 3D −6.4 %, X-Men vs. SF and Virtua Fighter 2 +0.8 %. That gain is the profile's: the earlier build's profile no longer matched its source.
VDP218 fixes · 4 commits
| Fix | What was wrong | Shown by | Games | Cost |
|---|---|---|---|---|
| Registers, the picture's size, cell timing | ||||
| NTSC has no 256-line mode | VRESO 2 gave 256 lines on NTSC, the VBlank 6 lines instead of 38. | 150 states: every NTSC size wrong → none | Die Hard Trilogy: 320×256 → 320×224 | none |
| RAMCTL reads back | Read as 0: a game updating part of it lost the rest. | Sega Rally's and Dark Savior's captures | none yet (needed before the colour RAM mirror) | none |
| NBG2 and NBG3 a cell late by the cycle pattern | Done for one exact set of registers (Dracula X's); a rule now, covering Mednafen's whole list. | Megamix's five states and Daytona CCE's now equal both | Megamix's menus and HUD, Daytona CCE, SF Real Battle on Film, Real Bout Garou Densetsu, D&D Collection, Sonic R (one picture) | none (x86 −0.45 %) |
| The back screen at the new size after a resolution change | The first field drew it at the old size. | 200 states: 62 → 0 | NiGHTS' title, for a field | none: Burning Rangers 6.698 → 6.706 |
| Scroll, line scroll and rotation as the chip sums them | ||||
| A coefficient read stays inside VRAM | Coefficient mode 3 read past VRAM's end. | 8 of 150 states crashed → 0 | — | none |
| Line scroll read by entry | With an interval, Y and zoom read X's value; the lines between reads drew one row; X wrapped at 1,024 dots. | 4 classes: 80–127 of 200 → 0 | Astra Superstars: the fights' background, smeared, is the snow scene | none |
| Rotation in the chip's ten bits of fraction | Sixteen bits: dots drifted along a line. Negative coordinates read as large ones; the coefficient table's start lost its fraction. | 150 states each → 0 | The arenas' floors in Virtua Fighter 2, Fighting Vipers, VF Kids; Death Crimson, Virtua Cop, Panzer Dragoon Saga, Ultraman, Final Fight Revenge, VF Remix | none |
| The rotation screen's screen-over modes | Modes 1 to 3 drawn as mode 0; mode 3 one dot off. | 6–94 % of dots → 0 | Sonic R's far sea | none in mode 0 |
| Scroll fractions with line scroll, in 1/256 dot | The scroll registers' and the line scroll table's fractions were dropped. | random classes → 0 | Ultraman's title, Guardian Heroes, Albert Odyssey | none: Virtua Fighter 2 9.80 → 9.76 |
| A rotation screen that is not turned keeps its fractions | A float step: the background shimmered by a dot as it zoomed. | 18–55 % of dots → 0 | Soukyuu Gurentai's zoomed background | none (x86 +0.75 %, with the two above) |
| Scroll fractions on zoomed NBG0 and NBG1; moved rows reused | The fraction was left out on a zoomed axis: the background stood still, then jumped two dots. With it alone, Virtua Fighter 2 lost 8.5 %; rows that moved are now copied from the last field's. | 98 games equal the exact fraction; check mode: 0 misses over 375,091 fields | Virtua Fighter 2, Fighting Vipers, VF Kids, VF Remix, Soukyuu, Radiant Silvergun, Silhouette Mirage | VF2 9.701 → 9.376 (−3.4 %), Vipers 10.173 → 9.797 (−3.7 %), Sonic R +0.3 % |
| Colour calculation, shadows, palettes and the colour offset | ||||
| A shadow halves the dot | Darkened to 124/255: a step too dark on a dot in four. | SF Real Battle on Film: 1,076 dots | Astal, Gokujou Parodius, Princess Crown, SF Real Battle on Film | none |
| Sprite shadow dots by their data; the back screen's shadow | Four cases: shadows drawn black, self-shadowing sprites at full brightness, transparency by colour not data, BKSDEN ignored. | 181 of 200 → 0 (with the next) | Soukyuu Gurentai's craft shadow themselves | a test a line (x86 +0.38 % for three) |
| A 2,048-colour dot is transparent by its 11 palette bits | Only a zero word was transparent. | 58–86 of 200 → 0 | — | none |
| A shadow and colour calculation on one dot | Darkened before mixing; mixed with the shadow's black. | 106 of 150 → 0 | — | a test a dot |
| The second screen's ratio for sprites, back and line screens | 31:1 for two; the line screen's ratio the other way round. | 121–139 of 150 → 0 | no bench game | none |
| Colour calculation by the chip's 32nds | (8k+7)/255: the top dot about 3 % heavier, a step on most blended dots. | 172 of 200 → 7 (ratio 0) | The blended areas of 28 games, by one step | below zero (x86 −0.43 %) |
| The colour offset after colour calculation | Each layer added its offset before the mix: wrong where a channel clipped or two screens' offsets differ. | 12 classes: 116–192 of 200 → 0; real states 197 → 181 | Panzer Dragoon II's title (108,590 dots → 0), NiGHTS, Burning Rangers, Clockwork Knight 2, Daytona CCE, Soukyuu, 5 more | Daytona CCE 8.393 → 7.364 (−12.3 %), Burning Rangers −3.7 %, Soukyuu +1.6 % |
VDP17 fixes · 2 commits
| Fix | What was wrong | Shown by | Games | Cost |
|---|---|---|---|---|
| The command list: a link's low bits, the wrap, command 7 | A link with its two low bits set read mid-table; the list ran past 512 KB; command 7 took its colour from the pattern. | 16 lists → 0; 27 → 11 | Dracula X, one dot | none |
| A scaled sprite's zoom point, axis by axis | Six values the manual leaves out drawn as two corners; an odd negative size halved the wrong way. | 144 of 144 and 35 of 60 → all 384 as both | Golden Axe The Duel's mirrored sprites, a dot | none |
| 64- and 128-colour dots by the whole byte; table boundaries | 0x40, 0x80 transparent; every 0x3F dropped as an end code; 0xFF drawn as colour 127. | 34–40 of 40 a class → 0 | — | none |
| Gouraud with half luminance and half transparency | Modes 6 and 7 mixed with the shading table, never the framebuffer: opaque. | 0 % of dots right → 100 % | Death Crimson, Soviet Strike | none |
| Lines and quad sides step where their middle passes | A line stepped after each whole run: 30 dots and 1 where the chip draws 16 and 15. | 95–100 of 100 a class → 0 | Every slanted edge, 95 games; Sonic R's track without gaps | within 0.3 % (Megamix 6.408 → 6.423) |
| Gouraud by the chip's whole-number steps | Never reached the far corner's level; half a level low on average. | 25 % of dots right → 100 % (87 % on slanted quads) | Shaded surfaces in 20 games | none seen (x86 +1.2 %) |
| Texture steps of scaled and distorted sprites | Each point took texel k × width / points: half a texel off along most lines, and the rows likewise. | Real lists exact 287 → 448 of 548; words off 1.71 M → 66 K | Textures in 95 games: Fighting Vipers, Quake, Sega Rally, Duke Nukem 3D, Panzer Dragoon II, Sonic R, Virtua Fighter 2 | Daytona CCE −1.2 %, Megamix −0.5 %, Duke +0.5 % (x86 −4.8 %) |
SCSP voices9 fixes · 2 commits
| Fix | What was wrong | Shown by | Games | Cost |
|---|---|---|---|---|
| Loops by the chip's two steps | One-shots lost their last sample; a reverse loop ran forward then stuck; alternating loops a sample off at each end. | 227–300 of 300 → 0 | Every one-shot sound | none expected |
| The noise generator steps for every slot | It stepped for sounding slots only: with one slot playing, noise lost its low end (2 % of its power below 2.75 kHz, against 13 %). | 41–46 of 300 → 0 | Noise percussion | below zero; 16 KB |
| LPSLNK ends the attack a sample later | The decay began a sample early. | 21 → 9 (the rest another fix's) | — | none |
| A noise slot without loop plays on | Cut after LEA samples, at once with LEA 0. | 28 → 0 | Noise voices set up without loop | none |
| The slot monitor reads where the last sample was read | The address past the loop end, or counting up in a reverse loop. | read by X-Men vs. SF's sound driver | X-Men vs. SF's driver reads it | none |
| A slot's output reaches the sound stack five slots on | Ten slots on: FM by a slot 5 to 9 before read two samples old. | 67 of 300 → 0 | FM instruments | below zero |
| The key-on sample leaves the envelope alone | A note at full level went to its decay a sample early. | 9 of 600 → 0 | — | none |
| Silence at envelope level 0x3C0, a sample later | At 0x3BF, tested twice: fading notes ended early, at full level with SDIR. | 90 and 100 of 300 → 0 | The tails of fading notes | none |
| A modulated slot's second sample by the next slot's fraction | The chip rounds it with the next slot's phase: the grit of its FM. | 291 of 300 → 0 (with the stack) | FM instruments | next to none |
68000 and SCU DSP8 faults · 2 commits
| Fix | What was wrong | Shown by | Games | Cost |
|---|---|---|---|---|
| 68000: Musashi's own four | ||||
| ABCD, SBCD, NBCD | Bytes with digits above 9, and V, unlike the chip. | SingleStepTests: 14,840 wrong → 3,739; of those, 3,736 are ASR cases where the test set alone disagrees with Motorola's manual, Musashi, Mednafen and Ymir | no picture changes in the bench | none |
| DIVS, DIVU on overflow | C left as it was; the chip clears it. | |||
| DIVS of 0x80000000 by −1 | Quotient 0, no overflow; it is 231, an overflow. | |||
| Bcc with displacement 0xFF | Taken as the 68020's long branch; on the 68000 it is a short one of −1. | |||
| SCU DSP: conditions, the accumulator, MVI and counters as Mednafen has them | ||||
| The condition NZS | "Z clear or S clear", nearly always true; it is neither. | Conditions: only NZS wrong → none. Random programs: 1,499 → 1,078 (the rest left by choice, below). Recompiler against interpreter: 40,000 trials, none differ | no picture changes | next to none |
| The ALU's high word | Low-word operations changed AC's bits 32–47. | |||
| MVI to PL | Zero-extended; it is sign-extended to 48 bits. | |||
| Counter widths | CT0–CT3 kept 8 bits and indexed past their page; LOP kept 16. They have 6 and 12. | |||
What it means in play
3D fighters
Virtua Fighter 2 and Fighting Vipers: matrix sums from a MAC in a delay slot written back. Arena floors in the chip's ten bits of fraction, zoomed backgrounds that drift a dot at a time, textures sampled as the chip samples them. The zoom fix makes both 3–4 % faster.
Polygons and textures
Every slanted edge in 95 games moves by up to a dot to where the chip puts it; Sonic R's track has no gaps. Textures along each line are now the chip's texels: Quake, Duke Nukem 3D, Sega Rally, Panzer Dragoon II. Gouraud reaches its corners' levels.
Backgrounds
Astra Superstars' fights over the snow scene, no longer smeared. Ultraman's title and Guardian Heroes scroll by their fractions. Soukyuu Gurentai's zoomed background stops shimmering. Sonic R's far sea repeats the right cell.
Light and colour
Panzer Dragoon II's title wall is its real colour, and NiGHTS, Burning Rangers, Clockwork Knight 2 and Daytona CCE fade as the chip fades them. Shadows are halves, not 124/255. Blends are in the chip's 32nds: a step on most mixed dots in 28 games.
Menus and screens
Fighters Megamix's menus and HUD, Daytona CCE's and SF Real Battle on Film's text sit where the chip's cell timing puts them. Die Hard Trilogy shows 224 lines, as on an NTSC set. NiGHTS' title no longer flashes the old size for a field.
Sound
Noise percussion has its low end; FM instruments read their modulators on time and take the chip's grit; one-shot sounds keep their last sample; reverse and alternating loops turn where the chip turns them. X-Men vs. SF's driver reads the slot monitor right.
Where the references disagree, and what was only read
| Case | Mednafen | Ymir | Decided by |
|---|---|---|---|
| The divider's exact −231 | overflow | fits | MiSTer's divider (590,000 divisions modelled from its RTL) and the hardware manual: fits |
| NBG2 and NBG3 a cell late | a list of register sets | a rule with more cases | a rule giving all of Mednafen's list and Ymir's results; three loading screens now centred, as Ymir draws them |
| A VDP1 colour table at an odd address | low bits dropped | kept | MiSTer and the manual: dropped |
| VDP1 mode 5, shading with shadow | differ | left as it was | |
| 68000 ASR by a count above the size | sign bit out, as Musashi and Motorola | the test set stands alone: left | |
| SCSP: FM beside a reverse loop | marked unsure in its own code | — | left |
| SCSP: SBCTL on a waveform that ended | SBXOR × level | SBXOR unscaled | left (ours is silence) |
Read in the code and fixed without a reproduction: check_addr's expiry test (it needs the code buffer to wrap during a compile) and the slave's divider interrupt level (no test game enables it). RAMCTL reads back right but changes no picture yet.
Left open by the chip checks
SH-2
- An invalid opcode or branch in a delay slot is an illegal slot instruction on the chip (vector 6); neither core raises it.
- A store over code later in the same block runs the old instruction until the block ends: 4 of the 5 random programs still wrong in 193,822.
VDP2
- Colour calculation left on at ratio 0: Steamgear Mash, The Lost World, Saturn Bomberman's sprites a step off.
- Colour RAM mode 1 in high resolution; extended colour calculation.
- Soukyuu Gurentai +1.6 % with the offset fix, its cause not established.
- 125 of the 1,090 real states still differ where both references agree.
VDP1
- End codes on texels a shrink skips (52,167 words in the class).
- A 64- or 128-colour dot of 0 with a colour bank of 0 is not written.
- The filling dots of slanted Gouraud lines take a share of a step (87 % right).
SCSP
- KYONEX is taken a line at a time (2–3 samples); the chip takes it at the next sample.
- Key off's envelope step; slots 26–31 leave the pipeline a sample later.
- Noise with SDIR after its envelope ends; addresses past 512 KB wrap.
SCU DSP and 68000
- DSP, by choice: V, LOP after a loop, a jump in a jump's slot, the D1 bus on its own counter, RA0 and WA0 through MVI, undocumented conditions.
- 68000: address errors (the core's Musashi is built without them); DIVU by zero's flags.
Then the whole machine
The chip checks compare one chip at a time. Four more checks ran the whole machine on the 98 test games.
- Shortcuts switched off. Six speed shortcuts change no picture and no sound. The 68000's idle skipping did: ten games gave other sound and six gave other pictures. Four causes were found and fixed. In Virtua Fighter 2 the game clears its sound driver's stack under the running 68000, and the skip had put the old values back. The ten games now give the pictures and sound of a run in full, frame for frame.
- The SH-2's idle skipping changes timing in 14 games' pictures and 37 sounds. Nothing was found wrong, and it stays.
- YabauseUT's hardware tests ran on Yabanjin, Mednafen and Ymir. Both references pass the misaligned and indirect DMA tests, and Yabanjin failed them. The SCU's DMA now copies and fills to the byte, with 27-bit addresses.
- The CD block's answers were compared with Mednafen's on 46 discs. The file system's scope was one file short, and it differed in 10 games with more than 254 files. Cyberbots, Guardian Heroes, Panzer Dragoon II and Shining Force III are among them. It now answers as Mednafen's.
- Raster effects. A log listed the VDP2 registers that games change inside the picture. Albert Odyssey's fade, Sega Rally's colour offset and Need for Speed's cockpit are drawn.
- Two smaller finds. VDP1's registers start at zero. A save state's load no longer hands the CD block time ahead.
How much of the code changed
| Component | Lines at the fork | Rewritten or removed | Share | Lines added to them | New files | The chip checks' +/− |
|---|---|---|---|---|---|---|
| SH-2 recompiler (AArch64 and shared) | 12,172 | 154 | 1.3 % | 1,129 | — | +512 / −88 |
| SH-2: interpreter, cache, divider | 9,292 | 262 | 2.8 % | 137 | — | +16 / −12 |
| 68000 (Musashi) | 16,520 | 253 | 1.5 % | 120 | — | +72 / −244 |
| SCU and its DSP | 4,685 | 562 | 12.0 % | 734 | 1,024 | +44 / −44 |
| SCSP and its DSP | 8,391 | 4,849 | 57.8 % | 1,112 | 2,444 | +167 / −163 |
| CD block | 7,319 | 2,739 | 37.4 % | 302 | 2,974 | — |
| VDP1, the chip's side | 2,819 | 70 | 2.5 % | 283 | — | +14 / −8 |
| VDP2, the chip's side | 2,357 | 78 | 3.3 % | 181 | — | +30 / −7 |
| Renderer: vidsoft, Titan | 13,115 | 1,277 | 9.7 % | 2,865 | — | +1,729 / −822 |
| libretro frontend | 8,436 | 386 | 4.6 % | 610 | — | — |
| Memory, SMPC, BIOS, the rest | 17,860 | 561 | 3.1 % | 244 | 122 | +2 / — |
| All | 102,966 | 11,191 | 10.9 % | 7,717 | 6,564 | +2,586 / −1,388 |
Counted on the files left after the prune: the code Yabanjin started from (elderica's a4b7c6e7) against the tree at the end of the chip checks, line endings ignored. The x86-64 backend's rewrite and the ST-V support came later and are not in these counts. "Rewritten or removed" is the fork's lines that a diff takes out; "new files" are the ones added since: the SCU and SCSP DSP recompilers and their AArch64 emitter, the per-sample SCSP ported from YabaSanshiro 1.20.55, and the CD block split by concern, its drive on Mednafen's model. Not counted: the 32-bit ARM, x86 and x64 recompiler back ends, 12,891 lines that no build used at that point, untouched; the 68000's generated opcode files; the bundled libraries. The SCSP's 58 % is the old sound model's removal, the CD block's 37 % its drive replaced. The chip checks took out 1,388 lines and added 2,586, two thirds of them in the renderer.
Speed before and after the chip checks ARC-S · 1.104 GHz locked · ms a frame
| Game | Before the checks | After | Change |
|---|---|---|---|
| Daytona USA CE | 7.17 | 6.35 | −11.4 % |
| Sega Rally | 6.63 | 6.04 | −8.9 % |
| Panzer Dragoon Saga | 6.29 | 5.79 | −7.9 % |
| Quake | 6.51 | 6.04 | −7.2 % |
| Duke Nukem 3D | 6.49 | 6.04 | −6.9 % |
| Panzer Dragoon II | 6.79 | 6.35 | −6.5 % |
| Burning Rangers | 6.57 | 6.23 | −5.2 % |
| Radiant Silvergun | 7.79 | 7.44 | −4.5 % |
| Metal Slug | 4.92 | 4.78 | −2.8 % |
| Fighters Megamix | 6.28 | 6.21 | −1.1 % |
| Grandia | 8.64 | 8.55 | −1.0 % |
| Virtua Fighter 2 | 8.66 | 8.61 | −0.6 % |
| Marvel vs. SF | 8.66 | 8.66 | 0.0 % |
| X-Men vs. SF | 8.81 | 8.94 | +1.5 % |
The two PGO+LTO cores (b7b70689, b162a076), alternated A B A B with the frontend stopped and the screen off. The gain comes from three reworked fixes (the colour offset, VDP1's texture steps and the zoomed scroll fractions: Daytona CCE −12.3 % on their own), from the build tuned for the Cortex-A55, and from a PGO profile taken on the checked code. In Burning Rangers' hangar the main thread's time still went to the code the game rewrites: get_addr, invalidate_addr, invalidate_blocks and the compares behind them. That is the next chapter.
Burning Rangers, from a recorded play session
Burning Rangers was the one test game that fell behind in play. The bench's short scene never showed it. A recorded play session did, and it became the measure for the fix.
What the game does
Burning Rangers rewrites its own code. Its two vertex routines hold a patch area of nine instructions that sets the axes' order and signs. The game rewrites that area before each object, between eleven forms. Each routine also keeps three work variables a few words after its code, and stores to them for every vertex.
A recompiler protects pages that hold compiled code, so that it sees writes to them. Here the same two pages take code writes and thousands of data writes a frame.
The first step: block by block
At first each rewrite invalidated its page whole. That was about 100 page invalidations a frame, each walking about 800 entries. A fifth of the main thread went to it. Compiled blocks now keep the source range they were made from, and a changed code word takes out only the blocks that hold it. The hangar scene went from 12.99 to 11.78 ms a frame at 1.104 GHz.
It was not enough in play. With the camera on the back of the hangar, frames still came late.
The recording
A play session was recorded on the ARC-S: 24,426 frames of pad input from the boot through the menus into mission 1. A replay feeds the same input to any build, so two builds can be compared on the same play. Replayed headless with the clock locked at 1.104 GHz, the session took 14.91 ms a frame. Two stretches took over 23 ms. Seventeen of its 39 stretches of 600 frames were over 16.7 ms, the time a frame has at full speed.
Samples of the main thread showed where the time went. Half of it was the handling of rewritten code, not the game's code itself.
| Main thread's samples, frames 20,400–22,200 | Before | After |
|---|---|---|
get_addr, finding a block's compiled form | 19.0 % | 5.9 % |
invalidate_blocks, walking a page's entries | 18.4 % | none |
verify_code's compares of a block with its source | 5.2 % | 7.1 % |
| The recompiled code itself | 19.2 % | 29.2 % |
| The VDP1 timing model | 4.5 % | 8.5 % |
The two pages lost their protection at 1,024 data stores a frame or 64 changed code words. Then get_addr gave it back at the next block it restored, 240 times a frame. The page's next store took it away again. Three pages' entries were walked for it, 64 times a frame.
The fix
A page that loses its protection whole to the game's writes now stays unprotected for a second. During that second its blocks compare their source on entry, and no store traps. The entry that get_addr finds moves to the head of its list.
The twelve timing games stayed within 0.06 ms a frame. The 98 test games give the same pictures and sound under QEMU.
In play
The last measure is the recording replayed in play on the ARC-S, through the frontend, with the clock free up to 1.8 GHz. The frontend counts a resync each time the game falls more than four frames behind.
Heat was a suspect, and it was not the cause. The chip throttles as before: it spends 40 % of the time at 1.416 GHz, at 75 °C. The frame now fits at that clock. Capping the clock had done little for the build before.
What is left in this game: every block of the two pages still compares its source on entry, 6,600 compares a frame. MAC.L and MAC.W are calls into C, 4.3 % of the main thread. The VDP1 timing model's walk is 8.5 %.
New hosts and players
Then the core went beyond one handheld and one pad: a recompiler for x86-64 PCs, an Android build, Sega's six-player adapter, a cheaper fast forward and the ST-V arcade board.
The x86-64 recompiler
Ari64's recompiler had an x86-64 backend of its own. It addressed its globals and its code in absolute 32 bits, so it could not be linked into a shared object. The shared code had also moved on with the ARM64 work.
The new backend is not that one brought forward. It is elderica's ARM64 backend rewritten with x86-64 instructions, behind the same interface. So the shared code takes the same paths on both hosts. It allocates the same registers and compiles the same blocks with the same cycle counts. A difference between the two hosts can only come from an instruction emitter.
- Registers. The allocator's register numbers 0 to 12 map to x86-64 registers. x86-64 has six callee-saved registers where ARM64 lends the allocator nine, so a call into C keeps r8 and r9 around it.
- Memory. The 16 MB code buffer and the recompiler's variables are within 2 GB of each other. Jumps, calls and variable accesses are rip-relative. The core has no absolute relocations.
- Flags. ARM64's instructions mostly leave the flags alone, and x86's change them. A build switch reports any conditional jump emitted on stale flags. Over the 98 games it reported one place: SLEEP.
SLEEP's flags. SLEEP adds the block's cycles to the cycle count and branches on the sign. The add set no flags on ARM64, so the branch read what the instruction before had left. Each host acted on what its own instructions leave, so two hosts could part there. The add now sets the flags on every host. The BIOS has a SLEEP that is compiled in 27 of the 98 games.
The divider. The SH-2's on-chip divider used the host's division. −231 / −1 gives −231 on ARM64 and a trap on x86, which ended the core. A divisor of −1 is now a negation on every host.
| ms a frame, Intel i3-12100F | Interpreter | Recompiler | Headroom at 60 fps |
|---|---|---|---|
| Burning Rangers | 3.21 | 1.16 | 14× |
| Panzer Dragoon II | 2.69 | 0.89 | 19× |
| Radiant Silvergun | 1.42 | 1.01 | 16× |
| Marvel vs. SF | 3.74 | 1.40 | 12× |
| X-Men vs. SF | 3.01 | 1.39 | 12× |
gcc 16, -O3, no PGO, every frame drawn. The SCU and SCSP DSPs run their interpreters on x86-64: their recompilers are for ARM64 only.
The checks: the 98 test games give the ARM64 build's pictures and sound. 20,000 random SH-2 programs run through both recompilers end in the same state bit for bit, one endless loop apart. Two differences are open, so a plain make on x86-64 still builds the interpreter and the recompiler takes make DYNAREC=2. Chapter 8 lists them.
Android
The ARM64 code runs as it is on Android. An NDK build with the ARM64 recompiler plays in RetroArch on Android 16, on a Galaxy Tab A8: 60 fps, and Darius Gaiden at 240–280 fps in fast forward.
The 6Player
The 6Player is Sega's adapter for six pads on one port. The inherited code read it as connected only with two pads or more behind it. With one pad or none, the port answered as a pad plugged in directly. It now answers as the hardware does, whatever is behind it: six sockets, the empty ones marked empty. Each port counts its own players.
Port 1's option has a new default, Auto. A Saturn disc's boot header lists the peripherals the game supports. Auto connects the 6Player for a disc that lists it. Eight of the 98 test games do.
Fast forward's hidden frames
A frontend in fast forward runs frames it never shows. It can say which, as each call begins. Yabanjin used to draw every hidden frame in full. Now a hidden frame's VDP2 screens are neither drawn nor composited. Nothing is emulated differently, so a shown frame's picture is drawn from the state it always was.
Two things are still drawn on hidden frames. VDP1's lists are, because games read them back. A field of a woven interlaced screen is, because the next picture holds its lines.
| ms a frame, one frame in four shown | Every frame drawn | Hidden frames left out |
|---|---|---|
| Batsugun | 6.17 | 4.62 |
| Duke Nukem 3D | 6.50 | 5.04 |
| Guardian Heroes | 6.47 | 5.02 |
| Radiant Silvergun | 8.35 | 6.80 |
| Fighters Megamix | 6.59 | 5.90 |
| Metal Slug | 5.29 | 4.74 |
| Panzer Dragoon Saga | 6.34 | 5.80 |
| Sega Rally | 6.58 | 6.20 |
| Panzer Dragoon II | 6.90 | 6.50 |
| Daytona USA CE | 6.99 | 6.75 |
| Grandia | 9.20 | 9.14 |
| Burning Rangers | 6.70 | 6.66 |
| Virtua Fighter 2 (woven) | 9.09 | 9.09 |
ARC-S at 1.104 GHz. The screens are drawn on other cores, so the emulation thread saves their set-up, its own share of the drawing, the compositing and the copy out. The rest of a frame is the SH-2s and the sound. The check: the 98 games with turns of 1 to 8 frames hidden, 276,727 of 356,400 frames, give the pictures and sound of a run with none hidden.
ST-V
The ST-V is Sega's arcade board built on the Saturn. Its support is modelled on Mednafen 1.32.1's: the game table of 64 entries, the cartridge ROM, the I/O board, the EEPROM and Radiant Silvergun's protection counter.
- A game is a MAME-format zip. It is found in the table by its files' names and sizes. Where sets share a name, the CRC-32 of a first file's first 0x80 bytes decides.
- The cabinet's BIOS comes from MAME's
stvbios.zip, chosen by area. - The cabinet's controls come from the pad. The coin is on Select. Test and Service are on L3 and R3.
- Vertical cabinets' games are turned a quarter left for the screen, as Mednafen shows them.
- The ST-V BIOS issues the SMPC's SYSRES command at power-on and waits for it. The inherited code ignored that command. It now resets the system.
On the ARC-S, Baku Baku takes 6.7 ms a frame, Radiant Silvergun 5.8 and Shienryu 7.6, with the clock free. Die Hard Arcade takes 13 ms at 1.104 GHz: it has a high-resolution rotation layer.
0.5.3, the first public release
0.5.3 is the first version made public. The versions before it were internal milestones on the way.
From the fork to 0.5.3
| Part | At the fork | In 0.5.3 |
|---|---|---|
| CD block | Yabause's cs2.c | The drive on Mednafen's model: reports, seeks, pauses, the software reset and the file system's scope |
| Sound | Yabause's old model; a per-sample one, off | The per-sample SCSP alone, at Mednafen's levels, with its effect DSP bit for bit; loops, noise, FM and envelope edges as the chip |
| DSP recompilers | interpreters | The SCU and SCSP DSPs compiled for ARM64: Grandia 13.4 → 9.0 ms a frame |
| Renderer | six layer threads through 3.4 MB of RAM | The band renderer with three workers (−4.3 % on twelve games); lines and moved rows reused; VDP2's 18 fixes and VDP1's 7; hidden frames not drawn |
| SH-2 recompiler | elderica's ARM64 backend | Code writes handled block by block; rewritten pages left unprotected for a second; 20 faults fixed; stress modes for testing; an x86-64 backend |
| Controllers | the standard pad; a 6Player that needed two pads behind it | The standard pad and the 6Player as Sega's, chosen from the disc's header |
| Games | disc images | Disc images, .m3u lists for multi-disc games, and ST-V games from MAME-format zips |
| Build | -O3 | PGO+LTO trained on the 98 test games (8–9 % against a plain build), tuned for the Cortex-A55; Android and Linux x86-64 builds |
What is open
Games
- Marvel Super Heroes vs. Street Fighter runs just under full speed in fights on the ARC-S: 59.9 fps.
- Waku Waku 7: shadows flicker at the start of a fight, voices sound brighter than on Mednafen, and the select music plays on over the pick's voice.
- Die Hard Trilogy's loading screen shows a garbled title. The game plays on.
- Discworld's studio logos run shorter than on Mednafen.
- Theme Park's intro movie is cut short.
x86-64
- Eight pictures of the recorded Burning Rangers session differ from the ARM64 build's: polygon edges are a dot off.
- King of Fighters '96's sound varies from run to run.
- Until both are explained, the recompiler is not the default there.
Fast forward and heat
- Fast forward gains nothing on a woven interlaced screen: Virtua Fighter 2, Fighting Vipers. With the Bob deinterlacer, the hidden fields are skipped.
- After half an hour of play the RK3566 sits near 70 °C and runs at 1.1–1.4 GHz. The core's part is headroom at those clocks.
ST-V
- The EEPROM is not kept between starts, so high scores and settings reset.
- The 315-5881 and 315-5838 chips are not modelled: Final Fight Revenge, Astra SuperStars, Decathlete, Steep Slope Sliders.
Controllers and regions
- Controllers are the standard pad and the 6Player. Light-gun games run with a pad.
- PAL is lightly tested: two games of the test set run at 50 Hz.
Save states
- A save state belongs to the build that wrote it. Another build refuses it.
- A state does not hold the size of the last picture. A state loaded while the display is off can give a black picture of another width, until the game turns the display on.
The repository's README lists every known issue and plan in a line each. NOTES.md holds what is known about each.
Planned
- The SCU DSP recompiler: flags worked out only where they are read, and counters kept in host registers.
- ST-V: the EEPROM kept as the game's save.
- Windows: first the SH-2 interpreter, then the x86-64 recompiler with Win64's calling convention.
- Recompiled code through a dual mapping, for hosts that refuse memory that is both writable and executable.
- Other controllers: the 3D Control Pad's analog mode, light guns, the mouse.
- The fixes that apply to elderica's branch, offered there.
How it is checked
Every fix is one commit. It is checked on the bench, then played on the ARC-S.
References
- Mednafen 1.32.1 is the reference for how the hardware behaves.
- The manuals: Hitachi's SH7604 hardware manual, Renesas' SH-2 software manual, and Sega's VDP1, VDP2, SCU and SCSP manuals, technical bulletins and developer newsletters.
- MiSTer's Saturn core: its FPGA logic, for timing and for what the manuals leave out.
- Ymir: a second emulator to compare with, and its game database.
- YabauseUT's hardware tests.
Tests
- The bench: the 98 test games run without a screen. Their pictures and sound are compared with the previous build's. It runs on a PC, under QEMU with the ARM64 build, and on the ARC-S. Under QEMU a run repeats exactly.
- Chip tests: the same small programs run on Yabanjin and on Mednafen or Ymir, and the results must match. There is one for the SH-2, VDP1, VDP2, the SCU DSP, the SCSP and its DSP, and the 68000.
- Long scripted play, 30,000 frames, finds crashes the bench is too short for.
- Recorded play on the ARC-S is replayed on each new build to compare speed.
The bench, the chip tests and the test games are kept outside the repository: the games are commercial.
The 98 test games
The bench runs these games on every build. They are the games Mednafen and Ymir single out, and the ones that broke along the way.
- Mednafen keeps per-game tables in its code (
ss/db.cpp): games that need its full SH-2 cache, its data cache, a cartridge, or a special hack. - Ymir keeps a game database and developer notes on finicky games.
- Every game either of them needs special handling for is here. Their other entries are FMV tearing, small glitches or Japanese-only titles.
- The rest are games that broke while Yabanjin was made, and five heavy 3D games to measure speed.
Each group is the part of the Saturn its games stress most. A source is given where a reference names the game.
SH-2s and the recompiler6 games
| Game | What it checks | Named by |
|---|---|---|
| Batsugun (Japan) | Input timing, and the master SH-2's counting loop | — |
| Fighters Megamix (Japan) | Special handling in Mednafen | Mednafen |
| Madden NFL 97 (USA) | A redundant SSHON command | — |
| Marvel Super Heroes vs. Street Fighter (Japan) | Needs the 4 MB RAM cartridge. TRAPA, SR and DSP DMA in the recompiler, and long fights, where the code cache wraps | — |
| Thunderstrike 2 (USA) | Hangs before and during play without special handling of SH-2 DMA and VDP1 | Mednafen |
| Virtua Fighter Remix (Japan) (6M) | Shared matrix stack between SH-2s | — |
SH-2 cache29 games
| Game | What it checks | Named by |
|---|---|---|
| Albert Odyssey Gaiden - Legend of Eldean (Japan) (3M) | Needs the SH-2 cache | — |
| Area 51 (USA) | Hangs without the full SH-2 cache | Mednafen |
| Astal (USA) | Needs the SH-2 cache | — |
| Baku Baku Animal - World Zookeeper Contest (Europe) | Freezes playing FMVs from the Options menu without the SH-2 cache | Ymir |
| Clockwork Knight 2 - Pepperouchau's Adventure (USA, Brazil) | Hangs after some FMVs without the full SH-2 cache | Mednafen |
| Creature Shock - Special Edition (USA) (Disc 1) | Crashes starting a level without the data cache | Mednafen |
| Dark Savior (USA) | Needs the SH-2 cache | — |
| Doraemon - Nobita to Fukkatsu no Hoshi (Japan) | Blank Game Over screen without the data cache | Mednafen |
| Dragon Ball Z - Idainaru Dragon Ball Densetsu (Japan) | Black screen after starting a new game without the SH-2 cache | Ymir |
| Gex (USA) | FMV glitches without the full cache | Mednafen |
| Grandia (Japan) (Disc 1) (4M) | Hangs at the end of disc 1 without the full cache; VDP1 swap timing; the backup RAM cartridge | Mednafen |
| House of the Dead, The (Japan) | Crashes on the gun calibration screen without the data cache | Mednafen |
| Lost World, The - Jurassic Park (USA) | Rock faces' graphics without the full cache | Mednafen |
| Magic Carpet (USA) | Hangs without the full SH-2 cache | Mednafen |
| Manx TT SuperBike (Japan) | Crashes in the optional intro movie without the cache | Mednafen |
| NiGHTS into Dreams... (Japan) | The slave SH-2 uses the cache data array | — |
| Policenauts (Japan) (Disc 1) | Flicker on disc 2 without the SH-2 cache; disc 1 boots the game | Mednafen |
| Policenauts (Japan) (Disc 2) | Flicker without the SH-2 cache | Mednafen |
| Soviet Strike (USA) | Flickering VDP1 graphics, tied to the SH-2 cache | Ymir |
| Space Jam (USA) | Crashes without the full cache | Mednafen |
| Steamgear Mash (Japan) (2M) | Partly flickering sprites without the SH-2 cache | Ymir |
| Super Puzzle Fighter II Turbo (USA) | Colour, brightness and other graphics without the data cache | Mednafen |
| Theme Park (Europe) (En,Fr,De,Es,Sv) | Hangs during an FMV without the data cache | Mednafen |
| Virtua Cop (Japan) (2M) | Hangs without the full SH-2 cache; a light-gun game, played with a pad | Mednafen |
| Virtua Fighter Kids (Japan) | FMVs and the CPU opponent, without the cache | Mednafen |
| Waku Waku 7 (Japan) | Needs the 1 MB RAM cartridge and the SH-2 cache | Ymir |
| Whizz (Japan) | Hangs at startup without the full cache; slow VDP1 drawing in play | Mednafen |
| Wipeout (USA) | Hangs leaving a race for the menu without the SH-2 cache | Mednafen |
| World Series Baseball (USA) | Game logic without the data cache | Mednafen |
SCU: DMA, DSP, timers, bus7 games
| Game | What it checks | Named by |
|---|---|---|
| Deep Fear (Europe) (Disc 1) | Freezes after the "April Fools!" voice line with fast bus timings | Ymir |
| Dennou Senki - Virtual On - Cyber Troopers (Japan) | SCU DMA must stall the bus | — |
| Exhumed (Europe) (En,Fr,De,Es) | SCU DMA must stall the bus | — |
| Jung Rhythm (Japan) | SCU DMA must stall the bus | — |
| Resident Evil (USA) | Freezes on the title without bus timings | — |
| Spot Goes to Hollywood (USA) | Sprites from a poorly timed SCU DMA | — |
| Virtua Racing (Japan) | A DMA step of the SCU's DSP | — |
VDP111 games
| Game | What it checks | Named by |
|---|---|---|
| Bug! (USA) | A 3D platformer | — |
| Dragon Ball Z - Shinbutouden (Japan) | Freezes after the SEGA logo if VDP1 runs too fast | — |
| Fighting Vipers (Japan) (Rev C) | The CPU opponent turns into a ghost statue without a per-game fix | Mednafen |
| Gokujou Parodius Da! Deluxe Pack (Japan) (Rev A) | VDP1's erase window, and the player select | — |
| Princess Crown (Japan) (1M) | 2D, many sprites | — |
| Rockman X3 (Japan) (2M) | VDP1 VRAM written while drawing | — |
| Sega Rally Championship Plus (Japan) | VDP1 swap before the list is ready, endless loop; heavy 3D | Ymir |
| Shining Force III (USA) | 30 fps 3D (VDP1 draw timing), a long RPG, the backup RAM cartridge | — |
| Silhouette Mirage (Japan) (Rev A) | 2D, many sprites | — |
| Sonic R (USA, Brazil) | VDP1 erase and swap mid-line; endless VDP1 list on a race's first frame | Ymir |
| Virtua Fighter 2 (Japan) (Rev B) (39B) | VDP1 vertices sign-extended from 13 bits; 704x480 | Ymir |
VDP26 games
| Game | What it checks | Named by |
|---|---|---|
| Dino Island (Japan) | A palette loaded by SCU DMA | — |
| Guardian Heroes (Japan) (3M) | 2D with many sprites and VDP2 effects | — |
| Panzer Dragoon Saga (USA) (Disc 1) | Bad VDP2 window tables at name entry; rotation backgrounds | Ymir |
| Road & Track Presents - The Need for Speed (USA) | RBG0's priority changed mid-frame: the cockpit and the loading screens | — |
| Street Fighter - Real Battle on Film (Japan) (2M) | NBG1 priority changed mid-frame | — |
| Street Fighter Zero 2' (Japan) | VDP2 access cycles outside the rules | Ymir |
CD block: seek, pacing, FMVs4 games
| Game | What it checks | Named by |
|---|---|---|
| Die Hard Trilogy (USA) | No cartridge: hangs at boot on VDP1's draw end and a slave restart, and crashes with a RAM cartridge | Mednafen, YabaSanshiro |
| Discworld (Japan) | INTBACK must time out at VBlank IN | — |
| Dragon Force II - Kami Sarishi Daichi ni (Japan) | A jump to address 0 entering a 100 vs 100 battle | — |
| Lunar - Silver Star Story (Japan) | Clipped FMVs | — |
SCSP and its DSP1 game
| Game | What it checks | Named by |
|---|---|---|
| Burning Rangers (Japan) | The slave SH-2's idle loop, and speed | — |
SMPC: input, multitap7 games
| Game | What it checks | Named by |
|---|---|---|
| Akumajou Dracula X - Gekka no Yasoukyoku (Japan) (2M) | Needs SMPC commands delayed | — |
| Death Crimson (Japan) | A light-gun game: shots counted as reloads without jitter; played with a pad | Ymir |
| Golden Axe - The Duel (USA) | Pads read in SH-2 direct mode | — |
| Rayman (Europe) (En,Fr,De) (1S) | SMPC interrupt pending while masked | — |
| Saturn Bomberman (Japan) | The multitap (four to ten players) | — |
| Soukyuu Gurentai (Japan) (Rev A) | Ignores the pad if INTBACK runs instantly | — |
| Virtual Hydlide (Japan) (2M) | Stuck on the SEGA logo if INTBACK runs instantly | — |
Cartridges (RAM and ROM)22 games
| Game | What it checks | Named by |
|---|---|---|
| Astra Superstars (Japan) | Needs the 1 MB RAM cartridge | Mednafen, Ymir |
| Cyberbots - Fullmetal Madness (Japan) (2M) | Needs the 1 MB RAM cartridge | Mednafen, Ymir |
| Dungeons & Dragons Collection (Japan) (Disc 1) (Tower of Doom) | Needs the 4 MB RAM cartridge | Mednafen, Ymir |
| Dungeons & Dragons Collection (Japan) (Disc 2) (Shadow over Mystara) | Needs the 4 MB RAM cartridge | Mednafen, Ymir |
| Fighter's History Dynamite (Japan) | Needs the 1 MB RAM cartridge | Mednafen, Ymir |
| Final Fight Revenge (Japan) | Needs the 4 MB RAM cartridge | Mednafen, Ymir |
| Gouketsuji Ichizoku 3 - Groove on Fight (Japan) | Needs the 1 MB RAM cartridge | Mednafen, Ymir |
| King of Fighters '95, The (Japan) (1M) | Needs the 1 MB RAM cartridge and its ROM cartridge, chosen by product code | Mednafen, Ymir |
| King of Fighters '96, The (Japan) (1M) | Needs the 1 MB RAM cartridge | Mednafen, Ymir |
| King of Fighters '97, The (Japan) | Needs the 1 MB RAM cartridge | Mednafen, Ymir |
| Magical Night Dreams - Cotton 2 (Japan) | Needs the 1 MB RAM cartridge | Mednafen, Ymir |
| Marvel Super Heroes (Japan) | Needs the 1 MB RAM cartridge | Mednafen, Ymir |
| Metal Slug - Super Vehicle-001 (Japan) | Needs the 1 MB RAM cartridge | Mednafen, Ymir |
| Pocket Fighter (Japan) | Needs the 4 MB RAM cartridge | Mednafen, Ymir |
| Real Bout Garou Densetsu (Japan) (En,Ja,Es,Pt) (2M) | Needs the 1 MB RAM cartridge and no other | Mednafen, Ymir |
| Real Bout Garou Densetsu Special (Japan) | Needs the 1 MB RAM cartridge | Mednafen, Ymir |
| Samurai Spirits - Amakusa Kourin (Japan) (En,Ja,Es,Pt) | Needs the 1 MB RAM cartridge; the 4 MB one doesn't work | Mednafen, Ymir |
| Samurai Spirits - Zankurou Musouken (Japan) | Needs the 1 MB RAM cartridge | Mednafen, Ymir |
| Street Fighter Zero 3 (Japan) | Needs the 4 MB RAM cartridge | Mednafen, Ymir |
| Ultraman - Hikari no Kyojin Densetsu (Japan) | Needs its ROM cartridge, chosen by product code | Mednafen, Ymir |
| Vampire Savior (Japan) | Needs the 4 MB RAM cartridge; freezes after the Capcom logo | Mednafen, Ymir |
| X-Men vs. Street Fighter (Japan) (1M) | Needs the 4 MB RAM cartridge; back to the BIOS after the Capcom logo without bus timings | Mednafen, Ymir |
Speed baselines (3D)5 games
| Game | What it checks | Named by |
|---|---|---|
| Daytona USA - Circuit Edition (Japan) | 3D speed baseline | — |
| Duke Nukem 3D (USA) | Heavy software 3D | — |
| Panzer Dragoon II Zwei (Japan) | 3D speed baseline | — |
| Quake (USA) | Heavy software 3D | — |
| Radiant Silvergun (Japan) | Speed (slow in places) | — |
About this page
Yabanjin was built with AI assistance throughout. The code changes were written by AI coding agents (Anthropic's Claude Opus and Claude Fable, via Claude Code), working under its maintainer's direction, and tested on real hardware. This page was written the same way.
Yabanjin is an unofficial personal fork. It is not affiliated with or endorsed by the Yabause, Yabadabadoo or YabaSanshiro authors, elderica, the Mednafen or Ymir authors, or Anbernic. Please don't report Yabanjin problems to them.
Yabanjin is free software under the GNU General Public License, version 2 or later, like Yabause. Its credits are in the repository's README.