Page 1 of 1

Help me fix Wizards & Warriors

Posted: Fri Oct 14, 2005 5:39 pm
by James
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

Posted: Fri Oct 14, 2005 6:35 pm
by blargg
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.

Posted: Sat Oct 15, 2005 9:12 am
by James
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.

Posted: Mon Oct 17, 2005 12:27 pm
by James
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...