Commodore 64 Files on macOS
Last year, I managed to acquire a C=64 Maxi. It’s a faithful replication of the original Commodore 64 based on an ARM SBC, similar to a Raspberry Pi, running a minimal Linux kernel and VICE. As I’m also a Mac user, I had to figure out how to access and transfer files, and develop software for the C=64 on the Mac. This should be mostly the same if using The C=64, or emulation of the C=64 on the Mac itself.
NOTE: While the installation process is different, using the tools is the same under Linux as macOS.
You’ll need a few things:
- The Xcode Command Line Tools
- c1541 which is part of the Vice package to access disk images
- cc65 to compile C programs
- detox64 to de-token BASIC programs
- cbmbasic to run BASIC programs locally
Xcode cmd tools and brew installs are documented on their respective pages.
c1541 as mentioned, is part of the Vice package. Vice, cc65, and cbmbasic can be installed with Brew.
$ brew install vice cc65 cbmbasic
For Detox, you’ll need to download the source and compile it
$ git clone https://github.com/vroby65/detox64 $ cd detox64 $ make make -C src gcc -o detox64 detox64.o $ cp src/detox64 ~/bin
Transferring files to and from .d64 or .d81 files
The c1541 will let you copy files to and from disk images.
Run it giving it the disk image name
$ c1541 BASIC-1.d81 c1541 (VICE 3.6.1) Copyright 1995-2022 The VICE Development Team. C1541 is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions.
Use the list command to get a disk list
c1541 #8> list 0 "disk " 3d 1 "10print" prg 1 "count mil" prg 1 "shooting" prg 1 "babycry" prg 1 "dolcry" prg 1 "simpson x sq" prg 1 "prime1" prg 2 "prime1a" prg 3151 blocks free.
Use the read command to copy files out of an image.
read “file” /path/to/file
c1541 #8> read prime1 /tmp/prime1 reading file `prime1' from unit 8
Use the write command to put files onto images
c1541 #8> write SPIRICOM.PRG "SPIRICOM" writing file `????????.???' as `????????' to unit 8 c1541 #8> list 0 "disk " 3d 1 "10print" prg 1 "count mil" prg 1 "shooting" prg 1 "babycry" prg 1 "dolcry" prg 1 "simpson x sq" prg 1 "prime1" prg 2 "prime1a" prg 39 "SPIRICOM" prg 3112 blocks free.
When done, use the quit command to exit.
There is are many other commands that it has such as a format and GEOS specific commands.
De-tokenizing and running BASIC programs
Since Commodore 64 programs are stored tokenized on disks, you’ll need to use detox64 to convert them to ASCII text.
To do so, just run detox > file.bas
$ detox64 /tmp/hello 10 PRINT"HELLO!" 20 GOTO 10
Or to save to a .bas file
$ detox64 /tmp/hello > /tmp/hello.bas
To run the basic program, use cbmbasic. Just know that it can’t use PETSCII characters and Pokes and Peeks don’t really work either.
$ cbmbasic /tmp/hello.bas | head -5 HELLO! HELLO! HELLO! HELLO! HELLO!
Compiling C programs
Use cl65 ( part of the cc65 package ) to compile C language programs.
$ cl65 -t c64 -o hello.prg hello.c $ file hello.prg hello.prg: CBM BASIC, SYS 2061
And then you can use c1541 to copy it to a disk image as described above or use vice to run it
$ x64sc hello.prg
To get the files to The C=64, all you need to do is copy the disk image to an USB drive and plug it into The C=64, then access it as you would any disk image.
In a future post, I’ll go over using a Greaseweazle to access files on physical disks.