diff options
| author | Väinö Kauppila <vaino@vke.fi> | 2026-04-20 15:16:47 +0300 |
|---|---|---|
| committer | Väinö Kauppila <vaino@vke.fi> | 2026-04-20 15:16:47 +0300 |
| commit | e98cf5fe63ccadce28885208bd917568a0e9658d (patch) | |
| tree | 8084b6deb801a95fd1aad486315d5cf5aac426dd /fw/snake.c | |
| parent | b33ebdfd1087bd1de038e23fd256ad5cc6576cfd (diff) | |
| download | vhdl_pic-e98cf5fe63ccadce28885208bd917568a0e9658d.tar.gz vhdl_pic-e98cf5fe63ccadce28885208bd917568a0e9658d.zip | |
increase to 8kB of progmem. bring back score couting
Diffstat (limited to 'fw/snake.c')
| -rw-r--r-- | fw/snake.c | 32 |
1 files changed, 16 insertions, 16 deletions
@@ -75,17 +75,17 @@ static void place_food(void) { food_y = y; } -/* static void print_uint8(uint8_t v) { */ -/* uint8_t started = 0; */ -/* if (v >= 200) { uart_send('2'); v -= 200; started = 1; } */ -/* else if (v >= 100) { uart_send('1'); v -= 100; started = 1; } */ -/* { */ -/* uint8_t t = '0'; */ -/* while (v >= 10) { v -= 10; t++; } */ -/* if (started || t != '0') uart_send(t); */ -/* } */ -/* uart_send(v + '0'); */ -/* } */ +static void print_uint8(uint8_t v) { + uint8_t started = 0; + if (v >= 200) { uart_send('2'); v -= 200; started = 1; } + else if (v >= 100) { uart_send('1'); v -= 100; started = 1; } + { + uint8_t t = '0'; + while (v >= 10) { v -= 10; t++; } + if (started || t != '0') uart_send(t); + } + uart_send(v + '0'); +} static void render(void) { uint8_t x, y, i; @@ -121,8 +121,8 @@ static void render(void) { for (x = 0; x < GRID_W; x++) uart_send('-'); uart_puts("+\r\n"); - /* uart_puts("Score: "); */ - /* print_uint8(score); */ + uart_puts("Score: "); + print_uint8(score); uart_puts(" \r\n"); } @@ -192,9 +192,9 @@ void main(void) { } uart_puts("\x1B[2J\x1B[H"); - /* uart_puts("GAME OVER score: "); */ - /* print_uint8(score); */ - /* uart_puts("\r\npress any key\r\n"); */ + uart_puts("GAME OVER score: "); + print_uint8(score); + uart_puts("\r\npress any key\r\n"); uart_getc(); } } |
