Tetris in 446 Bytes

You want to play Tetris. You want to play Tetris on any operating system. You want to play on an old IBM PC, you want to play Tetris on a new MacBook. You want a Tetris that’ll fit inside the master boot record of a disk. You want Tetris as an operating system. You want TetrOS.

Or maybe you don’t, but it’s a fantastic piece of work, and we love tiny demos. Check it out below the break. Or read through the source code in the banner image.

It doesn’t have scores, or fancy graphics, or an intro splash screen. It doesn’t show the next brick. It doesn’t speed up as you keep playing. The fatal flaw is that it doesn’t play the Tetris theme in the background. But it is tiny, and it is playable.

And speaking of Tetris without an OS, if you’ve got a comparatively spacious Arduino, you can get a version with all the frills.

48 thoughts on “Tetris in 446 Bytes

    1. A good read – if you like 6502 code – is Steve Wozniak’s floating point system in 256 bytes for Apple II. Lets see, floating point Tetris in 700 bytes? Just because.

        1. He says he wrote the core routines himself. I recall he sweated out the end to fit in 256 bytes. Like his FDD software, he obsessed over saving a byte. If you started with boards where 1K was a luxury, you understand.

          1. Yes, all became clear when I followed the link to Extra Rheolism – ‘The one line is a byte short of the maximum length when tokenised, and so very hard to type in. Hence, it is distributed in the form of a file which should be *Exec-ed.’ – In other words you can’t just type it in, the normal BASIC editor can’t handle it.

  1. I usually start development on these little bootsector toys by making a .COM file in DOSBox. I usually use FASM inside of DOSBox, but whatever floats your boat. Once you have a .COM file working, adjust the origin and running it as a boot sector is a minor modification.

  2. Quote: “want to play Tetris on any operating system”

    Unless I read wrong QEMU will emulate different hardware but the code still must suit the target system. So in theory this code only runs in the hardware it was targeted for or on the emulator in the emulation mode for that hardware ???

    1. technically your right, but if you know the op-codes for the processor (or microcontroller) then it is pretty much good as the cource-code… it’s not really decompiling when the code was written for the CPU registers themselves; as long as you have access to the datasheet of that specific chip, its just a translation.

      that is the simplistic beauty of assembler, you do not need to understand how things MIGHT have been done, you only need to read table of commands and put them in order in a text file :)
      0xFF=NOP (single-byte)
      0x30=LD (following byte contains 7bitdata and 1bit that determines if 3rd byte follows)
      0x00=END (single-byte)

      1. if it was the binary tetris from a C or BASIC ect compiler then every different version and setting will make huge changes to what actually comes out, even thought the programs do the same thing the binary will be different, often decompliling only does 90-99% of the code and the rest is errors. but when something complex is coded using assembler and MANUALLY optimized BY HAND over and over until its a mere few hundred bytes including graphics(commands), and then decompiled, it will usually be working sourcecode that can be re-compiled without fixing any commands. usually the only ASSEMBLER things not easy to decompile on the first try are things that do not end up in code, like special compliler directives. eg ORG, AVR”fuse-bits”, #library

  3. …I’ve already taken six bytes out of the keyboard routine from a very quick look scrolling through the asm listing. Run it by the old Hugi compo mob on yahoogroups and someone will take this 446 bytes and halve it very easily. There were a number of Tetris’s made for various 256 byte compos over the years as mentioned above.

    1. I’ll take that for true when it runs… some of these super tiny programs start doing things like taking an instruction as as a variable input elsewhere, just ‘coz it happens to be the right number, or one that will work.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s