Introduction: Load Commodore Computer Programs Using MS Excel

I appreciate a good spreadsheet and enjoy tinkering with retro-computers, so thought I'd put them together!

As a result, here's a cheap and simple way of loading software onto a Commodore 64 or Commodore Vic-20 retro-computer from a macro-enabled Excel spreadsheet, with the help of an Arduino / clone microcontroller.

Some of the main features are:

  • Load D64, PRG and T64 program files, including multi-loaders to your Commodore
  • Select programs from the comfort and familiarity of an Excel spreadsheet
  • View box art for the program where this has been set-up
  • Switch between the Commodore 64 or Vic-20 computers if you have both computers
  • Works with various 5V 16Mhz Arduino / clone microcontrollers, including the popular Arduino Uno
  • Requires simple connections to the Commodore serial interface and Windows PC / laptop

Supplies

Assuming you have a Windows PC with Excel and a Commodore 64 / Vic-20 computer (of course), items are cheap and readily available on eBay.

  • For connecting to the Commodore, a 5V 16Mhz Arduino / clone microcontroller is used. This may be an ATmega32U4 device (Micro, Pro-Micro and variations) or ATmega328P device (Uno, Nano)
  • Cables, wires and headers are needed to connect the Commodore, Arduino and PC together. This varies a bit depending on the choice of Arduino used, explained further in the next section
  • Connection to the Commodore serial port is via the 6 pin DIN socket and 5 wire cable (or jumper wires)

Excel Microsoft 365 running on a 10 year old Windows 10 laptop and also a new Windows 11 computer were used for testing this project. The project may work with other versions of Excel.

Depending on what you have available to connect to the Commodore serial port, soldering a new cable may be necessary.

Step 1: Hardware Connections

Important! Although the connections required are simple, there is potential for variation and errors, so only proceed if you are content to take on all risks involved. Some specific points to be aware of are listed below.

  • Only use a 5V 16Mhz Arduino / clone microcontroller as listed in the supplies section. A 3.3V Arduino / clone is likely to be damaged if connected directly the Commodore
  • The connections to the Commodore and Arduino are essential to get right. Damage to the Commodore and Arduino may result if this isn't done
  • This project potentially involves soldering the pin connections for the Commodore and Arduino. Ensure you're confident to do this and that connections will be secure and will not leave pins touching one another

Next, decide the Arduino / clone to use, which also determines the cable needed to connect to your PC.

  • The Uno needs a USB B-type male to USB male cable
  • The Pro-Micro needs a standard micro-USB to USB cable
  • The Pro-Micro USB Beetle needs a USB female to USB male cable

To connect the Commodore and Arduino, prepare a cable as shown in the diagrams.

  • Soldering wires onto the 6 pin DIN connector is a bit tricky, so it's worth checking YouTube videos for tips if not done before
  • Any digital pins may be used. The digital pins used in these diagrams are working examples. The ones you choose are defined in the settings tab on the spreadsheet, so keep a note of the Arduino pin numbers used for each of the Atn, Clock, Data and Reset pins
  • The Arduino pin connections need to terminate as male pins for the Uno. For the others, usually female pins are required (depends on the choice of header pins used)

Having a reset button is useful for restarting the Arduino which is occasionally needed if a program fails in loading. The Arduino Micro and Uno already have one but many Arduino clones do not.

  • To make one, a momentary button needs to be connected between the reset pin (usually labelled RES or RST) and ground pin (GND)
  • Alternatively, the Arduino needs to be re-plugged in to reset it

A picture is shown of a completed, working example using a Pro-Micro USB Beetle with a reset button mounted in a Lego case. I chose the Pro-Micro USB Beetle as my main device because it is the smallest option and has a sturdy male USB header for the PC connection.

Step 2: Software Installation

Start by setting up the Excel spreadsheet:

  • Download the ExcelCommodroid.xlsm macro-enabled spreadsheet from https://github.com/raspberrypioneer/ExcelCommodroid to a folder location on the PC
  • When the spreadsheet is first opened, a message appears "SECURITY WARNING Some active content has been disabled. Click for more details". This is due to the macros needed to run the loader software
  • To allow the macros to run and use the spreadsheet, choose "Enable content". If you prefer to understand more before doing so, you can review the code as explained below


  • To view the macros, enable the Developer tab via File > Options > Customize Ribbon, and select the Developer tab under the All Tabs dropdown
  • From the Developer tab, choose Visual Basic to view the modules and classes as shown below

c64, vic20: Code for these sheets to handle connect / disconnect, program selection and viewing box art

frmBoxArtView: Simple form for displaying box art

PROGRAM_LOADER: Contains the main program and loop for getting messages from the Arduino and sending responses back. Includes handshake with Arduino and handles open program, close, get program size, read packet of data, read directory listing

SERIAL_PORT_VBA: Contains the code to connect and communicate with the Arduino. Works like an imported library, see the Acknowledgement section for details

UTILS: Code for handling display of box art images

D64_DRIVER: Class for reading D64 program files and returning data to the program loader

PRG_DRIVER: As above for PRG program files

T64_DRIVER: As above for T64 program files

  • The VBA project references are standard except for the addition of the VBScript Regular Expressions library
  • If you only have a C64 or Vic-20, you can delete the other tab you don't need


Next, compile and upload the Arduino software:


  • The Arduino sketch consists of a number of files. The main ones are briefly described below.

commodore_sketch.ino: Main sketch which deals with the PC handshake and calls the disk interface handlers

interface.cpp, interface.h: Handles the communication events between the PC and the Commodore IEC disk interface

iec_driver.cpp, iec_driver.h: Provides the disk interface to the Commodore handling the Atn, Clock, Data, Reset signals

Step 3: Configuration Settings

At this stage, set-up of the hardware, connections, spreadsheet and sketch should all be complete. This step deals with the configuration needed, which is typically done once by updating the settings tab values on the spreadsheet.

  • COMPORT is the choice of Windows USB / COM port being used. If you connect the Arduino to the same USB port each time, the COM port number usually remains the same

Find the COM port being used by connecting the Arduino to a USB port and type "system" in the Windows search box. Choose the System Information app, then navigate to the serial ports section as shown in the screenshot

If the COM port number being used is greater than 20 (probably unlikely), then the maximum port number value will need changing in the SERIAL_PORT_VBA code. This is done by opening this module via Developer > Visual Basic > VBAProject > Modules and editing the value at the top of the file

  • PINS are the pins used on the Arduino mapped to the Commodore serial interface (Atn, Clock, Data, Reset pins). The Hardware Connections step contains more details about this
  • MEDIA_FOLDER defines where the Commodore games / roms and box art images should be located. This project does not include Commodore programs as there are potential copyright implications in doing so. These have to be sourced independently and copied to the media folder

D64, PRG and T64 program files are kept in c64 and vic20 subfolders

Box art images are optional, but if used must be located in the art subfolders and given the same name as their corresponding game with a jpg file extension, e.g. Blue Max.d64 may have an associated image called Blue Max.jpg. RetroPie style image naming also work, e.g. Blue Max-image.jpg. Note that png image files unfortunately do not work

Use the Refresh List button on the settings tab to add programs to the c64 and vic20 program lists in the spreadsheet. New programs are added in alphabetic order to the end of an existing list. All program columns can then be populated and sorted as required.

Step 4: Using the Spreadsheet

Ensure all the physical connections are made between the Commodore, Arduino and PC. Check the Hardware Connections step for details and diagrams if needed.

  • Remember that the Commodore should always be turned off when physically connecting to it
  • On the c64 or vic20 tab, click the Connect button to connect to the Arduino. A colour indicator around the button shows the status of the connection

Background colour: Connection not started

Red: Not connected

Orange: Connected ok, handshake in progress

Green: Arduino handshake ok, ready to go

  • If there is a problem connecting, reset the Arduino and wait 5-10 seconds, then click Disconnect and Connect again

To select a program to load, click on the cell of the program you want or alternatively, enter the program name in the cell beneath the Connect button. Usually Excel will find the name before you type it in full.

Click on the Show box art button to see box art associated with the program. Clicking through the program names will show art for the selected program where available.

Step 5: Loading Commodore Programs

Once you have selected the program required, over on the Commodore issue the required LOAD command.

LOAD "*",8 is used to load the selected D64, PRG or T64 based program. The disk drive number is always 8

LOAD "*",8,1 is needed for many Vic-20 games and some C64 games. The program will be loaded at the memory location given in the first two bytes of a PRG file

LOAD "program.ext",8 where program.ext is the full program name and extension, e.g. LOAD "BLUE MAX.D64",8 loads Blue Max.d64. Unlike the other load commands above, there is no need to navigate to the program beforehand

LOAD "partial name.*",8 where partial name is contained in the program name, e.g. LOAD "BLUE.*",8 loads Blue Max.d64. If there is more than one match, then the first one is used. Unlike the other load commands above, there is no need to navigate to the program beforehand

RUN runs the program following LOAD above

LOAD "$",8 loads a directory listing of the contents of a D64 or T64 file

LIST lists the directory contents after the command above

LOAD "program number",8 where program number is 1, 2, 3 etc counting PRG programs from the top of a directory listing, e.g. LOAD "2",8 loads the second program on the listing. For D64 or T64 based programs, this is a shortcut way of loading a program somewhere on the listing without having to type the full program name

Note that load times in disk drive mode are not fast by modern standards, taking just over a minute for most programs. I have been able to load and run over 200 titles of favourite and popular C64 and Vic-20 games, including Vic-20 games requiring a memory expansion. This is not a 'true' disk drive emulator though and there are some related downsides and things which have not been tested.

  • Some C64 program files do not load because they require features of the actual disk drive hardware
  • Has not been tested with C64 fast-loader cartridges
  • Has not been fully tested for programs which use two or more D64 files
  • Saving programs or handling disk operations e.g. renaming a file is not currently supported
  • This project has used a PAL C64 and Vic-20 for testing, so it's uncertain how this might work on NTSC machines

A program title may have many different roms. If having a problem, try other versions instead, especially for a favourite game.

Step 6: Acknowledgements

The information and code shared by the following sources helped inspire this project and is gratefully acknowledged.

Step 7: Conclusion

Enjoy your new spreadsheet to play games with! Comments and ideas are welcome.