antirez / c64-hw-simulator
git clone https://github.com/antirez/c64-hw-simulator.git
Commodore 64 hardware simulator
—
stars, 24h
+399
stars, 7 days · #147
+399
stars, 30 days · #680
399
★ total · +399% this week
16
forks · 1 open issues
Star history starts 2026-10-20; the chart appears after the second daily snapshot.
LanguageC
License—
Created2026-10-15 (5d ago)
Last pushtoday
Watchers9
OwnerUser
Links
README excerpt
# c64-hw-sim c64-hw-sim simulates the motherboards of the Commodore 64 (ASSY 250407) and of the ZX Spectrum 48K (board Issue 3B), pin by pin. You can lift the leg of a chip, short it to ground or to +5V, pull a chip out of its socket, or open a resistor. Then you watch what the machine does: the picture on the monitor, the keyboard, every signal on the board. The program knows the board's netlist (the electrical connections on the PCB) and how each chip behaves at its pins. It knows nothing about what a broken Commodore 64 or Spectrum looks like: when you simulate a broken part and the screen fills with garbage, that garbage was computed from the circuit, not chosen by someone who knew what to expect. Here is an example. Lift pin 17 (A7) of the C64 color RAM before power on, and the machine boots and looks healthy. The CPU writes and the VIC reads with the same wrong address, so the RAM simply aliases. Put the leg back, and the half of the color RAM that was never written shows up as random colors. Lift it again, and the screen is clean. A real 2114 does the same. With this program you can do mainly two things: 1. Learn how the Commodore 64 and the Spectrum work at a more intimate level, in a way that is hard to reproduce on real hardware without the risk of damaging it (and on most boards many chips are soldered, not socketed). 2. If you have a broken C64 or Spectrum and some hypothesis about what could be broken, simulate it with this program and perhaps gain clues, so that you can desolder chips in the most logical order, and desolder as few of them as possible (desoldering is a boring process, and every time it risks damaging the board...). A matching symptom is a clue, not a proof: different faults can look the same, and the simulation has its limits (see below). Please note that **even on fast computers** this program struggles to simulate these machines at real speed. A real C64 is simulated at 31% of its speed on an Apple M3 Max, 39% on an AMD Ryzen AI Max+ PRO 495 (Gorgon Halo), and 48% on an Apple M5 Max. The ZX Spectrum is simulated at 23%, 28% and 34% of its speed on the same computers. This is not a problem for the goals of this program, but be warned: it is not an emulator to play games with. Why is the Spectrum slower to simulate than the C64, even though its board is simpler? Because of the time resolution. The ULA is simulated at a very low level, so that the bus contention just emerges from the simulation. Its signals are timed to the half period of its 14 MHz oscillator, so the whole board settles 28 million times per simulated second, against about 6 million for the C64. Above: the classic C64 `10 PRINT CHR$(205.5+RND(1));:GOTO 10` maze is running when the character ROM (U5) is pulled out of its socket, and later put back. The CPU, the RAM and the program keep working; only the shapes of the characters are lost, as repairers know well. The scope is on the data line D0 of the ROM socket: with the socket empty, the bus