per-channel oscilloscope, part 3
K00/C64/NES fixed FDS, Game Boy and Sound Unit
This commit is contained in:
parent
312a037816
commit
1c3dcae05e
|
|
@ -63,9 +63,13 @@ void DivPlatformBubSysWSG::acquire(short* bufL, short* bufR, size_t start, size_
|
||||||
} else {
|
} else {
|
||||||
chanOut=chan[i].waveROM[k005289->addr(i)]*(regPool[2+i]&0xf);
|
chanOut=chan[i].waveROM[k005289->addr(i)]*(regPool[2+i]&0xf);
|
||||||
out+=chanOut;
|
out+=chanOut;
|
||||||
oscBuf[i]->data[oscBuf[i]->needle++]=chanOut;
|
if (writeOscBuf==0) {
|
||||||
|
oscBuf[i]->data[oscBuf[i]->needle++]=chanOut<<7;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (++writeOscBuf>=64) writeOscBuf=0;
|
||||||
|
|
||||||
out<<=6; // scale output to 16 bit
|
out<<=6; // scale output to 16 bit
|
||||||
|
|
||||||
|
|
@ -330,6 +334,9 @@ void DivPlatformBubSysWSG::notifyInsDeletion(void* ins) {
|
||||||
void DivPlatformBubSysWSG::setFlags(unsigned int flags) {
|
void DivPlatformBubSysWSG::setFlags(unsigned int flags) {
|
||||||
chipClock=COLOR_NTSC;
|
chipClock=COLOR_NTSC;
|
||||||
rate=chipClock;
|
rate=chipClock;
|
||||||
|
for (int i=0; i<2; i++) {
|
||||||
|
oscBuf[i]->rate=rate/64;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DivPlatformBubSysWSG::poke(unsigned int addr, unsigned short val) {
|
void DivPlatformBubSysWSG::poke(unsigned int addr, unsigned short val) {
|
||||||
|
|
@ -344,6 +351,7 @@ int DivPlatformBubSysWSG::init(DivEngine* p, int channels, int sugRate, unsigned
|
||||||
parent=p;
|
parent=p;
|
||||||
dumpWrites=false;
|
dumpWrites=false;
|
||||||
skipRegisterWrites=false;
|
skipRegisterWrites=false;
|
||||||
|
writeOscBuf=0;
|
||||||
for (int i=0; i<2; i++) {
|
for (int i=0; i<2; i++) {
|
||||||
isMuted[i]=false;
|
isMuted[i]=false;
|
||||||
oscBuf[i]=new DivDispatchOscBuffer;
|
oscBuf[i]=new DivDispatchOscBuffer;
|
||||||
|
|
|
||||||
|
|
@ -58,6 +58,7 @@ class DivPlatformBubSysWSG: public DivDispatch {
|
||||||
Channel chan[2];
|
Channel chan[2];
|
||||||
DivDispatchOscBuffer* oscBuf[2];
|
DivDispatchOscBuffer* oscBuf[2];
|
||||||
bool isMuted[2];
|
bool isMuted[2];
|
||||||
|
unsigned char writeOscBuf;
|
||||||
|
|
||||||
k005289_core* k005289;
|
k005289_core* k005289;
|
||||||
unsigned short regPool[4];
|
unsigned short regPool[4];
|
||||||
|
|
|
||||||
|
|
@ -114,9 +114,9 @@ void DivPlatformC64::acquire(short* bufL, short* bufR, size_t start, size_t len)
|
||||||
bufL[i]=sid.output();
|
bufL[i]=sid.output();
|
||||||
if (++writeOscBuf>=8) {
|
if (++writeOscBuf>=8) {
|
||||||
writeOscBuf=0;
|
writeOscBuf=0;
|
||||||
oscBuf[0]->data[oscBuf[0]->needle++]=sid.last_chan_out[0];
|
oscBuf[0]->data[oscBuf[0]->needle++]=sid.last_chan_out[0]>>5;
|
||||||
oscBuf[1]->data[oscBuf[1]->needle++]=sid.last_chan_out[1];
|
oscBuf[1]->data[oscBuf[1]->needle++]=sid.last_chan_out[1]>>5;
|
||||||
oscBuf[2]->data[oscBuf[2]->needle++]=sid.last_chan_out[2];
|
oscBuf[2]->data[oscBuf[2]->needle++]=sid.last_chan_out[2]>>5;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -85,6 +85,10 @@ void DivPlatformFDS::acquire(short* bufL, short* bufR, size_t start, size_t len)
|
||||||
if (sample>32767) sample=32767;
|
if (sample>32767) sample=32767;
|
||||||
if (sample<-32768) sample=-32768;
|
if (sample<-32768) sample=-32768;
|
||||||
bufL[i]=sample;
|
bufL[i]=sample;
|
||||||
|
if (++writeOscBuf>=32) {
|
||||||
|
writeOscBuf=0;
|
||||||
|
oscBuf->data[oscBuf->needle++]=sample<<1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -396,6 +400,10 @@ void* DivPlatformFDS::getChanState(int ch) {
|
||||||
return &chan[ch];
|
return &chan[ch];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DivDispatchOscBuffer* DivPlatformFDS::getOscBuffer(int ch) {
|
||||||
|
return oscBuf;
|
||||||
|
}
|
||||||
|
|
||||||
unsigned char* DivPlatformFDS::getRegisterPool() {
|
unsigned char* DivPlatformFDS::getRegisterPool() {
|
||||||
return regPool;
|
return regPool;
|
||||||
}
|
}
|
||||||
|
|
@ -436,6 +444,7 @@ void DivPlatformFDS::setFlags(unsigned int flags) {
|
||||||
rate=COLOR_NTSC/2.0;
|
rate=COLOR_NTSC/2.0;
|
||||||
}
|
}
|
||||||
chipClock=rate;
|
chipClock=rate;
|
||||||
|
oscBuf->rate=rate/32;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DivPlatformFDS::notifyInsDeletion(void* ins) {
|
void DivPlatformFDS::notifyInsDeletion(void* ins) {
|
||||||
|
|
@ -457,7 +466,9 @@ int DivPlatformFDS::init(DivEngine* p, int channels, int sugRate, unsigned int f
|
||||||
apuType=flags;
|
apuType=flags;
|
||||||
dumpWrites=false;
|
dumpWrites=false;
|
||||||
skipRegisterWrites=false;
|
skipRegisterWrites=false;
|
||||||
|
writeOscBuf=0;
|
||||||
fds=new struct _fds;
|
fds=new struct _fds;
|
||||||
|
oscBuf=new DivDispatchOscBuffer;
|
||||||
for (int i=0; i<1; i++) {
|
for (int i=0; i<1; i++) {
|
||||||
isMuted[i]=false;
|
isMuted[i]=false;
|
||||||
}
|
}
|
||||||
|
|
@ -468,6 +479,7 @@ int DivPlatformFDS::init(DivEngine* p, int channels, int sugRate, unsigned int f
|
||||||
}
|
}
|
||||||
|
|
||||||
void DivPlatformFDS::quit() {
|
void DivPlatformFDS::quit() {
|
||||||
|
delete oscBuf;
|
||||||
delete fds;
|
delete fds;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -64,9 +64,11 @@ class DivPlatformFDS: public DivDispatch {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
Channel chan[1];
|
Channel chan[1];
|
||||||
|
DivDispatchOscBuffer* oscBuf;
|
||||||
bool isMuted[1];
|
bool isMuted[1];
|
||||||
DivWaveSynth ws;
|
DivWaveSynth ws;
|
||||||
unsigned char apuType;
|
unsigned char apuType;
|
||||||
|
unsigned char writeOscBuf;
|
||||||
struct _fds* fds;
|
struct _fds* fds;
|
||||||
unsigned char regPool[128];
|
unsigned char regPool[128];
|
||||||
|
|
||||||
|
|
@ -78,6 +80,7 @@ class DivPlatformFDS: public DivDispatch {
|
||||||
void acquire(short* bufL, short* bufR, size_t start, size_t len);
|
void acquire(short* bufL, short* bufR, size_t start, size_t len);
|
||||||
int dispatch(DivCommand c);
|
int dispatch(DivCommand c);
|
||||||
void* getChanState(int chan);
|
void* getChanState(int chan);
|
||||||
|
DivDispatchOscBuffer* getOscBuffer(int chan);
|
||||||
unsigned char* getRegisterPool();
|
unsigned char* getRegisterPool();
|
||||||
int getRegisterPoolSize();
|
int getRegisterPoolSize();
|
||||||
void reset();
|
void reset();
|
||||||
|
|
|
||||||
|
|
@ -87,6 +87,10 @@ void DivPlatformGB::acquire(short* bufL, short* bufR, size_t start, size_t len)
|
||||||
GB_advance_cycles(gb,16);
|
GB_advance_cycles(gb,16);
|
||||||
bufL[i]=gb->apu_output.final_sample.left;
|
bufL[i]=gb->apu_output.final_sample.left;
|
||||||
bufR[i]=gb->apu_output.final_sample.right;
|
bufR[i]=gb->apu_output.final_sample.right;
|
||||||
|
|
||||||
|
for (int i=0; i<4; i++) {
|
||||||
|
oscBuf[i]->data[oscBuf[i]->needle++]=(gb->apu_output.current_sample[i].left+gb->apu_output.current_sample[i].right)<<6;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -429,6 +433,10 @@ void* DivPlatformGB::getChanState(int ch) {
|
||||||
return &chan[ch];
|
return &chan[ch];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DivDispatchOscBuffer* DivPlatformGB::getOscBuffer(int ch) {
|
||||||
|
return oscBuf[ch];
|
||||||
|
}
|
||||||
|
|
||||||
unsigned char* DivPlatformGB::getRegisterPool() {
|
unsigned char* DivPlatformGB::getRegisterPool() {
|
||||||
return regPool;
|
return regPool;
|
||||||
}
|
}
|
||||||
|
|
@ -495,20 +503,25 @@ void DivPlatformGB::poke(std::vector<DivRegWrite>& wlist) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int DivPlatformGB::init(DivEngine* p, int channels, int sugRate, unsigned int flags) {
|
int DivPlatformGB::init(DivEngine* p, int channels, int sugRate, unsigned int flags) {
|
||||||
|
chipClock=4194304;
|
||||||
|
rate=chipClock/16;
|
||||||
for (int i=0; i<4; i++) {
|
for (int i=0; i<4; i++) {
|
||||||
isMuted[i]=false;
|
isMuted[i]=false;
|
||||||
|
oscBuf[i]=new DivDispatchOscBuffer;
|
||||||
|
oscBuf[i]->rate=rate;
|
||||||
}
|
}
|
||||||
parent=p;
|
parent=p;
|
||||||
dumpWrites=false;
|
dumpWrites=false;
|
||||||
skipRegisterWrites=false;
|
skipRegisterWrites=false;
|
||||||
chipClock=4194304;
|
|
||||||
rate=chipClock/16;
|
|
||||||
gb=new GB_gameboy_t;
|
gb=new GB_gameboy_t;
|
||||||
reset();
|
reset();
|
||||||
return 4;
|
return 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DivPlatformGB::quit() {
|
void DivPlatformGB::quit() {
|
||||||
|
for (int i=0; i<4; i++) {
|
||||||
|
delete oscBuf[i];
|
||||||
|
}
|
||||||
delete gb;
|
delete gb;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -57,6 +57,7 @@ class DivPlatformGB: public DivDispatch {
|
||||||
wave(-1) {}
|
wave(-1) {}
|
||||||
};
|
};
|
||||||
Channel chan[4];
|
Channel chan[4];
|
||||||
|
DivDispatchOscBuffer* oscBuf[4];
|
||||||
bool isMuted[4];
|
bool isMuted[4];
|
||||||
unsigned char lastPan;
|
unsigned char lastPan;
|
||||||
DivWaveSynth ws;
|
DivWaveSynth ws;
|
||||||
|
|
@ -71,6 +72,7 @@ class DivPlatformGB: public DivDispatch {
|
||||||
void acquire(short* bufL, short* bufR, size_t start, size_t len);
|
void acquire(short* bufL, short* bufR, size_t start, size_t len);
|
||||||
int dispatch(DivCommand c);
|
int dispatch(DivCommand c);
|
||||||
void* getChanState(int chan);
|
void* getChanState(int chan);
|
||||||
|
DivDispatchOscBuffer* getOscBuffer(int chan);
|
||||||
unsigned char* getRegisterPool();
|
unsigned char* getRegisterPool();
|
||||||
int getRegisterPoolSize();
|
int getRegisterPoolSize();
|
||||||
void reset();
|
void reset();
|
||||||
|
|
|
||||||
|
|
@ -117,11 +117,11 @@ void DivPlatformNES::acquire(short* bufL, short* bufR, size_t start, size_t len)
|
||||||
bufL[i]=sample;
|
bufL[i]=sample;
|
||||||
if (++writeOscBuf>=32) {
|
if (++writeOscBuf>=32) {
|
||||||
writeOscBuf=0;
|
writeOscBuf=0;
|
||||||
oscBuf[0]->data[oscBuf[0]->needle++]=nes->S1.output<<7;
|
oscBuf[0]->data[oscBuf[0]->needle++]=nes->S1.output<<11;
|
||||||
oscBuf[1]->data[oscBuf[1]->needle++]=nes->S2.output<<7;
|
oscBuf[1]->data[oscBuf[1]->needle++]=nes->S2.output<<11;
|
||||||
oscBuf[2]->data[oscBuf[2]->needle++]=nes->TR.output<<7;
|
oscBuf[2]->data[oscBuf[2]->needle++]=nes->TR.output<<11;
|
||||||
oscBuf[3]->data[oscBuf[3]->needle++]=nes->NS.output<<7;
|
oscBuf[3]->data[oscBuf[3]->needle++]=nes->NS.output<<11;
|
||||||
oscBuf[4]->data[oscBuf[4]->needle++]=nes->DMC.output<<7;
|
oscBuf[4]->data[oscBuf[4]->needle++]=nes->DMC.output<<8;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -88,6 +88,12 @@ class SoundUnit {
|
||||||
bool muted[8];
|
bool muted[8];
|
||||||
void Write(unsigned char addr, unsigned char data);
|
void Write(unsigned char addr, unsigned char data);
|
||||||
void NextSample(short* l, short* r);
|
void NextSample(short* l, short* r);
|
||||||
|
inline int GetSample(int ch) {
|
||||||
|
int ret=(nsL[ch]+nsR[ch])>>1;
|
||||||
|
if (ret<-32768) ret=-32768;
|
||||||
|
if (ret>32767) ret=32767;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
void Init();
|
void Init();
|
||||||
void Reset();
|
void Reset();
|
||||||
SoundUnit();
|
SoundUnit();
|
||||||
|
|
|
||||||
|
|
@ -99,6 +99,9 @@ void DivPlatformSoundUnit::acquire(short* bufL, short* bufR, size_t start, size_
|
||||||
writes.pop();
|
writes.pop();
|
||||||
}
|
}
|
||||||
su->NextSample(&bufL[h],&bufR[h]);
|
su->NextSample(&bufL[h],&bufR[h]);
|
||||||
|
for (int i=0; i<8; i++) {
|
||||||
|
oscBuf[i]->data[oscBuf[i]->needle++]=su->GetSample(i);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -313,6 +316,10 @@ void* DivPlatformSoundUnit::getChanState(int ch) {
|
||||||
return &chan[ch];
|
return &chan[ch];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DivDispatchOscBuffer* DivPlatformSoundUnit::getOscBuffer(int ch) {
|
||||||
|
return oscBuf[ch];
|
||||||
|
}
|
||||||
|
|
||||||
unsigned char* DivPlatformSoundUnit::getRegisterPool() {
|
unsigned char* DivPlatformSoundUnit::getRegisterPool() {
|
||||||
return (unsigned char*)su->chan;
|
return (unsigned char*)su->chan;
|
||||||
}
|
}
|
||||||
|
|
@ -365,6 +372,9 @@ void DivPlatformSoundUnit::setFlags(unsigned int flags) {
|
||||||
chipClock=1236000;
|
chipClock=1236000;
|
||||||
}
|
}
|
||||||
rate=chipClock/4;
|
rate=chipClock/4;
|
||||||
|
for (int i=0; i<8; i++) {
|
||||||
|
oscBuf[i]->rate=rate;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DivPlatformSoundUnit::poke(unsigned int addr, unsigned short val) {
|
void DivPlatformSoundUnit::poke(unsigned int addr, unsigned short val) {
|
||||||
|
|
@ -381,6 +391,7 @@ int DivPlatformSoundUnit::init(DivEngine* p, int channels, int sugRate, unsigned
|
||||||
skipRegisterWrites=false;
|
skipRegisterWrites=false;
|
||||||
for (int i=0; i<8; i++) {
|
for (int i=0; i<8; i++) {
|
||||||
isMuted[i]=false;
|
isMuted[i]=false;
|
||||||
|
oscBuf[i]=new DivDispatchOscBuffer;
|
||||||
}
|
}
|
||||||
setFlags(flags);
|
setFlags(flags);
|
||||||
su=new SoundUnit();
|
su=new SoundUnit();
|
||||||
|
|
@ -390,6 +401,9 @@ int DivPlatformSoundUnit::init(DivEngine* p, int channels, int sugRate, unsigned
|
||||||
}
|
}
|
||||||
|
|
||||||
void DivPlatformSoundUnit::quit() {
|
void DivPlatformSoundUnit::quit() {
|
||||||
|
for (int i=0; i<8; i++) {
|
||||||
|
delete oscBuf[i];
|
||||||
|
}
|
||||||
delete su;
|
delete su;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -71,6 +71,7 @@ class DivPlatformSoundUnit: public DivDispatch {
|
||||||
wave(0) {}
|
wave(0) {}
|
||||||
};
|
};
|
||||||
Channel chan[8];
|
Channel chan[8];
|
||||||
|
DivDispatchOscBuffer* oscBuf[8];
|
||||||
bool isMuted[8];
|
bool isMuted[8];
|
||||||
struct QueuedWrite {
|
struct QueuedWrite {
|
||||||
unsigned char addr;
|
unsigned char addr;
|
||||||
|
|
@ -94,6 +95,7 @@ class DivPlatformSoundUnit: public DivDispatch {
|
||||||
void acquire(short* bufL, short* bufR, size_t start, size_t len);
|
void acquire(short* bufL, short* bufR, size_t start, size_t len);
|
||||||
int dispatch(DivCommand c);
|
int dispatch(DivCommand c);
|
||||||
void* getChanState(int chan);
|
void* getChanState(int chan);
|
||||||
|
DivDispatchOscBuffer* getOscBuffer(int chan);
|
||||||
unsigned char* getRegisterPool();
|
unsigned char* getRegisterPool();
|
||||||
int getRegisterPoolSize();
|
int getRegisterPoolSize();
|
||||||
void reset();
|
void reset();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue