Tetris-OS: An operating system that only plays Tetris

cconger | 314 points

This is cool, but I think it's misleading to call it an operating system. It's Tetris that runs without an operating system, which is to say, on bare metal, old school. Writing programs that run on bare metal is a cool and worthwhile thing to do, but calling any such program an "operating system" is confusing.

This probably sounds like I'm picking a nit, but I think it matters for the sake of newbies just starting to climb the learning curve and trying to understand what an "operating system" actually is. IMHO, the defining characteristic of an operating system is that it provides an environment in which to run other programs, ones that are not part of the operating system, and which may not even exist at the time that the operating system starts to run.

lisper | 3 years ago

I made one too, 20 years ago! http://pliki.danieljanus.pl/btetris.bin

(Use qemu-system-i386 -fda btetris.bin if you want to try it out.)

Not really an OS, I just squeezed an implementation of Tetris into a 512-byte boot sector. I remember that a first draft had ~600 bytes and I was cutting away bytes, here replacing mov ax,0 with xor ax,ax, there reusing code as data, until I arrived at that size.

I've lost the source code, but ndisasm should help out.

I remember I encoded tetromino shapes as a 4x4 1bpp bitmaps taking up 2 bytes each, and there's a 56 41 59 41 52 01 56 01 15 48 52 41 59 in the hexdump, which in ASCII reads VAYAR^AV^A^UHRAY. I've been meaning to write a short story featuring a Vayar V. Hray as a protagonist, but never got around to it.

nathell | 3 years ago

“In the 1980s with things like the Amiga computer, for example, every game was a boot disk. It booted into its own customized version of an operating system that ran what it needed to run to make its game work well and be performant and reliable. … We know that in the past, hardware that was very capable and very interesting made it so easy to create an operating system that literally everybody did it. Not a few people. Not even most people. But literally everybody.”

– Casey Muratori in “The Thirty Million Line Problem” https://youtu.be/kZRE7HIO3vk?t=1205

modernerd | 3 years ago

Youtube video that goes over the developer's experience making it: https://www.youtube.com/watch?v=FaILnmUYS_U

cconger | 3 years ago
readflaggedcomm | 3 years ago

There is a similar project for Space Invaders here: http://www.erikyyy.de/invaders/

procrastitron | 3 years ago

> Soundblaster 16 driver

This brings back memories for those wretched days when you needed floppy drivers for the most casual of peripherals. Life was simpler back then (and also much more complex)

charles_f | 3 years ago

If Tetris (with an infinite board) is Turing complete, then how about building an OS from Tetris?

(It seems for certain problems it is NP-complete!) https://liacs.leidenuniv.nl/~kosterswa/tetris/tot.pdf

dudeinjapan | 3 years ago

"Windows - Absolutely no idea."

QEMU works on WSL and WSL2 now, that would be one way.

tyingq | 3 years ago

I was half-expecting an OS where you delete a file by completing lines with the right Tetris pieces.

rejschaap | 3 years ago

Damn that’s probably some good Tetris performance with it being so close to bare metal.

Edit: having read the readme, it looks like performance is locked at 60fps.

nikodunk | 3 years ago

Reminds me of this https://www.nand2tetris.org/

mrmckizzle | 3 years ago

How do we delineate "OS that does one thing" from "bare metal program?"

loser777 | 3 years ago

TetrOS would be a better name.

Koshkin | 3 years ago

Would be interesting to make a bootloader and “OS” that you could wrap any game with, including GPU driven games like Crysis. I wonder how much more performance we could eek out of our hardware by removing extra overhead.

luxuryballs | 3 years ago

You don´t need Qemu, DOSBox will run it if you set 100h as the loading address.

anthk | 3 years ago

> This has only been tested in an emulator. Real hardware might not like it.

?! So this is just a stand-alone binary with an awkward loader then.

The real trick (and challenge) comes when you want to run your stuff on actual bare metal.

ganafagol | 3 years ago

Like the last bit. As many have observed a good movie is more about the sound than the sight.

But has it actually run on bare metal or just qemu I wonder. Anyway good music.

ngcc_hk | 3 years ago

I am confused. Normally it's distributions that have an OS suffix. This is actually an Operating System. How rebellious.

raggi | 3 years ago

if you built an operating system that only does X it’s called an embedded system or you know, a video game

netik | 3 years ago

Vertically Integrated Tetris!

jarym | 3 years ago
[deleted]
| 3 years ago

I’d love to see a Super Mario Brothers version of this concept.

shockeychap | 3 years ago

so this is just a bootable thing that runs Tetris? Does it do anything to run/control the hardware?

ChrisArchitect | 3 years ago

>Features:

> - It's Tetris.

Not sure what I was expecting.

frodetb | 3 years ago

I wonder why the choice of SB16

AndrewKemendo | 3 years ago

lol, this is awesome!

martin1975 | 3 years ago

Well, at least until someone ports DOOM to it.

cwyers | 3 years ago

oh, so like emacs then?

tonfreed | 3 years ago

Do you know that effect? Once you touch a topic, it appears to show up everywhere! :-) I recently wrote a tetris clone for braille users. https://news.ycombinator.com/item?id=26790812

mlang23 | 3 years ago

Tetrinet next?

Black101 | 3 years ago