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

@ -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) {