I'll let you work on the audio stuff first then I can test going forward and report back on that.
The only reason I tried different sample rates is because the base frequency sounded wrong even at the default of 96000Hz -- meaning everything still sounded too high pitched (octave-wise). I tried lower frequencies and was like "oh nice, now the octave decreases.... and buffer underrun, whee!!!" Haha.
I'm happy to help you test whatever is needed.
Other things / details I experienced:
1. Joypad input is still honoured even if the application has lost focus
2. Application focus -- emulator still runs in the background even when lost focus,
except the music. This is a little strange to say the least. I'm guessing it's the root cause of the above item too
3. Emulator crash -- tried to load Blaster Master.nes (can send ROM if need be), so your guess that it's code relating to mappers is almost certainly spot on
4. Emulator saves last X/Y coordinates of the window when you quit. But upon re-launching the emulator, the emulator appears briefly in the upper left of the desktop (certainly positioned by Windows), then obviously moves itself to the saved X/Y coordinates. Emulator shouldn't appear in the upper left at all.
5. Please do away with the "Do you wish to quit?" dialog -- annoying. Else if it's preferred, make it a toggleable option.
6. Input configuration (joypad) -- please make this a native Windows configuration thing, and not something done within the emulator the way it is. Look at how Nestopia does it (meaning the style/model) -- it's easily the best style/model I've seen.
7. When a ROM isn't loaded, File -> ROM information... should be greyed out; thus there's no point to the Dialog() of "No ROM is currently loaded".
8. Same goes for "Close ROM" -- if a ROM isn't loaded, Close ROM should be greyed out.
9. Emulation -> CPU needs segregation between a hard reset (power-cycle) and soft reset (hitting reset button on NES / jumping to RESET vector). This is very important for games like Zanac, where if you soft reset the game 13 times, you get a special menu.
10. Joypad input -- this one is really hard to explain from a UI perspective. Basically with my joypad (it's a Playstation->USB adapter), your emulator requires me to press the "Analog" button on my PS2 controller before I can use the digital pad. I've seen this before in other emulators and it's shameful behaviour. In Nestopia, with "Analog" off, I see "(joy 0) -x" when pressing Left, while with "Analog" on I see "(joy 0) -p0x". So long story short I think you need to support some kind of other X/Y axis model that Windows or UHID provides, I just forget what it's called!
11. There have been many times where I'd loaded one game, played for a short bit (few seconds), then loaded another game and found its audio to be *completely* screwed up. It looks/sounds to me like you're not resetting your internal APU system state correctly or completely, i.e. there are some variables you need to reset/clear/reinitialise when loading a ROM image.
12. Please don't change the mouse cursor (invert its colour) when its X/Y coordinate is within the rendering/drawing surface. Maybe SDL is doing this, in which case I'll live with it. Moral: the less crap you mess with the better off you'll be.
I'm intentionally leaving out all the audio anomalies I hear (they're obviously issues with the emulation, and that's totally okay! Work in progress!
), but I have lots of games that sound quite wrong in many ways, sans one game:
About Megaman 2, since you stated it sounds pretty much perfect to you:
When firing Megaman's gun, there is what sounds like a bass-y "fart" noise at the end of the effect. You don't have to have an amazing ear to hear it, but I noticed it immediately. It's clearest on Air Man's level. I hear something similar when picking Normal/Difficult from the main menu, as Megaman flies off into the stratosphere, and when selecting a level.
Yeah, you're right I can hear the fart noise. I've noticed it before, but haven't taken a good look yet. The audio stuff has been tough for me, this is the first time I wrote a serious software model to emulate a sound chip. You should have heard my first attempt, the current code sounds amazing compared to what it used to be.
That is a lot of issues you've got listed. Some I was aware of, others not. Blaster Master works here, btw. It plays well too. Maybe you have a slightly different version. I agree about the joystick config too, but that is very low in my priority list right now. I thought it was a decent enough makeshift way to config the controls for the time being. I've never designed and used an actual Windows form in C before, so that's why I'm putting that off. I'll tackle it once the emulator is more accurate, that's the important thing.
BTW, the inverted mouse cursor is an SDL thing. I'm sure there's a way to stop it. Maybe not directly with an SDL function, but I can always come up with some sort of hack to get around it. After all, the menubar on the SDL form is a hack. If you're resourceful enough with the Win32 API, basically anything can be done.
The sound disappearing is an XP+SDL quirk, btw. I have an old Pentium 1 MMX running XP, and the same thing happens there. It keeps playing here on Windows 7. I'm going to just force the emu to pause on losing focus anyway. That's actually caused me to get killed in games a handful of times if another window decides to pop up, or i accidentally hit the Windows key.
I'm doing a bit more work on the code. I didn't get enough time to work on it yet, so tomorrow I'll definitely come back and upload with some fixes. I may or may not need tips with some of the audio bugs, not sure yet. Damn NES sound hardware is so quirky.