From 861ae5156f0f83b7bbc83fce0c4225cf51bb9164 Mon Sep 17 00:00:00 2001 From: dinkc64 <12570148+dinkc64@users.noreply.github.com> Date: Sat, 8 Aug 2015 00:37:03 +0000 Subject: [PATCH] pokey update: eliminate clipping & add volume attenuation. also make centipede & millipede the same volume --- src/burn/drv/pre90s/d_atetris.cpp | 2 +- src/burn/drv/pre90s/d_millipede.cpp | 4 ++-- src/burn/snd/pokey.cpp | 16 +++++++++++----- src/burn/snd/pokey.h | 2 +- 4 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/burn/drv/pre90s/d_atetris.cpp b/src/burn/drv/pre90s/d_atetris.cpp index cbdbc7082..4a9bb0a83 100644 --- a/src/burn/drv/pre90s/d_atetris.cpp +++ b/src/burn/drv/pre90s/d_atetris.cpp @@ -327,7 +327,7 @@ static INT32 CommonInit(INT32 boot) SN76496SetRoute(1, 0.50, BURN_SND_ROUTE_BOTH); SN76496SetRoute(2, 0.50, BURN_SND_ROUTE_BOTH); } else { - PokeyInit(0, 2, 6, 0); + PokeyInit(0, 2, 1.00, 0); } GenericTilesInit(); diff --git a/src/burn/drv/pre90s/d_millipede.cpp b/src/burn/drv/pre90s/d_millipede.cpp index d0e1100fd..490548044 100644 --- a/src/burn/drv/pre90s/d_millipede.cpp +++ b/src/burn/drv/pre90s/d_millipede.cpp @@ -726,7 +726,7 @@ static INT32 DrvInit() M6502SetReadOpHandler(millipede_read); M6502Close(); - PokeyInit(12096000/8, 2, 6, 0); + PokeyInit(12096000/8, 2, 1.00, 0); init_penmask(); @@ -777,7 +777,7 @@ static INT32 DrvInitcentiped() M6502SetReadOpHandler(centipede_read); M6502Close(); - PokeyInit(12096000/8, 2, 6, 0); + PokeyInit(12096000/8, 2, 2.40, 0); init_penmask(); diff --git a/src/burn/snd/pokey.cpp b/src/burn/snd/pokey.cpp index 3a844ae07..e98239dc7 100644 --- a/src/burn/snd/pokey.cpp +++ b/src/burn/snd/pokey.cpp @@ -56,6 +56,8 @@ * I use 15/11 = 1.3636, so this is a little lower. */ #define POKEY_DEFAULT_GAIN (32767/11/4) +static double pokey_mastervol = 1.0; +static INT32 nLeftSample = 0, nRightSample = 0; #define VERBOSE 0 #define VERBOSE_SOUND 0 @@ -326,9 +328,12 @@ static UINT8 *rand17; pokey[chip].samplepos_fract &= 0x000000ff; \ } \ /* store sum of output signals into the buffer */ \ - *buffer++ += (sum > 65535) ? 0x7fff : sum - 0x8000; \ - *buffer++ += (sum > 65535) ? 0x7fff : sum - 0x8000; \ - length-- + nLeftSample = buffer[0] + (sum * pokey_mastervol); \ + nRightSample = buffer[1] + (sum * pokey_mastervol); \ + buffer[0] = BURN_SND_CLIP(nLeftSample); \ + buffer[1] = BURN_SND_CLIP(nRightSample); \ + buffer++; buffer++; \ + length--; #if HEAVY_MACRO_USAGE @@ -570,14 +575,15 @@ static void rand_init(UINT8 *rng, int size, int left, int right, int add) } } -int PokeyInit(int clock, int num, int vol, int addtostream) +int PokeyInit(int clock, int num, double vol, int addtostream) { int chip, sample_rate; memset(&intf, 0, sizeof(intf)); sample_rate = nBurnSoundRate; intf.num = num; - intf.mixing_level[0] = vol; + //intf.mixing_level[0] = vol; + pokey_mastervol = vol; intf.baseclock = (clock) ? clock : FREQ_17_EXACT; intf.addtostream = addtostream; diff --git a/src/burn/snd/pokey.h b/src/burn/snd/pokey.h index 1edaa6783..e1ed4a998 100644 --- a/src/burn/snd/pokey.h +++ b/src/burn/snd/pokey.h @@ -98,7 +98,7 @@ struct POKEYinterface { }; -int PokeyInit (int clock, int num, int vol, int addtostream); +int PokeyInit (int clock, int num, double vol, int addtostream); void PokeyExit (void); void pokey_update(int num, INT16 *buffer, int length);