AVR Breakout clone

At some point I bought a KS0108 128x64 pixel graphical LCD and hooked it up to an AVR ATmega32. After getting it to work I decided to take it a step further and do something (somewhat) useful with it, so I made a Breakout clone.

The problem with the ATmega32 is the limited memory (2 KiB). The KS0108 doesn't have any commands to operate on individual pixels, instead you (over-)write 8 pixels at a time. This means, depending on what you're doing with it, that you're gonna have to keep a full framebuffer in MCU RAM. Since it's a monochrome display we only need one bit per pixel, 128x64 is 8192 pixels, divide by 8 and you get 1024 bytes of RAM, so half the MCU RAM is going to a framebuffer.

But that's not enough. This doesn't tell me what has changed in the framebuffer. If I change a pixel I don't want it to be written out to the LCD immediately since I could change more pixels in the same 8 pixel group that gets sent to the LCD. So we need another buffer that determines what pixels have actually changed, but we can't do another 1 KiB buffer since we don't have enough RAM left (also it would be slow going over the entire buffer every frame) and since we send groups of 8 pixels anyway it doesn't make any sense. Instead we reduce it to those pixel groups, so 1024 divided by 8 which is 128.

I should point out that it's possible to read back data from the LCD but since there's RAM available for this in the MCU, it's much faster and easier to just use a framebuffer.

Now we need some bricks! There are 8 bricks per row (one bit per brick), so checking if a row is completely cleared of bricks is simple, just check if rows[n] is zero.

And then we just need to add some game logic and input and we're done!

Pictures, source code and video will be available soon(ish).