diff --git a/common/include/PS2Edefs.h b/common/include/PS2Edefs.h index 4455b7ccba..6dc9e62059 100644 --- a/common/include/PS2Edefs.h +++ b/common/include/PS2Edefs.h @@ -511,6 +511,7 @@ typedef char*(CALLBACK* _PS2EgetLibName)(void); // NOTE: GSreadFIFOX/GSwriteCSR functions CANNOT use XMM/MMX regs // If you want to use them, need to save and restore current ones typedef s32 (CALLBACK* _GSopen)(void *pDsp, char *Title, int multithread); +typedef s32 (CALLBACK* _GSopen2)( void *pDsp, u32 forceSoftware ); typedef void (CALLBACK* _GSvsync)(int field); typedef void (CALLBACK* _GSgifTransfer1)(u32 *pMem, u32 addr); typedef void (CALLBACK* _GSgifTransfer2)(u32 *pMem, u32 size); @@ -662,6 +663,7 @@ typedef void (CALLBACK* _FWirqCallback)(void (*callback)()); // GS extern _GSopen GSopen; +extern _GSopen2 GSopen2; extern _GSvsync GSvsync; extern _GSgifTransfer1 GSgifTransfer1; extern _GSgifTransfer2 GSgifTransfer2; diff --git a/common/include/Utilities/HashMap.h b/common/include/Utilities/HashMap.h index d808369e1f..982239e7d5 100644 --- a/common/include/Utilities/HashMap.h +++ b/common/include/Utilities/HashMap.h @@ -554,7 +554,7 @@ public: using _parent::operator[]; using _parent::end; - typedef typename __super::const_iterator const_iterator; + typedef typename _parent::const_iterator const_iterator; virtual ~HashMap() {} diff --git a/pcsx2/CDVD/CDVD.cpp b/pcsx2/CDVD/CDVD.cpp index 9a0dc887c2..fb7ea20adc 100644 --- a/pcsx2/CDVD/CDVD.cpp +++ b/pcsx2/CDVD/CDVD.cpp @@ -377,8 +377,7 @@ void cdvdReadKey(u8 arg0, u16 arg1, u32 arg2, u8* key) { { ElfCRC = loadElfCRC( str ); ElfApplyPatches(); - if( GSsetGameCRC != NULL ) - GSsetGameCRC( ElfCRC, 0 ); + GSsetGameCRC( ElfCRC, 0 ); } } @@ -511,8 +510,7 @@ void cdvdDetectDisk() { ElfCRC = loadElfCRC( str.ToAscii().data() ); ElfApplyPatches(); - if( GSsetGameCRC != NULL ) - GSsetGameCRC( ElfCRC, 0 ); + GSsetGameCRC( ElfCRC, 0 ); } } diff --git a/pcsx2/MTGS.cpp b/pcsx2/MTGS.cpp index 86194a130f..e91c131a59 100644 --- a/pcsx2/MTGS.cpp +++ b/pcsx2/MTGS.cpp @@ -588,8 +588,14 @@ sptr mtgsThreadObject::ExecuteTask() GSsetBaseMem( m_gsMem ); GSirqCallback( dummyIrqCallback ); - Console::WriteLn( (wxString)L"\t\tForced software switch: " + (renderswitch ? L"Enabled" : L"Disabled") ); - m_returncode = GSopen( (void*)&pDsp, "PCSX2", renderswitch ? 2 : 1 ); + if( renderswitch ) + Console::WriteLn( "\t\tForced software switch enabled." ); + + if( GSopen2 != NULL ) + m_returncode = GSopen2( (void*)&pDsp, !!renderswitch ); + else + m_returncode = GSopen( (void*)&pDsp, "PCSX2", renderswitch ? 2 : 1 ); + DevCon::WriteLn( "MTGS: GSopen Finished, return code: 0x%x", m_returncode ); GSCSRr = 0x551B4000; // 0x55190000 diff --git a/pcsx2/PluginManager.cpp b/pcsx2/PluginManager.cpp index 74693e5e39..afabf938da 100644 --- a/pcsx2/PluginManager.cpp +++ b/pcsx2/PluginManager.cpp @@ -130,6 +130,7 @@ static s32 CALLBACK fallback_test() { return 0; } _GSvsync GSvsync; _GSopen GSopen; +_GSopen2 GSopen2; _GSgifTransfer1 GSgifTransfer1; _GSgifTransfer2 GSgifTransfer2; _GSgifTransfer3 GSgifTransfer3; @@ -150,6 +151,7 @@ _GSreset GSreset; _GSwriteCSR GSwriteCSR; static void CALLBACK GS_makeSnapshot(const char *path) {} +static void CALLBACK GS_setGameCRC(u32 crc, int gameopts) {} static void CALLBACK GS_irqCallback(void (*callback)()) {} static void CALLBACK GS_printf(int timeout, char *fmt, ...) { @@ -276,14 +278,15 @@ static const LegacyApi_ReqMethod s_MethMessReq_GS[] = { "GSprintf", (vMeth**)&GSprintf, (vMeth*)GS_printf }, { "GSsetBaseMem", (vMeth**)&GSsetBaseMem, NULL }, { "GSwriteCSR", (vMeth**)&GSwriteCSR, NULL }, + { "GSsetGameCRC", (vMeth**)&GSsetGameCRC, (vMeth*)GS_setGameCRC }, { NULL } }; static const LegacyApi_OptMethod s_MethMessOpt_GS[] = { + { "GSopen2", (vMeth**)&GSopen2 }, { "GSreset", (vMeth**)&GSreset }, { "GSsetupRecording", (vMeth**)&GSsetupRecording }, - { "GSsetGameCRC", (vMeth**)&GSsetGameCRC }, { "GSsetFrameSkip", (vMeth**)&GSsetFrameSkip }, { "GSsetFrameLimit", (vMeth**)&GSsetFrameLimit }, { "GSchangeSaveState",(vMeth**)&GSchangeSaveState }, @@ -734,7 +737,7 @@ PluginManager::PluginManager( const wxString (&folders)[PluginId_Count] ) g_plugins = this; } -PluginManager::~PluginManager() +PluginManager::~PluginManager() throw() { try { @@ -834,8 +837,8 @@ static bool OpenPlugin_CDVD() static bool OpenPlugin_GS() { if( mtgsThread != NULL ) return true; - mtgsOpen(); // mtgsOpen raises its own exception on error + GSsetGameCRC( ElfCRC, 0 ); return true; } diff --git a/pcsx2/Plugins.h b/pcsx2/Plugins.h index d07682d1f4..fc791fd16d 100644 --- a/pcsx2/Plugins.h +++ b/pcsx2/Plugins.h @@ -280,7 +280,7 @@ public: // hack until we unsuck plugins... PluginStatus_t m_info[PluginId_Count]; public: - virtual ~PluginManager(); + virtual ~PluginManager() throw(); void Init(); void Shutdown(); diff --git a/pcsx2/gui/App.h b/pcsx2/gui/App.h index 1862fe2221..ca9e799702 100644 --- a/pcsx2/gui/App.h +++ b/pcsx2/gui/App.h @@ -22,13 +22,15 @@ #include +class IniInterface; +class MainEmuFrame; +class GSFrame; + #include "AppConfig.h" #include "System.h" #include "ConsoleLogger.h" #include "ps2/CoreEmuThread.h" -class IniInterface; - BEGIN_DECLARE_EVENT_TYPES() DECLARE_EVENT_TYPE( pxEVT_SemaphorePing, -1 ) @@ -245,6 +247,7 @@ protected: // Note: Pointers to frames should not be scoped because wxWidgets handles deletion // of these objects internally. MainEmuFrame* m_MainFrame; + GSFrame* m_gsFrame; ConsoleLogFrame* m_ProgramLogBox; bool m_ConfigImagesAreLoaded; diff --git a/pcsx2/gui/AppMain.cpp b/pcsx2/gui/AppMain.cpp index d2a0bf9f46..61741ee988 100644 --- a/pcsx2/gui/AppMain.cpp +++ b/pcsx2/gui/AppMain.cpp @@ -150,6 +150,21 @@ void Pcsx2App::SysExecute( CDVD_SourceType cdvdsrc ) LoadPluginsImmediate(); CDVDsys_SetFile( CDVDsrc_Iso, g_Conf->CurrentIso ); CDVDsys_ChangeSource( cdvdsrc ); + + if( m_gsFrame == NULL && GSopen2 != NULL ) + { + // Yay, we get to open and manage our OWN window!!! + // (work-in-progress) + + m_gsFrame = new GSFrame( m_MainFrame, L"PCSX2" ); + m_gsFrame->SetFocus(); + pDsp = (uptr)m_gsFrame->GetHandle(); + m_gsFrame->Show(); + + // The "in the main window" quickie hack... + //pDsp = (uptr)m_MainFrame->m_background.GetHandle(); + } + m_CoreThread.reset( new AppEmuThread( *m_CorePlugins ) ); m_CoreThread->Resume(); } @@ -188,7 +203,7 @@ sptr AppEmuThread::ExecuteTask() // ---------------------------------------------------------------------------- catch( Exception::FileNotFound& ex ) { - GetPluginManager().Close(); + m_plugins.Close(); if( ex.StreamName == g_Conf->FullpathToBios() ) { GetPluginManager().Close(); @@ -211,7 +226,7 @@ sptr AppEmuThread::ExecuteTask() // ---------------------------------------------------------------------------- catch( Exception::PluginError& ex ) { - GetPluginManager().Close(); + m_plugins.Close(); Console::Error( ex.FormatDiagnosticMessage() ); Msgbox::Alert( ex.FormatDisplayMessage(), _("Plugin Open Error") ); @@ -227,7 +242,7 @@ sptr AppEmuThread::ExecuteTask() catch( Exception::BaseException& ex ) { // Sent the exception back to the main gui thread? - GetPluginManager().Close(); + m_plugins.Close(); Msgbox::Alert( ex.FormatDisplayMessage() ); } @@ -619,7 +634,15 @@ void Pcsx2App::OnMessageBox( pxMessageBoxEvent& evt ) void Pcsx2App::CleanupMess() { - m_CorePlugins.reset(); + m_CorePlugins->Close(); + m_CorePlugins->Shutdown(); + + // Notice: deleting the plugin manager (unloading plugins) here causes Lilypad to crash, + // likely due to some pending message in the queue that references lilypad procs. + // We don't need to unload plugins anyway tho -- shutdown is plenty safe enough for + // closing out all the windows. So just leave it be and let the plugins get unloaded + // during the wxApp destructor. -- air + m_ProgramLogBox = NULL; m_MainFrame = NULL; } @@ -681,6 +704,7 @@ int Pcsx2App::OnExit() Pcsx2App::Pcsx2App() : m_MainFrame( NULL ) +, m_gsFrame( NULL ) , m_ProgramLogBox( NULL ) , m_ConfigImages( 32, 32 ) , m_ConfigImagesAreLoaded( false ) diff --git a/pcsx2/gui/ConsoleLogger.h b/pcsx2/gui/ConsoleLogger.h index db9012fe23..2d6bfab64c 100644 --- a/pcsx2/gui/ConsoleLogger.h +++ b/pcsx2/gui/ConsoleLogger.h @@ -24,7 +24,6 @@ static const bool EnableThreadedLoggingTest = false; //true; using namespace Threading; -class MainEmuFrame; class LogWriteEvent; diff --git a/pcsx2/gui/FrameForGS.cpp b/pcsx2/gui/FrameForGS.cpp new file mode 100644 index 0000000000..e68928b7e7 --- /dev/null +++ b/pcsx2/gui/FrameForGS.cpp @@ -0,0 +1,36 @@ +/* PCSX2 - PS2 Emulator for PCs + * Copyright (C) 2002-2009 PCSX2 Dev Team + * + * PCSX2 is free software: you can redistribute it and/or modify it under the terms + * of the GNU Lesser General Public License as published by the Free Software Found- + * ation, either version 3 of the License, or (at your option) any later version. + * + * PCSX2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with PCSX2. + * If not, see . + */ + +#include "PrecompiledHeader.h" +#include "MainFrame.h" + + +GSFrame::GSFrame(wxWindow* parent, const wxString& title): + wxFrame(parent, wxID_ANY, title, wxDefaultPosition, wxSize( 640, 480 ), wxDEFAULT_FRAME_STYLE ) +{ + //new wxStaticText( "" ); + + //Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler(GSFrame::OnCloseWindow) ); +} + +GSFrame::~GSFrame() throw() +{ +} + +/*void GSFrame::OnCloseWindow(wxCloseEvent& evt) +{ + evt.Skip(); +} +*/ \ No newline at end of file diff --git a/pcsx2/gui/MainFrame.cpp b/pcsx2/gui/MainFrame.cpp index 7229d1054b..dcb7654650 100644 --- a/pcsx2/gui/MainFrame.cpp +++ b/pcsx2/gui/MainFrame.cpp @@ -126,13 +126,11 @@ void MainEmuFrame::PopulatePadMenu() // void MainEmuFrame::OnCloseWindow(wxCloseEvent& evt) { - // Note Closure Vetoing would be handled here (user prompt confirmation - // of closing the app) - if( !wxGetApp().PrepForExit() ) - evt.Veto( true ); + evt.Veto( evt.CanVeto() ); evt.Skip(); + //Destroy(); } void MainEmuFrame::OnMoveAround( wxMoveEvent& evt ) @@ -430,13 +428,17 @@ MainEmuFrame::MainEmuFrame(wxWindow* parent, const wxString& title): UpdateIsoSrcFile(); } -MainEmuFrame::~MainEmuFrame() +MainEmuFrame::~MainEmuFrame() throw() { - if( m_RecentIsoList != NULL ) + try { - m_RecentIsoList->Save( *wxConfigBase::Get( false ) ); - safe_delete( m_RecentIsoList ); + if( m_RecentIsoList != NULL ) + { + m_RecentIsoList->Save( *wxConfigBase::Get( false ) ); + safe_delete( m_RecentIsoList ); + } } + DESTRUCTOR_CATCHALL } void MainEmuFrame::ApplySettings() diff --git a/pcsx2/gui/MainFrame.h b/pcsx2/gui/MainFrame.h index ae3cb77343..de5e9b5874 100644 --- a/pcsx2/gui/MainFrame.h +++ b/pcsx2/gui/MainFrame.h @@ -21,11 +21,20 @@ #include "App.h" -class MainEmuFrame: public wxFrame +class GSFrame : public wxFrame { - // ------------------------------------------------------------------------ - // MainEmuFrame Protected Variables - // ------------------------------------------------------------------------ +protected: + +public: + GSFrame(wxWindow* parent, const wxString& title); + virtual ~GSFrame() throw(); +}; + +class MainEmuFrame : public wxFrame +{ +// ------------------------------------------------------------------------ +// MainEmuFrame Protected Variables +// ------------------------------------------------------------------------ protected: wxFileHistory* m_RecentIsoList; @@ -49,13 +58,13 @@ protected: wxMenuItem& m_MenuItem_Console; - // ------------------------------------------------------------------------ - // MainEmuFrame Constructors and Member Methods - // ------------------------------------------------------------------------ +// ------------------------------------------------------------------------ +// MainEmuFrame Constructors and Member Methods +// ------------------------------------------------------------------------ public: MainEmuFrame(wxWindow* parent, const wxString& title); - virtual ~MainEmuFrame(); + virtual ~MainEmuFrame() throw(); void OnLogBoxHidden(); @@ -101,9 +110,9 @@ protected: bool _DoSelectIsoBrowser(); - // ------------------------------------------------------------------------ - // MainEmuFram Internal API for Populating Main Menu Contents - // ------------------------------------------------------------------------ +// ------------------------------------------------------------------------ +// MainEmuFram Internal API for Populating Main Menu Contents +// ------------------------------------------------------------------------ wxMenu* MakeStatesSubMenu( int baseid ) const; wxMenu* MakeStatesMenu(); diff --git a/pcsx2/gui/Plugins.cpp b/pcsx2/gui/Plugins.cpp index 65da250122..db13783456 100644 --- a/pcsx2/gui/Plugins.cpp +++ b/pcsx2/gui/Plugins.cpp @@ -15,6 +15,7 @@ #include "PrecompiledHeader.h" #include "App.h" +#include "MainFrame.h" #include #include diff --git a/pcsx2/ps2/CoreEmuThread.cpp b/pcsx2/ps2/CoreEmuThread.cpp index 016847616e..3c9e90b0b1 100644 --- a/pcsx2/ps2/CoreEmuThread.cpp +++ b/pcsx2/ps2/CoreEmuThread.cpp @@ -87,8 +87,7 @@ void CoreEmuThread::CpuInitializeMess() } } - if( GSsetGameCRC != NULL ) - GSsetGameCRC( ElfCRC, 0 ); + GSsetGameCRC( ElfCRC, 0 ); } // special macro which disables inlining on functions that require their own function stackframe. diff --git a/pcsx2/windows/VCprojects/pcsx2_2008.vcproj b/pcsx2/windows/VCprojects/pcsx2_2008.vcproj index d827e88b81..73dfb29cf8 100644 --- a/pcsx2/windows/VCprojects/pcsx2_2008.vcproj +++ b/pcsx2/windows/VCprojects/pcsx2_2008.vcproj @@ -1918,6 +1918,10 @@ RelativePath="..\..\gui\ConsoleLogger.cpp" > + +