mirror of
https://codeberg.org/hkzlab/TK2048.git
synced 2025-12-26 07:02: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();
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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_ */
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue