Merge branch 'master' of https://github.com/tildearrow/furnace into ymf289b

This commit is contained in:
cam900 2023-01-14 12:11:26 +09:00
commit 3d345af1b8
149 changed files with 2940 additions and 1763 deletions

View file

@ -19,7 +19,7 @@
#include "../dispatch.h"
void DivDispatch::acquire(short* bufL, short* bufR, size_t start, size_t len) {
void DivDispatch::acquire(short** buf, size_t len) {
}
void DivDispatch::fillStream(std::vector<DivDelayedWrite>& stream, int sRate, size_t len) {
@ -69,8 +69,8 @@ int DivDispatch::dispatch(DivCommand c) {
void DivDispatch::reset() {
}
bool DivDispatch::isStereo() {
return false;
int DivDispatch::getOutputCount() {
return 1;
}
bool DivDispatch::keyOffAffectsArp(int ch) {

View file

@ -75,9 +75,9 @@ const char** DivPlatformAmiga::getRegisterSheet() {
if (chan[i+1].freq<AMIGA_DIVIDER) chan[i+1].freq=AMIGA_DIVIDER; \
}
void DivPlatformAmiga::acquire(short* bufL, short* bufR, size_t start, size_t len) {
void DivPlatformAmiga::acquire(short** buf, size_t len) {
static int outL, outR, output;
for (size_t h=start; h<start+len; h++) {
for (size_t h=0; h<len; h++) {
outL=0;
outR=0;
for (int i=0; i<4; i++) {
@ -142,8 +142,8 @@ void DivPlatformAmiga::acquire(short* bufL, short* bufR, size_t start, size_t le
filter[0][1]+=(filtConst*(filter[0][0]-filter[0][1]))>>12;
filter[1][0]+=(filtConst*(outR-filter[1][0]))>>12;
filter[1][1]+=(filtConst*(filter[1][0]-filter[1][1]))>>12;
bufL[h]=filter[0][1];
bufR[h]=filter[1][1];
buf[0][h]=filter[0][1];
buf[1][h]=filter[1][1];
}
}
@ -401,8 +401,8 @@ void DivPlatformAmiga::reset() {
filtConst=filterOn?filtConstOn:filtConstOff;
}
bool DivPlatformAmiga::isStereo() {
return true;
int DivPlatformAmiga::getOutputCount() {
return 2;
}
bool DivPlatformAmiga::keyOffAffectsArp(int ch) {

View file

@ -67,7 +67,7 @@ class DivPlatformAmiga: public DivDispatch {
friend void putDispatchChan(void*,int,int);
public:
void acquire(short* bufL, short* bufR, size_t start, size_t len);
void acquire(short** buf, size_t len);
int dispatch(DivCommand c);
void* getChanState(int chan);
DivDispatchOscBuffer* getOscBuffer(int chan);
@ -75,7 +75,7 @@ class DivPlatformAmiga: public DivDispatch {
void forceIns();
void tick(bool sysTick=true);
void muteChannel(int ch, bool mute);
bool isStereo();
int getOutputCount();
bool keyOffAffectsArp(int ch);
DivMacroInt* getChanMacroInt(int ch);
void setFlags(const DivConfig& flags);

View file

@ -19,6 +19,7 @@
#include "arcade.h"
#include "../engine.h"
#include "../../ta-log.h"
#include <string.h>
#include <math.h>
@ -50,10 +51,10 @@ const char** DivPlatformArcade::getRegisterSheet() {
return regCheatSheetOPM;
}
void DivPlatformArcade::acquire_nuked(short* bufL, short* bufR, size_t start, size_t len) {
void DivPlatformArcade::acquire_nuked(short** buf, size_t len) {
static int o[2];
for (size_t h=start; h<start+len; h++) {
for (size_t h=0; h<len; h++) {
for (int i=0; i<8; i++) {
if (!writes.empty() && !fm.write_busy) {
QueuedWrite& w=writes.front();
@ -84,17 +85,17 @@ void DivPlatformArcade::acquire_nuked(short* bufL, short* bufR, size_t start, si
if (o[1]<-32768) o[1]=-32768;
if (o[1]>32767) o[1]=32767;
bufL[h]=o[0];
bufR[h]=o[1];
buf[0][h]=o[0];
buf[1][h]=o[1];
}
}
void DivPlatformArcade::acquire_ymfm(short* bufL, short* bufR, size_t start, size_t len) {
void DivPlatformArcade::acquire_ymfm(short** buf, size_t len) {
static int os[2];
ymfm::ym2151::fm_engine* fme=fm_ymfm->debug_engine();
for (size_t h=start; h<start+len; h++) {
for (size_t h=0; h<len; h++) {
os[0]=0; os[1]=0;
if (!writes.empty()) {
if (--delay<1) {
@ -121,16 +122,16 @@ void DivPlatformArcade::acquire_ymfm(short* bufL, short* bufR, size_t start, siz
if (os[1]<-32768) os[1]=-32768;
if (os[1]>32767) os[1]=32767;
bufL[h]=os[0];
bufR[h]=os[1];
buf[0][h]=os[0];
buf[1][h]=os[1];
}
}
void DivPlatformArcade::acquire(short* bufL, short* bufR, size_t start, size_t len) {
void DivPlatformArcade::acquire(short** buf, size_t len) {
if (useYMFM) {
acquire_ymfm(bufL,bufR,start,len);
acquire_ymfm(buf,len);
} else {
acquire_nuked(bufL,bufR,start,len);
acquire_nuked(buf,len);
}
}
@ -868,25 +869,26 @@ void DivPlatformArcade::setFlags(const DivConfig& flags) {
switch (flags.getInt("clockSel",0)) {
case 1:
chipClock=COLOR_PAL*4.0/5.0;
baseFreqOff=12;
break;
case 2:
chipClock=4000000.0;
baseFreqOff=-122;
break;
default:
chipClock=COLOR_NTSC;
baseFreqOff=0;
break;
}
CHECK_CUSTOM_CLOCK;
baseFreqOff=round(768.0*(log((COLOR_NTSC/(double)chipClock))/log(2.0)));
rate=chipClock/64;
for (int i=0; i<8; i++) {
oscBuf[i]->rate=rate;
}
}
bool DivPlatformArcade::isStereo() {
return true;
int DivPlatformArcade::getOutputCount() {
return 2;
}
void DivPlatformArcade::setYMFM(bool use) {

View file

@ -58,13 +58,13 @@ class DivPlatformArcade: public DivPlatformOPM {
int octave(int freq);
int toFreq(int freq);
void acquire_nuked(short* bufL, short* bufR, size_t start, size_t len);
void acquire_ymfm(short* bufL, short* bufR, size_t start, size_t len);
void acquire_nuked(short** buf, size_t len);
void acquire_ymfm(short** buf, size_t len);
friend void putDispatchChan(void*,int,int);
friend void putDispatchChip(void*,int);
public:
void acquire(short* bufL, short* bufR, size_t start, size_t len);
void acquire(short** buf, size_t len);
int dispatch(DivCommand c);
void* getChanState(int chan);
DivDispatchOscBuffer* getOscBuffer(int chan);
@ -77,7 +77,7 @@ class DivPlatformArcade: public DivPlatformOPM {
DivMacroInt* getChanMacroInt(int ch);
void notifyInsChange(int ins);
void setFlags(const DivConfig& flags);
bool isStereo();
int getOutputCount();
void setYMFM(bool use);
void poke(unsigned int addr, unsigned short val);
void poke(std::vector<DivRegWrite>& wlist);

View file

@ -169,7 +169,7 @@ void DivPlatformAY8910::checkWrites() {
}
}
void DivPlatformAY8910::acquire(short* bufL, short* bufR, size_t start, size_t len) {
void DivPlatformAY8910::acquire(short** buf, size_t len) {
if (ayBufLen<len) {
ayBufLen=len;
for (int i=0; i<3; i++) {
@ -184,8 +184,8 @@ void DivPlatformAY8910::acquire(short* bufL, short* bufR, size_t start, size_t l
checkWrites();
ay->sound_stream_update(ayBuf,1);
bufL[i+start]=ayBuf[0][0];
bufR[i+start]=bufL[i+start];
buf[0][i]=ayBuf[0][0];
buf[1][i]=buf[0][i];
oscBuf[0]->data[oscBuf[0]->needle++]=sunsoftVolTable[31-(ay->lastIndx&31)]>>3;
oscBuf[1]->data[oscBuf[1]->needle++]=sunsoftVolTable[31-((ay->lastIndx>>5)&31)]>>3;
@ -198,11 +198,11 @@ void DivPlatformAY8910::acquire(short* bufL, short* bufR, size_t start, size_t l
ay->sound_stream_update(ayBuf,1);
if (stereo) {
bufL[i+start]=ayBuf[0][0]+ayBuf[1][0]+((ayBuf[2][0]*stereoSep)>>8);
bufR[i+start]=((ayBuf[0][0]*stereoSep)>>8)+ayBuf[1][0]+ayBuf[2][0];
buf[0][i]=ayBuf[0][0]+ayBuf[1][0]+((ayBuf[2][0]*stereoSep)>>8);
buf[1][i]=((ayBuf[0][0]*stereoSep)>>8)+ayBuf[1][0]+ayBuf[2][0];
} else {
bufL[i+start]=ayBuf[0][0]+ayBuf[1][0]+ayBuf[2][0];
bufR[i+start]=bufL[i+start];
buf[0][i]=ayBuf[0][0]+ayBuf[1][0]+ayBuf[2][0];
buf[1][i]=buf[0][i];
}
oscBuf[0]->data[oscBuf[0]->needle++]=ayBuf[0][0]<<2;
@ -337,6 +337,7 @@ void DivPlatformAY8910::tick(bool sysTick) {
chan[i].dac.rate=((double)rate*((sunsoft||clockSel)?8.0:16.0))/(double)(MAX(1,off*chan[i].freq));
if (dumpWrites) addWrite(0xffff0001+(i<<8),chan[i].dac.rate);
}
if (chan[i].freq<0) chan[i].freq=0;
if (chan[i].freq>4095) chan[i].freq=4095;
if (chan[i].keyOn) {
//rWrite(16+i*5+1,((chan[i].duty&3)<<6)|(63-(ins->gb.soundLen&63)));
@ -751,8 +752,8 @@ void DivPlatformAY8910::reset() {
portBVal=0;
}
bool DivPlatformAY8910::isStereo() {
return true;
int DivPlatformAY8910::getOutputCount() {
return 2;
}
bool DivPlatformAY8910::keyOffAffectsArp(int ch) {

View file

@ -128,7 +128,7 @@ class DivPlatformAY8910: public DivDispatch {
public:
void setExtClockDiv(unsigned int eclk=COLOR_NTSC, unsigned char ediv=8);
void acquire(short* bufL, short* bufR, size_t start, size_t len);
void acquire(short** buf, size_t len);
int dispatch(DivCommand c);
void* getChanState(int chan);
DivDispatchOscBuffer* getOscBuffer(int chan);
@ -140,7 +140,7 @@ class DivPlatformAY8910: public DivDispatch {
void tick(bool sysTick=true);
void muteChannel(int ch, bool mute);
void setFlags(const DivConfig& flags);
bool isStereo();
int getOutputCount();
bool keyOffAffectsArp(int ch);
DivMacroInt* getChanMacroInt(int ch);
bool getDCOffRequired();

View file

@ -164,7 +164,7 @@ void DivPlatformAY8930::checkWrites() {
}
}
void DivPlatformAY8930::acquire(short* bufL, short* bufR, size_t start, size_t len) {
void DivPlatformAY8930::acquire(short** buf, size_t len) {
if (ayBufLen<len) {
ayBufLen=len;
for (int i=0; i<3; i++) {
@ -179,11 +179,11 @@ void DivPlatformAY8930::acquire(short* bufL, short* bufR, size_t start, size_t l
ay->sound_stream_update(ayBuf,1);
if (stereo) {
bufL[i+start]=ayBuf[0][0]+ayBuf[1][0]+((ayBuf[2][0]*stereoSep)>>8);
bufR[i+start]=((ayBuf[0][0]*stereoSep)>>8)+ayBuf[1][0]+ayBuf[2][0];
buf[0][i]=ayBuf[0][0]+ayBuf[1][0]+((ayBuf[2][0]*stereoSep)>>8);
buf[1][i]=((ayBuf[0][0]*stereoSep)>>8)+ayBuf[1][0]+ayBuf[2][0];
} else {
bufL[i+start]=ayBuf[0][0]+ayBuf[1][0]+ayBuf[2][0];
bufR[i+start]=bufL[i+start];
buf[0][i]=ayBuf[0][0]+ayBuf[1][0]+ayBuf[2][0];
buf[1][i]=buf[0][i];
}
oscBuf[0]->data[oscBuf[0]->needle++]=ayBuf[0][0]<<2;
@ -270,7 +270,7 @@ void DivPlatformAY8930::tick(bool sysTick) {
if (chan[i].std.pitch.had) {
if (chan[i].std.pitch.mode) {
chan[i].pitch2+=chan[i].std.pitch.val;
CLAMP_VAR(chan[i].pitch2,-32768,32767);
CLAMP_VAR(chan[i].pitch2,-65535,65535);
} else {
chan[i].pitch2=chan[i].std.pitch.val;
}
@ -297,7 +297,7 @@ void DivPlatformAY8930::tick(bool sysTick) {
}
}
if (chan[i].std.ex1.had) { // duty
rWrite(0x16+i,chan[i].std.ex1.val);
immWrite(0x16+i,chan[i].std.ex1.val);
}
if (chan[i].std.ex2.had) {
chan[i].envelope.mode=chan[i].std.ex2.val;
@ -336,6 +336,7 @@ void DivPlatformAY8930::tick(bool sysTick) {
chan[i].dac.rate=((double)chipClock*4.0)/(double)(MAX(1,off*chan[i].freq));
if (dumpWrites) addWrite(0xffff0001+(i<<8),chan[i].dac.rate);
}
if (chan[i].freq<0) chan[i].freq=0;
if (chan[i].freq>65535) chan[i].freq=65535;
if (chan[i].keyOn) {
if (!chan[i].nextPSGMode.dac) {
@ -747,8 +748,8 @@ void DivPlatformAY8930::reset() {
immWrite(0x1a,0x00); // or mask
}
bool DivPlatformAY8930::isStereo() {
return true;
int DivPlatformAY8930::getOutputCount() {
return 2;
}
bool DivPlatformAY8930::keyOffAffectsArp(int ch) {
@ -808,6 +809,12 @@ void DivPlatformAY8930::setFlags(const DivConfig& flags) {
case 12:
chipClock=3600000;
break;
case 13:
chipClock=20000000/16;
break;
case 14:
chipClock=1536000;
break;
default:
chipClock=COLOR_NTSC/2.0;
break;

View file

@ -131,7 +131,7 @@ class DivPlatformAY8930: public DivDispatch {
friend void putDispatchChan(void*,int,int);
public:
void acquire(short* bufL, short* bufR, size_t start, size_t len);
void acquire(short** buf, size_t len);
int dispatch(DivCommand c);
void* getChanState(int chan);
DivDispatchOscBuffer* getOscBuffer(int chan);
@ -142,7 +142,7 @@ class DivPlatformAY8930: public DivDispatch {
void tick(bool sysTick=true);
void muteChannel(int ch, bool mute);
void setFlags(const DivConfig& flags);
bool isStereo();
int getOutputCount();
bool keyOffAffectsArp(int ch);
DivMacroInt* getChanMacroInt(int ch);
void notifyInsDeletion(void* ins);

View file

@ -39,9 +39,9 @@ const char** DivPlatformBubSysWSG::getRegisterSheet() {
return regCheatSheetBubSysWSG;
}
void DivPlatformBubSysWSG::acquire(short* bufL, short* bufR, size_t start, size_t len) {
void DivPlatformBubSysWSG::acquire(short** buf, size_t len) {
int chanOut=0;
for (size_t h=start; h<start+len; h++) {
for (size_t h=0; h<len; h++) {
signed int out=0;
// K005289 part
k005289.tick();
@ -68,7 +68,7 @@ void DivPlatformBubSysWSG::acquire(short* bufL, short* bufR, size_t start, size_
if (out>32767) out=32767;
//printf("out: %d\n",out);
bufL[h]=bufR[h]=out;
buf[0][h]=out;
}
}
@ -306,8 +306,8 @@ void DivPlatformBubSysWSG::reset() {
k005289.reset();
}
bool DivPlatformBubSysWSG::isStereo() {
return false;
int DivPlatformBubSysWSG::getOutputCount() {
return 1;
}
bool DivPlatformBubSysWSG::keyOffAffectsArp(int ch) {

View file

@ -45,7 +45,7 @@ class DivPlatformBubSysWSG: public DivDispatch {
friend void putDispatchChip(void*,int);
friend void putDispatchChan(void*,int,int);
public:
void acquire(short* bufL, short* bufR, size_t start, size_t len);
void acquire(short** buf, size_t len);
int dispatch(DivCommand c);
void* getChanState(int chan);
DivDispatchOscBuffer* getOscBuffer(int chan);
@ -56,7 +56,7 @@ class DivPlatformBubSysWSG: public DivDispatch {
void forceIns();
void tick(bool sysTick=true);
void muteChannel(int ch, bool mute);
bool isStereo();
int getOutputCount();
bool keyOffAffectsArp(int ch);
DivMacroInt* getChanMacroInt(int ch);
void setFlags(const DivConfig& flags);

View file

@ -63,9 +63,9 @@ const char** DivPlatformC64::getRegisterSheet() {
return regCheatSheetSID;
}
void DivPlatformC64::acquire(short* bufL, short* bufR, size_t start, size_t len) {
void DivPlatformC64::acquire(short** buf, size_t len) {
int dcOff=isFP?0:sid.get_dc(0);
for (size_t i=start; i<start+len; i++) {
for (size_t i=0; i<len; i++) {
if (!writes.empty()) {
QueuedWrite w=writes.front();
if (isFP) {
@ -77,7 +77,7 @@ void DivPlatformC64::acquire(short* bufL, short* bufR, size_t start, size_t len)
writes.pop();
}
if (isFP) {
sid_fp.clock(4,&bufL[i]);
sid_fp.clock(4,&buf[0][i]);
if (++writeOscBuf>=4) {
writeOscBuf=0;
oscBuf[0]->data[oscBuf[0]->needle++]=(sid_fp.lastChanOut[0]-dcOff)>>5;
@ -86,7 +86,7 @@ void DivPlatformC64::acquire(short* bufL, short* bufR, size_t start, size_t len)
}
} else {
sid.clock();
bufL[i]=sid.output();
buf[0][i]=sid.output();
if (++writeOscBuf>=16) {
writeOscBuf=0;
oscBuf[0]->data[oscBuf[0]->needle++]=(sid.last_chan_out[0]-dcOff)>>5;
@ -148,7 +148,7 @@ void DivPlatformC64::tick(bool sysTick) {
if (chan[i].std.pitch.had) {
if (chan[i].std.pitch.mode) {
chan[i].pitch2+=chan[i].std.pitch.val;
CLAMP_VAR(chan[i].pitch2,-32768,32767);
CLAMP_VAR(chan[i].pitch2,-65535,65535);
} else {
chan[i].pitch2=chan[i].std.pitch.val;
}
@ -188,6 +188,7 @@ void DivPlatformC64::tick(bool sysTick) {
if (chan[i].freqChanged || chan[i].keyOn || chan[i].keyOff) {
chan[i].freq=parent->calcFreq(chan[i].baseFreq,chan[i].pitch,chan[i].fixedArp?chan[i].baseNoteOverride:chan[i].arpOff,chan[i].fixedArp,false,8,chan[i].pitch2,chipClock,CHIP_FREQBASE);
if (chan[i].freq<0) chan[i].freq=0;
if (chan[i].freq>0xffff) chan[i].freq=0xffff;
if (chan[i].keyOn) {
rWrite(i*7+5,(chan[i].attack<<4)|(chan[i].decay));

View file

@ -79,7 +79,7 @@ class DivPlatformC64: public DivDispatch {
void updateFilter();
public:
void acquire(short* bufL, short* bufR, size_t start, size_t len);
void acquire(short** buf, size_t len);
int dispatch(DivCommand c);
void* getChanState(int chan);
DivDispatchOscBuffer* getOscBuffer(int chan);

View file

@ -24,9 +24,9 @@
#define CHIP_FREQBASE 2048
void DivPlatformDummy::acquire(short* bufL, short* bufR, size_t start, size_t len) {
void DivPlatformDummy::acquire(short** buf, size_t len) {
int chanOut;
for (size_t i=start; i<start+len; i++) {
for (size_t i=0; i<len; i++) {
int out=0;
for (unsigned char j=0; j<chans; j++) {
if (chan[j].active) {
@ -44,7 +44,7 @@ void DivPlatformDummy::acquire(short* bufL, short* bufR, size_t start, size_t le
}
if (out<-32768) out=-32768;
if (out>32767) out=32767;
bufL[i]=out;
buf[0][i]=out;
}
}

View file

@ -37,7 +37,7 @@ class DivPlatformDummy: public DivDispatch {
friend void putDispatchChip(void*,int);
friend void putDispatchChan(void*,int,int);
public:
void acquire(short* bufL, short* bufR, size_t start, size_t len);
void acquire(short** buf, size_t len);
void muteChannel(int ch, bool mute);
int dispatch(DivCommand c);
void* getChanState(int chan);

View file

@ -55,13 +55,13 @@ const char** DivPlatformFDS::getRegisterSheet() {
return regCheatSheetFDS;
}
void DivPlatformFDS::acquire_puNES(short* bufL, short* bufR, size_t start, size_t len) {
for (size_t i=start; i<start+len; i++) {
void DivPlatformFDS::acquire_puNES(short* buf, size_t len) {
for (size_t i=0; i<len; i++) {
extcl_apu_tick_FDS(fds);
int sample=isMuted[0]?0:fds->snd.main.output;
if (sample>32767) sample=32767;
if (sample<-32768) sample=-32768;
bufL[i]=sample;
buf[i]=sample;
if (++writeOscBuf>=32) {
writeOscBuf=0;
oscBuf->data[oscBuf->needle++]=sample<<1;
@ -69,15 +69,15 @@ void DivPlatformFDS::acquire_puNES(short* bufL, short* bufR, size_t start, size_
}
}
void DivPlatformFDS::acquire_NSFPlay(short* bufL, short* bufR, size_t start, size_t len) {
void DivPlatformFDS::acquire_NSFPlay(short* buf, size_t len) {
int out[2];
for (size_t i=start; i<start+len; i++) {
for (size_t i=0; i<len; i++) {
fds_NP->Tick(1);
fds_NP->Render(out);
int sample=isMuted[0]?0:(out[0]<<1);
if (sample>32767) sample=32767;
if (sample<-32768) sample=-32768;
bufL[i]=sample;
buf[i]=sample;
if (++writeOscBuf>=32) {
writeOscBuf=0;
oscBuf->data[oscBuf->needle++]=sample<<1;
@ -93,11 +93,11 @@ void DivPlatformFDS::doWrite(unsigned short addr, unsigned char data) {
}
}
void DivPlatformFDS::acquire(short* bufL, short* bufR, size_t start, size_t len) {
void DivPlatformFDS::acquire(short** buf, size_t len) {
if (useNP) {
acquire_NSFPlay(bufL,bufR,start,len);
acquire_NSFPlay(buf[0],len);
} else {
acquire_puNES(bufL,bufR,start,len);
acquire_puNES(buf[0],len);
}
}

View file

@ -62,11 +62,11 @@ class DivPlatformFDS: public DivDispatch {
friend void putDispatchChan(void*,int,int);
void doWrite(unsigned short addr, unsigned char data);
void acquire_puNES(short* bufL, short* bufR, size_t start, size_t len);
void acquire_NSFPlay(short* bufL, short* bufR, size_t start, size_t len);
void acquire_puNES(short* buf, size_t len);
void acquire_NSFPlay(short* buf, size_t len);
public:
void acquire(short* bufL, short* bufR, size_t start, size_t len);
void acquire(short** buf, size_t len);
int dispatch(DivCommand c);
void* getChanState(int chan);
DivMacroInt* getChanMacroInt(int ch);

View file

@ -51,7 +51,7 @@ inline void DivPlatformGA20::chWrite(unsigned char ch, unsigned int addr, unsign
}
}
void DivPlatformGA20::acquire(short* bufL, short* bufR, size_t start, size_t len) {
void DivPlatformGA20::acquire(short** buf, size_t len) {
if (ga20BufLen<len) {
ga20BufLen=len;
for (int i=0; i<4; i++) {
@ -60,7 +60,7 @@ void DivPlatformGA20::acquire(short* bufL, short* bufR, size_t start, size_t len
}
}
for (size_t h=start; h<start+len; h++) {
for (size_t h=0; h<len; h++) {
if ((--delay)<=0) {
delay=MAX(0,delay);
if (!writes.empty()) {
@ -73,7 +73,7 @@ void DivPlatformGA20::acquire(short* bufL, short* bufR, size_t start, size_t len
}
short *buffer[4] = {&ga20Buf[0][h],&ga20Buf[1][h],&ga20Buf[2][h],&ga20Buf[3][h]};
ga20.sound_stream_update(buffer, 1);
bufL[h]=(signed int)(ga20Buf[0][h]+ga20Buf[1][h]+ga20Buf[2][h]+ga20Buf[3][h])>>2;
buf[0][h]=(signed int)(ga20Buf[0][h]+ga20Buf[1][h]+ga20Buf[2][h]+ga20Buf[3][h])>>2;
for (int i=0; i<4; i++) {
oscBuf[i]->data[oscBuf[i]->needle++]=ga20Buf[i][h];
}
@ -361,8 +361,8 @@ void DivPlatformGA20::reset() {
}
}
bool DivPlatformGA20::isStereo() {
return false;
int DivPlatformGA20::getOutputCount() {
return 1;
}
void DivPlatformGA20::notifyInsChange(int ins) {

View file

@ -74,7 +74,7 @@ class DivPlatformGA20: public DivDispatch, public iremga20_intf {
void chWrite(unsigned char ch, unsigned int addr, unsigned char val);
public:
virtual u8 read_byte(u32 address) override;
virtual void acquire(short* bufL, short* bufR, size_t start, size_t len) override;
virtual void acquire(short** buf, size_t len) override;
virtual int dispatch(DivCommand c) override;
virtual void* getChanState(int chan) override;
virtual DivMacroInt* getChanMacroInt(int ch) override;
@ -85,7 +85,7 @@ class DivPlatformGA20: public DivDispatch, public iremga20_intf {
virtual void forceIns() override;
virtual void tick(bool sysTick=true) override;
virtual void muteChannel(int ch, bool mute) override;
virtual bool isStereo() override;
virtual int getOutputCount() override;
virtual void notifyInsChange(int ins) override;
virtual void notifyWaveChange(int wave) override;
virtual void notifyInsDeletion(void* ins) override;

View file

@ -61,8 +61,8 @@ const char** DivPlatformGB::getRegisterSheet() {
return regCheatSheetGB;
}
void DivPlatformGB::acquire(short* bufL, short* bufR, size_t start, size_t len) {
for (size_t i=start; i<start+len; i++) {
void DivPlatformGB::acquire(short** buf, size_t len) {
for (size_t i=0; i<len; i++) {
if (!writes.empty()) {
QueuedWrite& w=writes.front();
GB_apu_write(gb,w.addr,w.val);
@ -70,8 +70,8 @@ void DivPlatformGB::acquire(short* bufL, short* bufR, size_t start, size_t len)
}
GB_advance_cycles(gb,16);
bufL[i]=gb->apu_output.final_sample.left;
bufR[i]=gb->apu_output.final_sample.right;
buf[0][i]=gb->apu_output.final_sample.left;
buf[1][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;
@ -284,14 +284,14 @@ void DivPlatformGB::tick(bool sysTick) {
if (chan[i].freqChanged || chan[i].keyOn || chan[i].keyOff) {
if (i==3) { // noise
int ntPos=chan[i].baseFreq;
int ntPos=chan[i].baseFreq+chan[i].pitch2;
if (ntPos<0) ntPos=0;
if (ntPos>255) ntPos=255;
chan[i].freq=noiseTable[ntPos];
} else {
chan[i].freq=parent->calcFreq(chan[i].baseFreq,chan[i].pitch,chan[i].fixedArp?chan[i].baseNoteOverride:chan[i].arpOff,chan[i].fixedArp,true,0,chan[i].pitch2,chipClock,CHIP_DIVIDER);
if (chan[i].freq>2047) chan[i].freq=2047;
if (chan[i].freq<0) chan[i].freq=0;
if (chan[i].freq<1) chan[i].freq=1;
}
if (chan[i].keyOn) {
if (i==2) { // wave
@ -604,8 +604,8 @@ int DivPlatformGB::getPortaFloor(int ch) {
return 24;
}
bool DivPlatformGB::isStereo() {
return true;
int DivPlatformGB::getOutputCount() {
return 2;
}
bool DivPlatformGB::getDCOffRequired() {

View file

@ -78,7 +78,7 @@ class DivPlatformGB: public DivDispatch {
friend void putDispatchChip(void*,int);
friend void putDispatchChan(void*,int,int);
public:
void acquire(short* bufL, short* bufR, size_t start, size_t len);
void acquire(short** buf, size_t len);
int dispatch(DivCommand c);
void* getChanState(int chan);
DivMacroInt* getChanMacroInt(int ch);
@ -90,7 +90,7 @@ class DivPlatformGB: public DivDispatch {
void tick(bool sysTick=true);
void muteChannel(int ch, bool mute);
int getPortaFloor(int ch);
bool isStereo();
int getOutputCount();
bool getDCOffRequired();
void notifyInsChange(int ins);
void notifyWaveChange(int wave);

View file

@ -132,11 +132,11 @@ void DivPlatformGenesis::processDAC(int iRate) {
}
}
void DivPlatformGenesis::acquire_nuked(short* bufL, short* bufR, size_t start, size_t len) {
void DivPlatformGenesis::acquire_nuked(short** buf, size_t len) {
static short o[2];
static int os[2];
for (size_t h=start; h<start+len; h++) {
for (size_t h=0; h<len; h++) {
processDAC(rate);
os[0]=0; os[1]=0;
@ -186,17 +186,17 @@ void DivPlatformGenesis::acquire_nuked(short* bufL, short* bufR, size_t start, s
if (os[1]<-32768) os[1]=-32768;
if (os[1]>32767) os[1]=32767;
bufL[h]=os[0];
bufR[h]=os[1];
buf[0][h]=os[0];
buf[1][h]=os[1];
}
}
void DivPlatformGenesis::acquire_ymfm(short* bufL, short* bufR, size_t start, size_t len) {
void DivPlatformGenesis::acquire_ymfm(short** buf, size_t len) {
static int os[2];
ymfm::ym2612::fm_engine* fme=fm_ymfm->debug_engine();
for (size_t h=start; h<start+len; h++) {
for (size_t h=0; h<len; h++) {
processDAC(rate);
os[0]=0; os[1]=0;
@ -242,16 +242,16 @@ void DivPlatformGenesis::acquire_ymfm(short* bufL, short* bufR, size_t start, si
if (os[1]<-32768) os[1]=-32768;
if (os[1]>32767) os[1]=32767;
bufL[h]=os[0];
bufR[h]=os[1];
buf[0][h]=os[0];
buf[1][h]=os[1];
}
}
void DivPlatformGenesis::acquire(short* bufL, short* bufR, size_t start, size_t len) {
void DivPlatformGenesis::acquire(short** buf, size_t len) {
if (useYMFM) {
acquire_ymfm(bufL,bufR,start,len);
acquire_ymfm(buf,len);
} else {
acquire_nuked(bufL,bufR,start,len);
acquire_nuked(buf,len);
}
}
@ -1193,8 +1193,8 @@ void DivPlatformGenesis::reset() {
delay=0;
}
bool DivPlatformGenesis::isStereo() {
return true;
int DivPlatformGenesis::getOutputCount() {
return 2;
}
bool DivPlatformGenesis::keyOffAffectsArp(int ch) {

View file

@ -92,13 +92,13 @@ class DivPlatformGenesis: public DivPlatformOPN {
friend void putDispatchChan(void*,int,int);
inline void processDAC(int iRate);
void acquire_nuked(short* bufL, short* bufR, size_t start, size_t len);
void acquire_ymfm(short* bufL, short* bufR, size_t start, size_t len);
void acquire_nuked(short** buf, size_t len);
void acquire_ymfm(short** buf, size_t len);
friend void putDispatchChip(void*,int);
friend void putDispatchChan(void*,int,int);
public:
void acquire(short* bufL, short* bufR, size_t start, size_t len);
void acquire(short** buf, size_t len);
void fillStream(std::vector<DivDelayedWrite>& stream, int sRate, size_t len);
int dispatch(DivCommand c);
void* getChanState(int chan);
@ -110,7 +110,7 @@ class DivPlatformGenesis: public DivPlatformOPN {
void forceIns();
void tick(bool sysTick=true);
void muteChannel(int ch, bool mute);
bool isStereo();
int getOutputCount();
void setYMFM(bool use);
bool keyOffAffectsArp(int ch);
bool keyOffAffectsPorta(int ch);

View file

@ -54,8 +54,8 @@ inline void DivPlatformK007232::chWrite(unsigned char ch, unsigned int addr, uns
}
}
void DivPlatformK007232::acquire(short* bufL, short* bufR, size_t start, size_t len) {
for (size_t h=start; h<start+len; h++) {
void DivPlatformK007232::acquire(short** buf, size_t len) {
for (size_t h=0; h<len; h++) {
if ((--delay)<=0) {
delay=MAX(0,delay);
if (!writes.empty()) {
@ -76,15 +76,15 @@ void DivPlatformK007232::acquire(short* bufL, short* bufR, size_t start, size_t
const unsigned char vol1=regPool[0x10],vol2=regPool[0x11];
const signed int lout[2]={(k007232.output(0)*(vol1&0xf)),(k007232.output(1)*(vol2&0xf))};
const signed int rout[2]={(k007232.output(0)*((vol1>>4)&0xf)),(k007232.output(1)*((vol2>>4)&0xf))};
bufL[h]=(lout[0]+lout[1])<<4;
bufR[h]=(rout[0]+rout[1])<<4;
buf[0][h]=(lout[0]+lout[1])<<4;
buf[1][h]=(rout[0]+rout[1])<<4;
for (int i=0; i<2; i++) {
oscBuf[i]->data[oscBuf[i]->needle++]=(lout[i]+rout[i])<<4;
}
} else {
const unsigned char vol=regPool[0xc];
const signed int out[2]={(k007232.output(0)*(vol&0xf)),(k007232.output(1)*((vol>>4)&0xf))};
bufL[h]=bufR[h]=(out[0]+out[1])<<4;
buf[0][h]=(out[0]+out[1])<<4;
for (int i=0; i<2; i++) {
oscBuf[i]->data[oscBuf[i]->needle++]=out[i]<<5;
}
@ -448,8 +448,8 @@ void DivPlatformK007232::reset() {
}
}
bool DivPlatformK007232::isStereo() {
return stereo;
int DivPlatformK007232::getOutputCount() {
return stereo?2:1;
}
void DivPlatformK007232::notifyInsChange(int ins) {

View file

@ -80,7 +80,7 @@ class DivPlatformK007232: public DivDispatch, public k007232_intf {
void chWrite(unsigned char ch, unsigned int addr, unsigned char val);
public:
u8 read_sample(u8 ne, u32 address);
void acquire(short* bufL, short* bufR, size_t start, size_t len);
void acquire(short** buf, size_t len);
int dispatch(DivCommand c);
void* getChanState(int chan);
DivMacroInt* getChanMacroInt(int ch);
@ -91,7 +91,7 @@ class DivPlatformK007232: public DivDispatch, public k007232_intf {
void forceIns();
void tick(bool sysTick=true);
void muteChannel(int ch, bool mute);
bool isStereo();
int getOutputCount();
void notifyInsChange(int ins);
void notifyWaveChange(int wave);
void notifyInsDeletion(void* ins);

View file

@ -130,8 +130,8 @@ const char** DivPlatformLynx::getRegisterSheet() {
return regCheatSheetLynx;
}
void DivPlatformLynx::acquire(short* bufL, short* bufR, size_t start, size_t len) {
for (size_t h=start; h<start+len; h++) {
void DivPlatformLynx::acquire(short** buf, size_t len) {
for (size_t h=0; h<len; h++) {
for (int i=0; i<4; i++) {
if (chan[i].pcm && chan[i].sample>=0 && chan[i].sample<parent->song.sampleLen) {
chan[i].sampleAccum-=chan[i].sampleFreq;
@ -156,7 +156,7 @@ void DivPlatformLynx::acquire(short* bufL, short* bufR, size_t start, size_t len
}
}
mikey->sampleAudio( bufL + h, bufR + h, 1, oscBuf );
mikey->sampleAudio(buf[0]+h,buf[1]+h,1,oscBuf);
}
}
@ -393,8 +393,8 @@ void DivPlatformLynx::muteChannel(int ch, bool mute) {
if (chan[ch].active) WRITE_VOLUME(ch,(isMuted[ch]?0:(chan[ch].outVol&127)));
}
bool DivPlatformLynx::isStereo() {
return true;
int DivPlatformLynx::getOutputCount() {
return 2;
}
void DivPlatformLynx::forceIns() {
@ -509,12 +509,12 @@ DivPlatformLynx::MikeyFreqDiv::MikeyFreqDiv(int frequency) {
if (top>7)
{
clockDivider=top-7;
backup=frequency>>(top-7);
backup=clamped>>(top-7);
}
else
{
clockDivider=0;
backup=frequency;
backup=clamped;
}
}

View file

@ -68,7 +68,7 @@ class DivPlatformLynx: public DivDispatch {
friend void putDispatchChip(void*,int);
friend void putDispatchChan(void*,int,int);
public:
void acquire(short* bufL, short* bufR, size_t start, size_t len);
void acquire(short** buf, size_t len);
int dispatch(DivCommand c);
void* getChanState(int chan);
DivMacroInt* getChanMacroInt(int ch);
@ -79,7 +79,7 @@ class DivPlatformLynx: public DivDispatch {
void forceIns();
void tick(bool sysTick=true);
void muteChannel(int ch, bool mute);
bool isStereo();
int getOutputCount();
bool keyOffAffectsArp(int ch);
bool keyOffAffectsPorta(int ch);
//int getPortaFloor(int ch);

View file

@ -43,8 +43,8 @@ const char** DivPlatformMMC5::getRegisterSheet() {
return regCheatSheetMMC5;
}
void DivPlatformMMC5::acquire(short* bufL, short* bufR, size_t start, size_t len) {
for (size_t i=start; i<start+len; i++) {
void DivPlatformMMC5::acquire(short** buf, size_t len) {
for (size_t i=0; i<len; i++) {
if (dacSample!=-1) {
dacPeriod+=dacRate;
if (dacPeriod>=rate) {
@ -81,7 +81,7 @@ 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;
buf[0][i]=sample;
if (++writeOscBuf>=32) {
writeOscBuf=0;

View file

@ -50,7 +50,7 @@ class DivPlatformMMC5: public DivDispatch {
friend void putDispatchChan(void*,int,int);
public:
void acquire(short* bufL, short* bufR, size_t start, size_t len);
void acquire(short** buf, size_t len);
int dispatch(DivCommand c);
void* getChanState(int chan);
DivMacroInt* getChanMacroInt(int ch);

View file

@ -45,8 +45,8 @@ const char** DivPlatformMSM5232::getRegisterSheet() {
return regCheatSheetMSM5232;
}
void DivPlatformMSM5232::acquire(short* bufL, short* bufR, size_t start, size_t len) {
for (size_t h=start; h<start+len; h++) {
void DivPlatformMSM5232::acquire(short** buf, size_t len) {
for (size_t h=0; h<len; h++) {
while (!writes.empty()) {
QueuedWrite w=writes.front();
msm->write(w.addr,w.val);
@ -75,9 +75,9 @@ void DivPlatformMSM5232::acquire(short* bufL, short* bufR, size_t start, size_t
}
//printf("tempL: %d tempR: %d\n",tempL,tempR);
bufL[h]=0;
buf[0][h]=0;
for (int i=0; i<8; i++) {
bufL[h]+=(temp[i]*partVolume[i])>>8;
buf[0][h]+=(temp[i]*partVolume[i])>>8;
}
}
}
@ -371,8 +371,8 @@ void DivPlatformMSM5232::reset() {
}
}
bool DivPlatformMSM5232::isStereo() {
return false;
int DivPlatformMSM5232::getOutputCount() {
return 1;
}
bool DivPlatformMSM5232::keyOffAffectsArp(int ch) {

View file

@ -60,7 +60,7 @@ class DivPlatformMSM5232: public DivDispatch {
friend void putDispatchChip(void*,int);
friend void putDispatchChan(void*,int,int);
public:
void acquire(short* bufL, short* bufR, size_t start, size_t len);
void acquire(short** buf, size_t len);
int dispatch(DivCommand c);
void* getChanState(int chan);
DivMacroInt* getChanMacroInt(int ch);
@ -71,7 +71,7 @@ class DivPlatformMSM5232: public DivDispatch {
void forceIns();
void tick(bool sysTick=true);
void muteChannel(int ch, bool mute);
bool isStereo();
int getOutputCount();
bool keyOffAffectsArp(int ch);
void setFlags(const DivConfig& flags);
void notifyInsDeletion(void* ins);

View file

@ -30,12 +30,12 @@ const char** DivPlatformMSM6258::getRegisterSheet() {
return NULL;
}
void DivPlatformMSM6258::acquire(short* bufL, short* bufR, size_t start, size_t len) {
void DivPlatformMSM6258::acquire(short** buf, size_t len) {
short* outs[2]={
&msmOut,
NULL
};
for (size_t h=start; h<start+len; h++) {
for (size_t h=0; h<len; h++) {
if (--msmClockCount<0) {
if (--msmDividerCount<=0) {
if (!writes.empty()) {
@ -78,12 +78,12 @@ void DivPlatformMSM6258::acquire(short* bufL, short* bufR, size_t start, size_t
}
if (isMuted[0]) {
bufL[h]=0;
bufR[h]=0;
buf[0][h]=0;
buf[1][h]=0;
oscBuf[0]->data[oscBuf[0]->needle++]=0;
} else {
bufL[h]=(msmPan&2)?msmOut:0;
bufR[h]=(msmPan&1)?msmOut:0;
buf[0][h]=(msmPan&2)?msmOut:0;
buf[1][h]=(msmPan&1)?msmOut:0;
oscBuf[0]->data[oscBuf[0]->needle++]=msmPan?msmOut:0;
}
}
@ -336,8 +336,8 @@ void DivPlatformMSM6258::reset() {
delay=0;
}
bool DivPlatformMSM6258::isStereo() {
return true;
int DivPlatformMSM6258::getOutputCount() {
return 2;
}
bool DivPlatformMSM6258::keyOffAffectsArp(int ch) {

View file

@ -58,7 +58,7 @@ class DivPlatformMSM6258: public DivDispatch {
friend void putDispatchChan(void*,int,int);
public:
void acquire(short* bufL, short* bufR, size_t start, size_t len);
void acquire(short** buf, size_t len);
int dispatch(DivCommand c);
void* getChanState(int chan);
DivMacroInt* getChanMacroInt(int ch);
@ -69,7 +69,7 @@ class DivPlatformMSM6258: public DivDispatch {
void forceIns();
void tick(bool sysTick=true);
void muteChannel(int ch, bool mute);
bool isStereo();
int getOutputCount();
bool keyOffAffectsArp(int ch);
void notifyInsChange(int ins);
void notifyInsDeletion(void* ins);

View file

@ -37,8 +37,8 @@ u8 DivPlatformMSM6295::read_byte(u32 address) {
return adpcmMem[address&0x3ffff];
}
void DivPlatformMSM6295::acquire(short* bufL, short* bufR, size_t start, size_t len) {
for (size_t h=start; h<start+len; h++) {
void DivPlatformMSM6295::acquire(short** buf, size_t len) {
for (size_t h=0; h<len; h++) {
if (delay<=0) {
if (!writes.empty()) {
QueuedWrite& w=writes.front();
@ -75,7 +75,7 @@ void DivPlatformMSM6295::acquire(short* bufL, short* bufR, size_t start, size_t
msm.tick();
msm.tick();
bufL[h]=msm.out()<<4;
buf[0][h]=msm.out()<<4;
if (++updateOsc>=22) {
updateOsc=0;

View file

@ -64,7 +64,7 @@ class DivPlatformMSM6295: public DivDispatch, public vgsound_emu_mem_intf {
public:
virtual u8 read_byte(u32 address) override;
virtual void acquire(short* bufL, short* bufR, size_t start, size_t len) override;
virtual void acquire(short** buf, size_t len) override;
virtual int dispatch(DivCommand c) override;
virtual void* getChanState(int chan) override;
virtual DivMacroInt* getChanMacroInt(int ch) override;

View file

@ -108,13 +108,13 @@ const char** DivPlatformN163::getRegisterSheet() {
return regCheatSheetN163;
}
void DivPlatformN163::acquire(short* bufL, short* bufR, size_t start, size_t len) {
for (size_t i=start; i<start+len; i++) {
void DivPlatformN163::acquire(short** buf, size_t len) {
for (size_t i=0; i<len; i++) {
n163.tick();
int out=(n163.out()<<6)*2; // scale to 16 bit
if (out>32767) out=32767;
if (out<-32768) out=-32768;
bufL[i]=bufR[i]=out;
buf[0][i]=out;
if (n163.voice_cycle()==0x78) for (int i=0; i<8; i++) {
oscBuf[i]->data[oscBuf[i]->needle++]=n163.voice_out(i)<<7;

View file

@ -74,7 +74,7 @@ class DivPlatformN163: public DivDispatch {
friend void putDispatchChan(void*,int,int);
public:
void acquire(short* bufL, short* bufR, size_t start, size_t len);
void acquire(short** buf, size_t len);
int dispatch(DivCommand c);
void* getChanState(int chan);
DivMacroInt* getChanMacroInt(int ch);

View file

@ -151,7 +151,7 @@ const char** DivPlatformNamcoWSG::getRegisterSheet() {
return regCheatSheetNamcoWSG;
}
void DivPlatformNamcoWSG::acquire(short* bufL, short* bufR, size_t start, size_t len) {
void DivPlatformNamcoWSG::acquire(short** buf, size_t len) {
while (!writes.empty()) {
QueuedWrite w=writes.front();
switch (devType) {
@ -171,11 +171,11 @@ void DivPlatformNamcoWSG::acquire(short* bufL, short* bufR, size_t start, size_t
regPool[w.addr&0x3f]=w.val;
writes.pop();
}
for (size_t h=start; h<start+len; h++) {
short* buf[2]={
bufL+h, bufR+h
for (size_t h=0; h<len; h++) {
short* bufC[2]={
buf[0]+h, buf[1]+h
};
namco->sound_stream_update(buf,1);
namco->sound_stream_update(bufC,1);
for (int i=0; i<chans; i++) {
oscBuf[i]->data[oscBuf[i]->needle++]=namco->m_channel_list[i].last_out*chans;
}
@ -494,8 +494,8 @@ void DivPlatformNamcoWSG::reset() {
namco->device_start(NULL);
}
bool DivPlatformNamcoWSG::isStereo() {
return (devType==30);
int DivPlatformNamcoWSG::getOutputCount() {
return (devType==30)?2:1;
}
bool DivPlatformNamcoWSG::keyOffAffectsArp(int ch) {

View file

@ -54,7 +54,7 @@ class DivPlatformNamcoWSG: public DivDispatch {
friend void putDispatchChip(void*,int);
friend void putDispatchChan(void*,int,int);
public:
void acquire(short* bufL, short* bufR, size_t start, size_t len);
void acquire(short** buf, size_t len);
int dispatch(DivCommand c);
void* getChanState(int chan);
DivMacroInt* getChanMacroInt(int ch);
@ -65,7 +65,7 @@ class DivPlatformNamcoWSG: public DivDispatch {
void forceIns();
void tick(bool sysTick=true);
void muteChannel(int ch, bool mute);
bool isStereo();
int getOutputCount();
bool keyOffAffectsArp(int ch);
void setDeviceType(int type);
void setFlags(const DivConfig& flags);

View file

@ -100,8 +100,8 @@ void DivPlatformNES::doWrite(unsigned short addr, unsigned char data) {
} \
}
void DivPlatformNES::acquire_puNES(short* bufL, short* bufR, size_t start, size_t len) {
for (size_t i=start; i<start+len; i++) {
void DivPlatformNES::acquire_puNES(short** buf, size_t len) {
for (size_t i=0; i<len; i++) {
doPCM;
apu_tick(nes,NULL);
@ -112,7 +112,7 @@ void DivPlatformNES::acquire_puNES(short* bufL, short* bufR, size_t start, size_
int sample=(pulse_output(nes)+tnd_output(nes))<<6;
if (sample>32767) sample=32767;
if (sample<-32768) sample=-32768;
bufL[i]=sample;
buf[0][i]=sample;
if (++writeOscBuf>=32) {
writeOscBuf=0;
oscBuf[0]->data[oscBuf[0]->needle++]=isMuted[0]?0:(nes->S1.output<<11);
@ -124,10 +124,10 @@ void DivPlatformNES::acquire_puNES(short* bufL, short* bufR, size_t start, size_
}
}
void DivPlatformNES::acquire_NSFPlay(short* bufL, short* bufR, size_t start, size_t len) {
void DivPlatformNES::acquire_NSFPlay(short** buf, size_t len) {
int out1[2];
int out2[2];
for (size_t i=start; i<start+len; i++) {
for (size_t i=0; i<len; i++) {
doPCM;
nes1_NP->Tick(1);
@ -139,7 +139,7 @@ void DivPlatformNES::acquire_NSFPlay(short* bufL, short* bufR, size_t start, siz
int sample=(out1[0]+out1[1]+out2[0]+out2[1])<<1;
if (sample>32767) sample=32767;
if (sample<-32768) sample=-32768;
bufL[i]=sample;
buf[0][i]=sample;
if (++writeOscBuf>=32) {
writeOscBuf=0;
oscBuf[0]->data[oscBuf[0]->needle++]=nes1_NP->out[0]<<11;
@ -151,11 +151,11 @@ void DivPlatformNES::acquire_NSFPlay(short* bufL, short* bufR, size_t start, siz
}
}
void DivPlatformNES::acquire(short* bufL, short* bufR, size_t start, size_t len) {
void DivPlatformNES::acquire(short** buf, size_t len) {
if (useNP) {
acquire_NSFPlay(bufL,bufR,start,len);
acquire_NSFPlay(buf,len);
} else {
acquire_puNES(bufL,bufR,start,len);
acquire_puNES(buf,len);
}
}
@ -278,6 +278,7 @@ void DivPlatformNES::tick(bool sysTick) {
ntPos+=chan[i].arpOff;
}
}
ntPos+=chan[i].pitch2;
if (parent->song.properNoiseLayout) {
chan[i].freq=15-(ntPos&15);
} else {

View file

@ -68,11 +68,11 @@ class DivPlatformNES: public DivDispatch {
void doWrite(unsigned short addr, unsigned char data);
unsigned char calcDPCMRate(int inRate);
void acquire_puNES(short* bufL, short* bufR, size_t start, size_t len);
void acquire_NSFPlay(short* bufL, short* bufR, size_t start, size_t len);
void acquire_puNES(short** buf, size_t len);
void acquire_NSFPlay(short** buf, size_t len);
public:
void acquire(short* bufL, short* bufR, size_t start, size_t len);
void acquire(short** buf, size_t len);
int dispatch(DivCommand c);
void* getChanState(int chan);
DivMacroInt* getChanMacroInt(int ch);

View file

@ -159,13 +159,13 @@ const int orderedOpsL[4]={
#define ADDR_FREQH 0xb0
#define ADDR_LR_FB_ALG 0xc0
void DivPlatformOPL::acquire_nuked(short* bufL, short* bufR, size_t start, size_t len) {
static short o[2];
static int os[2];
void DivPlatformOPL::acquire_nuked(short** buf, size_t len) {
static short o[4];
static int os[4];
static ymfm::ymfm_output<2> aOut;
for (size_t h=start; h<start+len; h++) {
os[0]=0; os[1]=0;
for (size_t h=0; h<len; h++) {
os[0]=0; os[1]=0; os[2]=0; os[3]=0;
if (!writes.empty() && --delay<0) {
delay=1;
QueuedWrite& w=writes.front();
@ -194,11 +194,14 @@ void DivPlatformOPL::acquire_nuked(short* bufL, short* bufR, size_t start, size_
}
if (downsample) {
OPL3_GenerateResampled(&fm,o);
OPL3_Generate4ChResampled(&fm,o);
} else {
OPL3_Generate(&fm,o);
OPL3_Generate4Ch(&fm,o);
}
os[0]+=o[0]; os[1]+=o[1];
os[0]+=o[0];
os[1]+=o[1];
os[2]+=o[2];
os[3]+=o[3];
if (adpcmChan>=0) {
adpcmB->clock();
@ -225,6 +228,12 @@ void DivPlatformOPL::acquire_nuked(short* bufL, short* bufR, size_t start, size_
if (fm.channel[i].out[1]!=NULL) {
oscBuf[i]->data[oscBuf[i]->needle]+=*fm.channel[ch].out[1];
}
if (fm.channel[i].out[2]!=NULL) {
oscBuf[i]->data[oscBuf[i]->needle]+=*fm.channel[ch].out[2];
}
if (fm.channel[i].out[3]!=NULL) {
oscBuf[i]->data[oscBuf[i]->needle]+=*fm.channel[ch].out[3];
}
oscBuf[i]->data[oscBuf[i]->needle]<<=1;
oscBuf[i]->needle++;
}
@ -244,6 +253,12 @@ void DivPlatformOPL::acquire_nuked(short* bufL, short* bufR, size_t start, size_
if (fm.channel[i].out[1]!=NULL) {
oscBuf[i]->data[oscBuf[i]->needle]+=*fm.channel[ch].out[1];
}
if (fm.channel[i].out[2]!=NULL) {
oscBuf[i]->data[oscBuf[i]->needle]+=*fm.channel[ch].out[2];
}
if (fm.channel[i].out[3]!=NULL) {
oscBuf[i]->data[oscBuf[i]->needle]+=*fm.channel[ch].out[3];
}
oscBuf[i]->data[oscBuf[i]->needle]<<=1;
oscBuf[i]->needle++;
}
@ -254,19 +269,36 @@ void DivPlatformOPL::acquire_nuked(short* bufL, short* bufR, size_t start, size_
if (os[1]<-32768) os[1]=-32768;
if (os[1]>32767) os[1]=32767;
if (os[2]<-32768) os[2]=-32768;
if (os[2]>32767) os[2]=32767;
if (os[3]<-32768) os[3]=-32768;
if (os[3]>32767) os[3]=32767;
bufL[h]=os[0];
if (oplType==3 || oplType==759) {
bufR[h]=os[1];
buf[0][h]=os[0];
if (totalOutputs>1) {
buf[1][h]=os[1];
}
if (totalOutputs>2) {
buf[2][h]=os[2];
}
if (totalOutputs>3) {
buf[3][h]=os[3];
}
if (totalOutputs==6) {
// placeholder for OPL4
buf[4][h]=0;
buf[5][h]=0;
}
}
}
void DivPlatformOPL::acquire(short* bufL, short* bufR, size_t start, size_t len) {
void DivPlatformOPL::acquire(short** buf, size_t len) {
//if (useYMFM) {
// acquire_ymfm(bufL,bufR,start,len);
// acquire_ymfm(buf,len);
//} else {
acquire_nuked(bufL,bufR,start,len);
acquire_nuked(buf,len);
//}
}
@ -314,13 +346,13 @@ void DivPlatformOPL::tick(bool sysTick) {
}
if (oplType==3 && chan[i].std.panL.had) {
chan[i].pan=((chan[i].std.panL.val&1)<<1)|((chan[i].std.panL.val&2)>>1);
chan[i].pan=((chan[i].std.panL.val&1)<<1)|((chan[i].std.panL.val&2)>>1)|((chan[i].std.panL.val&4)<<1)|((chan[i].std.panL.val&8)>>1);
}
if (chan[i].std.pitch.had) {
if (chan[i].std.pitch.mode) {
chan[i].pitch2+=chan[i].std.pitch.val;
CLAMP_VAR(chan[i].pitch2,-32768,32767);
CLAMP_VAR(chan[i].pitch2,-131071,131071);
} else {
chan[i].pitch2=chan[i].std.pitch.val;
}
@ -347,9 +379,9 @@ void DivPlatformOPL::tick(bool sysTick) {
rWrite(chanMap[i+1]+ADDR_LR_FB_ALG,((chan[i].state.alg>>1)&1)|(chan[i].state.fb<<1));
}
} else {
rWrite(chanMap[i]+ADDR_LR_FB_ALG,(chan[i].state.alg&1)|(chan[i].state.fb<<1)|((chan[i].pan&3)<<4));
rWrite(chanMap[i]+ADDR_LR_FB_ALG,(chan[i].state.alg&1)|(chan[i].state.fb<<1)|((chan[i].pan&15)<<4));
if (ops==4) {
rWrite(chanMap[i+1]+ADDR_LR_FB_ALG,((chan[i].state.alg>>1)&1)|(chan[i].state.fb<<1)|((chan[i].pan&3)<<4));
rWrite(chanMap[i+1]+ADDR_LR_FB_ALG,((chan[i].state.alg>>1)&1)|(chan[i].state.fb<<1)|((chan[i].pan&15)<<4));
}
}
}
@ -659,9 +691,9 @@ void DivPlatformOPL::muteChannel(int ch, bool mute) {
rWrite(chanMap[ch+1]+ADDR_LR_FB_ALG,((chan[ch].state.alg>>1)&1)|(chan[ch].state.fb<<1));
}
} else {
rWrite(chanMap[ch]+ADDR_LR_FB_ALG,(chan[ch].state.alg&1)|(chan[ch].state.fb<<1)|((chan[ch].pan&3)<<4));
rWrite(chanMap[ch]+ADDR_LR_FB_ALG,(chan[ch].state.alg&1)|(chan[ch].state.fb<<1)|((chan[ch].pan&15)<<4));
if (ops==4) {
rWrite(chanMap[ch+1]+ADDR_LR_FB_ALG,((chan[ch].state.alg>>1)&1)|(chan[ch].state.fb<<1)|((chan[ch].pan&3)<<4));
rWrite(chanMap[ch+1]+ADDR_LR_FB_ALG,((chan[ch].state.alg>>1)&1)|(chan[ch].state.fb<<1)|((chan[ch].pan&15)<<4));
}
}
}
@ -797,7 +829,7 @@ int DivPlatformOPL::dispatch(DivCommand c) {
rWrite(chanMap[ch]+ADDR_LR_FB_ALG,(chan[ch].state.alg&1)|(chan[ch].state.fb<<1));
} else {
oldWrites[chanMap[ch]+ADDR_LR_FB_ALG]=-1;
rWrite(chanMap[ch]+ADDR_LR_FB_ALG,(chan[ch].state.alg&1)|(chan[ch].state.fb<<1)|((chan[ch].pan&3)<<4));
rWrite(chanMap[ch]+ADDR_LR_FB_ALG,(chan[ch].state.alg&1)|(chan[ch].state.fb<<1)|((chan[ch].pan&15)<<4));
}
}
} else {
@ -847,10 +879,10 @@ int DivPlatformOPL::dispatch(DivCommand c) {
}
} else {
oldWrites[chanMap[c.chan]+ADDR_LR_FB_ALG]=-1;
rWrite(chanMap[c.chan]+ADDR_LR_FB_ALG,(chan[c.chan].state.alg&1)|(chan[c.chan].state.fb<<1)|((chan[c.chan].pan&3)<<4));
rWrite(chanMap[c.chan]+ADDR_LR_FB_ALG,(chan[c.chan].state.alg&1)|(chan[c.chan].state.fb<<1)|((chan[c.chan].pan&15)<<4));
if (ops==4) {
oldWrites[chanMap[c.chan+1]+ADDR_LR_FB_ALG]=-1;
rWrite(chanMap[c.chan+1]+ADDR_LR_FB_ALG,((chan[c.chan].state.alg>>1)&1)|(chan[c.chan].state.fb<<1)|((chan[c.chan].pan&3)<<4));
rWrite(chanMap[c.chan+1]+ADDR_LR_FB_ALG,((chan[c.chan].state.alg>>1)&1)|(chan[c.chan].state.fb<<1)|((chan[c.chan].pan&15)<<4));
}
}
}
@ -956,10 +988,11 @@ int DivPlatformOPL::dispatch(DivCommand c) {
case DIV_CMD_PANNING: {
if (oplType!=3) break;
if (c.chan==adpcmChan) break;
if (c.value==0 && c.value2==0) {
chan[c.chan].pan=3;
chan[c.chan].pan&=~3;
if (c.value==0 && c.value2==0 && compatPan) {
chan[c.chan].pan|=3;
} else {
chan[c.chan].pan=(c.value>0)|((c.value2>0)<<1);
chan[c.chan].pan|=(c.value>0)|((c.value2>0)<<1);
}
int ops=(slots[3][c.chan]!=255 && chan[c.chan].state.ops==4 && oplType==3)?4:2;
if (isMuted[c.chan]) {
@ -968,9 +1001,36 @@ int DivPlatformOPL::dispatch(DivCommand c) {
rWrite(chanMap[c.chan+1]+ADDR_LR_FB_ALG,((chan[c.chan].state.alg>>1)&1)|(chan[c.chan].state.fb<<1));
}
} else {
rWrite(chanMap[c.chan]+ADDR_LR_FB_ALG,(chan[c.chan].state.alg&1)|(chan[c.chan].state.fb<<1)|((chan[c.chan].pan&3)<<4));
rWrite(chanMap[c.chan]+ADDR_LR_FB_ALG,(chan[c.chan].state.alg&1)|(chan[c.chan].state.fb<<1)|((chan[c.chan].pan&15)<<4));
if (ops==4) {
rWrite(chanMap[c.chan+1]+ADDR_LR_FB_ALG,((chan[c.chan].state.alg>>1)&1)|(chan[c.chan].state.fb<<1)|((chan[c.chan].pan&3)<<4));
rWrite(chanMap[c.chan+1]+ADDR_LR_FB_ALG,((chan[c.chan].state.alg>>1)&1)|(chan[c.chan].state.fb<<1)|((chan[c.chan].pan&15)<<4));
}
}
break;
}
case DIV_CMD_SURROUND_PANNING: {
if (oplType!=3) break;
if (c.chan==adpcmChan) break;
if (c.value==2) {
chan[c.chan].pan&=3;
if (c.value2>0) chan[c.chan].pan|=4;
} else if (c.value==3) {
if (c.value2>0) chan[c.chan].pan|=8;
} else {
break;
}
int ops=(slots[3][c.chan]!=255 && chan[c.chan].state.ops==4 && oplType==3)?4:2;
if (isMuted[c.chan]) {
rWrite(chanMap[c.chan]+ADDR_LR_FB_ALG,(chan[c.chan].state.alg&1)|(chan[c.chan].state.fb<<1));
if (ops==4) {
rWrite(chanMap[c.chan+1]+ADDR_LR_FB_ALG,((chan[c.chan].state.alg>>1)&1)|(chan[c.chan].state.fb<<1));
}
} else {
rWrite(chanMap[c.chan]+ADDR_LR_FB_ALG,(chan[c.chan].state.alg&1)|(chan[c.chan].state.fb<<1)|((chan[c.chan].pan&15)<<4));
if (ops==4) {
rWrite(chanMap[c.chan+1]+ADDR_LR_FB_ALG,((chan[c.chan].state.alg>>1)&1)|(chan[c.chan].state.fb<<1)|((chan[c.chan].pan&15)<<4));
}
}
break;
@ -1049,9 +1109,9 @@ int DivPlatformOPL::dispatch(DivCommand c) {
rWrite(chanMap[c.chan+1]+ADDR_LR_FB_ALG,((chan[c.chan].state.alg>>1)&1)|(chan[c.chan].state.fb<<1));
}
} else {
rWrite(chanMap[c.chan]+ADDR_LR_FB_ALG,(chan[c.chan].state.alg&1)|(chan[c.chan].state.fb<<1)|((chan[c.chan].pan&3)<<4));
rWrite(chanMap[c.chan]+ADDR_LR_FB_ALG,(chan[c.chan].state.alg&1)|(chan[c.chan].state.fb<<1)|((chan[c.chan].pan&15)<<4));
if (ops==4) {
rWrite(chanMap[c.chan+1]+ADDR_LR_FB_ALG,((chan[c.chan].state.alg>>1)&1)|(chan[c.chan].state.fb<<1)|((chan[c.chan].pan&3)<<4));
rWrite(chanMap[c.chan+1]+ADDR_LR_FB_ALG,((chan[c.chan].state.alg>>1)&1)|(chan[c.chan].state.fb<<1)|((chan[c.chan].pan&15)<<4));
}
}
break;
@ -1431,9 +1491,9 @@ void DivPlatformOPL::forceIns() {
rWrite(chanMap[i+1]+ADDR_LR_FB_ALG,((chan[i].state.alg>>1)&1)|(chan[i].state.fb<<1));
}
} else {
rWrite(chanMap[i]+ADDR_LR_FB_ALG,(chan[i].state.alg&1)|(chan[i].state.fb<<1)|((chan[i].pan&3)<<4));
rWrite(chanMap[i]+ADDR_LR_FB_ALG,(chan[i].state.alg&1)|(chan[i].state.fb<<1)|((chan[i].pan&15)<<4));
if (ops==4) {
rWrite(chanMap[i+1]+ADDR_LR_FB_ALG,((chan[i].state.alg>>1)&1)|(chan[i].state.fb<<1)|((chan[i].pan&3)<<4));
rWrite(chanMap[i+1]+ADDR_LR_FB_ALG,((chan[i].state.alg>>1)&1)|(chan[i].state.fb<<1)|((chan[i].pan&15)<<4));
}
}
*/
@ -1568,8 +1628,8 @@ void DivPlatformOPL::reset() {
immWrite(0xbd,(dam<<7)|(dvb<<6)|(properDrums<<5)|drumState);
}
bool DivPlatformOPL::isStereo() {
return (oplType==3 || oplType==759);
int DivPlatformOPL::getOutputCount() {
return totalOutputs;
}
bool DivPlatformOPL::keyOffAffectsArp(int ch) {
@ -1625,6 +1685,7 @@ void DivPlatformOPL::setOPLType(int type, bool drums) {
if (type==8950) {
adpcmChan=drums?11:9;
}
totalOutputs=1;
break;
case 3: case 4: case 759:
slotsNonDrums=slotsOPL3;
@ -1643,6 +1704,7 @@ void DivPlatformOPL::setOPLType(int type, bool drums) {
chipFreqBase=32768*684;
downsample=true;
}
totalOutputs=(type==4)?6:4;
break;
}
chipType=type;
@ -1681,6 +1743,8 @@ void DivPlatformOPL::setFlags(const DivConfig& flags) {
rate=chipClock/36;
}*/
compatPan=false;
switch (chipType) {
default:
case 1: case 2: case 8950:
@ -1736,12 +1800,14 @@ void DivPlatformOPL::setFlags(const DivConfig& flags) {
rate=chipClock/768;
chipRateBase=chipClock/684;
downsample=true;
totalOutputs=2; // Stereo output only
break;
default: // YMF262
chipFreqBase=32768*288;
rate=chipClock/288;
chipRateBase=rate;
downsample=false;
totalOutputs=4;
break;
}
reset();
@ -1768,6 +1834,7 @@ void DivPlatformOPL::setFlags(const DivConfig& flags) {
chipClock=rate*288;
break;
}
compatPan=flags.getBool("compatPan",false);
for (int i=0; i<20; i++) {
oscBuf[i]->rate=rate;

View file

@ -81,7 +81,7 @@ class DivPlatformOPL: public DivDispatch {
const unsigned short* chanMap;
const unsigned char* outChanMap;
int chipFreqBase, chipRateBase;
int delay, chipType, oplType, chans, melodicChans, totalChans, adpcmChan, sampleBank;
int delay, chipType, oplType, chans, melodicChans, totalChans, adpcmChan, sampleBank, totalOutputs;
unsigned char lastBusy;
unsigned char drumState;
unsigned char drumVol[5];
@ -92,7 +92,7 @@ class DivPlatformOPL: public DivDispatch {
unsigned char lfoValue;
bool useYMFM, update4OpMask, pretendYMU, downsample;
bool useYMFM, update4OpMask, pretendYMU, downsample, compatPan;
short oldWrites[512];
short pendingWrites[512];
@ -104,11 +104,11 @@ class DivPlatformOPL: public DivDispatch {
friend void putDispatchChip(void*,int);
friend void putDispatchChan(void*,int,int);
void acquire_nuked(short* bufL, short* bufR, size_t start, size_t len);
//void acquire_ymfm(short* bufL, short* bufR, size_t start, size_t len);
void acquire_nuked(short** buf, size_t len);
//void acquire_ymfm(short** buf, size_t len);
public:
void acquire(short* bufL, short* bufR, size_t start, size_t len);
void acquire(short** buf, size_t len);
int dispatch(DivCommand c);
void* getChanState(int chan);
DivMacroInt* getChanMacroInt(int ch);
@ -119,7 +119,7 @@ class DivPlatformOPL: public DivDispatch {
void forceIns();
void tick(bool sysTick=true);
void muteChannel(int ch, bool mute);
bool isStereo();
int getOutputCount();
void setYMFM(bool use);
void setOPLType(int type, bool drums);
bool keyOffAffectsArp(int ch);

View file

@ -39,11 +39,11 @@ const unsigned char visMapOPLL[9]={
6, 7, 8, 3, 4, 5, 0, 1, 2
};
void DivPlatformOPLL::acquire_nuked(short* bufL, short* bufR, size_t start, size_t len) {
void DivPlatformOPLL::acquire_nuked(short** buf, size_t len) {
static int o[2];
static int os;
for (size_t h=start; h<start+len; h++) {
for (size_t h=0; h<len; h++) {
os=0;
for (int i=0; i<9; i++) {
if (!writes.empty() && --delay<0) {
@ -83,15 +83,15 @@ void DivPlatformOPLL::acquire_nuked(short* bufL, short* bufR, size_t start, size
os*=50;
if (os<-32768) os=-32768;
if (os>32767) os=32767;
bufL[h]=os;
buf[0][h]=os;
}
}
void DivPlatformOPLL::acquire_ymfm(short* bufL, short* bufR, size_t start, size_t len) {
void DivPlatformOPLL::acquire_ymfm(short** buf, size_t len) {
}
void DivPlatformOPLL::acquire(short* bufL, short* bufR, size_t start, size_t len) {
acquire_nuked(bufL,bufR,start,len);
void DivPlatformOPLL::acquire(short** buf, size_t len) {
acquire_nuked(buf,len);
}
void DivPlatformOPLL::tick(bool sysTick) {
@ -124,7 +124,7 @@ void DivPlatformOPLL::tick(bool sysTick) {
if (chan[i].std.pitch.had) {
if (chan[i].std.pitch.mode) {
chan[i].pitch2+=chan[i].std.pitch.val;
CLAMP_VAR(chan[i].pitch2,-32768,32767);
CLAMP_VAR(chan[i].pitch2,-65535,65535);
} else {
chan[i].pitch2=chan[i].std.pitch.val;
}

View file

@ -77,11 +77,11 @@ class DivPlatformOPLL: public DivDispatch {
friend void putDispatchChip(void*,int);
friend void putDispatchChan(void*,int,int);
void acquire_nuked(short* bufL, short* bufR, size_t start, size_t len);
void acquire_ymfm(short* bufL, short* bufR, size_t start, size_t len);
void acquire_nuked(short** buf, size_t len);
void acquire_ymfm(short** buf, size_t len);
public:
void acquire(short* bufL, short* bufR, size_t start, size_t len);
void acquire(short** buf, size_t len);
int dispatch(DivCommand c);
void* getChanState(int chan);
DivMacroInt* getChanMacroInt(int ch);

View file

@ -53,8 +53,8 @@ const char** DivPlatformPCE::getRegisterSheet() {
return regCheatSheetPCE;
}
void DivPlatformPCE::acquire(short* bufL, short* bufR, size_t start, size_t len) {
for (size_t h=start; h<start+len; h++) {
void DivPlatformPCE::acquire(short** buf, size_t len) {
for (size_t h=0; h<len; h++) {
// PCM part
for (int i=0; i<6; i++) {
if (chan[i].pcm && chan[i].dacSample!=-1) {
@ -113,8 +113,8 @@ void DivPlatformPCE::acquire(short* bufL, short* bufR, size_t start, size_t len)
if (tempR[0]>32767) tempR[0]=32767;
//printf("tempL: %d tempR: %d\n",tempL,tempR);
bufL[h]=tempL[0];
bufR[h]=tempR[0];
buf[0][h]=tempL[0];
buf[1][h]=tempR[0];
}
}
@ -242,6 +242,7 @@ void DivPlatformPCE::tick(bool sysTick) {
chan[i].dacRate=((double)chipClock/2)/MAX(1,off*chan[i].freq);
if (dumpWrites) addWrite(0xffff0001+(i<<8),chan[i].dacRate);
}
if (chan[i].freq<1) chan[i].freq=1;
if (chan[i].freq>4095) chan[i].freq=4095;
chWrite(i,0x02,chan[i].freq&0xff);
chWrite(i,0x03,chan[i].freq>>8);
@ -547,8 +548,8 @@ void DivPlatformPCE::reset() {
delay=500;
}
bool DivPlatformPCE::isStereo() {
return true;
int DivPlatformPCE::getOutputCount() {
return 2;
}
bool DivPlatformPCE::keyOffAffectsArp(int ch) {

View file

@ -76,7 +76,7 @@ class DivPlatformPCE: public DivDispatch {
friend void putDispatchChip(void*,int);
friend void putDispatchChan(void*,int,int);
public:
void acquire(short* bufL, short* bufR, size_t start, size_t len);
void acquire(short** buf, size_t len);
int dispatch(DivCommand c);
void* getChanState(int chan);
DivMacroInt* getChanMacroInt(int ch);
@ -87,7 +87,7 @@ class DivPlatformPCE: public DivDispatch {
void forceIns();
void tick(bool sysTick=true);
void muteChannel(int ch, bool mute);
bool isStereo();
int getOutputCount();
bool keyOffAffectsArp(int ch);
void setFlags(const DivConfig& flags);
void notifyWaveChange(int wave);

View file

@ -26,13 +26,13 @@
// to ease the driver, freqency register is a 8.16 counter relative to output sample rate
#define CHIP_FREQBASE 65536
void DivPlatformPCMDAC::acquire(short* bufL, short* bufR, size_t start, size_t len) {
void DivPlatformPCMDAC::acquire(short** buf, size_t len) {
const int depthScale=(15-outDepth);
int output=0;
for (size_t h=start; h<start+len; h++) {
for (size_t h=0; h<len; h++) {
if (!chan[0].active || isMuted) {
bufL[h]=0;
bufR[h]=0;
buf[0][h]=0;
buf[1][h]=0;
oscBuf->data[oscBuf->needle++]=0;
continue;
}
@ -157,12 +157,12 @@ void DivPlatformPCMDAC::acquire(short* bufL, short* bufR, size_t start, size_t l
output=output*chan[0].vol*chan[0].envVol/16384;
oscBuf->data[oscBuf->needle++]=output;
if (outStereo) {
bufL[h]=((output*chan[0].panL)>>(depthScale+8))<<depthScale;
bufR[h]=((output*chan[0].panR)>>(depthScale+8))<<depthScale;
buf[0][h]=((output*chan[0].panL)>>(depthScale+8))<<depthScale;
buf[1][h]=((output*chan[0].panR)>>(depthScale+8))<<depthScale;
} else {
output=(output>>depthScale)<<depthScale;
bufL[h]=output;
bufR[h]=output;
buf[0][h]=output;
buf[1][h]=output;
}
}
}
@ -410,8 +410,8 @@ void DivPlatformPCMDAC::reset() {
chan[0].ws.init(NULL,32,255);
}
bool DivPlatformPCMDAC::isStereo() {
return true;
int DivPlatformPCMDAC::getOutputCount() {
return 2;
}
DivMacroInt* DivPlatformPCMDAC::getChanMacroInt(int ch) {

View file

@ -67,7 +67,7 @@ class DivPlatformPCMDAC: public DivDispatch {
friend void putDispatchChan(void*,int,int);
public:
void acquire(short* bufL, short* bufR, size_t start, size_t len);
void acquire(short** buf, size_t len);
int dispatch(DivCommand c);
void* getChanState(int chan);
DivDispatchOscBuffer* getOscBuffer(int chan);
@ -75,7 +75,7 @@ class DivPlatformPCMDAC: public DivDispatch {
void forceIns();
void tick(bool sysTick=true);
void muteChannel(int ch, bool mute);
bool isStereo();
int getOutputCount();
DivMacroInt* getChanMacroInt(int ch);
void setFlags(const DivConfig& flags);
void notifyInsChange(int ins);

View file

@ -193,9 +193,9 @@ const char** DivPlatformPCSpeaker::getRegisterSheet() {
const float cut=0.05;
const float reso=0.06;
void DivPlatformPCSpeaker::acquire_unfilt(short* bufL, short* bufR, size_t start, size_t len) {
void DivPlatformPCSpeaker::acquire_unfilt(short** buf, size_t len) {
int out=0;
for (size_t i=start; i<start+len; i++) {
for (size_t i=0; i<len; i++) {
if (on) {
pos-=PCSPKR_DIVIDER;
if (pos>freq) pos=freq;
@ -207,17 +207,17 @@ void DivPlatformPCSpeaker::acquire_unfilt(short* bufL, short* bufR, size_t start
}
}
out=(pos>(freq>>1) && !isMuted[0])?32767:0;
bufL[i]=out;
buf[0][i]=out;
oscBuf->data[oscBuf->needle++]=out;
} else {
bufL[i]=0;
buf[0][i]=0;
oscBuf->data[oscBuf->needle++]=0;
}
}
}
void DivPlatformPCSpeaker::acquire_cone(short* bufL, short* bufR, size_t start, size_t len) {
for (size_t i=start; i<start+len; i++) {
void DivPlatformPCSpeaker::acquire_cone(short** buf, size_t len) {
for (size_t i=0; i<len; i++) {
if (on) {
pos-=PCSPKR_DIVIDER;
if (pos>freq) pos=freq;
@ -234,17 +234,17 @@ void DivPlatformPCSpeaker::acquire_cone(short* bufL, short* bufR, size_t start,
float out=(low+band)*0.75;
if (out>1.0) out=1.0;
if (out<-1.0) out=-1.0;
bufL[i]=out*32767;
buf[0][i]=out*32767;
oscBuf->data[oscBuf->needle++]=out*32767;
} else {
bufL[i]=0;
buf[0][i]=0;
oscBuf->data[oscBuf->needle++]=0;
}
}
}
void DivPlatformPCSpeaker::acquire_piezo(short* bufL, short* bufR, size_t start, size_t len) {
for (size_t i=start; i<start+len; i++) {
void DivPlatformPCSpeaker::acquire_piezo(short** buf, size_t len) {
for (size_t i=0; i<len; i++) {
if (on) {
pos-=PCSPKR_DIVIDER;
if (pos>freq) pos=freq;
@ -261,10 +261,10 @@ void DivPlatformPCSpeaker::acquire_piezo(short* bufL, short* bufR, size_t start,
float out=band*0.15-(next-low)*0.06;
if (out>1.0) out=1.0;
if (out<-1.0) out=-1.0;
bufL[i]=out*32767;
buf[0][i]=out*32767;
oscBuf->data[oscBuf->needle++]=out*32767;
} else {
bufL[i]=0;
buf[0][i]=0;
oscBuf->data[oscBuf->needle++]=0;
}
}
@ -274,7 +274,7 @@ void DivPlatformPCSpeaker::beepFreq(int freq, int delay) {
realQueueLock.lock();
#ifdef __linux__
struct timespec ts;
double addition=1000000000.0*(double)delay/(double)rate;
double addition=1000000000.0*(double)delay/parent->getAudioDescGot().rate;
addition+=1500000000.0*((double)parent->getAudioDescGot().bufsize/parent->getAudioDescGot().rate);
if (clock_gettime(CLOCK_MONOTONIC,&ts)<0) {
ts.tv_sec=0;
@ -294,14 +294,14 @@ void DivPlatformPCSpeaker::beepFreq(int freq, int delay) {
realOutCond.notify_one();
}
void DivPlatformPCSpeaker::acquire_real(short* bufL, short* bufR, size_t start, size_t len) {
void DivPlatformPCSpeaker::acquire_real(short** buf, size_t len) {
int out=0;
if (lastOn!=on || lastFreq!=freq) {
lastOn=on;
lastFreq=freq;
beepFreq((on && !isMuted[0])?freq:0,start);
beepFreq((on && !isMuted[0])?freq:0,parent->getBufferPos());
}
for (size_t i=start; i<start+len; i++) {
for (size_t i=0; i<len; i++) {
if (on) {
pos-=PCSPKR_DIVIDER;
if (pos>freq) pos=freq;
@ -317,23 +317,23 @@ void DivPlatformPCSpeaker::acquire_real(short* bufL, short* bufR, size_t start,
} else {
oscBuf->data[oscBuf->needle++]=0;
}
bufL[i]=0;
buf[0][i]=0;
}
}
void DivPlatformPCSpeaker::acquire(short* bufL, short* bufR, size_t start, size_t len) {
void DivPlatformPCSpeaker::acquire(short** buf, size_t len) {
switch (speakerType) {
case 0:
acquire_unfilt(bufL,bufR,start,len);
acquire_unfilt(buf,len);
break;
case 1:
acquire_cone(bufL,bufR,start,len);
acquire_cone(buf,len);
break;
case 2:
acquire_piezo(bufL,bufR,start,len);
acquire_piezo(buf,len);
break;
case 3:
acquire_real(bufL,bufR,start,len);
acquire_real(buf,len);
break;
}
}

View file

@ -61,14 +61,14 @@ class DivPlatformPCSpeaker: public DivDispatch {
void beepFreq(int freq, int delay=0);
void acquire_unfilt(short* bufL, short* bufR, size_t start, size_t len);
void acquire_cone(short* bufL, short* bufR, size_t start, size_t len);
void acquire_piezo(short* bufL, short* bufR, size_t start, size_t len);
void acquire_real(short* bufL, short* bufR, size_t start, size_t len);
void acquire_unfilt(short** buf, size_t len);
void acquire_cone(short** buf, size_t len);
void acquire_piezo(short** buf, size_t len);
void acquire_real(short** buf, size_t len);
public:
void pcSpeakerThread();
void acquire(short* bufL, short* bufR, size_t start, size_t len);
void acquire(short** buf, size_t len);
int dispatch(DivCommand c);
void* getChanState(int chan);
DivMacroInt* getChanMacroInt(int ch);

View file

@ -55,14 +55,14 @@ void DivPlatformPET::rWrite(unsigned int addr, unsigned char val) {
regPool[addr]=val;
}
void DivPlatformPET::acquire(short* bufL, short* bufR, size_t start, size_t len) {
void DivPlatformPET::acquire(short** buf, size_t len) {
bool hwSROutput=((regPool[11]>>2)&7)==4;
if (chan[0].enable) {
int reload=regPool[8]*2+4;
if (!hwSROutput) {
reload+=regPool[9]*512;
}
for (size_t h=start; h<start+len; h++) {
for (size_t h=0; h<len; h++) {
if (SAMP_DIVIDER>chan[0].cnt) {
chan[0].out=(chan[0].sreg&1)*32767;
chan[0].sreg=(chan[0].sreg>>1)|((chan[0].sreg&1)<<7);
@ -70,17 +70,15 @@ void DivPlatformPET::acquire(short* bufL, short* bufR, size_t start, size_t len)
} else {
chan[0].cnt-=SAMP_DIVIDER;
}
bufL[h]=chan[0].out;
bufR[h]=chan[0].out;
buf[0][h]=chan[0].out;
oscBuf->data[oscBuf->needle++]=chan[0].out;
}
// emulate driver writes to PCR
if (!hwSROutput) regPool[12]=chan[0].out?0xe0:0xc0;
} else {
chan[0].out=0;
for (size_t h=start; h<start+len; h++) {
bufL[h]=0;
bufR[h]=0;
for (size_t h=0; h<len; h++) {
buf[0][h]=0;
oscBuf->data[oscBuf->needle++]=0;
}
}
@ -287,8 +285,8 @@ void DivPlatformPET::reset() {
chan[0].std.setEngine(parent);
}
bool DivPlatformPET::isStereo() {
return false;
int DivPlatformPET::getOutputCount() {
return 1;
}
void DivPlatformPET::notifyInsDeletion(void* ins) {

View file

@ -45,7 +45,7 @@ class DivPlatformPET: public DivDispatch {
friend void putDispatchChip(void*,int);
friend void putDispatchChan(void*,int,int);
public:
void acquire(short* bufL, short* bufR, size_t start, size_t len);
void acquire(short** buf, size_t len);
int dispatch(DivCommand c);
void* getChanState(int chan);
DivMacroInt* getChanMacroInt(int ch);
@ -57,7 +57,7 @@ class DivPlatformPET: public DivDispatch {
void tick(bool sysTick=true);
void muteChannel(int ch, bool mute);
void notifyInsDeletion(void* ins);
bool isStereo();
int getOutputCount();
void poke(unsigned int addr, unsigned short val);
void poke(std::vector<DivRegWrite>& wlist);
const char** getRegisterSheet();

View file

@ -86,9 +86,9 @@ void DivPlatformPokeMini::rWrite(unsigned char addr, unsigned char val) {
}
}
void DivPlatformPokeMini::acquire(short* bufL, short* bufR, size_t start, size_t len) {
void DivPlatformPokeMini::acquire(short** buf, size_t len) {
int out=0;
for (size_t i=start; i<start+len; i++) {
for (size_t i=0; i<len; i++) {
for (int j=0; j<PCSPKR_DIVIDER; j++) {
elapsedMain++;
if (on) {
@ -102,10 +102,10 @@ void DivPlatformPokeMini::acquire(short* bufL, short* bufR, size_t start, size_t
}
if (on) {
out=(pos>=pivot && !isMuted[0])?volTable[vol&3]:0;
bufL[i]=out;
buf[0][i]=out;
oscBuf->data[oscBuf->needle++]=out;
} else {
bufL[i]=0;
buf[0][i]=0;
oscBuf->data[oscBuf->needle++]=0;
}
}

View file

@ -46,7 +46,7 @@ class DivPlatformPokeMini: public DivDispatch {
friend void putDispatchChan(void*,int,int);
public:
void acquire(short* bufL, short* bufR, size_t start, size_t len);
void acquire(short** buf, size_t len);
int dispatch(DivCommand c);
void* getChanState(int chan);
DivMacroInt* getChanMacroInt(int ch);

View file

@ -64,16 +64,16 @@ const char** DivPlatformPOKEY::getRegisterSheet() {
return regCheatSheetPOKEY;
}
void DivPlatformPOKEY::acquire(short* bufL, short* bufR, size_t start, size_t len) {
void DivPlatformPOKEY::acquire(short** buf, size_t len) {
if (useAltASAP) {
acquireASAP(bufL, start, len);
acquireASAP(buf[0],len);
} else {
acquireMZ(bufL, start, len);
acquireMZ(buf[0],len);
}
}
void DivPlatformPOKEY::acquireMZ(short* buf, size_t start, size_t len) {
for (size_t h=start; h<start+len; h++) {
void DivPlatformPOKEY::acquireMZ(short* buf, size_t len) {
for (size_t h=0; h<len; h++) {
while (!writes.empty()) {
QueuedWrite w=writes.front();
Update_pokey_sound_mz(&pokey,w.addr,w.val,0);
@ -93,14 +93,14 @@ void DivPlatformPOKEY::acquireMZ(short* buf, size_t start, size_t len) {
}
}
void DivPlatformPOKEY::acquireASAP(short* buf, size_t start, size_t len) {
void DivPlatformPOKEY::acquireASAP(short* buf, size_t len) {
while (!writes.empty()) {
QueuedWrite w=writes.front();
altASAP.write(w.addr, w.val);
writes.pop();
}
for (size_t h=start; h<start+len; h++) {
for (size_t h=0; h<len; h++) {
if (++oscBufDelay>=2) {
oscBufDelay=0;
buf[h]=altASAP.sampleAudio(oscBuf);
@ -241,7 +241,7 @@ void DivPlatformPOKEY::tick(bool sysTick) {
chan[i].ctlChanged=false;
if ((i==1 && audctl&16) || (i==3 && audctl&8)) {
// ignore - channel is paired
} else if ((i==0 && audctl&16) || (i==0 && audctl&8)) {
} else if ((i==0 && audctl&16) || (i==2 && audctl&8)) {
rWrite(1+(i<<1),0);
rWrite(3+(i<<1),val);
} else {

View file

@ -58,9 +58,9 @@ class DivPlatformPOKEY: public DivDispatch {
friend void putDispatchChip(void*,int);
friend void putDispatchChan(void*,int,int);
public:
void acquire(short* bufL, short* bufR, size_t start, size_t len);
void acquireMZ(short* buf, size_t start, size_t len);
void acquireASAP(short* buf, size_t start, size_t len);
void acquire(short** buf, size_t len);
void acquireMZ(short* buf, size_t len);
void acquireASAP(short* buf, size_t len);
int dispatch(DivCommand c);
void* getChanState(int chan);
DivMacroInt* getChanMacroInt(int ch);

View file

@ -23,19 +23,19 @@
#define CHIP_DIVIDER 1024
void DivPlatformPong::acquire(short* bufL, short* bufR, size_t start, size_t len) {
void DivPlatformPong::acquire(short** buf, size_t len) {
int out=0;
for (size_t i=start; i<start+len; i++) {
for (size_t i=0; i<len; i++) {
if (on) {
if (--pos<=0) {
pos=(freq?2:1)<<4;
flip=!flip;
}
out=(flip && !isMuted[0])?32767:0;
bufL[i]=out;
buf[0][i]=out;
oscBuf->data[oscBuf->needle++]=out;
} else {
bufL[i]=0;
buf[0][i]=0;
oscBuf->data[oscBuf->needle++]=0;
flip=false;
}

View file

@ -39,7 +39,7 @@ class DivPlatformPong: public DivDispatch {
friend void putDispatchChan(void*,int,int);
public:
void acquire(short* bufL, short* bufR, size_t start, size_t len);
void acquire(short** buf, size_t len);
int dispatch(DivCommand c);
void* getChanState(int chan);
DivMacroInt* getChanMacroInt(int ch);

View file

@ -265,11 +265,11 @@ const char** DivPlatformQSound::getRegisterSheet() {
return regCheatSheetQSound;
}
void DivPlatformQSound::acquire(short* bufL, short* bufR, size_t start, size_t len) {
for (size_t h=start; h<start+len; h++) {
void DivPlatformQSound::acquire(short** buf, size_t len) {
for (size_t h=0; h<len; h++) {
qsound_update(&chip);
bufL[h]=chip.out[0];
bufR[h]=chip.out[1];
buf[0][h]=chip.out[0];
buf[1][h]=chip.out[1];
for (int i=0; i<19; i++) {
int data=chip.voice_output[i]<<2;
@ -636,8 +636,8 @@ void DivPlatformQSound::reset() {
immWrite(Q1_ECHO_FEEDBACK, echoFeedback << 6);
}
bool DivPlatformQSound::isStereo() {
return true;
int DivPlatformQSound::getOutputCount() {
return 2;
}
bool DivPlatformQSound::keyOffAffectsArp(int ch) {
@ -707,11 +707,11 @@ const void* DivPlatformQSound::getSampleMem(int index) {
}
size_t DivPlatformQSound::getSampleMemCapacity(int index) {
return (index == 0 || index == 1) ? 16777216 : 0;
return index == 0 ? 16777216 : index == 1 ? MAX(0,16777216 - sampleMemUsage) : 0;
}
size_t DivPlatformQSound::getSampleMemUsage(int index) {
return index == 0 ? sampleMemLen : index == 1 ? sampleMemLenBS : 0;
return index == 0 ? sampleMemLen : index == 1 ? MAX(0,sampleMemLenBS - sampleMemUsage) : 0;
}
bool DivPlatformQSound::isSampleLoaded(int index, int sample) {
@ -766,6 +766,7 @@ void DivPlatformQSound::renderSamples(int sysID) {
sampleMemLen=memPos+256;
memPos=(memPos+0xffff)&0xff0000;
sampleMemUsage=memPos;
for (int i=0; i<parent->song.sampleLen; i++) {
DivSample* s=parent->song.sample[i];
@ -818,6 +819,7 @@ int DivPlatformQSound::init(DivEngine* p, int channels, int sugRate, const DivCo
sampleMem=new unsigned char[getSampleMemCapacity()];
sampleMemLen=0;
sampleMemLenBS=0;
sampleMemUsage=0;
chip.rom_data=sampleMem;
chip.rom_mask=0xffffff;
reset();

View file

@ -50,6 +50,7 @@ class DivPlatformQSound: public DivDispatch {
unsigned char* sampleMem;
size_t sampleMemLen;
size_t sampleMemLenBS;
size_t sampleMemUsage;
bool sampleLoaded[256];
bool sampleLoadedBS[256];
struct qsound_chip chip;
@ -62,7 +63,7 @@ class DivPlatformQSound: public DivDispatch {
friend void putDispatchChan(void*,int,int);
public:
void acquire(short* bufL, short* bufR, size_t start, size_t len);
void acquire(short** buf, size_t len);
int dispatch(DivCommand c);
void* getChanState(int chan);
DivMacroInt* getChanMacroInt(int ch);
@ -74,7 +75,7 @@ class DivPlatformQSound: public DivDispatch {
void forceIns();
void tick(bool sysTick=true);
void muteChannel(int ch, bool mute);
bool isStereo();
int getOutputCount();
bool keyOffAffectsArp(int ch);
void setFlags(const DivConfig& flags);
void notifyInsChange(int ins);

View file

@ -54,25 +54,27 @@ void DivPlatformRF5C68::chWrite(unsigned char ch, unsigned int addr, unsigned ch
}
}
void DivPlatformRF5C68::acquire(short* bufL, short* bufR, size_t start, size_t len) {
short buf[16][256];
// TODO: this code is weird
// make sure newDispatch didn't break it up
void DivPlatformRF5C68::acquire(short** buf, size_t len) {
short bufC[16][256];
short* chBufPtrs[16]={
buf[0],buf[1],buf[2],buf[3],buf[4],buf[5],buf[6],buf[7],
buf[8],buf[9],buf[10],buf[11],buf[12],buf[13],buf[14],buf[15]
bufC[0],bufC[1],bufC[2],bufC[3],bufC[4],bufC[5],bufC[6],bufC[7],
bufC[8],bufC[9],bufC[10],bufC[11],bufC[12],bufC[13],bufC[14],bufC[15]
};
size_t pos=start;
size_t pos=0;
for (int i=0; i<16; i++) {
memset(buf[i],0,256*sizeof(short));
memset(bufC[i],0,256*sizeof(short));
}
while (len > 0) {
size_t blockLen=MIN(len,256);
short* bufPtrs[2]={&bufL[pos],&bufR[pos]};
short* bufPtrs[2]={&buf[0][pos],&buf[1][pos]};
rf5c68.sound_stream_update(bufPtrs,chBufPtrs,blockLen);
for (int i=0; i<8; i++) {
for (size_t j=0; j<blockLen; j++) {
oscBuf[i]->data[oscBuf[i]->needle++]=buf[i*2][j]+buf[i*2+1][j];
oscBuf[i]->data[oscBuf[i]->needle++]=bufC[i*2][j]+bufC[i*2+1][j];
}
}
pos+=blockLen;
@ -332,8 +334,8 @@ void DivPlatformRF5C68::reset() {
}
}
bool DivPlatformRF5C68::isStereo() {
return true;
int DivPlatformRF5C68::getOutputCount() {
return 2;
}
void DivPlatformRF5C68::notifyInsChange(int ins) {

View file

@ -56,7 +56,7 @@ class DivPlatformRF5C68: public DivDispatch {
friend void putDispatchChan(void*,int,int);
public:
void acquire(short* bufL, short* bufR, size_t start, size_t len);
void acquire(short** buf, size_t len);
int dispatch(DivCommand c);
void* getChanState(int chan);
DivMacroInt* getChanMacroInt(int ch);
@ -67,7 +67,7 @@ class DivPlatformRF5C68: public DivDispatch {
void forceIns();
void tick(bool sysTick=true);
void muteChannel(int ch, bool mute);
bool isStereo();
int getOutputCount();
void setChipModel(int type);
void notifyInsChange(int ins);
void notifyWaveChange(int wave);

View file

@ -56,7 +56,7 @@ const char** DivPlatformSAA1099::getRegisterSheet() {
return regCheatSheetSAA;
}
void DivPlatformSAA1099::acquire_saaSound(short* bufL, short* bufR, size_t start, size_t len) {
void DivPlatformSAA1099::acquire_saaSound(short** buf, size_t len) {
if (saaBufLen<len*2) {
saaBufLen=len*2;
for (int i=0; i<2; i++) {
@ -73,19 +73,19 @@ void DivPlatformSAA1099::acquire_saaSound(short* bufL, short* bufR, size_t start
saa_saaSound->GenerateMany((unsigned char*)saaBuf[0],len,oscBuf);
#ifdef TA_BIG_ENDIAN
for (size_t i=0; i<len; i++) {
bufL[i+start]=(short)((((unsigned short)saaBuf[0][1+(i<<1)])<<8)|(((unsigned short)saaBuf[0][1+(i<<1)])>>8));
bufR[i+start]=(short)((((unsigned short)saaBuf[0][i<<1])<<8)|(((unsigned short)saaBuf[0][i<<1])>>8));
buf[0][i]=(short)((((unsigned short)saaBuf[0][1+(i<<1)])<<8)|(((unsigned short)saaBuf[0][1+(i<<1)])>>8));
buf[1][i]=(short)((((unsigned short)saaBuf[0][i<<1])<<8)|(((unsigned short)saaBuf[0][i<<1])>>8));
}
#else
for (size_t i=0; i<len; i++) {
bufL[i+start]=saaBuf[0][i<<1];
bufR[i+start]=saaBuf[0][1+(i<<1)];
buf[0][i]=saaBuf[0][i<<1];
buf[1][i]=saaBuf[0][1+(i<<1)];
}
#endif
}
void DivPlatformSAA1099::acquire(short* bufL, short* bufR, size_t start, size_t len) {
acquire_saaSound(bufL,bufR,start,len);
void DivPlatformSAA1099::acquire(short** buf, size_t len) {
acquire_saaSound(buf,len);
}
inline unsigned char applyPan(unsigned char vol, unsigned char pan) {
@ -419,8 +419,8 @@ void DivPlatformSAA1099::reset() {
rWrite(0x1c,1);
}
bool DivPlatformSAA1099::isStereo() {
return true;
int DivPlatformSAA1099::getOutputCount() {
return 2;
}
int DivPlatformSAA1099::getPortaFloor(int ch) {

View file

@ -71,10 +71,10 @@ class DivPlatformSAA1099: public DivDispatch {
friend void putDispatchChip(void*,int);
friend void putDispatchChan(void*,int,int);
void acquire_saaSound(short* bufL, short* bufR, size_t start, size_t len);
void acquire_saaSound(short** buf, size_t len);
public:
void acquire(short* bufL, short* bufR, size_t start, size_t len);
void acquire(short** buf, size_t len);
int dispatch(DivCommand c);
void* getChanState(int chan);
DivMacroInt* getChanMacroInt(int ch);
@ -86,7 +86,7 @@ class DivPlatformSAA1099: public DivDispatch {
void tick(bool sysTick=true);
void muteChannel(int ch, bool mute);
void setFlags(const DivConfig& flags);
bool isStereo();
int getOutputCount();
int getPortaFloor(int ch);
bool keyOffAffectsArp(int ch);
void notifyInsDeletion(void* ins);

View file

@ -80,13 +80,13 @@ const char** DivPlatformSCC::getRegisterSheet() {
return isPlus ? regCheatSheetSCCPlus : regCheatSheetSCC;
}
void DivPlatformSCC::acquire(short* bufL, short* bufR, size_t start, size_t len) {
for (size_t h=start; h<start+len; h++) {
void DivPlatformSCC::acquire(short** buf, size_t len) {
for (size_t h=0; h<len; h++) {
for (int i=0; i<16; i++) {
scc->tick();
}
short out=(short)scc->out()<<5;
bufL[h]=bufR[h]=out;
buf[0][h]=out;
for (int i=0; i<5; i++) {
oscBuf[i]->data[oscBuf[i]->needle++]=scc->voice_out(i)<<7;
@ -335,8 +335,8 @@ void DivPlatformSCC::reset() {
lastUpdated34=0;
}
bool DivPlatformSCC::isStereo() {
return false;
int DivPlatformSCC::getOutputCount() {
return 1;
}
void DivPlatformSCC::notifyWaveChange(int wave) {

View file

@ -50,7 +50,7 @@ class DivPlatformSCC: public DivDispatch {
friend void putDispatchChip(void*,int);
friend void putDispatchChan(void*,int,int);
public:
void acquire(short* bufL, short* bufR, size_t start, size_t len);
void acquire(short** buf, size_t len);
int dispatch(DivCommand c);
void* getChanState(int chan);
DivMacroInt* getChanMacroInt(int ch);
@ -61,7 +61,7 @@ class DivPlatformSCC: public DivDispatch {
void forceIns();
void tick(bool sysTick=true);
void muteChannel(int ch, bool mute);
bool isStereo();
int getOutputCount();
void notifyWaveChange(int wave);
void notifyInsDeletion(void* ins);
void poke(unsigned int addr, unsigned short val);

View file

@ -26,10 +26,10 @@
//#define rWrite(a,v) if (!skipRegisterWrites) {pendingWrites[a]=v;}
//#define immWrite(a,v) if (!skipRegisterWrites) {writes.emplace(a,v); if (dumpWrites) {addWrite(a,v);} }
void DivPlatformSegaPCM::acquire(short* bufL, short* bufR, size_t start, size_t len) {
void DivPlatformSegaPCM::acquire(short** buf, size_t len) {
static int os[2];
for (size_t h=start; h<start+len; h++) {
for (size_t h=0; h<len; h++) {
os[0]=0; os[1]=0;
// do a PCM cycle
pcmL=0; pcmR=0;
@ -67,8 +67,8 @@ void DivPlatformSegaPCM::acquire(short* bufL, short* bufR, size_t start, size_t
if (os[1]<-32768) os[1]=-32768;
if (os[1]>32767) os[1]=32767;
bufL[h]=os[0];
bufR[h]=os[1];
buf[0][h]=os[0];
buf[1][h]=os[1];
}
}
@ -502,8 +502,8 @@ void DivPlatformSegaPCM::setFlags(const DivConfig& flags) {
}
}
bool DivPlatformSegaPCM::isStereo() {
return true;
int DivPlatformSegaPCM::getOutputCount() {
return 2;
}
int DivPlatformSegaPCM::init(DivEngine* p, int channels, int sugRate, const DivConfig& flags) {

View file

@ -77,7 +77,7 @@ class DivPlatformSegaPCM: public DivDispatch {
friend void putDispatchChan(void*,int,int);
public:
void acquire(short* bufL, short* bufR, size_t start, size_t len);
void acquire(short** buf, size_t len);
int dispatch(DivCommand c);
void* getChanState(int chan);
DivMacroInt* getChanMacroInt(int ch);
@ -91,7 +91,7 @@ class DivPlatformSegaPCM: public DivDispatch {
void notifyInsChange(int ins);
void renderSamples(int chipID);
void setFlags(const DivConfig& flags);
bool isStereo();
int getOutputCount();
void poke(unsigned int addr, unsigned short val);
void poke(std::vector<DivRegWrite>& wlist);
int init(DivEngine* parent, int channels, int sugRate, const DivConfig& flags);

View file

@ -39,10 +39,10 @@ const char** DivPlatformSMS::getRegisterSheet() {
return stereo?regCheatSheetGG:regCheatSheetSN;
}
void DivPlatformSMS::acquire_nuked(short* bufL, short* bufR, size_t start, size_t len) {
void DivPlatformSMS::acquire_nuked(short** buf, size_t len) {
int oL=0;
int oR=0;
for (size_t h=start; h<start+len; h++) {
for (size_t h=0; h<len; h++) {
if (!writes.empty()) {
QueuedWrite w=writes.front();
if (w.addr==0) {
@ -73,8 +73,8 @@ void DivPlatformSMS::acquire_nuked(short* bufL, short* bufR, size_t start, size_
if (oL>32767) oL=32767;
if (oR<-32768) oR=-32768;
if (oR>32767) oR=32767;
bufL[h]=oL;
bufR[h]=oR;
buf[0][h]=oL;
if (stereo) buf[1][h]=oR;
for (int i=0; i<4; i++) {
if (isMuted[i]) {
oscBuf[i]->data[oscBuf[i]->needle++]=0;
@ -85,7 +85,7 @@ void DivPlatformSMS::acquire_nuked(short* bufL, short* bufR, size_t start, size_
}
}
void DivPlatformSMS::acquire_mame(short* bufL, short* bufR, size_t start, size_t len) {
void DivPlatformSMS::acquire_mame(short** buf, size_t len) {
while (!writes.empty()) {
QueuedWrite w=writes.front();
if (stereo && (w.addr==1))
@ -95,10 +95,10 @@ void DivPlatformSMS::acquire_mame(short* bufL, short* bufR, size_t start, size_t
}
writes.pop();
}
for (size_t h=start; h<start+len; h++) {
for (size_t h=0; h<len; h++) {
short* outs[2]={
&bufL[h],
&bufR[h]
&buf[0][h],
stereo?(&buf[1][h]):NULL
};
sn->sound_stream_update(outs,1);
for (int i=0; i<4; i++) {
@ -111,11 +111,11 @@ void DivPlatformSMS::acquire_mame(short* bufL, short* bufR, size_t start, size_t
}
}
void DivPlatformSMS::acquire(short* bufL, short* bufR, size_t start, size_t len) {
void DivPlatformSMS::acquire(short** buf, size_t len) {
if (nuked) {
acquire_nuked(bufL,bufR,start,len);
acquire_nuked(buf,len);
} else {
acquire_mame(bufL,bufR,start,len);
acquire_mame(buf,len);
}
}
@ -445,8 +445,8 @@ void DivPlatformSMS::reset() {
}
}
bool DivPlatformSMS::isStereo() {
return stereo;
int DivPlatformSMS::getOutputCount() {
return stereo?2:1;
}
bool DivPlatformSMS::keyOffAffectsArp(int ch) {

View file

@ -66,10 +66,10 @@ class DivPlatformSMS: public DivDispatch {
double NOTE_SN(int ch, int note);
int snCalcFreq(int ch);
void acquire_nuked(short* bufL, short* bufR, size_t start, size_t len);
void acquire_mame(short* bufL, short* bufR, size_t start, size_t len);
void acquire_nuked(short** buf, size_t len);
void acquire_mame(short** buf, size_t len);
public:
void acquire(short* bufL, short* bufR, size_t start, size_t len);
void acquire(short** buf, size_t len);
int dispatch(DivCommand c);
void* getChanState(int chan);
DivMacroInt* getChanMacroInt(int ch);
@ -78,7 +78,7 @@ class DivPlatformSMS: public DivDispatch {
void forceIns();
void tick(bool sysTick=true);
void muteChannel(int ch, bool mute);
bool isStereo();
int getOutputCount();
bool keyOffAffectsArp(int ch);
bool keyOffAffectsPorta(int ch);
int getPortaFloor(int ch);

View file

@ -65,10 +65,10 @@ const char** DivPlatformSNES::getRegisterSheet() {
return regCheatSheetSNESDSP;
}
void DivPlatformSNES::acquire(short* bufL, short* bufR, size_t start, size_t len) {
void DivPlatformSNES::acquire(short** buf, size_t len) {
short out[2];
short chOut[16];
for (size_t h=start; h<start+len; h++) {
for (size_t h=0; h<len; h++) {
if (--delay<=0) {
delay=0;
if (!writes.empty()) {
@ -82,8 +82,8 @@ void DivPlatformSNES::acquire(short* bufL, short* bufR, size_t start, size_t len
dsp.set_output(out,1);
dsp.run(32);
dsp.get_voice_outputs(chOut);
bufL[h]=out[0];
bufR[h]=out[1];
buf[0][h]=out[0];
buf[1][h]=out[1];
for (int i=0; i<8; i++) {
int next=(3*(chOut[i*2]+chOut[i*2+1]))>>2;
if (next<-32768) next=-32768;
@ -768,8 +768,8 @@ void DivPlatformSNES::reset() {
initEcho();
}
bool DivPlatformSNES::isStereo() {
return true;
int DivPlatformSNES::getOutputCount() {
return 2;
}
void DivPlatformSNES::notifyInsChange(int ins) {

View file

@ -93,7 +93,7 @@ class DivPlatformSNES: public DivDispatch {
friend void putDispatchChan(void*,int,int);
public:
void acquire(short* bufL, short* bufR, size_t start, size_t len);
void acquire(short** buf, size_t len);
int dispatch(DivCommand c);
void* getChanState(int chan);
DivMacroInt* getChanMacroInt(int ch);
@ -104,7 +104,7 @@ class DivPlatformSNES: public DivDispatch {
void forceIns();
void tick(bool sysTick=true);
void muteChannel(int ch, bool mute);
bool isStereo();
int getOutputCount();
void notifyInsChange(int ins);
void notifyWaveChange(int wave);
void setFlags(const DivConfig& flags);

View file

@ -1064,12 +1064,11 @@ void ay8910_device::sound_stream_update(short** outputs, int outLen)
tone = &m_tone[chan];
const int period = std::max<int>(1, tone->period) * (m_step_mul << 1);
tone->count += is_expanded_mode() ? 32 : ((m_feature & PSG_HAS_EXPANDED_MODE) ? 1 : 2);
while (tone->count >= period)
{
tone->duty_cycle = (tone->duty_cycle - 1) & 0x1f;
tone->output = is_expanded_mode() ? BIT(duty_cycle[tone_duty(tone)], tone->duty_cycle) : BIT(tone->duty_cycle, 0);
tone->count -= period;
}
if (tone->count>=period) {
tone->duty_cycle = (tone->duty_cycle - (tone->count/period)) & 0x1f;
tone->output = is_expanded_mode() ? BIT(duty_cycle[tone_duty(tone)], tone->duty_cycle) : BIT(tone->duty_cycle, 0);
tone->count = tone->count % period;
}
}
const int period_noise = (int)(noise_period()) * m_step_mul;

View file

@ -659,11 +659,13 @@ void namco_audio_device::sound_stream_update(short** outputs, int len)
{
lmix[i]+=l_noise_data;
rmix[i]+=r_noise_data;
voice->last_out=(l_noise_data+r_noise_data)>>1;
}
else
{
lmix[i]+=-l_noise_data;
rmix[i]+=-r_noise_data;
voice->last_out=-((l_noise_data+r_noise_data)>>1);
}
if (hold)

View file

@ -40,14 +40,14 @@ double DivPlatformSoundUnit::NOTE_SU(int ch, int note) {
return NOTE_FREQUENCY(note);
}
void DivPlatformSoundUnit::acquire(short* bufL, short* bufR, size_t start, size_t len) {
for (size_t h=start; h<start+len; h++) {
void DivPlatformSoundUnit::acquire(short** buf, size_t len) {
for (size_t h=0; h<len; h++) {
while (!writes.empty()) {
QueuedWrite w=writes.front();
su->Write(w.addr,w.val);
writes.pop();
}
su->NextSample(&bufL[h],&bufR[h]);
su->NextSample(&buf[0][h],&buf[1][h]);
for (int i=0; i<8; i++) {
oscBuf[i]->data[oscBuf[i]->needle++]=su->GetSample(i);
}
@ -499,8 +499,8 @@ void DivPlatformSoundUnit::reset() {
rWrite(0xbd,fil1);
}
bool DivPlatformSoundUnit::isStereo() {
return true;
int DivPlatformSoundUnit::getOutputCount() {
return 2;
}
bool DivPlatformSoundUnit::keyOffAffectsArp(int ch) {

View file

@ -98,7 +98,7 @@ class DivPlatformSoundUnit: public DivDispatch {
friend void putDispatchChip(void*,int);
friend void putDispatchChan(void*,int,int);
public:
void acquire(short* bufL, short* bufR, size_t start, size_t len);
void acquire(short** buf, size_t len);
int dispatch(DivCommand c);
void* getChanState(int chan);
DivMacroInt* getChanMacroInt(int ch);
@ -109,7 +109,7 @@ class DivPlatformSoundUnit: public DivDispatch {
void forceIns();
void tick(bool sysTick=true);
void muteChannel(int ch, bool mute);
bool isStereo();
int getOutputCount();
bool keyOffAffectsArp(int ch);
void setFlags(const DivConfig& flags);
void notifyInsDeletion(void* ins);

View file

@ -50,8 +50,8 @@ const char** DivPlatformSwan::getRegisterSheet() {
return regCheatSheetWS;
}
void DivPlatformSwan::acquire(short* bufL, short* bufR, size_t start, size_t len) {
for (size_t h=start; h<start+len; h++) {
void DivPlatformSwan::acquire(short** buf, size_t len) {
for (size_t h=0; h<len; h++) {
// PCM part
if (pcm && dacSample!=-1) {
dacPeriod+=dacRate;
@ -83,8 +83,8 @@ void DivPlatformSwan::acquire(short* bufL, short* bufR, size_t start, size_t len
int16_t samp[2]{0, 0};
ws->SoundUpdate(16);
ws->SoundFlush(samp, 1);
bufL[h]=samp[0];
bufR[h]=samp[1];
buf[0][h]=samp[0];
buf[1][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;
}
@ -490,8 +490,8 @@ void DivPlatformSwan::reset() {
rWrite(0x11,0x09); // enable speakers
}
bool DivPlatformSwan::isStereo() {
return true;
int DivPlatformSwan::getOutputCount() {
return 2;
}
void DivPlatformSwan::notifyWaveChange(int wave) {

View file

@ -56,7 +56,7 @@ class DivPlatformSwan: public DivDispatch {
friend void putDispatchChip(void*,int);
friend void putDispatchChan(void*,int,int);
public:
void acquire(short* bufL, short* bufR, size_t start, size_t len);
void acquire(short** buf, size_t len);
int dispatch(DivCommand c);
void* getChanState(int chan);
DivMacroInt* getChanMacroInt(int ch);
@ -69,7 +69,7 @@ class DivPlatformSwan: public DivDispatch {
void muteChannel(int ch, bool mute);
void notifyWaveChange(int wave);
void notifyInsDeletion(void* ins);
bool isStereo();
int getOutputCount();
void poke(unsigned int addr, unsigned short val);
void poke(std::vector<DivRegWrite>& wlist);
const char** getRegisterSheet();

View file

@ -35,8 +35,8 @@ const char** DivPlatformT6W28::getRegisterSheet() {
return regCheatSheetT6W28;
}
void DivPlatformT6W28::acquire(short* bufL, short* bufR, size_t start, size_t len) {
for (size_t h=start; h<start+len; h++) {
void DivPlatformT6W28::acquire(short** buf, size_t len) {
for (size_t h=0; h<len; h++) {
cycles=0;
while (!writes.empty() && cycles<16) {
QueuedWrite w=writes.front();
@ -64,8 +64,8 @@ void DivPlatformT6W28::acquire(short* bufL, short* bufR, size_t start, size_t le
if (tempR<-32768) tempR=-32768;
if (tempR>32767) tempR=32767;
bufL[h]=tempL;
bufR[h]=tempR;
buf[0][h]=tempL;
buf[1][h]=tempR;
}
}
@ -289,6 +289,7 @@ void DivPlatformT6W28::forceIns() {
chan[i].insChanged=true;
chan[i].freqChanged=true;
}
rWrite(1,0xe0+chan[3].duty);
}
void* DivPlatformT6W28::getChanState(int ch) {
@ -336,8 +337,8 @@ void DivPlatformT6W28::reset() {
rWrite(1,0xe7);
}
bool DivPlatformT6W28::isStereo() {
return true;
int DivPlatformT6W28::getOutputCount() {
return 2;
}
bool DivPlatformT6W28::keyOffAffectsArp(int ch) {

View file

@ -59,7 +59,7 @@ class DivPlatformT6W28: public DivDispatch {
void writeOutVol(int ch);
public:
void acquire(short* bufL, short* bufR, size_t start, size_t len);
void acquire(short** buf, size_t len);
int dispatch(DivCommand c);
void* getChanState(int chan);
DivMacroInt* getChanMacroInt(int ch);
@ -70,7 +70,7 @@ class DivPlatformT6W28: public DivDispatch {
void forceIns();
void tick(bool sysTick=true);
void muteChannel(int ch, bool mute);
bool isStereo();
int getOutputCount();
bool keyOffAffectsArp(int ch);
void setFlags(const DivConfig& flags);
void notifyInsDeletion(void* ins);

View file

@ -38,16 +38,16 @@ const char** DivPlatformTIA::getRegisterSheet() {
return regCheatSheetTIA;
}
void DivPlatformTIA::acquire(short* bufL, short* bufR, size_t start, size_t len) {
for (size_t h=start; h<start+len; h++) {
void DivPlatformTIA::acquire(short** buf, size_t len) {
for (size_t h=0; h<len; h++) {
tia.tick();
if (mixingType==2) {
bufL[h]=tia.myCurrentSample[0];
bufR[h]=tia.myCurrentSample[1];
buf[0][h]=tia.myCurrentSample[0];
buf[1][h]=tia.myCurrentSample[1];
} else if (mixingType==1) {
bufL[h]=(tia.myCurrentSample[0]+tia.myCurrentSample[1])>>1;
buf[0][h]=(tia.myCurrentSample[0]+tia.myCurrentSample[1])>>1;
} else {
bufL[h]=tia.myCurrentSample[0];
buf[0][h]=tia.myCurrentSample[0];
}
if (++chanOscCounter>=114) {
chanOscCounter=0;
@ -342,8 +342,8 @@ float DivPlatformTIA::getPostAmp() {
return 0.5f;
}
bool DivPlatformTIA::isStereo() {
return (mixingType==2);
int DivPlatformTIA::getOutputCount() {
return (mixingType==2)?2:1;
}
bool DivPlatformTIA::keyOffAffectsArp(int ch) {

View file

@ -45,7 +45,7 @@ class DivPlatformTIA: public DivDispatch {
unsigned char dealWithFreq(unsigned char shape, int base, int pitch);
public:
void acquire(short* bufL, short* bufR, size_t start, size_t len);
void acquire(short** buf, size_t len);
int dispatch(DivCommand c);
void* getChanState(int chan);
DivMacroInt* getChanMacroInt(int ch);
@ -58,7 +58,7 @@ class DivPlatformTIA: public DivDispatch {
void muteChannel(int ch, bool mute);
void setFlags(const DivConfig& flags);
float getPostAmp();
bool isStereo();
int getOutputCount();
bool keyOffAffectsArp(int ch);
void notifyInsDeletion(void* ins);
void poke(unsigned int addr, unsigned short val);

View file

@ -55,12 +55,12 @@ const char** DivPlatformTX81Z::getRegisterSheet() {
return regCheatSheetOPZ;
}
void DivPlatformTX81Z::acquire(short* bufL, short* bufR, size_t start, size_t len) {
void DivPlatformTX81Z::acquire(short** buf, size_t len) {
static int os[2];
ymfm::ym2414::fm_engine* fme=fm_ymfm->debug_engine();
for (size_t h=start; h<start+len; h++) {
for (size_t h=0; h<len; h++) {
os[0]=0; os[1]=0;
if (!writes.empty()) {
if (--delay<1) {
@ -87,8 +87,8 @@ void DivPlatformTX81Z::acquire(short* bufL, short* bufR, size_t start, size_t le
if (os[1]<-32768) os[1]=-32768;
if (os[1]>32767) os[1]=32767;
bufL[h]=os[0];
bufR[h]=os[1];
buf[0][h]=os[0];
buf[1][h]=os[1];
}
}
@ -152,6 +152,14 @@ void DivPlatformTX81Z::tick(bool sysTick) {
chan[i].freqChanged=true;
}
if (chan[i].std.panL.had) {
chan[i].chVolL=(chan[i].std.panL.val&2)>>1;
chan[i].chVolR=chan[i].std.panL.val&1;
chan[i].freqChanged=true;
immWrite(chanOffs[i]+ADDR_LR_FB_ALG,(chan[i].state.alg&7)|(chan[i].state.fb<<3)|(chan[i].active?0x40:0)|(chan[i].chVolR<<7));
}
if (chan[i].std.phaseReset.had) {
if (chan[i].std.phaseReset.val==1 && chan[i].active) {
chan[i].keyOn=true;
@ -933,22 +941,23 @@ void DivPlatformTX81Z::setFlags(const DivConfig& flags) {
int clockSel=flags.getInt("clockSel",0);
if (clockSel==2) {
chipClock=4000000.0;
baseFreqOff=-122;
} else if (clockSel==1) {
chipClock=COLOR_PAL*4.0/5.0;
baseFreqOff=12;
} else {
chipClock=COLOR_NTSC;
baseFreqOff=0;
}
CHECK_CUSTOM_CLOCK;
baseFreqOff=round(768.0*(log((COLOR_NTSC/(double)chipClock))/log(2.0)));
rate=chipClock/64;
for (int i=0; i<8; i++) {
oscBuf[i]->rate=rate;
}
}
bool DivPlatformTX81Z::isStereo() {
return true;
int DivPlatformTX81Z::getOutputCount() {
return 2;
}
int DivPlatformTX81Z::init(DivEngine* p, int channels, int sugRate, const DivConfig& flags) {

View file

@ -60,7 +60,7 @@ class DivPlatformTX81Z: public DivPlatformOPM {
friend void putDispatchChip(void*,int);
public:
void acquire(short* bufL, short* bufR, size_t start, size_t len);
void acquire(short** buf, size_t len);
int dispatch(DivCommand c);
void* getChanState(int chan);
DivMacroInt* getChanMacroInt(int ch);
@ -73,7 +73,7 @@ class DivPlatformTX81Z: public DivPlatformOPM {
void muteChannel(int ch, bool mute);
void notifyInsChange(int ins);
void setFlags(const DivConfig& flags);
bool isStereo();
int getOutputCount();
void poke(unsigned int addr, unsigned short val);
void poke(std::vector<DivRegWrite>& wlist);
const char** getRegisterSheet();

View file

@ -93,8 +93,8 @@ const char** DivPlatformVB::getRegisterSheet() {
return regCheatSheetVB;
}
void DivPlatformVB::acquire(short* bufL, short* bufR, size_t start, size_t len) {
for (size_t h=start; h<start+len; h++) {
void DivPlatformVB::acquire(short** buf, size_t len) {
for (size_t h=0; h<len; h++) {
cycles=0;
while (!writes.empty()) {
QueuedWrite w=writes.front();
@ -117,8 +117,8 @@ void DivPlatformVB::acquire(short* bufL, short* bufR, size_t start, size_t len)
if (tempR<-32768) tempR=-32768;
if (tempR>32767) tempR=32767;
bufL[h]=tempL;
bufR[h]=tempR;
buf[0][h]=tempL;
buf[1][h]=tempR;
}
}
@ -465,8 +465,8 @@ void DivPlatformVB::reset() {
delay=500;
}
bool DivPlatformVB::isStereo() {
return true;
int DivPlatformVB::getOutputCount() {
return 2;
}
bool DivPlatformVB::keyOffAffectsArp(int ch) {

View file

@ -64,7 +64,7 @@ class DivPlatformVB: public DivDispatch {
friend void putDispatchChip(void*,int);
friend void putDispatchChan(void*,int,int);
public:
void acquire(short* bufL, short* bufR, size_t start, size_t len);
void acquire(short** buf, size_t len);
int dispatch(DivCommand c);
void* getChanState(int chan);
DivMacroInt* getChanMacroInt(int ch);
@ -76,7 +76,7 @@ class DivPlatformVB: public DivDispatch {
void forceIns();
void tick(bool sysTick=true);
void muteChannel(int ch, bool mute);
bool isStereo();
int getOutputCount();
bool keyOffAffectsArp(int ch);
float getPostAmp();
void setFlags(const DivConfig& flags);

View file

@ -53,11 +53,11 @@ const char** DivPlatformVERA::getRegisterSheet() {
return regCheatSheetVERA;
}
void DivPlatformVERA::acquire(short* bufL, short* bufR, size_t start, size_t len) {
void DivPlatformVERA::acquire(short** buf, size_t len) {
// both PSG part and PCM part output a full 16-bit range, putting bufL/R
// argument right into both could cause an overflow
short buf[4][128];
size_t pos=start;
short whyCallItBuf[4][128];
size_t pos=0;
DivSample* s=parent->getSample(chan[16].pcm.sample);
while (len>0) {
if (s->samples>0) {
@ -98,18 +98,18 @@ void DivPlatformVERA::acquire(short* bufL, short* bufR, size_t start, size_t len
chan[16].pcm.sample=-1;
}
int curLen=MIN(len,128);
memset(buf,0,sizeof(buf));
pcm_render(pcm,buf[2],buf[3],curLen);
memset(whyCallItBuf,0,sizeof(whyCallItBuf));
pcm_render(pcm,whyCallItBuf[2],whyCallItBuf[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);
psg_render(psg,&whyCallItBuf[0][i],&whyCallItBuf[1][i],1);
buf[0][pos]=(short)(((int)whyCallItBuf[0][i]+whyCallItBuf[2][i])/2);
buf[1][pos]=(short)(((int)whyCallItBuf[1][i]+whyCallItBuf[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];
int pcmOut=whyCallItBuf[2][i]+whyCallItBuf[3][i];
if (pcmOut<-32768) pcmOut=-32768;
if (pcmOut>32767) pcmOut=32767;
oscBuf[16]->data[oscBuf[16]->needle++]=pcmOut;
@ -406,8 +406,8 @@ float DivPlatformVERA::getPostAmp() {
return 4.0f;
}
bool DivPlatformVERA::isStereo() {
return true;
int DivPlatformVERA::getOutputCount() {
return 2;
}
void DivPlatformVERA::notifyInsDeletion(void* ins) {

View file

@ -60,7 +60,7 @@ class DivPlatformVERA: public DivDispatch {
friend void putDispatchChan(void*,int,int);
public:
void acquire(short* bufL, short* bufR, size_t start, size_t len);
void acquire(short** buf, size_t len);
int dispatch(DivCommand c);
void* getChanState(int chan);
DivMacroInt* getChanMacroInt(int ch);
@ -72,7 +72,7 @@ class DivPlatformVERA: public DivDispatch {
void muteChannel(int ch, bool mute);
void notifyInsDeletion(void* ins);
float getPostAmp();
bool isStereo();
int getOutputCount();
void poke(unsigned int addr, unsigned short val);
void poke(std::vector<DivRegWrite>& wlist);
const char** getRegisterSheet();

View file

@ -39,13 +39,13 @@ const char** DivPlatformVIC20::getRegisterSheet() {
return regCheatSheetVIC;
}
void DivPlatformVIC20::acquire(short* bufL, short* bufR, size_t start, size_t len) {
void DivPlatformVIC20::acquire(short** buf, size_t len) {
const unsigned char loadFreq[3] = {0x7e, 0x7d, 0x7b};
const unsigned char wavePatterns[16] = {
0b0, 0b10, 0b100, 0b110, 0b1000, 0b1010, 0b1011, 0b1110,
0b10010, 0b10100, 0b10110, 0b11000, 0b11010, 0b100100, 0b101010, 0b101100
};
for (size_t h=start; h<start+len; h++) {
for (size_t h=0; h<len; h++) {
if (hasWaveWrite) {
hasWaveWrite=false;
for (int i=0; i<3; i++) {
@ -66,8 +66,7 @@ void DivPlatformVIC20::acquire(short* bufL, short* bufR, size_t start, size_t le
}
short samp;
vic_sound_machine_calculate_samples(vic,&samp,1,1,0,SAMP_DIVIDER);
bufL[h]=samp;
bufR[h]=samp;
buf[0][h]=samp;
for (int i=0; i<4; i++) {
oscBuf[i]->data[oscBuf[i]->needle++]=vic->ch[i].out?(vic->volume<<11):0;
}
@ -299,8 +298,8 @@ void DivPlatformVIC20::reset() {
vic_sound_clock(vic,4);
}
bool DivPlatformVIC20::isStereo() {
return false;
int DivPlatformVIC20::getOutputCount() {
return 1;
}
void DivPlatformVIC20::notifyInsDeletion(void* ins) {

View file

@ -43,7 +43,7 @@ class DivPlatformVIC20: public DivDispatch {
friend void putDispatchChip(void*,int);
friend void putDispatchChan(void*,int,int);
public:
void acquire(short* bufL, short* bufR, size_t start, size_t len);
void acquire(short** buf, size_t len);
int dispatch(DivCommand c);
void* getChanState(int chan);
DivMacroInt* getChanMacroInt(int ch);
@ -56,7 +56,7 @@ class DivPlatformVIC20: public DivDispatch {
void muteChannel(int ch, bool mute);
void setFlags(const DivConfig& flags);
void notifyInsDeletion(void* ins);
bool isStereo();
int getOutputCount();
void poke(unsigned int addr, unsigned short val);
void poke(std::vector<DivRegWrite>& wlist);
const char** getRegisterSheet();

View file

@ -46,8 +46,8 @@ const char** DivPlatformVRC6::getRegisterSheet() {
return regCheatSheetVRC6;
}
void DivPlatformVRC6::acquire(short* bufL, short* bufR, size_t start, size_t len) {
for (size_t i=start; i<start+len; i++) {
void DivPlatformVRC6::acquire(short** buf, size_t len) {
for (size_t i=0; i<len; i++) {
// PCM part
for (int i=0; i<2; i++) {
if (chan[i].pcm && chan[i].dacSample!=-1) {
@ -81,7 +81,7 @@ void DivPlatformVRC6::acquire(short* bufL, short* bufR, size_t start, size_t len
int sample=vrc6.out()<<9; // scale to 16 bit
if (sample>32767) sample=32767;
if (sample<-32768) sample=-32768;
bufL[i]=bufR[i]=sample;
buf[0][i]=sample;
// Oscilloscope buffer part
if (++writeOscBuf>=32) {

View file

@ -61,7 +61,7 @@ class DivPlatformVRC6: public DivDispatch, public vrcvi_intf {
friend void putDispatchChan(void*,int,int);
public:
void acquire(short* bufL, short* bufR, size_t start, size_t len);
void acquire(short** buf, size_t len);
int dispatch(DivCommand c);
void* getChanState(int chan);
DivMacroInt* getChanMacroInt(int ch);

View file

@ -205,8 +205,8 @@ const char** DivPlatformX1_010::getRegisterSheet() {
return regCheatSheetX1_010;
}
void DivPlatformX1_010::acquire(short* bufL, short* bufR, size_t start, size_t len) {
for (size_t h=start; h<start+len; h++) {
void DivPlatformX1_010::acquire(short** buf, size_t len) {
for (size_t h=0; h<len; h++) {
x1_010.tick();
signed int tempL=x1_010.output(0);
@ -218,8 +218,8 @@ void DivPlatformX1_010::acquire(short* bufL, short* bufR, size_t start, size_t l
if (tempR>32767) tempR=32767;
//printf("tempL: %d tempR: %d\n",tempL,tempR);
bufL[h]=stereo?tempL:((tempL+tempR)>>1);
bufR[h]=stereo?tempR:bufL[h];
buf[0][h]=stereo?tempL:((tempL+tempR)>>1);
if (stereo) buf[1][h]=tempR;
for (int i=0; i<16; i++) {
oscBuf[i]->data[oscBuf[i]->needle++]=(x1_010.voice_out(i,0)+x1_010.voice_out(i,1))>>1;
@ -362,7 +362,7 @@ void DivPlatformX1_010::tick(bool sysTick) {
if (chan[i].std.pitch.had) {
if (chan[i].std.pitch.mode) {
chan[i].pitch2+=chan[i].std.pitch.val;
CLAMP_VAR(chan[i].pitch2,-32768,32767);
CLAMP_VAR(chan[i].pitch2,-65535,65535);
} else {
chan[i].pitch2=chan[i].std.pitch.val;
}
@ -484,6 +484,7 @@ void DivPlatformX1_010::tick(bool sysTick) {
if (chan[i].freq>255) chan[i].freq=255;
chWrite(i,2,chan[i].freq&0xff);
} else {
if (chan[i].freq<0) chan[i].freq=0;
if (chan[i].freq>65535) chan[i].freq=65535;
chWrite(i,2,chan[i].freq&0xff);
chWrite(i,3,(chan[i].freq>>8)&0xff);
@ -894,8 +895,8 @@ void DivPlatformX1_010::reset() {
}
}
bool DivPlatformX1_010::isStereo() {
return stereo;
int DivPlatformX1_010::getOutputCount() {
return stereo?2:1;
}
bool DivPlatformX1_010::keyOffAffectsArp(int ch) {

View file

@ -127,7 +127,7 @@ class DivPlatformX1_010: public DivDispatch, public vgsound_emu_mem_intf {
friend void putDispatchChan(void*,int,int);
public:
u8 read_byte(u32 address);
void acquire(short* bufL, short* bufR, size_t start, size_t len);
void acquire(short** buf, size_t len);
int dispatch(DivCommand c);
void* getChanState(int chan);
DivMacroInt* getChanMacroInt(int ch);
@ -138,7 +138,7 @@ class DivPlatformX1_010: public DivDispatch, public vgsound_emu_mem_intf {
void forceIns();
void tick(bool sysTick=true);
void muteChannel(int ch, bool mute);
bool isStereo();
int getOutputCount();
bool keyOffAffectsArp(int ch);
void setFlags(const DivConfig& flags);
void notifyWaveChange(int wave);

View file

@ -156,19 +156,19 @@ const char** DivPlatformYM2203::getRegisterSheet() {
return regCheatSheetYM2203;
}
void DivPlatformYM2203::acquire(short* bufL, short* bufR, size_t start, size_t len) {
void DivPlatformYM2203::acquire(short** buf, size_t len) {
if (useCombo) {
acquire_combo(bufL,bufR,start,len);
acquire_combo(buf,len);
} else {
acquire_ymfm(bufL,bufR,start,len);
acquire_ymfm(buf,len);
}
}
void DivPlatformYM2203::acquire_combo(short* bufL, short* bufR, size_t start, size_t len) {
void DivPlatformYM2203::acquire_combo(short** buf, size_t len) {
static int os;
static short ignored[2];
for (size_t h=start; h<start+len; h++) {
for (size_t h=0; h<len; h++) {
os=0;
// Nuked part
for (unsigned int i=0; i<nukedMult; i++) {
@ -218,7 +218,7 @@ void DivPlatformYM2203::acquire_combo(short* bufL, short* bufR, size_t start, si
if (os<-32768) os=-32768;
if (os>32767) os=32767;
bufL[h]=os;
buf[0][h]=os;
for (int i=0; i<3; i++) {
oscBuf[i]->data[oscBuf[i]->needle++]=fm_nuked.ch_out[i];
@ -230,7 +230,7 @@ void DivPlatformYM2203::acquire_combo(short* bufL, short* bufR, size_t start, si
}
}
void DivPlatformYM2203::acquire_ymfm(short* bufL, short* bufR, size_t start, size_t len) {
void DivPlatformYM2203::acquire_ymfm(short** buf, size_t len) {
static int os;
ymfm::ym2203::fm_engine* fme=fm->debug_fm_engine();
@ -240,7 +240,7 @@ void DivPlatformYM2203::acquire_ymfm(short* bufL, short* bufR, size_t start, siz
fmChan[i]=fme->debug_channel(i);
}
for (size_t h=start; h<start+len; h++) {
for (size_t h=0; h<len; h++) {
os=0;
if (!writes.empty()) {
if (--delay<1) {
@ -259,7 +259,7 @@ void DivPlatformYM2203::acquire_ymfm(short* bufL, short* bufR, size_t start, siz
if (os<-32768) os=-32768;
if (os>32767) os=32767;
bufL[h]=os;
buf[0][h]=os;
for (int i=0; i<3; i++) {
@ -967,8 +967,8 @@ void DivPlatformYM2203::reset() {
ay->flushWrites();
}
bool DivPlatformYM2203::isStereo() {
return false;
int DivPlatformYM2203::getOutputCount() {
return 1;
}
bool DivPlatformYM2203::keyOffAffectsArp(int ch) {

View file

@ -55,11 +55,11 @@ class DivPlatformYM2203: public DivPlatformOPN {
friend void putDispatchChip(void*,int);
void acquire_combo(short* bufL, short* bufR, size_t start, size_t len);
void acquire_ymfm(short* bufL, short* bufR, size_t start, size_t len);
void acquire_combo(short** buf, size_t len);
void acquire_ymfm(short** buf, size_t len);
public:
void acquire(short* bufL, short* bufR, size_t start, size_t len);
void acquire(short** buf, size_t len);
int dispatch(DivCommand c);
void* getChanState(int chan);
DivMacroInt* getChanMacroInt(int ch);
@ -70,7 +70,7 @@ class DivPlatformYM2203: public DivPlatformOPN {
void forceIns();
void tick(bool sysTick=true);
void muteChannel(int ch, bool mute);
bool isStereo();
int getOutputCount();
bool keyOffAffectsArp(int ch);
void notifyInsChange(int ins);
void notifyInsDeletion(void* ins);

View file

@ -297,15 +297,15 @@ double DivPlatformYM2608::NOTE_ADPCMB(int note) {
return 0;
}
void DivPlatformYM2608::acquire(short* bufL, short* bufR, size_t start, size_t len) {
void DivPlatformYM2608::acquire(short** buf, size_t len) {
if (useCombo) {
acquire_combo(bufL,bufR,start,len);
acquire_combo(buf,len);
} else {
acquire_ymfm(bufL,bufR,start,len);
acquire_ymfm(buf,len);
}
}
void DivPlatformYM2608::acquire_combo(short* bufL, short* bufR, size_t start, size_t len) {
void DivPlatformYM2608::acquire_combo(short** buf, size_t len) {
static int os[2];
static short ignored[2];
@ -320,7 +320,7 @@ void DivPlatformYM2608::acquire_combo(short* bufL, short* bufR, size_t start, si
adpcmAChan[i]=aae->debug_channel(i);
}
for (size_t h=start; h<start+len; h++) {
for (size_t h=0; h<len; h++) {
os[0]=0; os[1]=0;
// Nuked part
for (int i=0; i<nukedMult; i++) {
@ -386,8 +386,8 @@ void DivPlatformYM2608::acquire_combo(short* bufL, short* bufR, size_t start, si
if (os[1]<-32768) os[1]=-32768;
if (os[1]>32767) os[1]=32767;
bufL[h]=os[0];
bufR[h]=os[1];
buf[0][h]=os[0];
buf[1][h]=os[1];
for (int i=0; i<psgChanOffs; i++) {
@ -407,7 +407,7 @@ void DivPlatformYM2608::acquire_combo(short* bufL, short* bufR, size_t start, si
}
}
void DivPlatformYM2608::acquire_ymfm(short* bufL, short* bufR, size_t start, size_t len) {
void DivPlatformYM2608::acquire_ymfm(short** buf, size_t len) {
static int os[2];
ymfm::ym2608::fm_engine* fme=fm->debug_fm_engine();
@ -424,7 +424,7 @@ void DivPlatformYM2608::acquire_ymfm(short* bufL, short* bufR, size_t start, siz
adpcmAChan[i]=aae->debug_channel(i);
}
for (size_t h=start; h<start+len; h++) {
for (size_t h=0; h<len; h++) {
os[0]=0; os[1]=0;
if (!writes.empty()) {
if (--delay<1) {
@ -447,8 +447,8 @@ void DivPlatformYM2608::acquire_ymfm(short* bufL, short* bufR, size_t start, siz
if (os[1]<-32768) os[1]=-32768;
if (os[1]>32767) os[1]=32767;
bufL[h]=os[0];
bufR[h]=os[1];
buf[0][h]=os[0];
buf[1][h]=os[1];
for (int i=0; i<6; i++) {
oscBuf[i]->data[oscBuf[i]->needle++]=(fmChan[i]->debug_output(0)+fmChan[i]->debug_output(1));
@ -715,6 +715,17 @@ void DivPlatformYM2608::tick(bool sysTick) {
}
chan[15].freqChanged=true;
}
if (chan[15].std.pitch.had) {
if (chan[15].std.pitch.mode) {
chan[15].pitch2+=chan[15].std.pitch.val;
CLAMP_VAR(chan[15].pitch2,-65535,65535);
} else {
chan[15].pitch2=chan[15].std.pitch.val;
}
chan[15].freqChanged=true;
}
if (chan[15].std.panL.had) {
if (chan[15].pan!=(chan[15].std.panL.val&3)) {
chan[15].pan=chan[15].std.panL.val&3;
@ -1424,8 +1435,8 @@ void DivPlatformYM2608::reset() {
ay->flushWrites();
}
bool DivPlatformYM2608::isStereo() {
return true;
int DivPlatformYM2608::getOutputCount() {
return 2;
}
bool DivPlatformYM2608::keyOffAffectsArp(int ch) {

View file

@ -70,11 +70,11 @@ class DivPlatformYM2608: public DivPlatformOPN {
friend void putDispatchChip(void*,int);
void acquire_combo(short* bufL, short* bufR, size_t start, size_t len);
void acquire_ymfm(short* bufL, short* bufR, size_t start, size_t len);
void acquire_combo(short** buf, size_t len);
void acquire_ymfm(short** buf, size_t len);
public:
void acquire(short* bufL, short* bufR, size_t start, size_t len);
void acquire(short** buf, size_t len);
int dispatch(DivCommand c);
void* getChanState(int chan);
DivMacroInt* getChanMacroInt(int ch);
@ -85,7 +85,7 @@ class DivPlatformYM2608: public DivPlatformOPN {
void forceIns();
void tick(bool sysTick=true);
void muteChannel(int ch, bool mute);
bool isStereo();
int getOutputCount();
bool keyOffAffectsArp(int ch);
void notifyInsChange(int ins);
void notifyInsDeletion(void* ins);

View file

@ -232,15 +232,15 @@ const char** DivPlatformYM2610::getRegisterSheet() {
return regCheatSheetYM2610;
}
void DivPlatformYM2610::acquire(short* bufL, short* bufR, size_t start, size_t len) {
void DivPlatformYM2610::acquire(short** buf, size_t len) {
if (useCombo) {
acquire_combo(bufL,bufR,start,len);
acquire_combo(buf,len);
} else {
acquire_ymfm(bufL,bufR,start,len);
acquire_ymfm(buf,len);
}
}
void DivPlatformYM2610::acquire_combo(short* bufL, short* bufR, size_t start, size_t len) {
void DivPlatformYM2610::acquire_combo(short** buf, size_t len) {
static int os[2];
static short ignored[2];
@ -255,7 +255,7 @@ void DivPlatformYM2610::acquire_combo(short* bufL, short* bufR, size_t start, si
adpcmAChan[i]=aae->debug_channel(i);
}
for (size_t h=start; h<start+len; h++) {
for (size_t h=0; h<len; h++) {
os[0]=0; os[1]=0;
// Nuked part
for (int i=0; i<24; i++) {
@ -317,8 +317,8 @@ void DivPlatformYM2610::acquire_combo(short* bufL, short* bufR, size_t start, si
if (os[1]<-32768) os[1]=-32768;
if (os[1]>32767) os[1]=32767;
bufL[h]=os[0];
bufR[h]=os[1];
buf[0][h]=os[0];
buf[1][h]=os[1];
for (int i=0; i<psgChanOffs; i++) {
@ -338,7 +338,7 @@ void DivPlatformYM2610::acquire_combo(short* bufL, short* bufR, size_t start, si
}
}
void DivPlatformYM2610::acquire_ymfm(short* bufL, short* bufR, size_t start, size_t len) {
void DivPlatformYM2610::acquire_ymfm(short** buf, size_t len) {
static int os[2];
ymfm::ym2610::fm_engine* fme=fm->debug_fm_engine();
@ -357,7 +357,7 @@ void DivPlatformYM2610::acquire_ymfm(short* bufL, short* bufR, size_t start, siz
adpcmAChan[i]=aae->debug_channel(i);
}
for (size_t h=start; h<start+len; h++) {
for (size_t h=0; h<len; h++) {
os[0]=0; os[1]=0;
if (!writes.empty()) {
if (--delay<1 && !(fm->read(0)&0x80)) {
@ -380,8 +380,8 @@ void DivPlatformYM2610::acquire_ymfm(short* bufL, short* bufR, size_t start, siz
if (os[1]<-32768) os[1]=-32768;
if (os[1]>32767) os[1]=32767;
bufL[h]=os[0];
bufR[h]=os[1];
buf[0][h]=os[0];
buf[1][h]=os[1];
for (int i=0; i<psgChanOffs; i++) {
oscBuf[i]->data[oscBuf[i]->needle++]=(fmChan[i]->debug_output(0)+fmChan[i]->debug_output(1));
@ -650,6 +650,17 @@ void DivPlatformYM2610::tick(bool sysTick) {
}
chan[adpcmBChanOffs].freqChanged=true;
}
if (chan[adpcmBChanOffs].std.pitch.had) {
if (chan[adpcmBChanOffs].std.pitch.mode) {
chan[adpcmBChanOffs].pitch2+=chan[adpcmBChanOffs].std.pitch.val;
CLAMP_VAR(chan[adpcmBChanOffs].pitch2,-65535,65535);
} else {
chan[adpcmBChanOffs].pitch2=chan[adpcmBChanOffs].std.pitch.val;
}
chan[adpcmBChanOffs].freqChanged=true;
}
if (chan[adpcmBChanOffs].std.panL.had) {
if (chan[adpcmBChanOffs].pan!=(chan[adpcmBChanOffs].std.panL.val&3)) {
chan[adpcmBChanOffs].pan=chan[adpcmBChanOffs].std.panL.val&3;
@ -1372,8 +1383,8 @@ void DivPlatformYM2610::reset() {
immWrite(0x1b,0xff); // B
}
bool DivPlatformYM2610::isStereo() {
return true;
int DivPlatformYM2610::getOutputCount() {
return 2;
}
bool DivPlatformYM2610::keyOffAffectsArp(int ch) {

Some files were not shown because too many files have changed in this diff Show more