I'm working through Disch's mapper docs and the wiki trying to get a handle on the MMC3's scanline counter so I can better understand the first boss battle in Super C. In short, once you hit the end of the level, scrolling halts and a large helicopter flies into view from the left side. My hypothesis was that the heli was drawn with BG tiles (Mega Man-style) and scrolled while the static lower terrain was handled with a scanline IRQ. This seems to be the case.
However, I wanted to look at how this happens programmatically and I'm tripped up on a small detail. (I'm new to both FCEUX debugging and MMC3, so bear with me.) I set breakpoints on the IRQ registers. $C000 (count value), $C001 (reset counter), and $E000 (IRQ disable) appear to be written every VBLANK (or twice?). $C000 never varies from #$F0. As expected, $E001 (IRQ enable) is not written until the 'boss area' scrolls into view. FCEUX throws a break at scanline 162. When I fool around with the scroll line display in the Name Table Viewer, I can verify that that is the point where the IRQ fires.
My confusion stems from the value in $C000. How does #$F0 count down to triggering at scanline 162? My only suspicion about the discrepancy is that shortly after the write to $C000, there are ten writes to $2006 (all #$00 as far as I can tell). The MMC3 docs indicate that this can manually manipulate the scanline counter, but I don't understand either enough to know how.
Surely I'm missing something. Or maybe I'm totally off base. Any insight is appreciated.
However, I wanted to look at how this happens programmatically and I'm tripped up on a small detail. (I'm new to both FCEUX debugging and MMC3, so bear with me.) I set breakpoints on the IRQ registers. $C000 (count value), $C001 (reset counter), and $E000 (IRQ disable) appear to be written every VBLANK (or twice?). $C000 never varies from #$F0. As expected, $E001 (IRQ enable) is not written until the 'boss area' scrolls into view. FCEUX throws a break at scanline 162. When I fool around with the scroll line display in the Name Table Viewer, I can verify that that is the point where the IRQ fires.
My confusion stems from the value in $C000. How does #$F0 count down to triggering at scanline 162? My only suspicion about the discrepancy is that shortly after the write to $C000, there are ten writes to $2006 (all #$00 as far as I can tell). The MMC3 docs indicate that this can manually manipulate the scanline counter, but I don't understand either enough to know how.
Surely I'm missing something. Or maybe I'm totally off base. Any insight is appreciated.