llvm-mos / llvm-mos-sdk

SDK for developing with the llvm-mos compiler
https://www.llvm-mos.org
Other
270 stars 56 forks source link

MMC3 IRQ setup doesn't work "out of the box" #262

Open wendelscardua opened 10 months ago

wendelscardua commented 10 months ago

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: