mirror of https://github.com/PCSX2/pcsx2.git
Minor cleanups to the order in which plugin init/open/close functions are called (PADs are always closed before the GS now, for example, since they usually rely on the GS's window handle).
git-svn-id: http://pcsx2.googlecode.com/svn/trunk@560 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
parent
18917ebc21
commit
f6f1f8665b
|
@ -382,6 +382,7 @@ extern mem32_t __fastcall hwRead32_generic(u32 mem);
|
|||
extern void __fastcall hwRead64_page_00(u32 mem, mem64_t* result );
|
||||
extern void __fastcall hwRead64_page_01(u32 mem, mem64_t* result );
|
||||
extern void __fastcall hwRead64_page_02(u32 mem, mem64_t* result );
|
||||
extern void __fastcall hwRead64_generic_INTC_HACK(u32 mem, mem64_t *out);
|
||||
extern void __fastcall hwRead64_generic(u32 mem, mem64_t* result );
|
||||
|
||||
extern void __fastcall hwRead128_page_00(u32 mem, mem128_t* result );
|
||||
|
|
|
@ -36,7 +36,6 @@ using namespace R5900;
|
|||
|
||||
static __forceinline void IntCHackCheck()
|
||||
{
|
||||
if( !CHECK_INTC_STAT_HACK ) return;
|
||||
cpuRegs.cycle = g_nextBranchCycle;
|
||||
|
||||
// Threshold method, might fix games that have problems with the simple
|
||||
|
@ -121,7 +120,8 @@ __forceinline u16 hwRead16(u32 mem)
|
|||
if( mem >= 0x10002000 && mem < 0x10008000 )
|
||||
Console::Notice("Unexpected hwRead16 from 0x%x", params mem);
|
||||
|
||||
switch (mem) {
|
||||
switch (mem)
|
||||
{
|
||||
case 0x10000000: ret = (u16)rcntRcount(0); break;
|
||||
case 0x10000010: ret = (u16)counters[0].modeval; break;
|
||||
case 0x10000020: ret = (u16)counters[0].target; break;
|
||||
|
@ -141,13 +141,15 @@ __forceinline u16 hwRead16(u32 mem)
|
|||
case 0x10001820: ret = (u16)counters[3].target; break;
|
||||
|
||||
default:
|
||||
if ((mem & 0xffffff0f) == 0x1000f200) {
|
||||
if ((mem & 0xffffff0f) == 0x1000f200)
|
||||
{
|
||||
if(mem == 0x1000f260) ret = 0;
|
||||
else if(mem == 0x1000F240) {
|
||||
ret = psHu16(mem) | 0x0102;
|
||||
psHu32(mem) &= ~0x4000;
|
||||
}
|
||||
else ret = psHu32(mem);
|
||||
else
|
||||
ret = psHu32(mem);
|
||||
return (u16)ret;
|
||||
}
|
||||
ret = psHu16(mem);
|
||||
|
@ -348,7 +350,7 @@ void __fastcall hwRead64_page_02(u32 mem, mem64_t* result )
|
|||
*result = ipuRead64(mem);
|
||||
}
|
||||
|
||||
void __fastcall hwRead64_generic(u32 mem, mem64_t* result )
|
||||
void __fastcall hwRead64_generic_INTC_HACK(u32 mem, mem64_t* result )
|
||||
{
|
||||
if( mem == INTC_STAT ) IntCHackCheck();
|
||||
|
||||
|
@ -356,6 +358,12 @@ void __fastcall hwRead64_generic(u32 mem, mem64_t* result )
|
|||
HW_LOG("Unknown Hardware Read 64 at %x\n",mem);
|
||||
}
|
||||
|
||||
void __fastcall hwRead64_generic(u32 mem, mem64_t* result )
|
||||
{
|
||||
*result = psHu64(mem);
|
||||
HW_LOG("Unknown Hardware Read 64 at %x\n",mem);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// Hardware READ 128 bit
|
||||
|
||||
|
|
|
@ -113,7 +113,7 @@ void UpdateDebugger(void)
|
|||
|
||||
void OnDebug_Close(GtkButton *button, gpointer user_data)
|
||||
{
|
||||
ClosePlugins();
|
||||
ClosePlugins( true );
|
||||
gtk_widget_destroy(DebugWnd);
|
||||
gtk_main_quit();
|
||||
gtk_widget_set_sensitive(MainWindow, TRUE);
|
||||
|
|
|
@ -388,7 +388,7 @@ void pcsx2_exit()
|
|||
|
||||
void SignalExit(int sig)
|
||||
{
|
||||
ClosePlugins();
|
||||
ClosePlugins( true );
|
||||
pcsx2_exit();
|
||||
}
|
||||
|
||||
|
|
|
@ -296,7 +296,7 @@ void RunExecute(const char* elf_file, bool use_bios)
|
|||
|
||||
// Take the user back to the GUI...
|
||||
safe_delete(g_RecoveryState);
|
||||
ClosePlugins();
|
||||
ClosePlugins( true );
|
||||
return;
|
||||
}
|
||||
safe_delete(g_RecoveryState);
|
||||
|
@ -750,11 +750,11 @@ void KeyEvent(keyEvent* ev)
|
|||
PluginsResetGS();
|
||||
}
|
||||
|
||||
ClosePlugins();
|
||||
ClosePlugins( Config.closeGSonEsc );
|
||||
|
||||
if (!UseGui) exit(0);
|
||||
|
||||
// fixme: The GUI is now capable of recieving control back from the
|
||||
// fixme: The GUI is now capable of receiving control back from the
|
||||
// emulator. Which means that when I set g_ReturnToGui here, the emulation
|
||||
// loop in ExecuteCpu() will exit. You should be able to set it up so
|
||||
// that it returns control to the existing GTK event loop, instead of
|
||||
|
@ -866,7 +866,7 @@ void SysClose()
|
|||
{
|
||||
if (sinit == 0) return;
|
||||
cpuShutdown();
|
||||
ClosePlugins();
|
||||
ClosePlugins( true );
|
||||
ReleasePlugins();
|
||||
|
||||
if (emuLog != NULL)
|
||||
|
|
|
@ -754,10 +754,11 @@ void memReset()
|
|||
_ext_memWrite8<1>, _ext_memWrite16<1>, hwWrite32_page_0E, hwWrite64_page_0E, hwWrite128_generic
|
||||
);
|
||||
|
||||
vtlbMemR32FP* page0F( CHECK_INTC_STAT_HACK ? hwRead32_page_0F_INTC_HACK : hwRead32_page_0F );
|
||||
vtlbMemR32FP* page0F32( CHECK_INTC_STAT_HACK ? hwRead32_page_0F_INTC_HACK : hwRead32_page_0F );
|
||||
vtlbMemR64FP* page0F64( CHECK_INTC_STAT_HACK ? hwRead64_generic_INTC_HACK : hwRead64_generic );
|
||||
|
||||
hw_by_page[0xf] = vtlb_RegisterHandler(
|
||||
_ext_memRead8<1>, _ext_memRead16<1>, page0F, hwRead64_generic, hwRead128_generic,
|
||||
_ext_memRead8<1>, _ext_memRead16<1>, page0F32, page0F64, hwRead128_generic,
|
||||
_ext_memWrite8<1>, _ext_memWrite16<1>, hwWrite32_page_0F, hwWrite64_generic, hwWrite128_generic
|
||||
);
|
||||
|
||||
|
|
|
@ -580,7 +580,7 @@ void ProcessFKeys(int fkey, int shift)
|
|||
"Pcsx2 encountered an error while trying to load the savestate\n"
|
||||
"and emulation had to be aborted." );
|
||||
|
||||
ClosePlugins();
|
||||
ClosePlugins( true );
|
||||
|
||||
throw Exception::CpuStateShutdown(
|
||||
"Saveslot load failed; PS2 emulated state had to be shut down." ); // let the GUI handle the error "gracefully"
|
||||
|
|
|
@ -586,69 +586,13 @@ struct PluginOpenStatusFlags
|
|||
|
||||
static PluginOpenStatusFlags OpenStatus = {0};
|
||||
|
||||
static bool loadp=false;
|
||||
static bool loadp = false;
|
||||
static bool initp = false;
|
||||
|
||||
int InitPlugins() {
|
||||
int ret;
|
||||
|
||||
ret = GSinit();
|
||||
if (ret != 0) { Msgbox::Alert("GSinit error: %d", params ret); return -1; }
|
||||
ret = PAD1init(1);
|
||||
if (ret != 0) { Msgbox::Alert("PAD1init error: %d", params ret); return -1; }
|
||||
ret = PAD2init(2);
|
||||
if (ret != 0) { Msgbox::Alert("PAD2init error: %d", params ret); return -1; }
|
||||
ret = SPU2init();
|
||||
if (ret != 0) { Msgbox::Alert("SPU2init error: %d", params ret); return -1; }
|
||||
ret = CDVDinit();
|
||||
if (ret != 0) { Msgbox::Alert("CDVDinit error: %d", params ret); return -1; }
|
||||
ret = DEV9init();
|
||||
if (ret != 0) { Msgbox::Alert("DEV9init error: %d", params ret); return -1; }
|
||||
ret = USBinit();
|
||||
if (ret != 0) { Msgbox::Alert("USBinit error: %d", params ret); return -1; }
|
||||
ret = FWinit();
|
||||
if (ret != 0) { Msgbox::Alert("FWinit error: %d", params ret); return -1; }
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ShutdownPlugins()
|
||||
int LoadPlugins()
|
||||
{
|
||||
ClosePlugins();
|
||||
|
||||
// GS is a special case: It needs closed first usually.
|
||||
// (the GS isn't always closed during emulation pauses)
|
||||
if( OpenStatus.GS )
|
||||
{
|
||||
gsClose();
|
||||
OpenStatus.GS = false;
|
||||
}
|
||||
|
||||
if( GSshutdown != NULL )
|
||||
GSshutdown();
|
||||
|
||||
if( PAD1shutdown != NULL )
|
||||
PAD1shutdown();
|
||||
if( PAD2shutdown != NULL )
|
||||
PAD2shutdown();
|
||||
|
||||
if( SPU2shutdown != NULL )
|
||||
SPU2shutdown();
|
||||
|
||||
if( CDVDshutdown != NULL )
|
||||
CDVDshutdown();
|
||||
|
||||
if( DEV9shutdown != NULL )
|
||||
DEV9shutdown();
|
||||
|
||||
if( USBshutdown != NULL )
|
||||
USBshutdown();
|
||||
|
||||
if( FWshutdown != NULL )
|
||||
FWshutdown();
|
||||
}
|
||||
|
||||
int LoadPlugins() {
|
||||
|
||||
if( loadp ) return 0;
|
||||
|
||||
string Plugin;
|
||||
|
||||
Path::Combine( Plugin, Config.PluginsDir, Config.GS );
|
||||
|
@ -672,27 +616,93 @@ int LoadPlugins() {
|
|||
Path::Combine( Plugin, Config.PluginsDir, Config.USB);
|
||||
if (LoadUSBplugin(Plugin) == -1) return -1;
|
||||
|
||||
Path::Combine( Plugin, Config.PluginsDir, Config.FW);
|
||||
Path::Combine( Plugin, Config.PluginsDir, Config.FW);
|
||||
if (LoadFWplugin(Plugin) == -1) return -1;
|
||||
|
||||
if (InitPlugins() == -1) return -1;
|
||||
|
||||
loadp=true;
|
||||
loadp = true;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int InitPlugins()
|
||||
{
|
||||
if( initp ) return 0;
|
||||
|
||||
// Ensure plugins have been loaded....
|
||||
if( LoadPlugins() == -1 ) return -1;
|
||||
|
||||
//if( !loadp )
|
||||
// throw Exception::InvalidOperation( "Bad coder mojo - InitPlugins called prior to plugins having been loaded." );
|
||||
|
||||
int ret;
|
||||
|
||||
ret = GSinit();
|
||||
if (ret != 0) { Msgbox::Alert("GSinit error: %d", params ret); return -1; }
|
||||
ret = PAD1init(1);
|
||||
if (ret != 0) { Msgbox::Alert("PAD1init error: %d", params ret); return -1; }
|
||||
ret = PAD2init(2);
|
||||
if (ret != 0) { Msgbox::Alert("PAD2init error: %d", params ret); return -1; }
|
||||
ret = SPU2init();
|
||||
if (ret != 0) { Msgbox::Alert("SPU2init error: %d", params ret); return -1; }
|
||||
ret = CDVDinit();
|
||||
if (ret != 0) { Msgbox::Alert("CDVDinit error: %d", params ret); return -1; }
|
||||
ret = DEV9init();
|
||||
if (ret != 0) { Msgbox::Alert("DEV9init error: %d", params ret); return -1; }
|
||||
ret = USBinit();
|
||||
if (ret != 0) { Msgbox::Alert("USBinit error: %d", params ret); return -1; }
|
||||
ret = FWinit();
|
||||
if (ret != 0) { Msgbox::Alert("FWinit error: %d", params ret); return -1; }
|
||||
|
||||
initp = true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ShutdownPlugins()
|
||||
{
|
||||
if( !initp ) return;
|
||||
|
||||
ClosePlugins( true );
|
||||
|
||||
if( GSshutdown != NULL )
|
||||
GSshutdown();
|
||||
|
||||
if( PAD1shutdown != NULL )
|
||||
PAD1shutdown();
|
||||
if( PAD2shutdown != NULL )
|
||||
PAD2shutdown();
|
||||
|
||||
if( SPU2shutdown != NULL )
|
||||
SPU2shutdown();
|
||||
|
||||
if( CDVDshutdown != NULL )
|
||||
CDVDshutdown();
|
||||
|
||||
if( DEV9shutdown != NULL )
|
||||
DEV9shutdown();
|
||||
|
||||
if( USBshutdown != NULL )
|
||||
USBshutdown();
|
||||
|
||||
if( FWshutdown != NULL )
|
||||
FWshutdown();
|
||||
|
||||
initp = false;
|
||||
}
|
||||
|
||||
uptr pDsp;
|
||||
extern void spu2DMA4Irq();
|
||||
extern void spu2DMA7Irq();
|
||||
extern void spu2Irq();
|
||||
|
||||
int OpenPlugins(const char* pTitleFilename) {
|
||||
int OpenPlugins(const char* pTitleFilename)
|
||||
{
|
||||
GSdriverInfo info;
|
||||
int ret;
|
||||
|
||||
if ( !loadp )
|
||||
throw Exception::InvalidOperation( "OpenPlugins cannot be called while the plugin state is uninitialized." );
|
||||
if ( !initp )
|
||||
InitPlugins();
|
||||
//throw Exception::InvalidOperation( "Bad coder mojo -- OpenPlugins called prior to InitPlugins." );
|
||||
|
||||
#ifndef _WIN32
|
||||
// change dir so that CDVD can find its config file
|
||||
|
@ -796,7 +806,7 @@ int OpenPlugins(const char* pTitleFilename) {
|
|||
return 0;
|
||||
|
||||
OpenError:
|
||||
ClosePlugins();
|
||||
ClosePlugins( true );
|
||||
#ifdef __LINUX__
|
||||
chdir(file);
|
||||
#endif
|
||||
|
@ -812,24 +822,43 @@ OpenError:
|
|||
}
|
||||
|
||||
|
||||
void ClosePlugins()
|
||||
void ClosePlugins( bool closegs )
|
||||
{
|
||||
// GS plugin is special and is not always closed during emulation pauses.
|
||||
// (that's because the GS is the most complicated plugin and to close it would
|
||||
// require we save the GS state -- plus, Gsdx doesn't really support being
|
||||
// closed)
|
||||
|
||||
if( OpenStatus.GS )
|
||||
mtgsWaitGS();
|
||||
|
||||
// Close pads first since they attatch to the GS's window.
|
||||
|
||||
CLOSE_PLUGIN( PAD1 );
|
||||
CLOSE_PLUGIN( PAD2 );
|
||||
|
||||
// GS plugin is special and is not always closed during emulation pauses.
|
||||
// (that's because the GS is the most complicated plugin and to close it would
|
||||
// require we save the GS state)
|
||||
|
||||
if( OpenStatus.GS )
|
||||
{
|
||||
if( closegs )
|
||||
{
|
||||
gsClose();
|
||||
OpenStatus.GS = false;
|
||||
}
|
||||
else
|
||||
mtgsWaitGS();
|
||||
}
|
||||
|
||||
CLOSE_PLUGIN( CDVD );
|
||||
CLOSE_PLUGIN( DEV9 );
|
||||
CLOSE_PLUGIN( USB );
|
||||
CLOSE_PLUGIN( FW );
|
||||
CLOSE_PLUGIN( SPU2 );
|
||||
|
||||
// More special treatment for the GS. It needs a complete shutdown and re-init
|
||||
// or else it will tend to error out when we try to use it again.
|
||||
if( 0 ) //closegs )
|
||||
{
|
||||
GSshutdown();
|
||||
|
||||
int ret = GSinit();
|
||||
if (ret != 0) { Msgbox::Alert("GSinit error: %d", params ret); }
|
||||
}
|
||||
}
|
||||
|
||||
void ResetPlugins()
|
||||
|
@ -863,6 +892,8 @@ void ReleasePlugins()
|
|||
|
||||
void PluginsResetGS()
|
||||
{
|
||||
// PADs are tied to the GS window, so shut them down together with the GS.
|
||||
|
||||
CLOSE_PLUGIN( PAD1 );
|
||||
CLOSE_PLUGIN( PAD2 );
|
||||
|
||||
|
@ -872,11 +903,6 @@ void PluginsResetGS()
|
|||
OpenStatus.GS = false;
|
||||
}
|
||||
|
||||
if( OpenStatus.PAD1 )
|
||||
{
|
||||
PAD1close();
|
||||
}
|
||||
|
||||
GSshutdown();
|
||||
|
||||
int ret = GSinit();
|
||||
|
|
|
@ -31,7 +31,7 @@ int LoadPlugins();
|
|||
void ReleasePlugins();
|
||||
|
||||
int OpenPlugins(const char* pTitleFilename);
|
||||
void ClosePlugins();
|
||||
void ClosePlugins( bool closegs );
|
||||
|
||||
int InitPlugins();
|
||||
|
||||
|
|
|
@ -613,7 +613,7 @@ BOOL APIENTRY DebuggerProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam
|
|||
EndDialog(hDlg,TRUE);
|
||||
EndDialog(hIopDlg,TRUE);
|
||||
|
||||
ClosePlugins();
|
||||
ClosePlugins( true );
|
||||
isRunning = 0;
|
||||
return TRUE;
|
||||
|
||||
|
|
|
@ -273,7 +273,7 @@ LRESULT WINAPI RemoteDebuggerProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lP
|
|||
//open socket & thread
|
||||
ListBox_SetHorizontalExtent(GetDlgItem(hDlg, IDC_COMMUNICATION), 1700);
|
||||
if (CreateSocket(hDlg, port)==FALSE){
|
||||
ClosePlugins();
|
||||
ClosePlugins( false );
|
||||
EndDialog(hDlg, FALSE );
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -287,7 +287,7 @@ LRESULT WINAPI RemoteDebuggerProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lP
|
|||
MessageBox(hDlg, _("Could not create threads or event"), 0, MB_OK);
|
||||
connected=0;
|
||||
closesocket(serversocket);
|
||||
ClosePlugins();
|
||||
ClosePlugins( false );
|
||||
EndDialog(hDlg, FALSE );
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -332,7 +332,7 @@ LRESULT WINAPI RemoteDebuggerProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lP
|
|||
CloseHandle(runEvent);
|
||||
closesocket(serversocket);
|
||||
WSACleanup();
|
||||
ClosePlugins();
|
||||
ClosePlugins( false );
|
||||
EndDialog(hDlg, TRUE );
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -288,7 +288,7 @@ void RunExecute( const char* elf_file, bool use_bios )
|
|||
|
||||
// Take the user back to the GUI...
|
||||
safe_delete( g_RecoveryState );
|
||||
ClosePlugins();
|
||||
ClosePlugins( true );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -685,10 +685,9 @@ static void __fastcall KeyEvent(keyEvent* ev)
|
|||
JustGsSavingState eddie;
|
||||
eddie.FreezePlugin( "GS", gsSafeFreeze ) ;
|
||||
eddie.gsFreeze();
|
||||
PluginsResetGS();
|
||||
}
|
||||
|
||||
ClosePlugins();
|
||||
ClosePlugins( Config.closeGSonEsc );
|
||||
nDisableSC = 0;
|
||||
}
|
||||
break;
|
||||
|
@ -780,12 +779,13 @@ bool SysInit()
|
|||
}
|
||||
|
||||
// completely shuts down the emulator's cpu state, and unloads all plugins from memory.
|
||||
void SysClose() {
|
||||
void SysClose()
|
||||
{
|
||||
if (!sinit) return;
|
||||
cpuShutdown();
|
||||
ClosePlugins();
|
||||
ClosePlugins( true );
|
||||
ReleasePlugins();
|
||||
sinit=false;
|
||||
sinit = false;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -40,6 +40,7 @@
|
|||
|
||||
#include "PS2Etypes.h"
|
||||
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include "ConvertUTF.h"
|
||||
|
||||
|
|
|
@ -36,6 +36,7 @@ namespace Exception
|
|||
public:
|
||||
const ResultType PartialResult;
|
||||
|
||||
virtual ~UTFConversion() throw() {}
|
||||
UTFConversion( const ResultType& result, std::string msg ) :
|
||||
runtime_error( msg ),
|
||||
PartialResult( result ) {}
|
||||
|
|
|
@ -1,454 +0,0 @@
|
|||
//GiGaHeRz's SPU2 Driver
|
||||
//Copyright (c) 2003-2008, David Quintana <gigaherz@gmail.com>
|
||||
//
|
||||
//This library 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 Foundation; either
|
||||
//version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
//This library is distributed in the hope that it will be useful,
|
||||
//but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
//Lesser General Public License for more details.
|
||||
//
|
||||
//You should have received a copy of the GNU Lesser General Public
|
||||
//License along with this library; if not, write to the Free Software
|
||||
//Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
//
|
||||
|
||||
#include "spu2.h"
|
||||
#include "regtable.h"
|
||||
|
||||
#include "svnrev.h"
|
||||
|
||||
// [Air]: Adding the spu2init boolean wasn't necessary except to help me in
|
||||
// debugging the spu2 suspend/resume behavior (when user hits escape).
|
||||
static bool spu2open=false; // has spu2open plugin interface been called?
|
||||
static bool spu2init=false; // has spu2init plugin interface been called?
|
||||
|
||||
static s32 logvolume[16384];
|
||||
static u32 pClocks=0;
|
||||
|
||||
|
||||
static const u8 version = PS2E_SPU2_VERSION;
|
||||
static const u8 revision = 1;
|
||||
static const u8 build = 9; // increase that with each version
|
||||
|
||||
static char libraryName[256];
|
||||
|
||||
BOOL WINAPI DllMain(HINSTANCE hinstDLL,DWORD dwReason,LPVOID lpvReserved)
|
||||
{
|
||||
if(dwReason==DLL_PROCESS_ATTACH) hInstance=hinstDLL;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void InitLibraryName()
|
||||
{
|
||||
#ifdef PUBLIC
|
||||
|
||||
// Public Release!
|
||||
// Output a simplified string that's just our name:
|
||||
|
||||
strcpy( libraryName, "SPU2ghz" );
|
||||
|
||||
#elif defined( SVN_REV_UNKNOWN )
|
||||
|
||||
// Unknown revision.
|
||||
// Output a name that includes devbuild status but not
|
||||
// subversion revision tags:
|
||||
|
||||
strcpy( libraryName, "SPU2ghz"
|
||||
# ifdef _DEBUG_FAST
|
||||
"-Debug"
|
||||
# elif defined( DEBUG )
|
||||
"-Debug/Strict" // strict debugging is slow!
|
||||
# else
|
||||
"-Dev"
|
||||
# endif
|
||||
);
|
||||
#else
|
||||
|
||||
// Use TortoiseSVN's SubWCRev utility's output
|
||||
// to label the specific revision:
|
||||
|
||||
sprintf_s( libraryName, "SPU2ghz r%d%s"
|
||||
# ifdef _DEBUG_FAST
|
||||
"-Debug"
|
||||
# elif defined( _DEBUG )
|
||||
"-Debug/Strict" // strict debugging is slow!
|
||||
# else
|
||||
"-Dev"
|
||||
# endif
|
||||
,SVN_REV,
|
||||
SVN_MODS ? "m" : ""
|
||||
);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
EXPORT_C_(u32) PS2EgetLibType()
|
||||
{
|
||||
return PS2E_LT_SPU2;
|
||||
}
|
||||
|
||||
EXPORT_C_(char*) PS2EgetLibName()
|
||||
{
|
||||
InitLibraryName();
|
||||
return libraryName;
|
||||
}
|
||||
|
||||
EXPORT_C_(u32) PS2EgetLibVersion2(u32 type)
|
||||
{
|
||||
return (version<<16)|(revision<<8)|build;
|
||||
}
|
||||
|
||||
EXPORT_C_(void) SPU2configure() {
|
||||
configure();
|
||||
}
|
||||
|
||||
EXPORT_C_(void) SPU2about() {
|
||||
InitLibraryName();
|
||||
SysMessage( libraryName );
|
||||
}
|
||||
|
||||
EXPORT_C_(s32) SPU2test() {
|
||||
return SndTest();
|
||||
}
|
||||
|
||||
EXPORT_C_(s32) SPU2init()
|
||||
{
|
||||
#define MAKESURE(a,b) \
|
||||
/*fprintf(stderr,"%08p: %08p == %08p\n",&(regtable[a>>1]),regtable[a>>1],U16P(b));*/ \
|
||||
assert(regtable[(a)>>1]==U16P(b))
|
||||
|
||||
MAKESURE(0x800,zero);
|
||||
|
||||
s32 c=0,v=0;
|
||||
ReadSettings();
|
||||
|
||||
#ifdef SPU2_LOG
|
||||
if(AccessLog())
|
||||
{
|
||||
spu2Log = fopen(AccessLogFileName, "w");
|
||||
setvbuf(spu2Log, NULL, _IONBF, 0);
|
||||
FileLog("SPU2init\n");
|
||||
}
|
||||
#endif
|
||||
srand((unsigned)time(NULL));
|
||||
|
||||
disableFreezes=false;
|
||||
|
||||
if (spu2init)
|
||||
{
|
||||
ConLog( " * SPU2: Already initialized - Ignoring SPU2init signal." );
|
||||
return 0;
|
||||
}
|
||||
|
||||
spu2init=true;
|
||||
|
||||
spu2regs = (short*)malloc(0x010000);
|
||||
_spu2mem = (short*)malloc(0x200000);
|
||||
|
||||
// adpcm decoder cache:
|
||||
// the cache data size is determined by taking the number of adpcm blocks
|
||||
// (2MB / 16) and multiplying it by the decoded block size (28 samples).
|
||||
// Thus: pcm_cache_data = 7,340,032 bytes (ouch!)
|
||||
// Expanded: 16 bytes expands to 56 bytes [3.5:1 ratio]
|
||||
// Resulting in 2MB * 3.5.
|
||||
|
||||
pcm_cache_data = (PcmCacheEntry*)calloc( pcm_BlockCount, sizeof(PcmCacheEntry) );
|
||||
|
||||
if( (spu2regs == NULL) || (_spu2mem == NULL) ||
|
||||
(pcm_cache_data == NULL) )
|
||||
{
|
||||
SysMessage("SPU2: Error allocating Memory\n"); return -1;
|
||||
}
|
||||
|
||||
for(int mem=0;mem<0x800;mem++)
|
||||
{
|
||||
u16 *ptr=regtable[mem>>1];
|
||||
if(!ptr) {
|
||||
regtable[mem>>1] = &(spu2Ru16(mem));
|
||||
}
|
||||
}
|
||||
|
||||
memset(spu2regs,0,0x010000);
|
||||
memset(_spu2mem,0,0x200000);
|
||||
memset(&Cores,0,(sizeof(V_Core) * 2));
|
||||
CoreReset(0);
|
||||
CoreReset(1);
|
||||
|
||||
DMALogOpen();
|
||||
|
||||
for(v=0;v<16384;v++)
|
||||
{
|
||||
logvolume[v]=(s32)(s32)floor(log((double)(v+1))*3376.7);
|
||||
}
|
||||
|
||||
LowPassFilterInit();
|
||||
InitADSR();
|
||||
|
||||
#ifdef STREAM_DUMP
|
||||
il0=fopen("logs/spu2input0.pcm","wb");
|
||||
il1=fopen("logs/spu2input1.pcm","wb");
|
||||
#endif
|
||||
|
||||
#ifdef EFFECTS_DUMP
|
||||
el0=fopen("logs/spu2fx0.pcm","wb");
|
||||
el1=fopen("logs/spu2fx1.pcm","wb");
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef S2R_ENABLE
|
||||
if(!replay_mode)
|
||||
s2r_open("replay_dump.s2r");
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
EXPORT_C_(s32) SPU2open(void *pDsp)
|
||||
{
|
||||
if( spu2open ) return 0;
|
||||
|
||||
FileLog("[%10d] SPU2 Open\n",Cycles);
|
||||
|
||||
/*
|
||||
if(debugDialogOpen==0)
|
||||
{
|
||||
hDebugDialog = CreateDialogParam(hInstance,MAKEINTRESOURCE(IDD_DEBUG),0,DebugProc,0);
|
||||
ShowWindow(hDebugDialog,SW_SHOWNORMAL);
|
||||
debugDialogOpen=1;
|
||||
}*/
|
||||
|
||||
spu2open=true;
|
||||
if (!SndInit())
|
||||
{
|
||||
srate_pv=(double)SampleRate/48000.0;
|
||||
|
||||
spdif_init();
|
||||
|
||||
DspLoadLibrary(dspPlugin,dspPluginModule);
|
||||
|
||||
WaveDump::Open();
|
||||
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
SPU2close();
|
||||
return -1;
|
||||
};
|
||||
}
|
||||
|
||||
EXPORT_C_(void) SPU2close()
|
||||
{
|
||||
if( !spu2open ) return;
|
||||
FileLog("[%10d] SPU2 Close\n",Cycles);
|
||||
|
||||
DspCloseLibrary();
|
||||
spdif_shutdown();
|
||||
SndClose();
|
||||
|
||||
spu2open = false;
|
||||
}
|
||||
|
||||
EXPORT_C_(void) SPU2shutdown()
|
||||
{
|
||||
if(!spu2init) return;
|
||||
|
||||
ConLog( " * SPU2: Shutting down.\n" );
|
||||
|
||||
SPU2close();
|
||||
|
||||
#ifdef S2R_ENABLE
|
||||
if(!replay_mode)
|
||||
s2r_close();
|
||||
#endif
|
||||
|
||||
DoFullDump();
|
||||
#ifdef STREAM_DUMP
|
||||
fclose(il0);
|
||||
fclose(il1);
|
||||
#endif
|
||||
#ifdef EFFECTS_DUMP
|
||||
fclose(el0);
|
||||
fclose(el1);
|
||||
#endif
|
||||
WaveDump::Close();
|
||||
|
||||
DMALogClose();
|
||||
|
||||
spu2init = false;
|
||||
|
||||
SAFE_FREE(spu2regs);
|
||||
SAFE_FREE(_spu2mem);
|
||||
|
||||
SAFE_FREE( pcm_cache_data );
|
||||
|
||||
spu2regs = NULL;
|
||||
_spu2mem = NULL;
|
||||
pcm_cache_data = NULL;
|
||||
|
||||
#ifdef SPU2_LOG
|
||||
if(!AccessLog()) return;
|
||||
FileLog("[%10d] SPU2shutdown\n",Cycles);
|
||||
if(spu2Log) fclose(spu2Log);
|
||||
#endif
|
||||
}
|
||||
|
||||
EXPORT_C_(void) SPU2setClockPtr(u32 *ptr)
|
||||
{
|
||||
cPtr=ptr;
|
||||
hasPtr=(cPtr!=NULL);
|
||||
}
|
||||
|
||||
bool numpad_minus_old=false;
|
||||
bool numpad_minus = false;
|
||||
bool numpad_plus = false, numpad_plus_old = false;
|
||||
|
||||
EXPORT_C_(void) SPU2async(u32 cycles)
|
||||
{
|
||||
#ifndef PUBLIC
|
||||
u32 oldClocks = lClocks;
|
||||
static u32 timer=0,time1=0,time2=0;
|
||||
timer++;
|
||||
if (timer == 1){
|
||||
time1=timeGetTime();
|
||||
}
|
||||
if (timer == 3000){
|
||||
time2 = timeGetTime()-time1 ;
|
||||
timer=0;
|
||||
}
|
||||
#endif
|
||||
|
||||
DspUpdate();
|
||||
|
||||
if(LimiterToggleEnabled)
|
||||
{
|
||||
numpad_minus = (GetAsyncKeyState(VK_SUBTRACT)&0x8000)!=0;
|
||||
|
||||
if(numpad_minus && !numpad_minus_old)
|
||||
{
|
||||
if(LimitMode) LimitMode=0;
|
||||
else LimitMode=1;
|
||||
SndUpdateLimitMode();
|
||||
}
|
||||
numpad_minus_old = numpad_minus;
|
||||
}
|
||||
|
||||
#ifndef PUBLIC
|
||||
/*numpad_plus = (GetAsyncKeyState(VK_ADD)&0x8000)!=0;
|
||||
if(numpad_plus && !numpad_plus_old)
|
||||
{
|
||||
DoFullDump();
|
||||
}
|
||||
numpad_plus_old = numpad_plus;*/
|
||||
#endif
|
||||
|
||||
if(hasPtr)
|
||||
{
|
||||
TimeUpdate(*cPtr);
|
||||
}
|
||||
else
|
||||
{
|
||||
pClocks+=cycles;
|
||||
TimeUpdate(pClocks);
|
||||
}
|
||||
}
|
||||
|
||||
EXPORT_C_(void) SPU2irqCallback(void (*SPU2callback)(),void (*DMA4callback)(),void (*DMA7callback)())
|
||||
{
|
||||
_irqcallback=SPU2callback;
|
||||
dma4callback=DMA4callback;
|
||||
dma7callback=DMA7callback;
|
||||
}
|
||||
|
||||
EXPORT_C_(u16) SPU2read(u32 rmem)
|
||||
{
|
||||
// if(!replay_mode)
|
||||
// s2r_readreg(Cycles,rmem);
|
||||
|
||||
if(hasPtr) TimeUpdate(*cPtr);
|
||||
|
||||
u16 ret=0xDEAD; u32 core=0, mem=rmem&0xFFFF, omem=mem;
|
||||
if (mem & 0x400) { omem^=0x400; core=1; }
|
||||
|
||||
if(rmem==0x1f9001AC)
|
||||
{
|
||||
ret = DmaRead(core);
|
||||
}
|
||||
else if (rmem>>16 == 0x1f80)
|
||||
{
|
||||
ret = SPU_ps1_read(rmem);
|
||||
}
|
||||
else if ((mem&0xFFFF)>=0x800)
|
||||
{
|
||||
ret=spu2Ru16(mem);
|
||||
ConLog(" * SPU2: Read from reg>=0x800: %x value %x\n",mem,ret);
|
||||
FileLog(" * SPU2: Read from reg>=0x800: %x value %x\n",mem,ret);
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = *(regtable[(mem>>1)]);
|
||||
|
||||
FileLog("[%10d] SPU2 read mem %x (core %d, register %x): %x\n",Cycles, mem, core, (omem & 0x7ff), ret);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
EXPORT_C_(void) SPU2write(u32 rmem, u16 value)
|
||||
{
|
||||
#ifdef S2R_ENABLE
|
||||
if(!replay_mode)
|
||||
s2r_writereg(Cycles,rmem,value);
|
||||
#endif
|
||||
|
||||
if(rmem==0x1f9001ac)
|
||||
{
|
||||
//RegWriteLog(0,value);
|
||||
if((Cores[0].IRQEnable)&&(Cores[0].TSA==Cores[0].IRQA))
|
||||
{
|
||||
Spdif.Info=4;
|
||||
SetIrqCall();
|
||||
}
|
||||
spu2M_Write( Cores[0].TSA++, value );
|
||||
Cores[0].TSA&=0xfffff;
|
||||
}
|
||||
else if(rmem==0x1f9005ac)
|
||||
{
|
||||
//RegWriteLog(1,value);
|
||||
if((Cores[0].IRQEnable)&&(Cores[0].TSA==Cores[0].IRQA))
|
||||
{
|
||||
Spdif.Info=4;
|
||||
SetIrqCall();
|
||||
}
|
||||
spu2M_Write( Cores[1].TSA++, value );
|
||||
Cores[1].TSA&=0xfffff;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(hasPtr) TimeUpdate(*cPtr);
|
||||
|
||||
if (rmem>>16 == 0x1f80)
|
||||
SPU_ps1_write(rmem,value);
|
||||
else
|
||||
SPU2_FastWrite( rmem, value );
|
||||
}
|
||||
}
|
||||
|
||||
// if start is 1, starts recording spu2 data, else stops
|
||||
// returns a non zero value if successful
|
||||
// for now, pData is not used
|
||||
EXPORT_C_(int) SPU2setupRecording(int start, void* pData)
|
||||
{
|
||||
// Don't record if we have a bogus state.
|
||||
if( disableFreezes ) return 0;
|
||||
|
||||
if(start==0)
|
||||
RecordStop();
|
||||
else if(start==1)
|
||||
RecordStart();
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -109,7 +109,7 @@ void SPU2writeLog( const char* action, u32 rmem, u16 value )
|
|||
if(Spdif.Unknown2 != value) ConLog(" * SPU2: SPDIF Unknown Register 2 set to %04x\n",value);
|
||||
RegLog(2,"SPDIF_UNKNOWN2",rmem,-1,value);
|
||||
break;
|
||||
case SPDIF_COPY:
|
||||
case SPDIF_PROTECT:
|
||||
if(Spdif.Protection != value) ConLog(" * SPU2: SPDIF Copy set to %04x\n",value);
|
||||
RegLog(2,"SPDIF_COPY",rmem,-1,value);
|
||||
break;
|
||||
|
|
|
@ -131,7 +131,7 @@
|
|||
#define IRQINFO 0x07C2
|
||||
#define SPDIF_MODE 0x07C6
|
||||
#define SPDIF_MEDIA 0x07C8 // SPDIF Media: 'CD'/DVD
|
||||
#define SPDIF_COPY 0x07CC // SPDIF Copy Protection
|
||||
#define SPDIF_PROTECT 0x07CC // SPDIF Copy Protection
|
||||
|
||||
|
||||
/*********************************************************************
|
||||
|
@ -161,8 +161,8 @@ Core attributes (SD_C)
|
|||
#define SPDIF_MEDIA_CDVD 0x0200
|
||||
#define SPDIF_MEDIA_400 0x0000
|
||||
|
||||
#define SPDIF_COPY_NORMAL 0x0000 // spdif stream is not protected
|
||||
#define SPDIF_COPY_PROHIBIT 0x8000 // spdif stream can't be copied
|
||||
#define SPDIF_PROTECT_NORMAL 0x0000 // spdif stream is not protected
|
||||
#define SPDIF_PROTECT_PROHIBIT 0x8000 // spdif stream can't be copied
|
||||
|
||||
/********************************************************************/
|
||||
|
||||
|
|
Loading…
Reference in New Issue