2 * RGB2R-C128-Kassenprogramm
3 * (c) 2007 phil_fry, sECuRE, sur5r
4 * See LICENSE for license information
19 /* undocumented function which scratches files */
20 unsigned char __fastcall__ _sysremove(const char *name);
22 unsigned long int money = 0;
23 unsigned long int items_sold = 0;
24 BYTE printer_port = 4;
25 static bool items_exists = false;
26 static bool credits_exists = false;
27 struct status_array_t status;
28 struct credits_array_t credits;
31 * Checks if items/credits-files are existing to avoid having to recover
32 * the error state of the drive (we'd have to if we would just access the
36 static void lookup_needed_files() {
38 struct cbm_dirent *dirent;
40 if (cbm_opendir(lfn, (BYTE)8) != 0) {
41 cprintf("could not open directory\r\n");
44 while (cbm_readdir(lfn, dirent) == 0) {
45 if (strncmp(dirent->name, "log", 3) == 0)
47 if (strcasecmp(dirent->name, "items") == 0)
49 if (strcasecmp(dirent->name, "credits") == 0)
50 credits_exists = true;
57 cbm_load("items", (BYTE)8, &status);
59 memset(&status, 0, sizeof(struct status_array_t));
64 cbm_load("credits", (BYTE)8, &credits);
66 memset(&credits, 0, sizeof(struct credits_array_t));
72 cbm_save("items", (BYTE)8, &status, sizeof(struct status_array_t));
78 _sysremove("credits");
79 cbm_save("credits", (BYTE)8, &credits, sizeof(struct credits_array_t));
80 credits_exists = true;
84 lookup_needed_files();