diff options
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/dfsound/externals.h | 4 | ||||
-rw-r--r-- | plugins/dfsound/freeze.c | 18 | ||||
-rw-r--r-- | plugins/dfsound/registers.c | 43 | ||||
-rw-r--r-- | plugins/dfsound/registers.h | 4 | ||||
-rw-r--r-- | plugins/dfsound/regs.h | 27 | ||||
-rw-r--r-- | plugins/dfsound/spu.c | 35 |
6 files changed, 34 insertions, 97 deletions
diff --git a/plugins/dfsound/externals.h b/plugins/dfsound/externals.h index 0ddf406..4ce39bb 100644 --- a/plugins/dfsound/externals.h +++ b/plugins/dfsound/externals.h @@ -107,19 +107,15 @@ typedef struct int spos;
int sinc;
- unsigned char * pStart; // start ptr into sound mem
unsigned char * pCurr; // current pos in sound mem
unsigned char * pLoop; // loop ptr in sound mem
unsigned int bStop:1; // is channel stopped (sample _can_ still be playing, ADSR Release phase)
unsigned int bReverb:1; // can we do reverb on this channel? must have ctrl register bit, to get active
- unsigned int bIgnoreLoop:1; // ignore loop bit, if an external loop address is used
unsigned int bRVBActive:1; // reverb active flag
unsigned int bNoise:1; // noise active flag
unsigned int bFMod:2; // freq mod (0=off, 1=sound channel, 2=freq channel)
- int iActFreq; // current psx pitch
- int iUsedFreq; // current pc pitch
int iLeftVolume; // left volume
int iRightVolume; // right volume
ADSRInfoEx ADSRX;
diff --git a/plugins/dfsound/freeze.c b/plugins/dfsound/freeze.c index d09a9b0..6caa6bf 100644 --- a/plugins/dfsound/freeze.c +++ b/plugins/dfsound/freeze.c @@ -22,7 +22,6 @@ #include "externals.h"
#include "registers.h"
#include "spu.h"
-#include "regs.h"
////////////////////////////////////////////////////////////////////////
// freeze structs
@@ -129,16 +128,16 @@ static void save_channel(SPUCHAN_orig *d, const SPUCHAN *s, int ch) d->spos = s->spos;
d->sinc = s->sinc;
memcpy(d->SB, s->SB, sizeof(d->SB));
- d->pStart = s->pStart;
+ d->pStart = (unsigned char *)((regAreaGet(ch,6)&~1)<<3);
d->pCurr = s->pCurr;
d->pLoop = s->pLoop;
d->bOn = !!(dwChannelOn & (1<<ch));
d->bStop = s->bStop;
d->bReverb = s->bReverb;
- d->iActFreq = s->iActFreq;
- d->iUsedFreq = s->iUsedFreq;
+ d->iActFreq = 1;
+ d->iUsedFreq = 2;
d->iLeftVolume = s->iLeftVolume;
- d->bIgnoreLoop = s->bIgnoreLoop;
+ d->bIgnoreLoop = 0;
d->iRightVolume = s->iRightVolume;
d->iRawPitch = s->iRawPitch;
d->s_1 = s->SB[27]; // yes it's reversed
@@ -168,16 +167,12 @@ static void load_channel(SPUCHAN *d, const SPUCHAN_orig *s, int ch) d->spos = s->spos;
d->sinc = s->sinc;
memcpy(d->SB, s->SB, sizeof(d->SB));
- d->pStart = (void *)((long)s->pStart & 0x7fff0);
d->pCurr = (void *)((long)s->pCurr & 0x7fff0);
d->pLoop = (void *)((long)s->pLoop & 0x7fff0);
if (s->bOn) dwChannelOn |= 1<<ch;
d->bStop = s->bStop;
d->bReverb = s->bReverb;
- d->iActFreq = s->iActFreq;
- d->iUsedFreq = s->iUsedFreq;
d->iLeftVolume = s->iLeftVolume;
- d->bIgnoreLoop = s->bIgnoreLoop;
d->iRightVolume = s->iRightVolume;
d->iRawPitch = s->iRawPitch;
d->bRVBActive = s->bRVBActive;
@@ -243,8 +238,6 @@ long CALLBACK SPUfreeze(uint32_t ulFreezeMode,SPUFreeze_t * pF) for(i=0;i<MAXCHAN;i++)
{
save_channel(&pFO->s_chan[i],&s_chan[i],i);
- if(pFO->s_chan[i].pStart)
- pFO->s_chan[i].pStart-=(unsigned long)spuMemC;
if(pFO->s_chan[i].pCurr)
pFO->s_chan[i].pCurr-=(unsigned long)spuMemC;
if(pFO->s_chan[i].pLoop)
@@ -320,7 +313,6 @@ void LoadStateV5(SPUFreeze_t * pF) {
load_channel(&s_chan[i],&pFO->s_chan[i],i);
- s_chan[i].pStart+=(unsigned long)spuMemC;
s_chan[i].pCurr+=(unsigned long)spuMemC;
s_chan[i].pLoop+=(unsigned long)spuMemC;
}
@@ -336,8 +328,6 @@ void LoadStateUnknown(SPUFreeze_t * pF) {
s_chan[i].bStop=0;
s_chan[i].pLoop=spuMemC;
- s_chan[i].pStart=spuMemC;
- s_chan[i].pLoop=spuMemC;
}
dwNewChannel=0;
diff --git a/plugins/dfsound/registers.c b/plugins/dfsound/registers.c index 983af8c..2493a1e 100644 --- a/plugins/dfsound/registers.c +++ b/plugins/dfsound/registers.c @@ -21,7 +21,6 @@ #include "externals.h"
#include "registers.h"
-#include "regs.h"
/*
// adsr time values (in ms) by James Higgs ... see the end of
@@ -41,6 +40,15 @@ #define SUSTAIN_MS 441L
#define RELEASE_MS 437L
+static void SoundOn(int start,int end,unsigned short val);
+static void SoundOff(int start,int end,unsigned short val);
+static void FModOn(int start,int end,unsigned short val);
+static void NoiseOn(int start,int end,unsigned short val);
+static void SetVolumeL(unsigned char ch,short vol);
+static void SetVolumeR(unsigned char ch,short vol);
+static void SetPitch(int ch,unsigned short val);
+static void ReverbOn(int start,int end,unsigned short val);
+
////////////////////////////////////////////////////////////////////////
// WRITE REGISTERS: called by main emu
////////////////////////////////////////////////////////////////////////
@@ -69,8 +77,7 @@ void CALLBACK SPUwriteRegister(unsigned long reg, unsigned short val) break;
//------------------------------------------------// start
case 6:
- // Brain Dead 13 - align to 16 boundary
- s_chan[ch].pStart= spuMemC+(unsigned long)((val<<3)&~0xf);
+ // taken from regArea later
break;
//------------------------------------------------// level with pre-calcs
case 8:
@@ -165,11 +172,7 @@ void CALLBACK SPUwriteRegister(unsigned long reg, unsigned short val) break;
//------------------------------------------------//
case 14: // loop?
- //WaitForSingleObject(s_chan[ch].hMutex,2000); // -> no multithread fuckups
- s_chan[ch].pLoop=spuMemC+((unsigned long)((val<<3)&~0xf));
- //s_chan[ch].bIgnoreLoop=1;
- //ReleaseMutex(s_chan[ch].hMutex); // -> oki, on with the thread
- dwChannelDead&=~(1<<ch);
+ s_chan[ch].pLoop=spuMemC+((val&~1)<<3);
break;
//------------------------------------------------//
}
@@ -413,7 +416,7 @@ unsigned short CALLBACK SPUreadRegister(unsigned long reg) // SOUND ON register write
////////////////////////////////////////////////////////////////////////
-void SoundOn(int start,int end,unsigned short val) // SOUND ON PSX COMAND
+static void SoundOn(int start,int end,unsigned short val)
{
int ch;
@@ -421,8 +424,6 @@ void SoundOn(int start,int end,unsigned short val) // SOUND ON PSX COMAND {
if((val&1) && regAreaGet(ch,6)) // mmm... start has to be set before key on !?!
{
- s_chan[ch].bIgnoreLoop=0;
-
// do this here, not in StartSound
// - fixes fussy timing issues
s_chan[ch].bStop=0;
@@ -440,7 +441,7 @@ void SoundOn(int start,int end,unsigned short val) // SOUND ON PSX COMAND // SOUND OFF register write
////////////////////////////////////////////////////////////////////////
-void SoundOff(int start,int end,unsigned short val) // SOUND OFF PSX COMMAND
+static void SoundOff(int start,int end,unsigned short val)
{
int ch;
for(ch=start;ch<end;ch++,val>>=1) // loop channels
@@ -460,7 +461,7 @@ void SoundOff(int start,int end,unsigned short val) // SOUND OFF PSX COMMAND // FMOD register write
////////////////////////////////////////////////////////////////////////
-void FModOn(int start,int end,unsigned short val) // FMOD ON PSX COMMAND
+static void FModOn(int start,int end,unsigned short val)
{
int ch;
@@ -487,7 +488,7 @@ void FModOn(int start,int end,unsigned short val) // FMOD ON PSX COMMAND // NOISE register write
////////////////////////////////////////////////////////////////////////
-void NoiseOn(int start,int end,unsigned short val) // NOISE ON PSX COMMAND
+static void NoiseOn(int start,int end,unsigned short val)
{
int ch;
@@ -504,7 +505,7 @@ void NoiseOn(int start,int end,unsigned short val) // NOISE ON PSX COMMAND // please note: sweep and phase invert are wrong... but I've never seen
// them used
-void SetVolumeL(unsigned char ch,short vol) // LEFT VOLUME
+static void SetVolumeL(unsigned char ch,short vol) // LEFT VOLUME
{
if(vol&0x8000) // sweep?
{
@@ -530,7 +531,7 @@ void SetVolumeL(unsigned char ch,short vol) // LEFT VOLUME // RIGHT VOLUME register write
////////////////////////////////////////////////////////////////////////
-void SetVolumeR(unsigned char ch,short vol) // RIGHT VOLUME
+static void SetVolumeR(unsigned char ch,short vol) // RIGHT VOLUME
{
if(vol&0x8000) // comments... see above :)
{
@@ -556,24 +557,22 @@ void SetVolumeR(unsigned char ch,short vol) // RIGHT VOLUME // PITCH register write
////////////////////////////////////////////////////////////////////////
-void SetPitch(int ch,unsigned short val) // SET PITCH
+static void SetPitch(int ch,unsigned short val) // SET PITCH
{
int NP;
if(val>0x3fff) NP=0x3fff; // get pitch val
else NP=val;
s_chan[ch].iRawPitch=NP;
-
- NP=(44100L*NP)/4096L; // calc frequency
- if(NP<1) NP=1; // some security
- s_chan[ch].iActFreq=NP; // store frequency
+ s_chan[ch].sinc=(NP<<4)|8;
+ if(iUseInterpolation==1) s_chan[ch].SB[32]=1; // -> freq change in simple interpolation mode: set flag
}
////////////////////////////////////////////////////////////////////////
// REVERB register write
////////////////////////////////////////////////////////////////////////
-void ReverbOn(int start,int end,unsigned short val) // REVERB ON PSX COMMAND
+static void ReverbOn(int start,int end,unsigned short val)
{
int ch;
diff --git a/plugins/dfsound/registers.h b/plugins/dfsound/registers.h index 204a669..cb95bc1 100644 --- a/plugins/dfsound/registers.h +++ b/plugins/dfsound/registers.h @@ -150,3 +150,7 @@ #define STAT_IRQ 0x40
+///////////////////////////////////////////////////////////
+
+void CALLBACK SPUwriteRegister(unsigned long reg, unsigned short val);
+
diff --git a/plugins/dfsound/regs.h b/plugins/dfsound/regs.h deleted file mode 100644 index 3d2689b..0000000 --- a/plugins/dfsound/regs.h +++ /dev/null @@ -1,27 +0,0 @@ -/***************************************************************************
- regs.h - description
- -------------------
- begin : Wed May 15 2002
- copyright : (C) 2002 by Pete Bernert
- email : BlackDove@addcom.de
- ***************************************************************************/
-/***************************************************************************
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. See also the license.txt file for *
- * additional informations. *
- * *
- ***************************************************************************/
-
-void SoundOn(int start,int end,unsigned short val);
-void SoundOff(int start,int end,unsigned short val);
-void FModOn(int start,int end,unsigned short val);
-void NoiseOn(int start,int end,unsigned short val);
-void SetVolumeL(unsigned char ch,short vol);
-void SetVolumeR(unsigned char ch,short vol);
-void SetPitch(int ch,unsigned short val);
-void ReverbOn(int start,int end,unsigned short val);
-void CALLBACK SPUwriteRegister(unsigned long reg, unsigned short val);
-
diff --git a/plugins/dfsound/spu.c b/plugins/dfsound/spu.c index b866cff..8c6f7d2 100644 --- a/plugins/dfsound/spu.c +++ b/plugins/dfsound/spu.c @@ -26,7 +26,6 @@ #include "registers.h" #include "cfg.h" #include "dsoundoss.h" -#include "regs.h" #ifdef ENABLE_NLS #include <libintl.h> @@ -287,19 +286,9 @@ INLINE void StartSound(int ch) // ALL KIND OF HELPERS //////////////////////////////////////////////////////////////////////// -INLINE void VoiceChangeFrequency(int ch) -{ - s_chan[ch].iUsedFreq=s_chan[ch].iActFreq; // -> take it and calc steps - s_chan[ch].sinc=s_chan[ch].iRawPitch<<4; - if(!s_chan[ch].sinc) s_chan[ch].sinc=1; - if(iUseInterpolation==1) s_chan[ch].SB[32]=1; // -> freq change in simle imterpolation mode: set flag -} - -//////////////////////////////////////////////////////////////////////// - INLINE int FModChangeFrequency(int ch,int ns) { - int NP=s_chan[ch].iRawPitch; + unsigned int NP=s_chan[ch].iRawPitch; int sinc; NP=((32768L+iFMod[ns])*NP)/32768L; @@ -307,12 +296,7 @@ INLINE int FModChangeFrequency(int ch,int ns) if(NP>0x3fff) NP=0x3fff; if(NP<0x1) NP=0x1; - NP=(44100L*NP)/(4096L); // calc frequency - - s_chan[ch].iActFreq=NP; - s_chan[ch].iUsedFreq=NP; - sinc=(((NP/10)<<16)/4410); - if(!sinc) sinc=1; + sinc=NP<<4; // calc frequency if(iUseInterpolation==1) // freq change in simple interpolation mode s_chan[ch].SB[32]=1; iFMod[ns]=0; @@ -512,9 +496,6 @@ static int skip_block(int ch) int flags = start[1]; int ret = 0; - // Tron Bonne hack, probably wrong (could be wrong memory contents..) - if(flags & ~7) flags = 0; - if(start == pSpuIrq) { do_irq(); @@ -750,9 +731,6 @@ static void *MAINThread(void *arg) if(dwNewChannel&(1<<ch)) StartSound(ch); // start new sound if(!(dwChannelOn&(1<<ch))) continue; // channel not playing? next - if(s_chan[ch].iActFreq!=s_chan[ch].iUsedFreq) // new psx frequency? - VoiceChangeFrequency(ch); - if(s_chan[ch].bNoise) d=do_samples_noise(ch, ns_from, ns_to); else if(s_chan[ch].bFMod==2 || (s_chan[ch].bFMod==0 && iUseInterpolation==0)) @@ -791,20 +769,18 @@ static void *MAINThread(void *arg) if(s_chan[ch].pCurr > pSpuIrq && s_chan[ch].pLoop > pSpuIrq) continue; - if(s_chan[ch].iActFreq!=s_chan[ch].iUsedFreq) // new psx frequency? - VoiceChangeFrequency(ch); - s_chan[ch].spos += s_chan[ch].sinc * NSSIZE; while(s_chan[ch].spos >= 28 * 0x10000) { - unsigned char *start=s_chan[ch].pCurr; + unsigned char *start = s_chan[ch].pCurr; // no need for bIRQReturn since the channel is silent iSpuAsyncWait |= skip_block(ch); if(start == s_chan[ch].pCurr) { // looping on self - dwChannelDead|=1<<ch; + dwChannelDead |= 1<<ch; + s_chan[ch].spos = 0; break; } @@ -1045,7 +1021,6 @@ void SetupStreams(void) // s_chan[i].hMutex=CreateMutex(NULL,FALSE,NULL); s_chan[i].ADSRX.SustainLevel = 0xf; // -> init sustain s_chan[i].pLoop=spuMemC; - s_chan[i].pStart=spuMemC; s_chan[i].pCurr=spuMemC; } |