Emulating A Complete Commodore 64

When the Commodore 64 was released in 1982, it was a masterpiece of engineering. It had capabilities far outstripping other home computers, and that was all due to two fancy chips inside the C64. The VIC-II, the video chip for the C64, had sprites and scrolling, all stuffed into a single bit of silicon. The SID chip was a complete synthesizer on a chip. These bits of silicon made the C64 the best selling computer of all time, but have also stymied efforts to emulate a complete C64 system on a microcontroller.

[Frank Bösing] has just managed to emulate an entire C64 on a Teensy 3.6. The Teensy uses an exceptionally powerful microcontroller, but this is a labor of love and code.

The inspiration for this project comes from a reverse-engineered SID chip that was ported to the Teensy 3.2. The SID chip is the make it or break it feature of any C64 emulation, but the Teensy 3.2 didn’t have enough RAM for the most recent versions of reSID. With the release of the Teensy 3.6, [Frank] figured the increased amount of RAM would allow a complete C64 system, so he built it.

The new C64 emulator uses a Teensy 3.6, with a small add-on ‘shield’ (or whetever we’re calling them) to provide connectors for joysticks and the Commodore IEC bus. There’s audio out, support for USB keyboards, and support for an IL9341 SPI display or a regular ‘ol VGA display.

The entire development of this Commodore emulator has been documented over on the PJRC forums, and all the code is over on GitHub. It’s a fantastic piece of work, and as the video (below) shows, this is a real Commodore 64 that fits in your pocket.

40 thoughts on “Emulating A Complete Commodore 64

      1. No, The C64 did not need the disk-drive – in fact most people would manage well with only a tape-drive.
        But yes, the disk-drive were intelligent (about the same CPU with less RAM as the C64 itself), and could be used similar to an SQL database, so it was really easy to make advanced programs in BSAIC on the C64.

        1. I think it’s in Europe that most C64 did not have a disk drive, i’m Canadian and I’ve never seen a store selling C64 games on anything but disk, American magazines also offered disks, either with the magazine or on order.

          1. My first computer was a C=128 with a 1571. however over the years, I picked up old 64’s some cartridge games, even a few tape games, I think I may still have the tape drive in the back room. I later got a +4 just to tinker with, had a nice monitor that matched the +4. I programmed some pro 2nd Amendment text to display on the screen and took it to a gun show. A fellow at the show loved them machine so much, he traded me a very nice Ithaca 10 gauge double barrel shotgun for the machine. Even had an SX64 that I picked up following major back surgery and had that set up on the coffee table next to the couch where I lay recovering for over a month. The SX was a godsend in that situation.
            This, of course was in the USA. So we did use tape drives, and cartridges in our C=128 and 64’s.

          1. One 6502 cpu, 2x 6522 via, and about 2K of ram, iirc. But all that was there essentially just to get sectors back and forth between buffers. The rom routines were just smart enough to manage sector allocation and follow file chains, and that was all largely transparent as far as the C64 itself was concerned, bcz the 1541 presented it all througha serial protocol.

        2. A lot of users in Europe made use of the Datasette which was reliable if slow though most North American users bought a 1541 since the computer was sold very discounted in those markets.

      1. I beg to differ. The monitor is definitely an essential part of the system. I imagine a 4k monitor and a bigass air core inductor hand wound to perfectly mimic the magnetic field of crt’s of the era in a 3D printed casing. It must be a high resolution monitor to be able to replicate the rgb segments.

          1. Will need something to churn out an obnoxious 15.75 kHz whistle, too. Seemed like the horizontal deflection always made it into the audio circuits. Most TVs did it, but that 1702 official C= brand monitor was especially loud in that way

    1. Not to mention that the face of the CRT usually had enough static charge on it to hold a full sheet of paper stuck to it, sometimes handy when typing in long listings before you saved them to tape

  1. “The Teensy is an exceptionally powerful microcontroller”
    I think NXP/Freescale didn’t rename their Kinetis (Teensy 3.6 is using K66) microcontroller family. Therefore Teensy is just the brand name of the development system. There are way more powerful microcontrollers.

  2. How the hell is 32 kB of RAM insufficient for SID emulation? What kind of hell am I living in? The SID has just a few registers, a few internal state registers and that’s all. The only place where you may need a bit of memory is for applying some filters…
    Reading this makes my eyes bleed.

    1. After a brief look at the ReSid sources, it seems it uses big lookup tables to generate waveforms, which would be a good things because the SID sounds didn’t consist in pure waves: its flaws made its sound that distinctive.

        1. Yes and no. the counters make the ideal triangle and sawtooth wave samples but the DAC inside and the analog circuits where flawed. and of course the filters. and also the filters where controlled by some DAC-values that had a huge variation from sid to sid. these non-linear DAC behaviours need to be emulated somehow. one approach is a ram-lookup-table – especially when speed optimization is an issue. but this could also be used as a new feature to implement wave-table synthesis extension.

    1. There is the VICE emulator for almost everything Commodore, which uses the same base SID emulator code as this project, so if that’s available for Linux on the particular ARM architecture used in rPi’s, then it’d be easier than you’d expect.

  3. Aside from the video output, it really lacks the “look and feel” of the C64.
    It needs a similar looking enclosure, maybe a “hat/shield/bonnet/bone/”(or whetever [sic]we’re calling them)” that will slip over a keyboard.

  4. Back in the day I was doing Commodore 64 development, we had an IEEE bus adapter and a “professional grade” Commodore dual 1.2 Mbyte floppy setup. Those 1.2 Mbyte floppies were like solid state drives compared to the awful 1541 floppy drive, very fast, very reliable, very expensive. We had a hot office with no A/C and the 1541 drives would die all the time, even with fans attached to them. Also Commodore used some sort of shellac in the manufacturing process which was a terrific bug attraction, and our office was directly above a pizza restaurant, so my system had to be opened up and cleaned out on a regular basis to remove the accumulated dead cockroaches. The Commodore programming manual was very good but no match for the excellent “De Re Atari” documentation for the Atari 800.

  5. One of the first boards I ever made for my Apple //e was an card with the commodore SID chip on it. Thinking back probably could have made a mint if I would have sold them.

    1. Yay!
      I got one of those after reading about them in an article here on HaD, I hadn’t heard of them before then.
      There’s also the new C64 mini. Like the NES mini, SNES mini of recent years it’s also an emulator in a box, but it’s the first one I’ve been tempted to purchase.

    2. Because it is just one of many and because it’s not a good one. Bad SID (no filters! filters is what makes the SID special!) and a lot of quirks and flaws.

      There are several much better efforts out there, both in software and (programmable) hardware.

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.