F1 Race glitch

Discuss emulation of the Nintendo Entertainment System and Famicom.

Moderator: Moderators

Post Reply
XiruProgrammer
Posts: 2
Joined: Fri Jun 10, 2022 4:11 am

F1 Race glitch

Post by XiruProgrammer »

Hello guys, this is my first post here hoping to get some help from your expertise.
It´s been a while since i started my own NES emulator development in Java for both learning purposes and fun. The main focus is to run decently most games, not high accuracy. So the main loop is instruction based, ie. it runs one opcode then updates 3 PPU cycles for each CPU cycle. To date, ~500 games are working pretty well, Battletoads included. But there are some minor glitches that are bogging me down, like the horizontal strips in F1 Race shown down. The same problem happens in Mach Rider. I have seen this exact same pattern in some older emulators, such as first versions of MESS. From this discussion: viewtopic.php?t=18682&hilit=F+1+Race&start=45, I have learned it has something to do with scrolling to curve the track, but this problem does not occur in Galaxian and 3-D Battles of World Runner.
Here are the screenshots. What you guys think I am missing here ? Sorry for my bad english, thank you in advance ! :D :beer:
Attachments
F1Race.png
MachRider.png
User avatar
Dwedit
Posts: 4924
Joined: Fri Nov 19, 2004 7:35 pm
Contact:

Re: F1 Race glitch

Post by Dwedit »

When you write to horizontal scroll, it doesn't do what you think it does.

https://www.nesdev.org/wiki/PPU_scrolli ... e_(w_is_0)

First write to $2005 affects "Fine X" (lowest 3 bits of horizontal scrolling), and "T".
At dot 257 of the scanline, all X related bits of "T" get copied to "V".

This means for any write to horizontal scrolling done during hblank time (between dot 257 and dot 341):
The bits for Fine X take effect immediately, and the other X bits are delayed until the upcoming scanline finishes.
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!
XiruProgrammer
Posts: 2
Joined: Fri Jun 10, 2022 4:11 am

Re: F1 Race glitch

Post by XiruProgrammer »

Thank you so much !
I took your advice and rewrote the PPU render logic from scanline-based to some sort of "cycle-accurate". The problem was that $2005 writes were affecting both coarse and Fine X immediately. Now Coarse X gets changed at right timing. This helped fix some glitches, such as background jittering in Ninja Gaiden 3 vertical stages.
Oddly enough, F1 Race and Mach Rider are now partially working, with glitches still occuring in lower half. Why could this be happening ? I suspect that is something to do with cpu to ppu cycle timing but not sure.
Attachments
Screenshot from 2022-08-07 06-56-01.png
Post Reply