2 * RGB2R-C128-Kassenprogramm
3 * © 2007-2009 phil_fry, sECuRE, sur5r
4 * See LICENSE for license information
13 #include "vdc_patch_charset.h"
16 * get_input_terminated_by() reads input (handling backspace correctly) until
17 * a terminator of |terminators| is encountered or |out| is full (outlen-1
18 * characters were read).
20 * get_input_terminated_by() returns the terminator it encountered.
23 input_terminator_t get_input_terminated_by(input_terminator_mask_t terminators,
24 char *out, BYTE outlen) {
31 if (((terminators & INPUT_TERMINATOR_RETURN) == INPUT_TERMINATOR_RETURN) &&
33 return INPUT_TERMINATOR_RETURN;
34 } else if (((terminators & INPUT_TERMINATOR_SPACE) ==
35 INPUT_TERMINATOR_SPACE) &&
37 return INPUT_TERMINATOR_SPACE;
38 } else if (c == PETSCII_DEL) {
39 /* If you are at the left-most position, do nothing */
43 cputcxy(x + i, y, ' ');
47 if (i == (outlen - 1)) {
56 * Liest (maximal 31) Zeichen ein, bis Enter gedrückt wird.
57 * Vorsicht: Es wird ein statischer Buffer benutzt, sodass man
58 * das Ergebnis via strdup() retten muss, bevor man get_input()
62 char *get_input(void) {
63 static char output[32];
64 memset(output, '\0', sizeof(output));
65 get_input_terminated_by(INPUT_TERMINATOR_RETURN, output, sizeof(output));
69 BYTE cgetn_input(char *s, BYTE len) {
71 get_input_terminated_by(INPUT_TERMINATOR_RETURN, s, len);
79 if (c == PETSCII_CR) {
85 char retry_or_quit(void) {
88 cprintf("\r\nr)etry or q)uit?\r\n");
90 } while ((*c != 'r') && (*c != 'q'));
94 char *format_euro(char *s, int maxlen, int cent) {
95 if (snprintf(s, maxlen, "%3d,%02d" EURSYM, cent / 100, cent % 100) > maxlen)
100 void c128_perror(BYTE c, char *msg) {
101 cprintf("\r\nError (Code %d) while: %s\r\nOS Error = %d\r\n", c, msg,