This page is a mirror of Tepples' nesdev forum mirror (URL TBD).
Last updated on Oct-18-2019 Download

MMC3 scanline scrolling (problem solved, ignore post)

MMC3 scanline scrolling (problem solved, ignore post)
by on (#89135)
EDIT: The problem was elsewhere, ignore this post.

I'm trying to do horizontal scrolling with the MMC such that I can change the horizontal scroll at a couple of specific scanlines. My IRQ code seems to be executing on the correct scanlines, but I get a really annoying flicker effect where it looks like the horizontal scroll randomly fails to set (consistent across a couple of emulators).

My IRQ code looks like this:

    STA $E000 ; acknowledge/stop interrupt
    LDA $2002
    LDA next_scroll_value
    STA $2005

After the ... I push the rest of the registers, do some logic to keep track of which scanline I'm going for next, set the next_scroll_value, and then write to $C000, $C001, $E000, $E001 to prepare the next interrupt before popping the registers back to their initial state.

Is there something else I need to do to make sure the scroll value takes effect properly? Is there a potential conflict when writing to $2005 that I need to take into account?

(I tried searching for an example, but nothing I found seems to suggest I need to do anything else but write to $2005.)

Also, just to eliminate a possible source of error, if I replace "LDA next_scroll_value" with "LDA #65" or other immediate value, I still get flickering, though I notice that in this case it only seems to occur after the first couple of IRQs, after that the screen seems to be stable with a scroll of 65. (So, the flickering is only happening if I change the scroll setting?)

by on (#89136)
ROM or more surce at all? But does it fail, or just flicker? Flickering can probably be fixed via timing it differently, putting a delay in before the write to $2005 so when it is reloaded the next scan line there's no lines seen, like SMB3 has the line flicker and crystalis, but other MMC3 games don't. Only other thing IMO would be to make sure you also update $2000 to the right name table if it scrolls onto a different name table from a different primary.

by on (#89137)
It doesn't seem to be an issue of horizontal timing; I mean, I do see little fuzz glitches near the left side on the scanline where I set the scroll, but that's something I expected. The flicker problem is that the scroll just isn't being set at all.

I can post a ROM in a little bit.

by on (#89138)
Hmm, nevermind. I think my music routine is conflicting in some way. If I disable it, the scrolling seems to work fine.

Thanks for answering, though.

by on (#89139)
Could be DMC IRQ's.

by on (#89141)
Put a breakpoint on the scroll writes and make sure they fall within hblank (you can see the PPU cycle count in Nintendulator). Adjust the timing with NOPs as necessary.

by on (#89144)
Thanks, but no that's not the problem.

My problem is somewhere in the music code; interestingly it actually has nothing to do with use of the APU (I can comment out the APU interaction, and the problem is still there), so it's not anything to do with DMC or the frame counter, I don't think.

Anyhow, long story short: my problem is my own stuff somewhere; I no longer have any questions. You can just ignore this thread.