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 files_existing = false;
24 struct status_array_t status;
25 struct credits_array_t credits;
28 * Checks if items/credits-files are existing to avoid having to recover
29 * the error state of the drive (we'd have to if we would just access the
33 bool lookup_needed_files() {
35 BYTE files_existing = 0;
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 ||
44 strcasecmp(dirent->name, "credits") == 0)
47 return (files_existing >= 2);
52 cbm_load("items", (BYTE)8, &status);
57 cbm_load("credits", (BYTE)8, &credits);
63 cbm_save("items", (BYTE)8, &status, sizeof(struct status_array_t));
64 files_existing = true;
69 _sysremove("credits");
70 cbm_save("credits", (BYTE)8, &credits, sizeof(struct credits_array_t));
71 files_existing = true;
75 files_existing = lookup_needed_files();