AY: this sucks, part 3
improve heuristics... noise is very slow
This commit is contained in:
parent
ccf9277bfe
commit
42920b9101
|
|
@ -255,33 +255,59 @@ void DivPlatformAY8910::acquire_mame(blip_buffer_t** bb, size_t len) {
|
|||
oscBuf[i]->begin(len);
|
||||
}
|
||||
|
||||
//logV("%d, %d, %d",ay->noise_enable(0),ay->noise_enable(1),ay->noise_enable(2));
|
||||
|
||||
for (size_t i=0; i<len; i++) {
|
||||
int advance=len-i;
|
||||
bool careAboutEnv=false;
|
||||
bool careAboutNoise=false;
|
||||
// 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;
|
||||
if (remain<advance) advance=remain;
|
||||
if (!ay->tone_enable(j) && ay->m_tone[j].volume!=0) {
|
||||
const int period=MAX(1,ay->m_tone[j].period)*(ay->m_step_mul<<1);
|
||||
const int remain=(period-ay->m_tone[j].count)>>1;
|
||||
if (remain<advance) {
|
||||
advance=remain;
|
||||
}
|
||||
}
|
||||
|
||||
// envelope
|
||||
if (j<1) {
|
||||
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;
|
||||
// count me in if I have noise enabled
|
||||
if (!ay->noise_enable(j) && ay->m_tone[j].volume!=0) {
|
||||
careAboutNoise=true;
|
||||
}
|
||||
|
||||
// envelope check
|
||||
if (ay->m_tone[j].volume&16) {
|
||||
careAboutEnv=true;
|
||||
}
|
||||
}
|
||||
// envelope
|
||||
if (careAboutEnv) {
|
||||
if (ay->m_envelope[0].holding==0) {
|
||||
const int periodEnv=MAX(1,ay->m_envelope[0].period)*ay->m_env_step_mul;
|
||||
const int remainEnv=periodEnv-ay->m_envelope[0].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;
|
||||
if (careAboutNoise) {
|
||||
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();
|
||||
//runTFX();
|
||||
|
||||
if (!writes.empty() || advance<1) advance=1;
|
||||
if (!writes.empty() || advance<1) {
|
||||
//logV("must write, advance is 1");
|
||||
advance=1;
|
||||
}
|
||||
checkWrites();
|
||||
|
||||
ay->sound_stream_update(ayBuf,advance);
|
||||
|
|
|
|||
|
|
@ -1060,21 +1060,21 @@ void ay8910_device::sound_stream_update(short* outputs, int advance)
|
|||
tone = &m_tone[chan];
|
||||
const int period = std::max<int>(1, tone->period) * (m_step_mul << 1);
|
||||
tone->count += advance << (is_expanded_mode() ? 5 : ((m_feature & PSG_HAS_EXPANDED_MODE) ? 0 : 1));
|
||||
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;
|
||||
}
|
||||
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;
|
||||
m_count_noise+=advance;
|
||||
while (m_count_noise >= period_noise)
|
||||
if (m_count_noise >= period_noise)
|
||||
{
|
||||
/* toggle the prescaler output. Noise is no different to
|
||||
* channels.
|
||||
*/
|
||||
m_count_noise -= period_noise;
|
||||
m_count_noise = 0;
|
||||
m_prescale_noise = (m_prescale_noise + 1) & ((m_feature & PSG_HAS_EXPANDED_MODE) ? 3 : 1);
|
||||
|
||||
if (is_expanded_mode()) // AY8930 noise generator rate is twice? compares as compatibility mode
|
||||
|
|
|
|||
Loading…
Reference in a new issue