MMC3 IRQ setup doesn't work "out of the box"
wendelscardua opened this issue · comments
On a MMC3 C++ project I was trying to use the irq-related API (based on nesdoug.h), and spent a long time trying to figure out why the irq wasn't "irqing", until someone pointed out to me that, if cli
only happens inside nmi (like the first call to irq_parser
possibly does, when the first instruction is a scanline counter), the flag state will be reverted by the nmi's rti
. Which means that if the interrupts aren't enabled beforehand during initialization, they will never be.
For now I'm doing an asm volatile("cli")
at the start of my main myself.
I think maybe either:
- interrupts should start enabled for MMC3, or
- if such magic is possible with llvm-mos, they should start enabled if irq functions are being used, or
set_irq_ptr
should enable it, ormapper.h
should have a comment telling the user to enable it beforehand