I've got an NSF emulator sort of working. Square 1 & 2, Triangle, and Noise sound fine, and can play tracks on the test nsf I have (megaman 3). When playing track 5, the CPU interrupt flag becomes cleared after just a few seconds, and my emulator breaks. I've been reading through the IRQ and APU interrupt docs on the wiki and can't quite figure them out. They say that if IRQ is 0 at the end of an instruction, push some things and load ffff and fffe, which is the same as BRK. So, I've added code that checks the I flag after each CPU step, and if I is low, run a BRK and tick the APU appropriately. However, this puts the CPU into some loop. Any idea what's going wrong?
Also, the APU docs say "At any time if the interrupt flag is set and the IRQ disable is clear, the CPU's IRQ line is asserted." What does asserted mean? Set the CPU's I register to 1? Is there anything more to this?
Code at: https://github.com/mjibson/mog/tree/master/codec/nsf
Also, the APU docs say "At any time if the interrupt flag is set and the IRQ disable is clear, the CPU's IRQ line is asserted." What does asserted mean? Set the CPU's I register to 1? Is there anything more to this?
Code at: https://github.com/mjibson/mog/tree/master/codec/nsf