Added support to sn76496.cpp for volume and left/right selection for each route. Updated necessary drivers to support. Fixed some drivers which were initting the wrong chip variant!

This commit is contained in:
Barry Harris 2012-05-22 09:41:38 +00:00
parent 3c061b62d3
commit 1b693b0a2a
16 changed files with 98 additions and 98 deletions

View File

@ -220,12 +220,16 @@ void GalSoundInit()
if (GalSoundType == GAL_SOUND_HARDWARE_TYPE_HEXPOOLASN76496) {
SN76496Init(0, 18432000 / 3 / 2, 0);
SN76496SetRoute(0, 1.00, BURN_SND_ROUTE_BOTH);
}
if (GalSoundType == GAL_SOUND_HARDWARE_TYPE_RACKNROLSN76496) {
SN76496Init(0, 18432000 / 3 / 2, 0);
SN76496Init(1, 18432000 / 3 / 2, 1);
SN76496Init(2, 18432000 / 3 / 2, 1);
SN76496SetRoute(0, 1.00, BURN_SND_ROUTE_BOTH);
SN76496SetRoute(1, 1.00, BURN_SND_ROUTE_BOTH);
SN76496SetRoute(2, 1.00, BURN_SND_ROUTE_BOTH);
}
if (GalSoundType == GAL_SOUND_HARDWARE_TYPE_HUNCHBACKAY8910) {

View File

@ -684,7 +684,8 @@ static INT32 DrvInit()
ZetMemEnd();
ZetClose();
SN76489Init(0, 18432000 / 12, 0);
SN76489AInit(0, 18432000 / 12, 0);
SN76496SetRoute(0, 1.00, BURN_SND_ROUTE_BOTH);
DrvDoReset();

View File

@ -1141,7 +1141,7 @@ static INT32 MegadriveResetDo()
SN76496Exit();
SN76496Init(0, OSC_PAL / 15, 1);
SN76496SetVolShift(0, 1);
SN76496SetRoute(0, 0.25, BURN_SND_ROUTE_BOTH);
} else {
BurnSetRefreshRate(60.0);
Reinitialise();
@ -1156,7 +1156,7 @@ static INT32 MegadriveResetDo()
SN76496Exit();
SN76496Init(0, OSC_NTSC / 15, 1);
SN76496SetVolShift(0, 1);
SN76496SetRoute(0, 0.25, BURN_SND_ROUTE_BOTH);
}
// other reset
@ -2975,7 +2975,7 @@ INT32 MegadriveInit()
BurnYM2612SetRoute(0, BURN_SND_YM2612_YM2612_ROUTE_2, 0.50, BURN_SND_ROUTE_RIGHT);
SN76496Init(0, OSC_NTSC / 15, 1);
SN76496SetVolShift(0, 1);
SN76496SetRoute(0, 0.25, BURN_SND_ROUTE_BOTH);
MegadriveSetupSRAM();
SetupCustomCartridgeMappers();

View File

@ -439,8 +439,8 @@ static INT32 DrvInit()
SN76489Init(0, 3000000, 0);
SN76489Init(1, 3000000, 1);
SN76496SetVolShift(0, 2);
SN76496SetVolShift(1, 2);
SN76496SetRoute(0, 0.36, BURN_SND_ROUTE_BOTH);
SN76496SetRoute(1, 0.36, BURN_SND_ROUTE_BOTH);
GenericTilesInit();

View File

@ -356,10 +356,10 @@ static INT32 DrvInit()
ZetMemEnd();
ZetClose();
SN76489Init(0, 8000000/4, 0);
SN76489Init(1, 8000000/2, 1);
SN76496SetVolShift(0, 2);
SN76496SetVolShift(1, 2);
SN76496Init(0, 8000000/4, 0);
SN76496Init(1, 8000000/2, 1);
SN76496SetRoute(0, 0.75, BURN_SND_ROUTE_BOTH);
SN76496SetRoute(1, 0.75, BURN_SND_ROUTE_BOTH);
GenericTilesInit();

View File

@ -777,8 +777,8 @@ static INT32 DrvInit(INT32 game_select)
SN76489Init(0, 4000000, 0);
SN76489Init(1, 4000000, 1);
SN76496SetVolShift(0, 2);
SN76496SetVolShift(1, 2);
SN76496SetRoute(0, 1.00, BURN_SND_ROUTE_BOTH);
SN76496SetRoute(1, 1.00, BURN_SND_ROUTE_BOTH);
GenericTilesInit();
@ -862,11 +862,11 @@ static INT32 SraiderInit()
SN76489Init(2, 4000000, 1);
SN76489Init(3, 4000000, 1);
SN76489Init(4, 4000000, 1);
SN76496SetVolShift(0, 3);
SN76496SetVolShift(1, 3);
SN76496SetVolShift(2, 3);
SN76496SetVolShift(3, 3);
SN76496SetVolShift(4, 3);
SN76496SetRoute(0, 1.00, BURN_SND_ROUTE_BOTH);
SN76496SetRoute(1, 1.00, BURN_SND_ROUTE_BOTH);
SN76496SetRoute(2, 1.00, BURN_SND_ROUTE_BOTH);
SN76496SetRoute(3, 1.00, BURN_SND_ROUTE_BOTH);
SN76496SetRoute(4, 1.00, BURN_SND_ROUTE_BOTH);
GenericTilesInit();

View File

@ -334,8 +334,10 @@ static INT32 DrvInit()
ZetMemEnd();
ZetClose();
SN76489Init(0, 4000000, 0);
SN76489Init(1, 4000000, 1);
SN76496Init(0, 4000000, 0);
SN76496Init(1, 4000000, 1);
SN76496SetRoute(0, 0.75, BURN_SND_ROUTE_BOTH);
SN76496SetRoute(1, 0.75, BURN_SND_ROUTE_BOTH);
GenericTilesInit();

View File

@ -305,8 +305,8 @@ static INT32 DrvInit()
SN76489Init(0, 4000000, 0);
SN76489Init(1, 4000000, 1);
SN76496SetVolShift(0, 1);
SN76496SetVolShift(1, 1);
SN76496SetRoute(0, 0.50, BURN_SND_ROUTE_BOTH);
SN76496SetRoute(1, 0.50, BURN_SND_ROUTE_BOTH);
DrvDoReset();

View File

@ -369,7 +369,8 @@ static INT32 DrvInit(INT32 game, INT32 swap)
s2650SetInHandler(s2650games_read_port);
s2650Close();
SN76489Init(0, 307200, 0);
SN76496Init(0, 307200, 0);
SN76496SetRoute(0, 0.75, BURN_SND_ROUTE_BOTH);
GenericTilesInit();

View File

@ -2497,6 +2497,8 @@ static INT32 DrvInit(void (*mapCallback)(), void (*pInitCallback)(), INT32 selec
SN76496Init(0, 1789750, 0);
SN76496Init(1, 1789750, 1);
SN76496SetRoute(0, 0.75, BURN_SND_ROUTE_BOTH);
SN76496SetRoute(1, 0.75, BURN_SND_ROUTE_BOTH);
NamcoSoundInit(18432000 / 6 / 32);

View File

@ -348,6 +348,9 @@ static INT32 DrvInit()
SN76489Init(0, 15468000 / 6, 0);
SN76489Init(1, 15468000 / 6, 1);
SN76489Init(2, 15468000 / 6, 1);
SN76496SetRoute(0, 1.00, BURN_SND_ROUTE_BOTH);
SN76496SetRoute(1, 1.00, BURN_SND_ROUTE_BOTH);
SN76496SetRoute(2, 1.00, BURN_SND_ROUTE_BOTH);
DrvDoReset();

View File

@ -430,10 +430,10 @@ static INT32 DrvInit()
ZetMemEnd();
ZetClose();
SN76489Init(0, 4000000, 0);
SN76489Init(1, 2000000, 1);
SN76496SetVolShift(0, 1);
SN76496SetVolShift(1, 1);
SN76496Init(0, 4000000, 0);
SN76496Init(1, 2000000, 1);
SN76496SetRoute(0, 1.00, BURN_SND_ROUTE_BOTH);
SN76496SetRoute(1, 1.00, BURN_SND_ROUTE_BOTH);
GenericTilesInit();

View File

@ -4178,8 +4178,8 @@ static INT32 System1Init(INT32 nZ80Rom1Num, INT32 nZ80Rom1Size, INT32 nZ80Rom2Nu
SN76489AInit(0, 2000000, 0);
SN76489AInit(1, 4000000, 1);
SN76496SetVolShift(0, 2);
SN76496SetVolShift(1, 2);
SN76496SetRoute(0, 0.50, BURN_SND_ROUTE_BOTH);
SN76496SetRoute(1, 0.50, BURN_SND_ROUTE_BOTH);
GenericTilesInit();

View File

@ -586,10 +586,10 @@ static INT32 DrvInit()
use_mcu = ~BurnDrvGetFlags() & BDF_BOOTLEG;
SN76489Init(0, 18432000 / 6, 0);
SN76489Init(1, 18432000 / 6, 1);
SN76496SetVolShift(0, 2);
SN76496SetVolShift(1, 2);
SN76496Init(0, 18432000 / 6, 0);
SN76496Init(1, 18432000 / 6, 1);
SN76496SetRoute(0, 0.80, BURN_SND_ROUTE_BOTH);
SN76496SetRoute(1, 0.80, BURN_SND_ROUTE_BOTH);
GenericTilesInit();

View File

@ -24,7 +24,8 @@ struct SN76496
INT32 Count[4];
INT32 Output[4];
INT32 bSignalAdd;
INT32 nVolShift;
double nVolume;
INT32 nOutputDir;
};
static INT32 NumChips;
@ -42,7 +43,6 @@ void SN76496Update(INT32 Num, INT16* pSoundBuf, INT32 Length)
#endif
INT32 i;
INT32 Temp;
struct SN76496 *R = Chip0;
if (Num >= MAX_SN76496_CHIPS) return;
@ -156,25 +156,23 @@ void SN76496Update(INT32 Num, INT16* pSoundBuf, INT32 Length)
Out /= STEP;
Out >>= R->nVolShift;
INT32 nLeftSample = 0, nRightSample = 0;
if ((R->nOutputDir & BURN_SND_ROUTE_LEFT) == BURN_SND_ROUTE_LEFT) {
nLeftSample += (INT32)(Out * R->nVolume);
}
if ((R->nOutputDir & BURN_SND_ROUTE_RIGHT) == BURN_SND_ROUTE_RIGHT) {
nRightSample += (INT32)(Out * R->nVolume);
}
if (R->bSignalAdd) {
Temp = pSoundBuf[0] + Out;
if (Temp > 32767) Temp = 32767;
if (Temp < -32768) Temp = -32768;
pSoundBuf[0] = Temp;
Temp = pSoundBuf[1] + Out;
if (Temp > 32767) Temp = 32767;
if (Temp < -32768) Temp = -32768;
pSoundBuf[1] = Temp;
pSoundBuf[0] = BURN_SND_CLIP(pSoundBuf[0] + nLeftSample);
pSoundBuf[1] = BURN_SND_CLIP(pSoundBuf[1] + nRightSample);
} else {
pSoundBuf[0] = Out;
pSoundBuf[1] = Out;
pSoundBuf[0] = BURN_SND_CLIP(nLeftSample);
pSoundBuf[1] = BURN_SND_CLIP(nRightSample);
}
pSoundBuf += 2;
Length--;
}
}
@ -304,7 +302,7 @@ static void GenericStart(INT32 Num, INT32 Clock, INT32 FeedbackMask, INT32 Noise
NumChips = Num;
if (Num == 0) {
Chip0 = (struct SN76496*)malloc(sizeof(*Chip0));
Chip0 = (struct SN76496*)BurnMalloc(sizeof(*Chip0));
memset(Chip0, 0, sizeof(*Chip0));
SN76496Init(Chip0, Clock);
@ -314,11 +312,12 @@ static void GenericStart(INT32 Num, INT32 Clock, INT32 FeedbackMask, INT32 Noise
Chip0->WhitenoiseTaps = NoiseTaps;
Chip0->WhitenoiseInvert = NoiseInvert;
Chip0->bSignalAdd = SignalAdd;
Chip0->nVolShift = 0;
Chip0->nVolume = 1.00;
Chip0->nOutputDir = BURN_SND_ROUTE_BOTH;
}
if (Num == 1) {
Chip1 = (struct SN76496*)malloc(sizeof(*Chip1));
Chip1 = (struct SN76496*)BurnMalloc(sizeof(*Chip1));
memset(Chip1, 0, sizeof(*Chip1));
SN76496Init(Chip1, Clock);
@ -328,11 +327,12 @@ static void GenericStart(INT32 Num, INT32 Clock, INT32 FeedbackMask, INT32 Noise
Chip1->WhitenoiseTaps = NoiseTaps;
Chip1->WhitenoiseInvert = NoiseInvert;
Chip1->bSignalAdd = SignalAdd;
Chip1->nVolShift = 0;
Chip1->nVolume = 1.00;
Chip1->nOutputDir = BURN_SND_ROUTE_BOTH;
}
if (Num == 2) {
Chip2 = (struct SN76496*)malloc(sizeof(*Chip2));
Chip2 = (struct SN76496*)BurnMalloc(sizeof(*Chip2));
memset(Chip2, 0, sizeof(*Chip2));
SN76496Init(Chip2, Clock);
@ -342,11 +342,12 @@ static void GenericStart(INT32 Num, INT32 Clock, INT32 FeedbackMask, INT32 Noise
Chip2->WhitenoiseTaps = NoiseTaps;
Chip2->WhitenoiseInvert = NoiseInvert;
Chip2->bSignalAdd = SignalAdd;
Chip2->nVolShift = 0;
Chip2->nVolume = 1.00;
Chip2->nOutputDir = BURN_SND_ROUTE_BOTH;
}
if (Num == 3) {
Chip3 = (struct SN76496*)malloc(sizeof(*Chip3));
Chip3 = (struct SN76496*)BurnMalloc(sizeof(*Chip3));
memset(Chip3, 0, sizeof(*Chip3));
SN76496Init(Chip3, Clock);
@ -356,11 +357,12 @@ static void GenericStart(INT32 Num, INT32 Clock, INT32 FeedbackMask, INT32 Noise
Chip3->WhitenoiseTaps = NoiseTaps;
Chip3->WhitenoiseInvert = NoiseInvert;
Chip3->bSignalAdd = SignalAdd;
Chip3->nVolShift = 0;
Chip3->nVolume = 1.00;
Chip3->nOutputDir = BURN_SND_ROUTE_BOTH;
}
if (Num == 4) {
Chip4 = (struct SN76496*)malloc(sizeof(*Chip4));
Chip4 = (struct SN76496*)BurnMalloc(sizeof(*Chip4));
memset(Chip4, 0, sizeof(*Chip4));
SN76496Init(Chip4, Clock);
@ -370,7 +372,8 @@ static void GenericStart(INT32 Num, INT32 Clock, INT32 FeedbackMask, INT32 Noise
Chip4->WhitenoiseTaps = NoiseTaps;
Chip4->WhitenoiseInvert = NoiseInvert;
Chip4->bSignalAdd = SignalAdd;
Chip4->nVolShift = 0;
Chip4->nVolume = 1.00;
Chip4->nOutputDir = BURN_SND_ROUTE_BOTH;
}
}
@ -394,6 +397,24 @@ void SN76496Init(INT32 Num, INT32 Clock, INT32 SignalAdd)
return GenericStart(Num, Clock, 0x8000, 0x06, 0, SignalAdd);
}
void SN76496SetRoute(INT32 Num, double nVolume, INT32 nRouteDir)
{
#if defined FBA_DEBUG
if (!DebugSnd_SN76496Initted) bprintf(PRINT_ERROR, _T("SN76496SetRoute called without init\n"));
if (Num > NumChips) bprintf(PRINT_ERROR, _T("SN76496SetRoute called with invalid chip %i\n"), Num);
#endif
struct SN76496 *R = Chip0;
if (Num >= MAX_SN76496_CHIPS) return;
if (Num == 1) R = Chip1;
if (Num == 2) R = Chip2;
if (Num == 3) R = Chip3;
if (Num == 4) R = Chip4;
R->nVolume = nVolume;
R->nOutputDir = nRouteDir;
}
void SN76496Exit()
{
#if defined FBA_DEBUG
@ -402,49 +423,15 @@ void SN76496Exit()
NumChips = 0;
if (Chip0!=NULL)
{
free(Chip0);
Chip0 = NULL;
}
if (Chip1!=NULL)
{
free(Chip1);
Chip1 = NULL;
}
if (Chip2!=NULL)
{
free(Chip2);
Chip2 = NULL;
}
if (Chip3!=NULL)
{
free(Chip3);
Chip3 = NULL;
}
if (Chip4!=NULL)
{
free(Chip4);
Chip4 = NULL;
}
BurnFree(Chip0);
BurnFree(Chip1);
BurnFree(Chip2);
BurnFree(Chip3);
BurnFree(Chip4);
DebugSnd_SN76496Initted = 0;
}
void SN76496SetVolShift(INT32 Num, INT32 nVolShift)
{
#if defined FBA_DEBUG
if (!DebugSnd_SN76496Initted) bprintf(PRINT_ERROR, _T("SN76496SetVolShift called without init\n"));
if (Num > NumChips) bprintf(PRINT_ERROR, _T("SN76496SetVolShift called with invalid chip %x\n"), Num);
#endif
if (Num == 0) Chip0->nVolShift = nVolShift;
if (Num == 1) Chip1->nVolShift = nVolShift;
if (Num == 2) Chip2->nVolShift = nVolShift;
if (Num == 3) Chip3->nVolShift = nVolShift;
if (Num == 4) Chip4->nVolShift = nVolShift;
}
INT32 SN76496Scan(INT32 nAction,INT32 *pnMin)
{
#if defined FBA_DEBUG

View File

@ -4,6 +4,6 @@ void SN76489Init(INT32 Num, INT32 Clock, INT32 SignalAdd);
void SN76489AInit(INT32 Num, INT32 Clock, INT32 SignalAdd);
void SN76494Init(INT32 Num, INT32 Clock, INT32 SignalAdd);
void SN76496Init(INT32 Num, INT32 Clock, INT32 SignalAdd);
void SN76496SetRoute(INT32 Num, double nVolume, INT32 nRouteDir);
void SN76496Exit();
void SN76496SetVolShift(INT32 Num, INT32 nVolShift);
INT32 SN76496Scan(INT32 nAction,INT32 *pnMin);