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

  1. Visit vice-emu.sourceforge.io
  2. Download the latest Windows installer (GTK3 version recommended)
  3. Run the installer and follow the prompts
  4. Launch x64sc from your Start Menu (this is the accurate C64 emulator)

macOS Installation

  1. Visit vice-emu.sourceforge.io
  2. Download the latest macOS DMG file
  3. Open the DMG and drag VICE to your Applications folder
  4. 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:

  1. In VICE, click PreferencesSettings
  2. Navigate to Machine/Model in the left sidebar
  3. Set Model to: C64C NTSC
  4. Click Close
  5. Save your settings: PreferencesSave 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

  1. Click FileAttach disk imageUnit 8
  2. Click Create new image
  3. Choose a location and filename (e.g., mywork.d64)
  4. Set Image type to D64 (1541)
  5. Enter a Disk name (optional, e.g., “MY PROGRAMS”)
  6. Click Create and then Autostart

You now have an empty virtual disk attached to your C64!

Attaching an Existing Disk Image

  1. Click FileAttach disk imageUnit 8
  2. Browse to your .d64 file
  3. 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


Now that you have VICE configured and understand how to save and load programs, you’re ready to start coding!

Next: Part 1 - High/Low Game | Back to Home