Screenful of BASIC 2025 compo
Dan’s MEGA65 Digest for February 2025. A new BASIC code competition for the MEGA65 10th anniversary!

On April 22, 2015, the Museum of Electronic Games & Art and Paul Gardner-Stephen announced the MEGA65 project to the world. Paul also announced the project on his development blog, where he had been documenting his work on a “C65GS” FPGA bitstream, on which the MEGA65 would be based. The MEGA65 has been a thing for ten years!
To help celebrate the ten-year anniversary of the MEGA65, ZeHa of Dr. Wuro Industries is throwing a short-form BASIC competition—and you’re invited! We want as many entries as possible, so power up your MEGA65 and crack open your User’s Guide. No experience necessary!
I’ll keep this Digest brief so you have extra time to start playing with code. We’ll go over how to enter the compo, check out some recent Featured Files, and take a brief look at a fun and obscure feature of the VIC-IV video chip: high resolution text fonts.
The Screenful of BASIC 2025 compo
It’s time for a good ol’ fashioned short-form BASIC competition!
The twist: Your program must be written in BASIC 65, and the program listing must fit entirely in one screen of 80 x 25 text, including space for the READY.
prompt at the bottom of the screen. Someone should be able to type your program in from a single screenshot, and type LIST
to see the entire program on screen. No data files allowed, one screen of code is all you get!
The deadline: Entries must be submitted by 11:59 pm GMT, April 22, 2025.
How to submit: Go to the itch.io page for the compo, create an itch.io account, and follow the instructions. Upload a D81 disk image containing a single PRG file of your program.
Pick your favorites: Public voting will open from April 23 to April 30. All entries will be available for download from itch.io. Results will be announced on May 1st.
Your program can do anything you’d like, and use any feature of the MEGA65. Just don’t destroy someone’s files or commit any crimes. Submissions should be family friendly in content. Multiple submissions are allowed, if you’re feeling productive.
Most MEGA65 users are running the latest stable release package v0.96, including ROM 920395. If your program requires a more recent ROM beta version, be sure to say so in the description of your entry. (We’re close to releasing v0.97 with all of the changes, but it won’t go out before the compo deadline.)
By submitting an entry to the competition, you assert that you have copyrights to the code, and you are assigning the Museum of Electronic Games & Art (MEGA) a non-exclusive right to distribute your program globally. Your entry will be hosted on itch.io, and may also be included in a compilation disk distributed on Filehost or bundled with the MEAG65 on the SD card as part of the “Intro Disk” anthology.
For complete rules and submission instructions, visit the Screenful of BASIC 2025 compo home page on itch.io. Many thanks to ZeHa for hosting this event!
BASIC compo tips

For BASIC To One-Liners, by Holger Weßling.
Clever coders have devised many ways to cram a lot of BASIC into a little space, just as a personal challenge or for a short-form coding competition like Screenful. Figuring out what works and what doesn’t is part of the fun. If you’d like a bit of inspiration, there’s a book I can recommend. For Basic to One-Liners by Holger Weßling is packed with time-tested tips and tricks that apply to many dialects of microcomputer BASIC, with a focus on the Commodore 64 and short-form BASIC competitions. ZeHa himself is mentioned in the book!
We’ve covered BASIC programming topics in past issues of this Digest. In particular, check out October 2023: Robot Finds Kitten, part 1 and July 2024: Let’s Paint for some ideas.
For the purposes of short-form compos, the biggest difference between BASIC 65 and other Commodore BASICs is the breadth of graphics, sound, and music commands available. The language is mostly the same. I’d watch out for an unusual fact about BEGIN
-BEND
blocks from BASIC 7, where everything after the BEND
on the same line is considered part of the block. If you discover any more language oddities, please mention them in the Discord or on Forum64.de.
Featured Files

“Hunt the Wumpus on the Mega65!” from the YouTube channel Coding with Culp.
Hunt the Wumpus by Dave Culp revives the classic computer game in BASIC 65. Traverse the dungeon, watch for clues, and take the Wumpus by surprise—before it surprises you. Don’t miss Dave’s video about his game on his YouTube channel, Coding with Culp.
It seems like muse has a new arcade core for us every month! I won’t hold him to that schedule, but I will very much enjoy Bank Panic (1984) from Sega. This western-themed reflex action game features colorful cartoon graphics and a unique user interface. This bank has so many doors! R6 owners will prefer the VGA video output. We’re waiting on a video fix for R6 boards in the MiSTer2MEGA framework that affects HDMI output of some arcade cores. I needed to use the horizontal position adjustment feature in the menu system, but then it looked great over VGA on my screen. As usual, see the Github repo for installation instructions.
WarGames simulator, originally by Andy Glenn, ported to BASIC 65 by Mr. Jones. Recreate scenes from the classic movie WarGames (1983) and avert Global Thermonuclear War. The game features a narrative hint mode if you don’t remember the movie.
BasicTracker by ZeHa is a simple, intuitive music composition program with a tracker-like interface. Compose for six simultaneous voices, each with six possible instruments. Enter two octaves worth of notes using letters and numbers, move the cursor with the cursor keys, and follow on-screen instructions for the rest. There’s no way to save or export song data, this is just for fun.
Tall Character Mode

When you first turn on the computer, it starts up with a text screen 80 character wide and 25 characters tall, where each character is 8 pixels wide and 8 pixels tall, for a resolution of 640 x 200. There are two other text mode resolutions you can access directly from this screen: press Esc then 4 to enter 40 x 25 text mode, Esc then 5 to enter 80 x 50 text mode, and Esc then 8 to return to 80 x 25 text mode. All of these modes use 8 x 8 characters.
The MEGA65 has another way to draw text—and it’s practically a secret. Tall Character mode (TCR mode) doubles the vertical pixel resolution without changing the dimensions of the screen. Each character becomes 8 pixels wide and 16 pixels tall, making the text sharper and easier to read. TCR mode needs a 8x16 font to do this, and the MEGA65 does not have any TCR fonts built in. But there’s an easy way to load such fonts yourself.
Xemu users, note that TCR support was very recently added to the next
branch (as of version 20250216001821), so download the latest if you want to try this in the emulator.
Loading TCR font files with the Freezer
M3wP has been experimenting with this feature recently, and produced TCR conversions of several modern fixed width fonts. Download M3wP’s conversions of the fonts Courier, Xirod, Hack, and Noto.
These fonts are distributed in the .TCR
file format, a binary format that matches how this data appears in the MEGA65’s memory. To load a .TCR
file into the MEGA65:
- Copy the
.TCR
file to your SD card. - Open the Freezer.
- Press the L key. Select the
.TCR
file. - Press F3 to resume, and enjoy!
These are lowercase ASCII character sets only, and naturally are missing PETSCII graphics symbols. They contain ASCII symbols such as underscore (_
) and tilde (~
).
The Oldschool PC Font Resource

Inspired by M3wP’s example, I spent an afternoon playing with The Oldschool PC Font Resource, a large collection of high fidelity reproductions of system fonts for IBM PCs, PC compatibles, and various BIOSes and devices. I wrote a script to convert the 8x16 bitmap fonts to TCR files, and put together a font browser in BASIC:
Mount this disk image, then RUN "*"
to play with the font browser.
A PC font normally has 256 unique characters in it, with the usual cast of ASCII characters in the first half and some familiar PC graphics characters and symbols in the second half. I attempted to relocate the ASCII-style characters to the corresponding screen codes used for PETSCII, such that ASCII text could be displayed without changes. I put some of the PC symbol characters (like the smiley faces) at useful but arbitrary locations.
There are two TCR files for each font: a 128-character version and a 256-character (“all characters”) version. The 128-character version uses the first 128 characters of the PC font, then repeats them in “reverse” video for the second 128 characters, such that the screen terminal cursor blinks correctly. When the screen terminal’s cursor is over a letter, it blinks between the letter and its reverse, so both need to be present in the character set.

The 256-character version of the TCR font uses all 256 characters of the PC font, with no reverses. This makes more symbols available, at the expense of not working correctly with the screen terminal. If you’re writing your own program, you could implement a new cursor using the reverse character attribute instead of dedicated reverse characters. (We tried upgrading the screen terminal to do this, but ran into issues with how the VIC-III defines character attributes. That’s a story for another day.)

See the mega65-pcfonts Github repo for documentation, loose TCR files, and the scripts I used to put it all together. Or just enjoy the demo disk.
Using a TCR font from a program
To use a TCR font in your own program (or AUTOBOOT.C65
startup sequence), the TCR file must be on a D81 disk image. You can use the usual PC tools to make such an image, or you can do it on the MEGA65 with the BSAVE
command, like so:
- Use the Freezer to load the TCR file into the character generator buffer, as above.
- Mount your D81 disk image.
- At the
READY
prompt,BSAVE
the character generator buffer:BSAVE "MYFONT.TCR",P($FF7E000) TO P($FF7EFFF)
The PCFONTS.D81
disk has the TCR files on the disk, so you can copy those with the COPY
command. Note that the PC fonts are released under a Creative Commons license with attribution and “share-alike” provisions. See the licensing terms in the README.md file.
In your program, load the font file into memory, and activate the TCR mode:
- Load the TCR file from disk into the character generator buffer, starting at address $FF7E000.
- Optionally, disable CRT emulation. (TCR mode works with this enabled, but doesn’t look as nice.) Clear the PALEMU register, $D054, bit 5.
- Enable TCR mode. Set the CHARY16 register, $D07A, bit 4.
In BASIC:
10 BLOAD "MYFONT.TCR",P($FF7E000)
20 CLRBIT $D054,5
30 SETBIT $D07A,4
To return to 8x8 PETSCII:
- Disable TCR mode. Clear the CHARY16 register.
- Restore the PETSCII character set. A BASIC program can use the
FONT
command to do this.
980 CLRBIT $D07A,4
990 FONT C
1000 END
How TCR fonts work
In the VIC-IV TCR mode, character set data is read directly from the character generator memory at $FF7E000-$FF7EFFF (4 KB). The screen terminal does not switch between “uppercase + graphics” and “lowercase + uppercase” text modes. There is only one text mode. Whereas a PETSCII character set has a set of 256 characters for each text mode, TCR mode uses the same amount of memory for a single mode, with twice as many pixels per character.
TCR character set data is interpreted as a single set of 256 characters of 8 x 16 resolution, using interleaving lines from charset positions n and n+256. For example, screen code 1 is normally a lowercase “a” character. Its image is made of alternating lines of the data at positions 1 and 257 in the character set, like so:
Byte Charset address
---------------------------
........ FF7E008
........ FF7E808
........ FF7E009
........ FF7E809
........ FF7E00A
..xxxx.. FF7E80A
.....xx. FF7E00B
.....xx. FF7E80B
..xxxxx. FF7E00C
.xx..xx. FF7E80C
.xx..xx. FF7E00D
..xxxxxx FF7E80D
........ FF7E00E
........ FF7E80E
........ FF7E00F
........ FF7E80F
In memory, the lines look like this:
........ FF7E008
........ FF7E009
........ FF7E00A
.....xx. FF7E00B
..xxxxx. FF7E00C
.xx..xx. FF7E00D
........ FF7E00E
........ FF7E00F
........ FF7E808
........ FF7E809
..xxxx.. FF7E80A
.....xx. FF7E80B
.xx..xx. FF7E80C
..xxxxxx FF7E80D
........ FF7E80E
........ FF7E80F
There’s a fun way to get an intuition for how this works. The original 8x8 PETSCII font keeps uppercase letters in the first half and lowercase letters in the second half. Without loading a TCR font, enable TCR mode by setting the CHARY16 register: SETBIT $D07A,4
The VIC-IV interleaves the uppercase and lowercase PETSCII characters at double the vertical resolution.

Character graphics are a big subject on the MEGA65, and I’m planning a series of Digest feature articles for later this year to cover as much of it as I can.
If you like this kind of thing, please consider supporting the Digest. Your patronage makes this Digest possible—and makes it free for everyone. Visit: https://ko-fi.com/dddaaannn
Now get cracking on that screenful!
— Dan