diff -Naur ref2/plugins/dfsound/spu.c patched/plugins/dfsound/spu.c --- ref2/plugins/dfsound/spu.c 2008-03-22 14:46:36.000000000 +0100 +++ patched/plugins/dfsound/spu.c 2008-03-22 13:29:52.000000000 +0100 @@ -99,18 +99,14 @@ // spu version infos/name //////////////////////////////////////////////////////////////////////// -const unsigned char version = 1; -const unsigned char revision = 0; -const unsigned char build = 0; -#ifdef _WINDOWS -static char * libraryName = "P.E.Op.S. DSound Audio Driver"; -#else +const u8 version = 1; +const u8 revision = 0; +const u8 build = 0; #ifndef USEALSA static char * libraryName = "OSS Sound"; #else static char * libraryName = "ALSA Sound"; #endif -#endif static char * libraryInfo = "P.E.Op.S. OSS Driver V1.7\nCoded by Pete Bernert and the P.E.Op.S. team\n"; //////////////////////////////////////////////////////////////////////// @@ -119,11 +115,11 @@ // psx buffer / addresses -unsigned short regArea[10000]; -unsigned short spuMem[256*1024]; -unsigned char * spuMemC; -unsigned char * pSpuIrq=0; -unsigned char * pSpuBuffer; +u16 regArea[10000]; +u16 spuMem[256*1024]; +u8 * spuMemC; +u8 * pSpuIrq=0; +u8 * pSpuBuffer; // user settings @@ -143,31 +139,25 @@ SPUCHAN s_chan[MAXCHAN+1]; // channel + 1 infos (1 is security for fmod handling) REVERBInfo rvb; -unsigned long dwNoiseVal=1; // global noise generator +u32 dwNoiseVal=1; // global noise generator int iWatchDog=0; -unsigned short spuCtrl=0; // some vars to store psx reg infos -unsigned short spuStat=0; -unsigned short spuIrq=0; -unsigned long spuAddr=0xffffffff; // address into spu mem +u16 spuCtrl=0; // some vars to store psx reg infos +u16 spuStat=0; +u16 spuIrq=0; +u32 spuAddr=0xffffffff; // address into spu mem 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 // 2003/06/07 - Pete #ifndef NOTHREADLIB static pthread_t thread = -1; // thread id (linux) #endif -#endif -unsigned long dwNewChannel=0; // flags for faster testing, if new channel starts + +u32 dwNewChannel=0; // flags for faster testing, if new channel starts void (CALLBACK *irqCallback)(void)=0; // func of main emu, called on spu irq void (CALLBACK *cddavCallback)(unsigned short,unsigned short)=0; @@ -354,14 +344,10 @@ //////////////////////////////////////////////////////////////////////// -#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,voldiv=iVolume; - unsigned char * start;unsigned int nSample; + u8 * start; u32 nSample; int ch,predict_nr,shift_factor,flags,d,s; int gpos,bIRQReturn=0; @@ -529,7 +515,7 @@ //if(!(flags&2)) // 1+2: do loop... otherwise: stop if(flags!=3 || s_chan[ch].pLoop==NULL) // PETE: if we don't check exactly for 3, loop hang ups will happen (DQ4, for example) { // and checking if pLoop is set avoids crashes, yeah - start = (unsigned char*)-1; + start = (u8*)-1; } else { @@ -548,11 +534,8 @@ bIRQReturn=0; lastch=ch; lastns=ns; -#ifdef _WINDOWS - return; -#else + return 0; -#endif } //////////////////////////////////////////// @@ -775,9 +758,9 @@ if(iCycle++>8) //temp fix: lowered for low latency alsa configs { - SoundFeedStreamData((unsigned char*)pSpuBuffer, - ((unsigned char *)pS)- - ((unsigned char *)pSpuBuffer)); + SoundFeedStreamData((u8*)pSpuBuffer, + ((u8 *)pS)- + ((u8 *)pSpuBuffer)); pS=(short *)pSpuBuffer; iCycle=0; } @@ -787,25 +770,9 @@ bThreadEnded=1; -#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 - //////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////// @@ -815,32 +782,15 @@ // 1 time every 'cycle' cycles... harhar //////////////////////////////////////////////////////////////////////// -void CALLBACK SPUasync(unsigned long cycle) +void CALLBACK SPUasync(u32 cycle) { iWatchDog=0; // clear the watchdog -#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 -#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 } } @@ -851,8 +801,6 @@ // (262/32)x60 in ntsc //////////////////////////////////////////////////////////////////////// -#ifndef _WINDOWS - // since epsxe 1.5.2 (linux) uses SPUupdate, not SPUasync, I will // leave that func in the linux port, until epsxe linux is using // the async function as well @@ -862,8 +810,6 @@ SPUasync(0); } -#endif - //////////////////////////////////////////////////////////////////////// // XA AUDIO //////////////////////////////////////////////////////////////////////// @@ -887,7 +833,7 @@ long CALLBACK SPUinit(void) { - spuMemC=(unsigned char *)spuMem; // just small setup + spuMemC=(u8 *)spuMem; // just small setup memset((void *)s_chan,0,MAXCHAN*sizeof(SPUCHAN)); memset((void *)&rvb,0,sizeof(REVERBInfo)); InitADSR(); @@ -980,7 +926,7 @@ { int i; - pSpuBuffer=(unsigned char *)malloc(32768); // alloc mixing buffer + pSpuBuffer=(u8 *)malloc(32768); // alloc mixing buffer if(iUseReverb==1) i=88200*2; else i=NSSIZE*2; @@ -991,7 +937,7 @@ sRVBPlay = sRVBStart; XAStart = // alloc xa buffer - (unsigned long *)malloc(44100*4); + (u32 *)malloc(44100*4); XAPlay = XAStart; XAFeed = XAStart; XAEnd = XAStart + 44100; @@ -1040,11 +986,7 @@ // SPUOPEN: called by main emu after init //////////////////////////////////////////////////////////////////////// -#ifdef _WINDOWS -long CALLBACK SPUopen(HWND hW) -#else long SPUopen(void) -#endif { if(bSPUIsOpen) return 0; // security for some stupid main emus @@ -1055,17 +997,11 @@ spuAddr=0xffffffff; bEndThread=0; bThreadEnded=0; - spuMemC=(unsigned char *)spuMem; + spuMemC=(u8 *)spuMem; memset((void *)s_chan,0,(MAXCHAN+1)*sizeof(SPUCHAN)); pSpuIrq=0; iSPUIRQWait=1; -#ifdef _WINDOWS - LastWrite=0xffffffff;LastPlay=0; // init some play vars - if(!IsWindow(hW)) hW=GetActiveWindow(); - hWMain = hW; // store hwnd -#endif - ReadConfig(); // read user stuff SetupSound(); // setup midas (before init!) @@ -1076,37 +1012,15 @@ 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; } //////////////////////////////////////////////////////////////////////// -#ifndef _WINDOWS void SPUsetConfigFile(char * pCfg) { pConfigFile=pCfg; } -#endif //////////////////////////////////////////////////////////////////////// // SPUCLOSE: called before shutdown @@ -1118,13 +1032,6 @@ 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 @@ -1158,12 +1065,7 @@ long CALLBACK SPUconfigure(void) { -#ifdef _WINDOWS - DialogBox(hInst,MAKEINTRESOURCE(IDD_CFGDLG), - GetActiveWindow(),(DLGPROC)DSoundDlgProc); -#else StartCfgTool("CFG"); -#endif return 0; } @@ -1173,12 +1075,7 @@ void CALLBACK SPUabout(void) { -#ifdef _WINDOWS - DialogBox(hInst,MAKEINTRESOURCE(IDD_ABOUT), - GetActiveWindow(),(DLGPROC)AboutDlgProc); -#else StartCfgTool("ABOUT"); -#endif } //////////////////////////////////////////////////////////////////////// @@ -1192,7 +1089,7 @@ irqCallback = callback; } -void CALLBACK SPUregisterCDDAVolume(void (CALLBACK *CDDAVcallback)(unsigned short,unsigned short)) +void CALLBACK SPUregisterCDDAVolume(void (CALLBACK *CDDAVcallback)(u16, u16)) { cddavCallback = CDDAVcallback; } @@ -1206,12 +1103,12 @@ return libraryName; } -unsigned long CALLBACK PSEgetLibType(void) +u32 CALLBACK PSEgetLibType(void) { return PSE_LT_SPU; } -unsigned long CALLBACK PSEgetLibVersion(void) +u32 CALLBACK PSEgetLibVersion(void) { return version<<16|revision<<8|build; } diff -Naur ref2/plugins/dfsound/spu.h patched/plugins/dfsound/spu.h --- ref2/plugins/dfsound/spu.h 2008-03-22 14:46:36.000000000 +0100 +++ patched/plugins/dfsound/spu.h 2008-03-22 13:12:40.000000000 +0100 @@ -28,3 +28,4 @@ void SetupTimer(void); void RemoveTimer(void); void CALLBACK SPUplayADPCMchannel(xa_decode_t *xap); + diff -Naur ref2/plugins/dfsound/stdafx.c patched/plugins/dfsound/stdafx.c --- ref2/plugins/dfsound/stdafx.c 2008-03-22 14:46:36.000000000 +0100 +++ patched/plugins/dfsound/stdafx.c 2008-03-22 13:12:30.000000000 +0100 @@ -6,3 +6,4 @@ // TODO: reference any additional headers you need in STDAFX.H // and not in this file + diff -Naur ref2/plugins/dfsound/stdafx.h patched/plugins/dfsound/stdafx.h --- ref2/plugins/dfsound/stdafx.h 2008-03-22 14:46:36.000000000 +0100 +++ patched/plugins/dfsound/stdafx.h 2008-03-22 13:29:28.000000000 +0100 @@ -24,31 +24,8 @@ // //*************************************************************************// -////////////////////////////////////////////////////////// -// WINDOWS -////////////////////////////////////////////////////////// - -#ifdef _WINDOWS - -#define WIN32_LEAN_AND_MEAN -#define STRICT -#include -#include -#include "mmsystem.h" -#include -#include - -// enable that for auxprintf(); -//#define SMALLDEBUG -//#include -//void auxprintf (LPCTSTR pFormat, ...); - -#define INLINE __inline - -////////////////////////////////////////////////////////// -// LINUX -////////////////////////////////////////////////////////// -#else +#ifndef __STDAFX_H_ +#define __STDAFX_H_ #include #include @@ -65,6 +42,21 @@ #include #include +#include + +/* Define types */ +typedef int8_t s8; +typedef int16_t s16; +typedef int32_t s32; +typedef int64_t s64; +typedef intptr_t sptr; + +typedef uint8_t u8; +typedef uint16_t u16; +typedef uint32_t u32; +typedef uint64_t u64; +typedef uintptr_t uptr; + #undef CALLBACK #define CALLBACK #define DWORD unsigned long @@ -73,6 +65,7 @@ #define INLINE inline +#include "psemuxa.h" + #endif -#include "psemuxa.h" diff -Naur ref2/plugins/dfsound/xa.c patched/plugins/dfsound/xa.c --- ref2/plugins/dfsound/xa.c 2008-03-22 14:46:36.000000000 +0100 +++ patched/plugins/dfsound/xa.c 2008-03-22 12:57:08.000000000 +0100 @@ -40,13 +40,13 @@ xa_decode_t * xapGlobal=0; -uint32_t * XAFeed = NULL; -uint32_t * XAPlay = NULL; -uint32_t * XAStart = NULL; -uint32_t * XAEnd = NULL; +u32 * XAFeed = NULL; +u32 * XAPlay = NULL; +u32 * XAStart = NULL; +u32 * XAEnd = NULL; -uint32_t XARepeat = 0; -uint32_t XALastVal = 0; +u32 XARepeat = 0; +u32 XALastVal = 0; int iLeftXAVol = 32767; int iRightXAVol = 32767; @@ -112,13 +112,13 @@ { static DWORD dwLT=0; static DWORD dwFPS=0; - static int iFPSCnt=0; - static int iLastSize=0; - static DWORD dwL1=0; - DWORD dw=timeGetTime_spu(),dw1,dw2; - - iPlace=iSize; - + static int iFPSCnt=0; + static int iLastSize=0; + static DWORD dwL1=0; + DWORD dw=timeGetTime_spu(),dw1,dw2; + + iPlace=iSize; + dwFPS+=dw-dwLT;iFPSCnt++; dwLT=dw; diff -Naur ref2/plugins/dfsound/xa.h patched/plugins/dfsound/xa.h --- ref2/plugins/dfsound/xa.h 2008-03-22 14:46:36.000000000 +0100 +++ patched/plugins/dfsound/xa.h 2008-03-22 12:54:42.000000000 +0100 @@ -27,3 +27,4 @@ INLINE void MixXA(void); INLINE void FeedXA(xa_decode_t *xap); +