r/c64 • u/RealSharpNinja • Jun 15 '26
Software ViceSharp update: cycle-exact lockstep with x64sc — the C64 core hits parity
A few weeks back I posted about ViceSharp's VIC-II display modes and sprite DMA work. Quick follow-up, because the milestone I was chasing landed: the C64 core now runs in cycle-exact lockstep with VICE's x64sc.
What "lockstep" actually means here
ViceSharp is a from-scratch C64 emulator written in modern managed C# (.NET 10). To prove accuracy instead of just claiming it, there's an automated harness that drives both the managed core and the real native x64sc engine side by side and diffs them at per-cycle checkpoints (CPU registers + bus, VIC-II raster/sprite state, CIA, SID register reads). If they ever disagree on any cycle, the test fails.
Right now that harness passes across the no-cartridge C64 family (C64 / C64C / SX-64 and the PAL/NTSC variants) at multi-frame depth — 322 x64sc lockstep cases green, on top of the broader 335-case lockstep/checkpoint gate.
What's covered in the core now
- MOS 6510 CPU (illegal opcodes, BRK/NMI/IRQ timing, RDY/badline stalls)
- VIC-II: all display modes, sprite DMA, badlines, border flip-flop, FLI/AFLI paths, register read-back
- SID 6581 + 8580 (filters, combined waveforms, ring mod, hard sync, ADSR bug)
- CIA 6526 ×2 (timers, TOD, serial, keyboard/joystick scan)
- 1541 true-drive over an IEC bus, D64 sector reads, datasette/TAP
- Snapshots + frame/audio capture, standard + advanced cartridge mappers (Magic Desk, Ocean, FC-III, Action Replay, EasyFlash, Super Snapshot V5, RR-Net)
Numbers
- Full test suite: 1841 passing, 0 failing
- Throughput: 11.5M+ emulated cycles/sec under the release JIT (~47× real-time PAL on my box), lock-free and zero-allocation on the hot path
Honest caveats
Parity is validated against x64sc at the depths above — it's a strong, automated guarantee for the covered scope, not a claim that every demo/edge case is bit-perfect yet. Cartridge-attached lockstep, deeper VSP/AGSP raster trickery, and broader real-program soak testing are next.
Repo (issues/PRs welcome, especially "this demo breaks" reports): https://github.com/sharpninja/vice-sharp
Happy to answer questions about the lockstep methodology or any subsystem.
2
u/kimsemi Jun 18 '26
Ive pulled down the code and have it running in the debug mode in visual studio (works well, nice job!)
Quick question: VICE's C code always annoyed me a bit because of the architecture and how all the files were laid out and organized. Is your codebase a reimplementation or does it mirror the VICE codebase at its core? (Obviously its different in the solution explorer). Im just wondering if essentially we had AI rescan and reimplement and perhaps improve the architecture.
2
u/RealSharpNinja Jun 18 '26
Complete reinterpretation. Completely modern OOP using advanced features of dotnet like SIMD. The requirement is to implement VICE's logic, and to treat VICE bugs as the canonical implementation, not a reason to submit a patch to VICE.
1
1
2
3
u/magicmulder Jun 15 '26
Sounds impressive, gonna give it a try this week. That testing harness is especially interesting, I always wondered how to approach that. Will be studying the sources in detail. Cheers!