Close

Tabulate your Data

A project log for Nyan Board

A small ATtiny85 board playing the Nyan Cat tune.

dehipudeʃhipu 11/26/2016 at 12:303 Comments

So I tried to shrink this program even more. There are those two lookup tables in there, one with frequencies of the notes and one with octaves. By sorting the notes and replacing the frequencies with a simple formula (Wolfram Alpha helped me to come up with it), I got:

120 + (354 + a * 6363 + a * a * 293) // 1000
Very happy with it, I put it in my program. BAM! 500 bytes larger.

Why? Well, I blame 16-bit division and modulo that i had to use...

Discussions

Eric Hertz wrote 11/26/2016 at 13:28 point

Looks like a clever solution... what about using that, or similar, to calculate a table that's loaded into RAM?

  Are you sure? yes | no

Eric Hertz wrote 11/26/2016 at 13:40 point

Ah, just saw your previous log... yeah might be difficult to beat those tables.

  Are you sure? yes | no

deʃhipu wrote 11/26/2016 at 14:25 point

The problem is that the code to generate them is larger than the tables :-) I could probably rewrite that to calculate the polynominal iteratively instead of using multiplication and division (something like the Bresenham's algorithms), but I think it's still not worth it for 8 bytes.

  Are you sure? yes | no