From: sECuRE Date: Sat, 28 Jul 2007 19:29:50 +0000 (+0000) Subject: broken code, credit_manager imeplemented X-Git-Tag: rgb2rv6~93 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=1afc8c2372f36f43e66d133afa3b9e28a517577d;p=c128-kasse broken code, credit_manager imeplemented git-svn-id: https://shell.noname-ev.de/svn/kasse/c128@16 af93e077-1a23-4f1e-9cbe-9382a9d578f5 --- diff --git a/Makefile b/Makefile index 87ac808..688d5ec 100644 --- a/Makefile +++ b/Makefile @@ -2,8 +2,8 @@ cc65 -t c128 $< ca65 -t c128 $$(basename $< .c).s -all: config.o kasse.o - cl65 -t c128 kasse.o config.o -o kasse +all: config.o kasse.o credit_manager.o general.o + cl65 -t c128 *.o -o kasse clean: rm -rf *.o *.s diff --git a/config.c b/config.c index c4c28af..a142c18 100644 --- a/config.c +++ b/config.c @@ -4,14 +4,17 @@ unsigned long int money = 0; unsigned long int num_items = 0; +uc num_credit_items = 0; unsigned long int items_sold = 0; struct status_t status[MAX_ITEMS+1]; +struct credits_t credits[MAX_CREDIT_ITEMS+1]; -void load_config(); +void load_config() { +} -void load_items(){ - char c; - num_items=3; +void load_items() { + uc c; + num_items=2; status[0].item_name = "cola"; status[0].price = 230; status[0].times_sold = 0; @@ -22,8 +25,17 @@ void load_items(){ status[c].item_name = NULL; } -void load_state(){ + +void load_state() { status[0].times_sold=23; status[1].times_sold=42; } -void save_state(){} + +void load_credits() { +} + +void save_state() { +} + +void save_credits() { +} diff --git a/config.h b/config.h index f730bf5..d7bea62 100644 --- a/config.h +++ b/config.h @@ -4,12 +4,12 @@ /* Eingenommes Geld in Cent */ extern unsigned long int money; extern unsigned long int num_items; +extern unsigned char num_credit_items; extern unsigned long int items_sold; /* Datenstruktur der verkauften Einträge */ struct status_t { - char key; char *item_name; /* Wieviel kostet der Eintrag (in Cent)? */ unsigned int price; @@ -20,10 +20,22 @@ struct status_t { #define MAX_ITEMS 15 extern struct status_t* status; -// unklar bis jetzt was das tun wird -void load_config(); +/* Datenstruktur für die Guthaben */ +struct credits_t { + char *nickname; + /* Guthaben (in Cent) */ + unsigned int credit; +}; + +#define MAX_CREDIT_ITEMS 75 +extern struct credits_t *credits; +/* Lädt Dinge wie die Druckeradresse */ +void load_config(); void load_items(); void load_state(); +void load_credits(); + void save_state(); +void save_credits(); #endif /*CONFIG_H_*/ diff --git a/general.h b/general.h index 93e996b..f8aa25b 100644 --- a/general.h +++ b/general.h @@ -2,4 +2,5 @@ #define GENERAL_H_ #define uc unsigned char #define NULL 0 +char *get_input(); #endif /*GENERAL_H_*/ diff --git a/kasse.c b/kasse.c index ab9f396..582adb9 100644 --- a/kasse.c +++ b/kasse.c @@ -5,10 +5,8 @@ #include "general.h" #include "config.h" #include "kasse.h" -// conf +#include "credit_manager.h" // drucker 4 oder 5 -// pricee+getraenke -// // graphic 4,0,10 @@ -21,7 +19,7 @@ void print_screen() { printf("Eingenommen: %d Euro, Verkauft: %d Flaschen\n\n", money * 100, items_sold); for (; i < num_items; ++i) printf("Item %x: %s (%d Cents, %d mal verkauft)\n", i, status[i].item_name, status[i].price, status[i].times_sold); - printf("\nBefehle: s) Save Data\tp) Toggle Printing\n"); + printf("\nBefehle: s) Save Data p) Toggle Printing\n"); } /* Druckt eine entsprechende Zeile aus */ @@ -52,7 +50,7 @@ void buy(uc n) { c = getchar(); if (c == 13) break; - else if (c == 45 && i == 0) + else if (c == '-'&& i == 0) negative = -1; else if (c > 47 && c < 58) entered[i++] = c; @@ -69,6 +67,15 @@ void buy(uc n) { int main() { static uc c; + /* Konfigurationsdatei laden */ + load_config(); + /* Einträge (=Getränke) laden */ + + load_items(); + /* Zustand laden */ + load_state(); + /* Guthaben laden */ + load_credits(); while (1) { /* Bildschirm anzeigen */ print_screen(); @@ -78,13 +85,19 @@ int main() { if (c > 47 && c < 58) buy(c - 48); else if (c == 's') { + /* Zustandsdatei schreiben */ save_state(); - printf("Statefile saved, press ANYKEY to continue...\n"); + save_credits(); + printf("Statefile/Creditfile saved, press ANYKEY to continue...\n"); getchar(); } else if (c == 'p') { + /* Drucken an- oder ausschalten */ printing = (printing == 1 ? 0 : 1); printf("Printing is now %s, press ANYKEY to continue...\n", (printing == 1 ? "on" : "off")); getchar(); + } else if (c == 'g') { + /* Guthabenverwalter aufrufen */ + credit_manager(); } else if (c == 'q') break; }