From 2b3d596d867dcf6eb2ed9d7b0a4923041ca62ce2 Mon Sep 17 00:00:00 2001 From: "Jake.Stine" Date: Thu, 17 Sep 2009 16:49:04 +0000 Subject: [PATCH 01/12] Minor fixes for interlocking against the threaded plugin loader (running a game too quickly could cause crashes) git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1843 96395faa-99c1-11dd-bbfe-3dabce05a288 --- pcsx2/gui/App.h | 2 + pcsx2/gui/AppMain.cpp | 17 ++-- pcsx2/gui/MainFrame.cpp | 11 +-- pcsx2/gui/MainFrame.h | 2 +- pcsx2/gui/Plugins.cpp | 177 ++++++++++++++++++++++++---------------- 5 files changed, 124 insertions(+), 85 deletions(-) diff --git a/pcsx2/gui/App.h b/pcsx2/gui/App.h index ca9e79970..fedcf7326 100644 --- a/pcsx2/gui/App.h +++ b/pcsx2/gui/App.h @@ -36,6 +36,7 @@ BEGIN_DECLARE_EVENT_TYPES() DECLARE_EVENT_TYPE( pxEVT_SemaphorePing, -1 ) DECLARE_EVENT_TYPE( pxEVT_OpenModalDialog, -1 ) DECLARE_EVENT_TYPE( pxEVT_ReloadPlugins, -1 ) + DECLARE_EVENT_TYPE( pxEVT_LoadPluginsComplete, -1 ) END_DECLARE_EVENT_TYPES() // ------------------------------------------------------------------------ @@ -365,6 +366,7 @@ protected: void HandleEvent(wxEvtHandler *handler, wxEventFunction func, wxEvent& event) const; void OnReloadPlugins( wxCommandEvent& evt ); + void OnLoadPluginsComplete( wxCommandEvent& evt ); void OnSemaphorePing( wxCommandEvent& evt ); void OnOpenModalDialog( wxCommandEvent& evt ); void OnMessageBox( pxMessageBoxEvent& evt ); diff --git a/pcsx2/gui/AppMain.cpp b/pcsx2/gui/AppMain.cpp index 61741ee98..04dfc0eba 100644 --- a/pcsx2/gui/AppMain.cpp +++ b/pcsx2/gui/AppMain.cpp @@ -27,13 +27,14 @@ #include #include -#include +#include IMPLEMENT_APP(Pcsx2App) DEFINE_EVENT_TYPE( pxEVT_SemaphorePing ); DEFINE_EVENT_TYPE( pxEVT_OpenModalDialog ); DEFINE_EVENT_TYPE( pxEVT_ReloadPlugins ); +DEFINE_EVENT_TYPE( pxEVT_LoadPluginsComplete ); bool UseAdminMode = false; wxDirName SettingsFolder; @@ -427,6 +428,7 @@ bool Pcsx2App::OnInit() Connect( pxEVT_SemaphorePing, wxCommandEventHandler( Pcsx2App::OnSemaphorePing ) ); Connect( pxEVT_OpenModalDialog, wxCommandEventHandler( Pcsx2App::OnOpenModalDialog ) ); Connect( pxEVT_ReloadPlugins, wxCommandEventHandler( Pcsx2App::OnReloadPlugins ) ); + Connect( pxEVT_LoadPluginsComplete, wxCommandEventHandler( Pcsx2App::OnLoadPluginsComplete ) ); Connect( pxID_Window_GS, wxEVT_KEY_DOWN, wxKeyEventHandler( Pcsx2App::OnEmuKeyDown ) ); @@ -630,12 +632,13 @@ void Pcsx2App::OnMessageBox( pxMessageBoxEvent& evt ) Msgbox::OnEvent( evt ); } -#include - void Pcsx2App::CleanupMess() { - m_CorePlugins->Close(); - m_CorePlugins->Shutdown(); + if( m_CorePlugins ) + { + 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. @@ -768,7 +771,7 @@ void Pcsx2App::LoadSettings() IniLoader loader( *conf ); g_Conf->LoadSave( loader ); - if( m_MainFrame != NULL ) + if( m_MainFrame != NULL && m_MainFrame->m_RecentIsoList ) m_MainFrame->m_RecentIsoList->Load( *conf ); } @@ -780,6 +783,6 @@ void Pcsx2App::SaveSettings() IniSaver saver( *conf ); g_Conf->LoadSave( saver ); - if( m_MainFrame != NULL ) + if( m_MainFrame != NULL && m_MainFrame->m_RecentIsoList ) m_MainFrame->m_RecentIsoList->Save( *conf ); } diff --git a/pcsx2/gui/MainFrame.cpp b/pcsx2/gui/MainFrame.cpp index dcb765465..13691b039 100644 --- a/pcsx2/gui/MainFrame.cpp +++ b/pcsx2/gui/MainFrame.cpp @@ -432,11 +432,8 @@ MainEmuFrame::~MainEmuFrame() throw() { try { - if( m_RecentIsoList != NULL ) - { + if( m_RecentIsoList ) m_RecentIsoList->Save( *wxConfigBase::Get( false ) ); - safe_delete( m_RecentIsoList ); - } } DESTRUCTOR_CATCHALL } @@ -450,10 +447,10 @@ void MainEmuFrame::ApplySettings() wxConfigBase* cfg = wxConfigBase::Get( false ); wxASSERT( cfg != NULL ); - if( m_RecentIsoList != NULL ) + if( m_RecentIsoList ) m_RecentIsoList->Save( *cfg ); - safe_delete( m_RecentIsoList ); - m_RecentIsoList = new wxFileHistory( g_Conf->RecentFileCount ); + m_RecentIsoList.reset(); + m_RecentIsoList.reset( new wxFileHistory( g_Conf->RecentFileCount ) ); m_RecentIsoList->Load( *cfg ); UpdateIsoSrcFile(); diff --git a/pcsx2/gui/MainFrame.h b/pcsx2/gui/MainFrame.h index de5e9b587..f5b115634 100644 --- a/pcsx2/gui/MainFrame.h +++ b/pcsx2/gui/MainFrame.h @@ -37,7 +37,7 @@ class MainEmuFrame : public wxFrame // ------------------------------------------------------------------------ protected: - wxFileHistory* m_RecentIsoList; + wxScopedPtr m_RecentIsoList; wxStatusBar& m_statusbar; wxStaticBitmap m_background; diff --git a/pcsx2/gui/Plugins.cpp b/pcsx2/gui/Plugins.cpp index db1378345..04eaf186c 100644 --- a/pcsx2/gui/Plugins.cpp +++ b/pcsx2/gui/Plugins.cpp @@ -25,6 +25,90 @@ #include "HostGui.h" #include "AppConfig.h" +using namespace Threading; + +// -------------------------------------------------------------------------------------- +// LoadPluginsTask +// -------------------------------------------------------------------------------------- +// On completion the thread sends a pxEVT_LoadPluginsComplete message, which contains a +// handle to this thread object. If the load is successful, the Result var is set to +// non-NULL. If NULL, an error occurred and the thread loads the exception into either +// Ex_PluginError or Ex_RuntimeError. +// +class LoadPluginsTask : public Threading::PersistentThread +{ +public: + Exception::PluginError* Ex_PluginError; + Exception::RuntimeError* Ex_RuntimeError; + PluginManager* Result; + +protected: + wxString m_folders[PluginId_Count]; + +public: + LoadPluginsTask( const wxString (&folders)[PluginId_Count] ) : + Ex_PluginError( NULL ) + , Ex_RuntimeError( NULL ) + , Result( NULL ) + { + for(int i=0; i _loadTask; + +LoadPluginsTask::~LoadPluginsTask() throw() +{ + _loadTask.release(); + PersistentThread::Cancel(); + _loadTask.reset(); +} + +int LoadPluginsTask::ExecuteTask() +{ + wxGetApp().Ping(); + Sleep(3); + + wxCommandEvent evt( pxEVT_LoadPluginsComplete ); + evt.SetClientData( this ); + + try + { + // This is for testing of the error handler... uncomment for fun? + //throw Exception::PluginError( PluginId_PAD, "This one is for testing the error handler!" ); + + Result = PluginManager_Create( m_folders ); + } + catch( Exception::PluginError& ex ) + { + Ex_PluginError = new Exception::PluginError( ex ); + } + catch( Exception::RuntimeError& innerEx ) + { + // Runtime errors are typically recoverable, so handle them here + // and prep them for re-throw on the main thread. + Ex_RuntimeError = new Exception::RuntimeError( + L"A runtime error occurred on the LoadPlugins thread.\n" + innerEx.FormatDiagnosticMessage(), + innerEx.FormatDisplayMessage() + ); + } + // anything else leave unhandled so that the debugger catches it! + + wxGetApp().AddPendingEvent( evt ); + return 0; +} + +///////////////////////////////////////////////////////////////////////////////////////// + + int EnumeratePluginsInFolder( const wxDirName& searchpath, wxArrayString* dest ) { wxScopedPtr placebo; @@ -45,69 +129,29 @@ int EnumeratePluginsInFolder( const wxDirName& searchpath, wxArrayString* dest ) wxDir::GetAllFiles( searchpath.ToString(), realdest, wxsFormat( pattern, wxDynamicLibrary::GetDllExt()), wxDIR_FILES ) : 0; } -using namespace Threading; - void Pcsx2App::OnReloadPlugins( wxCommandEvent& evt ) { ReloadPlugins(); } +void Pcsx2App::OnLoadPluginsComplete( wxCommandEvent& evt ) +{ + // scoped ptr ensures the thread object is cleaned up even on exception: + wxScopedPtr killTask( (LoadPluginsTask*)evt.GetClientData() ); + m_CorePlugins.reset( killTask->Result ); + + if( !m_CorePlugins ) + { + if( killTask->Ex_PluginError != NULL ) + throw *killTask->Ex_PluginError; + if( killTask->Ex_RuntimeError != NULL ) + throw *killTask->Ex_RuntimeError; // Re-Throws generic threaded errors + } +} + void Pcsx2App::ReloadPlugins() { - class LoadPluginsTask : public Threading::BaseTaskThread - { - public: - PluginManager* Result; - Exception::PluginError* Ex_PluginError; - Exception::RuntimeError* Ex_RuntimeError; - - protected: - const wxString (&m_folders)[PluginId_Count]; - - public: - LoadPluginsTask( const wxString (&folders)[PluginId_Count] ) : - Result( NULL ) - , Ex_PluginError( NULL ) - , Ex_RuntimeError( NULL ) - , m_folders( folders ) - { - } - - virtual ~LoadPluginsTask() throw() - { - BaseTaskThread::Cancel(); - } - - protected: - void Task() - { - wxGetApp().Ping(); - Sleep(3); - - try - { - //throw Exception::PluginError( PluginId_PAD, "This one is for testing the error handler!" ); - Result = PluginManager_Create( m_folders ); - } - catch( Exception::PluginError& ex ) - { - Result = NULL; - Ex_PluginError = new Exception::PluginError( ex ); - } - catch( Exception::RuntimeError& innerEx ) - { - // Runtime errors are typically recoverable, so handle them here - // and prep them for re-throw on the main thread. - Result = NULL; - Ex_RuntimeError = new Exception::RuntimeError( - L"A runtime error occurred on the LoadPlugins thread.\n" + innerEx.FormatDiagnosticMessage(), - innerEx.FormatDisplayMessage() - ); - } - - // anything else leave unhandled so that the debugger catches it! - } - }; + if( _loadTask ) return; m_CoreThread.reset(); m_CorePlugins.reset(); @@ -123,20 +167,8 @@ void Pcsx2App::ReloadPlugins() passins[pi->id] = g_Conf->FullpathTo( pi->id ); } - LoadPluginsTask task( passins ); - task.Start(); - task.PostTask(); - task.WaitForResult(); - - if( task.Result == NULL ) - { - if( task.Ex_PluginError != NULL ) - throw *task.Ex_PluginError; - if( task.Ex_RuntimeError != NULL ) - throw *task.Ex_RuntimeError; // Re-Throws generic threaded errors - } - - m_CorePlugins.reset( task.Result ); + _loadTask.reset( new LoadPluginsTask( passins ) ); + // ... and when it finishes it posts up a OnLoadPluginsComplete(). Bye. :) } // Posts a message to the App to reload plugins. Plugins are loaded via a background thread @@ -158,6 +190,11 @@ void LoadPluginsImmediate() wxASSERT( !guard.IsReentrant() ); wxGetApp().ReloadPlugins(); + while( _loadTask ) + { + Sleep( 10 ); + wxGetApp().ProcessPendingEvents(); + } } void UnloadPlugins() From 556a811933089f1cd39a86a0582e3aedcbf54f1e Mon Sep 17 00:00:00 2001 From: "Jake.Stine" Date: Thu, 17 Sep 2009 23:04:02 +0000 Subject: [PATCH 02/12] Linux: added missing files, and switched from my own WindowDisbler hack to wx's built-in wxWindoweDisabler hack. :) git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1844 96395faa-99c1-11dd-bbfe-3dabce05a288 --- pcsx2-codeblocks.workspace | 4 +- pcsx2/FiFo.cpp | 18 +- pcsx2/Linux/pcsx2.cbp | 1 + pcsx2/VifDma.cpp | 330 +++++++++++------------ pcsx2/gui/Panels/PluginSelectorPanel.cpp | 9 +- 5 files changed, 182 insertions(+), 180 deletions(-) diff --git a/pcsx2-codeblocks.workspace b/pcsx2-codeblocks.workspace index 1268984b6..6aa305ae6 100644 --- a/pcsx2-codeblocks.workspace +++ b/pcsx2-codeblocks.workspace @@ -1,7 +1,7 @@ - + @@ -22,6 +22,6 @@ - + diff --git a/pcsx2/FiFo.cpp b/pcsx2/FiFo.cpp index e89c47525..113b5288d 100644 --- a/pcsx2/FiFo.cpp +++ b/pcsx2/FiFo.cpp @@ -1,6 +1,6 @@ /* 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. @@ -52,7 +52,7 @@ extern int FOreadpos; void __fastcall ReadFIFO_page_4(u32 mem, u64 *out) { jASSUME( (mem >= VIF0_FIFO) && (mem < VIF1_FIFO) ); - + VIF_LOG("ReadFIFO/VIF0 0x%08X", mem); //out[0] = psHu64(mem ); //out[1] = psHu64(mem+8); @@ -93,7 +93,7 @@ void __fastcall ReadFIFO_page_6(u32 mem, u64 *out) //out[1] = psHu64(mem+8); out[0] = psHu64(0x6000); - out[1] = psHu64(0x6008); + out[1] = psHu64(0x6008); } void __fastcall ReadFIFO_page_7(u32 mem, u64 *out) @@ -126,24 +126,24 @@ void __fastcall WriteFIFO_page_4(u32 mem, const mem128_t *value) jASSUME( (mem >= VIF0_FIFO) && (mem < VIF1_FIFO) ); VIF_LOG("WriteFIFO/VIF0, addr=0x%08X", mem); - + //psHu64(mem ) = value[0]; //psHu64(mem+8) = value[1]; psHu64(0x4000) = value[0]; psHu64(0x4008) = value[1]; - + vif0ch->qwc += 1; int ret = VIF0transfer((u32*)value, 4, 0); assert( ret == 0 ); // vif stall code not implemented } - + void __fastcall WriteFIFO_page_5(u32 mem, const mem128_t *value) { jASSUME( (mem >= VIF1_FIFO) && (mem < GIF_FIFO) ); VIF_LOG("WriteFIFO/VIF1, addr=0x%08X", mem); - + //psHu64(mem ) = value[0]; //psHu64(mem+8) = value[1]; @@ -175,14 +175,14 @@ void __fastcall WriteFIFO_page_6(u32 mem, const mem128_t *value) psHu64(0x6008) = value[1]; FreezeRegs(1); - const uint count = mtgsThread->PrepDataPacket(GIF_PATH_3, nloop0_packet, 1); + mtgsThread->PrepDataPacket(GIF_PATH_3, nloop0_packet, 1); u64* data = (u64*)mtgsThread->GetDataPacketPtr(); data[0] = value[0]; data[1] = value[1]; mtgsThread->SendDataPacket(); FreezeRegs(0); } - + void __fastcall WriteFIFO_page_7(u32 mem, const mem128_t *value) { jASSUME( (mem >= IPUout_FIFO) && (mem < D0_CHCR) ); diff --git a/pcsx2/Linux/pcsx2.cbp b/pcsx2/Linux/pcsx2.cbp index 151eef722..180fbaaf3 100644 --- a/pcsx2/Linux/pcsx2.cbp +++ b/pcsx2/Linux/pcsx2.cbp @@ -282,6 +282,7 @@ + diff --git a/pcsx2/VifDma.cpp b/pcsx2/VifDma.cpp index a545e9db6..b13342359 100644 --- a/pcsx2/VifDma.cpp +++ b/pcsx2/VifDma.cpp @@ -1,6 +1,6 @@ /* 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. @@ -57,7 +57,7 @@ static const unsigned int VIF0dmanum = 0; static const unsigned int VIF1dmanum = 1; int g_vifCycles = 0; -Path3Modes Path3progress = STOPPED_MODE; +Path3Modes Path3progress = STOPPED_MODE; static PCSX2_ALIGNED16( u32 splittransfer[4] ); u32 splitptr = 0; @@ -155,7 +155,7 @@ extern "C" { \ UNPACK_SkippingWrite_##name##_##sign##_WriteMask_0, \ UNPACK_SkippingWrite_##name##_##sign##_WriteMask_1, \ UNPACK_SkippingWrite_##name##_##sign##_WriteMask_2 \ - + #define _UNPACK_TABLE_SSE_NULL \ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL @@ -211,7 +211,7 @@ static const VIFSSEUnpackTable VIFfuncTableSSE[16] = __forceinline void vif0FLUSH() { int _cycles = VU0.cycle; - + // fixme: this code should call _vu0WaitMicro instead? I'm not sure if // it's purposefully ignoring ee cycles or not (see below for more) @@ -250,7 +250,7 @@ __forceinline static int _limit(int a, int max) static void ProcessMemSkip(int size, unsigned int unpackType, const unsigned int VIFdmanum) { const VIFUnpackFuncTable *unpack; - + unpack = &VIFfuncTable[ unpackType ]; switch (unpackType) @@ -313,7 +313,7 @@ static void ProcessMemSkip(int size, unsigned int unpackType, const unsigned int } //Append any skips in to the equasion - + if (vifRegs->cycle.cl > vifRegs->cycle.wl) { VIFUNPACK_LOG("Old addr %x CL %x WL %x", vif->tag.addr, vifRegs->cycle.cl, vifRegs->cycle.wl); @@ -327,11 +327,11 @@ static void ProcessMemSkip(int size, unsigned int unpackType, const unsigned int VIFUNPACK_LOG("addr aligned to %x", vif->tag.addr); vif->tag.addr = (vif->tag.addr & ~0xf) + (vifRegs->offset * 4); } - if(vif->tag.addr >= (u32)(VIFdmanum ? 0x4000 : 0x1000)) + if(vif->tag.addr >= (u32)(VIFdmanum ? 0x4000 : 0x1000)) { vif->tag.addr &= (u32)(VIFdmanum ? 0x3fff : 0xfff); } - + } static int VIFalign(u32 *data, vifCode *v, unsigned int size, const unsigned int VIFdmanum) @@ -369,21 +369,21 @@ static int VIFalign(u32 *data, vifCode *v, unsigned int size, const unsigned int VIF_LOG("VIF%d UNPACK Align: Mode=%x, v->size=%d, size=%d, v->addr=%x v->num=%x", VIFdmanum, v->cmd & 0xf, v->size, size, v->addr, vifRegs->num); - + // The unpack type unpackType = v->cmd & 0xf; - + ft = &VIFfuncTable[ unpackType ]; func = vif->usn ? ft->funcU : ft->funcS; size <<= 2; - + #ifdef PCSX2_DEBUG memsize = size; #endif - + if(vifRegs->offset != 0) - { + { int unpacksize; //This is just to make sure the alignment isnt loopy on a split packet @@ -399,13 +399,13 @@ static int VIFalign(u32 *data, vifCode *v, unsigned int size, const unsigned int DevCon::Error("Wasn't enough left size/dsize = %x left to write %x", (size / ft->dsize), (ft->qsize - vifRegs->offset)); } unpacksize = min((size / ft->dsize), (ft->qsize - vifRegs->offset)); - + VIFUNPACK_LOG("Increasing dest by %x from offset %x", (4 - ft->qsize) + unpacksize, vifRegs->offset); - + func(dest, (u32*)cdata, unpacksize); size -= unpacksize * ft->dsize; - + if(vifRegs->offset == 0) { vifRegs->num--; @@ -430,13 +430,13 @@ static int VIFalign(u32 *data, vifCode *v, unsigned int size, const unsigned int vif->tag.addr += ((4 - ft->qsize) + unpacksize) * 4; dest += (4 - ft->qsize) + unpacksize; } - - if (vif->tag.addr >= (u32)(VIFdmanum ? 0x4000 : 0x1000)) + + if (vif->tag.addr >= (u32)(VIFdmanum ? 0x4000 : 0x1000)) { vif->tag.addr &= (u32)(VIFdmanum ? 0x3fff : 0xfff); dest = (u32*)(VU->Mem + v->addr); } - + cdata += unpacksize * ft->dsize; vif->cl = 0; VIFUNPACK_LOG("Aligning packet done size = %d offset %d addr %x", size, vifRegs->offset, vif->tag.addr); @@ -447,13 +447,13 @@ static int VIFalign(u32 *data, vifCode *v, unsigned int size, const unsigned int { vif->tag.addr += ((4 - ft->qsize) + unpacksize) * 4; dest += (4 - ft->qsize) + unpacksize; - - if (vif->tag.addr >= (u32)(VIFdmanum ? 0x4000 : 0x1000)) + + if (vif->tag.addr >= (u32)(VIFdmanum ? 0x4000 : 0x1000)) { vif->tag.addr &= (u32)(VIFdmanum ? 0x3fff : 0xfff); dest = (u32*)(VU->Mem + v->addr); } - + cdata += unpacksize * ft->dsize; VIFUNPACK_LOG("Aligning packet done size = %d offset %d addr %x", size, vifRegs->offset, vif->tag.addr); } @@ -465,7 +465,7 @@ static int VIFalign(u32 *data, vifCode *v, unsigned int size, const unsigned int if (vifRegs->cycle.cl >= vifRegs->cycle.wl) // skipping write { - if (vif->tag.addr >= (u32)(VIFdmanum ? 0x4000 : 0x1000)) + if (vif->tag.addr >= (u32)(VIFdmanum ? 0x4000 : 0x1000)) { vif->tag.addr &= (u32)(VIFdmanum ? 0x3fff : 0xfff); dest = (u32*)(VU->Mem + v->addr); @@ -473,7 +473,7 @@ static int VIFalign(u32 *data, vifCode *v, unsigned int size, const unsigned int // continuation from last stream VIFUNPACK_LOG("Continuing last stream size = %d offset %d addr %x", size, vifRegs->offset, vif->tag.addr); incdest = ((vifRegs->cycle.cl - vifRegs->cycle.wl) << 2) + 4; - + while ((size >= ft->gsize) && (vifRegs->num > 0)) { func(dest, (u32*)cdata, ft->qsize); @@ -486,7 +486,7 @@ static int VIFalign(u32 *data, vifCode *v, unsigned int size, const unsigned int { dest += incdest; vif->tag.addr += incdest * 4; - + vif->cl = 0; if((size & 0xf) == 0)break; } @@ -495,9 +495,9 @@ static int VIFalign(u32 *data, vifCode *v, unsigned int size, const unsigned int dest += 4; vif->tag.addr += 16; } - + // Hurrah for the 4th occurrance of this piece of code in this function... - if (vif->tag.addr >= (u32)(VIFdmanum ? 0x4000 : 0x1000)) + if (vif->tag.addr >= (u32)(VIFdmanum ? 0x4000 : 0x1000)) { vif->tag.addr &= (u32)(VIFdmanum ? 0x3fff : 0xfff); dest = (u32*)(VU->Mem + v->addr); @@ -512,14 +512,14 @@ static int VIFalign(u32 *data, vifCode *v, unsigned int size, const unsigned int vifRow[1] = vifRegs->r1; vifRow[2] = vifRegs->r2; vifRow[3] = vifRegs->r3; - } + } } if (size >= ft->dsize && vifRegs->num > 0 && ((size & 0xf) != 0 || vif->cl != 0)) { //VIF_LOG("warning, end with size = %d", size); /* unpack one qword */ - if(vif->tag.addr + ((size / ft->dsize) * 4) >= (u32)(VIFdmanum ? 0x4000 : 0x1000)) + if(vif->tag.addr + ((size / ft->dsize) * 4) >= (u32)(VIFdmanum ? 0x4000 : 0x1000)) { //DevCon::Notice("Overflow"); vif->tag.addr &= (u32)(VIFdmanum ? 0x3fff : 0xfff); @@ -527,7 +527,7 @@ static int VIFalign(u32 *data, vifCode *v, unsigned int size, const unsigned int } vif->tag.addr += (size / ft->dsize) * 4; - + func(dest, (u32*)cdata, size / ft->dsize); size = 0; @@ -538,7 +538,7 @@ static int VIFalign(u32 *data, vifCode *v, unsigned int size, const unsigned int vifRow[1] = vifRegs->r1; vifRow[2] = vifRegs->r2; vifRow[3] = vifRegs->r3; - } + } VIFUNPACK_LOG("leftover done, size %d, vifnum %d, addr %x", size, vifRegs->num, vif->tag.addr); } } @@ -555,7 +555,7 @@ static void VIFunpack(u32 *data, vifCode *v, unsigned int size, const unsigned i u8 *cdata = (u8*)data; u32 tempsize = 0; const u32 memlimit = (VIFdmanum ? 0x4000 : 0x1000); - + #ifdef PCSX2_DEBUG u32 memsize = memlimit; #endif @@ -593,19 +593,19 @@ static void VIFunpack(u32 *data, vifCode *v, unsigned int size, const unsigned i unpackType = v->cmd & 0xf; _mm_prefetch((char*)data + 128, _MM_HINT_NTA); - + ft = &VIFfuncTable[ unpackType ]; func = vif->usn ? ft->funcU : ft->funcS; size <<= 2; - + #ifdef PCSX2_DEBUG memsize = size; #endif - + if (vifRegs->cycle.cl >= vifRegs->cycle.wl) // skipping write { - if (v->addr >= memlimit) + if (v->addr >= memlimit) { //DevCon::Notice("Overflown at the start"); v->addr &= (memlimit - 1); @@ -614,18 +614,18 @@ static void VIFunpack(u32 *data, vifCode *v, unsigned int size, const unsigned i size = min(size, (int)vifRegs->num * ft->gsize); //size will always be the same or smaller - tempsize = vif->tag.addr + ((((vifRegs->num-1) / vifRegs->cycle.wl) * + tempsize = vif->tag.addr + ((((vifRegs->num-1) / vifRegs->cycle.wl) * (vifRegs->cycle.cl - vifRegs->cycle.wl)) * 16) + (vifRegs->num * 16); - /*tempsize = vif->tag.addr + (((size / (ft->gsize * vifRegs->cycle.wl)) * + /*tempsize = vif->tag.addr + (((size / (ft->gsize * vifRegs->cycle.wl)) * (vifRegs->cycle.cl - vifRegs->cycle.wl)) * 16) + (vifRegs->num * 16);*/ - + //Sanity Check (memory overflow) - if (tempsize > memlimit) + if (tempsize > memlimit) { - if (((vifRegs->cycle.cl != vifRegs->cycle.wl) && - ((memlimit + (vifRegs->cycle.cl - vifRegs->cycle.wl) * 16) == tempsize) || + if (((vifRegs->cycle.cl != vifRegs->cycle.wl) && + ((memlimit + (vifRegs->cycle.cl - vifRegs->cycle.wl) * 16) == tempsize) || (tempsize == memlimit))) { //It's a red herring, so ignore it! SSE unpacks will be much quicker. @@ -637,12 +637,12 @@ static void VIFunpack(u32 *data, vifCode *v, unsigned int size, const unsigned i tempsize = size; size = 0; } - } - else + } + else { tempsize = 0; //Commenting out this then //tempsize = size; // -\_uncommenting these Two enables non-SSE unpacks - //size = 0; // -/ + //size = 0; // -/ } if (size >= ft->gsize) @@ -679,13 +679,13 @@ static void VIFunpack(u32 *data, vifCode *v, unsigned int size, const unsigned i } #endif - if ((vifRegs->cycle.cl == 0) || (vifRegs->cycle.wl == 0) || + if ((vifRegs->cycle.cl == 0) || (vifRegs->cycle.wl == 0) || ((vifRegs->cycle.cl == vifRegs->cycle.wl) && !(vifRegs->code & 0x10000000))) { oldcycle = *(u32*) & vifRegs->cycle; vifRegs->cycle.cl = vifRegs->cycle.wl = 1; } - + pfn = vif->usn ? VIFfuncTableSSE[unpackType].funcU : VIFfuncTableSSE[unpackType].funcS; writemask = VIFdmanum ? g_vif1HasMask3[min(vifRegs->cycle.wl,(u8)3)] : g_vif0HasMask3[min(vifRegs->cycle.wl,(u8)3)]; writemask = pfn[(((vifRegs->code & 0x10000000)>>28)<mode](dest, (u32*)cdata, size); @@ -700,7 +700,7 @@ static void VIFunpack(u32 *data, vifCode *v, unsigned int size, const unsigned i vifRegs->r2 = vifRow[2]; vifRegs->r3 = vifRow[3]; } - + // if size is left over, update the src,dst pointers if (writemask > 0) @@ -728,7 +728,7 @@ static void VIFunpack(u32 *data, vifCode *v, unsigned int size, const unsigned i vifRow[1] = vifRegs->r1; vifRow[2] = vifRegs->r2; vifRow[3] = vifRegs->r3; - } + } VIFUNPACK_LOG("leftover done, size %d, vifnum %d, addr %x", size, vifRegs->num, vif->tag.addr); } } @@ -739,25 +739,25 @@ static void VIFunpack(u32 *data, vifCode *v, unsigned int size, const unsigned i size = 0; } - } + } else if(tempsize) { int incdest = ((vifRegs->cycle.cl - vifRegs->cycle.wl) << 2) + 4; size = 0; int addrstart = v->addr; if((tempsize >> 2) != vif->tag.size) DevCon::Notice("split when size != tagsize"); - + VIFUNPACK_LOG("sorting tempsize :p, size %d, vifnum %d, addr %x", tempsize, vifRegs->num, vif->tag.addr); while ((tempsize >= ft->gsize) && (vifRegs->num > 0)) { - if(v->addr >= memlimit) + if(v->addr >= memlimit) { DevCon::Notice("Mem limit ovf"); v->addr &= (memlimit - 1); dest = (u32*)(VU->Mem + v->addr); } - + func(dest, (u32*)cdata, ft->qsize); cdata += ft->gsize; tempsize -= ft->gsize; @@ -773,7 +773,7 @@ static void VIFunpack(u32 *data, vifCode *v, unsigned int size, const unsigned i else { dest += 4; - v->addr += 16; + v->addr += 16; } } @@ -785,7 +785,7 @@ static void VIFunpack(u32 *data, vifCode *v, unsigned int size, const unsigned i vifRow[2] = vifRegs->r2; vifRow[3] = vifRegs->r3; } - if(v->addr >= memlimit) + if(v->addr >= memlimit) { v->addr &= (memlimit - 1); dest = (u32*)(VU->Mem + v->addr); @@ -818,9 +818,9 @@ static void VIFunpack(u32 *data, vifCode *v, unsigned int size, const unsigned i { if(vifRegs->cycle.cl > 0) // Quicker and avoids zero division :P - if((u32)(((size / ft->gsize) / vifRegs->cycle.cl) * vifRegs->cycle.wl) < vifRegs->num) + if((u32)(((size / ft->gsize) / vifRegs->cycle.cl) * vifRegs->cycle.wl) < vifRegs->num) DevCon::Notice("Filling write warning! %x < %x and CL = %x WL = %x", (size / ft->gsize), vifRegs->num, vifRegs->cycle.cl, vifRegs->cycle.wl); - + //DevCon::Notice("filling write %d cl %d, wl %d mask %x mode %x unpacktype %x addr %x", vifRegs->num, vifRegs->cycle.cl, vifRegs->cycle.wl, vifRegs->mask, vifRegs->mode, unpackType, vif->tag.addr); while (vifRegs->num > 0) { @@ -828,25 +828,25 @@ static void VIFunpack(u32 *data, vifCode *v, unsigned int size, const unsigned i { vif->cl = 0; } - + if (vif->cl < vifRegs->cycle.cl) /* unpack one qword */ { - if(size < ft->gsize) + if(size < ft->gsize) { VIF_LOG("Out of Filling write data"); break; } - + func(dest, (u32*)cdata, ft->qsize); cdata += ft->gsize; size -= ft->gsize; vif->cl++; vifRegs->num--; - + if (vif->cl == vifRegs->cycle.wl) { vif->cl = 0; - } + } } else { @@ -876,7 +876,7 @@ static void vuExecMicro(u32 addr, const u32 VIFdmanum) VU = &VU1; vif1FLUSH(); } - + if (VU->vifRegs->itops > (VIFdmanum ? 0x3ffu : 0xffu)) Console::WriteLn("VIF%d ITOP overrun! %x", VIFdmanum, VU->vifRegs->itops); @@ -890,7 +890,7 @@ static void vuExecMicro(u32 addr, const u32 VIFdmanum) /* is DBF flag set in VIF_STAT? */ if (VU->vifRegs->stat & VIF_STAT_DBF) { - /* it is, so set tops with base, and set the stat DBF flag */ + /* it is, so set tops with base, and set the stat DBF flag */ VU->vifRegs->tops = VU->vifRegs->base; VU->vifRegs->stat &= ~VIF_STAT_DBF; } @@ -955,7 +955,7 @@ static __forceinline void vif0UNPACK(u32 *data) vif0.tag.cmd = vif0.cmd; vif0Regs->offset = 0; - + } static __forceinline void vif0mpgTransfer(u32 addr, u32 *data, int size) @@ -1066,24 +1066,24 @@ static int __fastcall Vif0TransMPG(u32 *data) // MPG if (vif0.vifpacketsize < vif0.tag.size) { if((vif0.tag.addr + vif0.vifpacketsize) > 0x1000) DevCon::Notice("Vif0 MPG Split Overflow"); - + vif0mpgTransfer(vif0.tag.addr, data, vif0.vifpacketsize); vif0.tag.addr += vif0.vifpacketsize << 2; vif0.tag.size -= vif0.vifpacketsize; - + return vif0.vifpacketsize; } else { int ret; - + if((vif0.tag.addr + vif0.tag.size) > 0x1000) DevCon::Notice("Vif0 MPG Overflow"); - + vif0mpgTransfer(vif0.tag.addr, data, vif0.tag.size); ret = vif0.tag.size; vif0.tag.size = 0; vif0.cmd = 0; - + return ret; } } @@ -1091,28 +1091,28 @@ static int __fastcall Vif0TransMPG(u32 *data) // MPG static int __fastcall Vif0TransUnpack(u32 *data) // UNPACK { int ret; - + FreezeXMMRegs(1); if (vif0.vifpacketsize < vif0.tag.size) { - if(vif0Regs->offset != 0 || vif0.cl != 0) + if(vif0Regs->offset != 0 || vif0.cl != 0) { ret = vif0.tag.size; vif0.tag.size -= vif0.vifpacketsize - VIFalign(data, &vif0.tag, vif0.vifpacketsize, VIF0dmanum); ret = ret - vif0.tag.size; data += ret; - + if(vif0.vifpacketsize > 0) VIFunpack(data, &vif0.tag, vif0.vifpacketsize - ret, VIF0dmanum); - + ProcessMemSkip((vif0.vifpacketsize - ret) << 2, (vif0.cmd & 0xf), VIF0dmanum); vif0.tag.size -= (vif0.vifpacketsize - ret); FreezeXMMRegs(0); - + return vif0.vifpacketsize; - } + } /* size is less that the total size, transfer is 'in pieces' */ VIFunpack(data, &vif0.tag, vif0.vifpacketsize, VIF0dmanum); - + ProcessMemSkip(vif0.vifpacketsize << 2, (vif0.cmd & 0xf), VIF0dmanum); ret = vif0.vifpacketsize; @@ -1122,9 +1122,9 @@ static int __fastcall Vif0TransUnpack(u32 *data) // UNPACK { /* we got all the data, transfer it fully */ ret = vif0.tag.size; - + //Align data after a split transfer first - if ((vif0Regs->offset != 0) || (vif0.cl != 0)) + if ((vif0Regs->offset != 0) || (vif0.cl != 0)) { vif0.tag.size = VIFalign(data, &vif0.tag, vif0.tag.size, VIF0dmanum); data += ret - vif0.tag.size; @@ -1134,11 +1134,11 @@ static int __fastcall Vif0TransUnpack(u32 *data) // UNPACK { VIFunpack(data, &vif0.tag, vif0.tag.size, VIF0dmanum); } - + vif0.tag.size = 0; vif0.cmd = 0; } - + FreezeXMMRegs(0); return ret; } @@ -1244,7 +1244,7 @@ int VIF0transfer(u32 *data, int size, int istag) if (vif0.cmd) { vif0Regs->stat |= VIF0_STAT_VPS_T; //Decompression has started - + ret = Vif0TransTLB[(vif0.cmd & 0x7f)](data); data += ret; vif0.vifpacketsize -= ret; @@ -1253,7 +1253,7 @@ int VIF0transfer(u32 *data, int size, int istag) } if (vif0.tag.size != 0) Console::WriteLn("no vif0 cmd but tag size is left last cmd read %x", vif0Regs->code); - + // if interrupt and new cmd is NOT MARK if (vif0.irq) break; @@ -1280,7 +1280,7 @@ int VIF0transfer(u32 *data, int size, int istag) } vif0.cmd = 0; } - else + else { Vif0CMDTLB[(vif0.cmd & 0x7f)](); } @@ -1316,11 +1316,11 @@ int VIF0transfer(u32 *data, int size, int istag) if (((vif0Regs->code >> 24) & 0x7f) != 0x7)vif0Regs->stat |= VIF0_STAT_VIS; //else Console::WriteLn("VIF0 IRQ on MARK"); - + // spiderman doesn't break on qw boundaries vif0.irqoffset = transferred % 4; // cannot lose the offset - if (!istag) + if (!istag) { transferred = transferred >> 2; vif0ch->madr += (transferred << 4); @@ -1372,24 +1372,24 @@ int _chainVIF0() int id, ret; vif0ptag = (u32*)dmaGetAddr(vif0ch->tadr); //Set memory pointer to TADR - + if (!(Tag::Transfer("Vif0 Tag", vif0ch, vif0ptag))) return -1; - + vif0ch->madr = vif0ptag[1]; // MADR = ADDR field id = Tag::Id(vif0ptag); // ID for DmaChain copied from bit 28 of the tag g_vifCycles += 1; // Increase the QW read for the tag - + VIF_LOG("dmaChain %8.8x_%8.8x size=%d, id=%d, madr=%lx, tadr=%lx", vif0ptag[1], vif0ptag[0], vif0ch->qwc, id, vif0ch->madr, vif0ch->tadr); // Transfer dma tag if tte is set if (vif0ch->chcr.TTE) { - if (vif0.vifstalled) + if (vif0.vifstalled) ret = VIF0transfer(vif0ptag + (2 + vif0.irqoffset), 2 - vif0.irqoffset, 1); //Transfer Tag on stall - else + else ret = VIF0transfer(vif0ptag + 2, 2, 1); //Transfer Tag - + if (ret == -1) return -1; //There has been an error if (ret == -2) return -2; //IRQ set by VIFTransfer } @@ -1427,14 +1427,14 @@ void vif0Interrupt() vif0ch->chcr.STR = 0; return; } - + if (vif0ch->qwc > 0 || vif0.irqoffset > 0) { if (vif0.stallontag) _chainVIF0(); - else + else _VIF0chain(); - + CPU_INT(0, g_vifCycles); return; } @@ -1453,16 +1453,16 @@ void vif0Interrupt() if (vif0ch->qwc > 0) _VIF0chain(); - else + else _chainVIF0(); - + CPU_INT(0, g_vifCycles); return; } if (vif0ch->qwc > 0) Console::WriteLn("VIF0 Ending with QWC left"); if (vif0.cmd != 0) Console::WriteLn("vif0.cmd still set %x", vif0.cmd); - + vif0ch->chcr.STR = 0; hwDmacIrq(DMAC_VIF0); vif0Regs->stat &= ~VIF0_STAT_FQC; // FQC=0 @@ -1523,7 +1523,7 @@ void dmaVIF0() vif0.vifstalled = true; return; } - + vif0.done = true; CPU_INT(0, g_vifCycles); return; @@ -1545,7 +1545,7 @@ void vif0Write32(u32 mem, u32 value) vif0Regs->stat &= ~VIF0_STAT_MRK; vif0Regs->mark = value; break; - + case VIF0_FBRST: VIF_LOG("VIF0_FBRST write32 0x%8.8x", value); @@ -1562,7 +1562,7 @@ void vif0Write32(u32 mem, u32 value) vif0Regs->err._u32 = 0; vif0Regs->stat &= ~(VIF0_STAT_FQC | VIF0_STAT_INT | VIF0_STAT_VSS | VIF0_STAT_VIS | VIF0_STAT_VFS | VIF0_STAT_VPS); // FQC=0 } - + if (value & 0x2) { /* Force Break the VIF */ @@ -1573,7 +1573,7 @@ void vif0Write32(u32 mem, u32 value) vif0.vifstalled = true; Console::WriteLn("vif0 force break"); } - + if (value & 0x4) { /* Stop VIF */ @@ -1583,7 +1583,7 @@ void vif0Write32(u32 mem, u32 value) vif0Regs->stat &= ~VIF0_STAT_VPS; vif0.vifstalled = true; } - + if (value & 0x8) { bool cancel = false; @@ -1612,7 +1612,7 @@ void vif0Write32(u32 mem, u32 value) } } break; - + case VIF0_ERR: // ERR VIF_LOG("VIF0_ERR write32 0x%8.8x", value); @@ -1620,7 +1620,7 @@ void vif0Write32(u32 mem, u32 value) /* Set VIF0_ERR with 'value' */ vif0Regs->err._u32 = value; break; - + case VIF0_R0: case VIF0_R1: case VIF0_R2: @@ -1628,7 +1628,7 @@ void vif0Write32(u32 mem, u32 value) assert((mem&0xf) == 0); g_vifRow0[(mem>>4) & 3] = value; break; - + case VIF0_C0: case VIF0_C1: case VIF0_C2: @@ -1636,7 +1636,7 @@ void vif0Write32(u32 mem, u32 value) assert((mem&0xf) == 0); g_vifCol0[(mem>>4) & 3] = value; break; - + default: Console::WriteLn("Unknown Vif0 write to %x", mem); psHu32(mem) = value; @@ -1717,9 +1717,9 @@ static __forceinline void vif1UNPACK(u32 *data) int n = vif1Regs->cycle.cl * (vifNum / vif1Regs->cycle.wl) + _limit(vifNum % vif1Regs->cycle.wl, vif1Regs->cycle.cl); - vif1.tag.size = ((n * VIFfuncTable[ vif1.cmd & 0xf ].gsize) + 3) >> 2; - } - + vif1.tag.size = ((n * VIFfuncTable[ vif1.cmd & 0xf ].gsize) + 3) >> 2; + } + if ((vif1Regs->code >> 15) & 0x1) vif1.tag.addr = (vif1Regs->code + vif1Regs->tops) & 0x3ff; else @@ -1867,7 +1867,7 @@ static int __fastcall Vif1TransDirectHL(u32 *data) { vif1Regs->stat |= VIF1_STAT_VGW; return 0; - } + } } psHu32(GIF_STAT) |= (GIF_STAT_APATH2 | GIF_STAT_OPH); @@ -1887,7 +1887,7 @@ static int __fastcall Vif1TransDirectHL(u32 *data) FreezeRegs(1); // copy 16 bytes the fast way: const u64* src = (u64*)splittransfer[0]; - const uint count = mtgsThread->PrepDataPacket(GIF_PATH_2, nloop0_packet, 1); + mtgsThread->PrepDataPacket(GIF_PATH_2, nloop0_packet, 1); u64* dst = (u64*)mtgsThread->GetDataPacketPtr(); dst[0] = src[0]; dst[1] = src[1]; @@ -1945,7 +1945,7 @@ static int __fastcall Vif1TransUnpack(u32 *data) { int ret = vif1.tag.size; /* size is less that the total size, transfer is 'in pieces' */ - if(vif1Regs->offset != 0 || vif1.cl != 0) + if(vif1Regs->offset != 0 || vif1.cl != 0) { vif1.tag.size -= vif1.vifpacketsize - VIFalign(data, &vif1.tag, vif1.vifpacketsize, VIF1dmanum); ret = ret - vif1.tag.size; @@ -1955,7 +1955,7 @@ static int __fastcall Vif1TransUnpack(u32 *data) vif1.tag.size -= (vif1.vifpacketsize - ret); FreezeXMMRegs(0); return vif1.vifpacketsize; - } + } VIFunpack(data, &vif1.tag, vif1.vifpacketsize, VIF1dmanum); ProcessMemSkip(vif1.vifpacketsize << 2, (vif1.cmd & 0xf), VIF1dmanum); @@ -1967,7 +1967,7 @@ static int __fastcall Vif1TransUnpack(u32 *data) { int ret = vif1.tag.size; - if(vif1Regs->offset != 0 || vif1.cl != 0) + if(vif1Regs->offset != 0 || vif1.cl != 0) { vif1.tag.size = VIFalign(data, &vif1.tag, vif1.tag.size, VIF1dmanum); data += ret - vif1.tag.size; @@ -1976,7 +1976,7 @@ static int __fastcall Vif1TransUnpack(u32 *data) vif1.cmd = 0; FreezeXMMRegs(0); return ret; - } + } else { /* we got all the data, transfer it fully */ @@ -2046,11 +2046,11 @@ void Vif1MskPath3() // MSKPATH3 else { //Let the Gif know it can transfer again (making sure any vif stall isnt unset prematurely) - Path3progress = TRANSFER_MODE; + Path3progress = TRANSFER_MODE; psHu32(GIF_STAT) &= ~GIF_STAT_IMT; - CPU_INT(2, 4); + CPU_INT(2, 4); } - + schedulepath3msk = 0; } static void Vif1CMDMskPath3() // MSKPATH3 @@ -2060,7 +2060,7 @@ static void Vif1CMDMskPath3() // MSKPATH3 schedulepath3msk = 0x10 | ((vif1Regs->code >> 15) & 0x1); vif1.vifstalled = true; } - else + else { schedulepath3msk = (vif1Regs->code >> 15) & 0x1; Vif1MskPath3(); @@ -2084,8 +2084,8 @@ static void Vif1CMDFlush() // FLUSH/E/A { // Gif is already transferring so wait for it. if (((Path3progress != STOPPED_MODE) || !vif1Regs->mskpath3) && gif->chcr.STR) - { - vif1Regs->stat |= VIF1_STAT_VGW; + { + vif1Regs->stat |= VIF1_STAT_VGW; CPU_INT(2, 4); } } @@ -2208,19 +2208,19 @@ int VIF1transfer(u32 *data, int size, int istag) vif1.vifpacketsize = size; while (vif1.vifpacketsize > 0) - { + { if(vif1Regs->stat & VIF1_STAT_VGW) break; - + if (vif1.cmd) { vif1Regs->stat |= VIF1_STAT_VPS_T; //Decompression has started - + ret = Vif1TransTLB[vif1.cmd](data); data += ret; vif1.vifpacketsize -= ret; - + //We are once again waiting for a new vifcode as the command has cleared - if (vif1.cmd == 0) vif1Regs->stat &= ~VIF1_STAT_VPS_T; + if (vif1.cmd == 0) vif1Regs->stat &= ~VIF1_STAT_VPS_T; continue; } @@ -2288,7 +2288,7 @@ int VIF1transfer(u32 *data, int size, int istag) if (((vif1Regs->code >> 24) & 0x7f) != 0x7) vif1Regs->stat |= VIF1_STAT_VIS; // Note: commenting this out fixes WALL-E if (vif1ch->qwc == 0 && (vif1.irqoffset == 0 || istag == 1)) vif1.inprogress &= ~0x1; - + // spiderman doesn't break on qw boundaries if (istag) return -2; @@ -2308,14 +2308,14 @@ int VIF1transfer(u32 *data, int size, int istag) { transferred = transferred >> 2; vif1ch->madr += (transferred << 4); - vif1ch->qwc -= transferred; + vif1ch->qwc -= transferred; } - + if(vif1Regs->stat & VIF1_STAT_VGW) { vif1.vifstalled = true; } - + if (vif1ch->qwc == 0 && (vif1.irqoffset == 0 || istag == 1)) vif1.inprogress &= ~0x1; @@ -2345,7 +2345,7 @@ void vif1TransferFromMemory() // completely and execute the transfer there-after. FreezeXMMRegs(1); - + if (GSreadFIFO2 == NULL) { for (size = vif1ch->qwc; size > 0; --size) @@ -2369,9 +2369,9 @@ void vif1TransferFromMemory() psHu64(0x5000) = pMem[2*vif1ch->qwc-2]; psHu64(0x5008) = pMem[2*vif1ch->qwc-1]; } - + FreezeXMMRegs(0); - + g_vifCycles += vif1ch->qwc * 2; vif1ch->madr += vif1ch->qwc * 16; // mgs3 scene changes vif1ch->qwc = 0; @@ -2396,7 +2396,7 @@ int _VIF1chain() } pMem = (u32*)dmaGetAddr(vif1ch->madr); - if (pMem == NULL) + if (pMem == NULL) { vif1.cmd = 0; vif1.tag.size = 0; @@ -2436,9 +2436,9 @@ __forceinline void vif1SetupTransfer() int ret; vif1ptag = (u32*)dmaGetAddr(vif1ch->tadr); //Set memory pointer to TADR - + if (!(Tag::Transfer("Vif1 Tag", vif1ch, vif1ptag))) return; - + vif1ch->madr = vif1ptag[1]; //MADR = ADDR field g_vifCycles += 1; // Add 1 g_vifCycles from the QW read for the tag id = Tag::Id(vif1ptag); //ID for DmaChain copied from bit 28 of the tag @@ -2469,7 +2469,7 @@ __forceinline void vif1SetupTransfer() else ret = VIF1transfer(vif1ptag + 2, 2, 1); //Transfer Tag - if (ret < 0 && vif1.irqoffset < 2) + if (ret < 0 && vif1.irqoffset < 2) { vif1.inprogress = 0; //Better clear this so it has to do it again (Jak 1) return; //There has been an error or an interrupt @@ -2480,7 +2480,7 @@ __forceinline void vif1SetupTransfer() vif1.done |= hwDmacSrcChainWithStack(vif1ch, id); //Check TIE bit of CHCR and IRQ bit of tag - if (vif1ch->chcr.TIE && (Tag::IRQ(vif1ptag))) + if (vif1ch->chcr.TIE && (Tag::IRQ(vif1ptag))) { VIF_LOG("dmaIrq Set"); @@ -2502,12 +2502,12 @@ __forceinline void vif1Interrupt() if((vif1Regs->stat & VIF1_STAT_VGW)) { if (gif->chcr.STR) - { + { CPU_INT(1, gif->qwc * BIAS); return; - } + } else vif1Regs->stat &= ~VIF1_STAT_VGW; - + } if (!(vif1ch->chcr.STR)) Console::WriteLn("Vif1 running when CHCR == %x", vif1ch->chcr._u32); @@ -2520,7 +2520,7 @@ __forceinline void vif1Interrupt() if (vif1Regs->stat & (VIF1_STAT_VSS | VIF1_STAT_VIS | VIF1_STAT_VFS)) { vif1Regs->stat &= ~VIF1_STAT_FQC; // FQC=0 - + // One game doesnt like vif stalling at end, cant remember what. Spiderman isnt keen on it tho vif1ch->chcr.STR = 0; return; @@ -2534,7 +2534,7 @@ __forceinline void vif1Interrupt() } } - if (vif1.inprogress & 0x1) + if (vif1.inprogress & 0x1) { _VIF1chain(); CPU_INT(1, g_vifCycles); @@ -2555,8 +2555,8 @@ __forceinline void vif1Interrupt() CPU_INT(1, g_vifCycles); return; } - - if (vif1.vifstalled && vif1.irq) + + if (vif1.vifstalled && vif1.irq) { CPU_INT(1, 0); return; //Dont want to end if vif is stalled. @@ -2571,7 +2571,7 @@ __forceinline void vif1Interrupt() g_vifCycles = 0; hwDmacIrq(DMAC_VIF1); - //Im not totally sure why Path3 Masking makes it want to see stuff in the fifo + //Im not totally sure why Path3 Masking makes it want to see stuff in the fifo //Games effected by setting, Fatal Frame, KH2, Shox, Crash N Burn, GT3/4 possibly //Im guessing due to the full gs fifo before the reverse? (Refraction) //Note also this is only the condition for reverse fifo mode, normal direction clears it as normal @@ -2587,7 +2587,7 @@ void dmaVIF1() g_vifCycles = 0; vif1.inprogress = 0; - + if (dmacRegs->ctrl.MFD == MFD_VIF1) // VIF MFIFO { //Console::WriteLn("VIFMFIFO\n"); @@ -2595,7 +2595,7 @@ void dmaVIF1() if (vif1ch->chcr.MOD == NORMAL_MODE) Console::WriteLn("MFIFO mode is normal (which isn't normal here)! %x", vif1ch->chcr); vifMFIFOInterrupt(); return; - } + } #ifdef PCSX2_DEVBUILD if (dmacRegs->ctrl.STD == STD_VIF1) @@ -2615,14 +2615,14 @@ void dmaVIF1() else vif1.dmamode = VIF_NORMAL_FROM_MEM_MODE; } - else + else { vif1.dmamode = VIF_CHAIN_MODE; } if (vif1.dmamode != VIF_NORMAL_FROM_MEM_MODE) vif1Regs->stat |= 0x10000000; // FQC=16 - else + else vif1Regs->stat |= min((u16)16, vif1ch->qwc) << 24; // FQC=16 // Chain Mode @@ -2641,7 +2641,7 @@ void vif1Write32(u32 mem, u32 value) vif1Regs->stat &= ~VIF1_STAT_MRK; vif1Regs->mark = value; break; - + case VIF1_FBRST: // FBRST VIF_LOG("VIF1_FBRST write32 0x%8.8x", value); @@ -2654,19 +2654,19 @@ void vif1Write32(u32 mem, u32 value) psHu64(VIF1_FIFO) = 0; psHu64(VIF1_FIFO + 8) = 0; vif1.done = true; - + if(vif1Regs->mskpath3) { vif1Regs->mskpath3 = 0; gifRegs->stat.IMT = 0; - if (gif->chcr.STR) CPU_INT(2, 4); + if (gif->chcr.STR) CPU_INT(2, 4); } - + vif1Regs->err._u32 = 0; vif1.inprogress = 0; vif1Regs->stat &= ~(VIF1_STAT_FQC | VIF1_STAT_FDR | VIF1_STAT_INT | VIF1_STAT_VSS | VIF1_STAT_VIS | VIF1_STAT_VFS | VIF1_STAT_VPS); // FQC=0 } - + if (value & 0x2) { /* Force Break the VIF */ @@ -2677,7 +2677,7 @@ void vif1Write32(u32 mem, u32 value) vif1.vifstalled = true; Console::WriteLn("vif1 force break"); } - + if (value & 0x4) { /* Stop VIF */ @@ -2688,7 +2688,7 @@ void vif1Write32(u32 mem, u32 value) cpuRegs.interrupt &= ~((1 << 1) | (1 << 10)); //Stop all vif1 DMA's vif1.vifstalled = true; } - + if (value & 0x8) { bool cancel = false; @@ -2701,7 +2701,7 @@ void vif1Write32(u32 mem, u32 value) vif1Regs->stat &= ~(VIF1_STAT_VSS | VIF1_STAT_VFS | VIF1_STAT_VIS | VIF1_STAT_INT | VIF1_STAT_ER0 | VIF1_STAT_ER1); - + if (cancel) { if (vif1.vifstalled) @@ -2723,14 +2723,14 @@ void vif1Write32(u32 mem, u32 value) } } break; - + case VIF1_ERR: // ERR VIF_LOG("VIF1_ERR write32 0x%8.8x", value); /* Set VIF1_ERR with 'value' */ vif1Regs->err._u32 = value; break; - + case VIF1_STAT: // STAT VIF_LOG("VIF1_STAT write32 0x%8.8x", value); @@ -2759,11 +2759,11 @@ void vif1Write32(u32 mem, u32 value) vif1Regs->stat &= ~VIF1_STAT_FQC; // FQC=0 } break; - + case VIF1_MODE: // MODE vif1Regs->mode = value; break; - + case VIF1_R0: case VIF1_R1: case VIF1_R2: @@ -2771,7 +2771,7 @@ void vif1Write32(u32 mem, u32 value) assert((mem&0xf) == 0); g_vifRow1[(mem>>4) & 3] = value; break; - + case VIF1_C0: case VIF1_C1: case VIF1_C2: @@ -2779,7 +2779,7 @@ void vif1Write32(u32 mem, u32 value) assert((mem&0xf) == 0); g_vifCol1[(mem>>4) & 3] = value; break; - + default: Console::WriteLn("Unknown Vif1 write to %x", mem); psHu32(mem) = value; diff --git a/pcsx2/gui/Panels/PluginSelectorPanel.cpp b/pcsx2/gui/Panels/PluginSelectorPanel.cpp index 53a733c4a..c32d40dcb 100644 --- a/pcsx2/gui/Panels/PluginSelectorPanel.cpp +++ b/pcsx2/gui/Panels/PluginSelectorPanel.cpp @@ -1,6 +1,6 @@ /* 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. @@ -297,7 +297,7 @@ void Panels::PluginSelectorPanel::Apply() // ---------------------------------------------------------------------------- // Make sure folders are up to date, and try to load/reload plugins if needed... - + g_Conf->Folders.ApplyDefaults(); // Need to unload the current emulation state if the user changed plugins, because @@ -340,7 +340,7 @@ void Panels::PluginSelectorPanel::Apply() wxsFormat( L"The selected %s plugin failed to load.", plugname.c_str() ) + L"\n\n" + GetApplyFailedMsg() ); } - } + } } void Panels::PluginSelectorPanel::CancelRefresh() @@ -416,7 +416,8 @@ void Panels::PluginSelectorPanel::OnConfigure_Clicked( wxCommandEvent& evt ) wxDynamicLibrary dynlib( (*m_FileList)[(int)m_ComponentBoxes.Get(pid).GetClientData(sel)] ); if( PluginConfigureFnptr configfunc = (PluginConfigureFnptr)dynlib.GetSymbol( tbl_PluginInfo[pid].GetShortname() + L"configure" ) ) { - ScopedWindowDisable disabler( wxGetTopLevelParent( this ) ); + //ScopedWindowDisable disabler( wxGetTopLevelParent( this ) ); + wxWindowDisabler disabler; configfunc(); } } From 34af7c1281f817f283fb1ab66cbd96d9b6991640 Mon Sep 17 00:00:00 2001 From: arcum42 Date: Thu, 17 Sep 2009 23:24:44 +0000 Subject: [PATCH 03/12] Linux: IsRunning was crashing pcsx2. Also, jNO_DEFAULT isn't a good idea in these two spots. git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1845 96395faa-99c1-11dd-bbfe-3dabce05a288 --- common/src/Utilities/ThreadTools.cpp | 2 ++ pcsx2/gui/Panels/SpeedhacksPanel.cpp | 11 ++++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/common/src/Utilities/ThreadTools.cpp b/common/src/Utilities/ThreadTools.cpp index 934f77def..5d79f2ac7 100644 --- a/common/src/Utilities/ThreadTools.cpp +++ b/common/src/Utilities/ThreadTools.cpp @@ -165,6 +165,8 @@ namespace Threading bool PersistentThread::IsRunning() const { + if (!m_running) return false; + if( !!m_detached ) return !!m_running; else diff --git a/pcsx2/gui/Panels/SpeedhacksPanel.cpp b/pcsx2/gui/Panels/SpeedhacksPanel.cpp index 22e805265..3a4388a39 100644 --- a/pcsx2/gui/Panels/SpeedhacksPanel.cpp +++ b/pcsx2/gui/Panels/SpeedhacksPanel.cpp @@ -1,6 +1,6 @@ /* 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. @@ -47,7 +47,8 @@ const wxChar* Panels::SpeedHacksPanel::GetEEcycleSliderMsg( int val ) L"audio on many FMVs." ); - jNO_DEFAULT + default: + break; } return L"Unreachable Warning Suppressor!!"; @@ -78,8 +79,8 @@ const wxChar* Panels::SpeedHacksPanel::GetVUcycleSliderMsg( int val ) L"3 - Maximum VU Cycle Stealing. Usefulness is limited, as this will cause flickering " L"visuals or slowdown in most games." ); - - jNO_DEFAULT + default: + break; } return L"Unreachable Warning Suppressor!!"; @@ -172,7 +173,7 @@ Panels::SpeedHacksPanel::SpeedHacksPanel( wxWindow& parent, int idealWidth ) : L"Uses SSE's Min/Max Floating Point Operations instead of custom logical Min/Max routines. " L"Known to break Gran Tourismo 4, Tekken 5." ) ); - + m_check_vuMinMax->SetValue(opts.vuMinMax); // ------------------------------------------------------------------------ From e75043b91ebef912ce8090832377d7b12f636ce0 Mon Sep 17 00:00:00 2001 From: "Jake.Stine" Date: Thu, 17 Sep 2009 23:49:39 +0000 Subject: [PATCH 04/12] GSdx: Fixed GSDialog so that it doesn't cause PCSX2 to minimize into the background when closing the config box. PCSX2: Reloads plugins a little less often. git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1846 96395faa-99c1-11dd-bbfe-3dabce05a288 --- pcsx2/gui/Panels/PluginSelectorPanel.cpp | 1 - pcsx2/gui/Plugins.cpp | 7 ++++++- plugins/GSdx/GSDialog.cpp | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/pcsx2/gui/Panels/PluginSelectorPanel.cpp b/pcsx2/gui/Panels/PluginSelectorPanel.cpp index c32d40dcb..9115e16dc 100644 --- a/pcsx2/gui/Panels/PluginSelectorPanel.cpp +++ b/pcsx2/gui/Panels/PluginSelectorPanel.cpp @@ -416,7 +416,6 @@ void Panels::PluginSelectorPanel::OnConfigure_Clicked( wxCommandEvent& evt ) wxDynamicLibrary dynlib( (*m_FileList)[(int)m_ComponentBoxes.Get(pid).GetClientData(sel)] ); if( PluginConfigureFnptr configfunc = (PluginConfigureFnptr)dynlib.GetSymbol( tbl_PluginInfo[pid].GetShortname() + L"configure" ) ) { - //ScopedWindowDisable disabler( wxGetTopLevelParent( this ) ); wxWindowDisabler disabler; configfunc(); } diff --git a/pcsx2/gui/Plugins.cpp b/pcsx2/gui/Plugins.cpp index 04eaf186c..aa76a6735 100644 --- a/pcsx2/gui/Plugins.cpp +++ b/pcsx2/gui/Plugins.cpp @@ -173,17 +173,22 @@ void Pcsx2App::ReloadPlugins() // Posts a message to the App to reload plugins. Plugins are loaded via a background thread // which is started on a pending event, so don't expect them to be ready "right now." +// If plugins are already loaded then no action is performed. void LoadPluginsPassive() { + if( g_plugins ) return; + wxCommandEvent evt( pxEVT_ReloadPlugins ); wxGetApp().AddPendingEvent( evt ); } // Blocks until plugins have been successfully loaded, or throws an exception if -// the user cancels the loading procedure after error. +// the user cancels the loading procedure after error. If plugins are already loaded +// then no action is performed. void LoadPluginsImmediate() { wxASSERT( wxThread::IsMain() ); + if( g_plugins ) return; static int _reentrant = 0; EntryGuard guard( _reentrant ); diff --git a/plugins/GSdx/GSDialog.cpp b/plugins/GSdx/GSDialog.cpp index c47cc3597..50244c4a7 100644 --- a/plugins/GSdx/GSDialog.cpp +++ b/plugins/GSdx/GSDialog.cpp @@ -32,7 +32,7 @@ GSDialog::GSDialog(UINT id) INT_PTR GSDialog::DoModal() { - return DialogBoxParam(theApp.GetModuleHandle(), MAKEINTRESOURCE(m_id), NULL, DialogProc, (LPARAM)this); + return DialogBoxParam(theApp.GetModuleHandle(), MAKEINTRESOURCE(m_id), GetActiveWindow(), DialogProc, (LPARAM)this); } INT_PTR CALLBACK GSDialog::DialogProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) From b6918b1b9b27a1bb2ef08079e6c31c37d75a17cb Mon Sep 17 00:00:00 2001 From: arcum42 Date: Fri, 18 Sep 2009 00:01:44 +0000 Subject: [PATCH 05/12] Hook up the save/load menus and make the Linux console output somewhat less insane. git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1847 96395faa-99c1-11dd-bbfe-3dabce05a288 --- pcsx2/gui/ConsoleLogger.cpp | 3 ++- pcsx2/gui/MainMenuClicks.cpp | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/pcsx2/gui/ConsoleLogger.cpp b/pcsx2/gui/ConsoleLogger.cpp index 667cb2d9d..996a45532 100644 --- a/pcsx2/gui/ConsoleLogger.cpp +++ b/pcsx2/gui/ConsoleLogger.cpp @@ -574,7 +574,7 @@ namespace Console // [TODO] make this a configurable option? Do we care? :) #ifdef __LINUX__ // puts does automatic newlines, which we don't want here - fputs( "PCSX2 > ", stdout ); + //fputs( "PCSX2 > ", stdout ); fputs( src, stdout ); #endif @@ -635,6 +635,7 @@ namespace Console bool __fastcall WriteLn( const wxString& fmt ) { const wxString fmtline( fmt + L"\n" ); + _immediate_logger( "PCSX2 > "); _immediate_logger( fmtline ); if( emuLog != NULL ) diff --git a/pcsx2/gui/MainMenuClicks.cpp b/pcsx2/gui/MainMenuClicks.cpp index 6adfb1b20..de7e88c20 100644 --- a/pcsx2/gui/MainMenuClicks.cpp +++ b/pcsx2/gui/MainMenuClicks.cpp @@ -144,13 +144,15 @@ void MainEmuFrame::Menu_OpenELF_Click(wxCommandEvent &event) void MainEmuFrame::Menu_LoadStates_Click(wxCommandEvent &event) { int id = event.GetId() - MenuId_State_Load01 - 1; - Console::WriteLn("If this were hooked up, it would load slot %d.", id); + Console::WriteLn("Loading slot %d.", id); + States_Load(id); } void MainEmuFrame::Menu_SaveStates_Click(wxCommandEvent &event) { int id = event.GetId() - MenuId_State_Save01 - 1; - Console::WriteLn("If this were hooked up, it would save slot %d.", id); + Console::WriteLn("Saving to slot %d.", id); + States_Save(id); } void MainEmuFrame::Menu_LoadStateOther_Click(wxCommandEvent &event) From 8372c48285a382c924c6ead712dd2232592fadf7 Mon Sep 17 00:00:00 2001 From: mattmenke Date: Fri, 18 Sep 2009 06:58:48 +0000 Subject: [PATCH 06/12] LilyPad: Switched to using pre-compiled headers, just for kicks. Compiles significantly faster, though it's not exactly the limiting factor in batch builds. Changed intermediate debug build directory, for consistency. Added another LilyPad-only build option, to compile without CRT dependencies, as manifests are evil. Finally nuked the VC 2005 project. git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1850 96395faa-99c1-11dd-bbfe-3dabce05a288 --- plugins/LilyPad/Config.cpp | 8 - plugins/LilyPad/Config.h | 3 - plugins/LilyPad/DeviceEnumerator.cpp | 1 - plugins/LilyPad/Diagnostics.cpp | 3 - plugins/LilyPad/DirectInput.cpp | 5 +- plugins/LilyPad/DirectInput.h | 2 - plugins/LilyPad/DualShock3.cpp | 1 - plugins/LilyPad/DualShock3.h | 1 - plugins/LilyPad/Global.cpp | 1 + plugins/LilyPad/Global.h | 21 + plugins/LilyPad/InputManager.cpp | 3 +- plugins/LilyPad/KeyboardHook.cpp | 2 - plugins/LilyPad/KeyboardQueue.cpp | 1 + plugins/LilyPad/KeyboardQueue.h | 2 - plugins/LilyPad/LilyPad.cpp | 51 +- plugins/LilyPad/LilyPad_VC2005.sln | 25 - plugins/LilyPad/LilyPad_VC2005.vcproj | 764 -------------------------- plugins/LilyPad/LilyPad_VC2008.vcproj | 514 +++++++++++++---- plugins/LilyPad/RawInput.cpp | 1 - plugins/LilyPad/RawInput.h | 2 - plugins/LilyPad/VKey.cpp | 3 +- plugins/LilyPad/WindowsKeyboard.h | 2 - plugins/LilyPad/WindowsMessaging.h | 2 - plugins/LilyPad/WindowsMouse.h | 2 - plugins/LilyPad/WndProcEater.cpp | 1 + plugins/LilyPad/WndProcEater.h | 2 - plugins/LilyPad/XInput.cpp | 1 - plugins/LilyPad/usb.h | 3 - 28 files changed, 462 insertions(+), 965 deletions(-) create mode 100644 plugins/LilyPad/Global.cpp delete mode 100644 plugins/LilyPad/LilyPad_VC2005.sln delete mode 100644 plugins/LilyPad/LilyPad_VC2005.vcproj diff --git a/plugins/LilyPad/Config.cpp b/plugins/LilyPad/Config.cpp index d790eb8d0..8fcc55938 100644 --- a/plugins/LilyPad/Config.cpp +++ b/plugins/LilyPad/Config.cpp @@ -1,17 +1,9 @@ #include "Global.h" -#include -#include -#include "Config.h" #include "PS2Edefs.h" #include "Resource.h" #include "Diagnostics.h" -#include -#include -#include -#include #include "DeviceEnumerator.h" -#include "InputManager.h" #include "KeyboardQueue.h" #include "WndProcEater.h" #include "DualShock3.h" diff --git a/plugins/LilyPad/Config.h b/plugins/LilyPad/Config.h index ff8737330..be5d96048 100644 --- a/plugins/LilyPad/Config.h +++ b/plugins/LilyPad/Config.h @@ -1,9 +1,6 @@ #ifndef CONFIG_H #define CONFIG_H -#include "InputManager.h" -#include "PS2Etypes.h" - extern u8 ps2e; enum PadType { diff --git a/plugins/LilyPad/DeviceEnumerator.cpp b/plugins/LilyPad/DeviceEnumerator.cpp index ccd8dfeca..cd41ce8fd 100644 --- a/plugins/LilyPad/DeviceEnumerator.cpp +++ b/plugins/LilyPad/DeviceEnumerator.cpp @@ -1,6 +1,5 @@ #include "Global.h" #include "DeviceEnumerator.h" -#include "InputManager.h" #include "WindowsMessaging.h" #include "DirectInput.h" #include "KeyboardHook.h" diff --git a/plugins/LilyPad/Diagnostics.cpp b/plugins/LilyPad/Diagnostics.cpp index 07c2f3812..6e19343fd 100644 --- a/plugins/LilyPad/Diagnostics.cpp +++ b/plugins/LilyPad/Diagnostics.cpp @@ -1,10 +1,7 @@ #include "Global.h" -#include "InputManager.h" #include "DeviceEnumerator.h" #include "resource.h" #include "KeyboardQueue.h" -#include -#include Device *dev; diff --git a/plugins/LilyPad/DirectInput.cpp b/plugins/LilyPad/DirectInput.cpp index 93d244d09..540a340f4 100644 --- a/plugins/LilyPad/DirectInput.cpp +++ b/plugins/LilyPad/DirectInput.cpp @@ -1,13 +1,10 @@ -#define DIRECTINPUT_VERSION 0x0800 - #include "Global.h" + #include "VKey.h" #include "DirectInput.h" #include -#include "InputManager.h" #include "DeviceEnumerator.h" #include "PS2Etypes.h" -#include // All for getting GUIDs of XInput devices.... #include diff --git a/plugins/LilyPad/DirectInput.h b/plugins/LilyPad/DirectInput.h index 9d263f7e5..e20606702 100644 --- a/plugins/LilyPad/DirectInput.h +++ b/plugins/LilyPad/DirectInput.h @@ -1,3 +1 @@ -#include "InputManager.h" - void EnumDirectInputDevices(int ignoreXInput); diff --git a/plugins/LilyPad/DualShock3.cpp b/plugins/LilyPad/DualShock3.cpp index 5a422242a..fdc1cb807 100644 --- a/plugins/LilyPad/DualShock3.cpp +++ b/plugins/LilyPad/DualShock3.cpp @@ -1,7 +1,6 @@ #include "Global.h" #include "usb.h" #include "HidDevice.h" -#include "InputManager.h" #define VID 0x054c diff --git a/plugins/LilyPad/DualShock3.h b/plugins/LilyPad/DualShock3.h index 97d7df3ba..1c46774d3 100644 --- a/plugins/LilyPad/DualShock3.h +++ b/plugins/LilyPad/DualShock3.h @@ -1,6 +1,5 @@ int DualShock3Possible(); void EnumDualShock3s(); -#include "InputManager.h" // May move elsewhere in the future. int InitLibUsb(); diff --git a/plugins/LilyPad/Global.cpp b/plugins/LilyPad/Global.cpp new file mode 100644 index 000000000..a57d59275 --- /dev/null +++ b/plugins/LilyPad/Global.cpp @@ -0,0 +1 @@ +#include "Global.h" diff --git a/plugins/LilyPad/Global.h b/plugins/LilyPad/Global.h index 92543f5aa..ef2823822 100644 --- a/plugins/LilyPad/Global.h +++ b/plugins/LilyPad/Global.h @@ -3,6 +3,8 @@ // dll size by over 100k while avoiding any dependencies on updated CRT dlls. #pragma once +#define DIRECTINPUT_VERSION 0x0800 + #ifdef NO_CRT #define _CRT_ALLOCATION_DEFINED #endif @@ -27,6 +29,15 @@ #include +#include +#include +#include +#include + +#include +// Only needed for DBT_DEVNODES_CHANGED +#include + #include "PS2Etypes.h" #include "PS2Edefs.h" @@ -66,7 +77,17 @@ EXPORT_C_(s32) PADfreeze(int mode, freezeData *data); EXPORT_C_(s32) PADsetSlot(u8 port, u8 slot); EXPORT_C_(s32) PADqueryMtap(u8 port); +#include "InputManager.h" +#include "Config.h" #ifdef NO_CRT + +#define malloc MyMalloc +#define calloc MyCalloc +#define free MyFree +#define realloc MyRealloc +#define wcsdup MyWcsdup +#define wcsicmp MyWcsicmp + inline void * malloc(size_t size) { return HeapAlloc(GetProcessHeap(), 0, size); } diff --git a/plugins/LilyPad/InputManager.cpp b/plugins/LilyPad/InputManager.cpp index 43b82668d..50d1b2715 100644 --- a/plugins/LilyPad/InputManager.cpp +++ b/plugins/LilyPad/InputManager.cpp @@ -1,7 +1,6 @@ -#include "InputManager.h" #include "Global.h" +#include "InputManager.h" #include "KeyboardQueue.h" -#include InputDeviceManager *dm = 0; diff --git a/plugins/LilyPad/KeyboardHook.cpp b/plugins/LilyPad/KeyboardHook.cpp index d3c45d989..b80dbc674 100644 --- a/plugins/LilyPad/KeyboardHook.cpp +++ b/plugins/LilyPad/KeyboardHook.cpp @@ -1,9 +1,7 @@ #include "Global.h" #include "KeyboardHook.h" -#include "InputManager.h" #include "WindowsKeyboard.h" -#include "Config.h" #include "VKey.h" #include "WndProcEater.h" #include "DeviceEnumerator.h" diff --git a/plugins/LilyPad/KeyboardQueue.cpp b/plugins/LilyPad/KeyboardQueue.cpp index 70badb83d..c8498ee11 100644 --- a/plugins/LilyPad/KeyboardQueue.cpp +++ b/plugins/LilyPad/KeyboardQueue.cpp @@ -1,3 +1,4 @@ +#include "Global.h" // This is undoubtedly completely unnecessary. #include "KeyboardQueue.h" diff --git a/plugins/LilyPad/KeyboardQueue.h b/plugins/LilyPad/KeyboardQueue.h index 3b8407be7..c5e44afad 100644 --- a/plugins/LilyPad/KeyboardQueue.h +++ b/plugins/LilyPad/KeyboardQueue.h @@ -1,5 +1,3 @@ -#include "Global.h" -#include "PS2Edefs.h" // This entire thing isn't really needed, // but takes little enough effort to be safe... diff --git a/plugins/LilyPad/LilyPad.cpp b/plugins/LilyPad/LilyPad.cpp index 646d7ce55..701a6744d 100644 --- a/plugins/LilyPad/LilyPad.cpp +++ b/plugins/LilyPad/LilyPad.cpp @@ -1,17 +1,10 @@ #include "Global.h" -#include -#include -#include // For escape timer, so as not to break GSDX+DX9. #include #define PADdefs -#include "PS2Etypes.h" -#include "PS2Edefs.h" -#include "Config.h" -#include "InputManager.h" #include "DeviceEnumerator.h" #include "WndProcEater.h" #include "KeyboardQueue.h" @@ -596,27 +589,26 @@ u32 CALLBACK PS2EgetLibVersion2(u32 type) { // Used in about and config screens. void GetNameAndVersionString(wchar_t *out) { -#ifdef PCSX2_DEBUG - wsprintfW(out, L"LilyPad Debug %i.%i.%i (r%i)", (VERSION>>8)&0xFF, VERSION&0xFF, (VERSION>>24)&0xFF, SVN_REV); -#elif (_MSC_VER != 1400) +#ifdef NO_CRT wsprintfW(out, L"LilyPad svn %i.%i.%i (r%i)", (VERSION>>8)&0xFF, VERSION&0xFF, (VERSION>>24)&0xFF, SVN_REV); +#elif defined(PCSX2_DEBUG) + wsprintfW(out, L"LilyPad Debug %i.%i.%i (r%i)", (VERSION>>8)&0xFF, VERSION&0xFF, (VERSION>>24)&0xFF, SVN_REV); #else wsprintfW(out, L"LilyPad %i.%i.%i", (VERSION>>8)&0xFF, VERSION&0xFF, (VERSION>>24)&0xFF, SVN_REV); #endif } char* CALLBACK PSEgetLibName() { -#ifdef PCSX2_DEBUG +#ifdef NO_CRT + return "LilyPad"; +#elif defined(PCSX2_DEBUG) static char version[50]; sprintf(version, "LilyPad Debug (r%i)", SVN_REV); return version; #else - #if (_MSC_VER != 1400) - static char version[50]; - sprintf(version, "LilyPad svn (r%i)", SVN_REV); - return version; - #endif - return "LilyPad"; + static char version[50]; + sprintf(version, "LilyPad svn (r%i)", SVN_REV); + return version; #endif } @@ -1412,18 +1404,6 @@ u32 CALLBACK PSEgetLibVersion() { return (VERSION & 0xFFFFFF); } -// Little funkiness to handle rounding floating points to ints without the C runtime. -// Unfortunately, means I can't use /GL optimization option when NO_CRT is defined. -#ifdef NO_CRT -extern "C" long _cdecl _ftol(); -extern "C" long _cdecl _ftol2_sse() { - return _ftol(); -} -extern "C" long _cdecl _ftol2() { - return _ftol(); -} -#endif - s32 CALLBACK PADqueryMtap(u8 port) { port--; if (port > 1) return 0; @@ -1441,3 +1421,16 @@ s32 CALLBACK PADsetSlot(u8 port, u8 slot) { // First slot always allowed. return pads[port][slot].enabled | !slot; } + +// Little funkiness to handle rounding floating points to ints without the C runtime. +// Unfortunately, means I can't use /GL optimization option when NO_CRT is defined. +#ifdef NO_CRT +extern "C" long _cdecl _ftol(); +extern "C" long _cdecl _ftol2_sse() { + return _ftol(); +} +extern "C" long _cdecl _ftol2() { + return _ftol(); +} +#endif + diff --git a/plugins/LilyPad/LilyPad_VC2005.sln b/plugins/LilyPad/LilyPad_VC2005.sln deleted file mode 100644 index a5dc5d75f..000000000 --- a/plugins/LilyPad/LilyPad_VC2005.sln +++ /dev/null @@ -1,25 +0,0 @@ -Microsoft Visual Studio Solution File, Format Version 9.00 -# Visual Studio 2005 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "LilyPad", "LilyPad_VC2005.vcproj", "{E4081455-398C-4610-A87C-90A8A7D72DC3}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Debug|x64 = Debug|x64 - Release|Win32 = Release|Win32 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {E4081455-398C-4610-A87C-90A8A7D72DC3}.Debug|Win32.ActiveCfg = Debug|Win32 - {E4081455-398C-4610-A87C-90A8A7D72DC3}.Debug|Win32.Build.0 = Debug|Win32 - {E4081455-398C-4610-A87C-90A8A7D72DC3}.Debug|x64.ActiveCfg = Debug|x64 - {E4081455-398C-4610-A87C-90A8A7D72DC3}.Debug|x64.Build.0 = Debug|x64 - {E4081455-398C-4610-A87C-90A8A7D72DC3}.Release|Win32.ActiveCfg = Release|Win32 - {E4081455-398C-4610-A87C-90A8A7D72DC3}.Release|Win32.Build.0 = Release|Win32 - {E4081455-398C-4610-A87C-90A8A7D72DC3}.Release|x64.ActiveCfg = Release|x64 - {E4081455-398C-4610-A87C-90A8A7D72DC3}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/plugins/LilyPad/LilyPad_VC2005.vcproj b/plugins/LilyPad/LilyPad_VC2005.vcproj deleted file mode 100644 index 474764ddb..000000000 --- a/plugins/LilyPad/LilyPad_VC2005.vcproj +++ /dev/null @@ -1,764 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/plugins/LilyPad/LilyPad_VC2008.vcproj b/plugins/LilyPad/LilyPad_VC2008.vcproj index 037a6f92d..c1fbce1b5 100644 --- a/plugins/LilyPad/LilyPad_VC2008.vcproj +++ b/plugins/LilyPad/LilyPad_VC2008.vcproj @@ -20,7 +20,6 @@ + + + + + + + + + + + + + + + + + + + @@ -183,90 +268,6 @@ Name="VCPostBuildEventTool" /> - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -506,14 +784,6 @@ PreprocessorDefinitions="" /> - - - @@ -522,6 +792,14 @@ PreprocessorDefinitions="" /> + + + @@ -530,6 +808,22 @@ PreprocessorDefinitions="" /> + + + + + + + + + + + + +#include "VKey.h" wchar_t *GetVKStringW(unsigned char vk) { int flag; diff --git a/plugins/LilyPad/WindowsKeyboard.h b/plugins/LilyPad/WindowsKeyboard.h index 938ec1dc0..bff14e941 100644 --- a/plugins/LilyPad/WindowsKeyboard.h +++ b/plugins/LilyPad/WindowsKeyboard.h @@ -1,5 +1,3 @@ -#include "InputManager.h" - // Shared functionality for WM and RAW keyboards. class WindowsKeyboard : public Device { public: diff --git a/plugins/LilyPad/WindowsMessaging.h b/plugins/LilyPad/WindowsMessaging.h index 11957fda5..8b9661638 100644 --- a/plugins/LilyPad/WindowsMessaging.h +++ b/plugins/LilyPad/WindowsMessaging.h @@ -1,3 +1 @@ -#include "InputManager.h" - void EnumWindowsMessagingDevices(); diff --git a/plugins/LilyPad/WindowsMouse.h b/plugins/LilyPad/WindowsMouse.h index 5fa5772c4..938e2256d 100644 --- a/plugins/LilyPad/WindowsMouse.h +++ b/plugins/LilyPad/WindowsMouse.h @@ -1,5 +1,3 @@ -#include "InputManager.h" - // Shared functionality for WM and RAW keyboards. class WindowsMouse : public Device { public: diff --git a/plugins/LilyPad/WndProcEater.cpp b/plugins/LilyPad/WndProcEater.cpp index 27d27cbde..a79247e11 100644 --- a/plugins/LilyPad/WndProcEater.cpp +++ b/plugins/LilyPad/WndProcEater.cpp @@ -1,3 +1,4 @@ +#include "Global.h" #include "WndProcEater.h" static HWND hWndEaten = 0; diff --git a/plugins/LilyPad/WndProcEater.h b/plugins/LilyPad/WndProcEater.h index b85af1fd2..b6821a632 100644 --- a/plugins/LilyPad/WndProcEater.h +++ b/plugins/LilyPad/WndProcEater.h @@ -1,5 +1,3 @@ -#include "Global.h" - #define EATPROC_NO_UPDATE_WHILE_UPDATING_DEVICES 1 /* Need this to let window be subclassed multiple times but still clean up nicely. diff --git a/plugins/LilyPad/XInput.cpp b/plugins/LilyPad/XInput.cpp index e24a0ed11..1a25d9740 100644 --- a/plugins/LilyPad/XInput.cpp +++ b/plugins/LilyPad/XInput.cpp @@ -1,7 +1,6 @@ #include "Global.h" #include "VKey.h" #include -#include "InputManager.h" // This way, I don't require that XInput junk be installed. typedef void (CALLBACK *_XInputEnable)(BOOL enable); diff --git a/plugins/LilyPad/usb.h b/plugins/LilyPad/usb.h index b00591cec..c6c5dca40 100644 --- a/plugins/LilyPad/usb.h +++ b/plugins/LilyPad/usb.h @@ -3,9 +3,6 @@ #ifndef __USB_H__ #define __USB_H__ -#include -#include - /* * 'interface' is defined somewhere in the Windows header files. This macro * is deleted here to avoid conflicts and compile errors. From 8a1df8dbb183d5e6cff79f96e576c0b49b42f3c1 Mon Sep 17 00:00:00 2001 From: arcum42 Date: Fri, 18 Sep 2009 07:37:21 +0000 Subject: [PATCH 07/12] Same changes to ZeroSPU2 & spu2-x's projects. ifdeffed out a few things in spu2-x. git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1851 96395faa-99c1-11dd-bbfe-3dabce05a288 --- pcsx2-codeblocks.workspace | 9 +++++++-- pcsx2/gui/ConsoleLogger.cpp | 15 ++++++++++++--- plugins/spu2-x/src/DllInterface.cpp | 2 ++ plugins/spu2-x/src/Linux/Config.cpp | 2 +- plugins/spu2-x/src/Linux/SPU2-X.cbp | 25 ++++--------------------- plugins/spu2-x/src/SndOut.cpp | 2 ++ plugins/spu2-x/src/Spu2.cpp | 19 ++++++++++++++++++- plugins/zerospu2/Linux/ZeroSPU2.cbp | 25 ++++--------------------- 8 files changed, 50 insertions(+), 49 deletions(-) diff --git a/pcsx2-codeblocks.workspace b/pcsx2-codeblocks.workspace index 6aa305ae6..f5e96284a 100644 --- a/pcsx2-codeblocks.workspace +++ b/pcsx2-codeblocks.workspace @@ -1,7 +1,7 @@ - + @@ -22,6 +22,11 @@ - + + + + + + diff --git a/pcsx2/gui/ConsoleLogger.cpp b/pcsx2/gui/ConsoleLogger.cpp index 996a45532..5e39cf656 100644 --- a/pcsx2/gui/ConsoleLogger.cpp +++ b/pcsx2/gui/ConsoleLogger.cpp @@ -565,6 +565,7 @@ namespace Console // they are implemented here using a mutex lock for maximum safety. static void _immediate_logger( const char* src ) { + ScopedLock locker( immediate_log_lock ); if( emuLog != NULL ) @@ -574,8 +575,16 @@ namespace Console // [TODO] make this a configurable option? Do we care? :) #ifdef __LINUX__ // puts does automatic newlines, which we don't want here - //fputs( "PCSX2 > ", stdout ); - fputs( src, stdout ); + + /*if (strchr(src, '\n')) + { + fputs( "PCSX2 > ", stdout ); + fputs( src , stdout); + } + else + {*/ + fputs( src, stdout ); + //} #endif } @@ -635,7 +644,7 @@ namespace Console bool __fastcall WriteLn( const wxString& fmt ) { const wxString fmtline( fmt + L"\n" ); - _immediate_logger( "PCSX2 > "); + //_immediate_logger( "PCSX2 > "); _immediate_logger( fmtline ); if( emuLog != NULL ) diff --git a/plugins/spu2-x/src/DllInterface.cpp b/plugins/spu2-x/src/DllInterface.cpp index e6d39bb69..11fce3a26 100644 --- a/plugins/spu2-x/src/DllInterface.cpp +++ b/plugins/spu2-x/src/DllInterface.cpp @@ -250,7 +250,9 @@ EXPORT_C_(void) SPU2close() if( !spu2open ) return; FileLog("[%10d] SPU2 Close\n",Cycles); +#ifndef __LINUX__ DspCloseLibrary(); +#endif spdif_shutdown(); SndBuffer::Cleanup(); diff --git a/plugins/spu2-x/src/Linux/Config.cpp b/plugins/spu2-x/src/Linux/Config.cpp index bdb995b36..848ce31b2 100644 --- a/plugins/spu2-x/src/Linux/Config.cpp +++ b/plugins/spu2-x/src/Linux/Config.cpp @@ -103,6 +103,6 @@ void configure() ReadSettings(); } -void SysMessage(char const*, ...) +void MessageBox(char const*, ...) { } diff --git a/plugins/spu2-x/src/Linux/SPU2-X.cbp b/plugins/spu2-x/src/Linux/SPU2-X.cbp index f127945b6..45edff99f 100644 --- a/plugins/spu2-x/src/Linux/SPU2-X.cbp +++ b/plugins/spu2-x/src/Linux/SPU2-X.cbp @@ -15,6 +15,9 @@ + + + @@ -51,27 +55,6 @@ - - - - - - - - - - - - - - - - - - - - - diff --git a/plugins/spu2-x/src/SndOut.cpp b/plugins/spu2-x/src/SndOut.cpp index 33ada97d1..29588ccf4 100644 --- a/plugins/spu2-x/src/SndOut.cpp +++ b/plugins/spu2-x/src/SndOut.cpp @@ -328,6 +328,7 @@ void SndBuffer::Write( const StereoOut32& Sample ) ssFreeze--; return; } +#ifndef __LINUX__ else if( dspPluginEnabled ) { // Convert in, send to winamp DSP, and convert out. @@ -357,6 +358,7 @@ void SndBuffer::Write( const StereoOut32& Sample ) ); } } +#endif else { if( !timeStretchDisabled ) diff --git a/plugins/spu2-x/src/Spu2.cpp b/plugins/spu2-x/src/Spu2.cpp index 0a4fb6271..ffe65eae8 100644 --- a/plugins/spu2-x/src/Spu2.cpp +++ b/plugins/spu2-x/src/Spu2.cpp @@ -67,6 +67,7 @@ void SetIrqCall() has_to_call_irq=true; } +#ifndef __LINUX__ void SysMessage(const char *fmt, ...) { va_list list; @@ -79,6 +80,19 @@ void SysMessage(const char *fmt, ...) swprintf_s(wtmp, L"%S", tmp); MessageBox(0, wtmp, L"SPU2-X System Message", 0); } +#else +void SysMessage(const char *fmt, ...) +{ + va_list list; + char tmp[512]; + wchar_t wtmp[512]; + + va_start(list,fmt); + sprintf(tmp,fmt,list); + va_end(list); + printf("%s", tmp); +} +#endif __forceinline s16 * __fastcall GetMemPtr(u32 addr) { @@ -791,7 +805,10 @@ static __forceinline u16 GetLoWord( s32& src ) return ((u16*)&src)[0]; } -__forceinline void SPU2_FastWrite( u32 rmem, u16 value ) +#ifndef __LINUX__ +__forceinline +#endif +void SPU2_FastWrite( u32 rmem, u16 value ) { u32 vx=0, vc=0, core=0, omem, mem; omem=mem=rmem & 0x7FF; //FFFF; diff --git a/plugins/zerospu2/Linux/ZeroSPU2.cbp b/plugins/zerospu2/Linux/ZeroSPU2.cbp index a80e65769..84c03b361 100644 --- a/plugins/zerospu2/Linux/ZeroSPU2.cbp +++ b/plugins/zerospu2/Linux/ZeroSPU2.cbp @@ -16,6 +16,9 @@ + + + @@ -53,27 +57,6 @@ - - - - - - - - - - - - - - - - - - - - - From 504082f52db36f5b98a64fe159042f1559047d98 Mon Sep 17 00:00:00 2001 From: mattmenke Date: Fri, 18 Sep 2009 10:18:56 +0000 Subject: [PATCH 08/12] wxWidgets: Clicking on the sliders on the hacks screen now works. Scroll rate is very inconsistent, but that's just wxWidgets doing what it does best (worst?)... Also fixed a minor bug in LilyPad version labeling. git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1853 96395faa-99c1-11dd-bbfe-3dabce05a288 --- pcsx2/gui/Panels/ConfigurationPanels.h | 1 + pcsx2/gui/Panels/SpeedhacksPanel.cpp | 33 ++++++++++++++++++++++++++ plugins/LilyPad/LilyPad.cpp | 4 ++-- 3 files changed, 36 insertions(+), 2 deletions(-) diff --git a/pcsx2/gui/Panels/ConfigurationPanels.h b/pcsx2/gui/Panels/ConfigurationPanels.h index eb8ec32f4..7d647d65a 100644 --- a/pcsx2/gui/Panels/ConfigurationPanels.h +++ b/pcsx2/gui/Panels/ConfigurationPanels.h @@ -250,6 +250,7 @@ namespace Panels const wxChar* GetEEcycleSliderMsg( int val ); const wxChar* GetVUcycleSliderMsg( int val ); + void Slider_Click(wxScrollEvent &event); void EECycleRate_Scroll(wxScrollEvent &event); void VUCycleRate_Scroll(wxScrollEvent &event); }; diff --git a/pcsx2/gui/Panels/SpeedhacksPanel.cpp b/pcsx2/gui/Panels/SpeedhacksPanel.cpp index 3a4388a39..964546b86 100644 --- a/pcsx2/gui/Panels/SpeedhacksPanel.cpp +++ b/pcsx2/gui/Panels/SpeedhacksPanel.cpp @@ -216,6 +216,17 @@ Panels::SpeedHacksPanel::SpeedHacksPanel( wxWindow& parent, int idealWidth ) : mainSizer.Add( &miscSizer, SizerFlags::TopLevelBox() ); SetSizer( &mainSizer ); + // There has to be a cleaner way to do this... + int ids[2] = {m_slider_eecycle->GetId(), m_slider_vustealer->GetId()}; + for (int i=0; i<2; i++) { + Connect( ids[i], wxEVT_SCROLL_PAGEUP, wxScrollEventHandler( SpeedHacksPanel::Slider_Click ) ); + Connect( ids[i], wxEVT_SCROLL_PAGEDOWN, wxScrollEventHandler( SpeedHacksPanel::Slider_Click ) ); + Connect( ids[i], wxEVT_SCROLL_LINEUP, wxScrollEventHandler( SpeedHacksPanel::Slider_Click ) ); + Connect( ids[i], wxEVT_SCROLL_LINEDOWN, wxScrollEventHandler( SpeedHacksPanel::Slider_Click ) ); + Connect( ids[i], wxEVT_SCROLL_TOP, wxScrollEventHandler( SpeedHacksPanel::Slider_Click ) ); + Connect( ids[i], wxEVT_SCROLL_BOTTOM, wxScrollEventHandler( SpeedHacksPanel::Slider_Click ) ); + } + Connect( m_slider_eecycle->GetId(), wxEVT_SCROLL_CHANGED, wxScrollEventHandler( SpeedHacksPanel::EECycleRate_Scroll ) ); Connect( m_slider_vustealer->GetId(), wxEVT_SCROLL_CHANGED, wxScrollEventHandler( SpeedHacksPanel::VUCycleRate_Scroll ) ); } @@ -233,6 +244,28 @@ void Panels::SpeedHacksPanel::Apply() opts.vuMinMax = m_check_vuMinMax->GetValue(); } +void Panels::SpeedHacksPanel::Slider_Click(wxScrollEvent &event) { + wxSlider* slider = (wxSlider*) event.GetEventObject(); + int value = slider->GetValue(); + int eventType = event.GetEventType(); + if (eventType == wxEVT_SCROLL_PAGEUP || eventType == wxEVT_SCROLL_LINEUP) { + if (value > slider->GetMin()) { + slider->SetValue(value-1); + } + } + else if (eventType == wxEVT_SCROLL_TOP) { + slider->SetValue(slider->GetMin()); + } + else if (eventType == wxEVT_SCROLL_PAGEDOWN || eventType == wxEVT_SCROLL_LINEDOWN) { + if (value < slider->GetMax()) { + slider->SetValue(value+1); + } + } + else if (eventType == wxEVT_SCROLL_BOTTOM) { + slider->SetValue(slider->GetMax()); + } +} + void Panels::SpeedHacksPanel::EECycleRate_Scroll(wxScrollEvent &event) { m_msg_eecycle->SetLabel(GetEEcycleSliderMsg(m_slider_eecycle->GetValue())); diff --git a/plugins/LilyPad/LilyPad.cpp b/plugins/LilyPad/LilyPad.cpp index 701a6744d..9a9a076f1 100644 --- a/plugins/LilyPad/LilyPad.cpp +++ b/plugins/LilyPad/LilyPad.cpp @@ -590,11 +590,11 @@ u32 CALLBACK PS2EgetLibVersion2(u32 type) { // Used in about and config screens. void GetNameAndVersionString(wchar_t *out) { #ifdef NO_CRT - wsprintfW(out, L"LilyPad svn %i.%i.%i (r%i)", (VERSION>>8)&0xFF, VERSION&0xFF, (VERSION>>24)&0xFF, SVN_REV); + wsprintfW(out, L"LilyPad %i.%i.%i", (VERSION>>8)&0xFF, VERSION&0xFF, (VERSION>>24)&0xFF, SVN_REV); #elif defined(PCSX2_DEBUG) wsprintfW(out, L"LilyPad Debug %i.%i.%i (r%i)", (VERSION>>8)&0xFF, VERSION&0xFF, (VERSION>>24)&0xFF, SVN_REV); #else - wsprintfW(out, L"LilyPad %i.%i.%i", (VERSION>>8)&0xFF, VERSION&0xFF, (VERSION>>24)&0xFF, SVN_REV); + wsprintfW(out, L"LilyPad svn %i.%i.%i (r%i)", (VERSION>>8)&0xFF, VERSION&0xFF, (VERSION>>24)&0xFF, SVN_REV); #endif } From 3ccb4d3698fee7794ca250ce7484013091431867 Mon Sep 17 00:00:00 2001 From: "Jake.Stine" Date: Fri, 18 Sep 2009 14:07:36 +0000 Subject: [PATCH 09/12] Re-re-re-re-fixed the BIOS skip hack saving on exit (plus lots of code cleanups and some API changes to saving/loading settings -- more to come). Linux/GCC: Disabled __forceinlining in debug builds. This is the intended design, fixes many GCC errors in debug builds, and also mimics MSVC behavior. git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1854 96395faa-99c1-11dd-bbfe-3dabce05a288 --- common/include/Pcsx2Defs.h | 6 +- common/include/Utilities/Exceptions.h | 20 ++- common/src/Utilities/Exceptions.cpp | 17 +++ pcsx2/gui/App.h | 94 ++++++-------- pcsx2/gui/AppConfig.cpp | 6 +- pcsx2/gui/AppConfig.h | 5 +- pcsx2/gui/AppMain.cpp | 140 ++++++++++++--------- pcsx2/gui/Dialogs/ConfigurationDialog.cpp | 4 +- pcsx2/gui/Dialogs/ImportSettingsDialog.cpp | 4 +- pcsx2/gui/MainFrame.cpp | 26 ++-- pcsx2/gui/MainFrame.h | 4 + pcsx2/gui/MainMenuClicks.cpp | 48 ++++--- pcsx2/gui/Panels/MiscPanelStuff.cpp | 4 +- pcsx2/gui/Plugins.cpp | 2 +- pcsx2/gui/Saveslots.cpp | 2 +- 15 files changed, 226 insertions(+), 156 deletions(-) diff --git a/common/include/Pcsx2Defs.h b/common/include/Pcsx2Defs.h index 4b1938674..d1a2ee125 100644 --- a/common/include/Pcsx2Defs.h +++ b/common/include/Pcsx2Defs.h @@ -227,7 +227,11 @@ This theoretically unoptimizes. Not having much luck so far. # define __fastcall __attribute__((fastcall)) # define __unused __attribute__((unused)) # define _inline __inline__ __attribute__((unused)) -# define __forceinline __attribute__((always_inline,unused)) +# ifdef NDEBUG +# define __forceinline __attribute__((always_inline,unused)) +# else +# define __forceinline // no forceinlines in debug builds +# endif # define __noinline __attribute__((noinline)) # define __hot __attribute__((hot)) # define __cold __attribute__((cold)) diff --git a/common/include/Utilities/Exceptions.h b/common/include/Utilities/Exceptions.h index 6d9b0e39b..e437d3260 100644 --- a/common/include/Utilities/Exceptions.h +++ b/common/include/Utilities/Exceptions.h @@ -144,7 +144,7 @@ namespace Exception explicit classname( const wxString& msg_eng ) { BaseException::InitBaseEx( msg_eng, wxEmptyString ); } // --------------------------------------------------------------------------------------- - // Generalized Exceptions: RuntimeError / LogicError / AssertionFailure + // Generalized Exceptions: RuntimeError / LogicError / ObjectIsNull // --------------------------------------------------------------------------------------- class RuntimeError : public virtual BaseException @@ -161,6 +161,24 @@ namespace Exception DEFINE_LOGIC_EXCEPTION( LogicError, wxLt("An unhandled logic error has occurred.") ) }; + class ObjectIsNull : public RuntimeError + { + public: + wxString ObjectName; + + DEFINE_EXCEPTION_COPYTORS( ObjectIsNull ) + + explicit ObjectIsNull( const char* objname="unspecified" ) + { + m_message_diag = wxString::FromUTF8( objname ); + // overridden message formatters only use the diagnostic version... + } + + + virtual wxString FormatDisplayMessage() const; + virtual wxString FormatDiagnosticMessage() const; + }; + // --------------------------------------------------------------------------------------- // OutOfMemory / InvalidOperation / InvalidArgument / IndexBoundsFault / ParseError // --------------------------------------------------------------------------------------- diff --git a/common/src/Utilities/Exceptions.cpp b/common/src/Utilities/Exceptions.cpp index bbfe5d0d2..b4201b822 100644 --- a/common/src/Utilities/Exceptions.cpp +++ b/common/src/Utilities/Exceptions.cpp @@ -100,6 +100,23 @@ namespace Exception return m_message_diag + L"\n\n" + m_stacktrace; } + // ------------------------------------------------------------------------ + wxString ObjectIsNull::FormatDiagnosticMessage() const + { + return wxsFormat( + L"An attempted reference to the %s has failed; the frame does not exist or it's handle is null.", + m_message_diag.c_str() + ) + m_stacktrace; + } + + wxString ObjectIsNull::FormatDisplayMessage() const + { + return wxsFormat( + L"An attempted reference to the %s has failed; the frame does not exist or it's handle is null.", + m_message_diag.c_str() + ); + } + // ------------------------------------------------------------------------ wxString Stream::FormatDiagnosticMessage() const { diff --git a/pcsx2/gui/App.h b/pcsx2/gui/App.h index fedcf7326..ae0d546ef 100644 --- a/pcsx2/gui/App.h +++ b/pcsx2/gui/App.h @@ -136,42 +136,9 @@ enum DialogIdentifiers DialogId_About, }; -////////////////////////////////////////////////////////////////////////////////////////// -// ScopedWindowDisable -// -// This class is a fix helper for WXGTK ports of PCSX2, which need the current window to -// be disabled in order for plugin-created modal dialogs to receive messages. This disabling -// causes problems in Win32/MSW, where some plugins' modal dialogs will cause all PCSX2 -// windows to minimize on closure. -// -class ScopedWindowDisable -{ - DeclareNoncopyableObject( ScopedWindowDisable ) - -protected: - wxWindow& m_window; - -public: - ScopedWindowDisable( wxWindow* whee ) : - m_window( *whee ) - { - #ifdef __WXGTK__ - wxASSERT( whee != NULL ); - m_window.Disable(); - #endif - } - - ~ScopedWindowDisable() - { -#ifdef __WXGTK__ - m_window.Enable(); - m_window.SetFocus(); -#endif - } -}; - -////////////////////////////////////////////////////////////////////////////////////////// -// +// -------------------------------------------------------------------------------------- +// AppImageIds - Config and Toolbar Images and Icons +// -------------------------------------------------------------------------------------- struct AppImageIds { struct ConfigIds @@ -214,7 +181,6 @@ struct AppImageIds } Toolbars; }; - struct MsgboxEventResult { Semaphore WaitForMe; @@ -260,34 +226,14 @@ public: void ReloadPlugins(); - void ApplySettings( const AppConfig* oldconf = NULL ); - void LoadSettings(); - void SaveSettings(); - void PostMenuAction( MenuIdentifiers menu_id ) const; int ThreadedModalDialog( DialogIdentifiers dialogId ); void Ping() const; bool PrepForExit(); - // Executes the emulator using a saved/existing virtual machine state and currently - // configured CDVD source device. - // Debug assertions: void SysExecute(); void SysExecute( CDVD_SourceType cdvdsrc ); - - void SysResume() - { - if( !m_CoreThread ) return; - m_CoreThread->Resume(); - } - - void SysSuspend() - { - if( !m_CoreThread ) return; - m_CoreThread->Suspend(); - } - void SysReset() { m_CoreThread.reset(); @@ -311,6 +257,22 @@ public: wxASSERT( m_MainFrame != NULL ); return *m_MainFrame; } + + MainEmuFrame& GetMainFrameOrExcept() const + { + if( m_MainFrame == NULL ) + throw Exception::ObjectIsNull( "main application frame" ); + + return *m_MainFrame; + } + + CoreEmuThread& GetCoreThreadOrExcept() const + { + if( !m_CoreThread ) + throw Exception::ObjectIsNull( "core emulation thread" ); + + return *m_CoreThread; + } // -------------------------------------------------------------------------- // Overrides of wxApp virtuals: @@ -434,3 +396,21 @@ extern bool pxIsValidWindowPosition( const wxWindow& window, const wxPoint& wind extern bool HandlePluginError( Exception::PluginError& ex ); extern bool EmulationInProgress(); +#define TryInvoke( obj, runme ) \ +{ \ + try { \ + wxGetApp().Get##obj##OrExcept().runme; \ + } \ + catch( Exception::ObjectIsNull& ) { } \ +} + +extern void AppLoadSettings(); +extern void AppSaveSettings(); +extern void AppApplySettings( const AppConfig* oldconf=NULL ); + +extern void SysSuspend(); +extern void SysResume(); +extern void SysReset(); +extern void SysExecute(); +extern void SysExecute( CDVD_SourceType cdvdsrc ); + diff --git a/pcsx2/gui/AppConfig.cpp b/pcsx2/gui/AppConfig.cpp index eeaea5c10..403772ada 100644 --- a/pcsx2/gui/AppConfig.cpp +++ b/pcsx2/gui/AppConfig.cpp @@ -511,7 +511,7 @@ wxFileConfig* OpenFileConfig( const wxString& filename ) // overwrite - this option forces the current settings to overwrite any existing settings that might // be saved to the configured ini/settings folder. // -void AppConfig_ReloadGlobalSettings( bool overwrite ) +void AppConfig_OnChangedSettingsFolder( bool overwrite ) { PathDefs::GetDocuments().Mkdir(); PathDefs::GetSettings().Mkdir(); @@ -521,9 +521,9 @@ void AppConfig_ReloadGlobalSettings( bool overwrite ) wxConfigBase::Get()->SetRecordDefaults(); if( !overwrite ) - wxGetApp().LoadSettings(); + AppLoadSettings(); - wxGetApp().ApplySettings(); + AppApplySettings(); g_Conf->Folders.Logs.Mkdir(); wxString newlogname( Path::Combine( g_Conf->Folders.Logs.ToString(), L"emuLog.txt" ) ); diff --git a/pcsx2/gui/AppConfig.h b/pcsx2/gui/AppConfig.h index 30776fc07..9f22dbaec 100644 --- a/pcsx2/gui/AppConfig.h +++ b/pcsx2/gui/AppConfig.h @@ -163,11 +163,8 @@ public: void LoadSaveUserMode( IniInterface& ini, const wxString& cwdhash ); -protected: void LoadSave( IniInterface& ini ); void LoadSaveMemcards( IniInterface& ini ); - - friend class Pcsx2App; }; struct ConfigOverrides @@ -179,6 +176,6 @@ struct ConfigOverrides extern ConfigOverrides OverrideOptions; extern wxFileConfig* OpenFileConfig( const wxString& filename ); -extern void AppConfig_ReloadGlobalSettings( bool overwrite = false ); +extern void AppConfig_OnChangedSettingsFolder( bool overwrite = false ); extern wxScopedPtr g_Conf; diff --git a/pcsx2/gui/AppMain.cpp b/pcsx2/gui/AppMain.cpp index 04dfc0eba..6b4377e62 100644 --- a/pcsx2/gui/AppMain.cpp +++ b/pcsx2/gui/AppMain.cpp @@ -132,44 +132,6 @@ void AppEmuThread::StateCheck() } } -// Executes the emulator using a saved/existing virtual machine state and currently -// configured CDVD source device. -void Pcsx2App::SysExecute() -{ - SysReset(); - LoadPluginsImmediate(); - m_CoreThread.reset( new AppEmuThread( *m_CorePlugins ) ); - m_CoreThread->Resume(); -} - -// Executes the specified cdvd source and optional elf file. This command performs a -// full closure of any existing VM state and starts a fresh VM with the requested -// sources. -void Pcsx2App::SysExecute( CDVD_SourceType cdvdsrc ) -{ - SysReset(); - 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(); -} - __forceinline bool EmulationInProgress() { return wxGetApp().EmuInProgress(); @@ -297,8 +259,8 @@ void Pcsx2App::ReadUserModeSettings() // Save user's new settings IniSaver saver( *conf_usermode ); g_Conf->LoadSaveUserMode( saver, groupname ); - AppConfig_ReloadGlobalSettings( true ); - wxGetApp().SaveSettings(); + AppConfig_OnChangedSettingsFolder( true ); + AppSaveSettings(); } else { @@ -322,8 +284,8 @@ void Pcsx2App::ReadUserModeSettings() // Save user's new settings IniSaver saver( *conf_usermode ); g_Conf->LoadSaveUserMode( saver, groupname ); - AppConfig_ReloadGlobalSettings( true ); - wxGetApp().SaveSettings(); + AppConfig_OnChangedSettingsFolder( true ); + AppSaveSettings(); } } } @@ -448,7 +410,7 @@ bool Pcsx2App::OnInit() delete wxLog::SetActiveTarget( new pxLogConsole() ); ReadUserModeSettings(); - AppConfig_ReloadGlobalSettings(); + AppConfig_OnChangedSettingsFolder(); m_MainFrame = new MainEmuFrame( NULL, L"PCSX2" ); @@ -465,7 +427,7 @@ bool Pcsx2App::OnInit() m_MainFrame->Show(); SysDetect(); - ApplySettings(); + AppApplySettings(); m_CoreAllocs.reset( new EmuCoreAllocations() ); @@ -697,7 +659,7 @@ int Pcsx2App::OnExit() PrepForExit(); if( g_Conf ) - SaveSettings(); + AppSaveSettings(); while( wxGetLocale() != NULL ) delete wxGetLocale(); @@ -726,7 +688,7 @@ Pcsx2App::~Pcsx2App() CleanupMess(); } -void Pcsx2App::ApplySettings( const AppConfig* oldconf ) +void AppApplySettings( const AppConfig* oldconf ) { DevAssert( wxThread::IsMain(), "ApplySettings valid from the GUI thread only." ); @@ -756,14 +718,11 @@ void Pcsx2App::ApplySettings( const AppConfig* oldconf ) } } - if( m_MainFrame != NULL ) - m_MainFrame->ApplySettings(); - - if( m_CoreThread ) - m_CoreThread->ApplySettings( g_Conf->EmuOptions ); + TryInvoke( MainFrame, ApplySettings() ); + TryInvoke( CoreThread, ApplySettings( g_Conf->EmuOptions ) ); } -void Pcsx2App::LoadSettings() +void AppLoadSettings() { wxConfigBase* conf = wxConfigBase::Get( false ); if( NULL == conf ) return; @@ -771,11 +730,10 @@ void Pcsx2App::LoadSettings() IniLoader loader( *conf ); g_Conf->LoadSave( loader ); - if( m_MainFrame != NULL && m_MainFrame->m_RecentIsoList ) - m_MainFrame->m_RecentIsoList->Load( *conf ); + TryInvoke( MainFrame, LoadRecentIsoList( *conf ) ); } -void Pcsx2App::SaveSettings() +void AppSaveSettings() { wxConfigBase* conf = wxConfigBase::Get( false ); if( NULL == conf ) return; @@ -783,6 +741,74 @@ void Pcsx2App::SaveSettings() IniSaver saver( *conf ); g_Conf->LoadSave( saver ); - if( m_MainFrame != NULL && m_MainFrame->m_RecentIsoList ) - m_MainFrame->m_RecentIsoList->Save( *conf ); + TryInvoke( MainFrame, SaveRecentIsoList( *conf ) ); +} + +// -------------------------------------------------------------------------------------- +// Sys/Core API and Shortcuts (for wxGetApp()) +// -------------------------------------------------------------------------------------- + +// Executes the emulator using a saved/existing virtual machine state and currently +// configured CDVD source device. +void Pcsx2App::SysExecute() +{ + SysReset(); + LoadPluginsImmediate(); + m_CoreThread.reset( new AppEmuThread( *m_CorePlugins ) ); + m_CoreThread->Resume(); +} + +// Executes the specified cdvd source and optional elf file. This command performs a +// full closure of any existing VM state and starts a fresh VM with the requested +// sources. +void Pcsx2App::SysExecute( CDVD_SourceType cdvdsrc ) +{ + SysReset(); + 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(); +} + +// Executes the emulator using a saved/existing virtual machine state and currently +// configured CDVD source device. +void SysExecute() +{ + wxGetApp().SysExecute(); +} + +void SysExecute( CDVD_SourceType cdvdsrc ) +{ + wxGetApp().SysExecute( cdvdsrc ); +} + +void SysResume() +{ + TryInvoke( CoreThread, Resume() ); +} + +void SysSuspend() +{ + TryInvoke( CoreThread, Suspend() ); +} + +void SysReset() +{ + wxGetApp().SysReset(); } diff --git a/pcsx2/gui/Dialogs/ConfigurationDialog.cpp b/pcsx2/gui/Dialogs/ConfigurationDialog.cpp index e4bb328b7..8f7dfd1a5 100644 --- a/pcsx2/gui/Dialogs/ConfigurationDialog.cpp +++ b/pcsx2/gui/Dialogs/ConfigurationDialog.cpp @@ -120,7 +120,7 @@ void Dialogs::ConfigurationDialog::OnOk_Click( wxCommandEvent& evt ) { FindWindow( wxID_APPLY )->Disable(); g_Conf->SettingsTabName = m_labels[m_listbook.GetSelection()]; - wxGetApp().SaveSettings(); + AppSaveSettings(); Close(); evt.Skip(); @@ -139,7 +139,7 @@ void Dialogs::ConfigurationDialog::OnApply_Click( wxCommandEvent& evt ) FindWindow( wxID_APPLY )->Disable(); g_Conf->SettingsTabName = m_labels[m_listbook.GetSelection()]; - wxGetApp().SaveSettings(); + AppSaveSettings(); } diff --git a/pcsx2/gui/Dialogs/ImportSettingsDialog.cpp b/pcsx2/gui/Dialogs/ImportSettingsDialog.cpp index 31796f2f0..6cd165291 100644 --- a/pcsx2/gui/Dialogs/ImportSettingsDialog.cpp +++ b/pcsx2/gui/Dialogs/ImportSettingsDialog.cpp @@ -55,14 +55,14 @@ Dialogs::ImportSettingsDialog::ImportSettingsDialog( wxWindow* parent ) : void Dialogs::ImportSettingsDialog::OnImport_Click( __unused wxCommandEvent& evt ) { - AppConfig_ReloadGlobalSettings( false ); // ... and import existing settings + AppConfig_OnChangedSettingsFolder( false ); // ... and import existing settings g_Conf->Folders.Bios.Mkdir(); EndModal( wxID_OK ); } void Dialogs::ImportSettingsDialog::OnOverwrite_Click( __unused wxCommandEvent& evt ) { - AppConfig_ReloadGlobalSettings( true ); // ... and overwrite any existing settings + AppConfig_OnChangedSettingsFolder( true ); // ... and overwrite any existing settings g_Conf->Folders.Bios.Mkdir(); EndModal( wxID_OK ); } diff --git a/pcsx2/gui/MainFrame.cpp b/pcsx2/gui/MainFrame.cpp index 13691b039..78e558e99 100644 --- a/pcsx2/gui/MainFrame.cpp +++ b/pcsx2/gui/MainFrame.cpp @@ -88,6 +88,19 @@ void MainEmuFrame::UpdateIsoSrcFile() GetMenuBar()->SetLabel( MenuId_Src_Iso, label ); } +void MainEmuFrame::LoadRecentIsoList( wxConfigBase& conf ) +{ + if( m_RecentIsoList ) + m_RecentIsoList->Load( conf ); +} + +void MainEmuFrame::SaveRecentIsoList( wxConfigBase& conf ) +{ + if( m_RecentIsoList ) + m_RecentIsoList->Load( conf ); +} + + // ------------------------------------------------------------------------ // Video / Audio / Pad "Extensible" Menus // ------------------------------------------------------------------------ @@ -174,18 +187,15 @@ void MainEmuFrame::ConnectMenus() #define ConnectMenu( id, handler ) \ Connect( id, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainEmuFrame::handler) ) - #define ConnectMenuRange( id_start, inc, handler ) \ Connect( id_start, id_start + inc, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainEmuFrame::handler) ) ConnectMenu( MenuId_Config_Settings, Menu_ConfigSettings_Click ); ConnectMenu( MenuId_Config_BIOS, Menu_SelectBios_Click ); - ConnectMenuRange(wxID_FILE1, 20, Menu_IsoRecent_Click); - - ConnectMenuRange(MenuId_Config_GS, PluginId_Count, Menu_ConfigPlugin_Click); - - ConnectMenuRange(MenuId_Src_Iso, 3, Menu_CdvdSource_Click); + ConnectMenuRange(wxID_FILE1, 20, Menu_IsoRecent_Click); + ConnectMenuRange(MenuId_Config_GS, PluginId_Count, Menu_ConfigPlugin_Click); + ConnectMenuRange(MenuId_Src_Iso, 3, Menu_CdvdSource_Click); ConnectMenu( MenuId_Video_Advanced, Menu_ConfigPlugin_Click); ConnectMenu( MenuId_Audio_Advanced, Menu_ConfigPlugin_Click); @@ -194,6 +204,7 @@ void MainEmuFrame::ConnectMenus() ConnectMenu( MenuId_Boot_CDVD, Menu_BootCdvd_Click ); ConnectMenu( MenuId_Boot_ELF, Menu_OpenELF_Click ); ConnectMenu( MenuId_IsoBrowse, Menu_IsoBrowse_Click ); + ConnectMenu( MenuId_SkipBiosToggle, Menu_SkipBiosToggle_Click ); ConnectMenu( MenuId_Exit, Menu_Exit_Click ); ConnectMenu( MenuId_Emu_Pause, Menu_EmuPause_Click ); @@ -440,6 +451,8 @@ MainEmuFrame::~MainEmuFrame() throw() void MainEmuFrame::ApplySettings() { + GetMenuBar()->Check( MenuId_SkipBiosToggle, g_Conf->EmuOptions.SkipBiosSplash ); + // Always perform delete and reload of the Recent Iso List. This handles cases where // the recent file count has been changed, and it's a helluva lot easier than trying // to make a clone copy of this complex object. ;) @@ -452,7 +465,6 @@ void MainEmuFrame::ApplySettings() m_RecentIsoList.reset(); m_RecentIsoList.reset( new wxFileHistory( g_Conf->RecentFileCount ) ); m_RecentIsoList->Load( *cfg ); - UpdateIsoSrcFile(); cfg->Flush(); } diff --git a/pcsx2/gui/MainFrame.h b/pcsx2/gui/MainFrame.h index f5b115634..149962f51 100644 --- a/pcsx2/gui/MainFrame.h +++ b/pcsx2/gui/MainFrame.h @@ -72,6 +72,9 @@ public: void UpdateIsoSrcFile(); void UpdateIsoSrcSelection(); void ApplySettings(); + + void LoadRecentIsoList( wxConfigBase& conf ); + void SaveRecentIsoList( wxConfigBase& conf ); protected: void InitLogBoxPosition( AppConfig::ConsoleLogOptions& conf ); @@ -85,6 +88,7 @@ protected: void Menu_RunIso_Click(wxCommandEvent &event); void Menu_IsoBrowse_Click(wxCommandEvent &event); void Menu_IsoRecent_Click(wxCommandEvent &event); + void Menu_SkipBiosToggle_Click(wxCommandEvent &event); void Menu_BootCdvd_Click(wxCommandEvent &event); void Menu_OpenELF_Click(wxCommandEvent &event); diff --git a/pcsx2/gui/MainMenuClicks.cpp b/pcsx2/gui/MainMenuClicks.cpp index de7e88c20..1bd644e52 100644 --- a/pcsx2/gui/MainMenuClicks.cpp +++ b/pcsx2/gui/MainMenuClicks.cpp @@ -29,7 +29,7 @@ void MainEmuFrame::Menu_ConfigSettings_Click(wxCommandEvent &event) { if( Dialogs::ConfigurationDialog( this ).ShowModal() ) { - wxGetApp().SaveSettings(); + AppSaveSettings(); } } @@ -37,7 +37,7 @@ void MainEmuFrame::Menu_SelectBios_Click(wxCommandEvent &event) { if( Dialogs::BiosSelectorDialog( this ).ShowModal() ) { - wxGetApp().SaveSettings(); + AppSaveSettings(); } } @@ -52,7 +52,7 @@ void MainEmuFrame::Menu_CdvdSource_Click( wxCommandEvent &event ) jNO_DEFAULT } UpdateIsoSrcSelection(); - wxGetApp().SaveSettings(); + AppSaveSettings(); } // Returns FALSE if the user cancelled the action. @@ -71,7 +71,7 @@ bool MainEmuFrame::_DoSelectIsoBrowser() { g_Conf->Folders.RunIso = wxFileName( ctrl.GetPath() ).GetPath(); g_Conf->CurrentIso = ctrl.GetPath(); - wxGetApp().SaveSettings(); + AppSaveSettings(); UpdateIsoSrcFile(); return true; @@ -82,13 +82,13 @@ bool MainEmuFrame::_DoSelectIsoBrowser() void MainEmuFrame::Menu_BootCdvd_Click( wxCommandEvent &event ) { - wxGetApp().SysSuspend(); + SysSuspend(); if( !wxFileExists( g_Conf->CurrentIso ) ) { if( !_DoSelectIsoBrowser() ) { - wxGetApp().SysResume(); + SysResume(); return; } } @@ -100,35 +100,35 @@ void MainEmuFrame::Menu_BootCdvd_Click( wxCommandEvent &event ) if( !result ) { - wxGetApp().SysResume(); + SysResume(); return; } } g_Conf->EmuOptions.SkipBiosSplash = GetMenuBar()->IsChecked( MenuId_SkipBiosToggle ); - wxGetApp().SaveSettings(); + AppSaveSettings(); - wxGetApp().SysExecute( g_Conf->CdvdSource ); + SysExecute( g_Conf->CdvdSource ); } void MainEmuFrame::Menu_IsoBrowse_Click( wxCommandEvent &event ) { - wxGetApp().SysSuspend(); + SysSuspend(); _DoSelectIsoBrowser(); - wxGetApp().SysResume(); + SysResume(); } void MainEmuFrame::Menu_RunIso_Click( wxCommandEvent &event ) { - wxGetApp().SysSuspend(); + SysSuspend(); if( !_DoSelectIsoBrowser() ) { - wxGetApp().SysResume(); + SysResume(); return; } - wxGetApp().SysExecute( CDVDsrc_Iso ); + SysExecute( CDVDsrc_Iso ); } void MainEmuFrame::Menu_IsoRecent_Click(wxCommandEvent &event) @@ -137,6 +137,18 @@ void MainEmuFrame::Menu_IsoRecent_Click(wxCommandEvent &event) //Console::WriteLn( Color_Magenta, g_RecentIsoList->GetHistoryFile( event.GetId() - g_RecentIsoList->GetBaseId() ) ); } +#include "IniInterface.h" + +void MainEmuFrame::Menu_SkipBiosToggle_Click( wxCommandEvent &event ) +{ + g_Conf->EmuOptions.SkipBiosSplash = GetMenuBar()->IsChecked( MenuId_SkipBiosToggle ); + + wxConfigBase* conf = wxConfigBase::Get( false ); + if( NULL == conf ) return; + IniSaver saver( *conf ); + g_Conf->EmuOptions.LoadSave( saver ); +} + void MainEmuFrame::Menu_OpenELF_Click(wxCommandEvent &event) { } @@ -179,20 +191,20 @@ void MainEmuFrame::Menu_EmuClose_Click(wxCommandEvent &event) void MainEmuFrame::Menu_EmuPause_Click(wxCommandEvent &event) { if( event.IsChecked() ) - wxGetApp().SysSuspend(); + SysSuspend(); else - wxGetApp().SysResume(); + SysResume(); } void MainEmuFrame::Menu_EmuReset_Click(wxCommandEvent &event) { bool wasRunning = EmulationInProgress(); - wxGetApp().SysReset(); + SysReset(); GetMenuBar()->Check( MenuId_Emu_Pause, false ); if( !wasRunning ) return; - wxGetApp().SysExecute(); + SysExecute(); } void MainEmuFrame::Menu_ConfigPlugin_Click(wxCommandEvent &event) diff --git a/pcsx2/gui/Panels/MiscPanelStuff.cpp b/pcsx2/gui/Panels/MiscPanelStuff.cpp index d3e06149d..8c5229f90 100644 --- a/pcsx2/gui/Panels/MiscPanelStuff.cpp +++ b/pcsx2/gui/Panels/MiscPanelStuff.cpp @@ -83,9 +83,9 @@ bool Panels::StaticApplyState::ApplyPage( int pageid, bool saveOnSuccess ) // If an exception is thrown above, this code below won't get run. // (conveniently skipping any option application! :D) - wxGetApp().ApplySettings( &confcopy ); + AppApplySettings( &confcopy ); if( saveOnSuccess ) - wxGetApp().SaveSettings(); + AppSaveSettings(); } catch( Exception::CannotApplySettings& ex ) { diff --git a/pcsx2/gui/Plugins.cpp b/pcsx2/gui/Plugins.cpp index aa76a6735..a396f2d6d 100644 --- a/pcsx2/gui/Plugins.cpp +++ b/pcsx2/gui/Plugins.cpp @@ -35,7 +35,7 @@ using namespace Threading; // non-NULL. If NULL, an error occurred and the thread loads the exception into either // Ex_PluginError or Ex_RuntimeError. // -class LoadPluginsTask : public Threading::PersistentThread +class LoadPluginsTask : public PersistentThread { public: Exception::PluginError* Ex_PluginError; diff --git a/pcsx2/gui/Saveslots.cpp b/pcsx2/gui/Saveslots.cpp index 9c46dbaae..1aff8bf54 100644 --- a/pcsx2/gui/Saveslots.cpp +++ b/pcsx2/gui/Saveslots.cpp @@ -62,7 +62,7 @@ void States_Load( const wxString& file ) StateRecovery::Recover(); } - wxGetApp().SysExecute(); + SysExecute(); } void States_Load(int num) From c63cb5d70a10c4a284faf4ce4428166167619e20 Mon Sep 17 00:00:00 2001 From: "Jake.Stine" Date: Fri, 18 Sep 2009 14:40:24 +0000 Subject: [PATCH 10/12] Disabling microVU (enabling superVU) gets saved to ini now. :) git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1855 96395faa-99c1-11dd-bbfe-3dabce05a288 --- pcsx2/Pcsx2Config.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pcsx2/Pcsx2Config.cpp b/pcsx2/Pcsx2Config.cpp index 05ba79e09..880c23baf 100644 --- a/pcsx2/Pcsx2Config.cpp +++ b/pcsx2/Pcsx2Config.cpp @@ -63,6 +63,9 @@ void Pcsx2Config::RecompilerOptions::LoadSave( IniInterface& ini ) IniBitBool( EnableIOP ); IniBitBool( EnableVU0 ); IniBitBool( EnableVU1 ); + + IniBitBool( UseMicroVU0 ); + IniBitBool( UseMicroVU1 ); } Pcsx2Config::CpuOptions::CpuOptions() : From 0017eb5ca3589b4c704711f35a04667cb9e1cca9 Mon Sep 17 00:00:00 2001 From: gigaherz Date: Fri, 18 Sep 2009 18:12:10 +0000 Subject: [PATCH 11/12] Small fix to remove an assertion in XAudio2. git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1857 96395faa-99c1-11dd-bbfe-3dabce05a288 --- plugins/spu2-x/src/Windows/SndOut_XAudio2.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/spu2-x/src/Windows/SndOut_XAudio2.cpp b/plugins/spu2-x/src/Windows/SndOut_XAudio2.cpp index 606b3e463..225e0ddaa 100644 --- a/plugins/spu2-x/src/Windows/SndOut_XAudio2.cpp +++ b/plugins/spu2-x/src/Windows/SndOut_XAudio2.cpp @@ -111,15 +111,15 @@ private: { WAVEFORMATEXTENSIBLE wfx; - memset(&wfx, 0, sizeof(WAVEFORMATEXTENSIBLE)); + memset(&wfx, 0, sizeof(WAVEFORMATEXTENSIBLE)); wfx.Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE; wfx.Format.nSamplesPerSec = SampleRate; wfx.Format.nChannels = m_nChannels; wfx.Format.wBitsPerSample = 16; wfx.Format.nBlockAlign = wfx.Format.nChannels*wfx.Format.wBitsPerSample/8; wfx.Format.nAvgBytesPerSec = SampleRate * wfx.Format.nBlockAlign; - wfx.Format.cbSize = 22; - wfx.Samples.wValidBitsPerSample = 0; + wfx.Format.cbSize = sizeof(WAVEFORMATEXTENSIBLE)-sizeof(WAVEFORMATEX); + wfx.Samples.wValidBitsPerSample = 16; wfx.dwChannelMask = chanConfig; wfx.SubFormat = KSDATAFORMAT_SUBTYPE_PCM; From 8376e0a886498fc798ba18268149ebf9db92f05d Mon Sep 17 00:00:00 2001 From: "Jake.Stine" Date: Fri, 18 Sep 2009 19:38:12 +0000 Subject: [PATCH 12/12] Moved the GIFtag from MTGS instance status to static status, since it needs to be preserved as part of the PS2 virtual machine state (fixes problems when pausing/resuming) git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1859 96395faa-99c1-11dd-bbfe-3dabce05a288 --- pcsx2/GS.h | 9 ++------- pcsx2/MTGS.cpp | 27 ++++++++++++++++++++------- 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/pcsx2/GS.h b/pcsx2/GS.h index b9a78e1e1..c0cc05c07 100644 --- a/pcsx2/GS.h +++ b/pcsx2/GS.h @@ -93,6 +93,8 @@ struct GIFPath u32 _pad[3]; u8 regs[16]; + GIFPath(); + __forceinline void PrepRegs(bool doPrep); __forceinline void SetTag(const void* mem); }; @@ -198,13 +200,6 @@ protected: Threading::MutexLock m_lock_Stack; #endif - // the MTGS "dummy" GIFtag info! - // fixme: The real PS2 has a single internal PATH and 3 logical sources, not 3 entirely - // separate paths. But for that to work properly we need also interlocked path sources. - // That is, when the GIF selects a source, it sticks to that source until an EOP. Currently - // this is not emulated! - GIFPath m_path[3]; - // contains aligned memory allocations for gs and Ringbuffer. SafeAlignedArray m_RingBuffer; diff --git a/pcsx2/MTGS.cpp b/pcsx2/MTGS.cpp index e91c131a5..32668eaf8 100644 --- a/pcsx2/MTGS.cpp +++ b/pcsx2/MTGS.cpp @@ -55,10 +55,24 @@ using namespace std; // // Yeah, it's a lot of work, but the performance gains are huge, even on HT cpus. + +// the MTGS "dummy" GIFtag info! +// fixme: The real PS2 has a single internal PATH and 3 logical sources, not 3 entirely +// separate paths. But for that to work properly we need also interlocked path sources. +// That is, when the GIF selects a source, it sticks to that source until an EOP. Currently +// this is not emulated! +PCSX2_ALIGNED16( static GIFPath s_path[3] ); + +GIFPath::GIFPath() +{ + memzero_obj( *this ); +} + // unpack the registers // registers are stored as a sequence of 4 bit values in the // upper 64 bits of the GIFTAG. That sucks for us, so we unpack // them into an 8 bit array. +// __forceinline void GIFPath::PrepRegs(bool doPrep = 1) { if (!doPrep) return; @@ -181,7 +195,6 @@ mtgsThreadObject::mtgsThreadObject() : , m_RingBuffer( m_RingBufferSize + (Ps2MemSize::GSregs/sizeof(u128)) ) , m_gsMem( (u8*)m_RingBuffer.GetPtr( m_RingBufferSize ) ) { - memzero_obj( m_path ); } void mtgsThreadObject::Start() @@ -226,7 +239,7 @@ void mtgsThreadObject::Reset() SendSimplePacket( GS_RINGTYPE_RESET, 0, 0, 0 ); SendSimplePacket( GS_RINGTYPE_FRAMESKIP, 0, 0, 0 ); - memzero_obj( m_path ); + memzero_obj( s_path ); } #define incPmem(x) { \ @@ -238,7 +251,7 @@ void mtgsThreadObject::Reset() __forceinline int mtgsThreadObject::_gifTransferDummy(GIF_PATH pathidx, const u8* pMem, u32 size) { - GIFPath& path = m_path[pathidx]; + GIFPath& path = s_path[pathidx]; u32 finish = (pathidx == GIF_PATH_1) ? 0x4000 : (size<<4); u32 oldSize = 0; u32 numRegs = 0; @@ -1003,9 +1016,9 @@ void mtgsOpen() void mtgsThreadObject::GIFSoftReset( int mask ) { - if(mask & 1) memzero_obj(m_path[0]); - if(mask & 2) memzero_obj(m_path[1]); - if(mask & 4) memzero_obj(m_path[2]); + if(mask & 1) memzero_obj(s_path[0]); + if(mask & 2) memzero_obj(s_path[1]); + if(mask & 4) memzero_obj(s_path[2]); if( GSgifSoftReset == NULL ) return; @@ -1015,7 +1028,7 @@ void mtgsThreadObject::GIFSoftReset( int mask ) void mtgsThreadObject::Freeze( SaveStateBase& state ) { - _mtgsFreezeGIF( state, this->m_path ); + _mtgsFreezeGIF( state, s_path ); } // this function is needed because of recompiled calls from iGS.cpp