Added support to segapcm.cpp for volume and left/right selection for each route. Updated necessary drivers to support.
This commit is contained in:
parent
f5b4c558ff
commit
5423fb03af
|
@ -2099,6 +2099,8 @@ INT32 System16Init()
|
|||
} else {
|
||||
SegaPCMInit(4000000, BANK_512, System16PCMData, System16PCMDataSize);
|
||||
}
|
||||
SegaPCMSetRoute(BURN_SND_SEGAPCM_ROUTE_1, 1.0, BURN_SND_ROUTE_LEFT);
|
||||
SegaPCMSetRoute(BURN_SND_SEGAPCM_ROUTE_2, 1.0, BURN_SND_ROUTE_RIGHT);
|
||||
}
|
||||
|
||||
System16TileBankSize = 0x1000;
|
||||
|
@ -2168,6 +2170,8 @@ INT32 System16Init()
|
|||
|
||||
if (System16PCMDataSize) {
|
||||
SegaPCMInit(4000000, BANK_512, System16PCMData, System16PCMDataSize);
|
||||
SegaPCMSetRoute(BURN_SND_SEGAPCM_ROUTE_1, 1.0, BURN_SND_ROUTE_LEFT);
|
||||
SegaPCMSetRoute(BURN_SND_SEGAPCM_ROUTE_2, 1.0, BURN_SND_ROUTE_RIGHT);
|
||||
}
|
||||
|
||||
System16RoadColorOffset1 = 0x400;
|
||||
|
@ -2260,6 +2264,8 @@ INT32 System16Init()
|
|||
|
||||
if (System16PCMDataSize) {
|
||||
SegaPCMInit(4000000, BANK_512, System16PCMData, System16PCMDataSize);
|
||||
SegaPCMSetRoute(BURN_SND_SEGAPCM_ROUTE_1, 1.0, BURN_SND_ROUTE_LEFT);
|
||||
SegaPCMSetRoute(BURN_SND_SEGAPCM_ROUTE_2, 1.0, BURN_SND_ROUTE_RIGHT);
|
||||
}
|
||||
|
||||
System16RoadColorOffset1 = 0x1700;
|
||||
|
@ -2341,6 +2347,8 @@ INT32 System16Init()
|
|||
|
||||
if (System16PCMDataSize) {
|
||||
SegaPCMInit(32215900 / 8, BANK_12M | BANK_MASKF8, System16PCMData, System16PCMDataSize);
|
||||
SegaPCMSetRoute(BURN_SND_SEGAPCM_ROUTE_1, 1.0, BURN_SND_ROUTE_LEFT);
|
||||
SegaPCMSetRoute(BURN_SND_SEGAPCM_ROUTE_2, 1.0, BURN_SND_ROUTE_RIGHT);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -10,6 +10,8 @@ struct segapcm
|
|||
INT32 bankshift;
|
||||
INT32 bankmask;
|
||||
INT32 UpdateStep;
|
||||
double Volume[2];
|
||||
INT32 OutputDir[2];
|
||||
};
|
||||
|
||||
static struct segapcm *Chip = NULL;
|
||||
|
@ -62,14 +64,28 @@ void SegaPCMUpdate(INT16* pSoundBuf, INT32 nLength)
|
|||
}
|
||||
|
||||
for (INT32 i = 0; i < nLength; i++) {
|
||||
if (Left[i] > 32767) Left[i] = 32767;
|
||||
if (Left[i] < -32768) Left[i] = -32768;
|
||||
INT32 nLeftSample = 0;
|
||||
INT32 nRightSample = 0;
|
||||
|
||||
if (Right[i] > 32767) Right[i] = 32767;
|
||||
if (Right[i] < -32768) Right[i] = -32768;
|
||||
if ((Chip->OutputDir[BURN_SND_SEGAPCM_ROUTE_1] & BURN_SND_ROUTE_LEFT) == BURN_SND_ROUTE_LEFT) {
|
||||
nLeftSample += (INT32)(Left[i] * Chip->Volume[BURN_SND_SEGAPCM_ROUTE_1]);
|
||||
}
|
||||
if ((Chip->OutputDir[BURN_SND_SEGAPCM_ROUTE_1] & BURN_SND_ROUTE_RIGHT) == BURN_SND_ROUTE_RIGHT) {
|
||||
nRightSample += (INT32)(Left[i] * Chip->Volume[BURN_SND_SEGAPCM_ROUTE_1]);
|
||||
}
|
||||
|
||||
pSoundBuf[0] += Left[i];
|
||||
pSoundBuf[1] += Right[i];
|
||||
if ((Chip->OutputDir[BURN_SND_SEGAPCM_ROUTE_2] & BURN_SND_ROUTE_LEFT) == BURN_SND_ROUTE_LEFT) {
|
||||
nLeftSample += (INT32)(Right[i] * Chip->Volume[BURN_SND_SEGAPCM_ROUTE_2]);
|
||||
}
|
||||
if ((Chip->OutputDir[BURN_SND_SEGAPCM_ROUTE_2] & BURN_SND_ROUTE_RIGHT) == BURN_SND_ROUTE_RIGHT) {
|
||||
nRightSample += (INT32)(Right[i] * Chip->Volume[BURN_SND_SEGAPCM_ROUTE_2]);
|
||||
}
|
||||
|
||||
nLeftSample = BURN_SND_CLIP(nLeftSample);
|
||||
nRightSample = BURN_SND_CLIP(nRightSample);
|
||||
|
||||
pSoundBuf[0] += nLeftSample;
|
||||
pSoundBuf[1] += nRightSample;
|
||||
pSoundBuf += 2;
|
||||
}
|
||||
}
|
||||
|
@ -102,9 +118,25 @@ void SegaPCMInit(INT32 clock, INT32 bank, UINT8 *pPCMData, INT32 PCMDataSize)
|
|||
double Rate = (double)clock / 128 / nBurnSoundRate;
|
||||
Chip->UpdateStep = (INT32)(Rate * 0x10000);
|
||||
|
||||
Chip->Volume[BURN_SND_SEGAPCM_ROUTE_1] = 1.00;
|
||||
Chip->Volume[BURN_SND_SEGAPCM_ROUTE_2] = 1.00;
|
||||
Chip->OutputDir[BURN_SND_SEGAPCM_ROUTE_1] = BURN_SND_ROUTE_LEFT;
|
||||
Chip->OutputDir[BURN_SND_SEGAPCM_ROUTE_2] = BURN_SND_ROUTE_RIGHT;
|
||||
|
||||
DebugSnd_SegaPCMInitted = 1;
|
||||
}
|
||||
|
||||
void SegaPCMSetRoute(INT32 nIndex, double nVolume, INT32 nRouteDir)
|
||||
{
|
||||
#if defined FBA_DEBUG
|
||||
if (!DebugSnd_SegaPCMInitted) bprintf(PRINT_ERROR, _T("SegaPCMSetRoute called without init\n"));
|
||||
if (nIndex < 0 || nIndex > 1) bprintf(PRINT_ERROR, _T("SegaPCMSetRoute called with invalid index %i\n"), nIndex);
|
||||
#endif
|
||||
|
||||
Chip->Volume[nIndex] = nVolume;
|
||||
Chip->OutputDir[nIndex] = nRouteDir;
|
||||
}
|
||||
|
||||
void SegaPCMExit()
|
||||
{
|
||||
#if defined FBA_DEBUG
|
||||
|
|
|
@ -7,7 +7,15 @@
|
|||
|
||||
void SegaPCMUpdate(INT16* pSoundBuf, INT32 nLength);
|
||||
void SegaPCMInit(INT32 clock, INT32 bank, UINT8 *pPCMData, INT32 PCMDataSize);
|
||||
void SegaPCMSetRoute(INT32 nIndex, double nVolume, INT32 nRouteDir);
|
||||
void SegaPCMExit();
|
||||
INT32 SegaPCMScan(INT32 nAction,INT32 *pnMin);
|
||||
UINT8 SegaPCMRead(UINT32 Offset);
|
||||
void SegaPCMWrite(UINT32 Offset, UINT8 Data);
|
||||
|
||||
#define BURN_SND_SEGAPCM_ROUTE_1 0
|
||||
#define BURN_SND_SEGAPCM_ROUTE_2 1
|
||||
|
||||
#define SegaPCMSetAllRoutes(i, v, d) \
|
||||
SegaPCMSetRoute(i, BURN_SND_SEGAPCM_ROUTE_1, v, d); \
|
||||
SegaPCMSetRoute(i, BURN_SND_SEGAPCM_ROUTE_2, v, d);
|
||||
|
|
Loading…
Reference in New Issue