VIC-20 Tetris

VIC-20 Tetris

Wrote Tetris in 6502 assembly for the Commodore VIC-20. You can find it here.

Collision detection is a mess, and the sound effects are primitive. Flicker is also a problem. The pros are able to synchronize rendering with the scan line of the CRT, which is far outside my understanding. On the other hand, the executable is 1,867 bytes, so there’s that.

I wrote it on Linux, using CC65 and VICE. I had problems compiling VICE so ended up running it through Flatpak. The Flatpak bundle also comes with the c1541 utility for making disk images. The assembler can generate a label file which makes debugging with the VICE monitor much, much easier.

I would recommend writing games for a 6502-based system to anyone interested in low-level programming. The toolchains and emulators are excellent, and there is a vibrant community of enthusiasts who continue to churn out new software for these machines. There’s lots of examples to work from, and while the 6502 is limited, it’s simplicity makes it easy to learn. In contrast, the x86 instruction set looks like it was designed by a cartoon villain. I can’t imagine very many people understand all its instructions.

It’s also humbling to write a game for the VIC-20. By today’s standards, it is a very simple machine, and nearly simple enough for me to understand in its entirety. I barely understand how a machine with three registers, 56 instructions, and 4k of RAM works, which reinforces my belief we don’t really have any idea what’s going on inside contemporary machines.