This is a projected that I finished development on over a year ago and I’m just now getting around to documenting it. I wanted to program Tetris from scratch and make it modular so it could be used with different displays. Right now I know it’s working with a KS0108 graphic LCD screen. I also did quite a bit of work on it with the Nokia 3595 screen which is the trunk build of the SVN right now. For this writeup I threw together the KS0108 hardware and loaded that branch of the svn onto the ATmega168 so that I could take some pictures. I’m happy to say it worked like a charm. Details after the break.
Gameplay is quite pleasing. At power-up the screen displays a message and prompts for a button click to begin the game. The random seed used generate the order of pieces is gathered from the system clock when the first button press registers. That way the pieces will not appear in the exact same order for every game.
I spent a lot of time working with the code to get the pieces to fit but not overlap each other or leave the game board. This can be seen in the box_game.c file. The BOX_check() and BOX_line_check() functions are where all the magic happens. I’d love to go into detail about all the issues I ran into when coding this but since it was over a year ago I simply can’t remember.
This is written for the AVR ATmega168 microprocessor. I prototyped this using the Dragon 500 board and an AVR Dragon programmer. The graphic LCD is a 128×64 pixel KS0108 compliant model that I picked up on eBay.
I used my own local subversion repository and the Eclipse IDE when developing the software. Recently I set up Google Code project hosting for this and used svnsync to import the entire history.
Project Page: http://code.google.com/p/tetrapuzz/
Anonymous Source Checkout (graphic LCD branch):
svn checkout https://tetrapuzz.googlecode.com/svn/branches/GLCD tetrapuzz