game settings/patches: don't apply acidentally to the bios

While c782b62 added much more reliable game game startup detection, the
settings system did not yet gain that knowledge, but typically that's OK.

Typically the settings (and patches) are loaded according to the current
CRC, which happens once on bios boot (with general settings) and then again
when the game starts, which includes game-specific fixes, patches, etc.

However, if the setting are changed (and therefore also applied) after
the game CRC is known but before the game starts, such as if the user
presses Tab to change framelimiter while at the bios, then until now it
was accidentally applying the game's settings while still at the bios.

This commit makes the settings routine know whether or not the game actually
started, and apply the generic/game settings accordingly.
This commit is contained in:
Avi Halachmi (:avih) 2016-07-29 20:55:58 +03:00
parent c782b6222c
commit e8e6d3bc77
4 changed files with 35 additions and 17 deletions

View File

@ -284,7 +284,7 @@ class CpuInitializer
public:
std::unique_ptr<CpuType> MyCpu;
ScopedExcept ExThrown;
CpuInitializer();
virtual ~CpuInitializer() throw();
@ -392,7 +392,7 @@ void SysMainMemory::ReserveAll()
m_ee.Reserve();
m_iop.Reserve();
m_vu.Reserve();
reserveNewVif(0);
reserveNewVif(1);
}
@ -444,7 +444,7 @@ void SysMainMemory::DecommitAll()
closeNewVif(0);
closeNewVif(1);
vtlb_Core_Free();
}
@ -653,20 +653,26 @@ u8* SysMmapEx(uptr base, u32 size, uptr bounds, const char *caller)
return Mem;
}
wxString SysGetBiosDiscID()
{
// FIXME: we should return a serial based on
// the BIOS being run (either a checksum of the BIOS roms, and/or a string based on BIOS
// region and revision).
return wxEmptyString;
}
// This function always returns a valid DiscID -- using the Sony serial when possible, and
// falling back on the CRC checksum of the ELF binary if the PS2 software being run is
// homebrew or some other serial-less item.
wxString SysGetDiscID()
{
if( !DiscSerial.IsEmpty() ) return DiscSerial;
if( !ElfCRC )
{
// FIXME: system is currently running the BIOS, so it should return a serial based on
// the BIOS being run (either a checksum of the BIOS roms, and/or a string based on BIOS
// region and revision).
return wxEmptyString;
// system is currently running the BIOS
return SysGetBiosDiscID();
}
return pxsFmt( L"%08x", ElfCRC );

View File

@ -87,20 +87,20 @@ namespace HostMemoryMap
// microVU0 recompiler code cache area (64mb)
static const uptr mVU1rec = 0x40000000;
#endif
}
// --------------------------------------------------------------------------------------
// SysMainMemory
// --------------------------------------------------------------------------------------
// This class provides the main memory for the virtual machines.
// This class provides the main memory for the virtual machines.
class SysMainMemory
{
protected:
eeMemoryReserve m_ee;
iopMemoryReserve m_iop;
vuMemoryReserve m_vu;
public:
SysMainMemory();
virtual ~SysMainMemory() throw();
@ -179,6 +179,7 @@ extern u8 *SysMmapEx(uptr base, u32 size, uptr bounds, const char *caller="Unnam
extern void vSyncDebugStuff( uint frame );
extern void NTFS_CompressFile( const wxString& file, bool compressStatus=true );
extern wxString SysGetBiosDiscID();
extern wxString SysGetDiscID();
extern SysMainMemory& GetVmMemory();

View File

@ -358,10 +358,16 @@ static void _ApplySettings( const Pcsx2Config& src, Pcsx2Config& fixup )
wxString gameCompat;
wxString gameMemCardFilter;
if (ElfCRC) gameCRC.Printf( L"%8.8x", ElfCRC );
if (!DiscSerial.IsEmpty()) gameSerial = L" [" + DiscSerial + L"]";
// The CRC can be known before the game actually starts (at the bios), so when
// we have the CRC but we're still at the bios and the settings are changed
// (e.g. the user presses TAB to speed up emulation), we don't want to apply the
// settings as if the game is already running (title, loadeding patches, etc).
bool ingame = (ElfCRC && (g_GameLoading || g_GameStarted));
if (ingame)
gameCRC.Printf( L"%8.8x", ElfCRC );
if (ingame && !DiscSerial.IsEmpty()) gameSerial = L" [" + DiscSerial + L"]";
const wxString newGameKey( SysGetDiscID() );
const wxString newGameKey(ingame ? SysGetDiscID() : SysGetBiosDiscID());
const bool verbose( newGameKey != curGameKey );
SetupPatchesCon(verbose);
@ -442,6 +448,11 @@ static void _ApplySettings( const Pcsx2Config& src, Pcsx2Config& fixup )
wxString consoleTitle = gameName + gameSerial;
consoleTitle += L" [" + gameCRC.MakeUpper() + L"]" + gameCompat + gameFixes + gamePatch + gameCheats + gameWsHacks;
Console.SetTitle(consoleTitle);
// It's possible then when we're booting, the bios loader will set a more detailed title
// with region, version, etc, thus overriding our patches status at the title. That's OK. Those
// users which want to know the status of the patches at the bios can check the console content.
// However, the bios loader sets the title once, so if any settings are changed and we're called
// (e.g. if the user presses tab to change the limiter), then the title will be set to consoleTitle.
}
// FIXME: This function is not for general consumption. Its only consumer (and

View File

@ -155,7 +155,7 @@ static void LoadBiosVersion( pxInputStream& fp, u32& version, wxString& descript
throw Exception::BadStream( fp.GetStreamName() )
.SetDiagMsg(L"BIOS version check failed: 'ROMDIR' tag could not be found.")
.SetUserMsg(_("The selected BIOS file is not a valid PS2 BIOS. Please re-configure."));
wxFileOffset fileSize = fp.Length();
if (fileSize < (int)fileOffset)
{
@ -325,7 +325,7 @@ bool IsBIOS(const wxString& filename, wxString& description)
{
wxFileName Bios( g_Conf->Folders.Bios + filename );
pxInputStream inway( filename, new wxFFileInputStream( filename ) );
if (!inway.IsOk()) return false;
// FPS2BIOS is smaller and of variable size
//if (inway.Length() < 512*1024) return false;