ATmega168 Tetris

Published November 22, 2009
Advertisement
The tvText library I discussed last entry allows you to display text on a PAL TV in black and white using a 20MHz ATmega168 and a pair of resistors. If this doesn't sound terribly exciting, it's probably because it isn't. However, if you bear some limitations in mind and change the font, you can use this text output as a more general tile-mapping system and use it for games that employ simple graphics.

The new circuit, featuring five sloppily-wired input buttons.
The new circuit, featuring five sloppily-wired input buttons.
I added five buttons to the test circuit -- up, down, left, right and fire -- to act as game input. This circuit is shown in the photograph above. I also added support for 8x8 characters alongside the existing 6x8 characters to the library, set as a compile-time option. This drops the number of characters per line from 32 to 24, but having square tiles makes producing graphics much easier. The reduction in size of the text buffer also frees up more of the precious 1KB of SRAM for the game!

Diagram of the game circuit.
Even though it was always recommended as an excellent game for beginners to write, I don't believe I've ever written a Tetris clone before. Its simple block graphics makes it an ideal candidate for this system, and it always helps to work on a game that's fun to play. Armed with a Game Boy and a stopwatch I attempted to recreate a moderately faithful version of what is probably the most popular rendition of the game.

">
Click to watch a gameplay video on YouTube.
I think the result plays pretty well, but don't take my word for it -- if you have an ATmega168 lying around, you can download the source and binaries here.
0 likes 4 comments

Comments

shadowcomplex
That is fantastic -- the game looks brilliant in motion! Looking forward to seeing you continue progress on this.
November 22, 2009 02:12 PM
benryves
Thanks. [smile]
November 23, 2009 05:10 AM
moose517
great work as usual ben, can't wait to see what you have up your sleeve, never fail to impress
November 23, 2009 06:23 PM
benryves
Cheers!
November 24, 2009 05:34 AM
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Advertisement