11 unsigned long int money = 0;
12 unsigned long int items_sold = 0;
13 BYTE printer_port = 4;
14 static bool files_existing = false;
15 struct status_array_t status;
16 struct credits_array_t credits;
19 * Checks if items/credits-files are existing to avoid having to recover
20 * the error state of the drive (we'd have to if we would just access the
24 bool lookup_needed_files() {
26 BYTE files_existing = 0;
27 struct cbm_dirent *dirent;
29 if (cbm_opendir(lfn, (BYTE)8) != 0) {
30 cprintf("could not open directory\r\n");
33 while (cbm_readdir(lfn, dirent) == 0)
34 if ( strcasecmp(dirent->name, "items") == 0 ||
35 strcasecmp(dirent->name, "credits") == 0)
38 return (files_existing >= 2);
43 cbm_load("items", (BYTE)8, &status);
48 cbm_load("credits", (BYTE)8, &credits);
52 cbm_save("items", (BYTE)8, &status, sizeof(struct status_array_t));
53 files_existing = true;
57 cbm_save("credits", (BYTE)8, &credits, sizeof(struct credits_array_t));
58 files_existing = true;
62 files_existing = lookup_needed_files();