hopefully a positive breakthrough. was skipping reset of apu cycles and thus missing frame counter clocks when frame counter had been switched to 4-mode but current cycle was already beyond 14915.

This commit is contained in:
Theron Spiegl 2020-01-01 15:55:50 -06:00
parent 73b0a28034
commit 42b3544648
2 changed files with 7 additions and 5 deletions

View File

@ -77,8 +77,9 @@ impl Apu {
self.noise.clock();
self.dmc.clock();
if (self.frame_counter == 4 && FRAME_COUNTER_STEPS[..4].contains(&self.cycle))
|| (self.frame_counter == 5 && FRAME_COUNTER_STEPS.contains(&self.cycle)) {
// if (self.frame_counter == 4 && FRAME_COUNTER_STEPS[..4].contains(&self.cycle))
// || (self.frame_counter == 5 && FRAME_COUNTER_STEPS.contains(&self.cycle)) {
if FRAME_COUNTER_STEPS.contains(&self.cycle) {
self.clock_frame_counter();
}
if self.remainder > CYCLES_PER_SAMPLE {
@ -89,8 +90,7 @@ impl Apu {
self.remainder += 1.0;
self.cycle += 1;
if (self.frame_counter == 4 && self.cycle == 14915)
|| (self.frame_counter == 5 && self.cycle == 18641) {
if (self.frame_counter == 4 && self.cycle == 14915) || self.cycle == 18641 {
self.cycle = 0;
}
@ -267,6 +267,7 @@ impl Apu {
self.triangle.clock_length_counter();
self.noise.clock_envelope();
self.noise.clock_length_counter();
self.clock_frame_counter();
}
}
}

View File

@ -69,7 +69,8 @@ fn main() -> Result<(), String> {
match cpu.apu.clock() {
Some(sample) => {
sps += 1;
if sps < 44_100 {audio_device.queue(&vec![sample]);}
if sps < 44_100 {audio_device.queue(&vec![sample]);} // TODO: fix this
// audio_device.queue(&vec![sample]);
},
None => (),
};