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

This commit is contained in:
Barry Harris 2012-05-22 15:34:24 +00:00
parent fc7a55b5c1
commit c63f55c3d0
3 changed files with 45 additions and 3 deletions

View File

@ -519,6 +519,8 @@ static INT32 CommonInit(int type)
vce_palette_init(DrvPalette);
c6280_init(3579545, 0);
c6280_set_route(BURN_SND_C6280_ROUTE_1, 1.00, BURN_SND_ROUTE_LEFT);
c6280_set_route(BURN_SND_C6280_ROUTE_2, 1.00, BURN_SND_ROUTE_RIGHT);
GenericTilesInit();

View File

@ -57,6 +57,7 @@
#include "burnint.h"
#include "h6280_intf.h"
#include "c6280.h"
#include "math.h"
typedef struct {
@ -81,6 +82,8 @@ typedef struct {
UINT32 noise_freq_tab[32];
UINT32 wave_freq_tab[4096];
INT32 bAdd;
double gain[2];
INT32 output_dir[2];
} c6280_t;
static INT16 *stream_buffer = NULL;
@ -152,6 +155,10 @@ void c6280_init(double clk, INT32 bAdd)
p->volume_table[31] = 0;
p->bAdd = bAdd;
p->gain[BURN_SND_C6280_ROUTE_1] = 1.00;
p->gain[BURN_SND_C6280_ROUTE_2] = 1.00;
p->output_dir[BURN_SND_C6280_ROUTE_1] = BURN_SND_ROUTE_LEFT;
p->output_dir[BURN_SND_C6280_ROUTE_2] = BURN_SND_ROUTE_RIGHT;
stream_buffer = (INT16*)BurnMalloc(nBurnSoundLen * 2 * sizeof(INT16));
@ -163,6 +170,14 @@ void c6280_init(double clk, INT32 bAdd)
}
}
void c6280_set_route(INT32 nIndex, double nVolume, INT32 nRouteDir)
{
c6280_t *p = &chip[0];
p->gain[nIndex] = nVolume;
p->output_dir[nIndex] = nRouteDir;
}
void c6280_exit()
{
if (stream_buffer) {
@ -367,11 +382,28 @@ void c6280_update(INT16 *pBuffer, INT32 samples)
c6280_stream_update();
if (!p->bAdd) {
memset (pBuffer, 0, samples * sizeof(short) * 2); // 16-bit * 2 channels
memset (pBuffer, 0, samples * sizeof(INT16) * 2); // 16-bit * 2 channels
}
for (INT32 i = 0; i < samples*2; i++) {
pBuffer[i] += stream_buffer[i];
for (INT32 i = 0; i < samples; i++) {
INT32 nLeftSample = 0, nRightSample = 0;
if ((p->output_dir[BURN_SND_C6280_ROUTE_1] & BURN_SND_ROUTE_LEFT) == BURN_SND_ROUTE_LEFT) {
nLeftSample += (INT32)(stream_buffer[(i << 1) + 0] * p->gain[BURN_SND_C6280_ROUTE_1]);
}
if ((p->output_dir[BURN_SND_C6280_ROUTE_1] & BURN_SND_ROUTE_RIGHT) == BURN_SND_ROUTE_RIGHT) {
nRightSample += (INT32)(stream_buffer[(i << 1) + 0] * p->gain[BURN_SND_C6280_ROUTE_1]);
}
if ((p->output_dir[BURN_SND_C6280_ROUTE_2] & BURN_SND_ROUTE_LEFT) == BURN_SND_ROUTE_LEFT) {
nLeftSample += (INT32)(stream_buffer[(i << 1) + 1] * p->gain[BURN_SND_C6280_ROUTE_2]);
}
if ((p->output_dir[BURN_SND_C6280_ROUTE_2] & BURN_SND_ROUTE_RIGHT) == BURN_SND_ROUTE_RIGHT) {
nRightSample += (INT32)(stream_buffer[(i << 1) + 1] * p->gain[BURN_SND_C6280_ROUTE_2]);
}
pBuffer[(i << 1) + 0] = BURN_SND_CLIP(nLeftSample);
pBuffer[(i << 1) + 1] = BURN_SND_CLIP(nRightSample);
}
}

View File

@ -1,5 +1,6 @@
void c6280_init(double clk, INT32 bAdd);
void c6280_set_route(INT32 nIndex, double nVolume, INT32 nRouteDir);
void c6280_exit();
void c6280_reset();
@ -10,3 +11,10 @@ void c6280_write(UINT8 offset, UINT8 data);
UINT8 c6280_read();
INT32 c6280_scan(INT32 nAction, INT32 *pnMin);
#define BURN_SND_C6280_ROUTE_1 0
#define BURN_SND_C6280_ROUTE_2 1
#define c6280_set_all_routes(v, d) \
c6280_set_route(BURN_SND_C6280_ROUTE_1, v, d); \
c6280_set_route(BURN_SND_C6280_ROUTE_2, v, d);