summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorSND\weimingzhi_cp <SND\weimingzhi_cp@e17a0e51-4ae3-4d35-97c3-1a29b211df97>2010-08-12 02:56:43 +0000
committerSND\weimingzhi_cp <SND\weimingzhi_cp@e17a0e51-4ae3-4d35-97c3-1a29b211df97>2010-08-12 02:56:43 +0000
commit8297a92012e3f42ed74d47fc3d11a3003c14b4ae (patch)
treefc781551eb9e024428de1c4b2a194c1e1c444be2 /plugins
parentd4840a37d9adf0b9124fad722a5ae5faae4bb639 (diff)
downloadpcsxr-8297a92012e3f42ed74d47fc3d11a3003c14b4ae.tar.gz
dfsound: readded windows support.
gtk gui: increased number of savestate slots. git-svn-id: https://pcsxr.svn.codeplex.com/svn/pcsxr@56022 e17a0e51-4ae3-4d35-97c3-1a29b211df97
Diffstat (limited to 'plugins')
-rw-r--r--plugins/dfsound/cfg.h6
-rw-r--r--plugins/dfsound/dsoundoss.h7
-rw-r--r--plugins/dfsound/externals.h35
-rw-r--r--plugins/dfsound/freeze.c7
-rw-r--r--plugins/dfsound/spu.c201
-rw-r--r--plugins/dfsound/stdafx.h20
-rw-r--r--plugins/dfsound/xa.c16
7 files changed, 262 insertions, 30 deletions
diff --git a/plugins/dfsound/cfg.h b/plugins/dfsound/cfg.h
index f64d6d62..b052b2d9 100644
--- a/plugins/dfsound/cfg.h
+++ b/plugins/dfsound/cfg.h
@@ -16,4 +16,10 @@
***************************************************************************/
void ReadConfig(void);
+
+#ifdef _WINDOWS
+BOOL CALLBACK AboutDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam);
+BOOL CALLBACK DSoundDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam);
+#else
void StartCfgTool(char * pCmdLine);
+#endif
diff --git a/plugins/dfsound/dsoundoss.h b/plugins/dfsound/dsoundoss.h
index 3702312f..f64f645b 100644
--- a/plugins/dfsound/dsoundoss.h
+++ b/plugins/dfsound/dsoundoss.h
@@ -18,5 +18,10 @@
void SetupSound(void);
void RemoveSound(void);
unsigned long SoundGetBytesBuffered(void);
-void SoundFeedStreamData(unsigned char* pSound,long lBytes);
+void SoundFeedStreamData(unsigned char* pSound,long lBytes);
+
+#ifdef _WINDOWS
+#define timeGetTime_spu timeGetTime
+#else
unsigned long timeGetTime_spu();
+#endif \ No newline at end of file
diff --git a/plugins/dfsound/externals.h b/plugins/dfsound/externals.h
index f8562046..30ac977d 100644
--- a/plugins/dfsound/externals.h
+++ b/plugins/dfsound/externals.h
@@ -193,6 +193,11 @@ typedef struct
int IN_COEF_R; // (coef.)
} REVERBInfo;
+#ifdef _WINDOWS
+extern HINSTANCE hInst;
+#define WM_MUTE (WM_USER+543)
+#endif
+
///////////////////////////////////////////////////////////
// SPU.C globals
///////////////////////////////////////////////////////////
@@ -240,11 +245,41 @@ extern int SSumL[];
extern int iCycle;
extern short * pS;
+#ifdef _WINDOWS
+extern HWND hWMain; // window handle
+extern HWND hWDebug;
+#endif
+
extern void (CALLBACK *cddavCallback)(unsigned short,unsigned short);
#endif
///////////////////////////////////////////////////////////
+// DSOUND.C globals
+///////////////////////////////////////////////////////////
+
+#ifndef _IN_DSOUND
+
+#ifdef _WINDOWS
+extern unsigned long LastWrite;
+extern unsigned long LastPlay;
+#endif
+
+#endif
+
+///////////////////////////////////////////////////////////
+// RECORD.C globals
+///////////////////////////////////////////////////////////
+
+#ifndef _IN_RECORD
+
+#ifdef _WINDOWS
+extern int iDoRecord;
+#endif
+
+#endif
+
+///////////////////////////////////////////////////////////
// XA.C globals
///////////////////////////////////////////////////////////
diff --git a/plugins/dfsound/freeze.c b/plugins/dfsound/freeze.c
index 12fdc1fd..e4283595 100644
--- a/plugins/dfsound/freeze.c
+++ b/plugins/dfsound/freeze.c
@@ -118,6 +118,13 @@ long CALLBACK SPUfreeze(uint32_t ulFreezeMode,SPUFreeze_t * pF)
if(ulFreezeMode!=0) return 0; // bad mode? bye
+#ifdef _WINDOWS
+ if(iDebugMode && IsWindow(hWDebug)) // clean debug mute infos
+ SendMessage(hWDebug,WM_MUTE,0,0);
+ if(IsBadReadPtr(pF,sizeof(SPUFreeze_t))) // check bad emu stuff
+ return 0;
+#endif
+
RemoveTimer(); // we stop processing while doing the save!
memcpy(spuMem,pF->cSPURam,0x80000); // get ram
diff --git a/plugins/dfsound/spu.c b/plugins/dfsound/spu.c
index c086c06b..b11e5fac 100644
--- a/plugins/dfsound/spu.c
+++ b/plugins/dfsound/spu.c
@@ -23,6 +23,11 @@
#include "cfg.h"
#include "dsoundoss.h"
#include "regs.h"
+
+#ifdef _WINDOWS
+#include "debug.h"
+#include "record.h"
+#endif
#ifdef ENABLE_NLS
#include <libintl.h>
@@ -33,8 +38,10 @@
#define _(x) (x)
#define N_(x) (x)
#endif
-
-#if defined (USEMACOSX)
+
+#if defined (_WINDOWS)
+static char * libraryName = N_("DirectSound Driver");
+#elif defined (USEMACOSX)
static char * libraryName = N_("Mac OS X Sound");
#elif defined (USEALSA)
static char * libraryName = N_("ALSA Sound");
@@ -89,8 +96,15 @@ int bEndThread=0; // thread handlers
int bThreadEnded=0;
int bSpuInit=0;
int bSPUIsOpen=0;
-
+
+#ifdef _WINDOWS
+HWND hWMain=0; // window handle
+HWND hWDebug=0;
+HWND hWRecord=0;
+static HANDLE hMainThread;
+#else
static pthread_t thread = (pthread_t)-1; // thread id (linux)
+#endif
unsigned long dwNewChannel=0; // flags for faster testing, if new channel starts
@@ -438,7 +452,11 @@ INLINE int iGetInterpolationVal(int ch)
////////////////////////////////////////////////////////////////////////
-static void *MAINThread(void *arg)
+#ifdef _WINDOWS
+static VOID CALLBACK MAINProc(UINT nTimerId, UINT msg, DWORD dwUser, DWORD dwParam1, DWORD dwParam2)
+#else
+static void *MAINThread(void *arg)
+#endif
{
int s_1,s_2,fa,ns;
#ifndef _MACOSX
@@ -471,8 +489,19 @@ static void *MAINThread(void *arg)
{
iSecureStart=0; // reset secure
- if(iUseTimer) return 0; // linux no-thread mode? bye
- usleep(PAUSE_L); // else sleep for x ms (linux)
+#ifdef _WINDOWS
+ if(iUseTimer) // no-thread mode?
+ {
+ if(iUseTimer==1) // -> ok, timer mode 1: setup a oneshot timer of x ms to wait
+ timeSetEvent(PAUSE_W,1,MAINProc,0,TIME_ONESHOT);
+ return; // -> and done this time (timer mode 1 or 2)
+ }
+ // win thread mode:
+ Sleep(PAUSE_W); // sleep for x ms (win)
+#else
+ if(iUseTimer) return 0; // linux no-thread mode? bye
+ usleep(PAUSE_L); // else sleep for x ms (linux)
+#endif
if(dwNewChannel) iSecureStart=1; // if a new channel kicks in (or, of course, sound buffer runs low), we will leave the loop
}
@@ -605,14 +634,22 @@ static void *MAINThread(void *arg)
while(iSpuAsyncWait && !bEndThread &&
timeGetTime_spu()<dwWatchTime)
- usleep(1000L);
+#ifdef _WINDOWS
+ Sleep(1);
+#else
+ usleep(1000L);
+#endif
}
else
{
lastch=ch;
lastns=ns;
-
- return 0;
+
+#ifdef _WINDOWS
+ return;
+#else
+ return 0;
+#endif
}
}
@@ -757,9 +794,25 @@ ENDX: ;
// end of big main loop...
bThreadEnded = 1;
-
- return 0;
+
+#ifndef _WINDOWS
+ return 0;
+#endif
}
+
+////////////////////////////////////////////////////////////////////////
+// WINDOWS THREAD... simply calls the timer func and stays forever :)
+////////////////////////////////////////////////////////////////////////
+
+#ifdef _WINDOWS
+
+DWORD WINAPI MAINThreadEx(LPVOID lpParameter)
+{
+ MAINProc(0,0,0,0,0);
+ return 0;
+}
+
+#endif
// SPU ASYNC... even newer epsxe func
// 1 time every 'cycle' cycles... harhar
@@ -771,13 +824,30 @@ void CALLBACK SPUasync(unsigned long cycle)
iSpuAsyncWait++;
if(iSpuAsyncWait<=64) return;
iSpuAsyncWait=0;
- }
+ }
+
+#ifdef _WINDOWS
+ if(iDebugMode==2)
+ {
+ if(IsWindow(hWDebug)) DestroyWindow(hWDebug);
+ hWDebug=0;iDebugMode=0;
+ }
+ if(iRecordMode==2)
+ {
+ if(IsWindow(hWRecord)) DestroyWindow(hWRecord);
+ hWRecord=0;iRecordMode=0;
+ }
+#endif
if(iUseTimer==2) // special mode, only used in Linux by this spu (or if you enable the experimental Windows mode)
{
if(!bSpuInit) return; // -> no init, no call
- MAINThread(0); // -> linux high-compat mode
+#ifdef _WINDOWS
+ MAINProc(0,0,0,0,0); // -> experimental win mode... not really tested... don't like the drawbacks
+#else
+ MAINThread(0); // -> linux high-compat mode
+#endif
}
}
@@ -825,17 +895,50 @@ void SetupTimer(void)
bEndThread=0; // init thread vars
bThreadEnded=0;
bSpuInit=1; // flag: we are inited
-
+
+#ifdef _WINDOWS
+
+ if(iUseTimer==1) // windows: use timer
+ {
+ timeBeginPeriod(1);
+ timeSetEvent(1,1,MAINProc,0,TIME_ONESHOT);
+ }
+ else
+ if(iUseTimer==0) // windows: use thread
+ {
+ //_beginthread(MAINThread,0,NULL);
+ DWORD dw;
+ hMainThread=CreateThread(NULL,0,MAINThreadEx,0,0,&dw);
+ SetThreadPriority(hMainThread,
+ //THREAD_PRIORITY_TIME_CRITICAL);
+ THREAD_PRIORITY_HIGHEST);
+ }
+
+#else
+
if(!iUseTimer) // linux: use thread
{
pthread_create(&thread, NULL, MAINThread, NULL);
- }
+ }
+
+#endif
}
// REMOVETIMER: kill threads/timers
void RemoveTimer(void)
{
- bEndThread=1; // raise flag to end thread
+ bEndThread=1; // raise flag to end thread
+
+#ifdef _WINDOWS
+
+ if(iUseTimer!=2) // windows thread?
+ {
+ while(!bThreadEnded) {Sleep(5L);} // -> wait till thread has ended
+ Sleep(5L);
+ }
+ if(iUseTimer==1) timeEndPeriod(1); // windows timer? stop it
+
+#else
if(!iUseTimer) // linux tread?
{
@@ -843,6 +946,8 @@ void RemoveTimer(void)
while(!bThreadEnded && i<2000) {usleep(1000L);i++;} // -> wait until thread has ended
if(thread!=(pthread_t)-1) {pthread_cancel(thread);thread=(pthread_t)-1;} // -> cancel thread anyway
}
+
+#endif
bThreadEnded=0; // no more spu is running
bSpuInit=0;
@@ -933,14 +1038,44 @@ long CALLBACK SPUinit(void)
}
// SPUOPEN: called by main emu after init
-long CALLBACK SPUopen(void)
+#ifdef _WINDOWS
+long CALLBACK SPUopen(HWND hW)
+#else
+long SPUopen(void)
+#endif
{
- if (bSPUIsOpen) return 0; // security for some stupid main emus
+ if (bSPUIsOpen) return 0; // security for some stupid main emus
+
+#ifdef _WINDOWS
+ LastWrite=0xffffffff;LastPlay=0; // init some play vars
+ if(!IsWindow(hW)) hW=GetActiveWindow();
+ hWMain = hW; // store hwnd
+#endif
SetupSound(); // setup sound (before init!)
SetupTimer(); // timer for feeding data
- bSPUIsOpen = 1;
+ bSPUIsOpen = 1;
+
+#ifdef _WINDOWS
+ if(iDebugMode) // windows debug dialog
+ {
+ hWDebug=CreateDialog(hInst,MAKEINTRESOURCE(IDD_DEBUG),
+ NULL,(DLGPROC)DebugDlgProc);
+ SetWindowPos(hWDebug,HWND_TOPMOST,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE|SWP_SHOWWINDOW|SWP_NOACTIVATE);
+ UpdateWindow(hWDebug);
+ SetFocus(hWMain);
+ }
+
+ if(iRecordMode) // windows recording dialog
+ {
+ hWRecord=CreateDialog(hInst,MAKEINTRESOURCE(IDD_RECORD),
+ NULL,(DLGPROC)RecordDlgProc);
+ SetWindowPos(hWRecord,HWND_TOPMOST,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE|SWP_SHOWWINDOW|SWP_NOACTIVATE);
+ UpdateWindow(hWRecord);
+ SetFocus(hWMain);
+ }
+#endif
return PSE_SPU_ERR_SUCCESS;
}
@@ -950,7 +1085,14 @@ long CALLBACK SPUclose(void)
{
if (!bSPUIsOpen) return 0; // some security
- bSPUIsOpen = 0; // no more open
+ bSPUIsOpen = 0; // no more open
+
+#ifdef _WINDOWS
+ if(IsWindow(hWDebug)) DestroyWindow(hWDebug);
+ hWDebug=0;
+ if(IsWindow(hWRecord)) DestroyWindow(hWRecord);
+ hWRecord=0;
+#endif
RemoveTimer(); // no more feeding
RemoveSound(); // no more sound handling
@@ -975,19 +1117,26 @@ long CALLBACK SPUtest(void)
// SPUCONFIGURE: call config dialog
long CALLBACK SPUconfigure(void)
-{
-#ifdef _MACOSX
+{
+#if defined (_WINDOWS)
+ DialogBox(hInst,MAKEINTRESOURCE(IDD_CFGDLG),
+ GetActiveWindow(),(DLGPROC)DSoundDlgProc);
+#elif defined (_MACOSX)
DoConfiguration();
#else
StartCfgTool("CFG");
-#endif
+#endif
+
return 0;
}
// SPUABOUT: show about window
void CALLBACK SPUabout(void)
-{
-#ifdef _MACOSX
+{
+#if defined (_WINDOWS)
+ DialogBox(hInst,MAKEINTRESOURCE(IDD_ABOUT),
+ GetActiveWindow(),(DLGPROC)AboutDlgProc);
+#elif defined (_MACOSX)
DoAbout();
#else
StartCfgTool("ABOUT");
@@ -1020,7 +1169,7 @@ unsigned long CALLBACK PSEgetLibType(void)
unsigned long CALLBACK PSEgetLibVersion(void)
{
- return (1 << 16) | (6 << 8);
+ return (1 << 16) | (1 << 8);
}
char * SPUgetLibInfos(void)
diff --git a/plugins/dfsound/stdafx.h b/plugins/dfsound/stdafx.h
index 8be88489..7d1a1f52 100644
--- a/plugins/dfsound/stdafx.h
+++ b/plugins/dfsound/stdafx.h
@@ -14,6 +14,24 @@
* additional informations. *
* *
***************************************************************************/
+
+#ifdef _WINDOWS
+
+#define WIN32_LEAN_AND_MEAN
+#define STRICT
+#include <windows.h>
+#include <windowsx.h>
+#include "mmsystem.h"
+#include <process.h>
+#include <stdlib.h>
+
+#ifndef INLINE
+#define INLINE __inline
+#endif
+
+#include "resource.h"
+
+#else
#ifndef _MACOSX
#include "config.h"
@@ -42,5 +60,7 @@
#ifndef INLINE
#define INLINE inline
#endif
+
+#endif
#include "psemuxa.h"
diff --git a/plugins/dfsound/xa.c b/plugins/dfsound/xa.c
index fdae4f9e..0c1ae57a 100644
--- a/plugins/dfsound/xa.c
+++ b/plugins/dfsound/xa.c
@@ -15,7 +15,8 @@
* *
***************************************************************************/
-#include "stdafx.h"
+#include "stdafx.h"
+
#define _IN_XA
#include <stdint.h>
@@ -101,6 +102,8 @@ INLINE void MixXA(void)
////////////////////////////////////////////////////////////////////////
// small linux time helper... only used for watchdog
////////////////////////////////////////////////////////////////////////
+
+#ifndef _WINDOWS
unsigned long timeGetTime_spu()
{
@@ -108,6 +111,8 @@ unsigned long timeGetTime_spu()
gettimeofday(&tv, 0); // well, maybe there are better ways
return tv.tv_sec * 1000 + tv.tv_usec/1000; // to do that, but at least it works
}
+
+#endif
////////////////////////////////////////////////////////////////////////
// FEED XA
@@ -397,9 +402,14 @@ INLINE void FeedCDDA(unsigned char *pcm, int nBytes)
if(CDDAFeed==CDDAEnd) CDDAFeed=CDDAStart;
while(CDDAFeed==CDDAPlay-1||
(CDDAFeed==CDDAEnd-1&&CDDAPlay==CDDAStart))
- {
+ {
+#ifdef _WINDOWS
+ if (!iUseTimer) Sleep(1);
+ else return;
+#else
if (!iUseTimer) usleep(1000);
- else return;
+ else return;
+#endif
}
*CDDAFeed++=(*pcm | (*(pcm+1)<<8) | (*(pcm+2)<<16) | (*(pcm+3)<<24));
nBytes-=4;