Just when we thought we’d seen the ‘80s game played on nearly everything, a group of Makers have built it onto an MCU.
For many, Tetris is simply a tile-matching video game originally designed and programmed by Alexey Pajitnov in 1984. However, for others, it inspires endless possibilities of Maker projects. Most recently, AdaCore’s Tristan Gingold and Yannick Moy have devised the highly-popular puzzle on an Atmel | SMART SAM4S ARM Cortex-M4 microcontroller.
“There are even versions of Tetris written in Ada. But there was no version of Tetris written in SPARK, so we’ve repaired that injustice. Also, there was no version of Tetris for the Atmel SAM4S ARM processor, another injustice we’ve repaired,” the duo writes.
The concept first stemmed from their colleague Quentin Ochem, who had been searching for a flashy demo for GNAT using SPARK on ARM, to run on the SAM4S Xplained Pro Evaluation Kit. Luckily, this kit features an OLED1 extension with a small rectangular display, which surely enough, immediately ‘SPARKed’ the idea of Tetris. Now, throw in the five buttons overall between the main card and the extension, and the team had all the necessary hardware to bring the project to life.
In total, the entire build took approximately five days to complete. Both Gingold and Moy advise, “Count two days for designing, coding and proving the logic of the game in SPARK, another two days for developing the BSP for the board, and a half day for putting it all together.”
For those unfamiliar with SPARK, it is a subset of Ada that can be analyzed very precisely for checking global data usage, data initialization, program integrity and functional correctness. Mostly, it excludes pointers and tasking, which proved not to be a problem for Tetris.
While we’ve seen the retro game played on everything from t-shirts to bracelets, we’ve never experienced the game literally on an MCU. As the team notes, all of the necessary sources can be downloaded in the tetris.tgz archive, while those interested in designing one of their own can find a detailed breakdown of the entire build here.