Program Sizes
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.
Name |
Org. Size |
Adj. Size |
Difference |
Firebox |
7594 |
7594 |
0 |
Alice Catches Cards |
11890 |
10990 |
900 |
Quick_Block |
12304 |
11508 |
796 |
filthecup |
13002 |
12386 |
616 |
SlidingTiles |
13952 |
13150 |
802 |
FlufflesRainyDay |
14582 |
14002 |
580 |
BeamEmUp |
16920 |
14112 |
2808 |
MissSnake |
14726 |
14392 |
334 |
NewBlocksOnTheKid |
14830 |
15002 |
-172 |
ArduboyZenbox |
17320 |
16760 |
560 |
Rhythum |
20668 |
20082 |
586 |
RushIDE |
20738 |
20758 |
-20 |
Lion |
22042 |
21872 |
170 |
buttonMash |
22892 |
22350 |
542 |
apprentice-wizard |
23306 |
22782 |
524 |
InsaneSkulls |
24092 |
23468 |
624 |
MannBarSchwein |
24908 |
24108 |
800 |
evasion |
25646 |
25464 |
182 |
It turns out that BeamEmUp was the only game affected by the process, gaining 2 spots in the order.
Adjustment Process
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:
arduboy.boot();
arduboy.safeMode();
- If the entry generated sound, I used:
arduboy.boot();
arduboy.safeMode();
arduboy.systemButtons();
arduboy.audio.begin();
arduboy.waitNoButtons();
- However, if an entry with sound included its own code to turn sound on and off, I used:
arduboy.boot();
arduboy.safeMode();
arduboy.audio.begin();
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 .hex
file.
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.