Added a GSopen2 call to the GS plugin API, which is used by PCSX2 to specify its own window handle.

git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1840 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
Jake.Stine 2009-09-17 07:31:57 +00:00
parent 19310cef03
commit e5da378d9a
15 changed files with 125 additions and 39 deletions

View File

@ -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;

View File

@ -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() {}

View File

@ -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 );
}
}

View File

@ -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

View File

@ -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;
}

View File

@ -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();

View File

@ -22,13 +22,15 @@
#include <wx/apptrait.h>
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;

View File

@ -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 )

View File

@ -24,7 +24,6 @@ static const bool EnableThreadedLoggingTest = false; //true;
using namespace Threading;
class MainEmuFrame;
class LogWriteEvent;

36
pcsx2/gui/FrameForGS.cpp Normal file
View File

@ -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 <http://www.gnu.org/licenses/>.
*/
#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();
}
*/

View File

@ -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()

View File

@ -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();

View File

@ -15,6 +15,7 @@
#include "PrecompiledHeader.h"
#include "App.h"
#include "MainFrame.h"
#include <wx/dir.h>
#include <wx/file.h>

View File

@ -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.

View File

@ -1918,6 +1918,10 @@
RelativePath="..\..\gui\ConsoleLogger.cpp"
>
</File>
<File
RelativePath="..\..\gui\FrameForGS.cpp"
>
</File>
<File
RelativePath="..\..\gui\HostGui.cpp"
>