From 5ecac321cda32ce57e32c12a6e9c4fa629c9a251 Mon Sep 17 00:00:00 2001 From: hkz Date: Fri, 25 Jul 2025 15:55:48 +0200 Subject: [PATCH] Draw different type of boxes --- src/game_graphics.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/game_graphics.c b/src/game_graphics.c index 4137b30..c67cb70 100644 --- a/src/game_graphics.c +++ b/src/game_graphics.c @@ -25,7 +25,9 @@ static uint8_t *front_buf = (uint8_t*)DISPLAY_PAGE_1; static uint8_t *back_buf = (uint8_t*)DISPLAY_PAGE_2; -static const uint8_t box_content_win[] = { +#define BOX_CONTENT_SIZE 544 + +static const uint8_t box_content_win[BOX_CONTENT_SIZE] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 77, 0, 77, 0, 83, 77, 84, 0, 77, 0, 77, 0, 0, 77, 0, 0, 0, 77, 0, 77, 0, 77, 0, 77, 0, 0, 0, 0, 0, 0, 0, 0, 77, 0, 77, 0, 77, 0, 77, 0, 77, 0, 77, 0, 0, 77, 0, 77, 0, 77, 0, 77, 0, 77, 84, 77, 0, 0, 0, 0, @@ -45,7 +47,7 @@ static const uint8_t box_content_win[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; -static const uint8_t box_content_lose[] = { +static const uint8_t box_content_lose[BOX_CONTENT_SIZE] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 77, 0, 77, 0, 83, 77, 84, 0, 77, 0, 77, 0, 0, 77, 0, 0, 0, 83, 77, 84, 0, 83, 77,192, 0, 77, 77, 77, 0, 0, 0, 0, 77, 0, 77, 0, 77, 0, 77, 0, 77, 0, 77, 0, 0, 77, 0, 0, 0, 77, 0, 77, 0,212, 77, 84, 0, 77, 0, 0, 0, 0, @@ -65,7 +67,7 @@ static const uint8_t box_content_lose[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; -static const uint8_t box_content_start[] = { +static const uint8_t box_content_start[BOX_CONTENT_SIZE] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 21, 19, 8, 0, 1, 14, 25, 0, 11, 5, 25, 0, 20, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -200,7 +202,13 @@ void ddraw_endgame_box(int8_t done, uint16_t score, uint16_t hi_score) { front_buf[offset + (SCREEN_WIDTH_B - ((ENDGAME_BOX_X_OFFSET * 2) + 2))] = CHARSET[GRAPH_OFFSET + (19 * CHAR_HEIGHT) + (row % CHAR_HEIGHT)]; } - const uint8_t *content = box_content_start; + uint8_t const *content; + + // Decide which type of content to show + if(done == 0) content = box_content_start; + else if (done > 0) content = box_content_win; + else content = box_content_lose; + // And now, the content!!! for(uint16_t tile = 0; tile < sizeof(box_content_win); tile++) { @@ -216,6 +224,8 @@ void ddraw_endgame_box(int8_t done, uint16_t score, uint16_t hi_score) { front_buf[offset] = invert ? ((~CHARSET[(ch_num * CHAR_HEIGHT) + row]) & 0x7F) : CHARSET[(ch_num * CHAR_HEIGHT) + row]; } } + + // TODO: Add additional info to the box, if necessary } // Note that the horizontal values here are in group of 7 pixels