Skip to content

Commit 62aba6c

Browse files
committed
refactor itemz from separate program into the kasse program
fixes #18 related to issue #30
1 parent 7ac9f79 commit 62aba6c

File tree

5 files changed

+24
-40
lines changed

5 files changed

+24
-40
lines changed

Makefile

+3-7
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ CFLAGS= -I include -t c128 -g
77

88
.PHONY: clean dist-clean format
99

10-
all: kasse itemz cat
10+
all: kasse cat
1111

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

35-
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
36-
${LD} -Ln $@.lbl -t c128 $^ -o $@
37-
38-
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
35+
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
3936
${LD} -Ln $@.lbl -t c128 $^ -o $@
4037

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

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

6965
dist-clean: clean
70-
rm -f kasse kasse.lbl itemz itemz.lbl cat cat.lbl kasse.d71
66+
rm -f kasse kasse.lbl cat cat.lbl kasse.d71
7167

7268
format:
7369
clang-format-3.9 -i **/*.[ch]

include/itemz.h

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#ifndef ITEMZ_H
2+
#define ITEMZ_H
3+
4+
void itemz_manager(void);
5+
6+
#endif /* ITEMZ_H */

src/credit_manager.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ static void delete_credit(char *nickname) {
172172
return;
173173
}
174174

175-
void credit_manager() {
175+
void credit_manager(void) {
176176
char nickname[NICKNAME_MAX_LEN + 1];
177177
char *c;
178178
while (1) {

src/itemz.c

+8-31
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ static void itemz_print_screen(void) {
2525

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

4040
cprintf("\r\n");
4141
MENU_KEY(" n", "Neu");
42-
MENU_KEY(" d", "L" oUML "schen");
42+
MENU_KEY(" d", "L" oUML "schen");
4343
MENU_KEY(" s", "Speichern");
44-
MENU_KEY(" g", "Guthabenverwaltung");
4544
cprintf("\r\n");
46-
MENU_KEY(" q", "Beenden");
47-
MENU_KEY(" r", "Reset des Verkauft-Z" aUML "hlers");
45+
MENU_KEY(" z", "Zur" uUML "ck");
46+
MENU_KEY(" r", "Reset des Verkauft-Z" aUML "hlers");
4847
cprintf("\r\n");
4948
}
5049

@@ -115,7 +114,7 @@ static void reset_counters(void) {
115114
}
116115
}
117116

118-
static void itemz_manager() {
117+
void itemz_manager() {
119118
char *c;
120119
while (1) {
121120
itemz_print_screen();
@@ -133,34 +132,12 @@ static void itemz_manager() {
133132
case 'r':
134133
reset_counters();
135134
break;
136-
case 'g':
137-
return; // switch to credit mode
138-
case 'q':
139-
exit(0);
135+
case 'z':
136+
save_items();
137+
return;
140138
default:
141139
cprintf("Unbekannter Befehl, druecke RETURN...\r\n");
142140
cget_return();
143141
}
144142
}
145143
}
146-
147-
int main(void) {
148-
videomode(VIDEOMODE_80x25);
149-
150-
/* clock CPU at double the speed (a whopping 2 Mhz!) */
151-
fast();
152-
153-
credits.num_items = 0;
154-
status.num_items = 0;
155-
cprintf("itemz loading...\n");
156-
load_config();
157-
cprintf("itemz: loading ITEMS...\n");
158-
load_items();
159-
cprintf("itemz: loading CREDITS...\n");
160-
load_credits();
161-
while (1) {
162-
itemz_manager();
163-
credit_manager();
164-
}
165-
return 0;
166-
}

src/kasse.c

+6-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include "config.h"
1717
#include "kasse.h"
1818
#include "credit_manager.h"
19+
#include "itemz.h"
1920
#include "c128time.h"
2021
#include "print.h"
2122
#include "version.h"
@@ -84,7 +85,8 @@ static void print_screen(void) {
8485
"\xC0\xC0\xC0\xC0\xC0\xC0\xC0\xC0\xC0\xC0\xC0\xC0\xC0\xC0\xC0\xC0\xBD"
8586
"\r\n");
8687

87-
MENU_KEY(" s", "Daten sichern ");
88+
MENU_KEY(" s", "Daten sichern ");
89+
MENU_KEY("i", "Itemzverwaltung ");
8890
MENU_KEY("g", "Guthabenverwaltung\r\n");
8991
MENU_KEY(" z", "Zeit setzen ");
9092
MENU_KEY("f", "Freitext verkaufen ");
@@ -368,6 +370,9 @@ int main(void) {
368370
cget_return();
369371
} else if (*c == 'g') {
370372
credit_manager();
373+
} else if (*c == 'i') {
374+
itemz_manager();
375+
load_items();
371376
} else if (*c == 'z') {
372377
set_time_interactive();
373378
} else if (*c == 'q')

0 commit comments

Comments
 (0)