Cheap character LCD displays are more versatile than we give them credit for. Most of the cheapies have a 5×8 character display, which looks blocky but legible when you have an appropriate font. Where it gets fun is that most of the LCD displays also let you upload custom characters.
Taking this to the extreme, [numeric] abused the user-defined characters to write a tiny game of Tetris that would run in the 10×16 frame that you get when you combine four characters together. It’s tiny, it’s monochrome, and doesn’t play the Troika theme (which may be a good thing), but it’s playable. Check out the video below.
[numeric] has bravely put his code for doing this online (ZIP file) as well. It’s rough, to say the least — he did this in a weekend just for fun. But before you go jumping on him for C code in header files, note that this is pretty cool for a quick hack, and also that as good as the Arduino platform is at getting beginners into coding, it doesn’t teach them how to do things right. We wish our first steps into our own coding looked this cool.
This is Hackaday, and we’ve covered a couple Tetris games before. If an LCD display is too high-tech for you, consider Tetris on a DIY LED matrix. If that’s too small, how about Tetris on a skyscraper? Even HP engineers can’t resist the allure of the tiny bricks. And of course, there’s our badge for Hackaday Belgrade. It’s a simple game, and a great test of your skills on a limited system. What’s your favorite Tetris platform?
19 thoughts on “Tetris Everywhere: Character LCD Edition”
Hah, brilliant! :-)
With the 8 bytes of CGRAM characters, you could make it a bit larger by flipping the screen vertically and using 2×4 chars. I guess the aspect ratio would be a bit off with that, though.
Anyway very cool project.
Nicely done! Is it just me or does anyone else feel the need to drop a long piece down the gap in the middle?
C-Code must be put in .c-files, not .h. These are only for prototypes, typedefs, constants,…
“Must be” is a pretty strong language or a project that obviously worked the way it was written. If the compiler was happy with it, then putting C-code in a header file would just count as an undocumented feature… and thus a perfectly reasonable hack.
Of course it will work, the file is #included, but it’s still not correct.
The compiler obviously disagrees with you about it being not correct.
You didn’t get it: The compiler doesn’t even see the .h, because the content is included in some .c (or corresponding Arduino-thing) using the preprocessor. If you explicitly feed a .h (containing code) to the gcc he won’t complain but he will not compile it, if you rename it in .c it works. Tested with ggc 4.7.2.
The interesting thing is if you use -o to force an .exe as output (gcc test.h -o test.exe) it will produce some quite big executable that doesn’t work (“programm to big for RAM” (or something similar, translated) but seems to be a valid executable… Can somebody explain what is happening?
(“edit” of previous post)
The big .exe is actually not a .exe but a precompiled header, thats what gcc produces if fed with .h. https://en.wikipedia.org/wiki/Precompiled_header
(My example code get messed up by wordpress, just correct the include, it’s stdio.h of course.)
Thank you much for you response. It was quite informative and helped clarify a detail I hadn’t realized.
Doing gcc someheader.h ends up with a precompiled header file. It is huge because it is including all of the various header files into one giant file for speed. Read https://gcc.gnu.org/onlinedocs/gcc/Precompiled-Headers.html
That makes a change. Compilers usually complain that what I consider correct, is apparently wrong. I wish compilers just fixed your code, or at least highlight what’s actually wrong. If there was more than one way the code might could go, the compiler should just give you a drop down of possible options. Predictive text, that learns your coding style, would also be nice. Maybe even, automatically generating the definitions when you create a function and move it outside of your main block of code.
Don’t forget .i files.
Cool. Neat application for the custom characters in HD44780. Could have used all 8 to get a bigger tetris canvas, albeit a square one
Did that 2 years ago, but with only 2 custom characters for the playfield and one more for piece preview. This thing also plays Breakout and PONG (the PONG version was featured by HaD about 2 or 3 years ago, shortly before I put Tetris in there too)
Does anyone know where to get the 1 line * 5 character LCDs used in some flat DELL Servers? I have one, but broke it during assembly of the world’s smallest PONG arcade machine…
Arghhh! Tetris, Now the gameboy versions music is playing in my head.
wow!! its great
For the record, Troika was only used in the Atari arcade version, Tengen NES version, and some variants on the SNES like Super Tetris 3. The theme that everyone *thinks* of as the Tetris theme, due to it being used as the Type A music in the Game Boy version, is actually Korobeiniki.
Please be kind and respectful to help make the comments section excellent. (Comment Policy)