A handheld computer made on a piece of prototyping board running a Tetris clone

Tetris Clone Uses 1000 Lines Of Code, And Nothing Else

If you’re programming on a modern computer, you typically make use of lots of work done by other people. There’s operating systems to abstract away the complexities of modern hardware, standard libraries to implement common tasks, and tons of third-party libraries that prevent you from having to reinvent the wheel all the time: you’re definitely not the first one trying to draw graphics onto a screen or store data in a file.

But if it’s the wheels you’re most interested in, then there’s nothing wrong with inventing new ones now and then. [Michal Zalewski], for instance, has made a beautiful Tetris clone in just 1000 lines of C, without using anyone else’s code.

The purpose of this exercise is to show that it’s possible to make a game with graphics comparable to modern, complex computing systems, without relying on operating systems or third-party libraries. The hardware consists of not much more than an ARM Cortex-M7 MCU, a 240×320 LCD screen and a few buttons soldered onto a piece of prototyping board, all powered by a set of AAA batteries.

The software is similarly spartan: just pure C code running directly on the CPU core. Graphic elements, some generated by AI and others hand-drawn, are stored in memory as plain bitmaps. They are manipulated by 150 lines of code that shuffles sprites around the display at a speed high enough to generate smooth motion. Game mechanics take up about 250 lines, while sound consists of simple square-wave chiptunes written in just 50 lines of code.

[Michal]’s code is very well documented, and his blog post gives even more details about all the problems he had to solve. One example is the length of keypresses: when do you interpret a keypress as a single “press”, and when does it become “press and hold”? Apparently, waiting 250 ms after the first press and 100 ms after subsequent ones does the trick. [Michal] is a bit of an expert on bare-bones game programming by now: he has previously pushed several 8-bit micros to their very limits. Third-party libraries can make your programming life a lot easier, but it’s good to reflect on the dangers of relying too much on other people’s code.

Continue reading Tetris Clone Uses 1000 Lines Of Code, And Nothing Else”

Install ChimeraOS And Never Leave The Sofa

There are some projects that initially don’t seem to make sense, but actually turn out to have valid use cases. ChimeraOS appears to be one of those. The idea is that if you own a gaming PC, but it is not necessarily located where you want to be all the time (like in a gaming den or office for example) then ChimeraOS allows you to play games on it remotely via a local machine. That machine may be a media PC attached to your main TV, or perhaps a mobile device like a steam deck.

With support for AMD GPUs only, there is one issue with deployment — if you’re an Nvidia owner you’re out of luck — the premise is to be able to boot up into a gaming-friendly environment with minimal fuss. Hook up a controller and you’re good to go. Support is also there for a few mobile devices, specifically some Aokzoe, Aya Neo, and OneXPlayer devices as well as some preliminary support for the Asus ROG Ally not to mention the Steam Deck as we touched on earlier. From a software perspective, it obviously supports the Steam platform but also Epic Games, Good Old Games (GOG), and tentatively a mention of console platforms. Sadly the website doesn’t mention much detail on that last bit, but there are some tantalizing hints in the project’s Twitter/X/whatever feed. Reading the release notes, there are mentions of PCSX2 (Playstation 2) Super Game Boy and Atari platforms, so digging into the GitHub repo might be instructive, or you know, actually installing it and trying. This scribe doesn’t own an AMD GPU so that isn’t an option, but do drop us a line in the comments if you’ve tried it and how it works for you.

Many of us at Hackday are avid gamers, especially of the retro kind, which is why we really like these projects. Here’s a nice game controller you can print yourself. For self-builds, there’s nothing quite like the satisfaction of a DIY arcade machine, but what if you think outside the box?

Classic Gaming With FPGA And ATX

Playing classic games, whether they are games from the golden age of arcades or simply games from consoles that are long out of production, tends to exist on a spectrum. At one end is grabbing a game’s ROM file, finding an emulator, and kludging together some controls on a keyboard and mouse with your average PC. At the other is meticulously restoring classic hardware for the “true” feel of what the game would have felt like when it was new. Towards the latter end is emulating the hardware with an FPGA which the open-source MiSTer project attempts to do. This build, though, adds ATX capabilities for the retrocomputing platform. Continue reading “Classic Gaming With FPGA And ATX”

Audio Playback Toy For DSP Adventures

The declining costs of single-board computers has made serious computing power available for even the most trivial of tasks. It’s easy enough to slap a Raspberry Pi onto almost anything for nearly the same cost as a powerful 32-bit microcontroller platform, but this takes some of the fun out of projects for a few of us. Looking to get into the weeds can be a challenge as well, as [Michal Zalewski] demonstrates in this audio playback device he built from a simple 8-bit microcontroller.

The small toy takes audio input from a microphone through an op-amp and feeds this signal to an ADC within the AVR128DA28 microcontroller. The data is then stored on a separate memory chip ready to be played back through another op-amp paired with a speaker. This is where being familiar with the inner workings of the microcontroller comes in handy. By manipulating the interrupt routines in specific ways, the audio stored in memory can be played back at various speeds.

[Michal] intended this build to be a toy for one of his younger relatives, and for the price of a few ICs and buttons it does a pretty good job of turning a regular voice into a chipmunk voice like some commercial children’s toys some of us might remember. If the design aesthetics of this gadget look familiar, you may be thinking of his minimalist gaming device which we recently featured.

Hackaday Podcast 203: Flashlight Fuel Fails, Weird DMA Machines, And A 3D Printed Prosthetic Hand Flex

This week, Editor-in-Chief Elliot Williams and Managing Editor Tom Nardi meet up virtually to talk about all the hacks that are fit to print. This week’s episode starts off with a discussion about the recently unveiled 2023 Hackaday.io Low-Power Challenge, and how hackers more often than not thrive when forced to work within these sort of narrow parameters. Discussion then continues to adding a virtual core to the RP2040, crowd-sourced device reliability information, and mechanical Soviet space computers. We’ll wrap things up by wondering what could have been had Mattel’s ill-fated ThingMaker 3D printer actually hit the market, and then engage in some wild speculation about the issues plaguing NASA’s latest Moon mission.

Check out the links below if you want to follow along, and as always, tell us what you think about this episode in the comments!

Available in the cloud, or as download!

Continue reading “Hackaday Podcast 203: Flashlight Fuel Fails, Weird DMA Machines, And A 3D Printed Prosthetic Hand Flex”

The Meraki AP PCB on a desk, case-less, with three USB-UARTs connected to its pins - one for interacting with the device, and two for monitoring both of the UART data lines.

Flashing Booby-Trapped Cisco AP With OpenWrt, The Hard Way

Certain manufacturers seriously dislike open-source firmware for their devices, and this particular hack deals with quite extreme anti-hobbyist measures. The Meraki MR33, made by Cisco, is a nice access point hardware-wise, and running OpenWrt on it is wonderful – if not for the Cisco’s malicious decision to permanently brick the CPU as soon as you enter Uboot through the serial port. This AP seems to be part of a “hardware as a service” offering, and the booby-trapped Uboot was rolled out by an OTA update some time after the OpenWrt port got published.

There’s an older Uboot version available out there, but you can’t quite roll back to it and up to a certain point, there was only a JTAG downgrade path noted on the wiki – with its full description consisting of a “FIXME: describe the process” tag. Our hacker, an anonymous user from the [SagaciousSuricata] blog, decided to go a different way — lifting, dumping and modifying the onboard flash in order to downgrade the bootloader, and guides us through the entire process. There’s quite a few notable things about this hack, like use of Nix package manager to get Python 2.7 on an OS which long abandoned it, and a tip about a workable lightweight TFTP server for such work, but the flash chip part caught our eye.

The flash chip is in TSOP48 package and uses a parallel interface, and an iMX6.LL devboard was used to read, modify and flash back the image — hotswapping the chip, much like we used to do with old parallel-interface BIOS chips. We especially liked the use of FFC cables and connectors for connecting the flash chip to the devboard in a way that allows hotswapping – now that we can see it, the TSOP 0.5 mm pitch and 0.5 mm FFC hardware are a match made in heaven. This hack, of course, will fit many TSOP48-equipped devices, and it’s nice to have a toolkit for it in case you don’t have a programmer handy.

In the end, the AP got a new lease of life, now governed by its owner as opposed to Cisco’s whims. This is a handy tutorial for anyone facing a parallel-flash-equipped device where the only way appears to be the hard way, and we’re glad to see hackers getting comfortable facing such challenges, whether it’s parallel flash, JTAG or power glitching. After all, it’s great when your devices can run an OS entirely under your control – it’s historically been that you get way more features that way, but it’s also that the manufacturer can’t pull the rug from under your feet like Amazon did with its Fire TV boxes.

We thank [WifiCable] for sharing this with us!

(Ed Note: Changed instances of “OpenWRT” to “OpenWrt”.)

Hackaday Podcast 180: Tiny CRTs, Springy PCBs, And Measuring Trees

The demogorgon just wants to be friends. See? He’s waving hello.

This week, Editor-in-Chief Elliot Williams and Assignments Editor Kristina Panos traded sweat for silence, recording from their respective attic-level offices in the August heat unaided by fans (too noisy). We decided there’s no real news this week that lacks a political bent, except maybe that Winamp is back with a new version that’s four years in the making. (Is Winamp divisive?) Does it still whip the llama’s ass? You be the judge.

After Elliot gives Kristina a brief math lesson in increasing area with regard to 3D printer nozzle sizes, we talk a bit about 3D pens, drool over a truly customizable macropad that uses a microcontroller for each keyswitch, and  discuss dendrometers and tree health. Then it’s back to keyboards for one incredible modular build with an e-ink display and haptic feedback knob which is soon to go open source.

Finally, we talk tiny CRTs, a USB drive that must have the ultimate in security through obscurity, discuss the merits of retrograde clocks, and wonder aloud about the utility of jumping PCBs. Don’t bounce on us just yet — not until you hear about our first electronics wins and learn the one thing Kristina doesn’t do when she’s spending all day in the heat.

Direct download. And listen with Winamp!

Check out the links below if you want to follow along, and as always, tell us what you think about this episode in the comments!

Continue reading “Hackaday Podcast 180: Tiny CRTs, Springy PCBs, And Measuring Trees”