void UnArchive(SYM_STR Filename) { SYM_ENTRY *SymPtr = NULL; HSym hsym = SymFind(Filename); SymPtr = DerefSym (hsym); if (SymPtr->flags.bits.archived) EM_moveSymFromExtMem(Filename, HS_NULL); }
void UnArchive(const char *Filename) { SYM_ENTRY *SymPtr = NULL; HSym hsym = SymFind(SYMSTR(Filename)); SymPtr = DerefSym (hsym); if (SymPtr->flags.bits.archived) EM_moveSymFromExtMem(SYMSTR(Filename), HS_NULL); }
void Archive(SYM_STR Filename) { SYM_ENTRY *SymPtr = NULL; HSym hsym = SymFind(Filename); SymPtr = DerefSym (hsym); if (EM_findEmptySlot(*Get_Data_Ptr(Filename, -2)) == NULL) return; // Make sure Garbage Collection will not occur if (!SymPtr->flags.bits.archived) EM_moveSymToExtMem(Filename, HS_NULL); }
// Saves all of the Team Data into the External File "hockteam" void Save_Teams(void) { short Size = sizeof(Names[g->No_Teams[0]]) + sizeof(Names[g->No_Teams[1]]) + 11; char *Base; HANDLE h; /* "hockteam" File Layout: unsigned short Size; unsigned char No1; unsigned char No2; Names Western[g->No_Teams[0]]; Names Eastern[g->No_Teams[1]]; char Zero1; char Type[4]; char Zero2; char Tag; */ UnArchive(SYMSTR_CONST("hockteam")); // Make sure that before writing to the file, it is not archived if ((h = HeapAlloc(Size)) == H_NULL) { Archive(SYMSTR_CONST("hockteam")); return; } if ((Base = HeapDeref(DerefSym(SymAdd(SYMSTR_CONST("hockteam")))->handle = h)) == (void*)0xFFFFFFFF) { HeapFree(h); return; } // Write data to "hockteam" file *(short*)Base = Size - 2; Base += 2; *Base++ = g->No_Teams[0]; *Base++ = g->No_Teams[1]; memcpy(Base, Western, sizeof(Names[g->No_Teams[0]])); Base += sizeof(Names[g->No_Teams[0]]); memcpy(Base, Eastern, sizeof(Names[g->No_Teams[1]])); Base += sizeof(Names[g->No_Teams[1]]); *Base++ = 0; strcpy(Base, "Team"); *(Base + 5) = OTH_TAG; Archive(SYMSTR_CONST("hockteam")); // Automatically Archive the team file in case of a crash }
// Saves the Difficulty and Time Limit Settings void Save_Config(void) { //unsigned char Extension[] = { 0, 'c', 'f', 'g', 0, OTH_TAG }; unsigned short Size = 11 + sizeof(RowKey[8]); char *Base; HANDLE h; if (g->Speed < 1 || g->Speed > 15) g->Speed = 7; /* "hockycfg" File Layout: unsigned short Size; char Config[3 + sizeof(RowKey[11])]; char Zero1; char Type[3]; char Zero2; char Tag; */ UnArchive(SYMSTR_CONST("hockycfg")); // Make sure that before writing to the file, it is not archived if ((h = HeapAlloc(Size)) == H_NULL) return; // Note: HeapDeref(H_NULL) == 0xFFFFFFFF. if ((Base = HeapDeref(DerefSym(SymAdd(SYMSTR_CONST("hockycfg")))->handle = h)) == (void*)0xFFFFFFFF) { HeapFree(h); return; } // Write data to "hockycfg" file *(short*)Base = Size - 2; Base += 2; memcpy(Base, &g->Keys, 3 + sizeof(RowKey[8])); Base += 3 + sizeof(RowKey[8]); *Base++ = 0; strcpy(Base, "cfg"); *(Base + 4) = OTH_TAG; Archive(SYMSTR_CONST("hockycfg")); // Automatically Archive the config file in case of a crash }
//good for a quick estimate, but will be wrong //if user puts anything other than song files //into SONGFOLDER. Assumes SongFolderExists. short CountSongs(void) { return FolderCount(DerefSym(SymFindHome(SONGFOLDER))); }