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

This commit is contained in:
Barry Harris 2012-05-21 13:54:13 +00:00
parent 5658ff2f75
commit 121af8c5db
3 changed files with 57 additions and 11 deletions

View File

@ -477,10 +477,12 @@ static INT32 DrvInit()
K053247SetSpriteOffset(-510, 158); K053247SetSpriteOffset(-510, 158);
BurnYM2151Init(4000000); BurnYM2151Init(4000000);
BurnYM2151SetRoute(BURN_SND_YM2151_YM2151_ROUTE_1, 1.00, BURN_SND_ROUTE_LEFT); BurnYM2151SetRoute(BURN_SND_YM2151_YM2151_ROUTE_1, 0.20, BURN_SND_ROUTE_LEFT);
BurnYM2151SetRoute(BURN_SND_YM2151_YM2151_ROUTE_2, 1.00, BURN_SND_ROUTE_RIGHT); BurnYM2151SetRoute(BURN_SND_YM2151_YM2151_ROUTE_2, 0.20, BURN_SND_ROUTE_RIGHT);
K054539Init(0, 48000, DrvSndROM, 0x200000); K054539Init(0, 48000, DrvSndROM, 0x200000);
K054539SetRoute(0, BURN_SND_K054539_ROUTE_1, 1.00, BURN_SND_ROUTE_LEFT);
K054539SetRoute(0, BURN_SND_K054539_ROUTE_2, 1.00, BURN_SND_ROUTE_RIGHT);
GenericTilesInit(); GenericTilesInit();

View File

@ -52,6 +52,9 @@ struct k054539_info {
UINT32 rom_mask; UINT32 rom_mask;
INT32 clock; INT32 clock;
double volume[2];
INT32 output_dir[2];
k054539_channel channels[8]; k054539_channel channels[8];
}; };
@ -266,12 +269,18 @@ static void k054539_init_chip(INT32 clock, UINT8 *rom, INT32 nLen)
info->rom = rom; info->rom = rom;
info->rom_size = nLen; info->rom_size = nLen;
info->rom_mask = 0xffffffffU; info->rom_mask = 0xffffffffU;
for(i=0; i<32; i++) for(i=0; i<32; i++) {
if((1U<<i) >= info->rom_size) { if((1U<<i) >= info->rom_size) {
info->rom_mask = (1U<<i) - 1; info->rom_mask = (1U<<i) - 1;
break; break;
} }
}
info->volume[BURN_SND_K054539_ROUTE_1] = 1.00;
info->volume[BURN_SND_K054539_ROUTE_2] = 1.00;
info->output_dir[BURN_SND_K054539_ROUTE_1] = BURN_SND_ROUTE_BOTH;
info->output_dir[BURN_SND_K054539_ROUTE_2] = BURN_SND_ROUTE_BOTH;
// if(info->intf->irq) // if(info->intf->irq)
// timer_pulse(ATTOTIME_IN_HZ(480), info, 0, k054539_irq); // 10% of usual clock... // timer_pulse(ATTOTIME_IN_HZ(480), info, 0, k054539_irq); // 10% of usual clock...
} }
@ -309,6 +318,20 @@ void K054539Init(INT32 chip, INT32 clock, UINT8 *rom, INT32 nLen)
nNumChips = chip; nNumChips = chip;
} }
void K054539SetRoute(INT32 chip, INT32 nIndex, double nVolume, INT32 nRouteDir)
{
#if defined FBA_DEBUG
if (!DebugSnd_K054539Initted) bprintf(PRINT_ERROR, _T("K054539SetRoute called without init\n"));
if (chip >nNumChips) bprintf(PRINT_ERROR, _T("K054539SetRoute called with invalid chip %x\n"), chip);
if (nIndex < 0 || nIndex > 1) bprintf(PRINT_ERROR, _T("K054539SetRoute called with invalid index %i\n"), nIndex);
#endif
info = &Chips[chip];
info->volume[nIndex] = nVolume;
info->output_dir[nIndex] = nRouteDir;
}
void K054539Exit() void K054539Exit()
{ {
#if defined FBA_DEBUG #if defined FBA_DEBUG
@ -576,14 +599,27 @@ else
} }
for (INT32 f = 0; f < length; f++) { for (INT32 f = 0; f < length; f++) {
if (buffer[0][f] > 32767) buffer[0][f] = 32767; INT32 nLeftSample = 0, nRightSample = 0;
if (buffer[0][f] < -32768) buffer[0][f] = -32768;
if (buffer[1][f] > 32767) buffer[1][f] = 32767; if ((info->output_dir[BURN_SND_K054539_ROUTE_1] & BURN_SND_ROUTE_LEFT) == BURN_SND_ROUTE_LEFT) {
if (buffer[1][f] < -32768) buffer[1][f] = -32768; nLeftSample += (INT32)(buffer[0][f] * info->volume[BURN_SND_K054539_ROUTE_1]);
}
pBuf[0] += buffer[0][f]; if ((info->output_dir[BURN_SND_K054539_ROUTE_1] & BURN_SND_ROUTE_RIGHT) == BURN_SND_ROUTE_RIGHT) {
pBuf[1] += buffer[1][f]; nRightSample += (INT32)(buffer[0][f] * info->volume[BURN_SND_K054539_ROUTE_1]);
}
if ((info->output_dir[BURN_SND_K054539_ROUTE_2] & BURN_SND_ROUTE_LEFT) == BURN_SND_ROUTE_LEFT) {
nLeftSample += (INT32)(buffer[1][f] * info->volume[BURN_SND_K054539_ROUTE_2]);
}
if ((info->output_dir[BURN_SND_K054539_ROUTE_2] & BURN_SND_ROUTE_RIGHT) == BURN_SND_ROUTE_RIGHT) {
nRightSample += (INT32)(buffer[1][f] * info->volume[BURN_SND_K054539_ROUTE_2]);
}
nLeftSample = BURN_SND_CLIP(nLeftSample);
nRightSample = BURN_SND_CLIP(nRightSample);
pBuf[0] += nLeftSample;
pBuf[1] += nRightSample;
pBuf += 2; pBuf += 2;
} }

View File

@ -13,6 +13,14 @@ UINT8 K054539Read(INT32 chip, INT32 offset);
void K054539Reset(INT32 chip); void K054539Reset(INT32 chip);
void K054539Init(INT32 chip, INT32 clock, UINT8 *rom, INT32 nLen); void K054539Init(INT32 chip, INT32 clock, UINT8 *rom, INT32 nLen);
void K054539SetRoute(INT32 chip, INT32 nIndex, double nVolume, INT32 nRouteDir);
void K054539Exit(); void K054539Exit();
INT32 K054539Scan(INT32 nAction); INT32 K054539Scan(INT32 nAction);
#define BURN_SND_K054539_ROUTE_1 0
#define BURN_SND_K054539_ROUTE_2 1
#define K054539PCMSetAllRoutes(i, v, d) \
K054539SetRoute(i, BURN_SND_K054539_ROUTE_1, v, d); \
K054539SetRoute(i, BURN_SND_K054539_ROUTE_2, v, d);