Rogue pixels

Are you new to 6502, NES, or even programming in general? Post any of your questions here. Remember - the only dumb question is the question that remains unasked.

Moderator: Moderators

User avatar
tokumaru
Posts: 12427
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: Rogue pixels

Post by tokumaru »

sailense wrote:Right now I'm resetting scoll values in all my subroutines where I write to $2006. Is that the best way to go?
If you're not doing any raster effects, you only need to reset the scroll once per frame, before rendering starts. Normally that'd be at the end of your NMI handler, after all PPU operations have already been done.
And when is the best time to read from controller? Every NMI or during the main loop?
Doing it in the NMI can actually cause bugs during lag frames, because the same logic frame may end up using 2 different states of the same button if an NMI happens between two checks. Better do it in the main loop, once for each logic frame.
tepples
Posts: 22705
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: Rogue pixels

Post by tepples »

tokumaru wrote:[Reading the controller] in the NMI can actually cause bugs during lag frames, because the same logic frame may end up using 2 different states of the same button if an NMI happens between two checks. Better do it in the main loop, once for each logic frame.
That's a good idea in many cases. The other way to handle it, especially if you're playing DPCM samples, is to have the main loop request that the NMI handler perform the reread immediately after uploading a display list to OAM, as Rahsennor discovered.
User avatar
tokumaru
Posts: 12427
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: Rogue pixels

Post by tokumaru »

Oh yeah, I forgot about that. Yes, if you read the controllers in the NMI only when a logic frame isn't interrupted, you can avoid that button inconsistency issue I mentioned before and still make use of this technique to avoid DPCM input glitches.
User avatar
sailense
Posts: 9
Joined: Wed Mar 14, 2018 6:23 pm

Re: Rogue pixels

Post by sailense »

tepples wrote:
tokumaru wrote:[Reading the controller] in the NMI can actually cause bugs during lag frames, because the same logic frame may end up using 2 different states of the same button if an NMI happens between two checks. Better do it in the main loop, once for each logic frame.
That's a good idea in many cases. The other way to handle it, especially if you're playing DPCM samples, is to have the main loop request that the NMI handler perform the reread immediately after uploading a display list to OAM, as Rahsennor discovered.
That's a great link. The ring counter technique is awesome.

I'm purposely avoiding DPCM samples in the music specifically so I don't have to worry about it.
Post Reply