C64 Tutorial Part 0
Setting Up Your Environment
Before we start programming on the Commodore 64, we need to set up our emulator and learn how to save and load programs. This tutorial will walk you through installing VICE (the most popular C64 emulator), configuring it, and understanding how to work with disk images.
Installing VICE
VICE (the Versatile Commodore Emulator) is a cross-platform emulator that accurately recreates the Commodore 64 hardware. It’s free, open-source, and runs on Windows, macOS, and Linux.
Windows Installation
- Visit vice-emu.sourceforge.io
- Download the latest Windows installer (GTK3 version recommended)
- Run the installer and follow the prompts
- Launch x64sc from your Start Menu (this is the accurate C64 emulator)
macOS Installation
- Visit vice-emu.sourceforge.io
- Download the latest macOS DMG file
- Open the DMG and drag VICE to your Applications folder
- Launch x64sc from your Applications folder
Note: You may need to allow the application in System Preferences → Security & Privacy if macOS blocks it.
Linux Installation
Use your distribution’s package manager to install VICE. For example:
Fedora/Nobara:
sudo dnf install vice
Ubuntu/Debian:
sudo apt install vice
Arch:
sudo pacman -S vice
After installation, launch x64sc from your application menu or terminal.
Setting NTSC Mode
The Commodore 64 came in two video standards: PAL (Europe/Australia) and NTSC (North America/Japan). Since we’re in Canada, we use NTSC. This affects the timing and vertical resolution of the display.
To set NTSC mode:
- In VICE, click Preferences → Settings
- Navigate to Machine/Model in the left sidebar
- Set Model to: C64C NTSC
- Click Close
- Save your settings: Preferences → Save Settings
This ensures your programs run at the correct speed and display properly.
Creating and Attaching a Disk Image
The C64 stored programs on floppy disks. In VICE, we use virtual disk images (files with a .d64 extension) to simulate these disks.
Creating a New Disk Image
- Click File → Attach disk image → Unit 8
- Click Create new image
- Choose a location and filename (e.g.,
mywork.d64) - Set Image type to D64 (1541)
- Enter a Disk name (optional, e.g., “MY PROGRAMS”)
- Click Create and then Autostart
You now have an empty virtual disk attached to your C64!
Attaching an Existing Disk Image
- Click File → Attach disk image → Unit 8
- Browse to your
.d64file - Click Autostart
The disk is now ready to use.
Saving Your Programs
The SAVE command writes your program to the attached disk. The basic syntax is:
SAVE "FILENAME",8
The 8 refers to device 8, which is the disk drive.
Basic SAVE Example
Type a simple program:
10 PRINT "HELLO WORLD"
20 GOTO 10
Save it to disk:
SAVE "HELLO",8
Wait for the drive light to stop flashing. Your program is now saved!
Overwriting Files with @:
If you try to save a file that already exists, the C64’s disk drive will blink green, and the file won’t actually be saved. To overwrite the existing file, use the @: prefix:
SAVE "@:HELLO",8
The @: tells the disk drive to replace the old version with the new one.
Remember: There’s no “undo” when you overwrite a file!
Loading Programs and Listing Directory Contents
The LOAD command reads programs from disk back into memory. It has two main uses: loading programs and listing the disk directory.
Loading a Program
To load a program into memory:
LOAD "HELLO",8
Then type RUN to execute it.
To load and automatically run:
LOAD "HELLO",8,1
The ,1 parameter loads the program and prepares it to run (then type RUN).
Listing Disk Contents
To see what’s on your disk, load the directory:
LOAD "$",8
Wait for the drive light to stop, then type:
LIST
You’ll see output like this:
0 "MY PROGRAMS " 00 2A
1 "HELLO" PRG
664 BLOCKS FREE.
This shows:
- The disk name (“MY PROGRAMS”)
- Each file name and type (PRG = program)
- How many blocks are free
Important: After viewing the directory with LIST, your program in memory is replaced by the directory listing! Always save your work before loading "$".
Quick Reference
| Command | Purpose |
|---|---|
SAVE "NAME",8 |
Save current program to disk |
SAVE "@:NAME",8 |
Overwrite existing file |
LOAD "NAME",8 |
Load program from disk |
LOAD "$",8 then LIST |
View disk directory |
RUN |
Run the program in memory |
NEW |
Clear program from memory |
Tips for Success
- Always attach a disk image before trying to save programs
- Save your work frequently - emulators can crash!
- Use descriptive filenames (max 16 characters)
- Check the directory regularly to verify your files are saving
- Remember that loading
"$"erases your program from memory - The VICE emulator saves disk images automatically when you write to them
Now that you have VICE configured and understand how to save and load programs, you’re ready to start coding!