Slack on the Commodore 64 thanks to Raspberry Pi
We use Slack all the time at Pi Towers. Granted, we often use it for sharing animated cat GIFs and the latest hacks for the office coffee machine, but we are definitely big fans.
Imagine our delight, then, when we heard about a Slack client for the Commodore 64 (another long-standing flame of ours). Our love for the C64 knows few bounds: along with the Sinclair Spectrum and the BBC Micro, it gave many of us here at the Raspberry Pi Foundation a coding kick-start.
The only thing that could make this better is the Raspberry Pi. And guess what’s sitting slap-bang in the middle between Slack and the C64? Only our favourite single-board computer.
This amazing trinity of tech brings our favourite things together for a text messaging party. We just had to figure out how it worked.
It turns out that bringing Slack to the C64 was no easy matter. Jeff Harris is a software engineer and hobbyist game developer in San Francisco. He’s responsible for developing Slack for the C64.
Much as we love it, the C64 is a little long in the tooth, so it needs a little help connecting to Slack’s API. Jeff’s ingenious result is to hook a Raspberry Pi up to it. “The C64 has an extension port called the user port which, via an adapter, can communicate over RS-232 serial,” Jeff says. The solution was to connect the user port on a Commodore 64 to a USB port on the Raspberry Pi, and Jeff created a homemade cable to do just that.
“The fastest I have been able to run this reliably is a solid 1200 baud or 150 bytes per second,” explains Jeff. At 0.00015 MB, it’s not likely to be much use at a LAN party, but it’s good enough for transferring text messages.
Coding Slack in 6502 Assembly
With the hardware hooked up, Jeff set about writing a Slack client for the Commodore 64. “On the Raspberry Pi, I wrote a NodeJS app which talks to the Slack RTM API,” he says.
The Raspberry Pi connects to the Slack API. It then uses the serial port to talk to the USB serial driver.
“On the Commodore, I wrote an application in 6502 Assembly,” says Jeff. “It uses built-in KERNAL ROM functions to read and write the serial port and update the screen.”
In this blog post, Jeff shows how the C64 client code works using C as a demonstration language. If you want to try recreating the project, all the code is available on Jeff’s GitHub page.
It’s great to see the Commodore 64 still being hacked and kept in use after all these years.
As a Z80 hacker, the only thing that makes me sadder than having to deal with the inferior 6502 assembly is node.js.
As an ex-Z80 hacker, I have tremendous respect for 6502 programmers. Having 256 registers and real indexed addressing modes doesn’t quite make up for having no stack…
JS makes development so much simpler, compared to assembler or C/C++ etc. JS is simple enough that those new to programming can use it to do something pretty easily. On the other hand JS is a sophisticated language that will keep experts happy. It has had high level features from the beginning that languages like C++ and Java have only recently adopted, in their clunky ways.
And, the performance of JS is almost up there with natively compiled C/C++.
Nothing to be sad about with JS and node.js.
I’ve got 4 c64s sitting in a box now. I took one out a while back to pull an old recipe off a 5.25 floppy disk. Written to disk 31 years ago and it still printed. Pays to buy good media.
Very cool – but I’m curious why the project didn’t use the Pi’s serial port on the GPIO.
I was about to ask the very same question :)
I don’t know about the C64 serial output, but it might well have been an RS-232 interface. The Pi GPIO serial pins are logic level inputs/output, so interfacing them to RS-232 would require an RS-232 driver chip and a negative DC power supply.
RS-232 to USB adapters take care of all that in one neat package.
> …along with the Sinclair Spectrum and the BBC Micro, it gave many of us here at the Raspberry Pi Foundation a coding kick-start.
My ‘coding’ began with adapting a BASIC satellite-tracker to run in an Excel spreadsheet! Had a ZX, but too fragile. Later an Acorn Electron for assembly-language ASCII pre-Packet Ham Radio Bulletin Board, then a QL with its >64k RAM. Anyone still got/running one of these?
I learnt to program on an Acorn Election. The Electron had the 2MHz 6502A CPU, the BBC’s OS, BBC Basic, built in 6502 assembler and a superb manual. Pity Acorn screwed the performance of the machine by skimping on the 4bit wide data bus to the 4*1x64kbit DRAM chips, if the machine had been built with 8 of these chips the Electron would have the same 64K RAM as the C64 and a near identical processor running at twice the clock speed over the whole memory map.
The RS-232 interface! I had somewhere in my garage an C64! Busy for winter vacation!
D Jeffrey Blumenthal
Boy does this bring back memories! Had one of the original PET computers and wrote everything in Assembler for the 6502 chip.
Um, wouldn’t this also work without a Pi? By just using the uIP Stack (or Contiki OS framework) and a TFE compatible ethernet cartridge? There’s a Twitter client implemented that way. Nice hack though!
I’ve been using a Raspberry Pi for another area of vintage computing. I’ve written a web browser for the Texas Instruments TI-99/4A, supporting a bespoke set of HTML tags that suit the 4A’s limited screen resolution and hardware. The browser makes HTTP GET requests which are sent over the RS-232 port, and a Python script on a Raspberry Pi is used to do serialEthernet conversion in both directions. With a colleague doing the code on a backend web server, we have Internet chess, e-mail, and ideas for a few more games.
Comments are closed