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

DMCIRQ examples?

DMCIRQ examples?
by on (#52867)
Are there examples of programs that run on an NES and use the DMC IRQ, other than the sawtooth demo?

by on (#52869)
Guardian Legend, Ian Bell's "Tank" demo (not sure if elite uses it too).

by on (#52871)
Guardian Legend uses it for the status bar, right?

by on (#52872)
Mig29 Soviet Fighter <--- ruthless about DMC IRQ timing

by on (#52873)
My post is from an NES programmer's point of view, not an emulator programmer's point of view. I am aware of these closed-source test cases. But I'm looking for something with available source code so that I can see the right sequence of reads and writes to get the IRQ 1. properly enabled and then 2. properly acknowledged. What I have so far fails differently in FCE Ultra (the emulator on an Ubuntu PC with CA65 installed), Nintendulator (the emulator on the other PC that runs Windows), and my PowerPak, making it an absolute pain to debug. Should I post my non-working source code and then have the rest of you pick it apart to see why it doesn't work?

Right now, I'm puzzling through the sawtooth demo.

I guess my questions are as follows: How do I know my IRQ handler is getting called? And after that, how do I know that the main thread of execution is resuming, as opposed to the IRQ handler just getting called again immediately after the RTI instruction at its end?

EDIT: I got it to work, mostly. It still fails when I press the NES's reset button, but it works when I hold the NES's reset button to go back to the PowerPak main menu.

by on (#52887)
I guess to proprely enable it you should write a value >$80 to $4010, and to proprely acknownledge it you should read $4015.

by on (#52904)
Tonight when I get home from work, I will upload a copy of my project. It works when I launch it from the PowerPak menu, but when I press reset, it freezes.

by on (#52910)
I don't know but I'd double check the initialisation of IRQs at reset. At reset you'd probably want to set the interrupt flag (at least until you actually expect IRQs), write #$00 to $4015 to disable all channels (especially DMC), and read $4015 after that (so it would acknownledge any possible interrupt to be safe).
I know the NES is supposed to disable all sound channels and IRQs when it's soft-resetted, but just to be sure...

by on (#52951)
This ROM (with source code for ca65) displays a message and flashes the backdrop color to let one know that the NMI handler is running, and its IRQ handler makes clicks through $4011 once every few iterations to let one know that it is running. But after a reset, it doesn't start clicking again, nor does it display the message. I'm sure I made some silly mistake near the top of the program. Worse yet, the environments that hang (PowerPak and Nestopia) don't have a debugger, while the environments with a debugger (FCEU series and Nintendulator) don't hang.

by on (#53162)
I figured it out. I was using the wrong branch in my PPU warm-up wait loops.

by on (#53163)
tepples wrote:
I figured it out. I was using the wrong branch in my PPU warm-up wait loops.

As it usually turns out, something seemingly unrelated... =)