RAMBO-1 IRQ timing

Discuss emulation of the Nintendo Entertainment System and Famicom.

Moderator: Moderators

Post Reply
User avatar
James
Posts: 429
Joined: Sat Jan 22, 2005 8:51 am
Location: Chicago, IL
Contact:

RAMBO-1 IRQ timing

Post by James » Sat Aug 31, 2013 10:25 am

Here's the results of my analysis of RAMBO-1 IRQ timing.

For MMC3-style IRQs, RAMBO-1 checks A12 on falling edges of M2. When it's time to do so, IRQ is asserted on the next falling edge of M2 (plus about 20ns). Since there are 4 possible CPU/PPU alignments, there are 4 variations of IRQ timing. Furthermore, since odd frames are 1 PPU cycle short, there are two different delays for each variation. Here's the IRQ assertion time, relative to the rising edge of A12, for each alignment:

Code: Select all

Short		Long
ns (cycles)
761 (4.1)	947 (5.1)
621 (3.3)	812 (4.3)
900 (4.8)	1088 (5.8)
582 (3.1)	950 (5.1)
Alignment 1:
Image
Image

Alignment 2:
Image
Image

Alignment 3:
Image
Image

Alignment 4:
Image
Image

Edit: Revised CPU cycle-based IRQ info below.
Last edited by James on Mon Sep 02, 2013 3:41 pm, edited 1 time in total.
get nemulator
http://nemulator.com

User avatar
infiniteneslives
Posts: 2100
Joined: Mon Apr 04, 2011 11:49 am
Location: WhereverIparkIt, USA
Contact:

Re: RAMBO-1 IRQ timing

Post by infiniteneslives » Sun Sep 01, 2013 10:49 am

Awesome work James! That's an interesting approach they took and now makes complete sense on the wide range of delays seen by the RAMBO-1. Thanks for taking the time to get that chip to spill it's guts.

We need to make sure this gets updated in the wiki and Disch docs.
If you're gonna play the Game Boy, you gotta learn to play it right. -Kenny Rogers

User avatar
James
Posts: 429
Joined: Sat Jan 22, 2005 8:51 am
Location: Chicago, IL
Contact:

Re: RAMBO-1 IRQ timing

Post by James » Mon Sep 02, 2013 3:49 pm

I took a closer look at CPU cycle-based IRQs today:

The IRQ counter reload is set to 0x74 (116) so, once IRQs are enabled, the next IRQ should occur 464 (116*4) CPU cycles later (or about 259.25us later):
Image

IRQs are enabled by writing to 0xE001 at D. The IRQ counter starts counting down on the next falling edge of M2 (E):
Image

The IRQ counter reaches 0 at F (as predicted, 259.25us after E) then, like MMC3-style IRQs, IRQ is asserted on the next falling edge of M2 (G):
Image
get nemulator
http://nemulator.com

User avatar
infiniteneslives
Posts: 2100
Joined: Mon Apr 04, 2011 11:49 am
Location: WhereverIparkIt, USA
Contact:

Re: RAMBO-1 IRQ timing

Post by infiniteneslives » Mon Sep 02, 2013 4:17 pm

James wrote:The IRQ counter reaches 0 at F (as predicted, 259.25us after E) then, like MMC3-style IRQs, IRQ is asserted on the next falling edge of M2 (G):
Good stuff,

So just to clarify, when you say 'like MMC3 style IRQs', you mean 'like RAMBO-1's CHR-A12 scanline counter' (which is similar to the MMC3 but different in delay amongst possible other things). Not 'like Nintendo's MMC3'. Correct?
If you're gonna play the Game Boy, you gotta learn to play it right. -Kenny Rogers

User avatar
James
Posts: 429
Joined: Sat Jan 22, 2005 8:51 am
Location: Chicago, IL
Contact:

Re: RAMBO-1 IRQ timing

Post by James » Mon Sep 02, 2013 5:00 pm

That's correct. Similar to RAMBO-1's scanline counter mode.
get nemulator
http://nemulator.com

User avatar
ulfalizer
Posts: 349
Joined: Fri Mar 08, 2013 9:55 pm
Location: Linköping, Sweden

Re: RAMBO-1 IRQ timing

Post by ulfalizer » Mon Sep 02, 2013 7:31 pm

Thanks for the investigation.

Another thing I'm curious about is the precise circumstances where MMC1 ignores writes. thefox implied it's not as simple as all writes but the first always being ignored for consecutive writes (can't remember where he said that though). Emulating it like that fixes Bill and Ted's Excellent Adventure but breaks the polynes3 demo.

3gengames
Formerly 65024U
Posts: 2276
Joined: Sat Mar 27, 2010 12:57 pm

Re: RAMBO-1 IRQ timing

Post by 3gengames » Mon Sep 02, 2013 7:46 pm

Isn't it consecutive writes the first one is the only one that takes effect? At least that's what I thought was determined from all tests, ever.

User avatar
ulfalizer
Posts: 349
Joined: Fri Mar 08, 2013 9:55 pm
Location: Linköping, Sweden

Re: RAMBO-1 IRQ timing

Post by ulfalizer » Mon Sep 02, 2013 7:50 pm

3gengames wrote:Isn't it consecutive writes the first one is the only one that takes effect? At least that's what I thought was determined from all tests, ever.
Yeah, that was what I meant - "...all writes but the first always being ignored..."

User avatar
infiniteneslives
Posts: 2100
Joined: Mon Apr 04, 2011 11:49 am
Location: WhereverIparkIt, USA
Contact:

Re: RAMBO-1 IRQ timing

Post by infiniteneslives » Mon Sep 02, 2013 11:53 pm

I verified the MMC1's double write cycle protection was based on what appears to be latching of PRG R/W with M2 as a clock. I verified that by leaving M2 low while writing to the mapper and every write was accepted or blocked based on the status of PRG R/W for the most recent latch.
If you're gonna play the Game Boy, you gotta learn to play it right. -Kenny Rogers

Post Reply