Generative AI Hits The Commodore 64

Image-generating AIs are typically trained on huge arrays of GPUs and require great wads of processing power to run. Meanwhile, [Nick Bild] has managed to get something similar running on a Commodore 64. (via Tom’s Hardware).

A figure generated by [Nick]’s C64. We shall name him… “Sword Guy”!
As you might imagine, [Nick’s] AI image generator isn’t churning out 4K cyberpunk stills dripping in neon. Instead, he aimed at a smaller target, more befitting the Commodore 64 itself. His image generator creates 8×8 game sprites instead.

[Nick’s] model was trained on 100 retro-inspired sprites that he created himself. He did the training phase on a modern computer, so that the Commodore 64 didn’t have to sweat this difficult task on its feeble 6502 CPU. However, it’s more than capable of generating sprites using the model, thanks to some BASIC code that runs off of the training data. Right now, it takes the C64 about 20 minutes to run through 94 iterations to generate a decent sprite.

8×8 sprites are generally simple enough that you don’t need to be an artist to create them. Nonetheless, [Nick] has shown that modern machine learning techniques can be run on slow archaic hardware, even if there is limited utility in doing so. Video after the break.

Continue reading “Generative AI Hits The Commodore 64”

Emulate A KIM-1 With A Commodore 64

When you think about virtualization, you usually think about making some CPU pretend to be another CPU. However, there are sometimes advantages to making a computer pretend to be the same computer.

That’s the case with [oldvcr]’s KIMplement, which emulates a KIM-1 with a 6502 using a Commodore 64, which also uses a 6502.The reason this makes sense is that you have total control over an emulated CPU. If a program, for example, writes to a critical memory location or tries to take over the screen or keyboard, you can easily make the emulator do something more appropriate. Things like breakpoints and single stepping also become trivial.

The virtual machine at the heart of it is 6o6 (6502 on 6502), and it seems to perform well. By virtualizing, you can easily protect the system from programs that try to, for example, take over an interrupt vector. This is similar to how x86 protected mode can run old real-mode code in a virtual environment and intervene for certain instructions. The emulation is good enough that the emulator can run the emulator, which then runs the emulator to actually run the real target. That’s wasteful, of course, but it does speak to the completeness of the pretend CPU.

If you want a KIM-1 (and an 1802 Elf) but only have an Arduino, you can emulate a different way. At least an emulated KIM-1 doesn’t develop bad memory chips.

You Can Use Visual Studio Code To Write Commodore 64 Assembly

Once upon a time, you might have developed for the Commodore 64 using the very machine itself. You’d use the chunky old keyboard, a tape drive, or the 1541 disk drive if you wanted to work faster. These days, though, we have more modern tools that provide a much more comfortable working environment. [My Developer Thoughts] has shared a guide on how to develop for the Commodore 64 using Visual Studio Code on Windows 11.

The video starts right at the beginning from a fresh Windows install, assuming you’ve got no dev tools to start with. It steps through installing git, Java, Kick Assembler, and Visual Studio Code. Beyond that, it even explains how to use these tools in partnership with VICE – the Versatile Commodore Emulator. That’s a key part of the whole shebang—using an emulator on the same machine is a far quicker way to develop than using real Commodore hardware. You can always truck your builds over to an actual C64 when you’ve worked the bugs out!

It’s a great primer for anyone who is new to C64 development and doesn’t know where to start. Plus, we love the idea of bringing modern version control and programming techniques to this ancient platform. Video after the break.

Continue reading “You Can Use Visual Studio Code To Write Commodore 64 Assembly”

The experimental setup – a Commodore 64 is connected to a monitor through a composite video to HDMI converter, with the code cartridge inserted into the expansion port.

Trolling IBM’s Quantum Processor Advantage With A Commodore 64

The memory map ofthe implementation, as set within the address space of the Commodore 64 - about 15kB of the accessible 64kB RAM is used. 8kB of this is reserved for code, although most of this is unused. Each of the two bitstrings for each Pauli string is stored separately (labeled as Pauli String X/Z) for more efficient addressing.
The memory map of
the implementation, as set within the address space of the Commodore 64 – about 15kB of the accessible 64kB RAM is used.

There’s been a lot of fuss about the ‘quantum advantage’ that would arise from the use of quantum processors and quantum systems in general. Yet in this high-noise, high-uncertainty era of quantum computing it seems fair to say that the advantage part is a bit of a stretch. Most recently an anonymous paper (PDF, starts at page 199) takes IBM’s claims with its 127-bit Eagle quantum processor to its ludicrous conclusion by running the same Trotterized Ising model on the ~1 MHz MOS 6510 processor in a Commodore 64. (Worth noting: this paper was submitted to Sigbovik, the conference of the Association for Computational Heresy.)

We previously covered the same claims by IBM already getting walloped by another group of researchers (Tindall et al., 2024) using a tensor network on a classical computer. The anonymous submitter of the Sigbovik paper based their experiment on a January 2024 research paper by [Tomislav Begušić] and colleagues as published in Science Advances. These researchers also used a classical tensor network to run the IBM experiment many times faster and more accurately, which the anonymous researcher(s) took as the basis for a version that runs on the C64 in a mere 15 kB of RAM, with the code put on an Atmel AT28C256 ROM inside a cartridge which the C64 then ran from.

The same sparse Pauli dynamics algorithm was used as by [Tomislav Begušić] et al., with some limitations due to the limited amount of RAM, implementing it in 6502 assembly. Although the C64 is ~300,000x slower per datapoint than a modern laptop, it does this much more efficiently than the quantum processor, and without the high error rate. Yes, that means that a compute cluster of Commodore 64s can likely outperform a ‘please call us for a quote’ quantum system depending on which linear algebra problem you’re trying to solve. Quantum computers may yet have their application, but this isn’t it, yet.

Thanks to [Stephen Walters] and [Pio] for the tip.

Making The Commodore SX-64 Mini

When you find a portable TV from the 1980s, and it reminds you of the portable Commodore 64, there’s only one thing to be done. [Aaron Newcomb] brings us the story of taking an Emerson PC-6 and mating it to the guts of his THEC64 Mini. It’s a bit of a journey, as the process includes modding the TV to include a composite input and trimming some unused PCB off the TV’s mainboard. Then some USB ports and a three-and-a-half inch floppy drive were shoehorned into the chassis, with the rear battery compartment holding the parts from THEC64 Mini.

The build was not entirely without issue. It turns out the degaussing coil connector can plug perfectly into the service port, and Murphy’s law proved itself true again. But no harm was done, and the error was quickly discovered. All that was left was to button the chassis back up and add some paint and 3d-printed trim details. The build looks great! Come back after the break to watch the video from the [Retro Hack Shack] for yourself.

Continue reading “Making The Commodore SX-64 Mini”

Developing In Pascal On The Commodore 64 With Abacus Super Pascal 64

Abacus Super Pascal 64 for the Commodore 64.

Most people associate the Commodore 64 with Commodore BASIC and precompiled applications, but it also had a number of alternative development environments produced for it. One of these was Super Pascal 64 by Abacus. A solid introduction to this software package is provided in a video tutorial by [My Developer Thoughts] on YouTube. This uses the Abacus Super Pascal 64 software and manual from the [Lyon Labs] website, which incidentally has a lot more development environments and operating systems for the C64 listed for your perusal.

Abacus’ Super Pascal supports the official Pascal language, requiring nothing more than a Commodore 64 and two Commodore 1541 floppy disk drives to get started. One FDD is for the Super Pascal software, which boots into the development environment, the other FDD and the disks in it are the target for the current project’s source code and compiled binary. Although the lack of support for FDDs other than the 1541 is somewhat odd, this comes presumably from the operating system nature of the development environment and the 1541 being by far the most common FDD for the C64.

Continue reading “Developing In Pascal On The Commodore 64 With Abacus Super Pascal 64”

Putting The C In C64

Older CPUs and some fairly modern microcontrollers are not made to readily support C compilers. Among those are the 1802, some 8-bit PICs, and the 6502 at the heart of the Commodore 64. That’s not to say you can’t make a C compiler for any of them, but the tricks required to handle the odd word sizes, lack of stack manipulation, or whatever other reason C isn’t a good fit tends to make compiled code bloated and possibly slower. [Dr. Mortal Wombat] took a different approach. The oscar64 compiler takes C source code and compiles it to a virtual machine code or native machine code for cases where performance might be important.

Turns out, the penalty for using native code isn’t as much as predicted, at least in some cases, The performance penalty for using the interpreter, however, can be significant in many common cases. The 6502 has a small stack that is hard to address, and indexing into a user-maintained stack is slow. The word size problem also produces lots of code as you have to break 16-bit operations into multiple 8-bit ones. The compiler aims to be C99-compliant, including floating point, recursion, multiple dimensions for arrays, and pointers to structures.

There are a few things left to hammer out. The linker doesn’t support external libraries, and the floating point code doesn’t understand NaN. On the other hand, many C++ features are available, like namespaces, reference types, templates, and more. The compiler can target several Commodore machines from the C128 to the PET. It also works with some Nintendo and Atari systems and can create various cartridge formats.

If you are writing code for any kind of 6502, it is probably worth checking out. Compiling C for the 6502 is no small feat, but then, so it is targeting PowerPoint. Don’t have a C64? Build one.

Image: [MOS6502], CC-BY-SA 3.0