games that depend on dmc irq?

Discuss emulation of the Nintendo Entertainment System and Famicom.

Moderator: Moderators

Post Reply
kazzmir
Posts: 3
Joined: Wed Aug 05, 2020 5:23 pm

games that depend on dmc irq?

Post by kazzmir » Sun Aug 09, 2020 8:42 pm

Are there nes games that depend on the dmc irq to function correctly? I have not tested that many games (less than 2 dozen), but I've found that Legend of Zelda and Mike Tyson's Punch Out use the dmc for sound output, but neither seem to care if the irq fires. In Legend of Zelda the dmc is used to create the shooting sword sound when Link is at full health, and in Mike Tyson's Punch Out the dmc is used for the crowd sound -- both work properly in my emulator. I'd like to test my emulator with a game that needs the dmc irq. For that matter I haven't found a game that cares about the frame timer irq either.

User avatar
Dwedit
Posts: 4350
Joined: Fri Nov 19, 2004 7:35 pm
Contact:

Re: games that depend on dmc irq?

Post by Dwedit » Sun Aug 09, 2020 8:46 pm

Fire Hawk, Time Lord, and Mig 29 Soviet Fighter come to mind.

Time Lord uses DMC IRQ as a backup for Sprite 0 hit, just in case that Sprite 0 hit hasn't been triggered yet. It will trigger an interrupt between scanline 161 and 165 on frames where CPU usage is high enough to miss reaching the Sprite 0 Polling code early.
The game also crashes if APU Frame IRQ ever happens.

Fire Hawk uses DMC IRQ at the title screen to get IRQs at scanlines 71, 158, 170. During gameplay, it recalibrates the DMC channel, then gets interrupts at scanlines 56, 156, 171, 187, 203, 219. Screen is actually split at scanline 181.

Mig 29 Soviet Fighter gets interrupts at scanlines 93, 103, 113, 123, 133, 160, 182, 202, 213, 218. Screen is actually split at scanline 190.
Last edited by Dwedit on Sun Aug 09, 2020 9:03 pm, edited 1 time in total.
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!

lidnariq
Posts: 9655
Joined: Sun Apr 13, 2008 11:12 am
Location: Seattle

Re: games that depend on dmc irq?

Post by lidnariq » Sun Aug 09, 2020 8:51 pm

You may find this page on our wiki useful:
nesdevwiki:Tricky-to-emulate games

User avatar
Controllerhead
Posts: 147
Joined: Tue Nov 13, 2018 4:58 am
Location: $4016
Contact:

Re: games that depend on dmc irq?

Post by Controllerhead » Sun Aug 09, 2020 9:04 pm

I remember reading a thread / seeing a demo where somebody used the DMC IRQ timer for PPU synchronization... looking for it...

EDIT: This one! viewtopic.php?t=6521
tepples wrote:
Tue Jun 22, 2010 3:16 pm
DPCM Split
Mapper 0, runs on PowerPak. README file inside archive explains how it works. It still has glitches that someone like blargg might be able to help find and fix.
* this demo runs a little gnarly...

EDIT2: And the final(?) version:
tepples wrote:
Mon Aug 16, 2010 1:35 pm
I've updated my own demo. Highlights:
  • Pumped full of comments
  • Scroll using Control Pad
  • Runs the priming playback with IRQs turned off
  • Removed some misuses of Y register
* this demo looks perfect in Mesen and on console w/ Everdrive
Last edited by Controllerhead on Sun Aug 09, 2020 9:41 pm, edited 7 times in total.
Image

lidnariq
Posts: 9655
Joined: Sun Apr 13, 2008 11:12 am
Location: Seattle

Re: games that depend on dmc irq?

Post by lidnariq » Sun Aug 09, 2020 9:18 pm

Supercat also had an even more insane DMC IRQ synchronization technique in this thread, relying on changing the DMC period twice for each IRQs so they sum up to the same number of CPU cycles in a refresh.

kazzmir
Posts: 3
Joined: Wed Aug 05, 2020 5:23 pm

Re: games that depend on dmc irq?

Post by kazzmir » Sun Aug 09, 2020 11:28 pm

Thanks I will check those out.

I seem to have a fairly basic issue with irq's. While running the apu tests (test_apu_2 by x0000), my emulator gets into an infinite loop executing the interrupt vector repeatedly. The issue seems to be that those tests clear the apu interrupt inhibit flag, set frame mode, and have an irq handler that does nothing other than rti.

Code: Select all

lda #0
sta $4017 # clear interrupt inhibit, set frame mode
...
irq:
   rti
When the frame interrupt is asserted in step 4 of the frame counter the cpu jumps to the interrupt vector, which does nothing other than return. After returning, the cpu again jumps to the interrupt vector because the frame interrupt is still asserted. My understanding is the irq handler is supposed to clear the frame interrupt by reading the apu status register or setting the interrupt inhibit flag.
The frame interrupt flag is connected to the CPU's IRQ line. It is set at a particular point in the 4-step sequence (see below) provided the interrupt inhibit flag in $4017 is clear, and can be cleared either by reading $4015 (which also returns its old status) or by setting the interrupt inhibit flag.

lidnariq
Posts: 9655
Joined: Sun Apr 13, 2008 11:12 am
Location: Seattle

Re: games that depend on dmc irq?

Post by lidnariq » Mon Aug 10, 2020 12:01 am

Are you taking the 6502's interrupt disable flag into account?
If you are, might you have the sense of SEI and CLI backwards?

dink
Posts: 50
Joined: Sun Jan 12, 2020 8:42 pm

Re: games that depend on dmc irq?

Post by dink » Mon Aug 10, 2020 6:00 am

IIRC Cobra Triangle uses the dmc irq for timing.

User avatar
tokumaru
Posts: 11858
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: games that depend on dmc irq?

Post by tokumaru » Mon Aug 10, 2020 6:27 am

Doesn't The Guardian Legend also use the DMC IRQ + Sprite 0 hit technique for its status bar?

kazzmir
Posts: 3
Joined: Wed Aug 05, 2020 5:23 pm

Re: games that depend on dmc irq?

Post by kazzmir » Mon Aug 10, 2020 8:34 am

lidnariq wrote:
Mon Aug 10, 2020 12:01 am
Are you taking the 6502's interrupt disable flag into account?
If you are, might you have the sense of SEI and CLI backwards?
Shoot yes you were right, I had a mistake in dealing with SEI/CLI. Thanks!

Post Reply