From: sECuRE Date: Tue, 23 Oct 2007 14:01:25 +0000 (+0000) Subject: fix time.c/h, fix test.c X-Git-Tag: rgb2rv6~56 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=ac35a296f50e79aa248f6eb3303e531ed83da58a;p=c128-kasse fix time.c/h, fix test.c git-svn-id: https://shell.noname-ev.de/svn/kasse/c128@53 af93e077-1a23-4f1e-9cbe-9382a9d578f5 --- diff --git a/Makefile b/Makefile index 9224028..6b88441 100644 --- a/Makefile +++ b/Makefile @@ -8,13 +8,17 @@ CL=~/customSoftware/cc65-2.11.0/src/cl65/cl65 # CL=cl65 src/%.o: src/%.c include/%.h - ${CC} -I include -t c128 $< + ${CC} -O -I include -t c128 $< ${CA} -I include -t c128 src/$$(basename $< .c).s -all: src/config.o src/kasse.o src/general.o src/credit_manager.o src/time.o +test/%.o: test/%.c + ${CC} -O -I include -t c128 $< + ${CA} -I include -t c128 test/$$(basename $< .c).s + +all: src/config.o src/kasse.o src/general.o src/credit_manager.o src/c128time.o # See above, please just kill the PATH-definition cp /tmp/cc65/lib/c128* . - PATH=${PATH}:~/customSoftware/cc65-2.11.0/src/ld65:/tmp/cc65/lib ${CL} -t c128 -O src/*.o -o kasse + PATH=${PATH}:~/customSoftware/cc65-2.11.0/src/ld65:/tmp/cc65/lib ${CL} -t c128 src/*.o -o kasse package: all c1541 -attach kasse.d64 -delete state || exit 0 @@ -24,8 +28,8 @@ package: all c1541 -attach kasse.d64 -write state || exit 0 c1541 -attach kasse.d64 -write items || exit 0 -test: config.o test.o general.o - ${CL} -t c128 config.o test.o general.o -o test +test: src/config.o test/test.o src/general.o + ${CL} -t c128 src/config.o test/test.o src/general.o -o test test-package: test c1541 -attach test.d64 -delete state || exit 0 @@ -36,7 +40,7 @@ test-package: test c1541 -attach test.d64 -write items || exit 0 clean: - rm -rf src/*.o src/*.s + rm -rf src/*.o src/*.s test/*.o test/*.s dist-clean: clean rm kasse test diff --git a/include/c128time.h b/include/c128time.h new file mode 100644 index 0000000..adc6ffb --- /dev/null +++ b/include/c128time.h @@ -0,0 +1,5 @@ +#ifndef TIME_H_ +#define TIME_H_ +void set_time(); +char *get_time(); +#endif diff --git a/include/time.h b/include/time.h deleted file mode 100644 index adc6ffb..0000000 --- a/include/time.h +++ /dev/null @@ -1,5 +0,0 @@ -#ifndef TIME_H_ -#define TIME_H_ -void set_time(); -char *get_time(); -#endif diff --git a/src/c128time.c b/src/c128time.c new file mode 100644 index 0000000..7b9f4cb --- /dev/null +++ b/src/c128time.c @@ -0,0 +1,26 @@ +#include +#include +#include +#include "general.h" + +char *get_time() { + long int h = PEEK(0x00A0) * 65536, + m = PEEK(0x00A1) * 256, + s = PEEK(0x00A2); + static char buffer[9]; + BYTE hrs, min; + h = (h + m + s) / 60; + hrs = (h / 3600); + h -= (hrs * 3600); + min = (h / 60); + h -= (min * 60); + sprintf(buffer, "%02d:%02d:%02d", hrs, min, (int)h); + return buffer; +} + +void set_time(BYTE hrs, min, sec) { + long int added = ((long int)sec + ((long int)min * (long int)60) + ((long int)hrs * (long int)3600)) * (long int)60; + POKE(0x00A0, (BYTE)(added / 65536)); + POKE(0x00A1, (BYTE)(added / 256)); + POKE(0x00A2, (BYTE)added); +} diff --git a/src/kasse.c b/src/kasse.c index 46d17bd..b000ed4 100644 --- a/src/kasse.c +++ b/src/kasse.c @@ -8,7 +8,7 @@ #include "config.h" #include "kasse.h" #include "credit_manager.h" -#include "time.h" +#include "c128time.h" // drucker 4 oder 5 // graphic 4,0,10 diff --git a/src/time.c b/src/time.c deleted file mode 100644 index 7b9f4cb..0000000 --- a/src/time.c +++ /dev/null @@ -1,26 +0,0 @@ -#include -#include -#include -#include "general.h" - -char *get_time() { - long int h = PEEK(0x00A0) * 65536, - m = PEEK(0x00A1) * 256, - s = PEEK(0x00A2); - static char buffer[9]; - BYTE hrs, min; - h = (h + m + s) / 60; - hrs = (h / 3600); - h -= (hrs * 3600); - min = (h / 60); - h -= (min * 60); - sprintf(buffer, "%02d:%02d:%02d", hrs, min, (int)h); - return buffer; -} - -void set_time(BYTE hrs, min, sec) { - long int added = ((long int)sec + ((long int)min * (long int)60) + ((long int)hrs * (long int)3600)) * (long int)60; - POKE(0x00A0, (BYTE)(added / 65536)); - POKE(0x00A1, (BYTE)(added / 256)); - POKE(0x00A2, (BYTE)added); -} diff --git a/test/test.c b/test/test.c index ea603ed..4873d87 100644 --- a/test/test.c +++ b/test/test.c @@ -13,18 +13,22 @@ int main(){ char euro[10]; load_items(); load_state(); - for (i=0; i < num_items; ++i) { - cprintf("%x: %s (%s, %d mal)\n", i, status[i].item_name, format_euro(euro, 9, status[i].price), status[i].times_sold); - status[i].times_sold+=10; + for (i=0; i < status.num_items; ++i) { + cprintf("%x: %s (%s, %d mal)\n", + i, status.status[i].item_name, format_euro(euro, 9, status.status[i].price), + status.status[i].times_sold); + status.status[i].times_sold += 10; } save_state(); load_items(); load_state(); - for (i=0; i < num_items; ++i) { - cprintf("%x: %s (%s, %d mal)\n", i, status[i].item_name, format_euro(euro, 9, status[i].price), status[i].times_sold); + for (i=0; i < status.num_items; ++i) { + cprintf("%x: %s (%s, %d mal)\n", + i, status.status[i].item_name, format_euro(euro, 9, status.status[i].price), + status.status[i].times_sold); } - cprintf("strlen(%s)==%d\n", status[1].item_name, strlen(status[1].item_name)); - cprintf("%d %d %d\n", status[1].item_name[0], '\r', '\n'); + cprintf("strlen(%s)==%d\n", status.status[1].item_name, strlen(status.status[1].item_name)); + cprintf("%d %d %d\n", status.status[1].item_name[0], '\r', '\n'); }