mirror of
https://codeberg.org/hkzlab/TK2048.git
synced 2025-12-26 04:22:16 +11:00
Add hi-score graphics
This commit is contained in:
parent
0173ab753a
commit
10dc668d9e
8 changed files with 41 additions and 8 deletions
|
|
@ -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();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue