Main Content

ATtiny85 Mario Challenge!

The ATtiny85 microcontroller is a capable but compact AVR. However with only 8K of program memory, 512 bytes of EEPROM, 512 of SRAM and only 8 pins (3 of which are dedicated to the usual suspects of Vcc, GND and RESET), it best suited to performing tasks where memory demands are not large, and only a few pins are required for interfacing.

Sounds boring! Can we push one the capabilities of the ATtiny85 and play a version of Mario on it? Can we add music? How about sound effects playing at the same time? Can we maneuver Mario around a fully horizontally scrolling level? How about infinite procedural level generation on the fly? Can we squish it all into the ATtiny85? Now that sounds like a fun challenge! Sometimes self-imposed constraints can be fun, so I came up with some loose rules for this project:
Use only the ATtiny85 as a microcontroller - no offloading the heavy lifting to other chips!
Though perhaps using other ICs to expand the GPIO pins might be acceptable (i.e. the PCF8574 or PCF8574a, I’ve opted to consider that cheating! 😊
Creative use of GPIO pins to maximise functionality strongly encouraged
Cram as many features into 8K of program memory and 512 of SRAM as possible!
The aim here is to learn about the ATtiny85 chip and do something fun with it. If I wanted a proper Mario clone I could use a Raspberry Pi, an STM32 or even an ESP32 emulator - but where would be the fun in that?!

Some of the features I ended up implementing that might be of general interest are:
Two OLED 128x64 screens and graphics.
3 button input on a single pin, with deconvolution of button combinations (Twice = 6 digital GPIOs on 2 pins).
Dual tone music and sound effects by hacking 8-bit Timer0 for additional tone functionality
Horizontal scrolling and procedural level generation (ad infinitum)
Internal clocking of ATtiny85 at 16 MHz without external crystal.
I’ve had a few ATtiny85s knocking around my workbench for a while and I decided I finally wanted to do “something” with them. I also found myself in possession of an OLED screen, namely an I2C SSD1306 128x64 screen. They are cute and only have 1 bit colour, i.e. dark or a light blue.”

Link to article