Programming the MEGA65 — Chapter 2: Getting to Know the MEGA65

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

Introduction

Before programming any computer, it pays to know its everyday tools well. On the MEGA65 those tools are richer than on a C64: the keyboard has more keys and more combinations, the screen editor has windows, tabs and escape sequences, and two utilities, the Freezer and the configuration utility, sit outside BASIC altogether.

This chapter covers:

Most of what follows applies to MEGA65 mode. Where a key or feature behaves differently in C64 mode, the text says so.

Switching On

The power switch is on the left-hand side of the machine, next to the two controller ports and the reset button. The first time a new MEGA65 is switched on, it shows an "on-boarding" screen for setting the clock, the video mode and the audio; every choice there can be changed later in the configuration utility. After that, a new machine runs the Intro Disk, a menu of community software. Press / to leave it for BASIC, or D to stop it starting automatically (MEGA65 Book, pp. 2-9 to 2-12).

With the Intro Disk out of the way, the MEGA65 starts at the BASIC 65 screen. Besides the familiar READY prompt, it shows:

The flashing square below READY is the cursor. It marks where typed characters appear, and its presence means the computer is waiting for input (MEGA65 Book, pp. 2-13, 3-8).

PAL and NTSC

The MEGA65 can produce either 50 Hz "PAL" or 60 Hz "NTSC" video, even on a modern digital display. The choice matters to programmers as well as to viewers: it sets the frame rate that raster interrupts, music players and the jiffy durations used by SOUND count against, as Chapters 8 and 13 explain. BASIC's TI timer is not affected: it counts microseconds. A program can tell which is in use from bit 7 of $D06F, which is set in NTSC mode.

The Keyboard

The MEGA65 keyboard follows the Commodore layout: letters and numbers where a C64 owner expects them, PETSCII graphic symbols on the key fronts, and a set of special keys. It also adds keys the C64 lacked. The descriptions below follow the Book's keyboard chapter (MEGA65 Book, pp. 3-3 to 3-7).

Special keys

Key What it does
RETURN Enters the line: BASIC acts on it, stores it or reports an error
SHIFT, SHIFT LOCK Upper-case letters, the right-hand graphic symbol on a key, and the even function keys
CAPS LOCK Shift for letter keys only; in C64 mode, holding it runs the CPU at full speed temporarily
CTRL Control functions: colours 1-8, reverse on and off with 9 and 0, and slowing a listing
MEGA Mega functions: colours 9-16, the left-hand graphic symbol on a key, and switching upper and lower case with SHIFT
RUN/STOP Stops a running program; SHIFT+RUN/STOP loads and runs the first program on disk
RESTORE With RUN/STOP, resets the screen and system vectors; held alone for a second, opens the Freezer
ESC Starts an escape sequence, described below
ALT Available to software; held at power-on, opens the utility menu
NO SCROLL Pauses a listing until another key is pressed
HELP Available to software, and acts as F15
F1-F14 Seven function keys, with SHIFT giving the even numbers; only F1-F8 work in C64 mode
INST/DEL Deletes left; with SHIFT, inserts a space
CLR/HOME Moves the cursor home; with SHIFT, clears the screen

NO SCROLL, ALT and F9 to F14 are not available in C64 mode.

Arrow keys and cursor keys

The four cursor keys at the bottom right move the cursor, and repeat when held. SHIFT with the right and down keys moves left and up, as on a C64. The two arrow keys, ← next to 1 and ↑ next to RESTORE, are different: they are PETSCII characters. In BASIC, ↑ is the power operator, and ← is a shortcut for SAVE (MEGA65 Book, p. 3-5).

Combinations worth knowing

Combination Effect
MEGA + SHIFT Switch the whole display between upper and lower case, even while a program runs
CTRL + 1-8, MEGA + 1-8 Change the text colour
CTRL + 9, CTRL + 0 Reverse text on and off
RUN/STOP + RESTORE Reset the screen editor and vectors without clearing memory
MEGA + TAB Open or close Matrix Mode, the built-in debugging console
Hold RESTORE for a second Open the Freezer
Hold RUN/STOP, press reset Start in the machine-language monitor
Hold MEGA, press reset or switch on Start in C64 mode
Hold ALT, switch on Open the utility menu

Some programs take over RUN/STOP and RESTORE, so these combinations do not always work. The Freezer is started by the Hypervisor, which keeps it reachable even then (MEGA65 Book, Hypervisor services appendix, freeze services). The complete list of control and MEGA codes is in the Book (MEGA65 Book, p. E-3).

The Screen Editor

The screen editor is the part of the ROM that handles typing. Like the C64's, it is a full-screen editor: move the cursor anywhere on the screen, change what is there, and press RETURN to enter that line. That makes editing a BASIC line as simple as listing it, changing it in place and pressing RETURN.

Quote mode and insert mode

Two modes surprise newcomers. After typing a quotation mark, the editor is in quote mode: cursor movements, colour changes and screen clears are recorded inside the string as PETSCII control characters instead of happening at once, so a program can PRINT them later. Insert mode works the same way for as many characters as spaces were inserted with SHIFT+INST/DEL. Typing the closing quotation mark ends quote mode, and ESC followed by O cancels either mode (MEGA65 Book, p. 3-9).

Escape sequences

An escape sequence is ESC pressed and released, then another key. They can also be printed from a program with PRINT CHR$(27);"X", which makes them useful for setting up a screen. The most useful are listed below; the Book has the full table (MEGA65 Book, pp. E-6 to E-10).

Keys Effect
ESC X Clear the screen and toggle between 40 × 25 and 80 × 25
ESC 4, ESC 8 Clear and switch to 40 × 25 or 80 × 25
ESC 5 Switch to 80 × 50
ESC @ Clear from the cursor to the end of the screen
ESC O Cancel quote, reverse, underline and flash modes
ESC I, ESC D Insert or delete a line
ESC P, ESC Q Erase to the start or end of the line
ESC J, ESC K Move to the start of the line, or after its last character
ESC V, ESC W Scroll the screen up or down one line
ESC L, ESC M Enable or disable scrolling at the bottom of the screen
ESC A, ESC C Turn auto-insert mode on or off
ESC E, ESC F Steady or flashing cursor
ESC T, ESC B Set the top-left or bottom-right corner of a window
ESC U, ESC S Use colours 0-15 or the alternate colours 16-31
ESC Y Restore the default tab stops

Some programs expect to start in 80 × 25 mode and may not work correctly in 80 × 50.

Windows and tabs

The editor can confine all output to a rectangular window. Put the cursor at the top-left corner and press ESC T, then at the bottom-right corner and press ESC B. Everything typed or printed, including LIST output, now stays inside, and pressing CLR/HOME twice returns to the full screen. Windows are useful from programs too: a program can print a status line, then confine its scrolling output below it.

Tab stops sit every eight columns by default. CTRL+X sets an extra stop at the cursor, CTRL+I moves to the next stop, and CTRL+W jumps to the next word (MEGA65 Book, pp. 3-10, 3-11).

Extra characters

The keyboard carries a few ASCII characters that PETSCII lacks, such as the backslash, curly brackets and underscore. The command FONT A or FONT B replaces some PETSCII characters with them in lower-case mode, where they are typed with MEGA and the key; FONT C restores the standard set (MEGA65 Book, pp. 3-11, 3-12).

The Freezer

The Freezer is a menu that can interrupt anything the MEGA65 is doing. Hold RESTORE for about a second and release it: the border flickers, the running program stops where it is, and the Freezer menu appears (MEGA65 Book, p. 3-12). The Hypervisor, not the KERNAL, starts the Freezer, which is why it works even when a program has disabled interrupts or switched the ROM out (MEGA65 Book, Hypervisor services appendix, freeze services).

Key in the Freezer Effect
F3 Resume the frozen program, or restore the selected freeze slot
F5 Abandon the program and reset
F7 Save the current state to the selected freeze slot
J Swap the joystick port numbers
A Open the audio mixer

The Freezer also mounts disks and disk images, shows version information through the MEGAINFO utility, and can change the CPU speed (F) and video mode (V) for the frozen program (Freezer source, freezer.c).

Freeze slots

The Freezer can store several complete machine states in freeze slots. Move to an unused slot with the cursor-right key and press F7; when the border stops blinking, the state is saved. Selecting a slot and pressing F3 later restores it exactly (MEGA65 Book, p. 3-13).

For programmers this is a powerful debugging aid. Freeze a program just before the part that crashes, save it to a slot, and every attempt to reproduce the bug can start from the same state, with no need to reload the program or play a game back to the same point.

Joystick swap

Many C64 games expect a joystick in port 2, some in port 1. Rather than unplugging the joystick, open the Freezer, press J to swap the ports, and resume.

The Configuration Utility

The configuration utility holds the settings the MEGA65 keeps between sessions. To reach it, switch the MEGA65 off, hold ALT and switch it on again; the utility menu appears, and 1 starts the configuration utility. The left and right cursor keys move between pages, up and down select a setting, and RETURN or SPACE changes it. A mouse in port 1 also works (MEGA65 Book, p. 4-3).

Page Settings
Input Mouse type for each controller port, 1351 de-jitter
Chipset Real-time clock, DMAgic revision, boot disk source and default disk image, long file names
Video PAL or NTSC, audio over digital video, CRT emulation
Audio Stereo or mono, SID generation (6581 or 8580), swap stereo channels, headphone amplifier
Network Ethernet MAC address
Done Save as defaults, abandon changes, or restore factory settings

The clock is set as soon as RETURN is pressed; everything else is saved only from the Done page, and the MEGA65 must then be switched off and on again (MEGA65 Book, pp. 4-4 to 4-8).

Settings that affect programs

Several of these settings change how a program behaves, so a program that depends on them should check or set them itself rather than assume the user's choice:

The settings are stored on the SD card, not in the machine. Replacing the SD card means setting them again.

SD Cards, Disks and Disk Images

Chapters 14 and 15 cover storage in depth. This section gives just enough to load and save programs.

SD cards

The MEGA65 has two SD card slots: a full-size slot inside the case, reached from underneath, and a microSD slot at the rear. Only one is used at a time: a card in the rear slot takes over, and the internal card is ignored. The SD card holds the ROM, the configuration, system files and the user's software, normally as D81 disk images. New cards should be SDHC, between 4GB and 32GB (MEGA65 Book, pp. 2-3, 4-9).

Disk images and drives

Much MEGA65 software comes as D81 files: images of 3.5" Commodore 1581 disks, stored on the SD card. Mounting an image makes it behave exactly like a real disk in drive 8. Images are mounted from the Freezer, or from BASIC with the MOUNT command. The MEGA65 also has a real 3.5" floppy drive, and the IEC serial port accepts Commodore 1541, 1571 and 1581 drives and modern equivalents such as SD2IEC.

The commands you need first

Command Effect
DIR List the files on the current disk
DLOAD "NAME" Load a BASIC program
RUN "NAME" Load and run a program in one step
DSAVE "NAME" Save the program in memory
DSAVE "@NAME" Save, replacing an existing file of that name
SHIFT + RUN/STOP Load and run the first program on the disk

The D in DLOAD and DSAVE stands for disk. In BASIC 65, LOAD and SAVE also use drive 8 by default, but DLOAD and DSAVE accept drive and unit options and are the commands the Book recommends. Chapter 3 describes every disk command.

Summary

Chapter 3 is the complete reference to BASIC 65.