Dirty tricks 6502 programmers use
Published on: 2025-04-25 17:58:36
Dirty tricks 6502 programmers use
Janne Hellsten on August 18, 2019
This post recaps some of the C64 coding tricks used in my little Commodore 64 coding competition. The competition rules were simple: make a C64 executable (PRG) that draws two lines to form the below image. The objective was to do this in as few bytes as possible.
Entries were posted as Twitter replies and DMs, containing only the PRG byte-length and an MD5 hash of the PRG file.
Here’s a list of participants with source code links to their submissions:
(If I missed someone, please let me know and I’ll update the post.)
The rest of this post focuses on some of the assembly coding tricks used in the compo submissions.
Basics
The C64 default graphics mode is the 40x25 charset mode. The framebuffer is split into two arrays in RAM:
$0400 (Screen RAM, 40x25 bytes)
(Screen RAM, 40x25 bytes) $d800 (Color RAM, 40x25 bytes)
To set a character, you store a byte into screen RAM at $0400 (e.g., $0400+y*40+x ). Color RAM
... Read full article.