From: matze Date: Sun, 29 Jul 2007 14:06:42 +0000 (+0000) Subject: save_state funktioniert jetzt X-Git-Tag: rgb2rv6~69 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=84ea76db84ed6b7e8f10e061f7f61318ef834afa;p=c128-kasse save_state funktioniert jetzt git-svn-id: https://shell.noname-ev.de/svn/kasse/c128@40 af93e077-1a23-4f1e-9cbe-9382a9d578f5 --- diff --git a/Makefile b/Makefile index c7efcd3..98bfcd3 100644 --- a/Makefile +++ b/Makefile @@ -13,8 +13,8 @@ package: all c1541 -attach kasse.d64 -write items || exit 0 c1541 -attach kasse.d64 -write kasse || exit 0 -test: config.o test.o - cl65 -t c128 config.o test.o -o test +test: config.o test.o general.o + cl65 -t c128 config.o test.o general.o -o test test-package: test c1541 -attach test.d64 -delete state || exit 0 diff --git a/config.c b/config.c index c2f61c7..b58f36f 100644 --- a/config.c +++ b/config.c @@ -37,7 +37,7 @@ void load_items(){ * must be called after load_items() */ void load_state(){ - FILE* f; + FILE * f; char line[80]; char * sep; char i, j; @@ -49,6 +49,8 @@ void load_state(){ while (!feof(f)) { fgets(line, 79, f); sep = strchr(line, '='); + if (sep==NULL) + continue; *(line + (sep-line)) = 0; for (i=0; i< MAX_ITEMS; i++) { if (strcmp(line, status[i].item_name)==0) { @@ -57,10 +59,38 @@ void load_state(){ } } } + fclose(f); } -void save_state(){} - +void save_state(){ + FILE * f; + int i; + + f = fopen("state", "w"); + if (f==NULL){ + c128_perror(23, "cannot open state file"); + return; + } + for (i=0;i