Although I’m not sure I agree with it, one of the criteria for awarding prizes for this jam is program size, as described here. In regard to this, I wondered:
An example would be some entries having the boot logo removed and others not. I proposed a way to accomplish this here. I’ve taken it upon myself to do this, with some changes to the original proposal (detailed further on). Here are the results:
Org. Size is the original size compiling the provided source.
Adj. Size is the “normalized” size after adjustments.
|Alice Catches Cards
It turns out that BeamEmUp was the only game affected by the process, gaining 2 spots in the order.
No entries removed the USB code, so I left it in for all of them.
If an entry used the Arduboy2 class but didn’t use any library text functions, I changed it to use the Arduboy2Base class.
If begin() was used, I changed it to boot() with additional calls as given below. If boot() was used instead, I adjusted the additional calls as necessary.
safeMode() was always added or replaced flashLight().
bootLogo() was always removed.
display() (used to clear the screen) was always removed, on the assumption that all programs would clear the display again shortly afterwards.
If the entry didn’t generate any sound, I used:
- If the entry generated sound, I used:
- However, if an entry with sound included its own code to turn sound on and off, I used:
Entries of Note
Firebox uses only the Arduboy2Core class instead of Arduboy2 or Arduboy2Base. I’ve never seen that done before. It’s the smallest but more work is involved in writing functions to replace those normally provided by the library.
BeamEmUp is the only one that uses class Arduboy2 but doesnt use text functions. Switching to Arduboy2Base reduced it enough to move it up in the order.
NewBlocksOnTheKid has sound but doesn’t include systemButtons() or provide any other way of turning sound on and off. This means that in order to turn sound on or off, another sketch has to be uploaded to do it, then NewBlocksOnTheKid has to be uploaded back in. I suggested to @bateske that systemButtons() be included (along with a few other notes in the post that followed). His response was:
Following my procedure, meaning including systemButtons(), increased the adjusted size for this program.
RushIDE uses boot() but doesn’t include flashLight() or safeMode() to guard against the bootloader “magic key” problem. Adding safeMode() slightly increased the adjusted size for this program.
MannBarSchwein is written using the Nim programming language. I didn’t want to go through the process of setting up to be able to compile it. I estimated what the savings would be based on entries with similar features (uses begin(), uses text functions, no sound). If my estimate was off by a few hundred bytes either way, it wouldn’t affect the order.
evasion tests specifically for version 5.2.1 of the Arduboy2 library. I had to change it for version 5.3.0 to match what I used for all the rest. This may affect the size that I’ve given compared to the size of the included
Note that this post is in no way a proposal that any sketch use what I’ve done to reduce code size, if not necessary. Quite the opposite; if you don’t need the extra space you should use begin(), not boot(), and using class Arduboy2 even when it’s possible to use Arduboy2Base won’t affect the actual operation of your sketch.
My doing this was only to provide an “apples to apples” comparison of relative code sizes for the purpose of contest scoring.