From 9151c056c5b04195c936a4a3a18aafdd0770f5fa Mon Sep 17 00:00:00 2001 From: Barry Harris <44396066+barry65536@users.noreply.github.com> Date: Wed, 23 May 2012 12:19:48 +0000 Subject: [PATCH] Added support to x1010.cpp for volume and left/right selection for each route. Updated necessary drivers to support. --- src/burn/drv/pst90s/d_seta.cpp | 14 ++++++- src/burn/drv/pst90s/d_seta2.cpp | 16 ++++++++ src/burn/snd/x1010.cpp | 66 +++++++++++++++++++++++++++++++-- src/burn/snd/x1010.h | 10 +++++ 4 files changed, 100 insertions(+), 6 deletions(-) diff --git a/src/burn/drv/pst90s/d_seta.cpp b/src/burn/drv/pst90s/d_seta.cpp index 073fd9371..af6e0e250 100644 --- a/src/burn/drv/pst90s/d_seta.cpp +++ b/src/burn/drv/pst90s/d_seta.cpp @@ -6740,6 +6740,8 @@ static INT32 DrvInit(void (*p68kInit)(), INT32 cpu_speed, INT32 irq_type, INT32 buffer_sprites = spr_buffer; x1010_sound_init(16000000, 0x0000); + x1010_set_route(BURN_SND_X1010_ROUTE_1, 1.00, BURN_SND_ROUTE_LEFT); + x1010_set_route(BURN_SND_X1010_ROUTE_2, 1.00, BURN_SND_ROUTE_RIGHT); BurnYM3812Init(4000000, NULL, DrvYM3812SynchroniseStream, 0); BurnTimerAttachSekYM3812(16000000); @@ -9305,7 +9307,11 @@ static INT32 downtownInit() DrvSetVideoOffsets(0, 0, -1, 0); DrvSetColorOffsets(0, 0, 0); - return DrvInit(downtown68kInit, 8000000, SET_IRQLINES(1, 2), NO_SPRITE_BUFFER, SET_GFX_DECODE(0, 1, -1)); + INT32 nRet = DrvInit(downtown68kInit, 8000000, SET_IRQLINES(1, 2), NO_SPRITE_BUFFER, SET_GFX_DECODE(0, 1, -1)); + + x1010_set_all_routes(0.50, BURN_SND_ROUTE_LEFT); + + return nRet; } struct BurnDriver BurnDrvDowntown = { @@ -9772,7 +9778,11 @@ static INT32 calibr50Init() DrvSetColorOffsets(0, 0, 0); DrvSetVideoOffsets(-1, 2, -3, -2); - return DrvInit(calibr5068kInit, 8000000, SET_IRQLINES(0x80, 0x80) /*custom*/, NO_SPRITE_BUFFER, SET_GFX_DECODE(0, 1, -1)); + INT32 nRet = DrvInit(calibr5068kInit, 8000000, SET_IRQLINES(0x80, 0x80) /*custom*/, NO_SPRITE_BUFFER, SET_GFX_DECODE(0, 1, -1)); + + x1010_set_all_routes(0.50, BURN_SND_ROUTE_LEFT); + + return nRet; } struct BurnDriver BurnDrvCalibr50 = { diff --git a/src/burn/drv/pst90s/d_seta2.cpp b/src/burn/drv/pst90s/d_seta2.cpp index 7d5131415..0d2a1d9b8 100644 --- a/src/burn/drv/pst90s/d_seta2.cpp +++ b/src/burn/drv/pst90s/d_seta2.cpp @@ -1642,6 +1642,8 @@ static INT32 grdiansInit() gfx_code_mask = 0x0800000 * 4 / 64; x1010_sound_init(50000000 / 3, 0x0000); + x1010_set_route(BURN_SND_X1010_ROUTE_1, 1.00, BURN_SND_ROUTE_LEFT); + x1010_set_route(BURN_SND_X1010_ROUTE_2, 1.00, BURN_SND_ROUTE_RIGHT); DrvDoReset(); @@ -1803,6 +1805,8 @@ static INT32 mj4simaiInit() gfx_code_mask = 0x0800000 * 4 / 64; x1010_sound_init(50000000 / 3, 0x0000); + x1010_set_route(BURN_SND_X1010_ROUTE_1, 1.00, BURN_SND_ROUTE_LEFT); + x1010_set_route(BURN_SND_X1010_ROUTE_2, 1.00, BURN_SND_ROUTE_RIGHT); // bMahjong = 1; @@ -1953,6 +1957,8 @@ static INT32 myangelInit() gfx_code_mask = 0x0400000 * 4 / 64; x1010_sound_init(50000000 / 3, 0x0000); + x1010_set_route(BURN_SND_X1010_ROUTE_1, 1.00, BURN_SND_ROUTE_LEFT); + x1010_set_route(BURN_SND_X1010_ROUTE_2, 1.00, BURN_SND_ROUTE_RIGHT); DrvDoReset(); @@ -2101,6 +2107,8 @@ static INT32 myangel2Init() gfx_code_mask = 0x0600000 * 4 / 64; x1010_sound_init(50000000 / 3, 0x0000); + x1010_set_route(BURN_SND_X1010_ROUTE_1, 1.00, BURN_SND_ROUTE_LEFT); + x1010_set_route(BURN_SND_X1010_ROUTE_2, 1.00, BURN_SND_ROUTE_RIGHT); DrvDoReset(); @@ -2257,6 +2265,8 @@ static INT32 pzlbowlInit() gfx_code_mask = 0x0400000 * 4 / 64; x1010_sound_init(50000000 / 3, 0x0000); + x1010_set_route(BURN_SND_X1010_ROUTE_1, 1.00, BURN_SND_ROUTE_LEFT); + x1010_set_route(BURN_SND_X1010_ROUTE_2, 1.00, BURN_SND_ROUTE_RIGHT); DrvDoReset(); @@ -2406,6 +2416,8 @@ static INT32 penbrosInit() gfx_code_mask = 0x0400000 * 4 / 64; x1010_sound_init(50000000 / 3, 0x0000); + x1010_set_route(BURN_SND_X1010_ROUTE_1, 1.00, BURN_SND_ROUTE_LEFT); + x1010_set_route(BURN_SND_X1010_ROUTE_2, 1.00, BURN_SND_ROUTE_RIGHT); DrvDoReset(); @@ -2571,6 +2583,8 @@ static INT32 gundamexInit() gfx_code_mask = 0x0800000 * 4 / 64; x1010_sound_init(50000000 / 3, 0x0000); + x1010_set_route(BURN_SND_X1010_ROUTE_1, 1.00, BURN_SND_ROUTE_LEFT); + x1010_set_route(BURN_SND_X1010_ROUTE_2, 1.00, BURN_SND_ROUTE_RIGHT); EEPROMInit(&eeprom_interface_93C46); @@ -2703,6 +2717,8 @@ static INT32 samshootInit() gfx_code_mask = 0x0800000 * 4 / 64; x1010_sound_init(50000000 / 3, 0x0000); + x1010_set_route(BURN_SND_X1010_ROUTE_1, 1.00, BURN_SND_ROUTE_LEFT); + x1010_set_route(BURN_SND_X1010_ROUTE_2, 1.00, BURN_SND_ROUTE_RIGHT); BurnGunInit(2, true); diff --git a/src/burn/snd/x1010.cpp b/src/burn/snd/x1010.cpp index 9c59c43eb..1a94978fb 100644 --- a/src/burn/snd/x1010.cpp +++ b/src/burn/snd/x1010.cpp @@ -95,8 +95,29 @@ void x1010_sound_update() break; } data = *(start + delta); - *bufL += (data * volL / 256); bufL += 2; - *bufR += (data * volR / 256); bufR += 2; + + INT32 nLeftSample = 0, nRightSample = 0; + + if ((x1_010_chip->output_dir[BURN_SND_X1010_ROUTE_1] & BURN_SND_ROUTE_LEFT) == BURN_SND_ROUTE_LEFT) { + nLeftSample += (INT32)((data * volL / 256) * x1_010_chip->gain[BURN_SND_X1010_ROUTE_1]); + } + if ((x1_010_chip->output_dir[BURN_SND_X1010_ROUTE_1] & BURN_SND_ROUTE_RIGHT) == BURN_SND_ROUTE_RIGHT) { + nRightSample += (INT32)((data * volL / 256) * x1_010_chip->gain[BURN_SND_X1010_ROUTE_1]); + } + + if ((x1_010_chip->output_dir[BURN_SND_X1010_ROUTE_2] & BURN_SND_ROUTE_LEFT) == BURN_SND_ROUTE_LEFT) { + nLeftSample += (INT32)((data * volR / 256) * x1_010_chip->gain[BURN_SND_X1010_ROUTE_2]); + } + if ((x1_010_chip->output_dir[BURN_SND_X1010_ROUTE_2] & BURN_SND_ROUTE_RIGHT) == BURN_SND_ROUTE_RIGHT) { + nRightSample += (INT32)((data * volR / 256) * x1_010_chip->gain[BURN_SND_X1010_ROUTE_2]); + } + + nLeftSample = BURN_SND_CLIP(nLeftSample); + nRightSample = BURN_SND_CLIP(nRightSample); + + *bufL += nLeftSample; bufL += 2;; + *bufR += nRightSample; bufR += 2; + smp_offs += smp_step; } x1_010_chip->smp_offset[ch] = smp_offs; @@ -131,8 +152,29 @@ void x1010_sound_update() volL = ((vol >> 4) & 0xf) * VOL_BASE; volR = ((vol >> 0) & 0xf) * VOL_BASE; data = *(start + ((smp_offs >> FREQ_BASE_BITS) & 0x7f)); - *bufL += (data * volL / 256); bufL += 2; - *bufR += (data * volR / 256); bufR += 2; + + INT32 nLeftSample = 0, nRightSample = 0; + + if ((x1_010_chip->output_dir[BURN_SND_X1010_ROUTE_1] & BURN_SND_ROUTE_LEFT) == BURN_SND_ROUTE_LEFT) { + nLeftSample += (INT32)((data * volL / 256) * x1_010_chip->gain[BURN_SND_X1010_ROUTE_1]); + } + if ((x1_010_chip->output_dir[BURN_SND_X1010_ROUTE_1] & BURN_SND_ROUTE_RIGHT) == BURN_SND_ROUTE_RIGHT) { + nRightSample += (INT32)((data * volL / 256) * x1_010_chip->gain[BURN_SND_X1010_ROUTE_1]); + } + + if ((x1_010_chip->output_dir[BURN_SND_X1010_ROUTE_2] & BURN_SND_ROUTE_LEFT) == BURN_SND_ROUTE_LEFT) { + nLeftSample += (INT32)((data * volR / 256) * x1_010_chip->gain[BURN_SND_X1010_ROUTE_2]); + } + if ((x1_010_chip->output_dir[BURN_SND_X1010_ROUTE_2] & BURN_SND_ROUTE_RIGHT) == BURN_SND_ROUTE_RIGHT) { + nRightSample += (INT32)((data * volR / 256) * x1_010_chip->gain[BURN_SND_X1010_ROUTE_2]); + } + + nLeftSample = BURN_SND_CLIP(nLeftSample); + nRightSample = BURN_SND_CLIP(nRightSample); + + *bufL += nLeftSample; bufL += 2;; + *bufR += nRightSample; bufR += 2; + smp_offs += smp_step; env_offs += env_step; } @@ -152,6 +194,22 @@ void x1010_sound_init(UINT32 base_clock, INT32 address) x1_010_chip->base_clock = base_clock; x1_010_chip->rate = x1_010_chip->base_clock / 1024; x1_010_chip->address = address; + + x1_010_chip->gain[BURN_SND_X1010_ROUTE_1] = 1.00; + x1_010_chip->gain[BURN_SND_X1010_ROUTE_2] = 1.00; + x1_010_chip->output_dir[BURN_SND_X1010_ROUTE_1] = BURN_SND_ROUTE_BOTH; + x1_010_chip->output_dir[BURN_SND_X1010_ROUTE_2] = BURN_SND_ROUTE_BOTH; +} + +void x1010_set_route(INT32 nIndex, double nVolume, INT32 nRouteDir) +{ +#if defined FBA_DEBUG + if (!DebugSnd_X1010Initted) bprintf(PRINT_ERROR, _T("x1010_set_route called without init\n")); + if (nIndex < 0 || nIndex > 1) bprintf(PRINT_ERROR, _T("x1010_set_route called with invalid index %i\n"), nIndex); +#endif + + x1_010_chip->gain[nIndex] = nVolume; + x1_010_chip->output_dir[nIndex] = nRouteDir; } void x1010_scan(INT32 nAction,INT32 *pnMin) diff --git a/src/burn/snd/x1010.h b/src/burn/snd/x1010.h index 805c55558..f001d8528 100644 --- a/src/burn/snd/x1010.h +++ b/src/burn/snd/x1010.h @@ -17,6 +17,8 @@ struct x1_010_info UINT32 env_offset[SETA_NUM_CHANNELS]; UINT32 base_clock; UINT32 sound_banks[SETA_NUM_BANKS]; + double gain[2]; + INT32 output_dir[2]; }; typedef struct { @@ -38,5 +40,13 @@ UINT8 x1010_sound_read(UINT32 offset); UINT16 x1010_sound_read_word(UINT32 offset); void x1010_sound_update(); void x1010_sound_init(UINT32 base_clock, INT32 address); +void x1010_set_route(INT32 nIndex, double nVolume, INT32 nRouteDir); void x1010_scan(INT32 nAction,INT32 *pnMin); void x1010_exit(); + +#define BURN_SND_X1010_ROUTE_1 0 +#define BURN_SND_X1010_ROUTE_2 1 + +#define x1010_set_all_routes(v, d) \ + x1010_set_route(BURN_SND_X1010_ROUTE_1, v, d); \ + x1010_set_route(BURN_SND_X1010_ROUTE_2, v, d);