per-channel oscilloscope, part 5
SAA1099 (SAASound and MAME), Lynx, MMC5, N163, PC Engine, PC Speaker, PET, QSound, WonderSwan, VERA, VIC-20, VRC6 and X1-010!
This commit is contained in:
parent
dadfd7efee
commit
c0e9b48b5b
|
@ -307,7 +307,7 @@ BYTE CSAADevice::_ReadData(void)
|
|||
}
|
||||
#endif
|
||||
|
||||
void CSAADevice::_TickAndOutputStereo(unsigned int& left_mixed, unsigned int& right_mixed)
|
||||
void CSAADevice::_TickAndOutputStereo(unsigned int& left_mixed, unsigned int& right_mixed, DivDispatchOscBuffer** oscBuf)
|
||||
{
|
||||
unsigned int temp_left, temp_right;
|
||||
unsigned int accum_left = 0, accum_right = 0;
|
||||
|
@ -316,21 +316,27 @@ void CSAADevice::_TickAndOutputStereo(unsigned int& left_mixed, unsigned int& ri
|
|||
m_Noise0.Tick();
|
||||
m_Noise1.Tick();
|
||||
m_Amp0.TickAndOutputStereo(temp_left, temp_right);
|
||||
oscBuf[0]->data[oscBuf[0]->needle++]=(temp_left+temp_right)<<4;
|
||||
accum_left += temp_left;
|
||||
accum_right += temp_right;
|
||||
m_Amp1.TickAndOutputStereo(temp_left, temp_right);
|
||||
oscBuf[1]->data[oscBuf[1]->needle++]=(temp_left+temp_right)<<4;
|
||||
accum_left += temp_left;
|
||||
accum_right += temp_right;
|
||||
m_Amp2.TickAndOutputStereo(temp_left, temp_right);
|
||||
oscBuf[2]->data[oscBuf[2]->needle++]=(temp_left+temp_right)<<4;
|
||||
accum_left += temp_left;
|
||||
accum_right += temp_right;
|
||||
m_Amp3.TickAndOutputStereo(temp_left, temp_right);
|
||||
oscBuf[3]->data[oscBuf[3]->needle++]=(temp_left+temp_right)<<4;
|
||||
accum_left += temp_left;
|
||||
accum_right += temp_right;
|
||||
m_Amp4.TickAndOutputStereo(temp_left, temp_right);
|
||||
oscBuf[4]->data[oscBuf[4]->needle++]=(temp_left+temp_right)<<4;
|
||||
accum_left += temp_left;
|
||||
accum_right += temp_right;
|
||||
m_Amp5.TickAndOutputStereo(temp_left, temp_right);
|
||||
oscBuf[5]->data[oscBuf[5]->needle++]=(temp_left+temp_right)<<4;
|
||||
accum_left += temp_left;
|
||||
accum_right += temp_right;
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@ public:
|
|||
void _SetClockRate(unsigned int nClockRate);
|
||||
void _SetSampleRate(unsigned int nSampleRate);
|
||||
void _SetOversample(unsigned int nOversample);
|
||||
void _TickAndOutputStereo(unsigned int& left_mixed, unsigned int& right_mixed);
|
||||
void _TickAndOutputStereo(unsigned int& left_mixed, unsigned int& right_mixed, DivDispatchOscBuffer** oscBuf);
|
||||
void _TickAndOutputSeparate(unsigned int& left_mixed, unsigned int& right_mixed,
|
||||
unsigned int& left0, unsigned int& right0,
|
||||
unsigned int& left1, unsigned int& right1,
|
||||
|
|
|
@ -298,7 +298,7 @@ void scale_for_output(unsigned int left_input, unsigned int right_input,
|
|||
*pBuffer++ = (right_output >> 8) & 0x00ff;
|
||||
}
|
||||
|
||||
void CSAASoundInternal::GenerateMany(BYTE* pBuffer, unsigned long nSamples)
|
||||
void CSAASoundInternal::GenerateMany(BYTE* pBuffer, unsigned long nSamples, DivDispatchOscBuffer** oscBuf)
|
||||
{
|
||||
unsigned int left_mixed, right_mixed;
|
||||
static double filterout_z1_left_mixed = 0, filterout_z1_right_mixed = 0;
|
||||
|
@ -376,7 +376,7 @@ void CSAASoundInternal::GenerateMany(BYTE* pBuffer, unsigned long nSamples)
|
|||
#endif
|
||||
while (nSamples--)
|
||||
{
|
||||
m_chip._TickAndOutputStereo(left_mixed, right_mixed);
|
||||
m_chip._TickAndOutputStereo(left_mixed, right_mixed, oscBuf);
|
||||
scale_for_output(left_mixed, right_mixed, oversample, m_bHighpass, nBoost, filterout_z1_left_mixed, filterout_z1_right_mixed, pBuffer);
|
||||
}
|
||||
|
||||
|
|
|
@ -68,7 +68,7 @@ public:
|
|||
unsigned short GetCurrentBytesPerSample(void);
|
||||
static unsigned short GetBytesPerSample(SAAPARAM uParam);
|
||||
|
||||
void GenerateMany(BYTE * pBuffer, unsigned long nSamples);
|
||||
void GenerateMany(BYTE * pBuffer, unsigned long nSamples, DivDispatchOscBuffer** oscBuf);
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -81,7 +81,7 @@ unsigned long SAAAPI SAASNDGetSampleRate(SAAPARAM uParam)
|
|||
|
||||
void SAAAPI SAASNDGenerateMany(SAASND object, BYTE * pBuffer, unsigned long nSamples)
|
||||
{
|
||||
((LPCSAASOUND)(object))->GenerateMany(pBuffer, nSamples);
|
||||
((LPCSAASOUND)(object))->GenerateMany(pBuffer, nSamples, NULL);
|
||||
}
|
||||
|
||||
void SAAAPI SAASNDSetSampleRate(SAASND object, unsigned int nSampleRate)
|
||||
|
|
|
@ -61,6 +61,8 @@ typedef unsigned long SAAPARAM;
|
|||
|
||||
#ifdef __cplusplus
|
||||
|
||||
#include "../../src/engine/dispatch.h"
|
||||
|
||||
class CSAASound
|
||||
{
|
||||
public:
|
||||
|
@ -79,7 +81,7 @@ public:
|
|||
virtual unsigned short GetCurrentBytesPerSample () = 0;
|
||||
static unsigned short GetBytesPerSample (SAAPARAM uParam);
|
||||
|
||||
virtual void GenerateMany (BYTE * pBuffer, unsigned long nSamples) = 0;
|
||||
virtual void GenerateMany (BYTE * pBuffer, unsigned long nSamples, DivDispatchOscBuffer** oscBuf) = 0;
|
||||
|
||||
virtual void SetClockRate(unsigned int nClockRate) = 0;
|
||||
virtual void SetSampleRate(unsigned int nSampleRate) = 0;
|
||||
|
|
|
@ -12,8 +12,10 @@
|
|||
defined(__arm__) || \
|
||||
(defined(__mips__) && defined(__MIPSEL__))
|
||||
#else
|
||||
#ifndef __BIG_ENDIAN
|
||||
#define __BIG_ENDIAN
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef NULL
|
||||
|
|
|
@ -142,7 +142,7 @@ const char* DivPlatformLynx::getEffectName(unsigned char effect) {
|
|||
}
|
||||
|
||||
void DivPlatformLynx::acquire(short* bufL, short* bufR, size_t start, size_t len) {
|
||||
mikey->sampleAudio( bufL + start, bufR + start, len );
|
||||
mikey->sampleAudio( bufL + start, bufR + start, len, oscBuf );
|
||||
}
|
||||
|
||||
void DivPlatformLynx::tick(bool sysTick) {
|
||||
|
@ -342,6 +342,10 @@ void* DivPlatformLynx::getChanState(int ch) {
|
|||
return &chan[ch];
|
||||
}
|
||||
|
||||
DivDispatchOscBuffer* DivPlatformLynx::getOscBuffer(int ch) {
|
||||
return oscBuf[ch];
|
||||
}
|
||||
|
||||
unsigned char* DivPlatformLynx::getRegisterPool()
|
||||
{
|
||||
return const_cast<unsigned char*>( mikey->getRegisterPool() );
|
||||
|
@ -398,16 +402,24 @@ int DivPlatformLynx::init(DivEngine* p, int channels, int sugRate, unsigned int
|
|||
|
||||
for (int i=0; i<4; i++) {
|
||||
isMuted[i]=false;
|
||||
oscBuf[i]=new DivDispatchOscBuffer;
|
||||
}
|
||||
|
||||
chipClock = 16000000;
|
||||
rate = chipClock/128;
|
||||
|
||||
for (int i=0; i<4; i++) {
|
||||
oscBuf[i]->rate=rate;
|
||||
}
|
||||
|
||||
reset();
|
||||
return 4;
|
||||
}
|
||||
|
||||
void DivPlatformLynx::quit() {
|
||||
for (int i=0; i<4; i++) {
|
||||
delete oscBuf[i];
|
||||
}
|
||||
mikey.reset();
|
||||
}
|
||||
|
||||
|
|
|
@ -74,6 +74,7 @@ class DivPlatformLynx: public DivDispatch {
|
|||
outVol(127) {}
|
||||
};
|
||||
Channel chan[4];
|
||||
DivDispatchOscBuffer* oscBuf[4];
|
||||
bool isMuted[4];
|
||||
std::unique_ptr<Lynx::Mikey> mikey;
|
||||
friend void putDispatchChan(void*,int,int);
|
||||
|
@ -81,6 +82,7 @@ class DivPlatformLynx: public DivDispatch {
|
|||
void acquire(short* bufL, short* bufR, size_t start, size_t len);
|
||||
int dispatch(DivCommand c);
|
||||
void* getChanState(int chan);
|
||||
DivDispatchOscBuffer* getOscBuffer(int chan);
|
||||
unsigned char* getRegisterPool();
|
||||
int getRegisterPoolSize();
|
||||
void reset();
|
||||
|
|
|
@ -59,7 +59,7 @@ void DivPlatformMMC5::acquire(short* bufL, short* bufR, size_t start, size_t len
|
|||
if (dacPeriod>=rate) {
|
||||
DivSample* s=parent->getSample(dacSample);
|
||||
if (s->samples>0) {
|
||||
if (!isMuted[4]) {
|
||||
if (!isMuted[2]) {
|
||||
rWrite(0x5011,((unsigned char)s->data8[dacPos]+0x80));
|
||||
}
|
||||
if (++dacPos>=s->samples) {
|
||||
|
@ -92,6 +92,13 @@ void DivPlatformMMC5::acquire(short* bufL, short* bufR, size_t start, size_t len
|
|||
if (sample>32767) sample=32767;
|
||||
if (sample<-32768) sample=-32768;
|
||||
bufL[i]=sample;
|
||||
|
||||
if (++writeOscBuf>=32) {
|
||||
writeOscBuf=0;
|
||||
oscBuf[0]->data[oscBuf[0]->needle++]=isMuted[0]?0:((mmc5->S3.output*10)<<7);
|
||||
oscBuf[1]->data[oscBuf[1]->needle++]=isMuted[1]?0:((mmc5->S4.output*10)<<7);
|
||||
oscBuf[2]->data[oscBuf[2]->needle++]=isMuted[2]?0:((mmc5->pcm.output*2)<<6);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -164,18 +171,18 @@ void DivPlatformMMC5::tick(bool sysTick) {
|
|||
}
|
||||
|
||||
// PCM
|
||||
if (chan[4].freqChanged) {
|
||||
chan[4].freq=parent->calcFreq(chan[4].baseFreq,chan[4].pitch,false);
|
||||
if (chan[4].furnaceDac) {
|
||||
if (chan[2].freqChanged) {
|
||||
chan[2].freq=parent->calcFreq(chan[2].baseFreq,chan[2].pitch,false);
|
||||
if (chan[2].furnaceDac) {
|
||||
double off=1.0;
|
||||
if (dacSample>=0 && dacSample<parent->song.sampleLen) {
|
||||
DivSample* s=parent->getSample(dacSample);
|
||||
off=(double)s->centerRate/8363.0;
|
||||
}
|
||||
dacRate=MIN(chan[4].freq*off,32000);
|
||||
dacRate=MIN(chan[2].freq*off,32000);
|
||||
if (dumpWrites) addWrite(0xffff0001,dacRate);
|
||||
}
|
||||
chan[4].freqChanged=false;
|
||||
chan[2].freqChanged=false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -342,6 +349,10 @@ void* DivPlatformMMC5::getChanState(int ch) {
|
|||
return &chan[ch];
|
||||
}
|
||||
|
||||
DivDispatchOscBuffer* DivPlatformMMC5::getOscBuffer(int ch) {
|
||||
return oscBuf[ch];
|
||||
}
|
||||
|
||||
unsigned char* DivPlatformMMC5::getRegisterPool() {
|
||||
return regPool;
|
||||
}
|
||||
|
@ -389,6 +400,9 @@ void DivPlatformMMC5::setFlags(unsigned int flags) {
|
|||
rate=COLOR_NTSC/2.0;
|
||||
}
|
||||
chipClock=rate;
|
||||
for (int i=0; i<3; i++) {
|
||||
oscBuf[i]->rate=rate/32;
|
||||
}
|
||||
}
|
||||
|
||||
void DivPlatformMMC5::notifyInsDeletion(void* ins) {
|
||||
|
@ -410,9 +424,11 @@ int DivPlatformMMC5::init(DivEngine* p, int channels, int sugRate, unsigned int
|
|||
apuType=flags;
|
||||
dumpWrites=false;
|
||||
skipRegisterWrites=false;
|
||||
writeOscBuf=0;
|
||||
mmc5=new struct _mmc5;
|
||||
for (int i=0; i<3; i++) {
|
||||
isMuted[i]=false;
|
||||
oscBuf[i]=new DivDispatchOscBuffer;
|
||||
//mmc5->muted[i]=false; // TODO
|
||||
}
|
||||
setFlags(flags);
|
||||
|
@ -423,6 +439,9 @@ int DivPlatformMMC5::init(DivEngine* p, int channels, int sugRate, unsigned int
|
|||
}
|
||||
|
||||
void DivPlatformMMC5::quit() {
|
||||
for (int i=0; i<3; i++) {
|
||||
delete oscBuf[i];
|
||||
}
|
||||
delete mmc5;
|
||||
}
|
||||
|
||||
|
|
|
@ -57,12 +57,14 @@ class DivPlatformMMC5: public DivDispatch {
|
|||
wave(-1) {}
|
||||
};
|
||||
Channel chan[5];
|
||||
DivDispatchOscBuffer* oscBuf[3];
|
||||
bool isMuted[5];
|
||||
int dacPeriod, dacRate;
|
||||
unsigned int dacPos;
|
||||
int dacSample;
|
||||
unsigned char sampleBank;
|
||||
unsigned char apuType;
|
||||
unsigned char writeOscBuf;
|
||||
struct _mmc5* mmc5;
|
||||
unsigned char regPool[128];
|
||||
|
||||
|
@ -72,6 +74,7 @@ class DivPlatformMMC5: public DivDispatch {
|
|||
void acquire(short* bufL, short* bufR, size_t start, size_t len);
|
||||
int dispatch(DivCommand c);
|
||||
void* getChanState(int chan);
|
||||
DivDispatchOscBuffer* getOscBuffer(int chan);
|
||||
unsigned char* getRegisterPool();
|
||||
int getRegisterPoolSize();
|
||||
void reset();
|
||||
|
|
|
@ -161,6 +161,10 @@ void DivPlatformN163::acquire(short* bufL, short* bufR, size_t start, size_t len
|
|||
if (out<-32768) out=-32768;
|
||||
bufL[i]=bufR[i]=out;
|
||||
|
||||
if (n163.voice_cycle()==0x78) for (int i=0; i<8; i++) {
|
||||
oscBuf[i]->data[oscBuf[i]->needle++]=n163.chan_out(i)<<7;
|
||||
}
|
||||
|
||||
// command queue
|
||||
while (!writes.empty()) {
|
||||
QueuedWrite w=writes.front();
|
||||
|
@ -619,6 +623,10 @@ void* DivPlatformN163::getChanState(int ch) {
|
|||
return &chan[ch];
|
||||
}
|
||||
|
||||
DivDispatchOscBuffer* DivPlatformN163::getOscBuffer(int ch) {
|
||||
return oscBuf[ch];
|
||||
}
|
||||
|
||||
unsigned char* DivPlatformN163::getRegisterPool() {
|
||||
for (int i=0; i<128; i++) {
|
||||
regPool[i]=n163.reg(i);
|
||||
|
@ -678,6 +686,9 @@ void DivPlatformN163::setFlags(unsigned int flags) {
|
|||
rate/=15;
|
||||
n163.set_multiplex(multiplex);
|
||||
rWrite(0x7f,initChanMax<<4);
|
||||
for (int i=0; i<8; i++) {
|
||||
oscBuf[i]->rate=rate/(initChanMax+1);
|
||||
}
|
||||
}
|
||||
|
||||
int DivPlatformN163::init(DivEngine* p, int channels, int sugRate, unsigned int flags) {
|
||||
|
@ -686,6 +697,7 @@ int DivPlatformN163::init(DivEngine* p, int channels, int sugRate, unsigned int
|
|||
skipRegisterWrites=false;
|
||||
for (int i=0; i<8; i++) {
|
||||
isMuted[i]=false;
|
||||
oscBuf[i]=new DivDispatchOscBuffer;
|
||||
}
|
||||
setFlags(flags);
|
||||
|
||||
|
@ -695,6 +707,9 @@ int DivPlatformN163::init(DivEngine* p, int channels, int sugRate, unsigned int
|
|||
}
|
||||
|
||||
void DivPlatformN163::quit() {
|
||||
for (int i=0; i<8; i++) {
|
||||
delete oscBuf[i];
|
||||
}
|
||||
}
|
||||
|
||||
DivPlatformN163::~DivPlatformN163() {
|
||||
|
|
|
@ -70,6 +70,7 @@ class DivPlatformN163: public DivDispatch {
|
|||
resVol(15) {}
|
||||
};
|
||||
Channel chan[8];
|
||||
DivDispatchOscBuffer* oscBuf[8];
|
||||
bool isMuted[8];
|
||||
struct QueuedWrite {
|
||||
unsigned char addr;
|
||||
|
@ -94,6 +95,7 @@ class DivPlatformN163: public DivDispatch {
|
|||
void acquire(short* bufL, short* bufR, size_t start, size_t len);
|
||||
int dispatch(DivCommand c);
|
||||
void* getChanState(int chan);
|
||||
DivDispatchOscBuffer* getOscBuffer(int chan);
|
||||
unsigned char* getRegisterPool();
|
||||
int getRegisterPoolSize();
|
||||
void reset();
|
||||
|
|
|
@ -116,6 +116,10 @@ void DivPlatformPCE::acquire(short* bufL, short* bufR, size_t start, size_t len)
|
|||
pce->Update(24);
|
||||
pce->ResetTS(0);
|
||||
|
||||
for (int i=0; i<6; i++) {
|
||||
oscBuf[i]->data[oscBuf[i]->needle++]=(pce->channel[i].blip_prev_samp[0]+pce->channel[i].blip_prev_samp[1])<<1;
|
||||
}
|
||||
|
||||
tempL[0]=(tempL[0]>>1)+(tempL[0]>>2);
|
||||
tempR[0]=(tempR[0]>>1)+(tempR[0]>>2);
|
||||
|
||||
|
@ -469,6 +473,10 @@ void* DivPlatformPCE::getChanState(int ch) {
|
|||
return &chan[ch];
|
||||
}
|
||||
|
||||
DivDispatchOscBuffer* DivPlatformPCE::getOscBuffer(int ch) {
|
||||
return oscBuf[ch];
|
||||
}
|
||||
|
||||
unsigned char* DivPlatformPCE::getRegisterPool() {
|
||||
return regPool;
|
||||
}
|
||||
|
@ -541,6 +549,9 @@ void DivPlatformPCE::setFlags(unsigned int flags) {
|
|||
chipClock=COLOR_NTSC;
|
||||
}
|
||||
rate=chipClock/12;
|
||||
for (int i=0; i<6; i++) {
|
||||
oscBuf[i]->rate=rate;
|
||||
}
|
||||
}
|
||||
|
||||
void DivPlatformPCE::poke(unsigned int addr, unsigned short val) {
|
||||
|
@ -557,6 +568,7 @@ int DivPlatformPCE::init(DivEngine* p, int channels, int sugRate, unsigned int f
|
|||
skipRegisterWrites=false;
|
||||
for (int i=0; i<6; i++) {
|
||||
isMuted[i]=false;
|
||||
oscBuf[i]=new DivDispatchOscBuffer;
|
||||
}
|
||||
setFlags(flags);
|
||||
pce=new PCE_PSG(tempL,tempR,PCE_PSG::REVISION_HUC6280A);
|
||||
|
@ -565,6 +577,9 @@ int DivPlatformPCE::init(DivEngine* p, int channels, int sugRate, unsigned int f
|
|||
}
|
||||
|
||||
void DivPlatformPCE::quit() {
|
||||
for (int i=0; i<6; i++) {
|
||||
delete oscBuf[i];
|
||||
}
|
||||
delete pce;
|
||||
}
|
||||
|
||||
|
|
|
@ -67,6 +67,7 @@ class DivPlatformPCE: public DivDispatch {
|
|||
wave(-1) {}
|
||||
};
|
||||
Channel chan[6];
|
||||
DivDispatchOscBuffer* oscBuf[6];
|
||||
bool isMuted[6];
|
||||
struct QueuedWrite {
|
||||
unsigned char addr;
|
||||
|
@ -88,6 +89,7 @@ class DivPlatformPCE: public DivDispatch {
|
|||
void acquire(short* bufL, short* bufR, size_t start, size_t len);
|
||||
int dispatch(DivCommand c);
|
||||
void* getChanState(int chan);
|
||||
DivDispatchOscBuffer* getOscBuffer(int chan);
|
||||
unsigned char* getRegisterPool();
|
||||
int getRegisterPoolSize();
|
||||
void reset();
|
||||
|
|
|
@ -50,6 +50,7 @@ const float cut=0.05;
|
|||
const float reso=0.06;
|
||||
|
||||
void DivPlatformPCSpeaker::acquire_unfilt(short* bufL, short* bufR, size_t start, size_t len) {
|
||||
int out=0;
|
||||
for (size_t i=start; i<start+len; i++) {
|
||||
if (on) {
|
||||
pos-=PCSPKR_DIVIDER;
|
||||
|
@ -61,9 +62,12 @@ void DivPlatformPCSpeaker::acquire_unfilt(short* bufL, short* bufR, size_t start
|
|||
pos+=freq;
|
||||
}
|
||||
}
|
||||
bufL[i]=(pos>(freq>>1) && !isMuted[0])?32767:0;
|
||||
out=(pos>(freq>>1) && !isMuted[0])?32767:0;
|
||||
bufL[i]=out;
|
||||
oscBuf->data[oscBuf->needle++]=out;
|
||||
} else {
|
||||
bufL[i]=0;
|
||||
oscBuf->data[oscBuf->needle++]=0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -87,8 +91,10 @@ void DivPlatformPCSpeaker::acquire_cone(short* bufL, short* bufR, size_t start,
|
|||
if (out>1.0) out=1.0;
|
||||
if (out<-1.0) out=-1.0;
|
||||
bufL[i]=out*32767;
|
||||
oscBuf->data[oscBuf->needle++]=out*32767;
|
||||
} else {
|
||||
bufL[i]=0;
|
||||
oscBuf->data[oscBuf->needle++]=0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -112,8 +118,10 @@ void DivPlatformPCSpeaker::acquire_piezo(short* bufL, short* bufR, size_t start,
|
|||
if (out>1.0) out=1.0;
|
||||
if (out<-1.0) out=-1.0;
|
||||
bufL[i]=out*32767;
|
||||
oscBuf->data[oscBuf->needle++]=out*32767;
|
||||
} else {
|
||||
bufL[i]=0;
|
||||
oscBuf->data[oscBuf->needle++]=0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -140,12 +148,28 @@ void DivPlatformPCSpeaker::beepFreq(int freq) {
|
|||
}
|
||||
|
||||
void DivPlatformPCSpeaker::acquire_real(short* bufL, short* bufR, size_t start, size_t len) {
|
||||
int out=0;
|
||||
if (lastOn!=on || lastFreq!=freq) {
|
||||
lastOn=on;
|
||||
lastFreq=freq;
|
||||
beepFreq((on && !isMuted[0])?freq:0);
|
||||
}
|
||||
for (size_t i=start; i<start+len; i++) {
|
||||
if (on) {
|
||||
pos-=PCSPKR_DIVIDER;
|
||||
if (pos>freq) pos=freq;
|
||||
while (pos<0) {
|
||||
if (freq<1) {
|
||||
pos=1;
|
||||
} else {
|
||||
pos+=freq;
|
||||
}
|
||||
}
|
||||
out=(pos>(freq>>1) && !isMuted[0])?32767:0;
|
||||
oscBuf->data[oscBuf->needle++]=out;
|
||||
} else {
|
||||
oscBuf->data[oscBuf->needle++]=0;
|
||||
}
|
||||
bufL[i]=0;
|
||||
}
|
||||
}
|
||||
|
@ -321,6 +345,10 @@ void* DivPlatformPCSpeaker::getChanState(int ch) {
|
|||
return &chan[ch];
|
||||
}
|
||||
|
||||
DivDispatchOscBuffer* DivPlatformPCSpeaker::getOscBuffer(int ch) {
|
||||
return oscBuf;
|
||||
}
|
||||
|
||||
unsigned char* DivPlatformPCSpeaker::getRegisterPool() {
|
||||
if (on) {
|
||||
regPool[0]=freq;
|
||||
|
@ -379,6 +407,7 @@ void DivPlatformPCSpeaker::setFlags(unsigned int flags) {
|
|||
chipClock=COLOR_NTSC/3.0;
|
||||
rate=chipClock/PCSPKR_DIVIDER;
|
||||
speakerType=flags&3;
|
||||
oscBuf->rate=rate;
|
||||
}
|
||||
|
||||
void DivPlatformPCSpeaker::notifyInsDeletion(void* ins) {
|
||||
|
@ -407,6 +436,7 @@ int DivPlatformPCSpeaker::init(DivEngine* p, int channels, int sugRate, unsigned
|
|||
for (int i=0; i<1; i++) {
|
||||
isMuted[i]=false;
|
||||
}
|
||||
oscBuf=new DivDispatchOscBuffer;
|
||||
setFlags(flags);
|
||||
|
||||
reset();
|
||||
|
@ -420,6 +450,7 @@ void DivPlatformPCSpeaker::quit() {
|
|||
#ifdef __linux__
|
||||
if (beepFD>=0) close(beepFD);
|
||||
#endif
|
||||
delete oscBuf;
|
||||
}
|
||||
|
||||
DivPlatformPCSpeaker::~DivPlatformPCSpeaker() {
|
||||
|
|
|
@ -56,6 +56,7 @@ class DivPlatformPCSpeaker: public DivDispatch {
|
|||
wave(-1) {}
|
||||
};
|
||||
Channel chan[1];
|
||||
DivDispatchOscBuffer* oscBuf;
|
||||
bool isMuted[1];
|
||||
bool on, flip, lastOn;
|
||||
int pos, speakerType, beepFD;
|
||||
|
@ -78,6 +79,7 @@ class DivPlatformPCSpeaker: public DivDispatch {
|
|||
void acquire(short* bufL, short* bufR, size_t start, size_t len);
|
||||
int dispatch(DivCommand c);
|
||||
void* getChanState(int chan);
|
||||
DivDispatchOscBuffer* getOscBuffer(int chan);
|
||||
unsigned char* getRegisterPool();
|
||||
int getRegisterPoolSize();
|
||||
void reset();
|
||||
|
|
|
@ -64,12 +64,14 @@ void DivPlatformPET::acquire(short* bufL, short* bufR, size_t start, size_t len)
|
|||
}
|
||||
bufL[h]=chan.out;
|
||||
bufR[h]=chan.out;
|
||||
oscBuf->data[oscBuf->needle++]=chan.out;
|
||||
}
|
||||
} else {
|
||||
chan.out=0;
|
||||
for (size_t h=start; h<start+len; h++) {
|
||||
bufL[h]=0;
|
||||
bufR[h]=0;
|
||||
oscBuf->data[oscBuf->needle++]=0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -244,6 +246,10 @@ void* DivPlatformPET::getChanState(int ch) {
|
|||
return &chan;
|
||||
}
|
||||
|
||||
DivDispatchOscBuffer* DivPlatformPET::getOscBuffer(int ch) {
|
||||
return oscBuf;
|
||||
}
|
||||
|
||||
unsigned char* DivPlatformPET::getRegisterPool() {
|
||||
return regPool;
|
||||
}
|
||||
|
@ -281,9 +287,15 @@ int DivPlatformPET::init(DivEngine* p, int channels, int sugRate, unsigned int f
|
|||
chipClock=1000000;
|
||||
rate=chipClock/SAMP_DIVIDER; // = 250000kHz
|
||||
isMuted=false;
|
||||
oscBuf=new DivDispatchOscBuffer;
|
||||
oscBuf->rate=rate;
|
||||
reset();
|
||||
return 1;
|
||||
}
|
||||
|
||||
void DivPlatformPET::quit() {
|
||||
delete oscBuf;
|
||||
}
|
||||
|
||||
DivPlatformPET::~DivPlatformPET() {
|
||||
}
|
||||
|
|
|
@ -57,6 +57,7 @@ class DivPlatformPET: public DivDispatch {
|
|||
out(0) {}
|
||||
};
|
||||
Channel chan;
|
||||
DivDispatchOscBuffer* oscBuf;
|
||||
bool isMuted;
|
||||
|
||||
unsigned char regPool[16];
|
||||
|
@ -65,6 +66,7 @@ class DivPlatformPET: public DivDispatch {
|
|||
void acquire(short* bufL, short* bufR, size_t start, size_t len);
|
||||
int dispatch(DivCommand c);
|
||||
void* getChanState(int chan);
|
||||
DivDispatchOscBuffer* getOscBuffer(int chan);
|
||||
unsigned char* getRegisterPool();
|
||||
int getRegisterPoolSize();
|
||||
void reset();
|
||||
|
@ -78,6 +80,7 @@ class DivPlatformPET: public DivDispatch {
|
|||
const char** getRegisterSheet();
|
||||
const char* getEffectName(unsigned char effect);
|
||||
int init(DivEngine* parent, int channels, int sugRate, unsigned int flags);
|
||||
void quit();
|
||||
~DivPlatformPET();
|
||||
private:
|
||||
void writeOutVol();
|
||||
|
|
|
@ -274,6 +274,13 @@ void DivPlatformQSound::acquire(short* bufL, short* bufR, size_t start, size_t l
|
|||
qsound_update(&chip);
|
||||
bufL[h]=chip.out[0];
|
||||
bufR[h]=chip.out[1];
|
||||
|
||||
for (int i=0; i<19; i++) {
|
||||
int data=chip.voice_output[i]<<2;
|
||||
if (data<-32768) data=-32768;
|
||||
if (data>32767) data=32767;
|
||||
oscBuf[i]->data[oscBuf[i]->needle++]=data;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -546,6 +553,10 @@ void* DivPlatformQSound::getChanState(int ch) {
|
|||
return &chan[ch];
|
||||
}
|
||||
|
||||
DivDispatchOscBuffer* DivPlatformQSound::getOscBuffer(int ch) {
|
||||
return oscBuf[ch];
|
||||
}
|
||||
|
||||
void DivPlatformQSound::reset() {
|
||||
for (int i=0; i<16; i++) {
|
||||
chan[i]=DivPlatformQSound::Channel();
|
||||
|
@ -632,9 +643,10 @@ int DivPlatformQSound::init(DivEngine* p, int channels, int sugRate, unsigned in
|
|||
dumpWrites=false;
|
||||
skipRegisterWrites=false;
|
||||
|
||||
//for (int i=0; i<16; i++) {
|
||||
// isMuted[i]=false;
|
||||
//}
|
||||
for (int i=0; i<19; i++) {
|
||||
oscBuf[i]=new DivDispatchOscBuffer;
|
||||
//isMuted[i]=false;
|
||||
}
|
||||
setFlags(flags);
|
||||
|
||||
chipClock=60000000;
|
||||
|
@ -642,8 +654,15 @@ int DivPlatformQSound::init(DivEngine* p, int channels, int sugRate, unsigned in
|
|||
chip.rom_data = (unsigned char*)&chip.rom_mask;
|
||||
chip.rom_mask = 0;
|
||||
reset();
|
||||
|
||||
for (int i=0; i<19; i++) {
|
||||
oscBuf[i]->rate=rate;
|
||||
}
|
||||
return 19;
|
||||
}
|
||||
|
||||
void DivPlatformQSound::quit() {
|
||||
for (int i=0; i<19; i++) {
|
||||
delete oscBuf[i];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -63,6 +63,7 @@ class DivPlatformQSound: public DivDispatch {
|
|||
outVol(255) {}
|
||||
};
|
||||
Channel chan[19];
|
||||
DivDispatchOscBuffer* oscBuf[19];
|
||||
int echoDelay;
|
||||
int echoFeedback;
|
||||
|
||||
|
@ -75,6 +76,7 @@ class DivPlatformQSound: public DivDispatch {
|
|||
void acquire(short* bufL, short* bufR, size_t start, size_t len);
|
||||
int dispatch(DivCommand c);
|
||||
void* getChanState(int chan);
|
||||
DivDispatchOscBuffer* getOscBuffer(int chan);
|
||||
unsigned char* getRegisterPool();
|
||||
int getRegisterPoolSize();
|
||||
int getRegisterPoolDepth();
|
||||
|
|
|
@ -86,7 +86,7 @@ void DivPlatformSAA1099::acquire_mame(short* bufL, short* bufR, size_t start, si
|
|||
regPool[w.addr&0x1f]=w.val;
|
||||
writes.pop();
|
||||
}
|
||||
saa.sound_stream_update(saaBuf,len);
|
||||
saa.sound_stream_update(saaBuf,len,oscBuf);
|
||||
for (size_t i=0; i<len; i++) {
|
||||
bufL[i+start]=saaBuf[0][i];
|
||||
bufR[i+start]=saaBuf[1][i];
|
||||
|
@ -107,7 +107,7 @@ void DivPlatformSAA1099::acquire_saaSound(short* bufL, short* bufR, size_t start
|
|||
regPool[w.addr&0x1f]=w.val;
|
||||
writes.pop();
|
||||
}
|
||||
saa_saaSound->GenerateMany((unsigned char*)saaBuf[0],len);
|
||||
saa_saaSound->GenerateMany((unsigned char*)saaBuf[0],len,oscBuf);
|
||||
for (size_t i=0; i<len; i++) {
|
||||
bufL[i+start]=saaBuf[0][i<<1];
|
||||
bufR[i+start]=saaBuf[0][1+(i<<1)];
|
||||
|
@ -398,6 +398,10 @@ void* DivPlatformSAA1099::getChanState(int ch) {
|
|||
return &chan[ch];
|
||||
}
|
||||
|
||||
DivDispatchOscBuffer* DivPlatformSAA1099::getOscBuffer(int ch) {
|
||||
return oscBuf[ch];
|
||||
}
|
||||
|
||||
unsigned char* DivPlatformSAA1099::getRegisterPool() {
|
||||
return regPool;
|
||||
}
|
||||
|
@ -485,6 +489,10 @@ void DivPlatformSAA1099::setFlags(unsigned int flags) {
|
|||
}
|
||||
rate=chipClock/32;
|
||||
|
||||
for (int i=0; i<6; i++) {
|
||||
oscBuf[i]->rate=rate;
|
||||
}
|
||||
|
||||
switch (core) {
|
||||
case DIV_SAA_CORE_MAME:
|
||||
break;
|
||||
|
@ -516,6 +524,7 @@ int DivPlatformSAA1099::init(DivEngine* p, int channels, int sugRate, unsigned i
|
|||
saa_saaSound=NULL;
|
||||
for (int i=0; i<6; i++) {
|
||||
isMuted[i]=false;
|
||||
oscBuf[i]=new DivDispatchOscBuffer;
|
||||
}
|
||||
if (core==DIV_SAA_CORE_SAASOUND) {
|
||||
saa_saaSound=CreateCSAASound();
|
||||
|
@ -530,6 +539,9 @@ int DivPlatformSAA1099::init(DivEngine* p, int channels, int sugRate, unsigned i
|
|||
}
|
||||
|
||||
void DivPlatformSAA1099::quit() {
|
||||
for (int i=0; i<6; i++) {
|
||||
delete oscBuf[i];
|
||||
}
|
||||
if (saa_saaSound!=NULL) {
|
||||
DestroyCSAASound(saa_saaSound);
|
||||
saa_saaSound=NULL;
|
||||
|
|
|
@ -49,6 +49,7 @@ class DivPlatformSAA1099: public DivDispatch {
|
|||
Channel(): freqH(0), freqL(0), freq(0), baseFreq(0), pitch(0), pitch2(0), note(0), ins(-1), psgMode(1), active(false), insChanged(true), freqChanged(false), keyOn(false), keyOff(false), portaPause(false), inPorta(false), vol(0), outVol(15), pan(255) {}
|
||||
};
|
||||
Channel chan[6];
|
||||
DivDispatchOscBuffer* oscBuf[6];
|
||||
bool isMuted[6];
|
||||
struct QueuedWrite {
|
||||
unsigned short addr;
|
||||
|
@ -90,6 +91,7 @@ class DivPlatformSAA1099: public DivDispatch {
|
|||
void acquire(short* bufL, short* bufR, size_t start, size_t len);
|
||||
int dispatch(DivCommand c);
|
||||
void* getChanState(int chan);
|
||||
DivDispatchOscBuffer* getOscBuffer(int chan);
|
||||
unsigned char* getRegisterPool();
|
||||
int getRegisterPoolSize();
|
||||
void reset();
|
||||
|
|
|
@ -458,23 +458,31 @@ public:
|
|||
return mAudioChannels[timer].fireAction( tick );
|
||||
}
|
||||
|
||||
AudioSample sampleAudio() const
|
||||
AudioSample sampleAudio( DivDispatchOscBuffer** oscb ) const
|
||||
{
|
||||
int left{};
|
||||
int right{};
|
||||
|
||||
for ( size_t i = 0; i < 4; ++i )
|
||||
{
|
||||
int oscbWrite = 0;
|
||||
|
||||
if ( ( mStereo & ( (uint8_t)0x01 << i ) ) == 0 )
|
||||
{
|
||||
const int attenuation = ( mPan & ( (uint8_t)0x01 << i ) ) != 0 ? mAttenuationLeft[i] : 0x3c;
|
||||
left += mAudioChannels[i].getOutput() * attenuation;
|
||||
oscbWrite += mAudioChannels[i].getOutput() * attenuation;
|
||||
}
|
||||
|
||||
if ( ( mStereo & ( (uint8_t)0x10 << i ) ) == 0 )
|
||||
{
|
||||
const int attenuation = ( mPan & ( (uint8_t)0x01 << i ) ) != 0 ? mAttenuationRight[i] : 0x3c;
|
||||
right += mAudioChannels[i].getOutput() * attenuation;
|
||||
oscbWrite += mAudioChannels[i].getOutput() * attenuation;
|
||||
}
|
||||
|
||||
if (oscb!=NULL) {
|
||||
oscb[i]->data[oscb[i]->needle++]=oscbWrite;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -534,7 +542,7 @@ void Mikey::enqueueSampling()
|
|||
mQueue->push( ( mNextTick & ~15 ) | 4 );
|
||||
}
|
||||
|
||||
void Mikey::sampleAudio( int16_t* bufL, int16_t* bufR, size_t size )
|
||||
void Mikey::sampleAudio( int16_t* bufL, int16_t* bufR, size_t size, DivDispatchOscBuffer** oscb )
|
||||
{
|
||||
size_t i = 0;
|
||||
while ( i < size )
|
||||
|
@ -549,7 +557,7 @@ void Mikey::sampleAudio( int16_t* bufL, int16_t* bufR, size_t size )
|
|||
}
|
||||
else
|
||||
{
|
||||
auto sample = mMikey->sampleAudio();
|
||||
auto sample = mMikey->sampleAudio( oscb );
|
||||
bufL[i] = sample.left;
|
||||
bufR[i] = sample.right;
|
||||
i += 1;
|
||||
|
|
|
@ -3,6 +3,9 @@
|
|||
#include <cstdint>
|
||||
#include <memory>
|
||||
|
||||
// can you forgive me
|
||||
#include "../../../dispatch.h"
|
||||
|
||||
namespace Lynx
|
||||
{
|
||||
|
||||
|
@ -18,7 +21,7 @@ public:
|
|||
~Mikey();
|
||||
|
||||
void write( uint8_t address, uint8_t value );
|
||||
void sampleAudio( int16_t* bufL, int16_t* bufR, size_t size );
|
||||
void sampleAudio( int16_t* bufL, int16_t* bufR, size_t size, DivDispatchOscBuffer** oscb = NULL );
|
||||
|
||||
uint8_t const* getRegisterPool();
|
||||
|
||||
|
|
|
@ -98,6 +98,8 @@ void n163_core::tick()
|
|||
m_ram[m_voice_cycle + 3] = bitfield(accum, 8, 8);
|
||||
m_ram[m_voice_cycle + 5] = bitfield(accum, 16, 8);
|
||||
|
||||
const u8 prev_voice_cycle = m_voice_cycle;
|
||||
|
||||
// update voice cycle
|
||||
bool flush = m_multiplex ? true : false;
|
||||
m_voice_cycle -= 0x8;
|
||||
|
@ -109,7 +111,9 @@ void n163_core::tick()
|
|||
}
|
||||
|
||||
// output 4 bit waveform and volume, multiplexed
|
||||
m_acc += wave * volume;
|
||||
const u8 chan_index = ((0x78-prev_voice_cycle)>>3)&7;
|
||||
m_ch_out[chan_index]=wave * volume;
|
||||
m_acc += m_ch_out[chan_index];
|
||||
if (flush)
|
||||
{
|
||||
m_out = m_acc / (m_multiplex ? 1 : (bitfield(m_ram[0x7f], 4, 3) + 1));
|
||||
|
@ -127,6 +131,7 @@ void n163_core::reset()
|
|||
m_addr_latch.reset();
|
||||
m_out = 0;
|
||||
m_acc = 0;
|
||||
std::fill(std::begin(m_ch_out), std::end(m_ch_out), 0);
|
||||
}
|
||||
|
||||
// accessor
|
||||
|
|
|
@ -46,6 +46,12 @@ public:
|
|||
// sound output pin
|
||||
s16 out() { return m_out; }
|
||||
|
||||
// get channel output
|
||||
s16 chan_out(u8 ch) { return m_ch_out[ch]; }
|
||||
|
||||
// get voice cycle
|
||||
u8 voice_cycle() { return m_voice_cycle; }
|
||||
|
||||
// register pool
|
||||
u8 reg(u8 addr) { return m_ram[addr & 0x7f]; }
|
||||
void set_multiplex(bool multiplex = true) { m_multiplex = multiplex; }
|
||||
|
@ -74,6 +80,7 @@ private:
|
|||
u8 m_voice_cycle = 0x78; // Voice cycle for processing
|
||||
addr_latch_t m_addr_latch; // address latch
|
||||
s16 m_out = 0; // output
|
||||
s16 m_ch_out[8] = {0}; // per channel output
|
||||
// demultiplex related
|
||||
bool m_multiplex = true; // multiplex flag, but less noisy = inaccurate!
|
||||
s16 m_acc = 0; // accumulated output
|
||||
|
|
|
@ -96,10 +96,11 @@ inline void PCE_PSG::UpdateOutputSub(const int32_t timestamp, psg_channel *ch, c
|
|||
HRBufs[1][l + 4] += delta[1] * c[4];
|
||||
HRBufs[1][l + 5] += delta[1] * c[5];
|
||||
HRBufs[1][l + 6] += delta[1] * c[6];
|
||||
*/
|
||||
|
||||
ch->blip_prev_samp[0] = samp0;
|
||||
ch->blip_prev_samp[1] = samp1;
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
void PCE_PSG::UpdateOutput_Norm(const int32_t timestamp, psg_channel *ch)
|
||||
|
|
|
@ -147,6 +147,8 @@ class PCE_PSG
|
|||
|
||||
void PeekWave(const unsigned int ch, uint32_t Address, uint32_t Length, uint8_t *Buffer);
|
||||
void PokeWave(const unsigned int ch, uint32_t Address, uint32_t Length, const uint8_t *Buffer);
|
||||
|
||||
psg_channel channel[6];
|
||||
|
||||
private:
|
||||
|
||||
|
@ -178,8 +180,6 @@ class PCE_PSG
|
|||
int32_t vol_update_vllatch;
|
||||
bool vol_pending;
|
||||
|
||||
psg_channel channel[6];
|
||||
|
||||
int32_t lastts;
|
||||
int revision;
|
||||
|
||||
|
|
|
@ -164,7 +164,7 @@ void saa1099_device::device_start()
|
|||
// sound_stream_update - handle a stream update
|
||||
//-------------------------------------------------
|
||||
|
||||
void saa1099_device::sound_stream_update(short** outputs, int len)
|
||||
void saa1099_device::sound_stream_update(short** outputs, int len, DivDispatchOscBuffer** oscBuf)
|
||||
{
|
||||
int j, ch;
|
||||
/* if the channels are disabled we're done */
|
||||
|
@ -225,9 +225,14 @@ void saa1099_device::sound_stream_update(short** outputs, int len)
|
|||
}
|
||||
if (level)
|
||||
{
|
||||
output_l += m_channels[ch].amplitude[ LEFT] * m_channels[ch].envelope[ LEFT] / 16;
|
||||
output_r += m_channels[ch].amplitude[RIGHT] * m_channels[ch].envelope[RIGHT] / 16;
|
||||
}
|
||||
int this_output_l = m_channels[ch].amplitude[ LEFT] * m_channels[ch].envelope[ LEFT] / 16;
|
||||
int this_output_r = m_channels[ch].amplitude[RIGHT] * m_channels[ch].envelope[RIGHT] / 16;
|
||||
output_l+=this_output_l;
|
||||
output_r+=this_output_r;
|
||||
oscBuf[ch]->data[oscBuf[ch]->needle++]=(this_output_l+this_output_r)<<1;
|
||||
} else if (oscBuf!=NULL) {
|
||||
oscBuf[ch]->data[oscBuf[ch]->needle++]=0;
|
||||
}
|
||||
}
|
||||
|
||||
for (ch = 0; ch < 2; ch++)
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
#ifndef MAME_SOUND_SAA1099_H
|
||||
#define MAME_SOUND_SAA1099_H
|
||||
|
||||
#include "../../dispatch.h"
|
||||
|
||||
//**************************************************************************
|
||||
// TYPE DEFINITIONS
|
||||
//**************************************************************************
|
||||
|
@ -28,7 +30,7 @@ public:
|
|||
void device_clock_changed();
|
||||
|
||||
// sound stream update overrides
|
||||
void sound_stream_update(short** outputs, int len);
|
||||
void sound_stream_update(short** outputs, int len, DivDispatchOscBuffer** oscBuf=NULL);
|
||||
|
||||
private:
|
||||
struct saa1099_channel
|
||||
|
|
|
@ -41,6 +41,8 @@ public:
|
|||
|
||||
void SoundUpdate(uint32_t);
|
||||
void RAMWrite(uint32_t, uint8_t);
|
||||
|
||||
int32_t sample_cache[4][2];
|
||||
|
||||
private:
|
||||
// Blip_Synth<blip_good_quality, 4096> WaveSynth;
|
||||
|
@ -61,8 +63,6 @@ private:
|
|||
uint8_t sweep_counter;
|
||||
uint8_t SampleRAMPos;
|
||||
|
||||
int32_t sample_cache[4][2];
|
||||
|
||||
int32_t last_v_val;
|
||||
|
||||
uint8_t HyperVoice;
|
||||
|
|
|
@ -86,6 +86,12 @@ render(struct VERA_PSG* psg, int16_t *left, int16_t *right)
|
|||
if (ch->right) {
|
||||
r += val;
|
||||
}
|
||||
|
||||
if (ch->left || ch->right) {
|
||||
ch->lastOut=val;
|
||||
} else {
|
||||
ch->lastOut=0;
|
||||
}
|
||||
}
|
||||
|
||||
*left = l;
|
||||
|
|
|
@ -15,6 +15,7 @@ struct VERAChannel {
|
|||
uint8_t waveform;
|
||||
|
||||
unsigned phase;
|
||||
int lastOut;
|
||||
uint8_t noiseval;
|
||||
};
|
||||
|
||||
|
|
|
@ -88,13 +88,23 @@ void vrcvi_core::tick()
|
|||
if (!m_control.m_halt) // Halt flag
|
||||
{
|
||||
// tick per each clock
|
||||
int elemIndex=0;
|
||||
for (auto & elem : m_pulse)
|
||||
{
|
||||
if (elem.tick())
|
||||
if (elem.tick()) {
|
||||
m_out += elem.m_control.m_volume; // add 4 bit pulse output
|
||||
m_ch_out[elemIndex]=elem.m_control.m_volume;
|
||||
} else {
|
||||
m_ch_out[elemIndex]=0;
|
||||
}
|
||||
elemIndex++;
|
||||
}
|
||||
if (m_sawtooth.tick())
|
||||
if (m_sawtooth.tick()) {
|
||||
m_out += bitfield(m_sawtooth.m_accum, 3, 5); // add 5 bit sawtooth output
|
||||
m_ch_out[2]=bitfield(m_sawtooth.m_accum, 3, 5);
|
||||
} else {
|
||||
m_ch_out[2]=0;
|
||||
}
|
||||
}
|
||||
if (m_timer.tick())
|
||||
m_timer.counter_tick();
|
||||
|
@ -109,6 +119,7 @@ void vrcvi_core::reset()
|
|||
m_timer.reset();
|
||||
m_control.reset();
|
||||
m_out = 0;
|
||||
std::fill(std::begin(m_ch_out),std::end(m_ch_out),0);
|
||||
}
|
||||
|
||||
bool vrcvi_core::alu_t::tick()
|
||||
|
|
|
@ -62,6 +62,8 @@ public:
|
|||
|
||||
// 6 bit output
|
||||
s8 out() { return m_out; }
|
||||
// channel output
|
||||
s16 chan_out(u8 ch) { return m_ch_out[ch]; }
|
||||
private:
|
||||
// Common ALU for sound channels
|
||||
struct alu_t
|
||||
|
@ -233,6 +235,7 @@ private:
|
|||
vrcvi_intf &m_intf;
|
||||
|
||||
s8 m_out = 0; // 6 bit output
|
||||
s8 m_ch_out[3] = {0}; // per-channel output
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -63,6 +63,7 @@ public:
|
|||
|
||||
// getters
|
||||
s32 output(u8 channel) { return m_out[channel & 1]; }
|
||||
s32 chan_out(u8 channel) { return (m_voice[channel].data * (m_voice[channel].vol_out[0]+m_voice[channel].vol_out[1]))<<2; }
|
||||
|
||||
// internal state
|
||||
void reset();
|
||||
|
|
|
@ -107,6 +107,9 @@ void DivPlatformSwan::acquire(short* bufL, short* bufR, size_t start, size_t len
|
|||
ws->SoundFlush(samp, 1);
|
||||
bufL[h]=samp[0];
|
||||
bufR[h]=samp[1];
|
||||
for (int i=0; i<4; i++) {
|
||||
oscBuf[i]->data[oscBuf[i]->needle++]=(ws->sample_cache[i][0]+ws->sample_cache[i][1])<<6;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -457,6 +460,10 @@ void* DivPlatformSwan::getChanState(int ch) {
|
|||
return &chan[ch];
|
||||
}
|
||||
|
||||
DivDispatchOscBuffer* DivPlatformSwan::getOscBuffer(int ch) {
|
||||
return oscBuf[ch];
|
||||
}
|
||||
|
||||
unsigned char* DivPlatformSwan::getRegisterPool() {
|
||||
// get Random from emulator
|
||||
regPool[0x12]=ws->SoundRead(0x92);
|
||||
|
@ -532,6 +539,8 @@ int DivPlatformSwan::init(DivEngine* p, int channels, int sugRate, unsigned int
|
|||
rate=chipClock/16; // = 192000kHz, should be enough
|
||||
for (int i=0; i<4; i++) {
|
||||
isMuted[i]=false;
|
||||
oscBuf[i]=new DivDispatchOscBuffer;
|
||||
oscBuf[i]->rate=rate;
|
||||
}
|
||||
ws=new WSwan();
|
||||
reset();
|
||||
|
@ -539,6 +548,9 @@ int DivPlatformSwan::init(DivEngine* p, int channels, int sugRate, unsigned int
|
|||
}
|
||||
|
||||
void DivPlatformSwan::quit() {
|
||||
for (int i=0; i<4; i++) {
|
||||
delete oscBuf[i];
|
||||
}
|
||||
delete ws;
|
||||
}
|
||||
|
||||
|
|
|
@ -57,6 +57,7 @@ class DivPlatformSwan: public DivDispatch {
|
|||
wave(-1) {}
|
||||
};
|
||||
Channel chan[4];
|
||||
DivDispatchOscBuffer* oscBuf[4];
|
||||
bool isMuted[4];
|
||||
bool pcm, sweep, furnaceDac;
|
||||
unsigned char sampleBank, noise;
|
||||
|
@ -78,6 +79,7 @@ class DivPlatformSwan: public DivDispatch {
|
|||
void acquire(short* bufL, short* bufR, size_t start, size_t len);
|
||||
int dispatch(DivCommand c);
|
||||
void* getChanState(int chan);
|
||||
DivDispatchOscBuffer* getOscBuffer(int chan);
|
||||
unsigned char* getRegisterPool();
|
||||
int getRegisterPoolSize();
|
||||
void reset();
|
||||
|
|
|
@ -111,12 +111,20 @@ void DivPlatformVERA::acquire(short* bufL, short* bufR, size_t start, size_t len
|
|||
}
|
||||
int curLen=MIN(len,128);
|
||||
memset(buf,0,sizeof(buf));
|
||||
psg_render(psg,buf[0],buf[1],curLen);
|
||||
pcm_render(pcm,buf[2],buf[3],curLen);
|
||||
for (int i=0; i<curLen; i++) {
|
||||
psg_render(psg,&buf[0][i],&buf[1][i],1);
|
||||
bufL[pos]=(short)(((int)buf[0][i]+buf[2][i])/2);
|
||||
bufR[pos]=(short)(((int)buf[1][i]+buf[3][i])/2);
|
||||
pos++;
|
||||
|
||||
for (int i=0; i<16; i++) {
|
||||
oscBuf[i]->data[oscBuf[i]->needle++]=psg->channels[i].lastOut<<4;
|
||||
}
|
||||
int pcmOut=buf[2][i]+buf[3][i];
|
||||
if (pcmOut<-32768) pcmOut=-32768;
|
||||
if (pcmOut>32767) pcmOut=32767;
|
||||
oscBuf[16]->data[oscBuf[16]->needle++]=pcmOut;
|
||||
}
|
||||
len-=curLen;
|
||||
}
|
||||
|
@ -373,6 +381,10 @@ void* DivPlatformVERA::getChanState(int ch) {
|
|||
return &chan[ch];
|
||||
}
|
||||
|
||||
DivDispatchOscBuffer* DivPlatformVERA::getOscBuffer(int ch) {
|
||||
return oscBuf[ch];
|
||||
}
|
||||
|
||||
unsigned char* DivPlatformVERA::getRegisterPool() {
|
||||
return regPool;
|
||||
}
|
||||
|
@ -426,6 +438,7 @@ void DivPlatformVERA::poke(std::vector<DivRegWrite>& wlist) {
|
|||
int DivPlatformVERA::init(DivEngine* p, int channels, int sugRate, unsigned int flags) {
|
||||
for (int i=0; i<17; i++) {
|
||||
isMuted[i]=false;
|
||||
oscBuf[i]=new DivDispatchOscBuffer;
|
||||
}
|
||||
parent=p;
|
||||
psg=new struct VERA_PSG;
|
||||
|
@ -434,11 +447,17 @@ int DivPlatformVERA::init(DivEngine* p, int channels, int sugRate, unsigned int
|
|||
skipRegisterWrites=false;
|
||||
chipClock=25000000;
|
||||
rate=chipClock/512;
|
||||
for (int i=0; i<17; i++) {
|
||||
oscBuf[i]->rate=rate;
|
||||
}
|
||||
reset();
|
||||
return 17;
|
||||
}
|
||||
|
||||
void DivPlatformVERA::quit() {
|
||||
for (int i=0; i<17; i++) {
|
||||
delete oscBuf[i];
|
||||
}
|
||||
delete psg;
|
||||
delete pcm;
|
||||
}
|
||||
|
|
|
@ -53,6 +53,7 @@ class DivPlatformVERA: public DivDispatch {
|
|||
Channel(): freq(0), baseFreq(0), pitch(0), pitch2(0), note(0), ins(-1), pan(0), active(false), freqChanged(false), inPorta(false), vol(0), outVol(0), accum(0), noiseval(0) {}
|
||||
};
|
||||
Channel chan[17];
|
||||
DivDispatchOscBuffer* oscBuf[17];
|
||||
bool isMuted[17];
|
||||
unsigned char regPool[67];
|
||||
struct VERA_PSG* psg;
|
||||
|
@ -65,6 +66,7 @@ class DivPlatformVERA: public DivDispatch {
|
|||
void acquire(short* bufL, short* bufR, size_t start, size_t len);
|
||||
int dispatch(DivCommand c);
|
||||
void* getChanState(int chan);
|
||||
DivDispatchOscBuffer* getOscBuffer(int chan);
|
||||
unsigned char* getRegisterPool();
|
||||
int getRegisterPoolSize();
|
||||
void reset();
|
||||
|
|
|
@ -77,6 +77,9 @@ void DivPlatformVIC20::acquire(short* bufL, short* bufR, size_t start, size_t le
|
|||
vic_sound_machine_calculate_samples(vic,&samp,1,1,0,SAMP_DIVIDER);
|
||||
bufL[h]=samp;
|
||||
bufR[h]=samp;
|
||||
for (int i=0; i<4; i++) {
|
||||
oscBuf[i]->data[oscBuf[i]->needle++]=vic->ch[i].out?(vic->volume<<11):0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -275,6 +278,10 @@ void* DivPlatformVIC20::getChanState(int ch) {
|
|||
return &chan[ch];
|
||||
}
|
||||
|
||||
DivDispatchOscBuffer* DivPlatformVIC20::getOscBuffer(int ch) {
|
||||
return oscBuf[ch];
|
||||
}
|
||||
|
||||
unsigned char* DivPlatformVIC20::getRegisterPool() {
|
||||
return regPool;
|
||||
}
|
||||
|
@ -314,6 +321,9 @@ void DivPlatformVIC20::setFlags(unsigned int flags) {
|
|||
chipClock=COLOR_NTSC*2.0/7.0;
|
||||
}
|
||||
rate=chipClock/4;
|
||||
for (int i=0; i<4; i++) {
|
||||
oscBuf[i]->rate=rate;
|
||||
}
|
||||
}
|
||||
|
||||
void DivPlatformVIC20::poke(unsigned int addr, unsigned short val) {
|
||||
|
@ -330,6 +340,7 @@ int DivPlatformVIC20::init(DivEngine* p, int channels, int sugRate, unsigned int
|
|||
skipRegisterWrites=false;
|
||||
for (int i=0; i<4; i++) {
|
||||
isMuted[i]=false;
|
||||
oscBuf[i]=new DivDispatchOscBuffer;
|
||||
}
|
||||
setFlags(flags);
|
||||
vic=new sound_vic20_t();
|
||||
|
@ -338,6 +349,9 @@ int DivPlatformVIC20::init(DivEngine* p, int channels, int sugRate, unsigned int
|
|||
}
|
||||
|
||||
void DivPlatformVIC20::quit() {
|
||||
for (int i=0; i<4; i++) {
|
||||
delete oscBuf[i];
|
||||
}
|
||||
delete vic;
|
||||
}
|
||||
|
||||
|
|
|
@ -56,6 +56,7 @@ class DivPlatformVIC20: public DivDispatch {
|
|||
waveWriteCycle(-1) {}
|
||||
};
|
||||
Channel chan[4];
|
||||
DivDispatchOscBuffer* oscBuf[4];
|
||||
bool isMuted[4];
|
||||
bool hasWaveWrite;
|
||||
|
||||
|
@ -67,6 +68,7 @@ class DivPlatformVIC20: public DivDispatch {
|
|||
void acquire(short* bufL, short* bufR, size_t start, size_t len);
|
||||
int dispatch(DivCommand c);
|
||||
void* getChanState(int chan);
|
||||
DivDispatchOscBuffer* getOscBuffer(int chan);
|
||||
unsigned char* getRegisterPool();
|
||||
int getRegisterPoolSize();
|
||||
void reset();
|
||||
|
|
|
@ -97,6 +97,14 @@ void DivPlatformVRC6::acquire(short* bufL, short* bufR, size_t start, size_t len
|
|||
if (sample<-32768) sample=-32768;
|
||||
bufL[i]=bufR[i]=sample;
|
||||
|
||||
// Oscilloscope buffer part
|
||||
if (++writeOscBuf>=32) {
|
||||
writeOscBuf=0;
|
||||
for (int i=0; i<3; i++) {
|
||||
oscBuf[i]->data[oscBuf[i]->needle++]=vrc6.chan_out(i)<<10;
|
||||
}
|
||||
}
|
||||
|
||||
// Command part
|
||||
while (!writes.empty()) {
|
||||
QueuedWrite w=writes.front();
|
||||
|
@ -427,6 +435,10 @@ void* DivPlatformVRC6::getChanState(int ch) {
|
|||
return &chan[ch];
|
||||
}
|
||||
|
||||
DivDispatchOscBuffer* DivPlatformVRC6::getOscBuffer(int ch) {
|
||||
return oscBuf[ch];
|
||||
}
|
||||
|
||||
unsigned char* DivPlatformVRC6::getRegisterPool() {
|
||||
return regPool;
|
||||
}
|
||||
|
@ -471,6 +483,9 @@ void DivPlatformVRC6::setFlags(unsigned int flags) {
|
|||
rate=COLOR_NTSC/2.0;
|
||||
}
|
||||
chipClock=rate;
|
||||
for (int i=0; i<3; i++) {
|
||||
oscBuf[i]->rate=rate/32;
|
||||
}
|
||||
}
|
||||
|
||||
void DivPlatformVRC6::notifyInsDeletion(void* ins) {
|
||||
|
@ -491,8 +506,10 @@ int DivPlatformVRC6::init(DivEngine* p, int channels, int sugRate, unsigned int
|
|||
parent=p;
|
||||
dumpWrites=false;
|
||||
skipRegisterWrites=false;
|
||||
writeOscBuf=0;
|
||||
for (int i=0; i<3; i++) {
|
||||
isMuted[i]=false;
|
||||
oscBuf[i]=new DivDispatchOscBuffer;
|
||||
}
|
||||
setFlags(flags);
|
||||
reset();
|
||||
|
@ -500,6 +517,9 @@ int DivPlatformVRC6::init(DivEngine* p, int channels, int sugRate, unsigned int
|
|||
}
|
||||
|
||||
void DivPlatformVRC6::quit() {
|
||||
for (int i=0; i<3; i++) {
|
||||
delete oscBuf[i];
|
||||
}
|
||||
}
|
||||
|
||||
DivPlatformVRC6::~DivPlatformVRC6() {
|
||||
|
|
|
@ -65,6 +65,7 @@ class DivPlatformVRC6: public DivDispatch {
|
|||
outVol(15) {}
|
||||
};
|
||||
Channel chan[3];
|
||||
DivDispatchOscBuffer* oscBuf[3];
|
||||
bool isMuted[3];
|
||||
struct QueuedWrite {
|
||||
unsigned short addr;
|
||||
|
@ -73,6 +74,7 @@ class DivPlatformVRC6: public DivDispatch {
|
|||
};
|
||||
std::queue<QueuedWrite> writes;
|
||||
unsigned char sampleBank;
|
||||
unsigned char writeOscBuf;
|
||||
vrcvi_intf intf;
|
||||
vrcvi_core vrc6;
|
||||
unsigned char regPool[13];
|
||||
|
@ -83,6 +85,7 @@ class DivPlatformVRC6: public DivDispatch {
|
|||
void acquire(short* bufL, short* bufR, size_t start, size_t len);
|
||||
int dispatch(DivCommand c);
|
||||
void* getChanState(int chan);
|
||||
DivDispatchOscBuffer* getOscBuffer(int chan);
|
||||
unsigned char* getRegisterPool();
|
||||
int getRegisterPoolSize();
|
||||
void reset();
|
||||
|
|
|
@ -252,6 +252,10 @@ void DivPlatformX1_010::acquire(short* bufL, short* bufR, size_t start, size_t l
|
|||
//printf("tempL: %d tempR: %d\n",tempL,tempR);
|
||||
bufL[h]=stereo?tempL:((tempL+tempR)>>1);
|
||||
bufR[h]=stereo?tempR:bufL[h];
|
||||
|
||||
for (int i=0; i<16; i++) {
|
||||
oscBuf[i]->data[oscBuf[i]->needle++]=x1_010->chan_out(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -822,6 +826,10 @@ void* DivPlatformX1_010::getChanState(int ch) {
|
|||
return &chan[ch];
|
||||
}
|
||||
|
||||
DivDispatchOscBuffer* DivPlatformX1_010::getOscBuffer(int ch) {
|
||||
return oscBuf[ch];
|
||||
}
|
||||
|
||||
unsigned char* DivPlatformX1_010::getRegisterPool() {
|
||||
for (int i=0; i<0x2000; i++) {
|
||||
regPool[i]=x1_010->ram_r(i);
|
||||
|
@ -888,6 +896,9 @@ void DivPlatformX1_010::setFlags(unsigned int flags) {
|
|||
}
|
||||
rate=chipClock/512;
|
||||
stereo=flags&16;
|
||||
for (int i=0; i<16; i++) {
|
||||
oscBuf[i]->rate=rate;
|
||||
}
|
||||
}
|
||||
|
||||
void DivPlatformX1_010::poke(unsigned int addr, unsigned short val) {
|
||||
|
@ -905,6 +916,7 @@ int DivPlatformX1_010::init(DivEngine* p, int channels, int sugRate, unsigned in
|
|||
stereo=false;
|
||||
for (int i=0; i<16; i++) {
|
||||
isMuted[i]=false;
|
||||
oscBuf[i]=new DivDispatchOscBuffer;
|
||||
}
|
||||
setFlags(flags);
|
||||
intf.parent=parent;
|
||||
|
@ -915,6 +927,9 @@ int DivPlatformX1_010::init(DivEngine* p, int channels, int sugRate, unsigned in
|
|||
}
|
||||
|
||||
void DivPlatformX1_010::quit() {
|
||||
for (int i=0; i<16; i++) {
|
||||
delete oscBuf[i];
|
||||
}
|
||||
delete x1_010;
|
||||
}
|
||||
|
||||
|
|
|
@ -112,6 +112,7 @@ class DivPlatformX1_010: public DivDispatch {
|
|||
waveBank(0) {}
|
||||
};
|
||||
Channel chan[16];
|
||||
DivDispatchOscBuffer* oscBuf[16];
|
||||
bool isMuted[16];
|
||||
bool stereo=false;
|
||||
unsigned char sampleBank;
|
||||
|
@ -126,6 +127,7 @@ class DivPlatformX1_010: public DivDispatch {
|
|||
void acquire(short* bufL, short* bufR, size_t start, size_t len);
|
||||
int dispatch(DivCommand c);
|
||||
void* getChanState(int chan);
|
||||
DivDispatchOscBuffer* getOscBuffer(int chan);
|
||||
unsigned char* getRegisterPool();
|
||||
int getRegisterPoolSize();
|
||||
void reset();
|
||||
|
|
Loading…
Reference in New Issue