SMS: implement Game Gear stereo in Nuked core
This commit is contained in:
parent
fef09fb00d
commit
b04743d045
|
@ -245,6 +245,11 @@ void YMPSG_Write(ympsg_t *chip, uint8_t data)
|
||||||
chip->write_flag = 1;
|
chip->write_flag = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void YMPSG_WriteStereo(ympsg_t *chip, uint8_t data)
|
||||||
|
{
|
||||||
|
chip->stereo = data;
|
||||||
|
}
|
||||||
|
|
||||||
uint16_t YMPSG_Read(ympsg_t *chip)
|
uint16_t YMPSG_Read(ympsg_t *chip)
|
||||||
{
|
{
|
||||||
uint16_t data = 0;
|
uint16_t data = 0;
|
||||||
|
@ -265,6 +270,7 @@ void YMPSG_Init(ympsg_t *chip, uint8_t real_sn, uint8_t noise_tap1, uint8_t nois
|
||||||
chip->noise_tap1 = noise_tap1;
|
chip->noise_tap1 = noise_tap1;
|
||||||
chip->noise_tap2 = noise_tap2;
|
chip->noise_tap2 = noise_tap2;
|
||||||
chip->noise_size = noise_size;
|
chip->noise_size = noise_size;
|
||||||
|
chip->stereo = 0xff;
|
||||||
for (i = 0; i < 17; i++)
|
for (i = 0; i < 17; i++)
|
||||||
{
|
{
|
||||||
chip->vol_table[i]=(real_sn?tipsg_vol[i]:ympsg_vol[i]) * 8192.0f;
|
chip->vol_table[i]=(real_sn?tipsg_vol[i]:ympsg_vol[i]) * 8192.0f;
|
||||||
|
@ -316,32 +322,62 @@ void YMPSG_Clock(ympsg_t *chip)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int YMPSG_GetOutput(ympsg_t *chip)
|
void YMPSG_GetOutput(ympsg_t *chip, int* left, int* right)
|
||||||
{
|
{
|
||||||
int sample = 0;
|
int sample_left = 0;
|
||||||
|
int sample_right = 0;
|
||||||
uint32_t i;
|
uint32_t i;
|
||||||
YMPSG_UpdateSample(chip);
|
YMPSG_UpdateSample(chip);
|
||||||
if (chip->test & 1)
|
if (chip->test & 1)
|
||||||
{
|
{
|
||||||
sample += chip->vol_table[chip->volume_out[chip->test >> 1]];
|
sample_left += chip->vol_table[chip->volume_out[chip->test >> 1]];
|
||||||
sample += chip->vol_table[16] * 3;
|
sample_left += chip->vol_table[16] * 3;
|
||||||
|
sample_right += chip->vol_table[chip->volume_out[chip->test >> 1]];
|
||||||
|
sample_right += chip->vol_table[16] * 3;
|
||||||
}
|
}
|
||||||
else if (!chip->mute)
|
else if (!chip->mute)
|
||||||
{
|
{
|
||||||
sample += chip->vol_table[chip->volume_out[0]];
|
if (chip->stereo&(0x10)) {
|
||||||
sample += chip->vol_table[chip->volume_out[1]];
|
sample_left += chip->vol_table[chip->volume_out[0]];
|
||||||
sample += chip->vol_table[chip->volume_out[2]];
|
}
|
||||||
sample += chip->vol_table[chip->volume_out[3]];
|
if (chip->stereo&(0x01)) {
|
||||||
|
sample_right += chip->vol_table[chip->volume_out[0]];
|
||||||
|
}
|
||||||
|
if (chip->stereo&(0x20)) {
|
||||||
|
sample_left += chip->vol_table[chip->volume_out[1]];
|
||||||
|
}
|
||||||
|
if (chip->stereo&(0x02)) {
|
||||||
|
sample_right += chip->vol_table[chip->volume_out[1]];
|
||||||
|
}
|
||||||
|
if (chip->stereo&(0x40)) {
|
||||||
|
sample_left += chip->vol_table[chip->volume_out[2]];
|
||||||
|
}
|
||||||
|
if (chip->stereo&(0x04)) {
|
||||||
|
sample_right += chip->vol_table[chip->volume_out[2]];
|
||||||
|
}
|
||||||
|
if (chip->stereo&(0x80)) {
|
||||||
|
sample_left += chip->vol_table[chip->volume_out[3]];
|
||||||
|
}
|
||||||
|
if (chip->stereo&(0x08)) {
|
||||||
|
sample_right += chip->vol_table[chip->volume_out[3]];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (i = 0; i < 4; i++)
|
for (i = 0; i < 4; i++)
|
||||||
{
|
{
|
||||||
if (!((chip->mute>>i) & 1))
|
if (!((chip->mute>>i) & 1)) {
|
||||||
sample += chip->vol_table[chip->volume_out[i]];
|
if (chip->stereo&(0x10<<i)) {
|
||||||
|
sample_left += chip->vol_table[chip->volume_out[i]];
|
||||||
|
}
|
||||||
|
if (chip->stereo&(0x01<<i)) {
|
||||||
|
sample_right += chip->vol_table[chip->volume_out[i]];
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return sample;
|
*left=sample_left;
|
||||||
|
*right=sample_right;
|
||||||
}
|
}
|
||||||
|
|
||||||
void YMPSG_Test(ympsg_t *chip, uint16_t test)
|
void YMPSG_Test(ympsg_t *chip, uint16_t test)
|
||||||
|
@ -349,7 +385,7 @@ void YMPSG_Test(ympsg_t *chip, uint16_t test)
|
||||||
chip->test = (test >> 9) & 7;
|
chip->test = (test >> 9) & 7;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
void YMPSG_Generate(ympsg_t *chip, int32_t *buf)
|
void YMPSG_Generate(ympsg_t *chip, int32_t *buf)
|
||||||
{
|
{
|
||||||
uint32_t i;
|
uint32_t i;
|
||||||
|
@ -373,7 +409,7 @@ void YMPSG_Generate(ympsg_t *chip, int32_t *buf)
|
||||||
}
|
}
|
||||||
out = YMPSG_GetOutput(chip);
|
out = YMPSG_GetOutput(chip);
|
||||||
*buf = (int32_t)(out * 8192.f);
|
*buf = (int32_t)(out * 8192.f);
|
||||||
}
|
}*/
|
||||||
|
|
||||||
void YMPSG_WriteBuffered(ympsg_t *chip, uint8_t data)
|
void YMPSG_WriteBuffered(ympsg_t *chip, uint8_t data)
|
||||||
{
|
{
|
||||||
|
|
|
@ -52,6 +52,8 @@ typedef struct {
|
||||||
uint8_t test;
|
uint8_t test;
|
||||||
uint8_t volume_out[4];
|
uint8_t volume_out[4];
|
||||||
|
|
||||||
|
uint8_t stereo;
|
||||||
|
|
||||||
//
|
//
|
||||||
uint64_t writebuf_samplecnt;
|
uint64_t writebuf_samplecnt;
|
||||||
uint32_t writebuf_cur;
|
uint32_t writebuf_cur;
|
||||||
|
@ -68,15 +70,16 @@ typedef struct {
|
||||||
|
|
||||||
|
|
||||||
void YMPSG_Write(ympsg_t *chip, uint8_t data);
|
void YMPSG_Write(ympsg_t *chip, uint8_t data);
|
||||||
|
void YMPSG_WriteStereo(ympsg_t *chip, uint8_t data);
|
||||||
uint16_t YMPSG_Read(ympsg_t *chip);
|
uint16_t YMPSG_Read(ympsg_t *chip);
|
||||||
void YMPSG_Init(ympsg_t *chip, uint8_t real_sn, uint8_t noise_tap1, uint8_t noise_tap2, uint32_t noise_size);
|
void YMPSG_Init(ympsg_t *chip, uint8_t real_sn, uint8_t noise_tap1, uint8_t noise_tap2, uint32_t noise_size);
|
||||||
void YMPSG_SetIC(ympsg_t *chip, uint32_t ic);
|
void YMPSG_SetIC(ympsg_t *chip, uint32_t ic);
|
||||||
void YMPSG_Clock(ympsg_t *chip);
|
void YMPSG_Clock(ympsg_t *chip);
|
||||||
int YMPSG_GetOutput(ympsg_t *chip);
|
void YMPSG_GetOutput(ympsg_t *chip, int* left, int* right);
|
||||||
void YMPSG_Test(ympsg_t *chip, uint16_t test);
|
void YMPSG_Test(ympsg_t *chip, uint16_t test);
|
||||||
|
|
||||||
|
|
||||||
void YMPSG_Generate(ympsg_t *chip, int32_t *buf);
|
//void YMPSG_Generate(ympsg_t *chip, int32_t *buf);
|
||||||
void YMPSG_WriteBuffered(ympsg_t *chip, uint8_t data);
|
void YMPSG_WriteBuffered(ympsg_t *chip, uint8_t data);
|
||||||
|
|
||||||
void YMPSG_SetMute(ympsg_t *chip, uint8_t mute);
|
void YMPSG_SetMute(ympsg_t *chip, uint8_t mute);
|
||||||
|
|
|
@ -48,12 +48,15 @@ const char* DivPlatformSMS::getEffectName(unsigned char effect) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void DivPlatformSMS::acquire_nuked(short* bufL, short* bufR, size_t start, size_t len) {
|
void DivPlatformSMS::acquire_nuked(short* bufL, short* bufR, size_t start, size_t len) {
|
||||||
int o=0;
|
int oL=0;
|
||||||
|
int oR=0;
|
||||||
for (size_t h=start; h<start+len; h++) {
|
for (size_t h=start; h<start+len; h++) {
|
||||||
if (!writes.empty()) {
|
if (!writes.empty()) {
|
||||||
QueuedWrite w=writes.front();
|
QueuedWrite w=writes.front();
|
||||||
if (w.addr==0) {
|
if (w.addr==0) {
|
||||||
YMPSG_Write(&sn_nuked,w.val);
|
YMPSG_Write(&sn_nuked,w.val);
|
||||||
|
} else if (w.addr==1) {
|
||||||
|
YMPSG_WriteStereo(&sn_nuked,w.val);
|
||||||
}
|
}
|
||||||
writes.pop();
|
writes.pop();
|
||||||
}
|
}
|
||||||
|
@ -73,10 +76,13 @@ void DivPlatformSMS::acquire_nuked(short* bufL, short* bufR, size_t start, size_
|
||||||
YMPSG_Clock(&sn_nuked);
|
YMPSG_Clock(&sn_nuked);
|
||||||
YMPSG_Clock(&sn_nuked);
|
YMPSG_Clock(&sn_nuked);
|
||||||
YMPSG_Clock(&sn_nuked);
|
YMPSG_Clock(&sn_nuked);
|
||||||
o=YMPSG_GetOutput(&sn_nuked);
|
YMPSG_GetOutput(&sn_nuked,&oL,&oR);
|
||||||
if (o<-32768) o=-32768;
|
if (oL<-32768) oL=-32768;
|
||||||
if (o>32767) o=32767;
|
if (oL>32767) oL=32767;
|
||||||
bufL[h]=bufR[h]=o;
|
if (oR<-32768) oR=-32768;
|
||||||
|
if (oR>32767) oR=32767;
|
||||||
|
bufL[h]=oL;
|
||||||
|
bufR[h]=oR;
|
||||||
for (int i=0; i<4; i++) {
|
for (int i=0; i<4; i++) {
|
||||||
if (isMuted[i]) {
|
if (isMuted[i]) {
|
||||||
oscBuf[i]->data[oscBuf[i]->needle++]=0;
|
oscBuf[i]->data[oscBuf[i]->needle++]=0;
|
||||||
|
|
Loading…
Reference in New Issue