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:
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?)
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:
Code:
irq:
PHA
STA $E000 ; acknowledge/stop interrupt
LDA $2002
LDA next_scroll_value
STA $2005
...
PHA
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?)