Added support to upd7759.cpp for volume and left/right selection for each route. Updated necessary drivers to support.

This commit is contained in:
Barry Harris 2012-05-20 06:44:34 +00:00
parent 4422be322a
commit f5b4c558ff
10 changed files with 53 additions and 12 deletions

View File

@ -482,6 +482,8 @@ static INT32 DrvInit()
UPD7759Init(0, UPD7759_STANDARD_CLOCK, DrvSndROM0);
UPD7759Init(1, UPD7759_STANDARD_CLOCK, DrvSndROM1);
UPD7759SetRoute(0, 0.30, BURN_SND_ROUTE_BOTH);
UPD7759SetRoute(1, 0.30, BURN_SND_ROUTE_BOTH);
K052109Init(DrvGfxROM0, 0x7ffff);
K052109SetCallback(K052109Callback);

View File

@ -762,6 +762,7 @@ static INT32 DrvInit(INT32 type)
BurnYM2151SetAllRoutes(0.30, BURN_SND_ROUTE_BOTH);
UPD7759Init(0, UPD7759_STANDARD_CLOCK, DrvSndROM1);
UPD7759SetRoute(0, 0.50, BURN_SND_ROUTE_BOTH);
GenericTilesInit();

View File

@ -4408,6 +4408,7 @@ static INT32 TmntInit()
K007232SetPortWriteHandler(0, DrvK007232VolCallback);
UPD7759Init(0, UPD7759_STANDARD_CLOCK, DrvUPD7759CRom);
UPD7759SetRoute(0, 0.60, BURN_SND_ROUTE_BOTH);
GenericTilesInit();

View File

@ -1026,6 +1026,7 @@ static INT32 DrvInit(INT32 (pLoadCallback)())
BurnYM2151SetRoute(BURN_SND_YM2151_YM2151_ROUTE_2, 1.00, BURN_SND_ROUTE_RIGHT);
UPD7759Init(0, UPD7759_STANDARD_CLOCK, DrvSndROM1);
UPD7759SetRoute(0, 0.20, BURN_SND_ROUTE_BOTH);
GenericTilesInit();

View File

@ -550,6 +550,7 @@ INT32 PrehisleInit()
BurnYM3812SetRoute(BURN_SND_YM3812_ROUTE, 1.00, BURN_SND_ROUTE_BOTH);
UPD7759Init(0, UPD7759_STANDARD_CLOCK, PrehisleADPCMSamples);
UPD7759SetRoute(0, 0.90, BURN_SND_ROUTE_BOTH);
GenericTilesInit();

View File

@ -577,6 +577,7 @@ static INT32 DrvInit(INT32 (*pRomLoadCallback)(), INT32 game)
BurnYM2151SetAllRoutes(0.50, BURN_SND_ROUTE_BOTH);
UPD7759Init(0, UPD7759_STANDARD_CLOCK, DrvSndROM);
UPD7759SetRoute(0, 0.50, BURN_SND_ROUTE_BOTH);
DrvDoReset();

View File

@ -958,6 +958,7 @@ static INT32 DrvInit(INT32 game)
BurnYM3812SetRoute(BURN_SND_YM3812_ROUTE, 1.00, BURN_SND_ROUTE_BOTH);
UPD7759Init(0, UPD7759_STANDARD_CLOCK, DrvSnd0);
UPD7759SetRoute(0, 0.50, BURN_SND_ROUTE_BOTH);
DrvDoReset();

View File

@ -1925,6 +1925,7 @@ INT32 System16Init()
if (System16UPD7759DataSize) {
UPD7759Init(0,UPD7759_STANDARD_CLOCK, NULL);
UPD7759SetDrqCallback(0,System16UPD7759DrqCallback);
UPD7759SetRoute(0, 0.48, BURN_SND_ROUTE_BOTH);
}
System16TileBankSize = 0x1000;

View File

@ -63,6 +63,10 @@ struct upd7759_chip
UINT8 * rom; /* pointer to ROM data or NULL for slave mode */
UINT8 * rombase; /* pointer to ROM data or NULL for slave mode */
UINT32 romoffset; /* ROM offset to make save/restore easier */
/* route */
double volume;
INT32 output_dir;
};
static struct upd7759_chip *Chips[2]; // more?
@ -328,8 +332,21 @@ void UPD7759Update(INT32 chip, INT16 *pSoundBuf, INT32 nLength)
while (nLength != 0)
{
/* store the current sample */
pSoundBuf[0] += Sample << 7;
pSoundBuf[1] += Sample << 7;
INT32 nLeftSample = 0;
INT32 nRightSample = 0;
if ((Chip->output_dir & BURN_SND_ROUTE_LEFT) == BURN_SND_ROUTE_LEFT) {
nLeftSample += (INT32)((Sample << 7) * Chip->volume);
}
if ((Chip->output_dir & BURN_SND_ROUTE_RIGHT) == BURN_SND_ROUTE_RIGHT) {
nRightSample += (INT32)((Sample << 7) * Chip->volume);
}
nLeftSample = BURN_SND_CLIP(nLeftSample);
nRightSample = BURN_SND_CLIP(nRightSample);
pSoundBuf[0] += nLeftSample;
pSoundBuf[1] += nRightSample;
pSoundBuf += 2;
nLength--;
@ -425,12 +442,26 @@ void UPD7759Init(INT32 chip, INT32 clock, UINT8* pSoundData)
Chip->reset = 1;
Chip->start = 1;
Chip->volume = 1.00;
Chip->output_dir = BURN_SND_ROUTE_BOTH;
nNumChips = chip;
UPD7759Reset();
}
void UPD7759SetRoute(INT32 chip, double nVolume, INT32 nRouteDir)
{
#if defined FBA_DEBUG
if (!DebugSnd_UPD7759Initted) bprintf(PRINT_ERROR, _T("UPD7759SetRoute called without init\n"));
if (chip > nNumChips) bprintf(PRINT_ERROR, _T("UPD7759SetRoute called with invalid chip %i\n"), chip);
#endif
Chip = Chips[chip];
Chip->volume = nVolume;
Chip->output_dir = nRouteDir;
}
void UPD7759SetDrqCallback(INT32 chip, drqcallback Callback)
{
#if defined FBA_DEBUG

View File

@ -2,13 +2,14 @@
typedef void (*drqcallback)(INT32 param);
extern void UPD7759Update(INT32 chip, INT16 *pSoundBuf, INT32 nLength);
extern void UPD7759Reset();
extern void UPD7759Init(INT32 chip, INT32 clock, UINT8* pSoundData);
extern void UPD7759SetDrqCallback(INT32 chip, drqcallback Callback);
extern INT32 UPD7759BusyRead(INT32 chip);
extern void UPD7759ResetWrite(INT32 chip, UINT8 Data);
extern void UPD7759StartWrite(INT32 chip, UINT8 Data);
extern void UPD7759PortWrite(INT32 chip, UINT8 Data);
extern INT32 UPD7759Scan(INT32 chip, INT32 nAction,INT32 *pnMin);
extern void UPD7759Exit();
void UPD7759Update(INT32 chip, INT16 *pSoundBuf, INT32 nLength);
void UPD7759Reset();
void UPD7759Init(INT32 chip, INT32 clock, UINT8* pSoundData);
void UPD7759SetRoute(INT32 chip, double nVolume, INT32 nRouteDir);
void UPD7759SetDrqCallback(INT32 chip, drqcallback Callback);
INT32 UPD7759BusyRead(INT32 chip);
void UPD7759ResetWrite(INT32 chip, UINT8 Data);
void UPD7759StartWrite(INT32 chip, UINT8 Data);
void UPD7759PortWrite(INT32 chip, UINT8 Data);
INT32 UPD7759Scan(INT32 chip, INT32 nAction,INT32 *pnMin);
void UPD7759Exit();