From: Maik Fischer Date: Thu, 26 Oct 2017 10:07:00 +0000 (+0200) Subject: use cget_return() to wait for a RETURN key press X-Git-Tag: rgb2rv17~9^2~15 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=defab3aeca9d460cf07267a2d1f59146f5528e65;p=c128-kasse use cget_return() to wait for a RETURN key press --- diff --git a/include/general.h b/include/general.h index 66294bf..82a0db9 100644 --- a/include/general.h +++ b/include/general.h @@ -12,6 +12,7 @@ typedef input_terminator_t input_terminator_mask_t; input_terminator_t get_input_terminated_by(input_terminator_mask_t terminators, char *out, BYTE outlen); char *get_input(void); +void cget_return(void); char retry_or_quit(void); char *format_euro(char *s, int maxlen, int cent); void c128_perror(BYTE, char *); diff --git a/src/credit_manager.c b/src/credit_manager.c index 347326a..728aa32 100644 --- a/src/credit_manager.c +++ b/src/credit_manager.c @@ -90,7 +90,7 @@ void deposit_credit(char *input) { print_the_buffer(); cprintf("\r\nEinzahlung durchgef" uUML "hrt, dr" uUML "cke RETURN...\r\n"); - input = get_input(); + cget_return(); } static void new_credit(void) { @@ -101,7 +101,7 @@ static void new_credit(void) { if (credits.num_items == 75) { cprintf("\rEs ist bereits die maximale Anzahl an Eintr" aUML "gen erreicht, dr" uUML "cke RETURN...\r\n"); - input = get_input(); + cget_return(); return; } @@ -189,7 +189,7 @@ void credit_manager() { return; default: cprintf("Unbekannter Befehl, dr" uUML "cke RETURN...\r\n"); - get_input(); + cget_return(); } } } diff --git a/src/general.c b/src/general.c index ec06ef4..87cdd07 100644 --- a/src/general.c +++ b/src/general.c @@ -66,6 +66,17 @@ char *get_input(void) { return output; } +/* wait until user pressed RETURN, ignore all other input */ +void cget_return() { + BYTE c; + while (1) { + c = cgetc(); + if (c == PETSCII_CR) { + return; + } + } +} + char retry_or_quit(void) { char *c; do { diff --git a/src/itemz.c b/src/itemz.c index f04678c..7751b68 100644 --- a/src/itemz.c +++ b/src/itemz.c @@ -128,7 +128,7 @@ static void itemz_manager() { exit(0); default: cprintf("Unbekannter Befehl, druecke RETURN...\r\n"); - get_input(); + cget_return(); } } } diff --git a/src/kasse.c b/src/kasse.c index 734599a..aa112f3 100644 --- a/src/kasse.c +++ b/src/kasse.c @@ -177,7 +177,7 @@ static signed int buy(char *name, unsigned int price) { } if (c == PETSCII_ESC) { cprintf("Kauf abgebrochen, dr" uUML "cke RETURN...\r\n"); - get_input(); + cget_return(); return 1; } if (c == '-' && i == 0) { @@ -309,14 +309,14 @@ static signed int buy(char *name, unsigned int price) { "cke RETURN...\r\n", nickname, rest); textcolor(TC_LIGHT_GRAY); - get_input(); + cget_return(); matches++; } else { textcolor(TC_LIGHT_RED); cprintf("\r\nNickname nicht gefunden in der Guthabenverwaltung! Abbruch, " "dr" uUML "cke RETURN...\r\n"); textcolor(TC_LIGHT_GRAY); - get_input(); + cget_return(); return 0; } } else { @@ -336,7 +336,7 @@ static signed int buy(char *name, unsigned int price) { void buy_stock(BYTE n) { if (n >= status.num_items || status.status[n].item_name == NULL) { cprintf("FEHLER: Diese Einheit existiert nicht.\r\n"); - get_input(); + cget_return(); return; } @@ -367,7 +367,7 @@ void buy_custom(void) { cputc(c); if (c == PETSCII_ESC) { cprintf("Kauf abgebrochen, dr" uUML "cke RETURN...\r\n"); - get_input(); + cget_return(); return; } else if (c == '-' && i == 0) negative = -1; @@ -472,7 +472,7 @@ int main(void) { log_flush(); cprintf("ok\r\nStatefile/Creditfile/Log gesichert, dr" uUML "cke RETURN...\r\n"); - get_input(); + cget_return(); } else if (*c == 'g') { credit_manager(); } else if (*c == 'z') {