From: Michael Stapelberg Date: Mon, 2 Nov 2009 12:29:31 +0000 (+0100) Subject: Implement printing a header X-Git-Tag: rgb2rv9~28 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=d503b42453dda112a0e252b4a59418dd5e03450f;p=c128-kasse Implement printing a header --- diff --git a/include/print.h b/include/print.h index 4ccde07..237e9fc 100644 --- a/include/print.h +++ b/include/print.h @@ -2,15 +2,16 @@ #define _PRINT_H void print_the_buffer(); +void print_header(); void log_file(const char *s); #ifdef _IS_PRINT char print_buffer[81]; -char log_num = 0; +unsigned char log_num = 0; int log_lines_written = 0; #else extern char print_buffer[81]; -extern int log_num; +extern unsigned char log_num; extern int log_lines_written; #endif diff --git a/src/config.c b/src/config.c index d94334a..266f441 100644 --- a/src/config.c +++ b/src/config.c @@ -71,7 +71,7 @@ static void lookup_needed_files() { if (log_num > 0) { log_num--; - sprintf(filename, "log-%d", log_num); + sprintf(filename, "log-%u", log_num); if ((c = cbm_open(lfn, (BYTE)8, (BYTE)CBM_READ, filename)) != 0) { c128_perror(c, "cbm_open(log) for reading"); exit(1); diff --git a/src/kasse.c b/src/kasse.c index 6996420..08fbdc1 100644 --- a/src/kasse.c +++ b/src/kasse.c @@ -36,7 +36,7 @@ static void print_screen() { cprintf("Einnahme %ld konnte nicht umgerechnet werden\r\n", money); exit(1); } - cprintf("C128-Kassenprogramm (phil_fry, sECuRE, sur5r) v:" GV "\r\ + cprintf("C128-Kassenprogramm (phil_fry, sECuRE, sur5r) " GV "\r\ \r\nUhrzeit: %s (wird nicht aktualisiert)\r\ Eingenommen: %s, Verkauft: %ld Dinge, Drucken: %s\r\n\r\n", time, profit, items_sold, (printing == 1 ? "ein" : "aus")); @@ -75,7 +75,7 @@ static void print_log(char *name, int item_price, int einheiten, char *nickname, exit(1); } - sprintf(print_buffer, "%c[%lu] %s - %-" xstr(MAX_ITEM_NAME_LENGTH) "s - %s - r %s - %d - an %s\r", 17, + sprintf(print_buffer, "%c[%3lu] %s - %-" xstr(MAX_ITEM_NAME_LENGTH) "s - %s - r %s - %d - an %s\r", 17, items_sold, time, name, price, rest, einheiten, (*nickname != '\0' ? nickname : "Unbekannt")); print_the_buffer(); @@ -238,6 +238,7 @@ void set_time_interactive() { int main() { char *c; + char *time; if (VIDEOMODE == 40) toggle_videomode(); @@ -249,12 +250,23 @@ int main() { /* Load configuration */ load_config(); - cprintf("got %d logfiles\r\n", log_num); /* Load items (= drinks) */ load_items(); /* Load credits */ load_credits(); + + time = get_time(); + sprintf(print_buffer, "%c-----------------------------------------------------------------\r", 17); + print_the_buffer(); + sprintf(print_buffer, "%cC128-Kasse Version " GV "\r", 17); + print_the_buffer(); + + sprintf(print_buffer, "%cKasse gestartet um %s. Nutze logfile log-%u, zeile %d.\r", 17, time, log_num, log_lines_written); + print_the_buffer(); + + print_header(); + while (1) { print_screen(); c = get_input(); diff --git a/src/print.c b/src/print.c index edd295e..006967b 100644 --- a/src/print.c +++ b/src/print.c @@ -41,6 +41,18 @@ RETRY: log_file(print_buffer); } +void print_header() { + sprintf(print_buffer, "%c-----------------------------------------------------------------\r", 17); + print_the_buffer(); + + sprintf(print_buffer, "%c#kauf Uhrzeit - Ding - Preis - Restguthab - # - Nickname\r", 17); + print_the_buffer(); + + sprintf(print_buffer, "%c-----------------------------------------------------------------\r", 17); + print_the_buffer(); + +} + void log_file(const char *s) { /* A log-entry has usually 50 bytes, so we take 64 bytes. Because files are wrapped (log.0, log.1, ...) every 100