AY: this sucks, part 2
This commit is contained in:
parent
9681f25e54
commit
ccf9277bfe
|
@ -164,23 +164,59 @@ void DivPlatformAY8930::checkWrites() {
|
|||
}
|
||||
}
|
||||
|
||||
void DivPlatformAY8930::acquire(short** buf, size_t len) {
|
||||
void DivPlatformAY8930::acquireDirect(blip_buffer_t** bb, size_t len) {
|
||||
thread_local short ayBuf[3];
|
||||
for (int i=0; i<3; i++) {
|
||||
oscBuf[i]->begin(len);
|
||||
}
|
||||
|
||||
for (size_t i=0; i<len; i++) {
|
||||
runDAC();
|
||||
int advance=len-i;
|
||||
// heuristic
|
||||
for (int j=0; j<3; j++) {
|
||||
// tone counter
|
||||
const int period=MAX(1,ay->m_tone[j].period)*(ay->m_step_mul<<1);
|
||||
const int remain=(period-ay->m_tone[j].count)>>5;
|
||||
if (remain<advance) advance=remain;
|
||||
|
||||
// envelope
|
||||
if (ay->m_envelope[j].holding==0) {
|
||||
const int periodEnv=MAX(1,ay->m_envelope[j].period)*ay->m_env_step_mul;
|
||||
const int remainEnv=periodEnv-ay->m_envelope[j].count;
|
||||
if (remainEnv<advance) advance=remainEnv;
|
||||
}
|
||||
}
|
||||
// noise
|
||||
const int noisePeriod=((int)ay->noise_period())*ay->m_step_mul;
|
||||
const int noiseRemain=noisePeriod-ay->m_count_noise;
|
||||
if (noiseRemain<advance) advance=noiseRemain;
|
||||
|
||||
//runDAC();
|
||||
|
||||
if (!writes.empty() || advance<1) advance=1;
|
||||
checkWrites();
|
||||
|
||||
ay->sound_stream_update(ayBuf,1);
|
||||
ay->sound_stream_update(ayBuf,advance);
|
||||
i+=advance-1;
|
||||
|
||||
if (stereo) {
|
||||
buf[0][i]=ayBuf[0]+ayBuf[1]+((ayBuf[2]*stereoSep)>>8);
|
||||
buf[1][i]=((ayBuf[0]*stereoSep)>>8)+ayBuf[1]+ayBuf[2];
|
||||
int out0=ayBuf[0]+ayBuf[1]+((ayBuf[2]*stereoSep)>>8);
|
||||
int out1=((ayBuf[0]*stereoSep)>>8)+ayBuf[1]+ayBuf[2];
|
||||
if (lastOut[0]!=out0) {
|
||||
blip_add_delta(bb[0],i,out0-lastOut[0]);
|
||||
lastOut[0]=out0;
|
||||
}
|
||||
if (lastOut[1]!=out1) {
|
||||
blip_add_delta(bb[1],i,out1-lastOut[1]);
|
||||
lastOut[1]=out1;
|
||||
}
|
||||
} else {
|
||||
buf[0][i]=ayBuf[0]+ayBuf[1]+ayBuf[2];
|
||||
buf[1][i]=buf[0][i];
|
||||
int out=ayBuf[0]+ayBuf[1]+ayBuf[2];
|
||||
if (lastOut[0]!=out) {
|
||||
blip_add_delta(bb[0],i,out-lastOut[0]);
|
||||
blip_add_delta(bb[1],i,out-lastOut[0]);
|
||||
lastOut[0]=out;
|
||||
}
|
||||
}
|
||||
|
||||
oscBuf[0]->putSample(i,ayBuf[0]<<2);
|
||||
|
@ -832,6 +868,8 @@ void DivPlatformAY8930::reset() {
|
|||
ayNoiseAnd=2;
|
||||
ayNoiseOr=0;
|
||||
delay=0;
|
||||
lastOut[0]=0;
|
||||
lastOut[1]=0;
|
||||
|
||||
extMode=false;
|
||||
bank=false;
|
||||
|
@ -854,6 +892,10 @@ bool DivPlatformAY8930::keyOffAffectsArp(int ch) {
|
|||
return true;
|
||||
}
|
||||
|
||||
bool DivPlatformAY8930::hasAcquireDirect() {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DivPlatformAY8930::getLegacyAlwaysSetVolume() {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -114,6 +114,7 @@ class DivPlatformAY8930: public DivDispatch {
|
|||
unsigned char sampleBank;
|
||||
|
||||
int delay;
|
||||
int lastOut[2];
|
||||
|
||||
bool extMode, stereo, clockSel;
|
||||
bool ioPortA, ioPortB;
|
||||
|
@ -131,7 +132,7 @@ class DivPlatformAY8930: public DivDispatch {
|
|||
friend void putDispatchChan(void*,int,int);
|
||||
|
||||
public:
|
||||
void acquire(short** buf, size_t len);
|
||||
void acquireDirect(blip_buffer_t** bb, size_t len);
|
||||
int dispatch(DivCommand c);
|
||||
void* getChanState(int chan);
|
||||
DivDispatchOscBuffer* getOscBuffer(int chan);
|
||||
|
@ -146,6 +147,7 @@ class DivPlatformAY8930: public DivDispatch {
|
|||
void setFlags(const DivConfig& flags);
|
||||
int getOutputCount();
|
||||
bool keyOffAffectsArp(int ch);
|
||||
bool hasAcquireDirect();
|
||||
DivMacroInt* getChanMacroInt(int ch);
|
||||
DivSamplePos getSamplePos(int ch);
|
||||
bool getLegacyAlwaysSetVolume();
|
||||
|
|
Loading…
Reference in a new issue