/[pcsx2_0.9.7]/trunk/plugins/spu2-x/src/PS2E-spu2.cpp
ViewVC logotype

Diff of /trunk/plugins/spu2-x/src/PS2E-spu2.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

--- trunk/plugins/spu2-x/src/PS2E-spu2.cpp	2010/09/07 03:24:11	31
+++ trunk/plugins/spu2-x/src/PS2E-spu2.cpp	2010/09/07 11:08:22	62
@@ -113,6 +113,9 @@
 
 static bool CheckSSE()
 {
+	return true;
+
+	#if 0
 	if( !cpu_detected )
 	{
 		cpudetectInit();
@@ -124,6 +127,7 @@
 		return false;
 	}
 	return true;
+	#endif
 }
 
 EXPORT_C_(u32) PS2EgetLibType()
@@ -197,6 +201,11 @@
 	CfgSetSettingsDir( dir );
 }
 
+EXPORT_C_(void) CALLBACK SPU2setLogDir(const char* dir)
+{
+	CfgSetLogDir( dir );
+}
+
 EXPORT_C_(s32)  SPU2dmaRead(s32 channel, u32* data, u32 bytesLeft, u32* bytesProcessed)
 {
 	if(channel==4)
@@ -293,27 +302,26 @@
 {
 	assert( regtable[0x400] == NULL );
 
-	//s32 c=0,v=0;
+	if (IsInitialized)
+	{
+		printf( " * SPU2-X: Already initialized - Ignoring SPU2init signal." );
+		return 0;
+	}
+
+	IsInitialized = true;
+
 	ReadSettings();
 
 #ifdef SPU2_LOG
 	if(AccessLog())
 	{
-		spu2Log = fopen( Unicode::Convert( AccessLogFileName ).c_str(), "w" );
+		spu2Log = OpenLog( AccessLogFileName );
 		setvbuf(spu2Log, NULL,  _IONBF, 0);
 		FileLog("SPU2init\n");
 	}
 #endif
 	srand((unsigned)time(NULL));
 
-	if (IsInitialized)
-	{
-		ConLog( " * SPU2: Already initialized - Ignoring SPU2init signal." );
-		return 0;
-	}
-
-	IsInitialized = true;
-
 	spu2regs  = (s16*)malloc(0x010000);
 	_spu2mem  = (s16*)malloc(0x200000);
 
@@ -328,14 +336,14 @@
 
 	if( (spu2regs == NULL) || (_spu2mem == NULL) || (pcm_cache_data == NULL) )
 	{
-		SysMessage("SPU2: Error allocating Memory\n"); return -1;
+		SysMessage("SPU2-X: Error allocating Memory\n"); return -1;
 	}
 	
 	// Patch up a copy of regtable that directly maps "NULLs" to SPU2 memory.
 	
 	memcpy(regtable, regtable_original, sizeof(regtable));
 
-	for(int mem=0;mem<0x800;mem++)
+	for(uint mem=0;mem<0x800;mem++)
 	{
 		u16 *ptr = regtable[mem>>1];
 		if(!ptr) {
@@ -345,31 +353,12 @@
 
 	memset(spu2regs, 0, 0x010000);
 	memset(_spu2mem, 0, 0x200000);
-	Cores[0].Reset(0);
-	Cores[1].Reset(1);
+	Cores[0].Init(0);
+	Cores[1].Init(1);
 
 	DMALogOpen();
-
-	/*for(v=0;v<16384;v++)
-	{
-		logvolume[v]=(s32)(s32)floor(log((double)(v+1))*3376.7);
-	}*/
-
-	// Initializes lowpass filter for reverb in mixer.cpp
-	//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");
@@ -377,6 +366,47 @@
 	return 0;
 }
 
+#ifdef _MSC_VER
+// Bit ugly to have this here instead of in RealttimeDebugger.cpp, but meh :p
+extern bool debugDialogOpen;
+extern HWND hDebugDialog;
+
+static BOOL CALLBACK DebugProc(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam)
+{
+	int wmId,wmEvent;
+
+	switch(uMsg)
+	{
+		case WM_PAINT:
+			return FALSE;
+		case WM_INITDIALOG:
+			{
+				debugDialogOpen=true;
+			}
+		break;
+
+		case WM_COMMAND:
+			wmId    = LOWORD(wParam);
+			wmEvent = HIWORD(wParam);
+			// Parse the menu selections:
+			switch (wmId)
+			{
+				case IDOK:
+				case IDCANCEL:
+					debugDialogOpen=false;
+					EndDialog(hWnd,0);
+					break;
+				default:
+					return FALSE;
+			}
+		break;
+
+		default:
+			return FALSE;
+	}
+	return TRUE;
+}
+#endif
 uptr gsWindowHandle = 0;
 
 EXPORT_C_(s32) SPU2open(void *pDsp)
@@ -390,12 +420,12 @@
 	else
 		gsWindowHandle = 0;
 
-	/*
-	if(debugDialogOpen==0)
+	// uncomment for a visual debug display showing all core's activity!
+	/*if(debugDialogOpen==0)
 	{
-	hDebugDialog = CreateDialogParam(hInstance,MAKEINTRESOURCE(IDD_DEBUG),0,DebugProc,0);
-	ShowWindow(hDebugDialog,SW_SHOWNORMAL);
-	debugDialogOpen=1;
+		hDebugDialog = CreateDialogParam(hInstance,MAKEINTRESOURCE(IDD_DEBUG),0,DebugProc,0);
+		ShowWindow(hDebugDialog,SW_SHOWNORMAL);
+		debugDialogOpen=1;
 	}*/
 
 	IsOpened = true;
@@ -429,6 +459,7 @@
 #ifndef __LINUX__
 	DspCloseLibrary();
 #endif
+
 	spdif_shutdown();
 	SndBuffer::Cleanup();
 }
@@ -438,7 +469,7 @@
 	if(!IsInitialized) return;
 	IsInitialized = false;
 
-	ConLog( " * SPU2: Shutting down.\n" );
+	ConLog( "* SPU2-X: Shutting down.\n" );
 
 	SPU2close();
 
@@ -464,6 +495,7 @@
 	safe_free(_spu2mem);
 	safe_free( pcm_cache_data );
 
+
 #ifdef SPU2_LOG
 	if(!AccessLog()) return;
 	FileLog("[%10d] SPU2shutdown\n",Cycles);
@@ -556,7 +588,7 @@
 		else if( (mem&0xFFFF) >= 0x800 )
 		{
 			ret = spu2Ru16(mem);
-			ConLog(" * SPU2: Read from reg>=0x800: %x value %x\n",mem,ret);
+			ConLog("* SPU2-X: Read from reg>=0x800: %x value %x\n",mem,ret);
 		}
 		else
 		{

 

  ViewVC Help
Powered by ViewVC 1.1.22