Programming the MEGA65 — Chapter 1: Introduction

Oct 4, 2026 · Updated Oct 11, 2026 · @Craig Taylor

What the MEGA65 Is

The MEGA65 is an 8-bit home computer, built in the 2020s to the design of a machine Commodore never released. It looks and feels like a classic Commodore: a full-size keyboard with a built-in 3.5" floppy drive, a BASIC prompt at power-on, and a built-in machine-language monitor. Underneath, it is something no 1980s machine could be: a single FPGA chip that implements the processor, video, sound and memory in reconfigurable logic, running at speeds and with memory sizes far beyond its ancestors.

It is designed to be understood. Every register is documented, the schematics are published, and the documentation is freely licensed. A programmer can reach any part of the machine directly, from BASIC with POKE or from machine language, and nothing sits between the program and the hardware except what the program chooses to use.

The MEGA65 is also three computers in one:

This book is about programming the first of these, and about using the other two where they help. It follows the plan of Raeto Colin West's Programming the Commodore 64: it starts with the machine and its BASIC, moves through machine language, and then covers graphics, sound, storage and peripherals in turn.

From the C65 to the MEGA65

In 1989 Commodore designed a successor to the C64: the Commodore 65, intended for release in 1990 (MEGA65 Book, p. 1-3). It combined a faster 4510 processor, a new VIC-III video chip with 80 columns and bitplane graphics, two SIDs (Wikipedia, “Commodore 65”), a built-in 3.5" floppy drive and BASIC 10, while keeping a C64 mode for compatibility. The machine never shipped. Prototypes and development units survived, but the C65 remained a collector's curiosity with an unfinished ROM.

The MEGA65 project set out to finish it. Paul Gardner-Stephen and the MEGA Museum of Electronic Games & Art e.V. in Germany joined forces in 2014 and relaunched the project as the MEGA65 in 2015 (Dan Sanderson, “MEGA65: The First Ten Years”). A community of volunteers re-implemented the C65's custom chips in an FPGA, completed and extended the ROM, and designed a new case, keyboard and main board. Along the way the design grew: the 4510 became the 45GS02 with 32-bit operations and a 40.5 MHz top speed, the VIC-III became the VIC-IV, the SIDs became four, and attic RAM, digital audio and Ethernet were added.

Production machines have shipped in several board revisions. The R3A boards were made in 2022 and the R6 boards in 2024; the differences that matter to programmers, such as the audio output on older boards, are noted where they arise (MEGA65 Book, pp. 2-7, V-26).

Because the hardware is implemented in an FPGA, the MEGA65 can be upgraded by loading a new "core", the FPGA configuration, from its SD card. Cores, the ROM and the Hypervisor are updated separately and regularly. Throughout this book, details that depend on a particular version say so, and Chapter 11 explains how a program can find out what it is running on.

The Three Modes

Which machine the MEGA65 becomes at power-on depends on the ROM file on its SD card, and from there it can switch modes on request (MEGA65 Book, p. 11-3):

Mode ROM BASIC Prompt shows
MEGA65 MEGA65 ROM (versions 92xxxx and later) BASIC 65 MEGA65 start-up screen
C65 Original Commodore 65 ROM (versions 91xxxx) BASIC 10 C65 start-up screen
C64 Built into either ROM BASIC 2 C64 start-up screen

The usual configuration is the MEGA65 ROM, which starts in MEGA65 mode, and that is the mode this book is written for. C65 mode is mainly of historical interest; almost everything BASIC 10 can do, BASIC 65 does better.

Switching modes

To How
C64 mode Type GO64 and answer the confirmation; or hold MEGA while switching on or pressing reset
MEGA65 mode from C64 mode Type SYS 58552, which does not ask for confirmation; or press reset; or hold RESTORE briefly and press F5 in the Freezer
The machine-language monitor Type MONITOR in BASIC 65; or hold RUN/STOP while pressing reset

Any program in memory is lost when switching between MEGA65 and C64 modes, as on a C128 (MEGA65 Book, pp. 11-3, 11-4). Plugging a C64 cartridge into the expansion port before switching on also starts the machine in C64 mode (MEGA65 Book, p. 3-13).

How compatible is C64 mode?

C64 mode, often called GO64 mode, is a temporary reconfiguration of the MEGA65, not a separate computer. It inherits the C65's design, including its different CPU, and some C64 software does not run in it. All the MEGA65's own features remain present, including the Freezer, which can mount disk images. For the highest compatibility there is a separate option: the "C64 for MEGA65" FPGA core, which replaces the whole MEGA65 design with an accurate re-creation of the C64's chips (MEGA65 Book, pp. 3-13, 3-14). It is a different machine altogether, so nothing in this book applies to it.

For programmers, the important point is the reverse: the MEGA65's features are not locked to MEGA65 mode. A program running in C64 mode can unlock the VIC-IV, use DMA or switch the CPU to full speed, using the techniques in Chapters 5 and 8.

The Hardware at a Glance

Component MEGA65 Covered in
Processor 45GS02, at 1, 2, 3.5 or 40.5 MHz Chapters 5, 7, 10
Chip RAM 384KB, visible to the video chip Chapter 5
Attic RAM 8MB or more of external RAM Chapters 5, 8
Colour RAM 32KB Chapters 5, 12
ROM 128KB image loaded from the SD card Chapter 11
Video VIC-IV; VGA and digital video outputs at 720×480 (60 Hz) or 720×576 (50 Hz) Chapter 12
Sound Four SIDs, four audio DMA channels, stereo mixer; 3.5mm jack with headphone amplifier, and audio over digital video Chapter 13
Storage Internal 3.5" floppy drive; an internal SD card slot and an external microSD card slot; IEC serial bus for Commodore drives Chapters 14, 15
Ports Two controller ports, cartridge expansion port, Ethernet Chapters 16, 17
Clock Real-time clock, readable as DT$ and TI$ Chapter 17

The display requirements, connectors and RTC details come from the Book's set-up chapter (MEGA65 Book, pp. 2-3 to 2-7). The controller ports accept Commodore-compatible joysticks, paddles, the 1351 mouse and Amiga mice, and the IEC port accepts drives such as the 1541, 1571 and 1581, as well as SD2IEC and Pi1541 devices.

Not everything the C64 had is here. There is no cassette port, so Chapter 14, which in West's book covered tape storage, covers the SD card instead. Nor is there a user port or a direct RS-232 interface in the C64 style; Chapter 17 covers the alternatives.

How to Use This Book

The chapters build on each other, but each can be read on its own once the basics are familiar.

Chapter Subject
1 Introduction: this chapter
2 Getting to know the MEGA65: keyboard, screen editor, Freezer and configuration
3 BASIC 65 reference: every keyword, with its format and token
4 Effective programming in BASIC 65
5 MEGA65 architecture: memory, banking, I/O, Hypervisor, DMA
6 Advanced BASIC 65: how BASIC stores programs and data
7 45GS02 machine language
8 Machine-language methods specific to the MEGA65
9 Mixing BASIC with machine language
10 The 45GS02 instruction set reference
11 The ROM: KERNAL jump table, vectors, Hypervisor services
12 Graphics
13 Sound
14 The SD card and mass storage
15 Disk drives
16 The controller ports
17 Major peripherals

Readers new to programming should start with Chapters 2 to 4. Experienced 6502 programmers can go straight to Chapter 5 and use Chapter 3 as a reference. Chapters 5, 10 and 11 are reference material that later chapters rely on.

Conventions

Typing in programs

BASIC listings can be typed in exactly as shown. Programs that load machine language from DATA statements include a checksum, so a mistyped number is reported instead of crashing the machine. Save your work often: DSAVE writes to the current disk or disk image, and the Freezer can save the complete machine state at any moment.

Versions

The MEGA65's ROM, core and Hypervisor are all updated over time, independently of each other. This book describes current releases. Where a feature arrived in a particular version, the text says so, and Chapter 11 shows how a program can check what it is running on. If an example behaves differently on your machine, check for an update before assuming the example is wrong.

The book was checked against ROM 920422 and the MEGA65 core's development source as of September 2026. At the time of writing, the latest stable release is package v0.97, from April 2025, with ROM 920413 and its matching core; ROMs after 920413 are beta releases (MEGA65 ROM change log). A few features described here are newer than the stable release, and the text gives the ROM that added each:

On a stable ROM, leave these out or check the version first, as Chapter 11 describes.