*sigh* I'm either really... I mean REALLY stupid, or Megaman 4 just HATES me! But... The code doesn't work...
I apologize in advance for the annoyance... again. I really did think that Disch's last reply solved everything, but unfortunately, I'm back... Thanks dougeff for the reply! You guys have been very helpful in my efforts of trying to tackle this "beast."
SO! Disch, I never knew you wrote Documents on all of the NES mappers, and I even referenced your MMC3 mapper document to see what you had about IRQs, and have testing for about the last couple hours or so with no avail. Let's see if I can explain what I'm dealing with, when using Megaman 4's IRQ handler, maybe that might help?
As I said, Megaman 4 already has an IRQ handler, and it already includes the code that you posted dougeff. Here's what it looks like;
This code is located at 7C159. It pushed everything into the stack, like dougeff said, and then does an indirect jump from $9C, which stores the IRQ effect. (i.e #$1, #$2, #$3, like when I was storing #$1 into $F0) So, according to our code, the IRQ effect is one, so it's going to JMP to C158. Now, according to Disch, I need store #$A0, or whatever Scanline I would need, into $C000 and $C001, and write to $E000 and $E001 before the RTI at 7C327. Sadly, the IRQ Handler only does one IRQ at a time, meaning, like Disch said, I need to do this manually set the second IRQ.
SO! I modified the first IRQ code to look like this;
The beginning is normal, just like the code Disch posted, but I modified the ending to setup for a second IRQ.
I wrote to $E000, to disable to IRQ, then I stored the necessary values into $9C and $9D. (We'll get to that shortly.) Then I loaded $A0, the Scanline that I want our second IRQ to break at, into $C000 and $C001. I then jumped BACK to $C152;
Which enables the IRQ once again. Now, this is also why I stored the values I did earlier into $9C and $9D. The CPU wasn't going to get back to the area in the NMI routine where it would've stored the values into $9C and $9D via a STX, which is why I needed to store them directly. Here's the code for reference.
$F0 is copied to $5D by the way, and we can't directly store to $5D because it will just get overwritten when $F0 is eventually stored there during the NMI routine. $C318 is where all the LOW bytes are stored, while $C324 is where all the HIGH bytes are stored for the IRQ effect addresses.
When I jump back to $C152, I enable the IRQ effect once more, then using the JMP ($9C), I send it to the second "Entrance Point" of the IRQ handler, and activating our second IRQ code that Disch posted in his response before.
It then jumps to $C30E where it disables the IRQ effect, pulls all the status from the stack, and returns from the interrupt.
Now, here's the kicker, the code actually works. But, it still only effects the scanlines #$20 down, while using the scroll code we used in the second IRQ. So pretty much, it's nothing more than a glorified IRQ.
To be honest, I practically now this IRQ handler inside and out, and it annoys me that I can't understand this somewhat simple procedure. I always hate having to come here and ask this many times about one thing...