Close

The Cat Needs a Diet

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:180 Comments

Now I’ve got Nyan Cat animation running while playing a simplified adaptation of the Nyan Cat music on my Hackaday Belgrade 2018 badge. I started writing run-length encoding on Friday, had a crash course in reading sheet music on Saturday, and by end of Sunday I had music and animation loop running together. This is roughly the same timespan that will be available to people putting their own projects on Hackaday Superconference 2018 badge, I just had the opportunity to do it a week ahead of time.

The original intent was twofold: One, to give myself some hands-on familiarity with the badge code base and two, have Nyan Cat project code available for other badge hackers as reference. I originally planned to have Nyan Cat up on Github for people to look at, but with this success my ambition grew: can this musical pop tart cat be part of the default badge firmware?

The greatest constraint on badge firmware is available space. Before I started this exploration, I hacked and slashed a bunch of features to make things lightweight, but if Nyan Cat is to be on the basic badge, it must coexist with all those features I had cut. And there isn’t enough free space for >30 kilobytes of Nyan Cat.

The majority of that space were consumed by run-length encoded animation frames, so that’s an obvious place to start. Code – both on encoding and decoding – most easily accommodates even power-of-two reductions. Nyan Cat is a blocky little kitty and should preserve well in downscaling from full resolution (320×240) to half (160×120), quarter (80×60), and eighth (40×30.) Here they are displayed in their pixel dimensions.

And here they are with pixels scaled up to fill a 320×240 screen, as it would on the badge.

There is visible degradation from full to half resolution, but not terrible. Nyan Cat starts getting pretty blocky at quarter resolution, but still recognizable. Eighth resolution is not usable.

So it looks like quarter scale is the sweet spot to target. This reduces the animation data from over 32 kilobytes to a little over 8 kilobytes. The music data and the program to bring it all together adds roughly another 2 kilobytes. It’s a good start but there is still room for improvement.

(Cross-posted to NewScrewdriver.com)

Discussions