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.

1

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 2003–2025 · Guillaume Duhamel, Theo Berkau, cyberwarriorx, d356… libretro port 2019–2025 barbudreadmon Yabadabadoo Oct 2026 · small handhelds ProRapSuperstarOriginalMaster aarch64-dynarec 29 Oct – 5 Nov 2026 elderica Yabanjin to 0.5.3 hard fork, libretro only 3,356 commits, both 136 commits 19 commits 330 commits to 0.5.3 base: elderica's a4b7c6e7
Five steps, one tree. YabaSanshiro's work (devMiyax) reached this line through Yabause. YabaSanshiro is a sibling, not an ancestor. Between elderica's base and 0.5.3, git counts 737 files changed: 20,123 lines added and 262,975 removed. Most of the removed lines are code the libretro core never built.

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.

2

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

13.4 → 9.0 msGrandia a frame with the two DSP recompilers (ARC-S, 1.104 GHz)
6,037 → 3,082lines of scsp.c with the old sound model gone
~1,370 → 731files in the tree after the prune
4–11 %less time a frame in heavy 3D games with PGO and LTO (ARC-S, 1.104 GHz)

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.

kept Yabause's added by Yabadabadoo or elderica added by Yabanjin fixed by Yabanjin modelled on another emulator removed tried, not kept
Subsystem
Yabause and its libretro port2003–2025
Yabadabadoo and elderica
Yabanjinto 0.5.3
SH-2 CPUsthe two main processors
interpreterAri64's recompiler, 32-bit ARM (2009–11)SH-2 cache model (YabaSanshiro's work)
ARM64 recompiler backend (elderica)MAC.L fix from YabaSanshiro
TRAPA, status-register writes, branches in delay slots, and out-of-range opcodes fixedthe CPU cache's effects, for the three games that rely on them: Astal, Dark Savior, Dragon Force II20 instruction bugs found by comparing with Mednafen and Ymir, most in branch delay slotsSLEEP's flags; the hardware divider's result for −231 ÷ −1games that write over their own code: only the changed block is recompiled. Marvel and X-Men vs. SF at full speeda code page the game keeps rewriting goes unwatched for a second, and its blocks are checked on entry instead: Burning Rangersan x86-64 backend, ported from the ARM64 onemore SH-2 state kept in host registers (19): 0.07 % faster, not kept
68Kthe sound CPU
Musashi 3.4 (2002)
the sound CPU and sound chip on a second CPU corethe sound CPU's idle loops skipped
bugs in Musashi (the 68000 emulator): BCD and division flags, short branchesidle skipping checked to give the same result as running every cyclethe thread waiting on the sound queue spins briefly, then gives up the corein test: the 68K run exactly on the main thread, with only sound synthesis on the second core
SCUDMA, timers, the DSP
SCU, DMADSP interpreter
the DSP's DMA address steps, timer 1, DMA timing, DMA to addresses on no bus (Deep Fear)the DSP's condition flags, accumulator, MVI instruction and loop counters, as in MednafenDMA exact to the byte, 27-bit addressesthe DSP's programs recompiled to ARM64: Grandia's movies 6 ms a frame faster
SCSPsound chip and its DSP
the old sound model, removeda second, per-sample model, unused
the per-sample model, now the only one, updated to d356's as in YabaSanshiro 1.20.55; volume and panning match Mednafenthe effects DSP (reverb, echo) gives the same output as Mednafen's, bit for bitthe effects DSP recompiled to ARM64sample loops, noise, FM and envelope edge cases as the hardware does theminterpolation between samplessave states hold the sound chip's whole state
CD blockdrive and its controller
cs2.c: the CD block's command interfacean emulation of the CD block's own SH-1 CPU and its 1 MB of buffers (2016), removed
the drive's mechanics (seek times, sector timing) rebuilt on Mednafen's modelstatus reports, reset, region check, seek and pause, software reset (Leynos 2)the file commands cover the same range of files as Mednafen'scs2.c split into one file per job
VDP1sprites and polygons
software rasteriser
worker threads, split by rowsdrawing put off until the result is neededa timing model: command RAM read when the chip would read it
each command list's drawing time modelled, so games that wait for the end of drawing run right: Oshaberi Parodius, Exhumed, Metal Slug, Rockman X3, Dark Savior; no per-game listlines, texture stepping, Gouraud shading and scaled sprites' anchor points as the chip draws themthe frame buffer's erase area; lists started by a plot trigger that never end
VDP2 and Titanbackgrounds and compositing
layer drawing (vidsoft)Titan, which merges the layers into the picture (2012)
an unchanged field isn't drawn againa layer line that hasn't changed is reusedrender worker threads
priorities and colour blending that change per line, line scroll, colour-RAM coefficients18 bugs found by comparing with Mednafen and Ymir: rotation, sub-pixel scrolling, shadows, the colour offsetpictures drawn in bands by three workersframes that fast forward skips are not drawncompositing during the vertical blank: tried, left as a switch, offSIMD (NEON) compositing: dropped
Build and frontendhosts, players, what ships
Qt, GTK and Windows front endsOpenGL renderers, other CPU coreslibretro port
small-handheld tuning, version 0.4
hard fork, libretro only, renamedAndroid and Linux x86-64 buildsST-V arcade games, after Mednafen's modelSega's 6Player multitap, turned on by the game's disc headerprofile-guided and link-time optimisation: 4–11 % faster in heavy gamessave files written atomically, reset without reloading, threads stopped when the core unloads, -ffast-math off
3

Drawing 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.

main thread emulating (SH-2s, SCU, sound sync) drawing layers (NBG0–3, RBG0, sprites) compositing: priority sort, blend, write the picture waiting

Whole-frame layers inherited · replaced as the default

Main thread 6 layer threads 5 compositing threads emulate display lines 0–224 wait mix VBlank picture out draw each layer, whole frame composite RAM · 6 full-frame buffers · 3.4 MB writes reads back VBlank-OUT VBlank-IN next VBlank-OUT
The main thread stops at VBlank-IN. It waits for the layer threads. It composites one share of the lines while five threads do the rest. Only then does it emulate the VBlank lines. Every layer goes through RAM in full: 6 × 560 KB written, then read back. In Radiant Silvergun that stop is 1.95 ms of waiting plus 2.5 ms of compositing a frame (profile build, ARC-S at 1.104 GHz).

Compositing during the VBlank tried · a switch, off

Main thread 6 layer threads 5 compositing threads emulate display lines 0–224 wait VBlank picture out draw each layer, whole frame composite starts, main goes on RAM · 6 full-frame buffers · 3.4 MB writes reads back VBlank-OUT VBlank-IN next VBlank-OUT the frame's end before saved
Compositing overlaps the VBlank lines. VBlank-IN starts the five compositing threads and returns. The main thread emulates lines 225–262 and waits only at the next VBlank-OUT. The picture goes to the frontend in the same 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

Main thread 3 band workers emulate display lines 0–224 VBlank picture out draw band k's layers composite band k as studied: 16-line bands, 14 a frame shared cache · band buffers ≈ 240 KB stays in cache VBlank-OUT VBlank-IN next VBlank-OUT
Each band is drawn and composited while it is still in cache. A worker takes a run of lines, draws every layer for them and composites them at once. Then it takes the next band. The emulation goes on meanwhile. The figure shows the study's 16-line bands, whose six layers take about 240 KB. To build it, every layer's drawing had to work on a range of lines.
ms a frameNo band workersThree band workers
Panzer Dragoon Saga8.496.61
Metal Slug6.265.59
Fighters Megamix7.466.84
Virtua Fighter 29.769.29
Grandia9.709.31
Burning Rangers7.337.08
Sega Rally6.946.81
Daytona USA CE7.967.93
Panzer Dragoon II7.137.16
Duke Nukem 3D6.596.69
Quake6.586.70
Radiant Silvergun8.358.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

Main thread SH-2s, VDP1 too 1 render thread 012 …224 VBlank 01224 picture out queue: the line's VRAM and register writes, then “draw line n” line buffers ≈ 35 KB VBlank-OUT VBlank-IN next VBlank-OUT each render block: draw that line's layers, mix it, write it out
One line at a time, a line behind the emulation. As the main thread finishes a line, it queues every VRAM and register write it made, then a draw command. The render thread replays the writes into its own copy. It draws all layers for that one line into small line buffers and mixes it straight away. It is the band design with a band of one line. It is exact for mid-frame changes, because each line sees the state as it was. The cost is elsewhere: Mednafen emulates the SH-2s and VDP1 cycle by cycle on the main thread, which needs a fast desktop CPU.

Where the layer pixels live

L1 32 KB a core shared cache 512 KB Mednafen · one line · 35 KB Bands · 16-line band · 240 KB Whole-frame layers · 3.4 MB 10 KB 100 KB 1 MB 10 MB
The RK3566's caches decide most of this. Log scale. A 320×224 frame at 8 bytes a pixel is 560 KB per layer. Six layers are 3.4 MB, about seven times the shared cache. The whole-frame design writes it all to RAM and reads it all back each frame. A 16-line band of the same six layers fits with room to spare. Mednafen's single line is about the size of one core's L1.

Side by side

Whole-frame layersCompositing during the VBlankBandsMednafen
Unit of worka whole layer, whole framesameall layers of a band of linesall layers of one line
Threads6 layer, 5 compositing, plus the main thread's share6 layer, 5 compositing3 band workers1 render thread
Layer data3.4 MB, through RAM3.4 MB, through RAM≈ 240 KB for a 16-line band, in the shared cache≈ 35 KB, in L1
Main thread at VBlank-INstops: waits for layers, compositeswaits for layers, then emulates on while compositing runsgoes on; the workers draw while it emulatesnever stops; it only queues lines
Mid-frame changesregisters captured per line; VRAM as at the frame's startsamesameexact: every write replayed in order
Picture showsthe previous frame's display (a frame behind, like VDP1's)samesamethe frame just emulated
Statusinherited; still the path on fewer than four corestried; a switch, offships: the default on four cores or morereference; 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.

4

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

6.5 ms7.0 ms7.5 ms8.0 mslower is faster▲ +17.4 %• −0.3 %▲ +3.9 %▼ −6.6 %• +0.5 %• −0.9 %▼ −6.6 %6.6947a00f41before0780e110sound model583e2d8fCD drive8.130bf3b162game fixes7158ea44retrained7.6462bdc053race check8910eeb6VBlank mix7.13d569b453speed work
slower than the build before faster within 1 % tried, not kept (off the line)
The sound model's cost, mostly earned back. Each point is the mean of six games that every run timed: Burning Rangers, Fighters Megamix, Grandia, Panzer Dragoon II, Radiant Silvergun and Sega Rally. The per-sample sound model added 17.4 %. A profile that no longer matched the code added a little more. Two retrained profiles and two days of speed work bring the last build to 7.13 ms. That is 6.7 % over the core before both rewrites, with the new sound, the new CD drive and every fix in between. Hover or focus a point for its games.
+17.4 %the per-sample sound model, six-game mean
−6.6 %the last build against 62bdc053, six-game mean
−9.1 %PGO against a plain build of the same code: 7.13 against 7.84 ms
7.27 → 6.79 msall 98 test games, 62bdc053 against 0bf3b162

What moved it

BuildWhat changedSix gamesChangeWhere it went
47a00f41Before both rewrites: Yabause's sound model and CD block, PGO on 21950a2f's profile.6.69—The reference.
0780e110The 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.
583e2d8fThe CD drive on Mednafen's model, with the sound model.7.83• −0.3 %No measurable cost.
0bf3b162Deep 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.
7158ea44Every 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.
62bdc053The 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 %).
8910eeb662bdc053'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.
d569b453Profile 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 frame47a00f41before0780e110sound model583e2d8fCD drive0bf3b162game fixes7158ea44retrained62bdc053race check8910eeb6VBlank mixd569b453speed work
Burning Rangers7.017.367.297.337.197.247.136.88
Fighters Megamix6.327.587.647.727.507.537.586.91
Grandia9.299.749.739.889.499.519.298.93
Panzer Dragoon II5.537.027.107.656.826.876.816.38
Radiant Silvergun7.208.288.218.357.978.028.037.50
Sega Rally4.777.137.017.876.636.676.596.20
Virtua Fighter 28.419.479.399.3511.749.599.579.01
Fighting Vipers–––10.0313.3010.2410.13–
Mean of the six6.697.857.838.137.607.647.577.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.

5

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.

56 fixesin 14 commits by kind, across six chips; each fix's evidence is in its commit message
1 in 5 → 5 of 193,822random SH-2 programs the recompiler ran otherwise than both references
269 → 125of 1,090 VDP2 fields captured from the games, differing where both references agree
285 → 448of 548 VDP1 command lists from 35 games drawn exactly as both references
14,840 → 3,73968000 single-step tests failed of a million; 3,736 of the rest are the test set's alone

How a fault was found and a fix accepted

1 · Find a difference test cases random, class by class, and captured from the 98 bench games Yabanjin, under QEMU Mednafen 1.32.1 Ymir Mednafen and Ymir agree? yes: Yabanjin must match them no: the manuals decide, then MiSTer's RTL a difference, shrunk to its shortest case the manual's page, both references a fix 2 · Accept it its own branch the evidence in its message 98 games, QEMU only the expected pictures move x86 instructions over the captured states and lists ARC-S timing 1.104 GHz locked, rounds interleaved a commit by kind or held back, or reworked
Two emulators that agree are the answer. Each harness runs a case through Yabanjin and both references. Where Mednafen and Ymir agree, Yabanjin has to match them: dot for dot, sample for sample or register for register. A difference is shrunk to the shortest case that still shows it. Its fix lands on its own branch. A fix is kept only if the 98 games change where it says they should and nowhere else. Its cost on the ARC-S must be paid only in the games that use what it fixes.

The harnesses

HarnessChipAgainstWhat it runs
sh2fuzzSH-2, interpreter and recompilerMednafen's and Ymir's SH-2Random 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.
vdp2fuzzVDP2 rendererMednafen, YmirWhole 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.
vdp1fuzzVDP1Mednafen, YmirCommand lists drawn into the framebuffer: generated classes (lines, polygons, scaled and distorted sprites, colour modes, end codes) and 582 lists captured from 35 games.
scspmdfnSCSP voicesMednafen's SCSPThe 32 slots sample by sample: loop modes, pitch, envelopes, FM by sounding slots, noise.
scudspmdfn, scudspfuzzSCU DSPMednafen; its own interpreterRandom DSP programs by class; the recompiler against the interpreter in lockstep.
m68ktest68000 (Musashi)SingleStepTests 680x0A million single instructions with registers and memory before and after.
sat-bench.pythe whole machinethe build beforeThe 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

  1. Mednafen and Ymir together. Two emulators written apart, both from hardware tests. Where they agree, that is the chip.
  2. 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.
  3. 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.
  4. For the 68000, Tom Harte's SingleStepTests, except where the test set alone disagrees with Motorola's manual, Musashi, Mednafen and Ymir.
  5. 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
FixWhat was wrongShown byGamesCost
Delay slots as the chip runs them
RTE pops PC and SR before its slotThe 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 programsMarvel vs. SF: seven RTEs with rotl r14 in the slotnone
PC-relative loads in the slots of BT/S, BF/S and register jumpsAddressed 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 slotMACH and MACL lost their dirty bits at the branch: the sum was never written back.6 hand programsVirtua Fighter 2, Fighting Vipers: their matrix sums written backnone
T in a slot assembled after its branchThe 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 PRA slot that also changes the jump register read the old PR.hand programs—none
A call's slot loading PR from a constant addressThe return address overwrote the host pointer: a crash.50 hand programs: 5 crashed → 0—none
A branch into a delay slotThe 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 registerRTEMP 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 RAMWork RAM code emitted with no map register: a crash.13 of 2,416 random crashed → 0—none
mov Rn,@-Rn with a constant RnThe decrement was skipped.hand programs—none
mov @Rm+,Rm with a constant RmRead 1, 2 or 4 bytes before the address.5 of 6,392 random → 0—none
A block's last instructionIts 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 MACLThe 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 sawA 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 registerAfter a slice ended there it jumped to junk: an endless loop.a random program, shrunk—none
TRAPA reads the cycle count backIt 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 bitsIn 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 addressBoth cores stacked the next one (hardware manual 4.5.4).eight opcodes with a handler—none
The divider's exact −231 does not overflowOverflow 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 IPRAThe 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
FixWhat was wrongShown byGamesCost
Registers, the picture's size, cell timing
NTSC has no 256-line modeVRESO 2 gave 256 lines on NTSC, the VBlank 6 lines instead of 38.150 states: every NTSC size wrong → noneDie Hard Trilogy: 320×256 → 320×224none
RAMCTL reads backRead as 0: a game updating part of it lost the rest.Sega Rally's and Dark Savior's capturesnone yet (needed before the colour RAM mirror)none
NBG2 and NBG3 a cell late by the cycle patternDone 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 bothMegamix'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 changeThe first field drew it at the old size.200 states: 62 → 0NiGHTS' title, for a fieldnone: Burning Rangers 6.698 → 6.706
Scroll, line scroll and rotation as the chip sums them
A coefficient read stays inside VRAMCoefficient mode 3 read past VRAM's end.8 of 150 states crashed → 0—none
Line scroll read by entryWith 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 → 0Astra Superstars: the fights' background, smeared, is the snow scenenone
Rotation in the chip's ten bits of fractionSixteen bits: dots drifted along a line. Negative coordinates read as large ones; the coefficient table's start lost its fraction.150 states each → 0The arenas' floors in Virtua Fighter 2, Fighting Vipers, VF Kids; Death Crimson, Virtua Cop, Panzer Dragoon Saga, Ultraman, Final Fight Revenge, VF Remixnone
The rotation screen's screen-over modesModes 1 to 3 drawn as mode 0; mode 3 one dot off.6–94 % of dots → 0Sonic R's far seanone in mode 0
Scroll fractions with line scroll, in 1/256 dotThe scroll registers' and the line scroll table's fractions were dropped.random classes → 0Ultraman's title, Guardian Heroes, Albert Odysseynone: Virtua Fighter 2 9.80 → 9.76
A rotation screen that is not turned keeps its fractionsA float step: the background shimmered by a dot as it zoomed.18–55 % of dots → 0Soukyuu Gurentai's zoomed backgroundnone (x86 +0.75 %, with the two above)
Scroll fractions on zoomed NBG0 and NBG1; moved rows reusedThe 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 fieldsVirtua Fighter 2, Fighting Vipers, VF Kids, VF Remix, Soukyuu, Radiant Silvergun, Silhouette MirageVF2 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 dotDarkened to 124/255: a step too dark on a dot in four.SF Real Battle on Film: 1,076 dotsAstal, Gokujou Parodius, Princess Crown, SF Real Battle on Filmnone
Sprite shadow dots by their data; the back screen's shadowFour 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 themselvesa test a line (x86 +0.38 % for three)
A 2,048-colour dot is transparent by its 11 palette bitsOnly a zero word was transparent.58–86 of 200 → 0—none
A shadow and colour calculation on one dotDarkened 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 screens31:1 for two; the line screen's ratio the other way round.121–139 of 150 → 0no bench gamenone
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 stepbelow zero (x86 −0.43 %)
The colour offset after colour calculationEach 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 → 181Panzer Dragoon II's title (108,590 dots → 0), NiGHTS, Burning Rangers, Clockwork Knight 2, Daytona CCE, Soukyuu, 5 moreDaytona CCE 8.393 → 7.364 (−12.3 %), Burning Rangers −3.7 %, Soukyuu +1.6 %
VDP17 fixes · 2 commits
FixWhat was wrongShown byGamesCost
The command list: a link's low bits, the wrap, command 7A 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 → 11Dracula X, one dotnone
A scaled sprite's zoom point, axis by axisSix 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 bothGolden Axe The Duel's mirrored sprites, a dotnone
64- and 128-colour dots by the whole byte; table boundaries0x40, 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 transparencyModes 6 and 7 mixed with the shading table, never the framebuffer: opaque.0 % of dots right → 100 %Death Crimson, Soviet Strikenone
Lines and quad sides step where their middle passesA line stepped after each whole run: 30 dots and 1 where the chip draws 16 and 15.95–100 of 100 a class → 0Every slanted edge, 95 games; Sonic R's track without gapswithin 0.3 % (Megamix 6.408 → 6.423)
Gouraud by the chip's whole-number stepsNever 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 gamesnone seen (x86 +1.2 %)
Texture steps of scaled and distorted spritesEach 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 KTextures in 95 games: Fighting Vipers, Quake, Sega Rally, Duke Nukem 3D, Panzer Dragoon II, Sonic R, Virtua Fighter 2Daytona CCE −1.2 %, Megamix −0.5 %, Duke +0.5 % (x86 −4.8 %)
SCSP voices9 fixes · 2 commits
FixWhat was wrongShown byGamesCost
Loops by the chip's two stepsOne-shots lost their last sample; a reverse loop ran forward then stuck; alternating loops a sample off at each end.227–300 of 300 → 0Every one-shot soundnone expected
The noise generator steps for every slotIt 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 → 0Noise percussionbelow zero; 16 KB
LPSLNK ends the attack a sample laterThe decay began a sample early.21 → 9 (the rest another fix's)—none
A noise slot without loop plays onCut after LEA samples, at once with LEA 0.28 → 0Noise voices set up without loopnone
The slot monitor reads where the last sample was readThe address past the loop end, or counting up in a reverse loop.read by X-Men vs. SF's sound driverX-Men vs. SF's driver reads itnone
A slot's output reaches the sound stack five slots onTen slots on: FM by a slot 5 to 9 before read two samples old.67 of 300 → 0FM instrumentsbelow zero
The key-on sample leaves the envelope aloneA note at full level went to its decay a sample early.9 of 600 → 0—none
Silence at envelope level 0x3C0, a sample laterAt 0x3BF, tested twice: fading notes ended early, at full level with SDIR.90 and 100 of 300 → 0The tails of fading notesnone
A modulated slot's second sample by the next slot's fractionThe chip rounds it with the next slot's phase: the grit of its FM.291 of 300 → 0 (with the stack)FM instrumentsnext to none
68000 and SCU DSP8 faults · 2 commits
FixWhat was wrongShown byGamesCost
68000: Musashi's own four
ABCD, SBCD, NBCDBytes 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 Ymirno picture changes in the benchnone
DIVS, DIVU on overflowC left as it was; the chip clears it.
DIVS of 0x80000000 by −1Quotient 0, no overflow; it is 231, an overflow.
Bcc with displacement 0xFFTaken 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 differno picture changesnext to none
The ALU's high wordLow-word operations changed AC's bits 32–47.
MVI to PLZero-extended; it is sign-extended to 48 bits.
Counter widthsCT0–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

CaseMednafenYmirDecided by
The divider's exact −231overflowfitsMiSTer's divider (590,000 divisions modelled from its RTL) and the hardware manual: fits
NBG2 and NBG3 a cell latea list of register setsa rule with more casesa 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 addresslow bits droppedkeptMiSTer and the manual: dropped
VDP1 mode 5, shading with shadowdifferleft as it was
68000 ASR by a count above the sizesign bit out, as Musashi and Motorolathe test set stands alone: left
SCSP: FM beside a reverse loopmarked unsure in its own code—left
SCSP: SBCTL on a waveform that endedSBXOR × levelSBXOR unscaledleft (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.

How much of the code changed

ComponentLines at the forkRewritten or removedShareLines added to themNew filesThe chip checks' +/−
SH-2 recompiler (AArch64 and shared)12,172154 1.3 %1,129—+512 / −88
SH-2: interpreter, cache, divider9,292262 2.8 %137—+16 / −12
68000 (Musashi)16,520253 1.5 %120—+72 / −244
SCU and its DSP4,685562 12.0 %7341,024+44 / −44
SCSP and its DSP8,3914,849 57.8 %1,1122,444+167 / −163
CD block7,3192,739 37.4 %3022,974—
VDP1, the chip's side2,81970 2.5 %283—+14 / −8
VDP2, the chip's side2,35778 3.3 %181—+30 / −7
Renderer: vidsoft, Titan13,1151,277 9.7 %2,865—+1,729 / −822
libretro frontend8,436386 4.6 %610——
Memory, SMPC, BIOS, the rest17,860561 3.1 %244122+2 / —
All102,96611,191 10.9 %7,7176,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

−4.8 %median of the fourteen timing games, after the checks against before
10.33 → 9.86 msBurning Rangers' hangar from the mission state, frames 600–1260
+1.5 %X-Men vs. SF, the one game slower
GameBefore the checksAfterChange
Daytona USA CE7.176.35−11.4 %
Sega Rally6.636.04−8.9 %
Panzer Dragoon Saga6.295.79−7.9 %
Quake6.516.04−7.2 %
Duke Nukem 3D6.496.04−6.9 %
Panzer Dragoon II6.796.35−6.5 %
Burning Rangers6.576.23−5.2 %
Radiant Silvergun7.797.44−4.5 %
Metal Slug4.924.78−2.8 %
Fighters Megamix6.286.21−1.1 %
Grandia8.648.55−1.0 %
Virtua Fighter 28.668.61−0.6 %
Marvel vs. SF8.668.660.0 %
X-Men vs. SF8.818.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.

6

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,200BeforeAfter
get_addr, finding a block's compiled form19.0 %5.9 %
invalidate_blocks, walking a page's entries18.4 %none
verify_code's compares of a block with its source5.2 %7.1 %
The recompiled code itself19.2 %29.2 %
The VDP1 timing model4.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 whole session 14.91 10.97 Mission 1, from frame 5,400 16.8 12.0 Frames 18,001–18,600 23.59 14.81 Frames 21,601–22,200 23.05 14.96 16.7 ms, full speed 0 ms 5 ms 10 ms 15 ms 20 ms 25 ms
before the fix after
No stretch of the session is over a frame's time any more. The recorded session replayed headless on the ARC-S, clock locked at 1.104 GHz, plain builds, ms a frame. Before the fix, 17 of the 39 stretches of 600 frames took more than 16.7 ms. After it, none does.

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.

178–214 → 0resyncs over the recorded session
11.8 → 7.55 msa frame over the recorded session
57.8–58.2 → 60.00frames a second
22.3 → 1.3 %of the frames over 16.7 ms
17.98 → 9.59 msa frame in the slowest minute

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 %.

7

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.

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-12100FInterpreterRecompilerHeadroom at 60 fps
Burning Rangers3.211.1614×
Panzer Dragoon II2.690.8919×
Radiant Silvergun1.421.0116×
Marvel vs. SF3.741.4012×
X-Men vs. SF3.011.3912×

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 shownEvery frame drawnHidden frames left out
Batsugun6.174.62
Duke Nukem 3D6.505.04
Guardian Heroes6.475.02
Radiant Silvergun8.356.80
Fighters Megamix6.595.90
Metal Slug5.294.74
Panzer Dragoon Saga6.345.80
Sega Rally6.586.20
Panzer Dragoon II6.906.50
Daytona USA CE6.996.75
Grandia9.209.14
Burning Rangers6.706.66
Virtua Fighter 2 (woven)9.099.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.

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.

8

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

PartAt the forkIn 0.5.3
CD blockYabause's cs2.cThe drive on Mednafen's model: reports, seeks, pauses, the software reset and the file system's scope
SoundYabause's old model; a per-sample one, offThe 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 recompilersinterpretersThe SCU and SCSP DSPs compiled for ARM64: Grandia 13.4 → 9.0 ms a frame
Renderersix layer threads through 3.4 MB of RAMThe 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 recompilerelderica's ARM64 backendCode writes handled block by block; rewritten pages left unprotected for a second; 20 faults fixed; stress modes for testing; an x86-64 backend
Controllersthe standard pad; a 6Player that needed two pads behind itThe standard pad and the 6Player as Sega's, chosen from the disc's header
Gamesdisc imagesDisc images, .m3u lists for multi-disc games, and ST-V games from MAME-format zips
Build-O3PGO+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

9

How it is checked

Every fix is one commit. It is checked on the bench, then played on the ARC-S.

References

Tests

The bench, the chip tests and the test games are kept outside the repository: the games are commercial.

10

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.

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
GameWhat it checksNamed by
Batsugun (Japan)Input timing, and the master SH-2's counting loop—
Fighters Megamix (Japan)Special handling in MednafenMednafen
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 VDP1Mednafen
Virtua Fighter Remix (Japan) (6M)Shared matrix stack between SH-2s—
SH-2 cache29 games
GameWhat it checksNamed by
Albert Odyssey Gaiden - Legend of Eldean (Japan) (3M)Needs the SH-2 cache—
Area 51 (USA)Hangs without the full SH-2 cacheMednafen
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 cacheYmir
Clockwork Knight 2 - Pepperouchau's Adventure (USA, Brazil)Hangs after some FMVs without the full SH-2 cacheMednafen
Creature Shock - Special Edition (USA) (Disc 1)Crashes starting a level without the data cacheMednafen
Dark Savior (USA)Needs the SH-2 cache—
Doraemon - Nobita to Fukkatsu no Hoshi (Japan)Blank Game Over screen without the data cacheMednafen
Dragon Ball Z - Idainaru Dragon Ball Densetsu (Japan)Black screen after starting a new game without the SH-2 cacheYmir
Gex (USA)FMV glitches without the full cacheMednafen
Grandia (Japan) (Disc 1) (4M)Hangs at the end of disc 1 without the full cache; VDP1 swap timing; the backup RAM cartridgeMednafen
House of the Dead, The (Japan)Crashes on the gun calibration screen without the data cacheMednafen
Lost World, The - Jurassic Park (USA)Rock faces' graphics without the full cacheMednafen
Magic Carpet (USA)Hangs without the full SH-2 cacheMednafen
Manx TT SuperBike (Japan)Crashes in the optional intro movie without the cacheMednafen
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 gameMednafen
Policenauts (Japan) (Disc 2)Flicker without the SH-2 cacheMednafen
Soviet Strike (USA)Flickering VDP1 graphics, tied to the SH-2 cacheYmir
Space Jam (USA)Crashes without the full cacheMednafen
Steamgear Mash (Japan) (2M)Partly flickering sprites without the SH-2 cacheYmir
Super Puzzle Fighter II Turbo (USA)Colour, brightness and other graphics without the data cacheMednafen
Theme Park (Europe) (En,Fr,De,Es,Sv)Hangs during an FMV without the data cacheMednafen
Virtua Cop (Japan) (2M)Hangs without the full SH-2 cache; a light-gun game, played with a padMednafen
Virtua Fighter Kids (Japan)FMVs and the CPU opponent, without the cacheMednafen
Waku Waku 7 (Japan)Needs the 1 MB RAM cartridge and the SH-2 cacheYmir
Whizz (Japan)Hangs at startup without the full cache; slow VDP1 drawing in playMednafen
Wipeout (USA)Hangs leaving a race for the menu without the SH-2 cacheMednafen
World Series Baseball (USA)Game logic without the data cacheMednafen
SCU: DMA, DSP, timers, bus7 games
GameWhat it checksNamed by
Deep Fear (Europe) (Disc 1)Freezes after the "April Fools!" voice line with fast bus timingsYmir
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
GameWhat it checksNamed 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 fixMednafen
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 3DYmir
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 frameYmir
Virtua Fighter 2 (Japan) (Rev B) (39B)VDP1 vertices sign-extended from 13 bits; 704x480Ymir
VDP26 games
GameWhat it checksNamed 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 backgroundsYmir
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 rulesYmir
CD block: seek, pacing, FMVs4 games
GameWhat it checksNamed by
Die Hard Trilogy (USA)No cartridge: hangs at boot on VDP1's draw end and a slave restart, and crashes with a RAM cartridgeMednafen, 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
GameWhat it checksNamed by
Burning Rangers (Japan)The slave SH-2's idle loop, and speed—
SMPC: input, multitap7 games
GameWhat it checksNamed 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 padYmir
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
GameWhat it checksNamed by
Astra Superstars (Japan)Needs the 1 MB RAM cartridgeMednafen, Ymir
Cyberbots - Fullmetal Madness (Japan) (2M)Needs the 1 MB RAM cartridgeMednafen, Ymir
Dungeons & Dragons Collection (Japan) (Disc 1) (Tower of Doom)Needs the 4 MB RAM cartridgeMednafen, Ymir
Dungeons & Dragons Collection (Japan) (Disc 2) (Shadow over Mystara)Needs the 4 MB RAM cartridgeMednafen, Ymir
Fighter's History Dynamite (Japan)Needs the 1 MB RAM cartridgeMednafen, Ymir
Final Fight Revenge (Japan)Needs the 4 MB RAM cartridgeMednafen, Ymir
Gouketsuji Ichizoku 3 - Groove on Fight (Japan)Needs the 1 MB RAM cartridgeMednafen, Ymir
King of Fighters '95, The (Japan) (1M)Needs the 1 MB RAM cartridge and its ROM cartridge, chosen by product codeMednafen, Ymir
King of Fighters '96, The (Japan) (1M)Needs the 1 MB RAM cartridgeMednafen, Ymir
King of Fighters '97, The (Japan)Needs the 1 MB RAM cartridgeMednafen, Ymir
Magical Night Dreams - Cotton 2 (Japan)Needs the 1 MB RAM cartridgeMednafen, Ymir
Marvel Super Heroes (Japan)Needs the 1 MB RAM cartridgeMednafen, Ymir
Metal Slug - Super Vehicle-001 (Japan)Needs the 1 MB RAM cartridgeMednafen, Ymir
Pocket Fighter (Japan)Needs the 4 MB RAM cartridgeMednafen, Ymir
Real Bout Garou Densetsu (Japan) (En,Ja,Es,Pt) (2M)Needs the 1 MB RAM cartridge and no otherMednafen, Ymir
Real Bout Garou Densetsu Special (Japan)Needs the 1 MB RAM cartridgeMednafen, Ymir
Samurai Spirits - Amakusa Kourin (Japan) (En,Ja,Es,Pt)Needs the 1 MB RAM cartridge; the 4 MB one doesn't workMednafen, Ymir
Samurai Spirits - Zankurou Musouken (Japan)Needs the 1 MB RAM cartridgeMednafen, Ymir
Street Fighter Zero 3 (Japan)Needs the 4 MB RAM cartridgeMednafen, Ymir
Ultraman - Hikari no Kyojin Densetsu (Japan)Needs its ROM cartridge, chosen by product codeMednafen, Ymir
Vampire Savior (Japan)Needs the 4 MB RAM cartridge; freezes after the Capcom logoMednafen, Ymir
X-Men vs. Street Fighter (Japan) (1M)Needs the 4 MB RAM cartridge; back to the BIOS after the Capcom logo without bus timingsMednafen, Ymir
Speed baselines (3D)5 games
GameWhat it checksNamed 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.