8 unsigned long int money = 0;
9 unsigned long int num_items = 0;
10 BYTE num_credit_items = 0;
11 unsigned long int items_sold = 0;
12 BYTE printer_port = 4;
13 struct status_t status[MAX_ITEMS+1];
14 struct credits_t credits[MAX_CREDIT_ITEMS+1];
20 char *sep, *newl = NULL, *lp;
25 if ((rc = cbm_open(lfn, (BYTE)8, (BYTE)0, "items,r")) != 0) {
26 cprintf("cannot open items\r\n");
29 for (num_items = 0; num_items < MAX_ITEMS && count > 0;) {
30 count = cbm_read(lfn, line, 79);
32 cprintf("read error\r\n");
39 if (newl < ((line+count)-1))
42 sep = strchr(lp, '=');
43 strncpy(status[num_items].item_name, lp, sep-lp);
46 status[num_items].price = atoi(sep+1);
47 status[num_items].times_sold = 0;
49 } while (newl = strchr(lp, '\n'));
55 * must be called after load_items()
65 rc=cbm_open(lfn, (BYTE)8, (BYTE)0, "state,r");
67 cprintf("cannot open state\r\n");
71 count=cbm_read(lfn,line,79);
73 sep = strchr(line, '=');
76 *(line + (sep-line)) = 0;
77 for (i=0; i< MAX_ITEMS; i++) {
78 if (strcmp(line, status[i].item_name)==0) {
79 status[i].times_sold = atoi(sep+1);
95 rc=cbm_open(lfn, (BYTE)8, (BYTE)0, "state,w");
97 c128_perror(23, "cannot open state file");
100 for (i=0;i<num_items;i++)
103 size=sprintf(line, "%s=%d\n", status[i].item_name, status[i].times_sold);
104 cbm_write(lfn, line, size);
105 //fprintf(f, "%s=%d\n",status[i].item_name, status[i].times_sold);
115 f = fopen("state", "r");
116 len = fread(buf, 1, 128, f);
117 cprintf("read %d bytes from state\n", len);
120 printf("%x ", buf[i]);