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];
22 // cbm_open(lfn, (BYTE)8, (BYTE)0, "items,r");
23 f = fopen("items","r");
24 for (num_items=0; num_items < MAX_ITEMS && !feof(f); num_items++) {
26 sep = strchr(line, '=');
27 strncpy(status[num_items].item_name, line, sep-line);
28 status[num_items].price = atoi(sep+1);
29 status[num_items].times_sold = 0;
35 * must be called after load_items()
42 f = fopen("state", "r");
44 cprintf("cannot open state\r\n");
49 sep = strchr(line, '=');
52 *(line + (sep-line)) = 0;
53 for (i=0; i< MAX_ITEMS; i++) {
54 if (strcmp(line, status[i].item_name)==0) {
55 status[i].times_sold = atoi(sep+1);
67 f = fopen("state", "w");
69 c128_perror(23, "cannot open state file");
72 for (i=0;i<num_items;i++)
73 fprintf(f, "%s=%d\n",status[i].item_name, status[i].times_sold);
82 f = fopen("state", "r");
83 len = fread(buf, 1, 128, f);
84 printf("read %d bytes from state\n", len);
87 printf("%x ", buf[i]);