Skip to content

Commit

Permalink
Drop coord_new() to save 40 more bytes.
Browse files Browse the repository at this point in the history
Moves _CODE from 896 bytes to 856 in game.map
  • Loading branch information
dmcardle committed Nov 22, 2023
1 parent 1c366f8 commit 2a2c7c1
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions game.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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;
}

Expand Down Expand Up @@ -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();

Expand Down

0 comments on commit 2a2c7c1

Please sign in to comment.