fixing bug report from adrianlshaw, APU over- and underflowed when not running in --release mode

This commit is contained in:
Theron 2020-01-20 17:37:27 -06:00
parent ea70b592ce
commit a86e75c064
3 changed files with 8 additions and 4 deletions

View File

@ -1,6 +1,10 @@
# nestur
Nestur is an NES emulator and a work in progress. There are still some minor bugs and the audio is kind of scratchy. I've mostly tested on Donkey Kong, Super Mario Bros., and Zelda so far. There are plenty of full-featured emulators out there; this is primarily an educational project but I do want it to run well. SDL2 is the only dependency, it's NTSC timing, and contains no `unsafe` code.
Nestur is an NES emulator and a work in progress. There are likely still several bugs, and MMC3 support is not great. There are plenty of full-featured emulators out there; this is primarily an educational project but I do want it to run well.
- SDL2 is the only dependency
- no use of `unsafe`
- NTSC timing
- may only implement mappers 0-4 as these cover ~85% of games according to http://tuxnes.sourceforge.net/nesmapper.txt
<img src="pics/smb.png" width=350> <img src="pics/zelda_dungeon.png" width=350>
@ -34,7 +38,7 @@ The code aims to follow the explanations from the [NES dev wiki](https://wiki.ne
## To do:
- More mappers (only mappers 0 (NROM) and 1 (MMC1) implemented so far)
- Find any bugs with mappers 0-4 and improve mapper 5 (MMC3)
- DMC audio channel, high- and low-pass filters

View File

@ -147,7 +147,7 @@ impl Apu {
self.trigger_irq = true;
}
// advance counter
self.frame_counter += 1;
self.frame_counter = self.frame_counter.wrapping_add(1);
if self.frame_counter == self.frame_sequence {
self.frame_counter = 0;
}

View File

@ -113,7 +113,7 @@ impl Square {
// which produces different results when each channel's change amount is made negative:
// Pulse 1 adds the ones' complement (-c - 1). Making 20 negative produces a change amount of -21.
// Pulse 2 adds the two's complement (-c). Making 20 negative produces a change amount of -20.
if self.first_channel {
if self.first_channel && self.target_period >= 1 {
self.target_period -= 1;
}
} else {