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

About MMC3 IRQs...

About MMC3 IRQs...
by on (#155636)
EDIT: Fixed. Turns out it was a pattern table problem already covered on the forum. (viewtopic.php?t=1609)
I really had no idea this was a thing, kind when I first tried to implement DPCM but I got quite angry because of the glitch controller reads.

I'm making a game with an IRQ-triggered status bar on the bottom. I made my routine and it works on FCEUX. However other emulators don't seem to be very keen on that routine. Anyone knows why it's wrong?
Here is the IRQ triggering code in my NMI and my IRQ handler.

Code:

  LDA IRQFlag                   ;This is the code that's in my NMI handler. Basically, it checks if the game needs IRQs with the IRQFlag variable
  BEQ .noirq                      ;then it does IRQ stuff like it's explained here - http://bobrost.com/nes/files/mmc3irqs.txt
  STA IRQOFF                    ;IRQLATCH      = $C000
  LDA #$BF                       ;IRQRELOAD      = $C001
  STA IRQLATCH               ;IRQOFF         = $E000
  STA IRQRELOAD             ;IRQON         = $E001
  STA IRQOFF
  STA IRQON
.noirq

                                             ;More code here...

IRQ:                                       ;This is my IRQ handler. Right now, it just scrolls the status bar with the "ticker" variable, and bankswitches CHR
                                             ;Works on FCEUX, doesn't work on any other emulator
  PHA                                     ;(Don't have a flashcart to test it on...)
  TXA
  PHA
  TYA
  PHA

  LDX #$00
.loop
  INX
  CPX #$0A
  BNE .loop

  NOP

  LDA #%10000000
  STA BANKSWAP
  LDA #%00010000
  STA BANKDATA

  LDA ticker
  STA $2005
  LDA #$00
  STA $2005

  LDA #%10110000
  STA $2000

  STA IRQOFF                                ;It's supposed to acknowledge the IRQ here.

  PLA
  TAX
  PLA
  TAY
  PLA

  RTI


Thanks for your help guys :)
Re: About MMC3 IRQs...
by on (#155639)
The only thing that sticks out to me is that you're pulling the registers from the stack in the wrong order in the end (you're swapping X and Y, you should really fix that), but that wouldn't break the IRQ.

Quote:
However other emulators don't seem to be very keen on that routine.

Can you elaborate? What happens when you run this in other emulators? Sadly, FCEUX is one of the last accurate emulators out there (even though it's a fantastic development tool), so the fact that your code only works on it is not a very good sign.
Re: About MMC3 IRQs...
by on (#155641)
tokumaru wrote:
The only thing that sticks out to me is that you're pulling the registers from the stack in the wrong order in the end (you're swapping X and Y, you should really fix that), but that wouldn't break the IRQ.

Quote:
However other emulators don't seem to be very keen on that routine.

Can you elaborate? What happens when you run this in other emulators? Sadly, FCEUX is one of the last accurate emulators out there (even though it's a fantastic development tool), so the fact that your code only works on it is not a very good sign.


Actually, you're right, good thing you noticed that to prevent keyboard smashes from my side :P

Basically, FCEUX works as it should, meaning the status bar scrolls AND the mid-rendering bankswitching happens, but nothing happens on other emulators (NEStopia and PUnes both give me the same result)
Here are a two pix to compare both results.

EDIT: Fixed, 8x16 sprites and their pattern table were the cause (viewtopic.php?t=1609)