Correct emulation of PAL DMC DMA cycle steals

Discuss emulation of the Nintendo Entertainment System and Famicom.

Moderator: Moderators

Post Reply
Bananmos
Posts: 552
Joined: Wed Mar 09, 2005 9:08 am
Contact:

Correct emulation of PAL DMC DMA cycle steals

Post by Bananmos »

Whilst trying out the new nifty PPU write register debug view in the Mesen emulator, I've realised that we still don't have correct emulation for the cycles stolen by the DMC DMA for PAL NES systems.

I tried running my old "Years Behind" music demo from 2003: https://files.scene.org/view/parties/20 ... behind.zip

This demo runs on PAL systems only, and compensates for the DMA DMC cycle steal by adjusting the skipped/taken cycle every scanline based on the current DMC playback rate. It's not 100% perfect, but mostly comes pretty close at keeping the writes within the safe hblank window.
(keep in mind some of the PPU register writes do happen before the hblank. This is perfectly fine, because they only affect the temporary 't' register rather than the 'v' register)

I've hacked this demo to replace the scroll register writes with writes to $2001 which enable/disable monochrome mode.
The hacked version can be found here: https://drive.google.com/open?id=1Uxsdx ... K4vlOplhYZ
And a video of it running on my PAL NES is here: https://drive.google.com/open?id=1JVvSY ... KsBdD9SCcr

Running the demo in an emulator produces a noticeably different view compared to the video, as the purple bar gets skewed *a lot more* and wraps around to the left side of the screen. Here's a screenshot in Mesen, for example:
MesenBoomjunk.png
I've also tried Nintendulator and FCEUX, and the results look pretty consistent with Mesen. So it looks like there's still an unsolved mystery when it comes to DMC DMA behavior on PAL systems.

Getting this right will probably involve a lot of analysis and test ROM writing. I don't have the time/motivation to be in the driving seat for this one, so just putting it out there in case someone is looking for one last emulation mystery to unravel. :)
But I'd be happy to assist with testing on my PAL console if anyone else picks this up.

Good starting points could be the DMC DMA tests previously done for NTSC systems:
https://forums.nesdev.com/viewtopic.php?f=3&t=14120
viewtopic.php?t=6100
Post Reply