new dispatch, part 1

This commit is contained in:
tildearrow 2023-01-03 01:09:46 -05:00
parent 3e0dcbb0ae
commit a29f36a5df
64 changed files with 258 additions and 242 deletions

View File

@ -80,8 +80,11 @@
#include "song.h"
void DivDispatchContainer::setRates(double gotRate) {
blip_set_rates(bb[0],dispatch->rate,gotRate);
blip_set_rates(bb[1],dispatch->rate,gotRate);
int outs=dispatch->getOutputCount();
for (int i=0; i<outs; i++) {
blip_set_rates(bb[i],dispatch->rate,gotRate);
}
}
void DivDispatchContainer::setQuality(bool lowQual) {
@ -90,73 +93,68 @@ void DivDispatchContainer::setQuality(bool lowQual) {
void DivDispatchContainer::acquire(size_t offset, size_t count) {
int outs=dispatch->getOutputCount();
for (int i=0; i<outs; i++) {
bbInMapped[i]=&bbIn[i][offset];
for (int i=0; i<DIV_MAX_OUTPUTS; i++) {
if (i>=outs) {
bbInMapped[i]=NULL;
} else {
bbInMapped[i]=&bbIn[i][offset];
}
}
dispatch->acquire(bbInMapped,count);
}
void DivDispatchContainer::flush(size_t count) {
blip_read_samples(bb[0],bbOut[0],count,0);
int outs=dispatch->getOutputCount();
if (dispatch->isStereo()) {
blip_read_samples(bb[1],bbOut[1],count,0);
for (int i=0; i<outs; i++) {
blip_read_samples(bb[i],bbOut[i],count,0);
}
}
void DivDispatchContainer::fillBuf(size_t runtotal, size_t offset, size_t size) {
int outs=dispatch->getOutputCount();
if (dcOffCompensation && runtotal>0) {
dcOffCompensation=false;
prevSample[0]=bbIn[0][0];
if (dispatch->isStereo()) prevSample[1]=bbIn[1][0];
for (int i=0; i<outs; i++) {
prevSample[i]=bbIn[i][0];
}
}
if (lowQuality) {
for (size_t i=0; i<runtotal; i++) {
temp[0]=bbIn[0][i];
blip_add_delta_fast(bb[0],i,temp[0]-prevSample[0]);
prevSample[0]=temp[0];
}
if (dispatch->isStereo()) for (size_t i=0; i<runtotal; i++) {
temp[1]=bbIn[1][i];
blip_add_delta_fast(bb[1],i,temp[1]-prevSample[1]);
prevSample[1]=temp[1];
for (int i=0; i<outs; i++) {
for (size_t j=0; j<runtotal; j++) {
temp[i]=bbIn[i][j];
blip_add_delta_fast(bb[i],j,temp[i]-prevSample[i]);
prevSample[i]=temp[i];
}
}
} else {
for (size_t i=0; i<runtotal; i++) {
temp[0]=bbIn[0][i];
blip_add_delta(bb[0],i,temp[0]-prevSample[0]);
prevSample[0]=temp[0];
}
if (dispatch->isStereo()) for (size_t i=0; i<runtotal; i++) {
temp[1]=bbIn[1][i];
blip_add_delta(bb[1],i,temp[1]-prevSample[1]);
prevSample[1]=temp[1];
for (int i=0; i<outs; i++) {
for (size_t j=0; j<runtotal; j++) {
temp[i]=bbIn[i][j];
blip_add_delta(bb[i],j,temp[i]-prevSample[i]);
prevSample[i]=temp[i];
}
}
}
blip_end_frame(bb[0],runtotal);
blip_read_samples(bb[0],bbOut[0]+offset,size,0);
for (int i=0; i<outs; i++) {
blip_end_frame(bb[i],runtotal);
blip_read_samples(bb[i],bbOut[i]+offset,size,0);
}
/*if (totalRead<(int)size && totalRead>0) {
for (size_t i=totalRead; i<size; i++) {
bbOut[0][i]=bbOut[0][totalRead-1];//bbOut[0][totalRead];
}
}*/
if (dispatch->isStereo()) {
blip_end_frame(bb[1],runtotal);
blip_read_samples(bb[1],bbOut[1]+offset,size,0);
}
}
void DivDispatchContainer::clear() {
blip_clear(bb[0]);
blip_clear(bb[1]);
temp[0]=0;
temp[1]=0;
prevSample[0]=0;
prevSample[1]=0;
for (int i=0; i<DIV_MAX_OUTPUTS; i++) {
if (bb[i]!=NULL) blip_clear(bb[i]);
temp[i]=0;
prevSample[i]=0;
}
if (dispatch->getDCOffRequired()) {
dcOffCompensation=true;
}
@ -463,8 +461,8 @@ void DivDispatchContainer::init(DivSystem sys, DivEngine* eng, int chanCount, do
bbIn[i]=new short[bbInLen];
bbOut[i]=new short[bbInLen];
memset(bbIn,0,bbInLen*sizeof(short));
memset(bbOut,0,bbInLen*sizeof(short));
memset(bbIn[i],0,bbInLen*sizeof(short));
memset(bbOut[i],0,bbInLen*sizeof(short));
}
}

View File

@ -897,11 +897,7 @@ void DivEngine::runExportThread() {
for (int i=0; i<song.systemLen; i++) {
sf[i]=NULL;
si[i].samplerate=got.rate;
if (disCont[i].dispatch->isStereo()) {
si[i].channels=2;
} else {
si[i].channels=1;
}
si[i].channels=disCont[i].dispatch->getOutputCount();
si[i].format=SF_FORMAT_WAV|SF_FORMAT_PCM_16;
}
@ -944,11 +940,12 @@ void DivEngine::runExportThread() {
if (isFadingOut) {
double mul=(1.0-((double)curFadeOutSample/(double)fadeOutSamples));
for (int i=0; i<song.systemLen; i++) {
if (!disCont[i].dispatch->isStereo()) {
sysBuf[i][j]=(double)disCont[i].bbOut[0][j]*mul;
} else {
sysBuf[i][j<<1]=(double)disCont[i].bbOut[0][j]*mul;
sysBuf[i][1+(j<<1)]=(double)disCont[i].bbOut[1][j]*mul;
for (int k=0; k<si[i].channels; k++) {
if (disCont[i].bbOut[k]==NULL) {
sysBuf[i][k+(j*si[i].channels)]=0;
} else {
sysBuf[i][k+(j*si[i].channels)]=(double)disCont[i].bbOut[k][j]*mul;
}
}
}
if (++curFadeOutSample>=fadeOutSamples) {
@ -957,11 +954,12 @@ void DivEngine::runExportThread() {
}
} else {
for (int i=0; i<song.systemLen; i++) {
if (!disCont[i].dispatch->isStereo()) {
sysBuf[i][j]=disCont[i].bbOut[0][j];
} else {
sysBuf[i][j<<1]=disCont[i].bbOut[0][j];
sysBuf[i][1+(j<<1)]=disCont[i].bbOut[1][j];
for (int k=0; k<si[i].channels; k++) {
if (disCont[i].bbOut[k]==NULL) {
sysBuf[i][k+(j*si[i].channels)]=0;
} else {
sysBuf[i][k+(j*si[i].channels)]=disCont[i].bbOut[k][j];
}
}
}
if (lastLoopPos>-1 && j>=lastLoopPos && totalLoops>=exportLoopCount) {
@ -1904,10 +1902,11 @@ String DivEngine::getPlaybackDebugInfo() {
"speed1: %d\n"
"speed2: %d\n"
"tempoAccum: %d\n"
"totalProcessed: %d\n",
"totalProcessed: %d\n"
"bufferPos: %d\n",
curOrder,prevOrder,curRow,prevRow,ticks,subticks,totalLoops,lastLoopPos,nextSpeed,divider,cycles,clockDrift,
changeOrd,changePos,totalSeconds,totalTicks,totalTicksR,totalCmds,lastCmds,cmdsPerSecond,globalPitch,
(int)extValue,(int)speed1,(int)speed2,(int)tempoAccum,(int)totalProcessed
(int)extValue,(int)speed1,(int)speed2,(int)tempoAccum,(int)totalProcessed,(int)bufferPos
);
}
@ -4311,6 +4310,10 @@ bool DivEngine::init() {
if (!haveAudio) {
return false;
} else {
if (output==NULL) {
logE("output is NULL!");
return false;
}
if (!output->setRun(true)) {
logE("error while activating!");
return false;

View File

@ -195,12 +195,12 @@ struct DivDispatchContainer {
lastAvail(0),
lowQuality(false),
dcOffCompensation(false) {
memset(bb,0,DIV_MAX_OUTPUTS*sizeof(void*));
memset(bb,0,DIV_MAX_OUTPUTS*sizeof(blip_buffer_t*));
memset(temp,0,DIV_MAX_OUTPUTS*sizeof(int));
memset(prevSample,0,DIV_MAX_OUTPUTS*sizeof(int));
memset(bbIn,0,DIV_MAX_OUTPUTS*sizeof(void*));
memset(bbInMapped,0,DIV_MAX_OUTPUTS*sizeof(void*));
memset(bbOut,0,DIV_MAX_OUTPUTS*sizeof(void*));
memset(bbIn,0,DIV_MAX_OUTPUTS*sizeof(short*));
memset(bbInMapped,0,DIV_MAX_OUTPUTS*sizeof(short*));
memset(bbOut,0,DIV_MAX_OUTPUTS*sizeof(short*));
}
};
@ -356,6 +356,7 @@ class DivEngine {
int softLockCount;
int subticks, ticks, curRow, curOrder, prevRow, prevOrder, remainingLoops, totalLoops, lastLoopPos, exportLoopCount, nextSpeed, elapsedBars, elapsedBeats;
size_t curSubSongIndex;
size_t bufferPos;
double divider;
int cycles;
double clockDrift;
@ -905,6 +906,9 @@ class DivEngine {
// set metronome volume (1.0 = 100%)
void setMetronomeVol(float vol);
// get buffer position
int getBufferPos();
// halt now
void halt();
@ -1073,6 +1077,7 @@ class DivEngine {
elapsedBars(0),
elapsedBeats(0),
curSubSongIndex(0),
bufferPos(0),
divider(60),
cycles(0),
clockDrift(0),

View File

@ -50,10 +50,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();
@ -89,12 +89,12 @@ void DivPlatformArcade::acquire_nuked(short* bufL, short* bufR, size_t start, si
}
}
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) {
@ -128,9 +128,9 @@ void DivPlatformArcade::acquire_ymfm(short* bufL, short* bufR, size_t start, siz
void DivPlatformArcade::acquire(short** buf, size_t len) {
if (useYMFM) {
acquire_ymfm(buf[0],buf[1],0,len);
acquire_ymfm(buf,len);
} else {
acquire_nuked(buf[0],buf[1],0,len);
acquire_nuked(buf,len);
}
}

View File

@ -58,8 +58,8 @@ 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);

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;
buf[0][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;
buf[0][i]=sample;
buf[i]=sample;
if (++writeOscBuf>=32) {
writeOscBuf=0;
oscBuf->data[oscBuf->needle++]=sample<<1;
@ -95,9 +95,9 @@ void DivPlatformFDS::doWrite(unsigned short addr, unsigned char data) {
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,8 +62,8 @@ 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** buf, size_t len);

View File

@ -60,7 +60,7 @@ void DivPlatformGA20::acquire(short** buf, 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()) {

View File

@ -62,7 +62,7 @@ const char** DivPlatformGB::getRegisterSheet() {
}
void DivPlatformGB::acquire(short** buf, size_t len) {
for (size_t i=start; i<start+len; i++) {
for (size_t i=0; i<len; i++) {
if (!writes.empty()) {
QueuedWrite& w=writes.front();
GB_apu_write(gb,w.addr,w.val);

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;
@ -191,12 +191,12 @@ void DivPlatformGenesis::acquire_nuked(short* bufL, short* bufR, size_t start, s
}
}
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;
@ -249,9 +249,9 @@ void DivPlatformGenesis::acquire_ymfm(short* bufL, short* bufR, size_t start, si
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);
}
}

View File

@ -92,8 +92,8 @@ 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);

View File

@ -55,7 +55,7 @@ inline void DivPlatformK007232::chWrite(unsigned char ch, unsigned int addr, uns
}
void DivPlatformK007232::acquire(short** buf, 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()) {

View File

@ -131,7 +131,7 @@ const char** DivPlatformLynx::getRegisterSheet() {
}
void DivPlatformLynx::acquire(short** buf, size_t len) {
for (size_t h=start; h<start+len; h++) {
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** buf, size_t len) {
}
}
mikey->sampleAudio( bufL + h, bufR + h, 1, oscBuf );
mikey->sampleAudio(buf[0]+h,buf[1]+h,1,oscBuf);
}
}

View File

@ -44,7 +44,7 @@ const char** DivPlatformMMC5::getRegisterSheet() {
}
void DivPlatformMMC5::acquire(short** buf, size_t len) {
for (size_t i=start; i<start+len; i++) {
for (size_t i=0; i<len; i++) {
if (dacSample!=-1) {
dacPeriod+=dacRate;
if (dacPeriod>=rate) {

View File

@ -46,7 +46,7 @@ const char** DivPlatformMSM5232::getRegisterSheet() {
}
void DivPlatformMSM5232::acquire(short** buf, size_t len) {
for (size_t h=start; h<start+len; h++) {
for (size_t h=0; h<len; h++) {
while (!writes.empty()) {
QueuedWrite w=writes.front();
msm->write(w.addr,w.val);

View File

@ -35,7 +35,7 @@ void DivPlatformMSM6258::acquire(short** buf, size_t len) {
&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()) {

View File

@ -38,7 +38,7 @@ u8 DivPlatformMSM6295::read_byte(u32 address) {
}
void DivPlatformMSM6295::acquire(short** buf, size_t len) {
for (size_t h=start; h<start+len; h++) {
for (size_t h=0; h<len; h++) {
if (delay<=0) {
if (!writes.empty()) {
QueuedWrite& w=writes.front();

View File

@ -109,7 +109,7 @@ const char** DivPlatformN163::getRegisterSheet() {
}
void DivPlatformN163::acquire(short** buf, size_t len) {
for (size_t i=start; i<start+len; i++) {
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;

View File

@ -171,11 +171,11 @@ void DivPlatformNamcoWSG::acquire(short** buf, size_t len) {
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;
}

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);
@ -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);
@ -153,9 +153,9 @@ void DivPlatformNES::acquire_NSFPlay(short* bufL, short* bufR, size_t start, siz
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);
}
}

View File

@ -68,8 +68,8 @@ 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** buf, size_t len);

View File

@ -159,12 +159,12 @@ 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) {
void DivPlatformOPL::acquire_nuked(short** buf, size_t len) {
static short o[2];
static int os[2];
static ymfm::ymfm_output<2> aOut;
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() && --delay<0) {
delay=1;
@ -264,9 +264,9 @@ void DivPlatformOPL::acquire_nuked(short* bufL, short* bufR, size_t start, size_
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);
//}
}

View File

@ -104,8 +104,8 @@ 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** buf, size_t len);

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) {
@ -87,11 +87,11 @@ void DivPlatformOPLL::acquire_nuked(short* bufL, short* bufR, size_t start, size
}
}
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** buf, size_t len) {
acquire_nuked(bufL,bufR,start,len);
acquire_nuked(buf,len);
}
void DivPlatformOPLL::tick(bool sysTick) {

View File

@ -77,8 +77,8 @@ 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** buf, size_t len);

View File

@ -54,7 +54,7 @@ const char** DivPlatformPCE::getRegisterSheet() {
}
void DivPlatformPCE::acquire(short** buf, size_t len) {
for (size_t h=start; h<start+len; h++) {
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) {

View File

@ -29,7 +29,7 @@
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) {
buf[0][h]=0;
buf[1][h]=0;

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;
@ -216,8 +216,8 @@ void DivPlatformPCSpeaker::acquire_unfilt(short* bufL, short* bufR, size_t start
}
}
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;
@ -243,8 +243,8 @@ void DivPlatformPCSpeaker::acquire_cone(short* bufL, short* bufR, size_t start,
}
}
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;
@ -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;
@ -324,16 +324,16 @@ void DivPlatformPCSpeaker::acquire_real(short* bufL, short* bufR, size_t start,
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,10 +61,10 @@ 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();

View File

@ -62,7 +62,7 @@ void DivPlatformPET::acquire(short** buf, size_t len) {
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);
@ -78,7 +78,7 @@ void DivPlatformPET::acquire(short** buf, size_t len) {
if (!hwSROutput) regPool[12]=chan[0].out?0xe0:0xc0;
} else {
chan[0].out=0;
for (size_t h=start; h<start+len; h++) {
for (size_t h=0; h<len; h++) {
buf[0][h]=0;
buf[1][h]=0;
oscBuf->data[oscBuf->needle++]=0;

View File

@ -88,7 +88,7 @@ void DivPlatformPokeMini::rWrite(unsigned char addr, unsigned char val) {
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) {

View File

@ -66,14 +66,14 @@ const char** DivPlatformPOKEY::getRegisterSheet() {
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);

View File

@ -59,8 +59,8 @@ class DivPlatformPOKEY: public DivDispatch {
friend void putDispatchChan(void*,int,int);
public:
void acquire(short** buf, size_t len);
void acquireMZ(short* buf, size_t start, size_t len);
void acquireASAP(short* buf, size_t start, 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

@ -25,7 +25,7 @@
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;

View File

@ -266,7 +266,7 @@ const char** DivPlatformQSound::getRegisterSheet() {
}
void DivPlatformQSound::acquire(short** buf, size_t len) {
for (size_t h=start; h<start+len; h++) {
for (size_t h=0; h<len; h++) {
qsound_update(&chip);
buf[0][h]=chip.out[0];
buf[1][h]=chip.out[1];

View File

@ -54,16 +54,18 @@ void DivPlatformRF5C68::chWrite(unsigned char ch, unsigned int addr, unsigned ch
}
}
// TODO: this code is weird
// make sure newDispatch didn't break it up
void DivPlatformRF5C68::acquire(short** buf, size_t len) {
short buf[16][256];
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) {
@ -72,7 +74,7 @@ void DivPlatformRF5C68::acquire(short** buf, size_t len) {
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;

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++) {
buf[0][i+start]=(short)((((unsigned short)saaBuf[0][1+(i<<1)])<<8)|(((unsigned short)saaBuf[0][1+(i<<1)])>>8));
buf[1][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++) {
buf[0][i+start]=saaBuf[0][i<<1];
buf[1][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** buf, size_t len) {
acquire_saaSound(bufL,bufR,start,len);
acquire_saaSound(buf,len);
}
inline unsigned char applyPan(unsigned char vol, unsigned char pan) {

View File

@ -71,7 +71,7 @@ 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** buf, size_t len);

View File

@ -81,7 +81,7 @@ const char** DivPlatformSCC::getRegisterSheet() {
}
void DivPlatformSCC::acquire(short** buf, size_t len) {
for (size_t h=start; h<start+len; h++) {
for (size_t h=0; h<len; h++) {
for (int i=0; i<16; i++) {
scc->tick();
}

View File

@ -29,7 +29,7 @@
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;

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) {
@ -74,7 +74,7 @@ void DivPlatformSMS::acquire_nuked(short* bufL, short* bufR, size_t start, size_
if (oR<-32768) oR=-32768;
if (oR>32767) oR=32767;
buf[0][h]=oL;
buf[1][h]=oR;
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]={
&buf[0][h],
&buf[1][h]
stereo?(&buf[1][h]):NULL
};
sn->sound_stream_update(outs,1);
for (int i=0; i<4; i++) {
@ -113,9 +113,9 @@ void DivPlatformSMS::acquire_mame(short* bufL, short* bufR, size_t start, size_t
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);
}
}

View File

@ -66,8 +66,8 @@ 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** buf, size_t len);
int dispatch(DivCommand c);

View File

@ -68,7 +68,7 @@ const char** DivPlatformSNES::getRegisterSheet() {
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()) {

View File

@ -41,7 +41,7 @@ double DivPlatformSoundUnit::NOTE_SU(int ch, int note) {
}
void DivPlatformSoundUnit::acquire(short** buf, size_t len) {
for (size_t h=start; h<start+len; h++) {
for (size_t h=0; h<len; h++) {
while (!writes.empty()) {
QueuedWrite w=writes.front();
su->Write(w.addr,w.val);

View File

@ -51,7 +51,7 @@ const char** DivPlatformSwan::getRegisterSheet() {
}
void DivPlatformSwan::acquire(short** buf, size_t len) {
for (size_t h=start; h<start+len; h++) {
for (size_t h=0; h<len; h++) {
// PCM part
if (pcm && dacSample!=-1) {
dacPeriod+=dacRate;

View File

@ -36,7 +36,7 @@ const char** DivPlatformT6W28::getRegisterSheet() {
}
void DivPlatformT6W28::acquire(short** buf, size_t len) {
for (size_t h=start; h<start+len; h++) {
for (size_t h=0; h<len; h++) {
cycles=0;
while (!writes.empty() && cycles<16) {
QueuedWrite w=writes.front();

View File

@ -39,7 +39,7 @@ const char** DivPlatformTIA::getRegisterSheet() {
}
void DivPlatformTIA::acquire(short** buf, size_t len) {
for (size_t h=start; h<start+len; h++) {
for (size_t h=0; h<len; h++) {
tia.tick();
if (mixingType==2) {
buf[0][h]=tia.myCurrentSample[0];

View File

@ -60,7 +60,7 @@ void DivPlatformTX81Z::acquire(short** buf, size_t len) {
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) {

View File

@ -94,7 +94,7 @@ const char** DivPlatformVB::getRegisterSheet() {
}
void DivPlatformVB::acquire(short** buf, size_t len) {
for (size_t h=start; h<start+len; h++) {
for (size_t h=0; h<len; h++) {
cycles=0;
while (!writes.empty()) {
QueuedWrite w=writes.front();

View File

@ -56,8 +56,8 @@ const char** DivPlatformVERA::getRegisterSheet() {
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** buf, 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);
buf[0][pos]=(short)(((int)buf[0][i]+buf[2][i])/2);
buf[1][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;

View File

@ -45,7 +45,7 @@ void DivPlatformVIC20::acquire(short** buf, size_t len) {
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++) {

View File

@ -47,7 +47,7 @@ const char** DivPlatformVRC6::getRegisterSheet() {
}
void DivPlatformVRC6::acquire(short** buf, size_t len) {
for (size_t i=start; i<start+len; i++) {
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) {

View File

@ -206,7 +206,7 @@ const char** DivPlatformX1_010::getRegisterSheet() {
}
void DivPlatformX1_010::acquire(short** buf, size_t len) {
for (size_t h=start; h<start+len; h++) {
for (size_t h=0; h<len; h++) {
x1_010.tick();
signed int tempL=x1_010.output(0);

View File

@ -158,17 +158,17 @@ const char** DivPlatformYM2203::getRegisterSheet() {
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++) {
@ -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) {

View File

@ -55,8 +55,8 @@ 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** buf, size_t len);

View File

@ -299,13 +299,13 @@ double DivPlatformYM2608::NOTE_ADPCMB(int note) {
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++) {
@ -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) {

View File

@ -70,8 +70,8 @@ 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** buf, size_t len);

View File

@ -234,13 +234,13 @@ const char** DivPlatformYM2610::getRegisterSheet() {
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++) {
@ -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)) {

View File

@ -38,8 +38,8 @@ class DivPlatformYM2610: public DivPlatformYM2610Base {
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** buf, size_t len);

View File

@ -298,13 +298,13 @@ const char** DivPlatformYM2610B::getRegisterSheet() {
void DivPlatformYM2610B::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 DivPlatformYM2610B::acquire_combo(short* bufL, short* bufR, size_t start, size_t len) {
void DivPlatformYM2610B::acquire_combo(short** buf, size_t len) {
static int os[2];
static short ignored[2];
@ -319,7 +319,7 @@ void DivPlatformYM2610B::acquire_combo(short* bufL, short* bufR, size_t start, s
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++) {
@ -406,7 +406,7 @@ void DivPlatformYM2610B::acquire_combo(short* bufL, short* bufR, size_t start, s
}
}
void DivPlatformYM2610B::acquire_ymfm(short* bufL, short* bufR, size_t start, size_t len) {
void DivPlatformYM2610B::acquire_ymfm(short** buf, size_t len) {
static int os[2];
ymfm::ym2610b::fm_engine* fme=fm->debug_fm_engine();
@ -423,7 +423,7 @@ void DivPlatformYM2610B::acquire_ymfm(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;
if (!writes.empty()) {
if (--delay<1 && !(fm->read(0)&0x80)) {

View File

@ -34,8 +34,8 @@ class DivPlatformYM2610B: public DivPlatformYM2610Base {
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** buf, size_t len);

View File

@ -61,12 +61,12 @@ const char** DivPlatformYMZ280B::getRegisterSheet() {
}
void DivPlatformYMZ280B::acquire(short** buf, size_t len) {
short buf[16][256];
short why[16][256];
short *bufPtrs[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]
why[0],why[1],why[2],why[3],why[4],why[5],why[6],why[7],
why[8],why[9],why[10],why[11],why[12],why[13],why[14],why[15]
};
size_t pos=start;
size_t pos=0;
while (len > 0) {
size_t blockLen = MIN(len, 256);
ymz280b.sound_stream_update(bufPtrs, blockLen);
@ -74,9 +74,9 @@ void DivPlatformYMZ280B::acquire(short** buf, size_t len) {
int dataL=0;
int dataR=0;
for (int j=0; j<8; j++) {
dataL+=buf[j*2][i];
dataR+=buf[j*2+1][i];
oscBuf[j]->data[oscBuf[j]->needle++]=(short)(((int)buf[j*2][i]+buf[j*2+1][i])/2);
dataL+=why[j*2][i];
dataR+=why[j*2+1][i];
oscBuf[j]->data[oscBuf[j]->needle++]=(short)(((int)why[j*2][i]+why[j*2+1][i])/2);
}
buf[0][pos]=(short)(dataL/8);
buf[1][pos]=(short)(dataR/8);

View File

@ -29,7 +29,7 @@ const char** DivPlatformZXBeeper::getRegisterSheet() {
void DivPlatformZXBeeper::acquire(short** buf, size_t len) {
bool o=false;
for (size_t h=start; h<start+len; h++) {
for (size_t h=0; h<len; h++) {
// clock here
if (curSample>=0 && curSample<parent->song.sampleLen) {
if (--curSamplePeriod<0) {

View File

@ -1359,6 +1359,10 @@ bool DivEngine::nextTick(bool noAccum, bool inhibitLowLat) {
return ret;
}
int DivEngine::getBufferPos() {
return bufferPos>>MASTER_CLOCK_PREC;
}
void DivEngine::nextBuf(float** in, float** out, int inChans, int outChans, unsigned int size) {
lastLoopPos=-1;
@ -1619,6 +1623,9 @@ void DivEngine::nextBuf(float** in, float** out, int inChans, int outChans, unsi
int attempts=0;
int runLeftG=size<<MASTER_CLOCK_PREC;
while (++attempts<(int)size) {
// -1. set bufferPos
bufferPos=(size<<MASTER_CLOCK_PREC)-runLeftG;
// 0. check if we've halted
if (halted) break;
// 1. check whether we are done with all buffers
@ -1693,12 +1700,13 @@ void DivEngine::nextBuf(float** in, float** out, int inChans, int outChans, unsi
disCont[i].fillBuf(disCont[i].runtotal,disCont[i].lastAvail,size-disCont[i].lastAvail);
}
// TODO: handle more than 2 outputs
for (int i=0; i<song.systemLen; i++) {
float volL=((float)song.systemVol[i]/64.0f)*((float)MIN(127,127-(int)song.systemPan[i])/127.0f)*song.masterVol;
float volR=((float)song.systemVol[i]/64.0f)*((float)MIN(127,127+(int)song.systemPan[i])/127.0f)*song.masterVol;
volL*=disCont[i].dispatch->getPostAmp();
volR*=disCont[i].dispatch->getPostAmp();
if (disCont[i].dispatch->isStereo()) {
if (disCont[i].dispatch->getOutputCount()>1) {
for (size_t j=0; j<size; j++) {
out[0][j]+=((float)disCont[i].bbOut[0][j]/32768.0)*volL;
out[1][j]+=((float)disCont[i].bbOut[1][j]/32768.0)*volR;