From 640c197525a152559d047c0328173bd2c32bd00f Mon Sep 17 00:00:00 2001 From: hkz Date: Tue, 22 Jul 2025 17:41:00 +0200 Subject: [PATCH] add score and moves --- Makefile | 2 +- graphics/moves.png | Bin 0 -> 327 bytes graphics/score.png | Bin 0 -> 300 bytes linker-files/linker.scm | 2 +- src/game_graphics.c | 28 ++++++++++++++++++---- src/game_graphics.h | 2 ++ src/graph_misc_data.c | 21 +++++++++++++++++ src/graph_misc_data.h | 14 +++++++++++ src/main.c | 10 ++++---- src/utility.c | 50 ++-------------------------------------- src/utility.h | 4 +--- 11 files changed, 71 insertions(+), 62 deletions(-) create mode 100644 graphics/moves.png create mode 100644 graphics/score.png create mode 100644 src/graph_misc_data.c create mode 100644 src/graph_misc_data.h diff --git a/Makefile b/Makefile index e9c5027..7a783fc 100644 --- a/Makefile +++ b/Makefile @@ -11,7 +11,7 @@ LIBS=clib-6502.a ASM_SRCS = tk2k_startup.s C_SRCS = main.c monitor_subroutines.c utility.c \ game_graphics.c game_logic.c input.c \ - line_data.c tiles.c + line_data.c tiles.c graph_misc_data.c # Object files OBJS = $(ASM_SRCS:%.s=%.o) $(C_SRCS:%.c=%.o) diff --git a/graphics/moves.png b/graphics/moves.png new file mode 100644 index 0000000000000000000000000000000000000000..6c3b88201790a34ec559c9f409459c039964a878 GIT binary patch literal 327 zcmV-N0l5B&P)Px$0ZBwbR7i=%R?7~&Ir=Da$g&%kTA7P;&LyD~O{KxHj0l-3 z0=r!H0D269sHD=1i-0-KnE^T-05_o#hi)jB%iNTmN~i0Jp|ij1A~Zo|yL1P$q&EOw z6evNz6z$ZbvaGHbU+*$kR?IQYBHHBA)8Y9-L1zviYw}v6Zt%&d8;gNrFB4fHmamOe zu>{+P(k)002ovPDHLkV1igNjT8U? literal 0 HcmV?d00001 diff --git a/graphics/score.png b/graphics/score.png new file mode 100644 index 0000000000000000000000000000000000000000..50c3b8a50fcdb55b02967011cb7f131868a38773 GIT binary patch literal 300 zcmV+{0n`48P)Px#=1D|BR7i=vRY?xRKnM#}|Nmurh%`dpf^w)&X~r-%OL|=%-QC^ygCn>oKFX=) zbrKa6RMm{EDj@I?1aineClHcQ&XqHE_tbITKoq-@r+{xzDP!2f>FHDkeRL}K_(&a9 z<(xVG(JDFj`(;iEtY~fol=J+2EDsP|{@}#6{?@@e0U4*UKnoJ(ga{AL0dIz@gyYCJ z%k5+i&L~iWpd9F;LTnB2sc1dlv4JZmJoCc2u>pvRp1&3t#Ep}%eDlkdHA!f5vM^ws yFLpEi_|4C5QRw5yXU@i3-n?)xig?$Q|KJBC8V(R!el|4#0000 + +const uint8_t score_pic_data[] = { + 0x00, 0x2C, 0x40, 0x40, 0x03, 0x05, 0x30, 0x00, 0x00, 0x7B, 0x70, 0x63, 0x06, 0x7B, 0x70, 0x0F, 0x00, 0x0F, + 0x78, 0x57, 0x0B, 0x47, 0x39, 0x00, 0x40, 0x03, 0x3C, 0x2E, 0x4E, 0x63, 0x39, 0x00, 0x60, 0x00, 0x3C, 0x1B, + 0x2E, 0x61, 0x39, 0x00, 0x00, 0x07, 0x5E, 0x1F, 0x6E, 0x71, 0x18, 0x00, 0x40, 0x1D, 0x4E, 0x0C, 0x66, 0x1D, + 0x7E, 0x03, 0x00, 0x3A, 0x0E, 0x4E, 0x67, 0x07, 0x7C, 0x01, 0x00, 0x30, 0x07, 0x0E, 0x77, 0x02, 0x0C, 0x00, + 0x00, 0x3C, 0x07, 0x66, 0x33, 0x06, 0x06, 0x00, 0x40, 0x1B, 0x47, 0x46, 0x3B, 0x0D, 0x06, 0x00, 0x30, 0x0F, + 0x23, 0x6E, 0x19, 0x0E, 0x7F, 0x00, 0x78, 0x01, 0x3E, 0x78, 0x18, 0x1C, 0x3F, 0x00, 0x18, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00 +}; + +const uint8_t moves_pic_data[] = { + 0x00, 0x06, 0x00, 0x1C, 0x06, 0x30, 0x00, 0x0B, 0x00, 0x3E, 0x0C, 0x36, 0x0E, 0x72, 0x6F, 0x1E, 0x00, 0x7F, + 0x0A, 0x5D, 0x06, 0x3A, 0x60, 0x03, 0x00, 0x57, 0x4D, 0x72, 0x0E, 0x3F, 0x70, 0x00, 0x40, 0x6F, 0x46, 0x71, + 0x26, 0x39, 0x18, 0x00, 0x50, 0x33, 0x67, 0x71, 0x47, 0x1B, 0x60, 0x01, 0x60, 0x19, 0x67, 0x30, 0x67, 0x7F, + 0x33, 0x07, 0x60, 0x15, 0x73, 0x3C, 0x67, 0x7C, 0x41, 0x0E, 0x70, 0x4C, 0x73, 0x38, 0x37, 0x0C, 0x00, 0x0C, + 0x68, 0x5C, 0x33, 0x1E, 0x1F, 0x06, 0x00, 0x0F, 0x30, 0x4C, 0x31, 0x1C, 0x1F, 0x06, 0x70, 0x06, 0x38, 0x26, + 0x71, 0x0E, 0x0E, 0x7F, 0x6C, 0x03, 0x38, 0x66, 0x41, 0x07, 0x07, 0x3F, 0x3E, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x06, 0x00 +}; diff --git a/src/graph_misc_data.h b/src/graph_misc_data.h new file mode 100644 index 0000000..3626703 --- /dev/null +++ b/src/graph_misc_data.h @@ -0,0 +1,14 @@ +#ifndef _GRAPH_MISC_DATA_HEADER_ +#define _GRAPH_MISC_DATA_HEADER_ + +#include + +#define SCORE_PIC_WIDTH_BYTES 8 +#define SCORE_PIC_HEIGHT 14 +extern const uint8_t score_pic_data[]; + +#define MOVES_PIC_WIDTH_BYTES 8 +#define MOVES_PIC_HEIGHT 14 +extern const uint8_t moves_pic_data[]; + +#endif /* _GRAPH_MISC_DATA_HEADER_ */ diff --git a/src/main.c b/src/main.c index f9c87fa..cb18fbd 100644 --- a/src/main.c +++ b/src/main.c @@ -26,12 +26,12 @@ void init(void) { memset((void*)DISPLAY_PAGE_2, 0, DISPLAY_PAGE_SIZE); } -#define MOVES_TEXT_X 28 -#define MOVES_TEXT_Y 14 -#define MOVES_TEXT_WIDTH 4 +#define MOVES_TEXT_X 32 +#define MOVES_TEXT_Y 61 +#define MOVES_TEXT_WIDTH 5 -#define SCORE_TEXT_X 28 -#define SCORE_TEXT_Y 22 +#define SCORE_TEXT_X 32 +#define SCORE_TEXT_Y 29 #define SCORE_TEXT_WIDTH 5 __task int main(void) { diff --git a/src/utility.c b/src/utility.c index 57e49c2..06fc881 100644 --- a/src/utility.c +++ b/src/utility.c @@ -40,54 +40,7 @@ uint16_t lfsr_update(void) { return lfsr; } -// Note that the horizontal values here are in group of 7 pixels -void clear_box(uint8_t w, uint8_t h, uint8_t off_x, uint8_t off_y, uint8_t *disp_buf) { - for(uint8_t y = off_y; y < off_y + h; y++) { - uint16_t line_counter = line_offset_map[y]; - - for(uint8_t x = off_x; x < off_x + w; x++) { - disp_buf[line_counter + x] = 0; - } - } -} - -void draw_pic(uint16_t w, uint8_t h, uint8_t off_x, uint8_t off_y, const uint8_t *data, uint8_t *disp_buf) { - uint8_t remainder = 0; - uint8_t remainder_size = 0; - uint8_t pic_width_bytes = w / 8 + ((w % 8) ? 1 : 0); - uint16_t counter; - - for(uint8_t row = 0; row < h; row++) { - uint8_t screen_row = row + off_y; - counter = line_offset_map[screen_row] + (off_x/7); - - remainder = 0; - remainder_size = 0; - - // MSB is the color indicator - for(uint8_t column = 0; column < pic_width_bytes; column++) { - uint8_t pix_data = data[(pic_width_bytes * row) + column]; - uint8_t conv_data = (pix_data << remainder_size) | remainder; - remainder_size++; - remainder = (pix_data >> (8 - remainder_size)) & 0x7F; - disp_buf[counter++] = conv_data & 0x7F; - - if(remainder_size == 7) { - disp_buf[counter++] = remainder & 0x7F; - remainder = 0; - remainder_size = 0; - } - } - - if(remainder_size != 0) { - uint8_t mask = ~((1 << remainder_size) - 1); - disp_buf[counter] = (disp_buf[counter] & mask) | (remainder & 0x7F); - counter++; - } - } -} - - +/* void print_line(const char* line, uint8_t off_x, uint8_t off_y) { POKEZ(ZP_CV, off_y); @@ -112,3 +65,4 @@ void print_line(const char* line, uint8_t off_x, uint8_t off_y) { COUT1(' '|0x80); WAIT(0xFF); } +*/ diff --git a/src/utility.h b/src/utility.h index 09b55dc..6723446 100644 --- a/src/utility.h +++ b/src/utility.h @@ -22,8 +22,6 @@ void num_to_decbuf(uint16_t n, uint8_t len, uint8_t *buf); uint8_t bit_reverse(uint8_t b); uint8_t bit_count(uint8_t b); uint16_t lfsr_update(void); -void clear_box(uint8_t w, uint8_t h, uint8_t off_x, uint8_t off_y, uint8_t *disp_buf); -void draw_pic(uint16_t w, uint8_t h, uint8_t off_x, uint8_t off_y, const uint8_t *data, uint8_t *disp_buf); -void print_line(const char* line, uint8_t off_x, uint8_t off_y); +//void print_line(const char* line, uint8_t off_x, uint8_t off_y); #endif /* _UTILITY_HEADER_ */