mirror of
https://github.com/RetroDECK/Supermodel.git
synced 2024-11-22 13:55:38 +00:00
add undefd codepath for correct use of the 18bit DAC path (which seems to be triggered for all games)
the volume correction to bring the data back into a valid range is not really needed in practice though, only Daytona2 seems to need it, and also only extremely rarely, so lets just live with a tiny bit of clamping for that game then while add it, make some formatting similar to MAME, and add one comment regarding a most likely wrong recent MAME change
This commit is contained in:
parent
153c510009
commit
db455ba5c1
|
@ -142,30 +142,6 @@ void SetAudioType(Game::AudioTypes type)
|
||||||
AudioType = type;
|
AudioType = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
static INT16 AddAndClampINT16(INT32 x, INT32 y)
|
|
||||||
{
|
|
||||||
INT32 sum = x + y;
|
|
||||||
if (sum > INT16_MAX) {
|
|
||||||
sum = INT16_MAX;
|
|
||||||
}
|
|
||||||
if (sum < INT16_MIN) {
|
|
||||||
sum = INT16_MIN;
|
|
||||||
}
|
|
||||||
return (INT16)sum;
|
|
||||||
}
|
|
||||||
|
|
||||||
static INT16 MixINT16(INT32 x, INT32 y)
|
|
||||||
{
|
|
||||||
INT32 sum = (x + y)>>1;
|
|
||||||
if (sum > INT16_MAX) {
|
|
||||||
sum = INT16_MAX;
|
|
||||||
}
|
|
||||||
if (sum < INT16_MIN) {
|
|
||||||
sum = INT16_MIN;
|
|
||||||
}
|
|
||||||
return (INT16)sum;
|
|
||||||
}
|
|
||||||
|
|
||||||
static INT16 MixINT16(float x, float y)
|
static INT16 MixINT16(float x, float y)
|
||||||
{
|
{
|
||||||
INT32 sum = (INT32)((x + y)*0.5f); //!! dither
|
INT32 sum = (INT32)((x + y)*0.5f); //!! dither
|
||||||
|
@ -185,7 +161,7 @@ static float MixFloat(float x, float y)
|
||||||
|
|
||||||
static INT16 ClampINT16(float x)
|
static INT16 ClampINT16(float x)
|
||||||
{
|
{
|
||||||
INT32 xi = (INT32)x;
|
INT32 xi = (INT32)x; //!! dither
|
||||||
if (xi > INT16_MAX) {
|
if (xi > INT16_MAX) {
|
||||||
xi = INT16_MAX;
|
xi = INT16_MAX;
|
||||||
}
|
}
|
||||||
|
|
|
@ -132,5 +132,3 @@ void MpegDec::DecodeAudio(int16_t* left, int16_t* right, int numStereoSamples)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -85,6 +85,7 @@ bool legacySound; // For LegacySound (SCSP DSP) config option.
|
||||||
|
|
||||||
#define MAX_SCSP 2
|
#define MAX_SCSP 2
|
||||||
|
|
||||||
|
//#define CORRECT_FOR_18BIT_DAC
|
||||||
|
|
||||||
// These globals control the operation of the SCSP, they are no longer extern and are set through SCSP_SetBuffers(). --Bart
|
// These globals control the operation of the SCSP, they are no longer extern and are set through SCSP_SetBuffers(). --Bart
|
||||||
static double SoundClock; // Originally titled SysFPS; seems to be for the sound CPU.
|
static double SoundClock; // Originally titled SysFPS; seems to be for the sound CPU.
|
||||||
|
@ -228,11 +229,11 @@ static int TimCnt[3];
|
||||||
int ARTABLE[64],DRTABLE[64];
|
int ARTABLE[64],DRTABLE[64];
|
||||||
|
|
||||||
//Envelope times in ms
|
//Envelope times in ms
|
||||||
double ARTimes[64]={100000/*infinity*/,100000/*infinity*/,8100.0,6900.0,6000.0,4800.0,4000.0,3400.0,3000.0,2400.0,2000.0,1700.0,1500.0,
|
static const double ARTimes[64] = {100000/*infinity*/,100000/*infinity*/,8100.0,6900.0,6000.0,4800.0,4000.0,3400.0,3000.0,2400.0,2000.0,1700.0,1500.0,
|
||||||
1200.0,1000.0,860.0,760.0,600.0,500.0,430.0,380.0,300.0,250.0,220.0,190.0,150.0,130.0,110.0,95.0,
|
1200.0,1000.0,860.0,760.0,600.0,500.0,430.0,380.0,300.0,250.0,220.0,190.0,150.0,130.0,110.0,95.0,
|
||||||
76.0,63.0,55.0,47.0,38.0,31.0,27.0,24.0,19.0,15.0,13.0,12.0,9.4,7.9,6.8,6.0,4.7,3.8,3.4,3.0,2.4,
|
76.0,63.0,55.0,47.0,38.0,31.0,27.0,24.0,19.0,15.0,13.0,12.0,9.4,7.9,6.8,6.0,4.7,3.8,3.4,3.0,2.4,
|
||||||
2.0,1.8,1.6,1.3,1.1,0.93,0.85,0.65,0.53,0.44,0.40,0.35,0.0,0.0};
|
2.0,1.8,1.6,1.3,1.1,0.93,0.85,0.65,0.53,0.44,0.40,0.35,0.0,0.0};
|
||||||
double DRTimes[64]={100000/*infinity*/,100000/*infinity*/,118200.0,101300.0,88600.0,70900.0,59100.0,50700.0,44300.0,35500.0,29600.0,25300.0,22200.0,17700.0,
|
static const double DRTimes[64] = {100000/*infinity*/,100000/*infinity*/,118200.0,101300.0,88600.0,70900.0,59100.0,50700.0,44300.0,35500.0,29600.0,25300.0,22200.0,17700.0,
|
||||||
14800.0,12700.0,11100.0,8900.0,7400.0,6300.0,5500.0,4400.0,3700.0,3200.0,2800.0,2200.0,1800.0,1600.0,1400.0,1100.0,
|
14800.0,12700.0,11100.0,8900.0,7400.0,6300.0,5500.0,4400.0,3700.0,3200.0,2800.0,2200.0,1800.0,1600.0,1400.0,1100.0,
|
||||||
920.0,790.0,690.0,550.0,460.0,390.0,340.0,270.0,230.0,200.0,170.0,140.0,110.0,98.0,85.0,68.0,57.0,49.0,43.0,34.0,
|
920.0,790.0,690.0,550.0,460.0,390.0,340.0,270.0,230.0,200.0,170.0,140.0,110.0,98.0,85.0,68.0,57.0,49.0,43.0,34.0,
|
||||||
28.0,25.0,22.0,18.0,14.0,12.0,11.0,8.5,7.1,6.1,5.4,4.3,3.6,3.1};
|
28.0,25.0,22.0,18.0,14.0,12.0,11.0,8.5,7.1,6.1,5.4,4.3,3.6,3.1};
|
||||||
|
@ -719,10 +720,10 @@ bool SCSP_Init(const Util::Config::Node &config, int n)
|
||||||
else
|
else
|
||||||
SDL=0.0;
|
SDL=0.0;
|
||||||
|
|
||||||
if(iSDL==0x6)
|
//if(iSDL==0x6)
|
||||||
int a=1;
|
// int a=1;
|
||||||
if(iTL==0x3a)
|
//if(iTL==0x3a)
|
||||||
int a=1;
|
// int a=1;
|
||||||
|
|
||||||
LPANTABLE[i]=FIX((4.0*LPAN*TL*SDL));
|
LPANTABLE[i]=FIX((4.0*LPAN*TL*SDL));
|
||||||
RPANTABLE[i]=FIX((4.0*RPAN*TL*SDL));
|
RPANTABLE[i]=FIX((4.0*RPAN*TL*SDL));
|
||||||
|
@ -1373,24 +1374,22 @@ signed int inline SCSP_UpdateSlot(_SLOT *slot)
|
||||||
//if (SSCTL(slot) == 0) {
|
//if (SSCTL(slot) == 0) {
|
||||||
if (PCM8B(slot)) //8 bit signed
|
if (PCM8B(slot)) //8 bit signed
|
||||||
{
|
{
|
||||||
signed char *p1 = (signed char *) &(slot->base[addr1 ^ 1]);
|
signed char p1 = *(signed char *) &(slot->base[addr1 ^ 1]);
|
||||||
signed char *p2 = (signed char *) &(slot->base[addr2 ^ 1]);
|
signed char p2 = *(signed char *) &(slot->base[addr2 ^ 1]);
|
||||||
int s;
|
int s;
|
||||||
signed int fpart = slot->cur_addr&((1 << SHIFT) - 1);
|
signed int fpart = slot->cur_addr&((1 << SHIFT) - 1);
|
||||||
//sample=(p[0])<<8;
|
//sample=(p[0])<<8;
|
||||||
s = (int)(p1[0] << 8)*((1 << SHIFT) - fpart) + (int)(p2[0] << 8)*fpart;
|
s = (int)(p1 << 8)*((1 << SHIFT) - fpart) + (int)(p2 << 8)*fpart;
|
||||||
sample = (s >> SHIFT);
|
sample = (s >> SHIFT);
|
||||||
}
|
}
|
||||||
else //16 bit signed (endianness?)
|
else //16 bit signed (endianness?)
|
||||||
{
|
{
|
||||||
signed short *p1 = (signed short *) &(slot->base[addr1]);
|
signed short p1 = *(signed short *) &(slot->base[addr1]);
|
||||||
signed short *p2 = (signed short *) &(slot->base[addr2]);
|
signed short p2 = *(signed short *) &(slot->base[addr2]);
|
||||||
int s;
|
int s;
|
||||||
signed int fpart = slot->cur_addr&((1 << SHIFT) - 1);
|
signed int fpart = slot->cur_addr&((1 << SHIFT) - 1);
|
||||||
//sample=(p[0]);
|
//sample=(p[0]);
|
||||||
s = (int)(p1[0])*((1 << (SHIFT)) - fpart) + (int)(p2[0])*fpart;
|
s = (int)(p1)*((1 << (SHIFT)) - fpart) + (int)(p2)*fpart;
|
||||||
|
|
||||||
|
|
||||||
sample = (s >> (SHIFT));
|
sample = (s >> (SHIFT));
|
||||||
|
|
||||||
//sample=((p[0]>>8)&0xFF)|(p[0]<<8);
|
//sample=((p[0]>>8)&0xFF)|(p[0]<<8);
|
||||||
|
@ -1498,6 +1497,11 @@ signed int inline SCSP_UpdateSlot(_SLOT *slot)
|
||||||
UINT16 Enc = ((TL(slot)) << 0x0) | (0x7 << 0xd);
|
UINT16 Enc = ((TL(slot)) << 0x0) | (0x7 << 0xd);
|
||||||
*RBUFDST = (sample * LPANTABLE[Enc]) >> (SHIFT + 1);
|
*RBUFDST = (sample * LPANTABLE[Enc]) >> (SHIFT + 1);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
UINT16 Enc = (0 << 0x0) | (0x7 << 0xd);
|
||||||
|
*RBUFDST = (sample * LPANTABLE[Enc]) >> (SHIFT + 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1667,14 +1671,23 @@ void SCSP_DoMasterSamples(int nsamples)
|
||||||
{
|
{
|
||||||
smpfl = ICLIP18(smpfl);
|
smpfl = ICLIP18(smpfl);
|
||||||
smpfr = ICLIP18(smpfr);
|
smpfr = ICLIP18(smpfr);
|
||||||
|
|
||||||
|
#ifdef CORRECT_FOR_18BIT_DAC
|
||||||
|
*buffl++ = (float)smpfl * 0.25f;
|
||||||
|
*buffr++ = (float)smpfr * 0.25f;
|
||||||
|
#else
|
||||||
|
*buffl++ = (float)smpfl;
|
||||||
|
*buffr++ = (float)smpfr;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
smpfl = ICLIP16(smpfl >> 2);
|
smpfl = ICLIP16(smpfl >> 2);
|
||||||
smpfr = ICLIP16(smpfr >> 2);
|
smpfr = ICLIP16(smpfr >> 2);
|
||||||
|
|
||||||
|
*buffl++ = (float)smpfl;
|
||||||
|
*buffr++ = (float)smpfr;
|
||||||
}
|
}
|
||||||
*buffl++ = (float)smpfl;
|
|
||||||
*buffr++ = (float)smpfr;
|
|
||||||
|
|
||||||
if (HasSlaveSCSP)
|
if (HasSlaveSCSP)
|
||||||
{
|
{
|
||||||
|
@ -1682,15 +1695,29 @@ void SCSP_DoMasterSamples(int nsamples)
|
||||||
{
|
{
|
||||||
smprl = ICLIP18(smprl);
|
smprl = ICLIP18(smprl);
|
||||||
smprr = ICLIP18(smprr);
|
smprr = ICLIP18(smprr);
|
||||||
|
|
||||||
|
#ifdef CORRECT_FOR_18BIT_DAC
|
||||||
|
*bufrl++ = (float)smprl * 0.25f;
|
||||||
|
*bufrr++ = (float)smprr * 0.25f;
|
||||||
|
#else
|
||||||
|
*bufrl++ = (float)smprl;
|
||||||
|
*bufrr++ = (float)smprr;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
smprl = ICLIP16(smprl >> 2);
|
smprl = ICLIP16(smprl >> 2);
|
||||||
smprr = ICLIP16(smprr >> 2);
|
smprr = ICLIP16(smprr >> 2);
|
||||||
|
|
||||||
|
*bufrl++ = (float)smprl;
|
||||||
|
*bufrr++ = (float)smprr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*bufrl++ = (float)smprl;
|
else
|
||||||
*bufrr++ = (float)smprr;
|
{
|
||||||
|
*bufrl++ = (float)smprl;
|
||||||
|
*bufrr++ = (float)smprr;
|
||||||
|
}
|
||||||
|
|
||||||
SCSP_TimersAddTicks(1);
|
SCSP_TimersAddTicks(1);
|
||||||
CheckPendingIRQ();
|
CheckPendingIRQ();
|
||||||
|
|
|
@ -150,13 +150,10 @@ unsigned char UnpackFunc[]={0x8B,0xD8,0x8B,0xC8,0x81,0xE3,0x00,0x80,0x00,0x00,0x
|
||||||
|
|
||||||
static UINT16 PACK(INT32 val)
|
static UINT16 PACK(INT32 val)
|
||||||
{
|
{
|
||||||
UINT32 temp;
|
int sign = (val >> 23) & 0x1;
|
||||||
int sign, exponent, k;
|
UINT32 temp = (val ^ (val << 1)) & 0xFFFFFF;
|
||||||
|
int exponent = 0;
|
||||||
sign = (val >> 23) & 0x1;
|
for (int k = 0; k < 12; k++)
|
||||||
temp = (val ^ (val << 1)) & 0xFFFFFF;
|
|
||||||
exponent = 0;
|
|
||||||
for (k = 0; k < 12; k++)
|
|
||||||
{
|
{
|
||||||
if (temp & 0x800000)
|
if (temp & 0x800000)
|
||||||
break;
|
break;
|
||||||
|
@ -177,13 +174,10 @@ static UINT16 PACK(INT32 val)
|
||||||
|
|
||||||
static INT32 UNPACK(UINT16 val)
|
static INT32 UNPACK(UINT16 val)
|
||||||
{
|
{
|
||||||
int sign, exponent, mantissa;
|
int sign = (val >> 15) & 0x1;
|
||||||
INT32 uval;
|
int exponent = (val >> 11) & 0xF;
|
||||||
|
int mantissa = val & 0x7FF;
|
||||||
sign = (val >> 15) & 0x1;
|
INT32 uval = mantissa << 11;
|
||||||
exponent = (val >> 11) & 0xF;
|
|
||||||
mantissa = val & 0x7FF;
|
|
||||||
uval = mantissa << 11;
|
|
||||||
if (exponent > 11)
|
if (exponent > 11)
|
||||||
{
|
{
|
||||||
exponent = 11;
|
exponent = 11;
|
||||||
|
@ -417,7 +411,7 @@ void SCSPDSP_Step(_SCSPDSP *DSP)
|
||||||
//ADDR+=DSP->RBP<<13;
|
//ADDR+=DSP->RBP<<13;
|
||||||
//MEMVAL=DSP->SCSPRAM[ADDR>>1];
|
//MEMVAL=DSP->SCSPRAM[ADDR>>1];
|
||||||
ADDR += DSP->RBP << 12;
|
ADDR += DSP->RBP << 12;
|
||||||
if (ADDR > 0x7ffff) ADDR = 0;
|
if (ADDR > 0x7ffff) ADDR = 0; //!! MAME has ADDR <<= 1 in here, but this seems to be wrong?
|
||||||
if (MRD && (step & 1)) //memory only allowed on odd? DoA inserts NOPs on even
|
if (MRD && (step & 1)) //memory only allowed on odd? DoA inserts NOPs on even
|
||||||
{
|
{
|
||||||
if (NOFL)
|
if (NOFL)
|
||||||
|
|
|
@ -49,10 +49,13 @@ struct _LFO
|
||||||
|
|
||||||
static int PLFO_TRI[256], PLFO_SQR[256], PLFO_SAW[256], PLFO_NOI[256];
|
static int PLFO_TRI[256], PLFO_SQR[256], PLFO_SAW[256], PLFO_NOI[256];
|
||||||
static int ALFO_TRI[256], ALFO_SQR[256], ALFO_SAW[256], ALFO_NOI[256];
|
static int ALFO_TRI[256], ALFO_SQR[256], ALFO_SAW[256], ALFO_NOI[256];
|
||||||
static float LFOFreq[32] = { 0.17f, 0.19f, 0.23f, 0.27f, 0.34f, 0.39f, 0.45f, 0.55f, 0.68f, 0.78f, 0.92f, 1.10f, 1.39f, 1.60f, 1.87f, 2.27f,
|
static const float LFOFreq[32] =
|
||||||
2.87f, 3.31f, 3.92f, 4.79f, 6.15f, 7.18f, 8.60f, 10.8f, 14.4f, 17.2f, 21.5f, 28.7f, 43.1f, 57.4f, 86.1f, 172.3f };
|
{
|
||||||
static float ASCALE[8] = { 0.0f, 0.4f, 0.8f, 1.5f, 3.0f, 6.0f, 12.0f, 24.0f };
|
0.17f,0.19f,0.23f,0.27f,0.34f,0.39f,0.45f,0.55f,0.68f,0.78f,0.92f,1.10f,1.39f,1.60f,1.87f,2.27f,
|
||||||
static float PSCALE[8] = { 0.0f, 7.0f, 13.5f, 27.0f, 55.0f, 112.0f, 230.0f, 494.0f };
|
2.87f,3.31f,3.92f,4.79f,6.15f,7.18f,8.60f,10.8f,14.4f,17.2f,21.5f,28.7f,43.1f,57.4f,86.1f,172.3f
|
||||||
|
};
|
||||||
|
static const float ASCALE[8] = {0.0f,0.4f,0.8f,1.5f,3.0f,6.0f,12.0f,24.0f};
|
||||||
|
static const float PSCALE[8] = {0.0f,7.0f,13.5f,27.0f,55.0f,112.0f,230.0f,494.0f};
|
||||||
static int PSCALES[8][256];
|
static int PSCALES[8][256];
|
||||||
static int ASCALES[8][256];
|
static int ASCALES[8][256];
|
||||||
|
|
||||||
|
@ -151,7 +154,7 @@ signed int inline ALFO_Step(struct _LFO *LFO)
|
||||||
|
|
||||||
void LFO_ComputeStep(struct _LFO *LFO, UINT32 LFOF, UINT32 LFOWS, UINT32 LFOS, int ALFO)
|
void LFO_ComputeStep(struct _LFO *LFO, UINT32 LFOF, UINT32 LFOWS, UINT32 LFOS, int ALFO)
|
||||||
{
|
{
|
||||||
float step = (float)LFOFreq[LFOF] * 256.0f / (float)44100.0f;
|
float step = (float)LFOFreq[LFOF] * 256.0f / 44100.0f;
|
||||||
LFO->phase_step = (unsigned int)((float)(1 << LFO_SHIFT)*step);
|
LFO->phase_step = (unsigned int)((float)(1 << LFO_SHIFT)*step);
|
||||||
if (ALFO)
|
if (ALFO)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue