UI flicker in Super Mario Bros / follow-up problem in IC

This is an archive of a topic from NESdev BBS, taken in mid-October 2019 before a server upgrade.
View original topic
UI flicker in Super Mario Bros / follow-up problem in IC
by on (#242246)
Hi guys,

I've been working on my NES emu for a few days now, and I have encountered a problem. It is very similar to this one here https://forums.nesdev.com/viewtopic.php?f=3&t=10762

As soon as the pixel 0,0 enters the 2nd Nametable, the UI starts to flicker, because of multiple writes of the base nametable address in PPUCTRL. Some of them are 0x2000 (as it is supposed to be, as the UI is still on NT1) and 0x2400 (which it should only be for everything below the UI).

I have a GIF of this right here

Image

(Don't mind the 'cut off' part, that was a sprite zero problem that has been fixed by now)

So, I thought I was able to fix this, by resetting the base nametable address [bits] to zero => 0x2000 on VBLANK. This will fix the flicker on Super Mario Bros., but will be responsible for a follow up bug in Ice Climber.

I was implementing Y-Scrolling in Ice Climber, when I realized this. With the reset-hack still in place, the upward-scrolls in Ice Climber will have glitches at the top, as soon as it is inside NT2 [again]. (Note, this is only coarse-scroll for now, fine-scroll has not been implemented yet)

Image

When I remove this hack, the Y-Scroll happens as it is supposed to.

Image

Now I am a bit stumped on how to proceed, and what might cause this exactly.

Side note: I did not implement the LoopyV/T stuff, as it confuses the hell out of me (I'm not a native speaker), and I'm not quite sure if I would have to refactor my whole PPU.
E.g. right now, the first write to 0x2005 is stored as uint8_t variable called scr_x. 'coarse x' is scr_x / 8 right now, 'fine x' is scr_x % 8. And in the loopy description I can't even figure out where to pull this from :-(

Any help would be greatly appreciated. Will provide logs, screenshots, whatever is necessary.

Thanks in advance!

LilaQ
Re: UI flicker in Super Mario Bros / follow-up problem in I
by on (#242264)
How are you emulating the effect of writes to $2006 on the base nametable address? Are you doing it through the t and v as described in The skinny on NES scrolling?
Re: UI flicker in Super Mario Bros / follow-up problem in I
by on (#242267)
PPUCTRL affects "Loopy T" only, not "Loopy V".
Re: UI flicker in Super Mario Bros / follow-up problem in I
by on (#242268)
I tried to implement the "v" and "t" mechanism now (as I didn't to this before), but now my Nametables don't get populated at all.

I did something like this before that:
Code:
//0x2006
void writePPUADDR(int adr) {
PPUADDR = adr
}
//0x2007
void writePPUDATA(int data) {
VRAM[PPUDATA] = data
}


Am I just supposed to use "v" instead of PPUADDR now? Sorry, but this really confuses me.
Re: UI flicker in Super Mario Bros / follow-up problem in I
by on (#242270)
Also, how will this affect the wrong base nametable address in PPUCTRL? :| :?:
Re: UI flicker in Super Mario Bros / follow-up problem in I
by on (#242289)
Okay, so I managed to get the flicker away with the use of v and t, to get the proper base nametable address.

Can someone please do me a favor, and tell me the coarse Y-scroll value of ice climbers, as soon as the game screen appears (where the bird is)? Mine is at 19, but it seems like it's supposed to be 18 - or 20 (I am one tile off).

Thanks!