bool8 SNES9X_FreezeTo(void) { OSStatus err; FSRef ref; char filename[PATH_MAX + 1]; if (cartOpen) { if (NavFreezeTo(filename)) { err = FSPathMakeRef((unsigned char *) filename, &ref, nil); if (!err) FSDeleteObject(&ref); S9xFreezeGame(filename); ChangeTypeAndCreator(filename, 'SAVE', '~9X~'); err = FSPathMakeRef((unsigned char *) filename, &ref, nil); WriteThumbnailToResourceFork(&ref, 128, 120); return true; } } return false; }
void SNES9X_SaveSRAM (void) { const char *sramFilename; if (cartOpen) { sramFilename = S9xGetFilename(".srm", SRAM_DIR); Memory.SaveSRAM(sramFilename); ChangeTypeAndCreator(sramFilename, 'SRAM', '~9X~'); } }
static bool8 NPClientEndOpenROMImage(void) { OSStatus err; FSCatalogInfo info; FSRef cartRef; char filename[PATH_MAX + 1]; bool8 r; r = NavEndOpenROMImageSheet(&cartRef); if (!r) { cartOpen = false; return (false); } err = FSGetCatalogInfo(&cartRef, kFSCatInfoVolume, &info, nil, nil, nil); lockedROMMedia = IsLockedMedia(info.volume); Settings.ForceLoROM = (romDetect == kLoROMForce ); Settings.ForceHiROM = (romDetect == kHiROMForce ); Settings.ForceNotInterleaved = (interleaveDetect == kNoInterleaveForce); Settings.ForceInterleaved = (interleaveDetect == kInterleaveForce ); Settings.ForceInterleaved2 = (interleaveDetect == kInterleave2Force ); Settings.ForceInterleaveGD24 = (interleaveDetect == kInterleaveGD24 ); Settings.ForcePAL = (videoDetect == kPALForce ); Settings.ForceNTSC = (videoDetect == kNTSCForce ); Settings.ForceHeader = (headerDetect == kHeaderForce ); Settings.ForceNoHeader = (headerDetect == kNoHeaderForce ); Settings.ForceSuperFX = Settings.ForceNoSuperFX = false; Settings.ForceDSP1 = Settings.ForceNoDSP1 = false; Settings.ForceSA1 = Settings.ForceNoSA1 = false; Settings.ForceC4 = Settings.ForceNoC4 = false; Settings.ForceSDD1 = Settings.ForceNoSDD1 = false; GFX.InfoString = nil; GFX.InfoStringTimeout = 0; err = FSRefMakePath(&cartRef, (unsigned char *) filename, PATH_MAX); if (Memory.LoadROM(filename) /*&& (Memory.ROMCRC32 == nprominfo.crc32)*/) { ChangeTypeAndCreator(filename, 'CART', '~9X~'); SNES9X_InitSound(); cartOpen = true; return (true); } else { cartOpen = false; return (false); } }
static bool8 NPClientEndOpenROMImage (void) { OSStatus err; FSRef cartRef; char filename[PATH_MAX + 1]; bool8 r; r = NavEndOpenROMImageSheet(&cartRef); if (!r) { cartOpen = false; return (false); } CheckSaveFolder(&cartRef); Settings.ForceLoROM = (romDetect == kLoROMForce ); Settings.ForceHiROM = (romDetect == kHiROMForce ); Settings.ForceHeader = (headerDetect == kHeaderForce ); Settings.ForceNoHeader = (headerDetect == kNoHeaderForce ); Settings.ForceInterleaved = (interleaveDetect == kInterleaveForce ); Settings.ForceInterleaved2 = (interleaveDetect == kInterleave2Force ); Settings.ForceInterleaveGD24 = (interleaveDetect == kInterleaveGD24 ); Settings.ForceNotInterleaved = (interleaveDetect == kNoInterleaveForce); Settings.ForcePAL = (videoDetect == kPALForce ); Settings.ForceNTSC = (videoDetect == kNTSCForce ); GFX.InfoString = NULL; GFX.InfoStringTimeout = 0; S9xResetSaveTimer(true); err = FSRefMakePath(&cartRef, (unsigned char *) filename, PATH_MAX); SNES9X_InitSound(); if (Memory.LoadROM(filename) /*&& (Memory.ROMCRC32 == nprominfo.crc32)*/) { ChangeTypeAndCreator(filename, 'CART', '~9X~'); cartOpen = true; return (true); } else { cartOpen = false; return (false); } }
bool8 SNES9X_RecordMovie(void) { OSStatus err; FSRef ref; char filename[PATH_MAX + 1]; if (cartOpen) { if (NavRecordMovieTo(filename)) { err = FSPathMakeRef((unsigned char *) filename, &ref, nil); if (!err) FSDeleteObject(&ref); int r; uint8 opt = 0, mask = 0; for (int i = 0; i <= 4; i++) if (macRecordFlag & (1 << i)) mask |= (1 << i); if (macRecordFlag & (1 << 5)) opt |= MOVIE_OPT_FROM_RESET; else opt |= MOVIE_OPT_FROM_SNAPSHOT; r = S9xMovieCreate(filename, mask, opt, macRecordWChar, wcslen(macRecordWChar)); if (r == SUCCESS) { ChangeTypeAndCreator(filename, 'SMOV', '~9X~'); if ((macRecordFlag & (1 << 5)) == 0) { err = FSPathMakeRef((unsigned char *) filename, &ref, nil); WriteThumbnailToResourceFork(&ref, 128, 120); } SNES9X_Go(); return true; } } } return false; }
bool8 SNES9X_Freeze(void) { OSStatus err; FSRef ref; int which; const char *filename; if (cartOpen) { MacStopSound(); which = PromptFreezeDefrost(true); if (which >= 0) { filename = S9xGetFreezeFilename(which); err = FSPathMakeRef((unsigned char *) filename, &ref, nil); if (!err) FSDeleteObject(&ref); S9xFreezeGame(filename); ChangeTypeAndCreator(filename, 'SAVE', '~9X~'); err = FSPathMakeRef((unsigned char *) filename, &ref, nil); WriteThumbnailToResourceFork(&ref, 128, 120); SNES9X_Go(); MacStartSound(); return true; } else { MacStartSound(); return false; } } else return false; }
bool8 SNES9X_OpenCart(FSRef *inRef) { OSStatus err; FSCatalogInfo info; FSRef cartRef; char filename[PATH_MAX + 1]; DeinitGameWindow(); if (cartOpen) { SNES9X_SaveSRAM(); S9xSaveCheatFile(S9xGetFilename(".cht", PATCH_DIR)); } Settings.MouseMaster = true; Settings.SuperScopeMaster = true; Settings.MultiPlayer5Master = true; Settings.JustifierMaster = true; ResetCheatFinder(); if (!inRef) { DisableMenus(); if (!NavOpenROMImage(&cartRef)) { cartOpen = false; EnableMenus(); return false; } EnableMenus(); } else cartRef = *inRef; spcFileCount = pngFileCount = 0; err = FSGetCatalogInfo(&cartRef, kFSCatInfoVolume, &info, nil, nil, nil); lockedROMMedia = IsLockedMedia(info.volume); Settings.ForceLoROM = (romDetect == kLoROMForce ); Settings.ForceHiROM = (romDetect == kHiROMForce ); Settings.ForceNotInterleaved = (interleaveDetect == kNoInterleaveForce); Settings.ForceInterleaved = (interleaveDetect == kInterleaveForce ); Settings.ForceInterleaved2 = (interleaveDetect == kInterleave2Force ); Settings.ForceInterleaveGD24 = (interleaveDetect == kInterleaveGD24 ); Settings.ForcePAL = (videoDetect == kPALForce ); Settings.ForceNTSC = (videoDetect == kNTSCForce ); Settings.ForceHeader = (headerDetect == kHeaderForce ); Settings.ForceNoHeader = (headerDetect == kNoHeaderForce ); Settings.ForceSuperFX = Settings.ForceNoSuperFX = false; Settings.ForceDSP1 = Settings.ForceNoDSP1 = false; Settings.ForceSA1 = Settings.ForceNoSA1 = false; Settings.ForceC4 = Settings.ForceNoC4 = false; Settings.ForceSDD1 = Settings.ForceNoSDD1 = false; GFX.InfoString = nil; GFX.InfoStringTimeout = 0; err = FSRefMakePath(&cartRef, (unsigned char *) filename, PATH_MAX); if (Memory.LoadROM(filename)) { cartOpen = true; SNES9X_InitSound(); SNES9X_LoadSRAM(); ChangeTypeAndCreator(filename, 'CART', '~9X~'); AddRecentItem(&cartRef); BuildRecentMenu(); for (int a = 0; a < MAC_MAX_PLAYERS; a++) for (int b = 0; b < 12; b++) autofireRec[a].nextTime[b] = 0; return true; } else { cartOpen = false; return false; } }
bool8 SNES9X_OpenCart (FSRef *inRef) { OSStatus err; FSRef cartRef; char filename[PATH_MAX + 1]; DeinitGameWindow(); if (cartOpen) { SNES9X_SaveSRAM(); S9xResetSaveTimer(false); S9xSaveCheatFile(S9xGetFilename(".cht", CHEAT_DIR)); } ResetCheatFinder(); if (!inRef) { if (!NavOpenROMImage(&cartRef)) { cartOpen = false; return (false); } } else cartRef = *inRef; spcFileCount = pngFileCount = 0; CheckSaveFolder(&cartRef); Settings.ForceLoROM = (romDetect == kLoROMForce ); Settings.ForceHiROM = (romDetect == kHiROMForce ); Settings.ForceHeader = (headerDetect == kHeaderForce ); Settings.ForceNoHeader = (headerDetect == kNoHeaderForce ); Settings.ForceInterleaved = (interleaveDetect == kInterleaveForce ); Settings.ForceInterleaved2 = (interleaveDetect == kInterleave2Force ); Settings.ForceInterleaveGD24 = (interleaveDetect == kInterleaveGD24 ); Settings.ForceNotInterleaved = (interleaveDetect == kNoInterleaveForce); Settings.ForcePAL = (videoDetect == kPALForce ); Settings.ForceNTSC = (videoDetect == kNTSCForce ); GFX.InfoString = NULL; GFX.InfoStringTimeout = 0; S9xResetSaveTimer(true); err = FSRefMakePath(&cartRef, (unsigned char *) filename, PATH_MAX); SNES9X_InitSound(); if (Memory.LoadROM(filename)) { cartOpen = true; SNES9X_LoadSRAM(); ChangeTypeAndCreator(filename, 'CART', '~9X~'); AddRecentItem(&cartRef); BuildRecentMenu(); ApplyNSRTHeaderControllers(); for (int a = 0; a < MAC_MAX_PLAYERS; a++) for (int b = 0; b < 12; b++) autofireRec[a].nextTime[b] = 0; return (true); } else { cartOpen = false; return (false); } }
bool8 SNES9X_OpenMultiCart (void) { Boolean r; char cart[2][PATH_MAX + 1]; DeinitGameWindow(); if (cartOpen) { SNES9X_SaveSRAM(); S9xResetSaveTimer(false); S9xSaveCheatFile(S9xGetFilename(".cht", CHEAT_DIR)); } ResetCheatFinder(); if (!MultiCartDialog()) { cartOpen = false; return (false); } spcFileCount = pngFileCount = 0; Settings.ForceHeader = (headerDetect == kHeaderForce ); Settings.ForceNoHeader = (headerDetect == kNoHeaderForce); Settings.ForcePAL = (videoDetect == kPALForce ); Settings.ForceNTSC = (videoDetect == kNTSCForce ); GFX.InfoString = NULL; GFX.InfoStringTimeout = 0; S9xResetSaveTimer(true); for (int i = 0; i < 2; i++) { cart[i][0] = 0; if (multiCartPath[i]) r = CFStringGetCString(multiCartPath[i], cart[i], PATH_MAX, kCFStringEncodingUTF8); } SNES9X_InitSound(); if (Memory.LoadMultiCart(cart[0], cart[1])) { cartOpen = true; SNES9X_LoadSRAM(); for (int i = 0; i < 2; i++) { if (cart[i][0]) ChangeTypeAndCreator(cart[i], 'CART', '~9X~'); } ApplyNSRTHeaderControllers(); for (int a = 0; a < MAC_MAX_PLAYERS; a++) for (int b = 0; b < 12; b++) autofireRec[a].nextTime[b] = 0; return (true); } else { cartOpen = false; return (false); } }