From 9b7646d434013f3a4f07b0af930cb4b59fc650bd Mon Sep 17 00:00:00 2001 From: hkz Date: Sat, 26 Jul 2025 12:27:24 +0200 Subject: [PATCH] Add reset key combo --- src/input.c | 13 +++++++++++-- src/input.h | 1 + src/main.c | 9 +++++++-- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/input.c b/src/input.c index 78b6927..1954e5b 100644 --- a/src/input.c +++ b/src/input.c @@ -6,8 +6,17 @@ key __internal_read_kb(void); inline key __internal_read_kb(void) { - PEEK(IO_KB_CTRL_LOW); + PEEK(IO_KB_CTRL_HI); + if(PEEK(IO_DATAIN) & 0x01) { + POKE(IO_DATAOUT, 0x04); + if (PEEK(IO_DATAIN) & 0x04) { + return K_CTRL_R; + } + } + + PEEK(IO_KB_CTRL_LOW); + POKE(IO_DATAOUT, 0x40); if (PEEK(IO_DATAIN) & 0x01) return K_UP; @@ -19,7 +28,7 @@ inline key __internal_read_kb(void) { POKE(IO_DATAOUT, 0x08); if (PEEK(IO_DATAIN) & 0x01) return K_LEFT; - + return K_NONE; } diff --git a/src/input.h b/src/input.h index fb54328..d57b3f4 100644 --- a/src/input.h +++ b/src/input.h @@ -9,6 +9,7 @@ typedef enum { K_DOWN, K_LEFT, K_RIGHT, + K_CTRL_R, } key; key read_kb(void); diff --git a/src/main.c b/src/main.c index b9d3d2a..9153677 100644 --- a/src/main.c +++ b/src/main.c @@ -99,6 +99,11 @@ __task int main(void) { done = step_game(STEP_RIGHT); ddraw_direction_arrows(ARROW_RIGHT); break; + case K_CTRL_R: + BELL1(); + score = 0; // We'll reset the score + done = -1; + break; default: continue; // Do nothing, loop again } @@ -106,9 +111,9 @@ __task int main(void) { // Increase the count of moves we made moves_count++; - // If we have won, break out of this loop + // If we have won, or we got a reset request, break out of this loop if(done) { - score += WIN_SCORE_BONUS; + score += (done > 0) ? WIN_SCORE_BONUS : 0; break; }