Trying to get Mapper 222 IRQs right

Discuss emulation of the Nintendo Entertainment System and Famicom.

Moderator: Moderators

zxbdragon
Posts: 488
Joined: Mon Dec 12, 2011 8:15 pm

Re: Trying to get Mapper 222 IRQs right

Post by zxbdragon » Sat Aug 15, 2015 2:06 pm

Joe wrote:These pictures are helpful, but the chips cover too much to trace the IRQ circuit.

If you remove the chips and take a picture of the empty board, I could trace it. Of course, then you won't be able to play the cartridge anymore (unless you're skilled enough at soldering to take it apart and put it back together).

Do you have anything you could use to trace it? I use a multimeter, but someone else might be able to suggest some other tool if you don't have one of those.

I want to discuss this with the owner of a cassette
I'm just trying to find all kinds of perfect MAPPPER cassette

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

Re: Trying to get Mapper 222 IRQs right

Post by lidnariq » Sat Aug 15, 2015 2:19 pm

There are traces connected to pin 6 (Q6) and pin 10 (↓CP) of the GD4020, so whatever it's counting, it's counting 64 of them. I'd guess it's counting on PPU A12 again, but who knows.

zxbdragon
Posts: 488
Joined: Mon Dec 12, 2011 8:15 pm

Re: Trying to get Mapper 222 IRQs right

Post by zxbdragon » Sun Aug 16, 2015 12:17 am

lidnariq wrote:There are traces connected to pin 6 (Q6) and pin 10 (↓CP) of the GD4020, so whatever it's counting, it's counting 64 of them. I'd guess it's counting on PPU A12 again, but who knows.


yes,fceux,nestopia src. A12,but not right

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

Re: Trying to get Mapper 222 IRQs right

Post by lidnariq » Sun Aug 16, 2015 1:10 am

Hm. Not PPU A12. Assuming that the 40-pin IC is a VRC2 clone (and what I can tell looks right), it's clocked by M2. And it appears to feed into the 74'161, so it looks like it's a program-controllable multiple of 64 M2 cycles.

zxbdragon
Posts: 488
Joined: Mon Dec 12, 2011 8:15 pm

Re: Trying to get Mapper 222 IRQs right

Post by zxbdragon » Wed Aug 19, 2015 1:34 am

Joe wrote:These pictures are helpful, but the chips cover too much to trace the IRQ circuit.

If you remove the chips and take a picture of the empty board, I could trace it. Of course, then you won't be able to play the cartridge anymore (unless you're skilled enough at soldering to take it apart and put it back together).

Do you have anything you could use to trace it? I use a multimeter, but someone else might be able to suggest some other tool if you don't have one of those.

Is there any progress?

Joe
Posts: 437
Joined: Mon Apr 01, 2013 11:17 pm

Re: Trying to get Mapper 222 IRQs right

Post by Joe » Wed Aug 19, 2015 3:35 am

No. I need to know how the chips are connected to tell you how they work.

Can you trace the connections? Or, can you remove the chips and take a picture of the board with no chips?

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

Re: Trying to get Mapper 222 IRQs right

Post by lidnariq » Wed Aug 19, 2015 10:06 am

The best I can possibly tell you from just glare-y pictures of the populated PCBs:

1- I believe the 40-pin IC is a VRC2 clone
2- IRQs are clocked by M2
3- IRQs seem to have a divide-by-64 prescaler
4- IRQs seem to be programmable, not fixed.

For us to be able to tell you anything more, you'll either have to get us a picture of the PCBs without the ICs; or sit down with a continuity meter and determine how all the signals are connected.

krzysiobal
Posts: 718
Joined: Sun Jun 12, 2011 12:06 pm
Location: Poland

Re: Trying to get Mapper 222 IRQs right

Post by krzysiobal » Wed Apr 15, 2020 10:56 am

Code: Select all

F000 [........] (mask $F003)
*Puts the counter into load mode 

F001 [VVVVVVVV] (mask $F001)
*Acknowledges interrupt
*If counter is in load mode, loads it with VVVVVVVV (otherwise do not modify its value)

F002 [........] (mask $F003)
*Puts the counter into clock mode

Counter operation:
* There is 8 bit latch that can be in LOAD or CLOCK mode.
* If it is in CLOCK mode and no interrupt is asserted, it is increased every 128th CPU clock
* If it overflows, IRQ is asserted and counter is stopped from furter increasing
Image Image Image

User avatar
Quietust
Posts: 1557
Joined: Sun Sep 19, 2004 10:59 pm
Contact:

Re: Trying to get Mapper 222 IRQs right

Post by Quietust » Wed Apr 15, 2020 12:02 pm

krzysiobal wrote:
Wed Apr 15, 2020 10:56 am
* If it is in CLOCK mode and no interrupt is asserted, it is increased every 128th CPU clock
Some additional details, if I'm reading the schematic correctly:
* the 128-cycle divider is initialized to 0 while an IRQ is being asserted
* the 128-cycle divider is actually a 14-bit counter which uses bit 6 (0x40) as its output , so the first latch increment after switching to COUNT mode would occur after 64 cycles, and the rest would all happen on 128 cycle intervals.

Also, unless I'm misreading the 74161 datasheet, it looks like the interrupt will be generated when the counter reaches 240 (i.e. when the 4 upper bits are 1), not when it overflows. The counter also looks like it'll increment $0E->$1F->$10 (rather than $0E->$0F->$10) due to using the lower chip's carry output as the upper counter's CLK pin instead of its ENT pin, which would make it trigger another "scanline" earlier.
Quietust, QMT Productions
P.S. If you don't get this note, let me know and I'll write you another.

krzysiobal
Posts: 718
Joined: Sun Jun 12, 2011 12:06 pm
Location: Poland

Re: Trying to get Mapper 222 IRQs right

Post by krzysiobal » Wed Apr 15, 2020 12:13 pm

Quietust wrote:
Wed Apr 15, 2020 12:02 pm
Some additional details, if I'm reading the schematic correctly:
3x Agree, good point.

NewRisingSun
Posts: 1189
Joined: Thu May 19, 2005 11:30 am

Re: Trying to get Mapper 222 IRQs right

Post by NewRisingSun » Wed Apr 15, 2020 12:44 pm

I don't understand what this means for the full counting sequence. This?

00,01,02,03,04,05,06,07,08,09,0A,0B,0C,0D,0E,1F,10,11,12,13,14,15,16,17,18,19,1A,1B,1C,1D,1E,2F,20,21,...

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

Re: Trying to get Mapper 222 IRQs right

Post by lidnariq » Wed Apr 15, 2020 1:04 pm

I think your sequence is right?
But it might be better to implement it as three separate counters?

The '4020 is either always counting, or else reset to 0. When counting is enabled, a rising edge of the 64s bit will clock the lower 74'161. (so: 64, 192, 320, so on).

When the lower 74'161 reaches a value of 15, it'll clock the upper 74'161.

When the upper 74'161 reaches a value of 15, that'll assert /IRQ, and stop the '4020. Thus it'll stop when it counts from $EE to $FF.

I have to admit I'm bewildered that they didn't daisy-chain the two 74'161s together the way you're "supposed" to (i.e. shared clock, RCO from lower half goes to ENP of upper half)

NewRisingSun
Posts: 1189
Joined: Thu May 19, 2005 11:30 am

Re: Trying to get Mapper 222 IRQs right

Post by NewRisingSun » Wed Apr 15, 2020 1:42 pm

All right then.

Mapper 222 is annoying because it denotes two different PCBs: Dragon Ninja (CTC-31), which is the one with the weird IRQ counter, and "Super Bros. 8", which is a graphics hack of "Don Doko Don 2". That particular "Super Bros. 8" is annoying because it writes a full 8-bit CHR bank byte to both $B000/$B001 etc., instead of nibblizing the data like a real VRC2 would require.

Edit: Spelling.
Last edited by NewRisingSun on Wed Apr 15, 2020 1:47 pm, edited 2 times in total.

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

Re: Trying to get Mapper 222 IRQs right

Post by lidnariq » Wed Apr 15, 2020 1:47 pm

NewRisingSun wrote:
Wed Apr 15, 2020 1:42 pm
That particular "Super Bros. 8" is annoying because it writes a full 8-bit CHR bank byte to both $B000/$B001 etc., instead of nibblizing the data like a real VRC2 would require.
Didn't we see a picture of that somewhere here? Where they added a multiplexer so that it paid attention to the lower half nybble at $B000 and the upper half nybble at $B001?

Not that that makes it any easier to emulate...

krzysiobal
Posts: 718
Joined: Sun Jun 12, 2011 12:06 pm
Location: Poland

Re: Trying to get Mapper 222 IRQs right

Post by krzysiobal » Wed Apr 15, 2020 1:51 pm


Post Reply