7 unsigned long int money = 0;
8 unsigned long int num_items = 0;
9 BYTE num_credit_items = 0;
10 unsigned long int items_sold = 0;
11 BYTE printer_port = 4;
12 struct status_t status[MAX_ITEMS+1];
13 struct credits_t credits[MAX_CREDIT_ITEMS+1];
24 // cbm_open(lfn, (BYTE)8, (BYTE)0, "items,r");
25 f = fopen("items","r");
26 for (num_items=0; num_items < MAX_ITEMS && !feof(f); num_items++) {
28 sep = strchr(line, '=');
29 strncpy(status[num_items].item_name, line, sep-line);
30 status[num_items].price = atoi(sep+1);
31 status[num_items].times_sold = 0;
37 * must be called after load_items()
44 f = fopen("state", "r");
46 cprintf("cannot open state\r\n");
51 sep = strchr(line, '=');
54 *(line + (sep-line)) = 0;
55 for (i=0; i< MAX_ITEMS; i++) {
56 if (strcmp(line, status[i].item_name)==0) {
57 status[i].times_sold = atoi(sep+1);
69 f = fopen("state", "w");
71 c128_perror(23, "cannot open state file");
74 for (i=0;i<num_items;i++)
75 fprintf(f, "%s=%d\n",status[i].item_name, status[i].times_sold);
84 f = fopen("state", "r");
85 len = fread(buf, 1, 128, f);
86 printf("read %d bytes from state\n", len);
89 printf("%x ", buf[i]);
105 strcpy(status[0].item_name, "cola");
106 status[0].price = 230;
107 status[0].times_sold = 0;
108 strcpy(status[1].item_name, "mate");
109 status[1].price = 150;
110 status[1].times_sold = 0;
111 for (c = 2; c < MAX_ITEMS; ++c)
112 status[c].item_name[0] = 0;
116 status[0].times_sold=23;
117 status[1].times_sold=42;
120 void load_credits() {
126 void save_credits() {}