2 * RGB2R-C128-Kassenprogramm
3 * (c) 2007 phil_fry, sECuRE, sur5r
4 * See LICENSE for license information
17 /* undocumented function which scratches files */
18 unsigned char __fastcall__ _sysremove(const char *name);
20 unsigned long int money = 0;
21 unsigned long int items_sold = 0;
22 BYTE printer_port = 4;
23 static bool items_exists = false;
24 static bool credits_exists = false;
25 struct status_array_t status;
26 struct credits_array_t credits;
29 * Checks if items/credits-files are existing to avoid having to recover
30 * the error state of the drive (we'd have to if we would just access the
34 bool lookup_needed_files() {
36 struct cbm_dirent *dirent;
38 if (cbm_opendir(lfn, (BYTE)8) != 0) {
39 cprintf("could not open directory\r\n");
42 while (cbm_readdir(lfn, dirent) == 0) {
43 if (strcasecmp(dirent->name, "items") == 0)
45 if (strcasecmp(dirent->name, "credits") == 0)
46 credits_exists = true;
49 return credits_exists || items_exists;
54 cbm_load("items", (BYTE)8, &status);
56 memset(&status, 0, sizeof(struct status_array_t));
61 cbm_load("credits", (BYTE)8, &credits);
63 memset(&credits, 0, sizeof(struct credits_array_t));
69 cbm_save("items", (BYTE)8, &status, sizeof(struct status_array_t));
75 _sysremove("credits");
76 cbm_save("credits", (BYTE)8, &credits, sizeof(struct credits_array_t));
77 credits_exists = true;
81 lookup_needed_files();