mirror of
https://github.com/RaySollium99/picodrive.git
synced 2025-09-05 07:17:45 -04:00
core, implement GG stereo
This commit is contained in:
parent
fa4e0531d4
commit
70efc52db8
9 changed files with 112 additions and 80 deletions
|
@ -56,7 +56,7 @@ struct SN76496
|
|||
int Period[4];
|
||||
int Count[4];
|
||||
int Output[4];
|
||||
int pad[1];
|
||||
int Panning;
|
||||
};
|
||||
|
||||
static struct SN76496 ono_sn; // one and only SN76496
|
||||
|
@ -135,7 +135,6 @@ void SN76496Update(short *buffer, int length, int stereo)
|
|||
while (length > 0)
|
||||
{
|
||||
int vol[4];
|
||||
unsigned int out;
|
||||
int left;
|
||||
|
||||
|
||||
|
@ -203,19 +202,43 @@ void SN76496Update(short *buffer, int length, int stereo)
|
|||
} while (left > 0 && R->Volume[3]);
|
||||
if (R->Output[3]) vol[3] -= R->Count[3];
|
||||
|
||||
out = vol[0] * R->Volume[0] + vol[1] * R->Volume[1] +
|
||||
length--;
|
||||
if (R->Panning == 0xff || !stereo) {
|
||||
unsigned int out =
|
||||
vol[0] * R->Volume[0] + vol[1] * R->Volume[1] +
|
||||
vol[2] * R->Volume[2] + vol[3] * R->Volume[3];
|
||||
|
||||
if (out > MAX_OUTPUT * STEP) out = MAX_OUTPUT * STEP;
|
||||
if (out > MAX_OUTPUT * STEP) out = MAX_OUTPUT * STEP;
|
||||
|
||||
out /= STEP; // will be optimized to shift; max 0x4800 = 18432
|
||||
*buffer++ += out;
|
||||
if (stereo) *buffer++ += out;
|
||||
out /= STEP; // will be optimized to shift; max 0x4800 = 18432
|
||||
*buffer++ += out;
|
||||
if (stereo) *buffer++ += out;
|
||||
} else {
|
||||
#define P(n) !!(R->Panning & (1<<(n)))
|
||||
unsigned int outl =
|
||||
vol[0] * R->Volume[0] * P(4) + vol[1] * R->Volume[1] * P(5) +
|
||||
vol[2] * R->Volume[2] * P(6) + vol[3] * R->Volume[3] * P(7);
|
||||
unsigned int outr =
|
||||
vol[0] * R->Volume[0] * P(0) + vol[1] * R->Volume[1] * P(1) +
|
||||
vol[2] * R->Volume[2] * P(2) + vol[3] * R->Volume[3] * P(3);
|
||||
#undef P
|
||||
if (outl > MAX_OUTPUT * STEP) outl = MAX_OUTPUT * STEP;
|
||||
if (outr > MAX_OUTPUT * STEP) outr = MAX_OUTPUT * STEP;
|
||||
|
||||
length--;
|
||||
outl /= STEP; // will be optimized to shift; max 0x4800 = 18432
|
||||
outr /= STEP; // will be optimized to shift; max 0x4800 = 18432
|
||||
*buffer++ += outl;
|
||||
*buffer++ += outr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SN76496Config(int panning)
|
||||
{
|
||||
struct SN76496 *R = &ono_sn;
|
||||
R->Panning = panning & 0xff;
|
||||
}
|
||||
|
||||
|
||||
static void SN76496_set_clock(struct SN76496 *R,int clock)
|
||||
{
|
||||
|
@ -286,6 +309,7 @@ int SN76496_init(int clock,int sample_rate)
|
|||
|
||||
// added
|
||||
SN76496_set_gain(R, 0);
|
||||
R->Panning = 0xff;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue