koute / pinky

An NES emulator written in Rust

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Square 1 not playing

xram64 opened this issue · comments

I noticed SQ_1 was not playing in the roms I tested (using RetroArch).
I narrowed it down to virtual_apu.rs, line 577:
self.period.wrapping_sub( period_delta ).wrapping_sub( 1 )

That .wrapping_sub( 1 ) is the problem. If I change it to 0, or change it to .wrapping_add( 1 ), it seems to work fine. I'd make a pull request, but I'm honestly not sure what that subtraction is there for, so I don't know if/how it should be changed.

Edit: After reading over the APU doc again, I see that the subtraction is to account for the difference in SQ_1's sweep. Still not sure why a wrapping_sub there seems to silence the channel though. I can wrapping_add any number without a problem.