Skip to content

Commit

Permalink
refactor itemz from separate program into the kasse program
Browse files Browse the repository at this point in the history
fixes #18

related to issue #30
  • Loading branch information
stapelberg committed Jun 10, 2022
1 parent 7ac9f79 commit 62aba6c
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 40 deletions.
10 changes: 3 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ CFLAGS= -I include -t c128 -g

.PHONY: clean dist-clean format

all: kasse itemz cat
all: kasse cat

build/%.o: src/%.c ${INCLUDES}
${CC} ${CFLAGS} -O $< -o build/$(addsuffix .s,$(shell basename $< .c))
Expand All @@ -32,10 +32,7 @@ include/version.h: .git/index
include/charset_umlauts.h: assets/umlauts.pbm
./util/mkfont assets/umlauts.pbm chars_umlauts > $@

kasse: build/config.o build/kasse.o build/general.o build/credit_manager.o build/c128time.o build/print.o build/vdc_patch_charset.o build/vdc_util.o build/globals.o build/bcd2dec.o
${LD} -Ln $@.lbl -t c128 $^ -o $@

itemz: build/config.o build/itemz.o build/general.o build/credit_manager.o build/c128time.o build/print.o build/globals.o build/bcd2dec.o build/vdc_util.o
kasse: build/config.o build/kasse.o build/itemz.o build/general.o build/credit_manager.o build/c128time.o build/print.o build/vdc_patch_charset.o build/vdc_util.o build/globals.o build/bcd2dec.o
${LD} -Ln $@.lbl -t c128 $^ -o $@

cat: build/general.o build/cat.o build/config.o build/print.o build/globals.o
Expand All @@ -50,7 +47,6 @@ ascii: build/print_ascii.o
package: all
c1541 -format "${GV}",KA d71 kasse.d71
c1541 -attach kasse.d71 -write kasse
c1541 -attach kasse.d71 -write itemz
[ -e credits ] && c1541 -attach kasse.d71 -write credits || exit 0
[ -e items ] && c1541 -attach kasse.d71 -write items || exit 0

Expand All @@ -67,7 +63,7 @@ clean:
rm -rf build/*.o build/*.s test/test

dist-clean: clean
rm -f kasse kasse.lbl itemz itemz.lbl cat cat.lbl kasse.d71
rm -f kasse kasse.lbl cat cat.lbl kasse.d71

format:
clang-format-3.9 -i **/*.[ch]
Expand Down
6 changes: 6 additions & 0 deletions include/itemz.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#ifndef ITEMZ_H
#define ITEMZ_H

void itemz_manager(void);

#endif /* ITEMZ_H */
2 changes: 1 addition & 1 deletion src/credit_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ static void delete_credit(char *nickname) {
return;
}

void credit_manager() {
void credit_manager(void) {
char nickname[NICKNAME_MAX_LEN + 1];
char *c;
while (1) {
Expand Down
39 changes: 8 additions & 31 deletions src/itemz.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ static void itemz_print_screen(void) {

clrscr();
textcolor(TC_CYAN);
cprintf("itemz (" KASSE_AUTHORS ") v:" GV "\r\n\r\n");
cprintf("itemz_manager (" KASSE_AUTHORS ") v:" GV "\r\n\r\n");
textcolor(TC_LIGHT_GRAY);
cprintf("Datei: ITEMS\r\n\r\n");
for (i = 0; i < max(status.num_items, 15); i++) {
Expand All @@ -39,12 +39,11 @@ static void itemz_print_screen(void) {

cprintf("\r\n");
MENU_KEY(" n", "Neu");
MENU_KEY(" d", "L" oUML "schen");
MENU_KEY(" d", "L" oUML "schen");
MENU_KEY(" s", "Speichern");
MENU_KEY(" g", "Guthabenverwaltung");
cprintf("\r\n");
MENU_KEY(" q", "Beenden");
MENU_KEY(" r", "Reset des Verkauft-Z" aUML "hlers");
MENU_KEY(" z", "Zur" uUML "ck");
MENU_KEY(" r", "Reset des Verkauft-Z" aUML "hlers");
cprintf("\r\n");
}

Expand Down Expand Up @@ -115,7 +114,7 @@ static void reset_counters(void) {
}
}

static void itemz_manager() {
void itemz_manager() {
char *c;
while (1) {
itemz_print_screen();
Expand All @@ -133,34 +132,12 @@ static void itemz_manager() {
case 'r':
reset_counters();
break;
case 'g':
return; // switch to credit mode
case 'q':
exit(0);
case 'z':
save_items();
return;
default:
cprintf("Unbekannter Befehl, druecke RETURN...\r\n");
cget_return();
}
}
}

int main(void) {
videomode(VIDEOMODE_80x25);

/* clock CPU at double the speed (a whopping 2 Mhz!) */
fast();

credits.num_items = 0;
status.num_items = 0;
cprintf("itemz loading...\n");
load_config();
cprintf("itemz: loading ITEMS...\n");
load_items();
cprintf("itemz: loading CREDITS...\n");
load_credits();
while (1) {
itemz_manager();
credit_manager();
}
return 0;
}
7 changes: 6 additions & 1 deletion src/kasse.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "config.h"
#include "kasse.h"
#include "credit_manager.h"
#include "itemz.h"
#include "c128time.h"
#include "print.h"
#include "version.h"
Expand Down Expand Up @@ -84,7 +85,8 @@ static void print_screen(void) {
"\xC0\xC0\xC0\xC0\xC0\xC0\xC0\xC0\xC0\xC0\xC0\xC0\xC0\xC0\xC0\xC0\xBD"
"\r\n");

MENU_KEY(" s", "Daten sichern ");
MENU_KEY(" s", "Daten sichern ");
MENU_KEY("i", "Itemzverwaltung ");
MENU_KEY("g", "Guthabenverwaltung\r\n");
MENU_KEY(" z", "Zeit setzen ");
MENU_KEY("f", "Freitext verkaufen ");
Expand Down Expand Up @@ -368,6 +370,9 @@ int main(void) {
cget_return();
} else if (*c == 'g') {
credit_manager();
} else if (*c == 'i') {
itemz_manager();
load_items();
} else if (*c == 'z') {
set_time_interactive();
} else if (*c == 'q')
Expand Down

0 comments on commit 62aba6c

Please sign in to comment.