The art of writing tiny

© 2002,2003 Peter Karlsson. Published in Swedish in ABC-Bladet 4/2002, the member-only magazine from ABC-Klubben. Translated into English in 2003 for publishing on the web.

In case you thought that this would be an article about handwriting, then you are wrong, this is, after all, a computer club. No, this article is about writing small programs, programs that are so small that you wonder how they really can manage to do anything at all.

Those of you who meticulously read through ABC-Bladet 3/2002, or who read the ABC-KOM conference “Heta WWW kontakter” (sic!) might have noticed a link to a competition called “2002 Minigame Compo”.

The competition

Entries per platform
Commodore 6421
Sinclair Spectrum10
Commodore VIC 206
Commodore Plus/44
Commodore Basic3
Gameboy Color3
Amstrad CPC3
Sinclair ZX812
Commodore 1282
Atari Lynx2
Laser2102
NES (Nintendo)2
Oric1
TI99/4A1

The goal of the competition was to write a game for a vintage computer that did not exceed one kilobyte (that is, 1024 byte). Impossible? Not at all. The competition, that took place on the Internet and was arranged by Per Olofsson in Gothenburg, Sweden, attracted 39 authors from all over the world. A total of 62 entries were submitted, for 14 different platforms (se table 1). Everything from platform games and shoot’em ups to strategy games, written either in assembly (machine language) or a high-level language such as BASIC (like my own entries). Some games brought new game ideas, but many were variations of existing themes or even outright copies of other games.

The competition for instance gave the Commodore VIC 20 its first, to my knowledge, version of Tetris. The competition was only open for vintage computers, that is computers from the early 1980s, and systems with similar specifications (such as handheld computer games). Unfortunately there were no entries for any of the ABC computers; perhaps we can see an improvement there next year?

Voting

Voting results (average score):
1. Splatform (Robin Harbron, Commodore 64) 8,25
— bounce around on platforms
2. Astrostorm (Vanja Utne, Commodore 64) 6,96
— fire your way through the asteroid belt
3. Kiloroid (Richard Wilson, Amstrad CPC) 6,89
— a version of Asteroids
4. Csabo’s 1k Tetris (Csabo, Commodore Plus/4) 6,86
— a version of the classic Tetris
5. 1Kanoid (Paolo Ferrarris, Sinclair Spectrum) 6,84
— a Breakout variant

To determine which game was the best there a vote was conducted when all the entries had been submitted, that too entirely over the Internet. Since not everyone has access to all platforms most of the game testing was done in emulators, the vote pack contained information on how to get emulators up and running for the most common platforms, but of course testing on the real machines were recommended, if you had access to one. Every game could be awarded 1–10 points or a blank vote. If the game did not work there was an option to vote that, which was not calculated towards the final score. This was especially important for those that were using emulators, since emulators not always manage to handle all the tricks used in games. And when you only have a kilobyte to use you have to resort to some trickery...

Most people seems to have limited their voting to the most common platforms, but all entries received enough votes to be ranked. The winner was, with a big margin, the game Splatform for the commodore 64 (see table 2), which can be described as a micture of a platform game and a puzzle game.

Its goal is to command a bouncing “head” through nine different levels of platforms. A very addictive albeit simple game, which even managed to squeeze in music in its kilobyte.

How did they do it?

What do you have to do to fit a game in only 1024 byte? The most important thing is probably planning what you want to have, and avoid putting in stuff that is not necessary.

On this kind of systems, with system subroutines in ROM, it is also often a good idea to use these subroutines to save code size. For example most computers have a subroutine to print a number on the screen, something which is not that simple if you want to print a regular decimal number, and if you can use that you save some tens of bytes. Using data that already is available, for example as one of the platform games used the character set of the computer as graphics, will save you even more space for the actual game subroutines.

Various kinds of compression is also common. One can either compress the entire game (which in itself might be larger than a kilobyte) and expand when it is run (the file size was what was counted as size), or you can use more or less intelligent ways of packing data. For instance there different Tetris variants had different ways of storing the game pieces, and one of the games used a BASIC loop to draw graphics from vector data so that there was no need to store the actual bitmap images.

Winner

I personally submitted three simple porgrams, all written in BASIC since my attempt of writing games in machine language failed miserably, and none of them were particularly good. I am happy to have avoided the last place. Since I was the only one to participate with a program for the Commodore 128 I can, however, proclaim myself as winner in that category...

Cryptic code

Since tightly packed BASIC code can be unreadable I have put up a web page where I comment the code, for those of you who are interested. The reason for the code being as cryptic as it is of course comes from the attempts of squeezing it into just one kilobyte.

A similar competition was held in 2001 which had two different categories, 512 byte and two kilobyte (2048 byte). The organizers of that competition did however feel that this was not very good, 512 byte was not enough to write a really good game, whereas two kilobytes was too much and was not fully utilised. If there will be any competition in 2003 is not yet decided, it depends on whether anyone wants to take on the burden of arranging it. Perhaps you wonder what one wins? Honour and admiration, there are no other prizes. That does not, however, stop people from competing.

Peter Karlsson <9944>

Screen shots

[Screenshot from Splatform]
Splatform
[Screenshot from Astrostorm]
Astrostorm
[Screenshot from Kiloroid]
Kiloroid
[Screenshot from 1Kanoid]
1Kanoid
[Screenshot from Csabo’s 1k Tetris]
Csabo’s 1k Tetris

This article in Svenska (swedish).

Return to the article index