Esempio n. 1
0
void SNES9X_Quit (void)
{
	DeinitGameWindow();

	if (cartOpen)
	{
		SNES9X_SaveSRAM();
		S9xResetSaveTimer(false);
		S9xSaveCheatFile(S9xGetFilename(".cht", CHEAT_DIR));
	}

	finished = true;
}
Esempio n. 2
0
void SNES9X_Quit(void)
{
	DeinitGameWindow();

	if (cartOpen)
	{
		SNES9X_SaveSRAM();
		S9xSaveCheatFile(S9xGetFilename(".cht", PATCH_DIR));
	}

	if (Settings.SPC7110)
		(*CleanUp7110)();
	
	finished = true;
}
Esempio n. 3
0
static bool8 NPClientBeginOpenROMImage(WindowRef window)
{
	CFStringRef			numRef, romRef, baseRef;
	CFMutableStringRef  mesRef;
	SInt32				replaceAt;
	bool8				r;

	DeinitGameWindow();

	if (cartOpen)
	{
		SNES9X_SaveSRAM();
		S9xSaveCheatFile(S9xGetFilename(".cht", PATCH_DIR));
	}
	
	cartOpen = false;
	
	Settings.MouseMaster = true;
	Settings.SuperScopeMaster = true;
	Settings.MultiPlayer5Master = true;
	Settings.JustifierMaster = true;

	ResetCheatFinder();
	
	romRef  = CFStringCreateWithCString(kCFAllocatorDefault, nprominfo.fname, MAC_PATH_ENCODING);
	numRef  = CFCopyLocalizedString(CFSTR("NPROMNamePos"), "1");
	baseRef = CFCopyLocalizedString(CFSTR("NPROMNameMes"), "NPROM");
	mesRef  = CFStringCreateMutableCopy(kCFAllocatorDefault, 0, baseRef);
	replaceAt = CFStringGetIntValue(numRef);
	CFStringReplace(mesRef, CFRangeMake(replaceAt - 1, 1), romRef);

	r = NavBeginOpenROMImageSheet(window, mesRef);

	CFRelease(mesRef);
	CFRelease(baseRef);
	CFRelease(numRef);
	CFRelease(romRef);
	
	return (r);
}
Esempio n. 4
0
static bool8 NPClientBeginOpenROMImage (WindowRef window)
{
	CFStringRef			numRef, romRef, baseRef;
	CFMutableStringRef	mesRef;
	SInt32				replaceAt;
	bool8				r;

	DeinitGameWindow();

	if (cartOpen)
	{
		SNES9X_SaveSRAM();
		S9xResetSaveTimer(false);
		S9xSaveCheatFile(S9xGetFilename(".cht", CHEAT_DIR));
	}

	cartOpen = false;

	ResetCheatFinder();

	romRef  = CFStringCreateWithCString(kCFAllocatorDefault, nprominfo.fname, kCFStringEncodingUTF8);
	numRef  = CFCopyLocalizedString(CFSTR("NPROMNamePos"), "1");
	baseRef = CFCopyLocalizedString(CFSTR("NPROMNameMes"), "NPROM");
	mesRef  = CFStringCreateMutableCopy(kCFAllocatorDefault, 0, baseRef);
	replaceAt = CFStringGetIntValue(numRef);
	CFStringReplace(mesRef, CFRangeMake(replaceAt - 1, 1), romRef);

	r = NavBeginOpenROMImageSheet(window, mesRef);

	CFRelease(mesRef);
	CFRelease(baseRef);
	CFRelease(numRef);
	CFRelease(romRef);

	return (r);
}
Esempio n. 5
0
void ConfigurePreferences (void)
{
	OSStatus	err;
	IBNibRef	nibRef;

	err = CreateNibReference(kMacS9XCFString, &nibRef);
	if (err == noErr)
	{
		WindowRef	tWindowRef;
		SInt32		oldVolume;
		uint32		oldPlaybackRate, oldInputRate, oldInterval, oldBufferSize;
		bool8		oldSynchronize, old16BitPlayback, oldStereo, oldReverseStereo, oldLagEnable;

		oldSynchronize   = Settings.SoundSync;
		old16BitPlayback = Settings.SixteenBitSound;
		oldStereo        = Settings.Stereo;
		oldReverseStereo = Settings.ReverseStereo;
		oldPlaybackRate  = Settings.SoundPlaybackRate;
		oldInputRate     = Settings.SoundInputRate;
		oldInterval      = macSoundInterval_ms;
		oldBufferSize    = macSoundBuffer_ms;
		oldLagEnable     = macSoundLagEnable;
		oldVolume        = macSoundVolume;

		if (cartOpen)
			DeinitGameWindow();

		S9xGraphicsDeinit();

		err = CreateWindowFromNib(nibRef, CFSTR("Preferences"), &tWindowRef);
		if (err == noErr)
		{
			EventHandlerUPP		tUPP, iUPP, aUPP, pUPP;
			EventHandlerRef		tRef, iRef, aRef, pRef;
			EventTypeSpec		tEvents[] = { { kEventClassControl, kEventControlHit          } },
								iEvents[] = { { kEventClassControl, kEventControlClick        } },
								aEvents[] = { { kEventClassControl, kEventControlClick        } },
								pEvents[] = { { kEventClassWindow,  kEventWindowClose         },
											  { kEventClassCommand, kEventCommandProcess      },
											  { kEventClassCommand, kEventCommandUpdateStatus } };
			ControlActionUPP	arrowsUPP, sliderUPP;
			HIViewRef			ctl, root;
			HIViewID			cid;
			MenuRef				menu;
			char				num[16];

			root = HIViewGetRoot(tWindowRef);

			cid.signature = 'tabs';
			cid.id = 128;
			HIViewFindByID(root, cid, &ctl);
			SetControl32BitValue(ctl, lastTabIndex);
			SelectTabPane(ctl, lastTabIndex);
			tUPP = NewEventHandlerUPP(TabEventHandler);
			err = InstallControlEventHandler(ctl, tUPP, GetEventTypeCount(tEvents), tEvents, 0, &tRef);

			cid.signature = 'snd_';
			cid.id = iNibSInputRateText;
			HIViewFindByID(root, cid, &ctl);
			iUPP = NewEventHandlerUPP(InputRateTextEventHandler);
			err = InstallControlEventHandler(ctl, iUPP, GetEventTypeCount(iEvents), iEvents, 0, &iRef);

			cid.signature = 'grap';
			cid.id = iNibGAspectRatioText;
			HIViewFindByID(root, cid, &ctl);
			aUPP = NewEventHandlerUPP(AspectRatioTextEventHandler);
			err = InstallControlEventHandler(ctl, aUPP, GetEventTypeCount(aEvents), aEvents, 0, &aRef);

			pUPP = NewEventHandlerUPP(PreferencesEventHandler);
			err = InstallWindowEventHandler(tWindowRef, pUPP, GetEventTypeCount(pEvents), pEvents, (void *) tWindowRef, &pRef);

			sliderUPP = NewControlActionUPP(InputRateSliderActionProc);
			arrowsUPP = NewControlActionUPP(LittleArrowsActionProc);

			cid.signature = 'grap';

			cid.id = iNibGFullScreen;
			HIViewFindByID(root, cid, &ctl);
			SetControl32BitValue(ctl, fullscreen);

			cid.id = iNibGSwitchResolution;
			HIViewFindByID(root, cid, &ctl);
			SetControl32BitValue(ctl, autoRes);

			cid.id = iNibGShowFrameRate;
			HIViewFindByID(root, cid, &ctl);
			SetControl32BitValue(ctl, Settings.DisplayFrameRate);

			cid.id = iNibGTransparency;
			HIViewFindByID(root, cid, &ctl);
			SetControl32BitValue(ctl, Settings.Transparency);

			cid.id = iNibGGL32bit;
			HIViewFindByID(root, cid, &ctl);
			SetControl32BitValue(ctl, gl32bit);

			cid.id = iNibGGLStretch;
			HIViewFindByID(root, cid, &ctl);
			SetControl32BitValue(ctl, glstretch);

			cid.id = iNibGVideoMode;
			HIViewFindByID(root, cid, &ctl);
			switch (videoMode)
			{
				case VIDEOMODE_BLOCKY:
					SetControl32BitValue(ctl, iOpenGLBlocky);
					break;

				case VIDEOMODE_TV:
					SetControl32BitValue(ctl, iOpenGLTVMode);
					break;

				case VIDEOMODE_SMOOTH:
					SetControl32BitValue(ctl, iOpenGLSmoothMode);
					break;

				case VIDEOMODE_BLEND:
					SetControl32BitValue(ctl, iOpenGLBlendMode);
					break;

				case VIDEOMODE_SUPEREAGLE:
					SetControl32BitValue(ctl, iOpenGLEagleMode);
					break;

				case VIDEOMODE_2XSAI:
					SetControl32BitValue(ctl, iOpenGL2xSAIMode);
					break;

				case VIDEOMODE_SUPER2XSAI:
					SetControl32BitValue(ctl, iOpenGLSuper2xSAIMode);
					break;

				case VIDEOMODE_EPX:
					SetControl32BitValue(ctl, iOpenGLEPXMode);
					break;

				case VIDEOMODE_HQ2X:
					SetControl32BitValue(ctl, iOpenGLHQ2xMode);
					break;

				case VIDEOMODE_HQ3X:
					SetControl32BitValue(ctl, iOpenGLHQ3xMode);
					break;

				case VIDEOMODE_HQ4X:
					SetControl32BitValue(ctl, iOpenGLHQ4xMode);
					break;

				case VIDEOMODE_NTSC_C:
					SetControl32BitValue(ctl, iOpenGLNTSC_CMode);
					break;

				case VIDEOMODE_NTSC_S:
					SetControl32BitValue(ctl, iOpenGLNTSC_SMode);
					break;

				case VIDEOMODE_NTSC_R:
					SetControl32BitValue(ctl, iOpenGLNTSC_RMode);
					break;

				case VIDEOMODE_NTSC_M:
					SetControl32BitValue(ctl, iOpenGLNTSC_MMode);
					break;

				case VIDEOMODE_NTSC_TV_C:
					SetControl32BitValue(ctl, iOpenGLNTSC_TV_CMode);
					break;

				case VIDEOMODE_NTSC_TV_S:
					SetControl32BitValue(ctl, iOpenGLNTSC_TV_SMode);
					break;

				case VIDEOMODE_NTSC_TV_R:
					SetControl32BitValue(ctl, iOpenGLNTSC_TV_RMode);
					break;

				case VIDEOMODE_NTSC_TV_M:
					SetControl32BitValue(ctl, iOpenGLNTSC_TV_MMode);
					break;
			}

			cid.id = iNibGDirectMP;
			HIViewFindByID(root, cid, &ctl);
			SetControl32BitValue(ctl, multiprocessor);

			cid.id = iNibGGLVSync;
			HIViewFindByID(root, cid, &ctl);
			SetControl32BitValue(ctl, vsync);

			cid.id = iNibGDrawOverscan;
			HIViewFindByID(root, cid, &ctl);
			SetControl32BitValue(ctl, drawoverscan);

			cid.id = iNibGScreenCurvature;
			HIViewFindByID(root, cid, &ctl);
			SetControl32BitValue(ctl, screencurvature);

			cid.id = iNibGCurvatureWarp;
			HIViewFindByID(root, cid, &ctl);
			SetControl32BitValue(ctl, macCurvatureWarp);
			if (!screencurvature)
				DeactivateControl(ctl);

			cid.id = iNibGAspectRatio;
			HIViewFindByID(root, cid, &ctl);
			SetControl32BitValue(ctl, macAspectRatio);
			if (!glstretch)
				DeactivateControl(ctl);

			cid.id = iNibGCIFilterEnable;
			HIViewFindByID(root, cid, &ctl);
			SetControl32BitValue(ctl, ciFilterEnable);
			if (systemVersion < 0x1040)
				DisableControl(ctl);

			if (systemVersion < 0x1040)
			{
				cid.id = iNibGCoreImageFilter;
				HIViewFindByID(root, cid, &ctl);
				DisableControl(ctl);
			}

			cid.signature = 'snd_';

			cid.id = iNibSSynchronize;
			HIViewFindByID(root, cid, &ctl);
			SetControl32BitValue(ctl, Settings.SoundSync);

			cid.id = iNibS16BitPlayback;
			HIViewFindByID(root, cid, &ctl);
			SetControl32BitValue(ctl, Settings.SixteenBitSound);
			DeactivateControl(ctl);

			cid.id = iNibSStereo;
			HIViewFindByID(root, cid, &ctl);
			SetControl32BitValue(ctl, Settings.Stereo);
			DeactivateControl(ctl);

			cid.id = iNibSReverseStereo;
			HIViewFindByID(root, cid, &ctl);
			SetControl32BitValue(ctl, Settings.ReverseStereo);
			DeactivateControl(ctl);

			cid.id = iNibSPlaybackRate;
			HIViewFindByID(root, cid, &ctl);
			switch (Settings.SoundPlaybackRate)
			{
				case 48000:
					SetControl32BitValue(ctl, 1);
					break;

				case 44100:
					SetControl32BitValue(ctl, 2);
					break;

				case 35000:
					SetControl32BitValue(ctl, 3);
					break;

				case 32000:
					SetControl32BitValue(ctl, 4);
					break;

				case 30000:
					SetControl32BitValue(ctl, 5);
					break;

				case 22050:
					SetControl32BitValue(ctl, 6);
					break;

				case 16000:
					SetControl32BitValue(ctl, 7);
					break;

				case 11025:
					SetControl32BitValue(ctl, 8);
					break;

				case 8000:
					SetControl32BitValue(ctl, 9);
					break;
			}

			cid.id = iNibSInputRate;
			HIViewFindByID(root, cid, &ctl);
			SetControl32BitValue(ctl, Settings.SoundInputRate);
			SetControlAction(ctl, sliderUPP);

			cid.id = iNibSInputRateText;
			HIViewFindByID(root, cid, &ctl);
			sprintf(num, "%d", Settings.SoundInputRate);
			SetStaticTextCStr(ctl, num, false);

			cid.id = iNibSInterval;
			HIViewFindByID(root, cid, &ctl);
			switch (macSoundInterval_ms)
			{
				case 8:
					SetControl32BitValue(ctl, 1);
					break;

				case 16:
					SetControl32BitValue(ctl, 2);
					break;

				case 32:
					SetControl32BitValue(ctl, 3);
					break;

				case 64:
					SetControl32BitValue(ctl, 4);
					break;

				case 0:
				default:
					SetControl32BitValue(ctl, 6);
					break;
			}

			cid.id = iNibSBufferSize;
			HIViewFindByID(root, cid, &ctl);
			SetControl32BitValue(ctl, macSoundBuffer_ms / 20);

			cid.id = iNibSAllowLag;
			HIViewFindByID(root, cid, &ctl);
			SetControl32BitValue(ctl, macSoundLagEnable);
			DeactivateControl(ctl);

			cid.id = iNibSVolume;
			HIViewFindByID(root, cid, &ctl);
			SetControl32BitValue(ctl, macSoundVolume);

			cid.signature = 'othe';

			cid.id = iNibOSaveFolder;
			HIViewFindByID(root, cid, &ctl);
			SetControl32BitValue(ctl, saveInROMFolder + 1);
			err = GetControlData(ctl, kControlMenuPart, kControlPopupButtonMenuRefTag, sizeof(MenuRef), &menu, NULL);
			if (saveFolderPath)
			{
				CFURLRef	url;
				CFStringRef	ref;

				url = CFURLCreateWithFileSystemPath(kCFAllocatorDefault, saveFolderPath, kCFURLPOSIXPathStyle, true);
				ref = CFURLCopyLastPathComponent(url);
				err = SetMenuItemTextWithCFString(menu, iNibSaveFolderNameMenuItem, ref);
				CFRelease(ref);
				CFRelease(url);
				EnableMenuItem(menu, iNibSaveFolderNameMenuItem);
			}
			else
			{
				CFStringRef	ref;

				ref = CFCopyLocalizedString(CFSTR("NoneSelected"), "NoneSelected");
				err = SetMenuItemTextWithCFString(menu, iNibSaveFolderNameMenuItem, ref);
				CFRelease(ref);
				DisableMenuItem(menu, iNibSaveFolderNameMenuItem);
			}

			cid.id = iNibOAutoSaveInterval;
			HIViewFindByID(root, cid, &ctl);
			sprintf(num, "%d", Settings.AutoSaveDelay);
			SetEditTextCStr(ctl, num, false);

			cid.signature = 'msc2';

			cid.id = iNibMCPUCycles;
			HIViewFindByID(root, cid, &ctl);
			sprintf(num, "%" PRIi32, Settings.HDMATimingHack);
			SetEditTextCStr(ctl, num, false);

			cid.id = iNibMTurboSkipArrows;
			HIViewFindByID(root, cid, &ctl);
			SetControl32BitValue(ctl, macFastForwardRate);
			SetControlAction(ctl, arrowsUPP);

			cid.id = iNibMTurboSkipText;
			HIViewFindByID(root, cid, &ctl);
			sprintf(num, "%d", macFastForwardRate);
			SetStaticTextCStr(ctl, num, false);

			cid.id = iNibMFrameSkip;
			HIViewFindByID(root, cid, &ctl);
			SetControl32BitValue(ctl, macFrameSkip + 2);

			cid.id = iNibMAllowInvalidVRAMAccess;
			HIViewFindByID(root, cid, &ctl);
			SetControl32BitValue(ctl, !Settings.BlockInvalidVRAMAccessMaster);

			cid.id = iNibMAllowSpecificGameHacks;
			HIViewFindByID(root, cid, &ctl);
			SetControl32BitValue(ctl, !Settings.DisableGameSpecificHacks);

			cid.signature = 'osx_';

			cid.id = iNibXStartOpenDialog;
			HIViewFindByID(root, cid, &ctl);
			SetControl32BitValue(ctl, startopendlog);

			cid.id = iNibXShowTimeInFrz;
			HIViewFindByID(root, cid, &ctl);
			SetControl32BitValue(ctl, showtimeinfrz);

			cid.id = iNibXMusicBoxMode;
			HIViewFindByID(root, cid, &ctl);
			SetControl32BitValue(ctl, musicboxmode);

			cid.id = iNibXEnableToggle;
			HIViewFindByID(root, cid, &ctl);
			SetControl32BitValue(ctl, enabletoggle);

			cid.id = iNibXSaveWindowPos;
			HIViewFindByID(root, cid, &ctl);
			SetControl32BitValue(ctl, savewindowpos);

			cid.id = iNibXUseIPSPatch;
			HIViewFindByID(root, cid, &ctl);
			SetControl32BitValue(ctl, !Settings.NoPatch);

			cid.id = iNibXOnScreenInfo;
			HIViewFindByID(root, cid, &ctl);
			SetControl32BitValue(ctl, onscreeninfo);

			cid.id = iNibXInactiveMode;
			HIViewFindByID(root, cid, &ctl);
			SetControl32BitValue(ctl, inactiveMode);

			cid.id = iNibXBSXBootup;
			HIViewFindByID(root, cid, &ctl);
			SetControl32BitValue(ctl, Settings.BSXBootup);

			MoveWindowPosition(tWindowRef, kWindowPreferences, false);
			ShowWindow(tWindowRef);
			err = RunAppModalLoopForWindow(tWindowRef);
			HideWindow(tWindowRef);
			SaveWindowPosition(tWindowRef, kWindowPreferences);

			cid.signature = 'grap';

			cid.id = iNibGFullScreen;
			HIViewFindByID(root, cid, &ctl);
			fullscreen = GetControl32BitValue(ctl) ? true : false;

			cid.id = iNibGSwitchResolution;
			HIViewFindByID(root, cid, &ctl);
			autoRes = GetControl32BitValue(ctl) ? true : false;

			cid.id = iNibGShowFrameRate;
			HIViewFindByID(root, cid, &ctl);
			Settings.DisplayFrameRate = GetControl32BitValue(ctl) ? true : false;

			cid.id = iNibGTransparency;
			HIViewFindByID(root, cid, &ctl);
			Settings.Transparency = GetControl32BitValue(ctl) ? true : false;

			cid.id = iNibGGL32bit;
			HIViewFindByID(root, cid, &ctl);
			gl32bit = GetControl32BitValue(ctl) ? true : false;

			cid.id = iNibGGLStretch;
			HIViewFindByID(root, cid, &ctl);
			glstretch = GetControl32BitValue(ctl) ? true : false;

			cid.id = iNibGVideoMode;
			HIViewFindByID(root, cid, &ctl);
			switch (GetControl32BitValue(ctl))
			{
				case iOpenGLBlocky:
					drawingMethod = kDrawingOpenGL;
					videoMode = VIDEOMODE_BLOCKY;
					break;

				case iOpenGLTVMode:
					drawingMethod = kDrawingBlitGL;
					videoMode = VIDEOMODE_TV;
					break;

				case iOpenGLSmoothMode:
					drawingMethod = kDrawingOpenGL;
					videoMode = VIDEOMODE_SMOOTH;
					break;

				case iOpenGLBlendMode:
					drawingMethod = kDrawingBlitGL;
					videoMode = VIDEOMODE_BLEND;
					break;

				case iOpenGLEagleMode:
					drawingMethod = kDrawingBlitGL;
					videoMode = VIDEOMODE_SUPEREAGLE;
					break;

				case iOpenGL2xSAIMode:
					drawingMethod = kDrawingBlitGL;
					videoMode = VIDEOMODE_2XSAI;
					break;

				case iOpenGLSuper2xSAIMode:
					drawingMethod = kDrawingBlitGL;
					videoMode = VIDEOMODE_SUPER2XSAI;
					break;

				case iOpenGLEPXMode:
					drawingMethod = kDrawingBlitGL;
					videoMode = VIDEOMODE_EPX;
					break;

				case iOpenGLHQ2xMode:
					drawingMethod = kDrawingBlitGL;
					videoMode = VIDEOMODE_HQ2X;
					break;

				case iOpenGLHQ3xMode:
					drawingMethod = kDrawingBlitGL;
					videoMode = VIDEOMODE_HQ3X;
					break;

				case iOpenGLHQ4xMode:
					drawingMethod = kDrawingBlitGL;
					videoMode = VIDEOMODE_HQ4X;
					break;

				case iOpenGLNTSC_CMode:
					drawingMethod = kDrawingBlitGL;
					videoMode = VIDEOMODE_NTSC_C;
					S9xBlitNTSCFilterSet(&snes_ntsc_composite);
					break;

				case iOpenGLNTSC_SMode:
					drawingMethod = kDrawingBlitGL;
					videoMode = VIDEOMODE_NTSC_S;
					S9xBlitNTSCFilterSet(&snes_ntsc_svideo);
					break;

				case iOpenGLNTSC_RMode:
					drawingMethod = kDrawingBlitGL;
					videoMode = VIDEOMODE_NTSC_R;
					S9xBlitNTSCFilterSet(&snes_ntsc_rgb);
					break;

				case iOpenGLNTSC_MMode:
					drawingMethod = kDrawingBlitGL;
					videoMode = VIDEOMODE_NTSC_M;
					S9xBlitNTSCFilterSet(&snes_ntsc_monochrome);
					break;

				case iOpenGLNTSC_TV_CMode:
					drawingMethod = kDrawingBlitGL;
					videoMode = VIDEOMODE_NTSC_TV_C;
					S9xBlitNTSCFilterSet(&snes_ntsc_composite);
					break;

				case iOpenGLNTSC_TV_SMode:
					drawingMethod = kDrawingBlitGL;
					videoMode = VIDEOMODE_NTSC_TV_S;
					S9xBlitNTSCFilterSet(&snes_ntsc_svideo);
					break;

				case iOpenGLNTSC_TV_RMode:
					drawingMethod = kDrawingBlitGL;
					videoMode = VIDEOMODE_NTSC_TV_R;
					S9xBlitNTSCFilterSet(&snes_ntsc_rgb);
					break;

				case iOpenGLNTSC_TV_MMode:
					drawingMethod = kDrawingBlitGL;
					videoMode = VIDEOMODE_NTSC_TV_M;
					S9xBlitNTSCFilterSet(&snes_ntsc_monochrome);
					break;
			}

			cid.id = iNibGDirectMP;
			HIViewFindByID(root, cid, &ctl);
			multiprocessor = GetControl32BitValue(ctl) ? true : false;

			cid.id = iNibGGLVSync;
			HIViewFindByID(root, cid, &ctl);
			vsync = GetControl32BitValue(ctl) ? true : false;

			cid.id = iNibGDrawOverscan;
			HIViewFindByID(root, cid, &ctl);
			drawoverscan = GetControl32BitValue(ctl) ? true : false;

			cid.id = iNibGScreenCurvature;
			HIViewFindByID(root, cid, &ctl);
			screencurvature = GetControl32BitValue(ctl) ? true : false;

			cid.id = iNibGCurvatureWarp;
			HIViewFindByID(root, cid, &ctl);
			macCurvatureWarp = GetControl32BitValue(ctl);

			cid.id = iNibGAspectRatio;
			HIViewFindByID(root, cid, &ctl);
			macAspectRatio = GetControl32BitValue(ctl);

			cid.id = iNibGCIFilterEnable;
			HIViewFindByID(root, cid, &ctl);
			ciFilterEnable = GetControl32BitValue(ctl) ? true : false;

			cid.signature = 'snd_';

			cid.id = iNibSSynchronize;
			HIViewFindByID(root, cid, &ctl);
			Settings.SoundSync = GetControl32BitValue(ctl) ? true : false;

			cid.id = iNibS16BitPlayback;
			HIViewFindByID(root, cid, &ctl);
			Settings.SixteenBitSound = GetControl32BitValue(ctl) ? true : false;

			cid.id = iNibSStereo;
			HIViewFindByID(root, cid, &ctl);
			Settings.Stereo = GetControl32BitValue(ctl) ? true : false;

			cid.id = iNibSReverseStereo;
			HIViewFindByID(root, cid, &ctl);
			Settings.ReverseStereo = GetControl32BitValue(ctl) ? true : false;

			cid.id = iNibSPlaybackRate;
			HIViewFindByID(root, cid, &ctl);
			switch (GetControl32BitValue(ctl))
			{
				case 1:
					Settings.SoundPlaybackRate = 48000;
					break;

				case 2:
					Settings.SoundPlaybackRate = 44100;
					break;

				case 3:
					Settings.SoundPlaybackRate = 35000;
					break;

				case 4:
					Settings.SoundPlaybackRate = 32000;
					break;

				case 5:
					Settings.SoundPlaybackRate = 30000;
					break;

				case 6:
					Settings.SoundPlaybackRate = 22050;
					break;

				case 7:
					Settings.SoundPlaybackRate = 16000;
					break;

				case 8:
					Settings.SoundPlaybackRate = 11025;
					break;

				case 9:
					Settings.SoundPlaybackRate = 8000;
					break;
			}

			cid.id = iNibSInputRate;
			HIViewFindByID(root, cid, &ctl);
			Settings.SoundInputRate = GetControl32BitValue(ctl);

			cid.id = iNibSInterval;
			HIViewFindByID(root, cid, &ctl);
			switch (GetControl32BitValue(ctl))
			{
				case 1:
					macSoundInterval_ms = 8;
					break;

				case 2:
					macSoundInterval_ms = 16;
					break;

				case 3:
					macSoundInterval_ms = 32;
					break;

				case 4:
					macSoundInterval_ms = 64;
					break;

				case 6:
				default:
					macSoundInterval_ms = 0;
					break;
			}

			cid.id = iNibSBufferSize;
			HIViewFindByID(root, cid, &ctl);
			macSoundBuffer_ms = GetControl32BitValue(ctl) * 20;

			cid.id = iNibSAllowLag;
			HIViewFindByID(root, cid, &ctl);
			macSoundLagEnable = GetControl32BitValue(ctl);

			cid.id = iNibSVolume;
			HIViewFindByID(root, cid, &ctl);
			macSoundVolume = GetControl32BitValue(ctl);

			cid.signature = 'othe';

			cid.id = iNibOSaveFolder;
			HIViewFindByID(root, cid, &ctl);
			saveInROMFolder = GetControl32BitValue(ctl) - 1;

			cid.id = iNibOAutoSaveInterval;
			HIViewFindByID(root, cid, &ctl);
			GetEditTextCStr(ctl, num);
			Settings.AutoSaveDelay = atoi(num);

			cid.signature = 'msc2';

			cid.id = iNibMCPUCycles;
			HIViewFindByID(root, cid, &ctl);
			GetEditTextCStr(ctl, num);
			Settings.HDMATimingHack = atoi(num);
			if ((Settings.HDMATimingHack <= 0) || (Settings.HDMATimingHack >= 200))
				Settings.HDMATimingHack = 100;

			cid.id = iNibMTurboSkipArrows;
			HIViewFindByID(root, cid, &ctl);
			macFastForwardRate = GetControl32BitValue(ctl);

			cid.id = iNibMFrameSkip;
			HIViewFindByID(root, cid, &ctl);
			macFrameSkip = GetControl32BitValue(ctl) - 2;

			cid.id = iNibMAllowInvalidVRAMAccess;
			HIViewFindByID(root, cid, &ctl);
			Settings.BlockInvalidVRAMAccessMaster = GetControl32BitValue(ctl) ? false : true;

			cid.id = iNibMAllowSpecificGameHacks;
			HIViewFindByID(root, cid, &ctl);
			Settings.DisableGameSpecificHacks = GetControl32BitValue(ctl) ? false : true;

			cid.signature = 'osx_';

			cid.id = iNibXStartOpenDialog;
			HIViewFindByID(root, cid, &ctl);
			startopendlog = GetControl32BitValue(ctl) ? true : false;

			cid.id = iNibXShowTimeInFrz;
			HIViewFindByID(root, cid, &ctl);
			showtimeinfrz = GetControl32BitValue(ctl) ? true : false;

			cid.id = iNibXMusicBoxMode;
			HIViewFindByID(root, cid, &ctl);
			musicboxmode = GetControl32BitValue(ctl);

			cid.id = iNibXEnableToggle;
			HIViewFindByID(root, cid, &ctl);
			enabletoggle = GetControl32BitValue(ctl) ? true : false;

			cid.id = iNibXSaveWindowPos;
			HIViewFindByID(root, cid, &ctl);
			savewindowpos = GetControl32BitValue(ctl) ? true : false;

			cid.id = iNibXUseIPSPatch;
			HIViewFindByID(root, cid, &ctl);
			Settings.NoPatch = GetControl32BitValue(ctl) ? false : true;

			cid.id = iNibXOnScreenInfo;
			HIViewFindByID(root, cid, &ctl);
			onscreeninfo = GetControl32BitValue(ctl) ? true : false;

			cid.id = iNibXInactiveMode;
			HIViewFindByID(root, cid, &ctl);
			inactiveMode = GetControl32BitValue(ctl);

			cid.id = iNibXBSXBootup;
			HIViewFindByID(root, cid, &ctl);
			Settings.BSXBootup = GetControl32BitValue(ctl) ? true : false;

			DisposeControlActionUPP(arrowsUPP);
			DisposeControlActionUPP(sliderUPP);

			err = RemoveEventHandler(pRef);
			DisposeEventHandlerUPP(pUPP);

			err = RemoveEventHandler(aRef);
			DisposeEventHandlerUPP(aUPP);

			err = RemoveEventHandler(iRef);
			DisposeEventHandlerUPP(iUPP);

			err = RemoveEventHandler(tRef);
			DisposeEventHandlerUPP(tUPP);

			CFRelease(tWindowRef);
		}

		DisposeNibReference(nibRef);

		S9xGraphicsInit();

		if (((oldSynchronize   != Settings.SoundSync        ) ||
			 (old16BitPlayback != Settings.SixteenBitSound  ) ||
			 (oldStereo        != Settings.Stereo           ) ||
			 (oldReverseStereo != Settings.ReverseStereo    ) ||
			 (oldPlaybackRate  != Settings.SoundPlaybackRate) ||
			 (oldInputRate     != Settings.SoundInputRate   ) ||
			 (oldInterval      != macSoundInterval_ms       ) ||
			 (oldBufferSize    != macSoundBuffer_ms         ) ||
			 (oldLagEnable     != macSoundLagEnable         ) ||
			 (oldVolume        != macSoundVolume            )) && cartOpen)
			SNES9X_InitSound();

		if (!fullscreen && cartOpen)
		{
			InitGameWindow();
			ShowWindow(gWindow);
		}

		if (cartOpen)
		{
			FSRef	ref;

			err = FSPathMakeRef((unsigned char *) Memory.ROMFilename, &ref, NULL);
			if (err == noErr)
				CheckSaveFolder(&ref);
		}
	}
}
Esempio n. 6
0
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;
	}
}
Esempio n. 7
0
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);
	}
}
Esempio n. 8
0
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);
	}
}