NES Program how to get the mirror information

Discuss technical or other issues relating to programming the Nintendo Entertainment System, Famicom, or compatible systems.

Moderator: Moderators

User avatar
byemu
Posts: 296
Joined: Mon Sep 05, 2011 5:56 pm
Contact:

NES Program how to get the mirror information

Post by byemu »

I'm a nes application,I'm in a nes cartridge run on a real nes,I want to know which mirror my cartridge used at this time,What must I do?
User avatar
Dwedit
Posts: 4470
Joined: Fri Nov 19, 2004 7:35 pm
Contact:

Re: NES Program how to get the mirror information

Post by Dwedit »

For cartridges with fixed mirroring, that's it, it's fixed.

Otherwise, you can tell by looking at the screen for scrolling artifacts. If the left column is blocked off, and there are attribute clashes as it scrolls horizontally, it's probably using horizontal mirroring (vertical nametable arrangement). If there is junk appearing at the top and bottom of the screen as it scrolls vertically, it's probably using vertical mirroring (horizontal nametable arrangement).

If there's no junk, and it's scrolling only horizontally or vertically, chances are good that it's using that nametable arrangement. Horizontal scrolling means vertical mirroring (horizontal nametable arrangement), and Vertical scrolling means horizontal mirroring (vertical nametable arrangement).

Or run it in an emulator and use a debugger to find out what mirroring mode it last selected.

Then there's the other hardware stuff where you determine how the vram lines that go back to the console are routed, since that's how mirroring selection works.
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!
lidnariq
Posts: 10677
Joined: Sun Apr 13, 2008 11:12 am
Location: Seattle

Re: NES Program how to get the mirror information

Post by lidnariq »

Use a continuity meter to see if the CIRAM A10 pin is connected to PPU A10 or PPU A11.
http://wiki.nesdev.com/w/index.php/Cartridge_connector

If neither, the nametable mirroring is most likely controlled by the mapper.
doppelganger
Posts: 183
Joined: Tue Apr 05, 2005 7:30 pm

Re: NES Program how to get the mirror information

Post by doppelganger »

If for some reason you want to do this in-program, you could read the name tables and check for mirroring that way. Not sure why you'd need to do that, but yeah, there it is.
Be whatever the situation demands.
tepples
Posts: 22345
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: NES Program how to get the mirror information

Post by tepples »

I did it in-program in three mapper test programs: one for MMC1 (unreleased), one for mappers 7 and 34 (BNTest), and one for mapper 28 (test28). Outside of mapper tests, a save state tool might use this to probe the current mirroring settings.
User avatar
byemu
Posts: 296
Joined: Mon Sep 05, 2011 5:56 pm
Contact:

Re: NES Program how to get the mirror information

Post by byemu »

doppelganger wrote:If for some reason you want to do this in-program, you could read the name tables and check for mirroring that way. Not sure why you'd need to do that, but yeah, there it is.
For my new fc/nes cartridge dump device softCopyFamicom to auto detected the mirror!
And later I want to make a emulator to run cartridge from a real fc/nes(so I need detected the mirror and irq...)
User avatar
infiniteneslives
Posts: 2102
Joined: Mon Apr 04, 2011 11:49 am
Location: WhereverIparkIt, USA
Contact:

Re: NES Program how to get the mirror information

Post by infiniteneslives »

I detect the board via mirroring, you just have to scroll through all the different styles of mirroring control registers and perform a test for each mapper's style of mirroring. If the test passes then that's your mapper(s).

This is limited, but it works pretty well for 'standard' mappers. Between mirroring, IRQs, WRAM detection, CHR-RAM detection,
and bankswitching you should be able to detect most boards.
If you're gonna play the Game Boy, you gotta learn to play it right. -Kenny Rogers
User avatar
byemu
Posts: 296
Joined: Mon Sep 05, 2011 5:56 pm
Contact:

Re: NES Program how to get the mirror information

Post by byemu »

tepples wrote:I did it in-program in three mapper test programs: one for MMC1 (unreleased), one for mappers 7 and 34 (BNTest), and one for mapper 28 (test28). Outside of mapper tests, a save state tool might use this to probe the current mirroring settings.
An easy way to detect v-mirror and h-mirror!

Code: Select all

//back
data_2000 = ppu_read(0x2000);
data_2400 = ppu_read(0x2400);
data_2800 = ppu_read(0x2800);
data_2C00 = ppu_read(0x2C00);

//
k0 = 0x00;
k1 = 0x88;

ppu_write(0x2000,k0);
ppu_write(0x2400,k0);
ppu_write(0x2800,k0);
ppu_write(0x2C00,k0);

ppu_write(0x2000,k1);
k1_2000 = ppu_read(0x2000);
k1_2400 = ppu_read(0x2400);
k1_2800 = ppu_read(0x2800);
k1_2C00 = ppu_read(0x2C00);

//h
if( (k1==k1_2000)&&(k1==k1_2400)&&(!k1_2800)&&(!k1_2C00) )
printf("h mirror\n");
//v
if( (k1==k1_2000)&&(k1==k1_2800)&&(!k1_2400)&&(!k1_2C00) )
printf("v mirror\n");

//resume
ppu_write(0x2000,data_2000);
ppu_write(0x2400,data_2400);
ppu_write(0x2800,data_2800);
ppu_write(0x2C00,data_2C00);

Drag
Posts: 1350
Joined: Mon Sep 27, 2004 2:57 pm
Contact:

Re: NES Program how to get the mirror information

Post by Drag »

Write:
$2000 <- #00
$2400 <- #01
$2800 <- #02
$2C00 <- #03

Then, simply read $2000 to get the mirroring configuration.
$2000 -> 00 = Four screen
$2000 -> 01 = Horizontal mirroring
$2000 -> 02 = Vertical mirroring
$2000 -> 03 = Single screen

(The reason this works is because $2000 gets overwritten with a different value for each of the four common mirroring configurations, if you write $2000, $2400, $2800, $2C00 in order.)
User avatar
infiniteneslives
Posts: 2102
Joined: Mon Apr 04, 2011 11:49 am
Location: WhereverIparkIt, USA
Contact:

Re: NES Program how to get the mirror information

Post by infiniteneslives »

I'm confused... Is this testing being done with the nes/fc or kazoo/other dumping device?

I thought the question was sensing the mapper for smart dumping, but everyone else's response seems from the perspective of the nes...
If you're gonna play the Game Boy, you gotta learn to play it right. -Kenny Rogers
tepples
Posts: 22345
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: NES Program how to get the mirror information

Post by tepples »

From the perspective of the NES and from the perspective of the dumping device are ultimately the same thing, as they interact with the Game Pak through the same 60 or 72 pins.
User avatar
infiniteneslives
Posts: 2102
Joined: Mon Apr 04, 2011 11:49 am
Location: WhereverIparkIt, USA
Contact:

Re: NES Program how to get the mirror information

Post by infiniteneslives »

tepples wrote:From the perspective of the NES and from the perspective of the dumping device are ultimately the same thing, as they interact with the Game Pak through the same 60 or 72 pins.
Yeah but with the NES you can't just read CIRAM A10 signal from the connector. You have to infer it from the NT's arrangment. In a standalone dumper (not copyNES) writing to NT's and then reading back tells you a whole lot of nothing unless the NT's are on the cartridge which is generally not the case.

Yes it's the same connector, but the methods you're able to sense what's going on with that connector aren't the same based on how the said hardware is connected to that connector...
If you're gonna play the Game Boy, you gotta learn to play it right. -Kenny Rogers
User avatar
byemu
Posts: 296
Joined: Mon Sep 05, 2011 5:56 pm
Contact:

Re: NES Program how to get the mirror information

Post by byemu »

Drag wrote:Write:
$2000 <- #00
$2400 <- #01
$2800 <- #02
$2C00 <- #03

Then, simply read $2000 to get the mirroring configuration.
$2000 -> 00 = Four screen
$2000 -> 01 = Horizontal mirroring
$2000 -> 02 = Vertical mirroring
$2000 -> 03 = Single screen

(The reason this works is because $2000 gets overwritten with a different value for each of the four common mirroring configurations, if you write $2000, $2400, $2800, $2C00 in order.)
Thanks,let me have a try.
User avatar
byemu
Posts: 296
Joined: Mon Sep 05, 2011 5:56 pm
Contact:

Re: NES Program how to get the mirror information

Post by byemu »

infiniteneslives wrote:I'm confused... Is this testing being done with the nes/fc or kazoo/other dumping device?

I thought the question was sensing the mapper for smart dumping, but everyone else's response seems from the perspective of the nes...
It's on my new dump device "softCopyFamicom"
viewtopic.php?f=9&t=10322
User avatar
Dwedit
Posts: 4470
Joined: Fri Nov 19, 2004 7:35 pm
Contact:

Re: NES Program how to get the mirror information

Post by Dwedit »

Some boards support custom mirroring, and can create mirroring configurations that don't match one of the standard types. For example:
0 1
1 1
or
0 1
1 0
mirroring won't be correctly identified by that code snippet.

Also, some boards can map ROM into the nametables.
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!
Post Reply