Help me fix Wizards & Warriors

This is an archive of a topic from NESdev BBS, taken in mid-October 2019 before a server upgrade.
View original topic
Help me fix Wizards & Warriors
by on (#5503)
Wizards & Warriors does not run correctly in my emulator. When a level is loading (e.g. at the beginning of the game or anytime the player dies and starts a new life), the display flickers between the background and the status bar (which is in the wrong position):

Image Image

This lasts for about second, then the background is stable, the player appears, and everything works fine. Possibly related to this problem, the map screen does not display correctly:

Image

Notice the bottom half of 'Map' below the trees and castle. Has anyone seen these problems before or have any suggestions?

Thanks,
James

by on (#5506)
The game changes graphics mid-frame, and on your emulator that is occurring too soon relative to the PPU frame. I was able to reproduce the corrupt map display by extending the vblank time by 7 scanlines, causing the game to write sooner in the frame than it thought it was. This didn't cause the status display to appear at the top, though. When I turned sprite 0 hit checking off, the status display didn't show and the game froze until I turned hit checking back on, so the status display is timed based on sprite 0 hit, in case that helps.

by on (#5528)
Well, I did realize that I was in vblank for one scanline too long, and I was able to make the problem sort-of (some graph. corruption) go away by reducing vblank to 15 scanlines, but that can't be right.

Here's how I do my scanline-based emulation -- am I missing something?

0-19: Emulate CPU. At the end of line 19, clear vblank and sprite #0 hit flags. This is the vblank period.

20: Emulate CPU.

21-260: Emulate CPU, emulate PPU.

261: Emulate CPU. At the end of line 261, set the vblank flag and, if NMIs are enabled, emulate one CPU cycle, then emulate an NMI.

by on (#5585)
I think something is seriously messed up with my timing. If I clear the sprite #0 hit flag at the beginning of vblank, instead of the end, this problem goes away...