11 /* undocumented function which scratches files */
12 unsigned char __fastcall__ _sysremove(const char *name);
14 unsigned long int money = 0;
15 unsigned long int items_sold = 0;
16 BYTE printer_port = 4;
17 static bool files_existing = false;
18 struct status_array_t status;
19 struct credits_array_t credits;
22 * Checks if items/credits-files are existing to avoid having to recover
23 * the error state of the drive (we'd have to if we would just access the
27 bool lookup_needed_files() {
29 BYTE files_existing = 0;
30 struct cbm_dirent *dirent;
32 if (cbm_opendir(lfn, (BYTE)8) != 0) {
33 cprintf("could not open directory\r\n");
36 while (cbm_readdir(lfn, dirent) == 0)
37 if ( strcasecmp(dirent->name, "items") == 0 ||
38 strcasecmp(dirent->name, "credits") == 0)
41 return (files_existing >= 2);
46 cbm_load("items", (BYTE)8, &status);
51 cbm_load("credits", (BYTE)8, &credits);
57 cbm_save("items", (BYTE)8, &status, sizeof(struct status_array_t));
58 files_existing = true;
63 _sysremove("credits");
64 cbm_save("credits", (BYTE)8, &credits, sizeof(struct credits_array_t));
65 files_existing = true;
69 files_existing = lookup_needed_files();