From 2a2c7c1d8575f614caab844a8f3e1ab4895f34d9 Mon Sep 17 00:00:00 2001 From: Dan McArdle Date: Tue, 21 Nov 2023 20:16:51 -0500 Subject: [PATCH] Drop coord_new() to save 40 more bytes. Moves _CODE from 896 bytes to 856 in game.map --- game.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/game.c b/game.c index 70b6671..abfd540 100644 --- a/game.c +++ b/game.c @@ -14,13 +14,7 @@ typedef struct coord { bool negative; } coord_t; -coord_t coord_new() { - coord_t coord; - coord.pos = 0; - coord.speed = 0; - coord.negative = false; - return coord; -} +const coord_t kDefaultCoord = {0, 0, false}; coord_t coord_tick(coord_t coord) { if (coord.negative) { @@ -43,8 +37,8 @@ typedef struct ball { ball_t ball_new() { ball_t ball; - ball.x = coord_new(); - ball.y = coord_new(); + ball.x = kDefaultCoord; + ball.y = kDefaultCoord; return ball; } @@ -123,7 +117,7 @@ int main() { DISPLAY_ON; enable_interrupts(); - for (uint8_t counter = 0; true; counter++) { + while (true) { // Slow down without a hot loop by waiting for a vertical blank interrupt. wait_vbl_done();