Obviously, attempting to cram in some potential scrolling functionality into an engine not set up for it has proved to be a bit of a trial. But so far so good.
I went to add a sprite 0 hit to maintain the hud at the top of the screen. It's an easy enough concept, I get it. I had to add in a few caveats for the engine, so that it only does sprite 0 check if a flag is ticked, and tick and untick that, but other than that, everything seems like it should work.
And it *is* working, except the draw is getting corrupted. Where there should be a HUD, it seems to be overwritten with some junk graphic data (which remains static, as expected, while the level scrolls). It's absolutely the wait for the sprite 0 hit that is causing the issue, and I checked to see if I was gobbling up too much NMI time, but that doesn't seem to be the problem. What else might I check here to find what's being corrupted to end up causing this? Any thoughts, just based on what is described?
Thanks!
Some Sprite 0 hit weirdness
Moderator: Moderators
Re: Some Sprite 0 hit weirdness
Use a debugger.
Get a list of symbols, and find the address of just past the Sprite zero hit. Set a breakpoint for that. Then, set a breakpoint for writes to 2006 or 2007, which is probably causing the corruption (writes to PPU during rendering).
Get a list of symbols, and find the address of just past the Sprite zero hit. Set a breakpoint for that. Then, set a breakpoint for writes to 2006 or 2007, which is probably causing the corruption (writes to PPU during rendering).
nesdoug.com -- blog/tutorial on programming for the NES
Re: Some Sprite 0 hit weirdness
Yeah - that was my instinct. That rogue 2006 writes without 2005 writes were the problem. But...simply disabling the zero sprite hit wait dismissed the problem. Curious.
I'll try that, though!
I'll try that, though!
Re: Some Sprite 0 hit weirdness
When waiting for the sprite hit, are you first waiting for it to be cleared, and then set? Since the flag remains set all throughout vblank, you may end up prematurely triggering a split if you don't wait for the flag to be cleared first, which happens at the end of vblank.
Re: Some Sprite 0 hit weirdness
Ah - fixed it. Something stupid. Trying to read the sprite 0 check with drawing $2000 still set to 0 (at least, pretty sure that was it). Seems fixed now other than NOPing to get the timing so I don't get the flicker pixels. Thanks for the help - I think I just need to look at it with a cup of coffee. Love you guys!