Ejemplo n.º 1
0
global void KRestartGame()
{
	/* Get rid of our internal stuff.
	 */
	static int varyList[] = {1,PALVARYKILL};

	DoSound(SProcess,FALSE);
	gameRestarted = 1;
	gameStarted = FALSE;

   /* Turn off PalVary */

   if (palVaryOn)
      {
		palVaryOn = FALSE;
		palettePercent = 0;
		KPalVary(varyList);
      }
	
	KillAllSounds();
	DisposeAllScripts();
	DisposeLastCast();
	/* SetDebug(FALSE); */
	/* free all memory */
	ResUnLoad(RES_MEM, ALL_IDS);

	/* Restore the heap and saved vars to what they were before the call
	 * to PMachine.
	 */
	RestartHeap();

	/* Regenerate the 'patchable resources' table */
	InitPatches();

	InitMenu();
	DoSound(SProcess,TRUE);
	DoSound(SSetReverb,0);
	reverbDefault = 0;

	/* Now restore the stack and restart the PMachine.
	 */
	longjmp(restartBuf, 1);
}
Ejemplo n.º 2
0
void AppCoreThread::ApplySettings( const Pcsx2Config& src )
{
	// Used to track the current game serial/id, and used to disable verbose logging of
	// applied patches if the game info hasn't changed.  (avoids spam when suspending/resuming
	// or using TAB or other things).
	static wxString curGameKey;

	// 'fixup' is the EmuConfig we're going to upload to the emulator, which very well may
	// differ from the user-configured EmuConfig settings.  So we make a copy here and then
	// we apply the commandline overrides and database gamefixes, and then upload 'fixup'
	// to the global EmuConfig.
	//
	// Note: It's important that we apply the commandline overrides *before* database fixes.
	// The database takes precedence (if enabled).

	Pcsx2Config fixup( src );

	const CommandlineOverrides& overrides( wxGetApp().Overrides );
	if( overrides.DisableSpeedhacks || !g_Conf->EnableSpeedHacks )
		fixup.Speedhacks.DisableAll();

	if( overrides.ApplyCustomGamefixes )
	{
		for (GamefixId id=GamefixId_FIRST; id < pxEnumEnd; ++id)
			fixup.Gamefixes.Set( id, overrides.Gamefixes.Get(id) );
	}
	else if( !g_Conf->EnableGameFixes )
		fixup.Gamefixes.DisableAll();

	wxString gameCRC;
	wxString gameSerial;
	wxString gamePatch;
	wxString gameFixes;
	wxString gameCheats;
	wxString gameWsHacks;

	wxString gameName;
	wxString gameCompat;

	int numberLoadedCheats;
	int numberLoadedWideScreenPatches;
	int numberDbfCheatsLoaded;

	if (ElfCRC) gameCRC.Printf( L"%8.8x", ElfCRC );
	if (!DiscSerial.IsEmpty()) gameSerial = L" [" + DiscSerial  + L"]";

	const wxString newGameKey( SysGetDiscID() );
	const bool verbose( newGameKey != curGameKey );
	curGameKey = newGameKey;

	if (!curGameKey.IsEmpty())
	{
		if (IGameDatabase* GameDB = AppHost_GetGameDatabase() )
		{
			Game_Data game;
			if (GameDB->findGame(game, curGameKey)) {
				int compat = game.getInt("Compat");
				gameName   = game.getString("Name");
				gameName  += L" (" + game.getString("Region") + L")";
				gameCompat = L" [Status = "+compatToStringWX(compat)+L"]";
			}

			if (EmuConfig.EnablePatches) {
				if (int patches = InitPatches(gameCRC, game)) {
					gamePatch.Printf(L" [%d Patches]", patches);
					if (verbose) Console.WriteLn(Color_Green, "(GameDB) Patches Loaded: %d", patches);
				}
				if (int fixes = loadGameSettings(fixup, game, verbose)) {
					gameFixes.Printf(L" [%d Fixes]", fixes);
				}
			}
		}
	}

	if (gameName.IsEmpty() && gameSerial.IsEmpty() && gameCRC.IsEmpty())
	{
		// if all these conditions are met, it should mean that we're currently running BIOS code.
		// Chances are the BiosChecksum value is still zero or out of date, however -- because
		// the BIos isn't loaded until after initial calls to ApplySettings.

		gameName = L"Booting PS2 BIOS... ";
	}

	ResetCheatsCount();

	//Till the end of this function, entry CRC will be 00000000
	if (!gameCRC.Length()) {
		if (EmuConfig.EnableWideScreenPatches || EmuConfig.EnableCheats) {
			Console.WriteLn(Color_Gray, "Patches: No CRC, using 00000000 instead.");
		}
		gameCRC = L"00000000";
	}

	// regular cheat patches
	if (EmuConfig.EnableCheats) {
		if (numberLoadedCheats = LoadCheats(gameCRC, GetCheatsFolder(), L"Cheats")) {
			gameCheats.Printf(L" [%d Cheats]", numberLoadedCheats);
		}
	}

	// wide screen patches
	if (EmuConfig.EnableWideScreenPatches) {
		if (numberLoadedWideScreenPatches = LoadCheats(gameCRC, GetCheatsWsFolder(), L"Widescreen hacks")) {
			gameWsHacks.Printf(L" [%d widescreen hacks]", numberLoadedWideScreenPatches);
		}
		else {
			// No ws cheat files found at the cheats_ws folder, try the ws cheats zip file.
			wxString cheats_ws_archive = Path::Combine(PathDefs::GetProgramDataDir(), wxFileName(L"cheats_ws.zip"));

			if (numberDbfCheatsLoaded = LoadCheatsFromZip(gameCRC, cheats_ws_archive)) {
				Console.WriteLn(Color_Green, "(Wide Screen Cheats DB) Patches Loaded: %d", numberDbfCheatsLoaded);
				gameWsHacks.Printf(L" [%d widescreen hacks]", numberDbfCheatsLoaded);
			}
		}
	}

	wxString consoleTitle = gameName + gameSerial;
	if (!gameSerial.IsEmpty()) {
		consoleTitle += L" [" + gameCRC.MakeUpper() + L"]";
	}
	consoleTitle += gameCompat + gameFixes + gamePatch + gameCheats + gameWsHacks;

	Console.SetTitle(consoleTitle);

	// Re-entry guard protects against cases where code wants to manually set core settings
	// which are not part of g_Conf.  The subsequent call to apply g_Conf settings (which is
	// usually the desired behavior) will be ignored.

	static int localc = 0;
	RecursionGuard guard( localc );
	if( guard.IsReentrant() ) return;
	if( fixup == EmuConfig ) return;

	if( m_ExecMode >= ExecMode_Opened )
	{
		ScopedCoreThreadPause paused_core;
		_parent::ApplySettings( fixup );
		paused_core.AllowResume();
	}
	else
	{
		_parent::ApplySettings( fixup );
	}
}