Live data from Hacker News

Tetris-OS: An operating system that only plays Tetris

github.com

71–80 of 126 posts

Re: Tetris-OS: An operating system that only plays Tetris

#71
post #27
post #19

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…

Yes, props to the developer for what they've done, but I am perversely disappointed that this isn't actually a complete OS - process scheduler, file system, TCP/IP stack, multiple user support, all the rest - that only runs Tetris.

The software in your washing machine begs to differ.

Re: Tetris-OS: An operating system that only plays Tetris

#72

“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 peop…

Truly everything old is new again.

Re: Tetris-OS: An operating system that only plays Tetris

#74

“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 peop…

It should be again like this. I only truly understood C after I wrote my own fully functional Operating System (e.g. paging, interrupts, user mode, multitasking and multicore etc.) and got it running on bare metal. Programming other things in C now often feels like when you beat the final level in recent Mario games ("Champions Road") and replay the core game again, it just flows is easy and highly enjoyable.

I'd recommend every serious programmer to write their own OS.

Re: Tetris-OS: An operating system that only plays Tetris

#75

“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 peop…

> 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

Most bootdisk-based games did not have any kind of "customized version of an operating system". They were running on bare metal. For 99% of the games, there was no abstraction/management layer between the application (the game) and the hardware nor any kind of framework that would impose a certain structure on your application. Of course, game code was structured and you could often find subroutines for recurring tasks (clear screen, wait 100ms, read track from floppy,...) but even those were sometimes directly inlined in higher-level code (e.g. game AI) where it gave a performance advantage.

Only complex games had some kind of very thin abstraction/management layer that you could call an OS (often MUCH thinner than embedded micro-OS like RIOT or Contiki). As an example, Carrier Command had a quite general GUI system.

Re: Tetris-OS: An operating system that only plays Tetris

#77
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.

Re: Tetris-OS: An operating system that only plays Tetris

#78

> 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.

I don’t understand your point? Are you trying to argue that OP didn’t work on a hard enough challenge to make you happy?

I'm arguing that OP did not build an OS. They built a program that needs a quite heavyweight runtime and loader in form of a system emulator.

Re: Tetris-OS: An operating system that only plays Tetris

#80

“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 peop…

It should be again like this. I only truly understood C after I wrote my own fully functional Operating System (e.g. paging, interrupts, user mode, multitasking and multicore etc.) and got it running on bare metal. Programming other things in C now often feels like when you beat the final level in recent Mario games ("Champions Road") and replay the core game again, it just flows is easy and highly enjoyable. I'd rec…

I've wanted to do this but had some trouble finding a good reference. Do you have any resources you can share? Thank you! :)
Post reply on HN