A small tip: If you fused your overlay_1heart
, overlay_2hearts
, and overlay_3hearts
into a single block of data like so:
pub static overlay_hearts: [u8; _] =
[
// Width, Height,
64, 8,
// Frame 0
0x00, 0x00, 0x7e, 0x40, 0x40, 0x40, 0x00, 0x7a, 0x00, 0x0c, 0x30, 0x40, 0x30, 0x0c,
0x00, 0x38, 0x54, 0x54, 0x58, 0x00, 0x58, 0x54, 0x54, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00,
0x0c, 0x1e, 0x3f, 0x7e, 0xfc, 0x7e, 0x3f, 0x1e, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00,
// Frame 1
0x00, 0x00, 0x7e, 0x40, 0x40, 0x40, 0x00, 0x7a, 0x00, 0x0c, 0x30, 0x40, 0x30, 0x0c,
0x00, 0x38, 0x54, 0x54, 0x58, 0x00, 0x58, 0x54, 0x54, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00,
0x0c, 0x1e, 0x3f, 0x7e, 0xfc, 0x7e, 0x3f, 0x1e, 0x0c, 0x00, 0x00, 0x0c, 0x1e, 0x3f, 0x7e,
0xfc, 0x7e, 0x3f, 0x1e, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00,
// Frame 2
0x00, 0x00, 0x7e, 0x40, 0x40, 0x40, 0x00, 0x7a, 0x00, 0x0c, 0x30, 0x40, 0x30, 0x0c,
0x00, 0x38, 0x54, 0x54, 0x58, 0x00, 0x58, 0x54, 0x54, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00,
0x0c, 0x1e, 0x3f, 0x7e, 0xfc, 0x7e, 0x3f, 0x1e, 0x0c, 0x00, 0x00, 0x0c, 0x1e, 0x3f, 0x7e,
0xfc, 0x7e, 0x3f, 0x1e, 0x0c, 0x00, 0x00, 0x0c, 0x1e, 0x3f, 0x7e, 0xfc, 0x7e, 0x3f, 0x1e,
0x0c, 0x00, 0x00, 0x00, 0x00,
];
Then instead of;
match p.live {
3 => sprites::draw_override(0, 0, get_sprite_addr!(overlay_3hearts), 0),
2 => sprites::draw_override(0, 0, get_sprite_addr!(overlay_2hearts), 0),
1 => sprites::draw_override(0, 0, get_sprite_addr!(overlay_1heart), 0),
_ => (),
}
You could have just:
if p.live > 0
{
sprites::draw_override(0, 0, get_sprite_addr!(overlay_hearts), (p.live - 1));
}
Which should produce less code and thus use less progmem.
(Not that you necessarily need to be worrying about that at the moment.)