diff --git a/graphics/highscores.aseprite b/graphics/highscores.aseprite new file mode 100644 index 0000000..7a55faf Binary files /dev/null and b/graphics/highscores.aseprite differ diff --git a/graphics/highscores.png b/graphics/highscores.png new file mode 100644 index 0000000..aebcd2a Binary files /dev/null and b/graphics/highscores.png differ diff --git a/linker-files/linker.scm b/linker-files/linker.scm index 2951d50..7d71a02 100644 --- a/linker-files/linker.scm +++ b/linker-files/linker.scm @@ -7,8 +7,8 @@ ;;; (section (programStart #x801) (startup #x80e) code switch idata cdata data_init_table)) (section (programStart #x801) (startup #x80e) code)) (memory displayPage1 (address (#x2000 . #x3fff)) (type ram) (section loadscreen)) - (memory datamem (address (#x4000 . #x91ff)) (type ram) (section cstack zdata data heap)) ;;; usermem goes from 0x4000 to 0x9FFFF (included), we are splitting it - (memory upperData (address (#x9200 . #x9fff)) (type ram) (section switch idata cdata data_init_table)) + (memory datamem (address (#x4000 . #x8fff)) (type ram) (section cstack zdata data heap)) ;;; usermem goes from 0x4000 to 0x9FFFF (included), we are splitting it + (memory upperData (address (#x9000 . #x9fff)) (type ram) (section switch idata cdata data_init_table)) (memory displayPage2 (address (#xa000 . #xbfff)) (type ram)) (memory io (address (#xc000 . #xc0ff)) (type ram)) (memory rombank (address (#xc100 . #xffff)) (type rom)) diff --git a/src/game_graphics.c b/src/game_graphics.c index 47ba2f8..34ef116 100644 --- a/src/game_graphics.c +++ b/src/game_graphics.c @@ -49,7 +49,7 @@ static const uint8_t box_content_win[BOX_CONTENT_SIZE] = { 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, 0, 0, 0, 0, 0, 0, 0, 0, 7, 1, 13, 5, 0, 15, 22, 5, 18, 33, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 1, 13, 5, 0, 15, 22, 5, 18, 33, 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, 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, @@ -93,12 +93,19 @@ static const uint8_t box_content_start[BOX_CONTENT_SIZE] = { void draw_field_borders_on_buffer(uint8_t brd, uint8_t* buf); void draw_picture(uint8_t w, uint8_t h, uint8_t x, uint8_t y, const uint8_t *data, uint8_t *dest); +void direct_draw_number(uint16_t n, uint8_t len, uint8_t x, uint8_t y, uint8_t *disp_buf); + void ddraw_field_borders_on_buffer(uint8_t brd) { draw_field_borders_on_buffer(brd, front_buf); } -void draw_game_background(void) { + +#define HIGH_TEXT_X 32 +#define HIGH_TEXT_Y 107 +#define HIGH_TEXT_WIDTH 5 + +void draw_game_background(uint16_t hi_score) { // Draw the background on display page 1 uint8_t* buf = (uint8_t*)DISPLAY_PAGE_1; @@ -108,6 +115,11 @@ void draw_game_background(void) { // Draw required pics draw_picture(SCORE_PIC_WIDTH_BYTES, SCORE_PIC_HEIGHT, 31, 14, score_pic_data, buf); draw_picture(MOVES_PIC_WIDTH_BYTES, MOVES_PIC_HEIGHT, 31, 45, moves_pic_data, buf); + draw_picture(HIGH_PIC_WIDTH_BYTES, HIGH_PIC_HEIGHT, 31, 76, high_pic_data, buf); + draw_picture(SCORE_PIC_WIDTH_BYTES, SCORE_PIC_HEIGHT, 31, 90, score_pic_data, buf); + + // Draw the high-score. This won't change at every turn, so makes sense to just draw once + direct_draw_number(hi_score, HIGH_TEXT_WIDTH, HIGH_TEXT_X, HIGH_TEXT_Y, front_buf); // Copy the data from display page 1 to 2 memcpy((void*)DISPLAY_PAGE_2, (void*)DISPLAY_PAGE_1, DISPLAY_PAGE_SIZE); @@ -133,7 +145,7 @@ void ddraw_single_tile(uint8_t offset) { } } -void draw_number(uint16_t n, uint8_t len, uint8_t x, uint8_t y) { +void direct_draw_number(uint16_t n, uint8_t len, uint8_t x, uint8_t y, uint8_t *disp_buf) { uint8_t buf[len]; // Decode the number into the buffer @@ -142,11 +154,15 @@ void draw_number(uint16_t n, uint8_t len, uint8_t x, uint8_t y) { for(uint8_t row = 0; row < CHAR_HEIGHT; row++) { uint16_t offset = line_offset_map[y + row]; for(uint8_t col = 0; col < len; col++) { - back_buf[(offset + (len - 1) - col) + x] = CHARSET[NUM_OFFSET + (buf[col] * CHAR_HEIGHT) + row]; + disp_buf[(offset + (len - 1) - col) + x] = CHARSET[NUM_OFFSET + (buf[col] * CHAR_HEIGHT) + row]; } } } +void draw_number(uint16_t n, uint8_t len, uint8_t x, uint8_t y) { + direct_draw_number(n, len, x, y, back_buf); +} + void draw_tiles(void) { uint8_t* grid = get_front_grid(); diff --git a/src/game_graphics.h b/src/game_graphics.h index ae5629d..eb04e18 100644 --- a/src/game_graphics.h +++ b/src/game_graphics.h @@ -21,7 +21,7 @@ typedef enum { } arrow_direction; void ddraw_field_borders_on_buffer(uint8_t brd); -void draw_game_background(void); +void draw_game_background(uint16_t hi_score); void draw_number(uint16_t n, uint8_t len, uint8_t x, uint8_t y); void draw_tiles(void); void ddraw_single_tile(uint8_t offset); diff --git a/src/graph_misc_data.c b/src/graph_misc_data.c index 1098e0d..0652f60 100644 --- a/src/graph_misc_data.c +++ b/src/graph_misc_data.c @@ -19,3 +19,13 @@ const uint8_t moves_pic_data[] = { 0x71, 0x0E, 0x0E, 0x7F, 0x6C, 0x03, 0x38, 0x66, 0x41, 0x07, 0x07, 0x3F, 0x3E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00 }; + +const uint8_t high_pic_data[] = { + 0x00, 0x00, 0x06, 0x60, 0x21, 0x30, 0x00, 0x00, 0x00, 0x00, 0x0A, 0x64, 0x78, 0x51, 0x20, 0x00, 0x00, 0x00, + 0x0E, 0x6E, 0x1D, 0x72, 0x70, 0x00, 0x00, 0x00, 0x06, 0x7E, 0x1E, 0x33, 0x30, 0x00, 0x00, 0x00, 0x0E, 0x33, + 0x0E, 0x71, 0x18, 0x00, 0x00, 0x00, 0x07, 0x7B, 0x05, 0x38, 0x18, 0x00, 0x00, 0x00, 0x5F, 0x1B, 0x07, 0x79, + 0x1D, 0x00, 0x00, 0x00, 0x7B, 0x59, 0x73, 0x59, 0x0F, 0x00, 0x00, 0x40, 0x27, 0x5D, 0x43, 0x3C, 0x0A, 0x00, + 0x00, 0x20, 0x51, 0x4C, 0x61, 0x0A, 0x05, 0x00, 0x00, 0x40, 0x71, 0x4C, 0x63, 0x0C, 0x07, 0x00, 0x00, 0x60, + 0x61, 0x06, 0x31, 0x0E, 0x06, 0x00, 0x00, 0x60, 0x30, 0x02, 0x3E, 0x06, 0x03, 0x00, 0x00, 0x20, 0x20, 0x00, + 0x00, 0x02, 0x02, 0x00 +}; diff --git a/src/graph_misc_data.h b/src/graph_misc_data.h index 3626703..e3f1724 100644 --- a/src/graph_misc_data.h +++ b/src/graph_misc_data.h @@ -11,4 +11,8 @@ extern const uint8_t score_pic_data[]; #define MOVES_PIC_HEIGHT 14 extern const uint8_t moves_pic_data[]; +#define HIGH_PIC_WIDTH_BYTES 8 +#define HIGH_PIC_HEIGHT 14 +extern const uint8_t high_pic_data[]; + #endif /* _GRAPH_MISC_DATA_HEADER_ */ diff --git a/src/main.c b/src/main.c index 335f694..96d4195 100644 --- a/src/main.c +++ b/src/main.c @@ -22,6 +22,9 @@ #define SCORE_TEXT_Y 29 #define SCORE_TEXT_WIDTH 5 +#define HIGH_TEXT_X 32 +#define HIGH_TEXT_Y 107 + #define WIN_SCORE_BONUS 10000 void init(void); @@ -64,7 +67,7 @@ __task int main(void) { score = reset_game(); // Draw the initial state of the game - draw_game_background(); + draw_game_background(hi_score); draw_number(moves_count, MOVES_TEXT_WIDTH, MOVES_TEXT_X, MOVES_TEXT_Y); draw_number(score, SCORE_TEXT_WIDTH, SCORE_TEXT_X, SCORE_TEXT_Y); draw_tiles();