Close

Clawing Back A Few Final Bytes

A project log for Nyan Cat Badge Demo (2018 Supercon)

An adaptation of YouTube star Nyan Cat for the 2018 Hackaday Superconference Badge

rogerRoger 11/09/2018 at 20:220 Comments

There are just a few more touches before the finish line for getting my Nyan Cat project ready for consideration for the Hackaday Superconference 2018 badge. The final space savings came from realizing I only used two out of three voices in music playback, but my song structure carried three values so the unused voice takes up space holding zeroes. Maybe it’s only a few hundred bytes, but that’s still waste I could trim.

Once trimmed, I reviewed my code and realized I was still reading key-presses by reading the raw IO lines instead of using the existing stdio_get() API. This was a mistake made early on, when I thought it would block my animation/music until a key is pressed. Functionally speaking, neglecting to use the API not a terribly huge deal, but if I want the program to serve as example code it should do the right thing.

And finally, code comments. I want this to be something people can read through and understand how to write code for the badge in C using some techniques that are absent from other examples on the badge. This is an important part of the pitch for putting Nyan Cat on the badge – it should be educational in its construction in addition to being entertaining to launch.

After I committed the final code updates and comments, I realized I forgot to update the memory footprint listed by the flag to turn Nyan Cat on/off in a build. Final tally: 84 bytes of data memory, 8468 bytes of program memory. This is over the 8 kilobyte goal I was shooting for, but certainly a tremendous reduction from the original 30+ kilobytes.

I packaged my Nyan Cat into a pull request against the upstream depot, and it was accepted. Now my sample project will be a part of the default firmware on every Supercon badge.

(Cross-posted to NewScrewdriver.com)

Discussions