mirror of
https://codeberg.org/hkzlab/TK2048.git
synced 2025-12-25 14:22:16 +11:00
Add reset key combo
This commit is contained in:
parent
56c290ed50
commit
9b7646d434
3 changed files with 19 additions and 4 deletions
13
src/input.c
13
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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ typedef enum {
|
|||
K_DOWN,
|
||||
K_LEFT,
|
||||
K_RIGHT,
|
||||
K_CTRL_R,
|
||||
} key;
|
||||
|
||||
key read_kb(void);
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue