From 4a88f486775592cf5655256be8b758beeb9e0776 Mon Sep 17 00:00:00 2001 From: Barry Harris <44396066+barry65536@users.noreply.github.com> Date: Wed, 23 May 2012 08:49:07 +0000 Subject: [PATCH] Added support to itemga20.cpp for volume and left/right selection for each route. Updated necessary drivers to support. --- src/burn/drv/irem/d_m92.cpp | 1 + src/burn/snd/iremga20.cpp | 35 +++++++++++++++++++++++++++++++++-- src/burn/snd/iremga20.h | 1 + 3 files changed, 35 insertions(+), 2 deletions(-) diff --git a/src/burn/drv/irem/d_m92.cpp b/src/burn/drv/irem/d_m92.cpp index 841d47635..dedf7fead 100644 --- a/src/burn/drv/irem/d_m92.cpp +++ b/src/burn/drv/irem/d_m92.cpp @@ -1752,6 +1752,7 @@ static INT32 DrvInit(INT32 (*pRomLoadCallback)(), const UINT8 *sound_decrypt_tab BurnYM2151SetAllRoutes(0.40, BURN_SND_ROUTE_BOTH); iremga20_init(0, DrvSndROM, 0x100000, 3579545); + itemga20_set_route(0, 1.00, BURN_SND_ROUTE_BOTH); MSM6295Init(0, 1000000 / 132, 0); // ppan MSM6295SetRoute(0, 1.00, BURN_SND_ROUTE_BOTH); diff --git a/src/burn/snd/iremga20.cpp b/src/burn/snd/iremga20.cpp index 649e7db89..3a1860b20 100644 --- a/src/burn/snd/iremga20.cpp +++ b/src/burn/snd/iremga20.cpp @@ -54,6 +54,8 @@ struct _ga20_state UINT16 regs[0x40]; struct IremGA20_channel_def channel[4]; INT32 frequency; + double gain; + INT32 output_dir; }; static struct _ga20_state chips[MAX_GA20]; @@ -130,8 +132,21 @@ void iremga20_update(INT32 device, INT16 *buffer, INT32 length) } sampleout >>= 2; - buffer[0] += sampleout; - buffer[1] += sampleout; + + INT32 nLeftSample = 0, nRightSample = 0; + + if ((chip->output_dir & BURN_SND_ROUTE_LEFT) == BURN_SND_ROUTE_LEFT) { + nLeftSample += (INT32)(sampleout * chip->gain); + } + if ((chip->output_dir & BURN_SND_ROUTE_RIGHT) == BURN_SND_ROUTE_RIGHT) { + nRightSample += (INT32)(sampleout * chip->gain); + } + + nLeftSample = BURN_SND_CLIP(nLeftSample); + nRightSample = BURN_SND_CLIP(nRightSample); + + buffer[0] += nLeftSample; + buffer[1] += nRightSample; } /* update the regs now */ @@ -247,6 +262,9 @@ void iremga20_init(INT32 device, UINT8 *rom, INT32 rom_size, INT32 frequency) chip->rom = rom; chip->rom_size = rom_size; chip->frequency = (frequency / 4) / 60; + + chip->gain = 1.00; + chip->output_dir = BURN_SND_ROUTE_BOTH; iremga20_reset(device); @@ -255,6 +273,19 @@ void iremga20_init(INT32 device, UINT8 *rom, INT32 rom_size, INT32 frequency) nNumChips = device; } +void itemga20_set_route(INT32 device, double nVolume, INT32 nRouteDir) +{ +#if defined FBA_DEBUG + if (!DebugSnd_IremGA20Initted) bprintf(PRINT_ERROR, _T("itemga20_set_route called without init\n")); + if (device > nNumChips) bprintf(PRINT_ERROR, _T("itemga20_set_route called with invalid chip %x\n"), device); +#endif + + chip = &chips[device]; + + chip->gain = nVolume; + chip->output_dir = nRouteDir; +} + void iremga20_exit() { #if defined FBA_DEBUG diff --git a/src/burn/snd/iremga20.h b/src/burn/snd/iremga20.h index 118bda7e0..0d45885d8 100644 --- a/src/burn/snd/iremga20.h +++ b/src/burn/snd/iremga20.h @@ -3,6 +3,7 @@ UINT8 iremga20_read(INT32 device, INT32 offset); void iremga20_reset(INT32 device); void iremga20_init(INT32 device, UINT8 *rom, INT32 rom_size, INT32 frequency); +void itemga20_set_route(INT32 device, double nVolume, INT32 nRouteDir); void iremga20_update(INT32 device, INT16 *buffer, INT32 length); void iremga20_exit();