diff --git a/pcsx2/CDVD/CDVD.cpp b/pcsx2/CDVD/CDVD.cpp index 07df8258da..b3cec3b188 100644 --- a/pcsx2/CDVD/CDVD.cpp +++ b/pcsx2/CDVD/CDVD.cpp @@ -29,7 +29,8 @@ #include "ps2/BiosTools.h" #include "DataBase_Loader.h" -DataBase_Loader GameDB("DataBase.dbf", "Serial"); +ScopedPtr GameDB; + wxString DiscID; static cdvdStruct cdvd; @@ -348,8 +349,11 @@ static __forceinline void _reloadElfInfo(wxString elfpath) elfptr.Delete(); // Set the Game DataBase to the correct game based on Game Serial Code... - GameDB.setGame(DiscID.ToUTF8().data()); - Console.WriteLn("Game = %s (%s)", GameDB.getString("Name").c_str(), GameDB.getString("Region").c_str()); + if( GameDB ) + { + GameDB->setGame(DiscID.ToUTF8().data()); + Console.WriteLn("Game = %s (%s)", GameDB->getString("Name").c_str(), GameDB->getString("Region").c_str()); + } } void cdvdReloadElfInfo() @@ -536,6 +540,8 @@ void cdvdReset() cdvd.RTC.day = (u8)curtime.GetDay(wxDateTime::GMT9); cdvd.RTC.month = (u8)curtime.GetMonth(wxDateTime::GMT9) + 1; // WX returns Jan as "0" cdvd.RTC.year = (u8)(curtime.GetYear(wxDateTime::GMT9) - 2000); + + GameDB = new DataBase_Loader("DataBase.dbf", "Serial"); } struct Freeze_v10Compat diff --git a/pcsx2/CDVD/CDVD.h b/pcsx2/CDVD/CDVD.h index 5f190343e4..0a7591327b 100644 --- a/pcsx2/CDVD/CDVD.h +++ b/pcsx2/CDVD/CDVD.h @@ -143,6 +143,6 @@ extern void cdvdNewDiskCB(); extern u8 cdvdRead(u8 key); extern void cdvdWrite(u8 key, u8 rt); -void cdvdReloadElfInfo(); +extern void cdvdReloadElfInfo(); extern wxString DiscID; diff --git a/pcsx2/CDVD/CDVDaccess.cpp b/pcsx2/CDVD/CDVDaccess.cpp index 9b74593fa7..7e5a2717af 100644 --- a/pcsx2/CDVD/CDVDaccess.cpp +++ b/pcsx2/CDVD/CDVDaccess.cpp @@ -281,6 +281,11 @@ void CDVDsys_SetFile( CDVD_SourceType srctype, const wxString& newfile ) m_SourceFilename[srctype] = newfile; } +const wxString& CDVDsys_GetFile( CDVD_SourceType srctype ) +{ + return m_SourceFilename[srctype]; +} + CDVD_SourceType CDVDsys_GetSourceType() { return m_CurrentSourceType; diff --git a/pcsx2/CDVD/CDVDaccess.h b/pcsx2/CDVD/CDVDaccess.h index 5303f95694..f4b35fe591 100644 --- a/pcsx2/CDVD/CDVDaccess.h +++ b/pcsx2/CDVD/CDVDaccess.h @@ -69,6 +69,7 @@ extern const wxChar* CDVD_SourceLabels[]; extern void CDVDsys_ChangeSource( CDVD_SourceType type ); extern void CDVDsys_SetFile( CDVD_SourceType srctype, const wxString& newfile ); +extern const wxString& CDVDsys_GetFile( CDVD_SourceType srctype ); extern CDVD_SourceType CDVDsys_GetSourceType(); extern bool DoCDVDopen(); diff --git a/pcsx2/DataBase_Loader.h b/pcsx2/DataBase_Loader.h index 592c1b82a8..8f39860d66 100644 --- a/pcsx2/DataBase_Loader.h +++ b/pcsx2/DataBase_Loader.h @@ -56,9 +56,9 @@ private: if (doMsg) Console.Error("DataBase_Loader: Bad file data [%s]", line.c_str()); keyPair.key = ""; } - void extract(string& line, key_pair& keyPair) { - int eol = line.rfind("\r"); - if (eol != string::npos) line = line.substr(0, eol); + void extract(string& line, key_pair& keyPair) { + int eol = line.rfind("\r"); + if (eol != string::npos) line = line.substr(0, eol); stringstream ss(line); string t; @@ -79,7 +79,7 @@ private: doError(line, keyPair, true); return; } - keyPair.value = t; + keyPair.value = t; int temp = 0; while (!ss.eof() && !ss.fail()) { ss >> t; @@ -202,4 +202,4 @@ public: } }; -extern DataBase_Loader GameDB; +extern ScopedPtr GameDB; diff --git a/pcsx2/R5900.cpp b/pcsx2/R5900.cpp index b061dfd8e8..6400910bdd 100644 --- a/pcsx2/R5900.cpp +++ b/pcsx2/R5900.cpp @@ -578,8 +578,12 @@ void __fastcall eeGameStarting() { if (!g_GameStarted && ElfCRC) { wxString gameCRC( wxsFormat( L"%8.8x", ElfCRC ) ); - wxString gameName = GameDB.getStringWX("Name"); - gameName += L" (" + GameDB.getStringWX("Region") + L")"; + wxString gameName; + if( GameDB ) + { + gameName = GameDB->getStringWX("Name"); + gameName += L" (" + GameDB->getStringWX("Region") + L")"; + } gameName += L" [" + DiscID + L"]"; gameName += L" [" + gameCRC + L"]"; diff --git a/pcsx2/gui/AppCoreThread.cpp b/pcsx2/gui/AppCoreThread.cpp index 72db3ad345..f083079b0f 100644 --- a/pcsx2/gui/AppCoreThread.cpp +++ b/pcsx2/gui/AppCoreThread.cpp @@ -70,6 +70,7 @@ static void PostCoreStatus( CoreThreadStatus pevt ) // -------------------------------------------------------------------------------------- AppCoreThread::AppCoreThread() : SysCoreThread() { + m_resetCdvd = false; } AppCoreThread::~AppCoreThread() throw() @@ -146,6 +147,13 @@ void AppCoreThread::ChangeCdvdSource() void AppCoreThread::OnResumeReady() { ApplySettings( g_Conf->EmuOptions ); + + CDVD_SourceType cdvdsrc( g_Conf->CdvdSource ); + if( cdvdsrc != CDVDsys_GetSourceType() || (cdvdsrc==CDVDsrc_Iso && (CDVDsys_GetFile(cdvdsrc) != g_Conf->CurrentIso)) ) + { + m_resetCdvd = true; + } + CDVDsys_SetFile( CDVDsrc_Iso, g_Conf->CurrentIso ); AppSaveSettings(); @@ -195,6 +203,13 @@ void AppCoreThread::DoCpuReset() void AppCoreThread::OnResumeInThread( bool isSuspended ) { + if( m_resetCdvd ) + { + GetCorePlugins().Close( PluginId_CDVD ); + CDVDsys_ChangeSource( g_Conf->CdvdSource ); + m_resetCdvd = false; + } + _parent::OnResumeInThread( isSuspended ); PostCoreStatus( CoreThread_Resumed ); } diff --git a/pcsx2/gui/AppCoreThread.h b/pcsx2/gui/AppCoreThread.h index b9bfe7a231..c20fbd5a62 100644 --- a/pcsx2/gui/AppCoreThread.h +++ b/pcsx2/gui/AppCoreThread.h @@ -120,6 +120,9 @@ class AppCoreThread : public SysCoreThread { typedef SysCoreThread _parent; +protected: + volatile bool m_resetCdvd; + public: AppCoreThread(); virtual ~AppCoreThread() throw(); diff --git a/pcsx2/gui/MainMenuClicks.cpp b/pcsx2/gui/MainMenuClicks.cpp index 913942fbb5..cd59f8de0c 100644 --- a/pcsx2/gui/MainMenuClicks.cpp +++ b/pcsx2/gui/MainMenuClicks.cpp @@ -140,18 +140,18 @@ wxWindowID SwapOrReset_Iso( wxWindow* owner, IScopedCoreThread& core_control, co } SysUpdateIsoSrcFile( isoFilename ); - if( result != wxID_RESET ) - { - Console.Indent().WriteLn( "HotSwapping to new ISO src image!" ); - g_Conf->CdvdSource = CDVDsrc_Iso; - CoreThread.ChangeCdvdSource(); - core_control.AllowResume(); - } - else + if( result == wxID_RESET ) { core_control.DisallowResume(); sApp.SysExecute( CDVDsrc_Iso ); } + else + { + Console.Indent().WriteLn( "HotSwapping to new ISO src image!" ); + g_Conf->CdvdSource = CDVDsrc_Iso; + //CoreThread.ChangeCdvdSource(); + core_control.AllowResume(); + } return result; } @@ -190,7 +190,7 @@ wxWindowID SwapOrReset_CdvdSrc( wxWindow* owner, CDVD_SourceType newsrc ) if( result != wxID_RESET ) { Console.Indent().WriteLn( L"(CdvdSource) HotSwapping CDVD source types from %s to %s.", CDVD_SourceLabels[oldsrc], CDVD_SourceLabels[newsrc] ); - CoreThread.ChangeCdvdSource(); + //CoreThread.ChangeCdvdSource(); sMainFrame.UpdateIsoSrcSelection(); core.AllowResume(); }