Tetris In A Single Line Of Code

PC gaming in the modern era has become a GPU measuring contest, but back when computers had far fewer resources, every sprite had to be accounted for. To many, this was peak gaming. So let’s look to the greats of [Martin Hollis, David Moore, and Olly Betts], who had the genius (or insanity) to create Tetris in a single BBC BASIC line.

Created in 1992, one-line Tetris serves as a great use of the limited resources available. The entirety of the game fits within 257 bytes. With the age of BASIC, the original intent of the game for BBC BASIC was to be played on computers similar to Acorn’s BBC microcomputer or Archimedes.

One line Tetris has all the core features of the original game. Moving left, right, and rotating all function like the traditional game, most of the time. Being created in a single line, there were a few corners cut with bug fixing. Bugs such as crashing every 136 years of play due to large numbers or holding all keys causing the tetrominoes to freeze make it an interesting play experience. However, as long as our GPUs are long enough to play, we don’t mind.

If you want to experience the most densely coded gaming experience possible but don’t have one of the BBC BASIC computers of old, make sure to try this emulator with a copy of the game. Considering the amount done in a single line of BBC BASIC, the thought may come into mind on what could be done with MORE than a SINGLE line of code. For those with this thought, check out the capabilities of the coding language with modern hardware.

Thanks to [Keith Olson] for the tip!

18 thoughts on “Tetris In A Single Line Of Code

  1. Well done! 👏🏼
    We liked Zentris in the mid and late 90s; it came on a floppy.

    Really begs the question why a mouse driver/utility is almost a gigabyte and so are motherboard ‘utilities’ just to enable ARGB.

    I can’t recommend Razer peripherals or MSI (The motherboards are fine, I use them, just usually with OpenRGB utility).

    1. Bandwidth costs them less than paying developers to optimize and ensmallen their drivers/utilities.

      I wish they’d stop shipping highly graphical, unintuitive, bad UIs that don’t conform to the style of the OS and often don’t have proper menus or even the “close” button in clear view.

      Why does Norton need a resource intensive, slick but unintuitive, nonstandard UI that bogs down my computer to even open it? (I hate Norton and especially since it merged with Avast, but my office requires it.)

          1. FreeDOS is a lightweight platform, but does it run a modern web browser. It’s almost sad to me, but that’s it; there are a handful of things I do that would be difficult relying on that and Steam alone (like PDF editing, and LaTeX editing and compiling), but 99% of what I and many other people do on a computer is run a web browser, and run Steam and games that come through it. If an OS can’t run a modern web browser, it’s an embedded OS, a toy OS or a server OS, and I’m not sure those you listed are going to run very well in the server competition.

          2. @David There are a few more modern browsers for FreeDOS.
            Arachne was updated a few years ago, there’s a graphical port (Dillo got updated just recently), Lynx/Links, PC GEOS has WebMagick browser, there’s a Japanese browser for IBM DOS..
            In principle, most these browsers can be updated, still, since source code is available.
            MicroWeb 2 was just written 3 years or go, or so..

            Here are some screenshots of DOS browsers, old and new:
            https://tinyurl.com/bdhb4kww

          3. @David “If an OS can’t run a modern web browser, it’s an embedded OS, a toy OS or a server OS, and I’m not sure those you listed are going to run very well in the server competition.”

            That’s a very depressing way of seeing it, I think.
            Because I think that in life there’s more than the internet.
            In the ham shack, for example, even an old C64 can still do a meaningful task. Log book, RTTY, controlling FT-817 etc.

            If you’re living in a browser (-nowadays inflated to size of an entire OS-) why not use a Chromebook?
            Using a real PC solely for surfing the web is a waste.

            Exactly because a PC used to be intelligent and not just a terminal.
            Using it as web browser machine is a step backwards.

            Client/Server concept and cloud computing is so 1960s!
            Back then it was called Terminal/Host and users had to run their software on time-sharing basis on a remote host computer (a mainframe, often).

            That’s exactly what we’re doing now again when we stream games from a server or run web-based software and VMs on the internet! So backwards..
            The PCs and ho,e computers liberated us back in the late 70s, gave every user his/her own computer to work on independently.
            Without the need for networks and relying on serial connections. Anytime. Let’s think about this for a moment.

    1. Any code can be one line with enough semicolons (ok depending on the language, i.e. not python)
      This tetris code is impressive, without the reason having to be “it’s all one line!”
      Trying to stretch “one line” this way (as it’s a very long line…) just cheapens it and makes the feat feel less amazing than it really is.

      1. There is a limit to the line length, which was even used to circumvent it in example in Commodore Basic (with a maximum of 2 usual Screenlimes of 40 characters, so 80) by using shortcuts, which became long again in listing, so it was still possible to have even more than 80 characters as one line of code.

    2. One line of code could have the length of what one byte could hold, so a maximum of characters, maybe in case of BBC-Basic 257 characters, as maybe they handled the length of a line interpreted as how many extra characters to the length of one character minimum size …

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.