It is currently Mon Nov 20, 2017 9:40 pm

All times are UTC - 7 hours





Post new topic Reply to topic  [ 32 posts ]  Go to page 1, 2, 3  Next
Author Message
PostPosted: Sun Aug 20, 2017 5:19 pm 
Offline

Joined: Mon Jan 30, 2017 5:20 pm
Posts: 300
Location: Colorado USA
So I know what mirroring is, but I don't know how I set it. There isn't a bit in the PPU control registers to set the mirroring, and when I went the nesdev wiki page, it says that vertical mirroring is in address $2000 and $2800, while as vertical is in $2000 and $2400. They say that mirroring exists because the NES didn't have enough PPU memory to have 4 screens, well why is there addresses, $2000, $2400, $2800. and $2C00, seems like it has enough memory to me. It says it has something to do with mappers. Well, if it involves mappers, then how come Super Mario Bros. can have Vertical Mirroring even though it doesn't have a mapper? You might not know what I'm referring to, so let me explain. on the wiki, it says "To configure a cartridge board for horizontal mirroring, connect PPU A11 to CIRAM A10. On cartridge boards made by Nintendo, this is selected by shorting the "V" solder pad (for "vertical arrangement"). Note using inverse logic may make more sense, "Leaving the 'H' jumper open gives horizontal mirroring" on Nintendo boards."
Well if this is the case, then how come games like Metroid or Super Mario Bros. 2 switch mirroring modes on the fly?


Top
 Profile  
 
PostPosted: Sun Aug 20, 2017 6:19 pm 
Offline
User avatar

Joined: Sat Feb 12, 2005 9:43 pm
Posts: 10116
Location: Rio de Janeiro - Brazil
Just because an address exists, that doesn't mean the memory it points to is visible ONLY at that address. Another example of memory mirroring on the NES is the CPU RAM, which is only 2KB, but can be seen at 4 different address ranges: $0000-$07ff, $0800-$0fff, $1000-$17ff and $1fff.

The PPU can see 4 name table slots, but the internal RAM chip for name tables only has enough actual space for 2, which can be arranged in different ways depending on configurations made inside the cartridge. These configurations may be hardwired (i.e. permanently soldered) or dynamically controlled by mapper chips.

The cartridge connector was designed to give a lot of control over the name tables to the cartridge, meaning that there are enough signals there to control which name table is mapped where and even to provide extra memory for a total of 4 unique name tables, so that no mirroring is necessary.


Top
 Profile  
 
PostPosted: Sun Aug 20, 2017 7:40 pm 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19237
Location: NE Indiana, USA (NTSC)
The mapper is switching H or V at runtime based on what values the CPU writes to its ports.

Metroid (メトロイド), Super Mario Bros. 2, and Doki Doki Panic are for the Famicom Disk System. This mapper contains a 2-to-1 multiplexer controlled by bit 3 of $4025, which selects PA10 or PA11 to be routed to A10 of nametable memory. Metroid and Doki Doki Panic changes the value of this bit when Samus goes through a doorway or Papa enters or leaves a vertical level, be it through a door or a ladder. (SMB2 doesn't change it.)

Metroid (U) is for the MMC1. This mapper contains a 4-to-1 multiplexer controlled by bits 1-0 of $8000, which select a constant 0, a constant 1, PA10, or PA11 to be routed to A10 of nametable memory. It changes the value of this bit every time Samus goes through a doorway.

Super Mario Bros. 2: Mario Madness (also called Super Mario USA) is a port of Doki Doki Panic to the MMC3. This mapper contains a 2-to-1 multiplexer controlled by bit 0 of $A000, which selects PA10 or PA11 to be routed to A10 of nametable memory. It changes the value of this bit when Toad enters or leaves a vertical level, be it through a door or a ladder.

The MMC3's multiplexer follows this truth table:
Code:
Select PA11 PA10 | Out
   0    0    0   |  0
   0    0    1   |  1
   0    1    0   |  0
   0    1    1   |  1
   1    0    0   |  0
   1    0    1   |  0
   1    1    0   |  1
   1    1    1   |  1


Written more compactly using "don't care" notation:
Code:
Select PA11 PA10 | Out
   0    x    0   |  0
   0    x    1   |  1
   1    0    x   |  0
   1    1    x   |  1


The multiplexer in MMC1 and Action 53 follows this truth table:
Code:
Select PA11 PA10 | Out
  00    x    x   |  0
  01    x    x   |  1
  10    x    0   |  0
  10    x    1   |  1
  11    0    x   |  0
  11    1    x   |  1


Top
 Profile  
 
PostPosted: Sun Aug 20, 2017 8:15 pm 
Offline

Joined: Mon Jan 30, 2017 5:20 pm
Posts: 300
Location: Colorado USA
Okay, but how would a simple game with no mapper set mirroring, like Super Mario Bros.


Top
 Profile  
 
PostPosted: Sun Aug 20, 2017 8:22 pm 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19237
Location: NE Indiana, USA (NTSC)
If there's no mapper, the mirroring is set using solder pads that hardwire PA10 or PA11 to A10 in. You set the mirroring by bridging one pair of pads and not bridging the other pair.


Top
 Profile  
 
PostPosted: Sun Aug 20, 2017 9:01 pm 
Offline
User avatar

Joined: Mon Apr 04, 2011 11:49 am
Posts: 1925
Location: WhereverIparkIt, USA
DementedPurple wrote:
Okay, but how would a simple game with no mapper set mirroring, like Super Mario Bros.

Simply put, you can't from the perspective of your game's code.

You can select H/V mirroring in you ines header which tells the emulator what mirroring your cart has. That's something you decide at compile time.

You'll need a mapper if you want to change mirroring at run time.

_________________
If you're gonna play the Game Boy, you gotta learn to play it right. -Kenny Rogers


Top
 Profile  
 
PostPosted: Mon Aug 21, 2017 2:29 am 
Offline
User avatar

Joined: Fri Nov 12, 2004 2:49 pm
Posts: 7271
Location: Chexbres, VD, Switzerland
DementedPurple wrote:
So I know what mirroring is, but I don't know how I set it. There isn't a bit in the PPU control registers to set the mirroring, and when I went the nesdev wiki page, it says that vertical mirroring is in address $2000 and $2800, while as vertical is in $2000 and $2400.

The current wiki page on mirroring is awful, and my attempts to revise it (to be still mediocre but less awful) were repeatedly rejected, so I gave up on the matter.

What does matter is that the wiki is a terrible ressource when it comes to this - the diagrams however should be helpful in understanding it. Other than that your best bet is to play games with nametable viewers enabled and see what is going on.


Top
 Profile  
 
PostPosted: Mon Aug 21, 2017 6:06 am 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19237
Location: NE Indiana, USA (NTSC)
Bregalad wrote:
The current wiki page on mirroring is awful, and my attempts to revise it (to be still mediocre but less awful) were repeatedly rejected, so I gave up on the matter.

I encourage you to propose a fork in your own user space. Or did you and did I miss it?


Top
 Profile  
 
PostPosted: Mon Aug 21, 2017 7:03 am 
Offline

Joined: Tue May 28, 2013 5:49 am
Posts: 872
Location: Sweden
Also I think the term "mirroring" have always been confusing in itself. Who cares what's mirrored when it's where the nametables are when scrolling that's the interesting part. Also using a term that is opposite from what Nintendo's boards and documents use (V-mirroring is H-scroll and H-mirroring is V-scroll) isn't very intuitive either.


Top
 Profile  
 
PostPosted: Mon Aug 21, 2017 7:49 am 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19237
Location: NE Indiana, USA (NTSC)
Except a lot of games use horizontal scrolling with horizontal mirroring, such as Super Mario Bros. 3. That's why I've tried to use the term "vertical arrangement" to represent the $2000/$2800 layout where the nametable is 32 cells wide and 60 cells tall.


Top
 Profile  
 
PostPosted: Mon Aug 21, 2017 9:24 am 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 5824
Location: Canada
tepples wrote:
Bregalad wrote:
The current wiki page on mirroring is awful, and my attempts to revise it (to be still mediocre but less awful) were repeatedly rejected, so I gave up on the matter.

I encourage you to propose a fork in your own user space. Or did you and did I miss it?

He did, and you missed it (despite commenting in its discussion thread, somehow). Here's the discussion if you want to comment:
http://wiki.nesdev.com/w/index.php/Talk:Mirroring#Moving_the_bulk_of_scrolling_update_problems_to_scrolling_page


Top
 Profile  
 
PostPosted: Mon Aug 21, 2017 9:45 am 
Offline

Joined: Tue May 28, 2013 5:49 am
Posts: 872
Location: Sweden
tepples wrote:
Except a lot of games use horizontal scrolling with horizontal mirroring, such as Super Mario Bros. 3. That's why I've tried to use the term "vertical arrangement" to represent the $2000/$2800 layout where the nametable is 32 cells wide and 60 cells tall.

Well H-scroll obviously doesn't mean that the game must scroll horizontally, but that horizontal scrolling takes you into the second nametable instead of mirrored VRAM. I say call it scroll mapping or nametable arrangement, either is fine, but mirroring is just backwards. Although it might be a bit late to change a convention like that.


Top
 Profile  
 
PostPosted: Mon Aug 21, 2017 10:33 am 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19237
Location: NE Indiana, USA (NTSC)
That's why I tried to describe both the arrangement terminology and the mirroring terminology in the "awful" page on the wiki.


Top
 Profile  
 
PostPosted: Mon Aug 21, 2017 10:50 am 
Offline
User avatar

Joined: Sat Feb 12, 2005 9:43 pm
Posts: 10116
Location: Rio de Janeiro - Brazil
Changing the convention at this point may indeed end up causing even more confusion.

I don't understand how anyone in their right mind, dumping ROMs and looking directly at the "H" and "V" markings on the boards, would come up with the "mirroring" notation instead. I mean, the guy who invented the iNES format must have reverse engineered a couple of boards at some point in order to figure out what kind of information the header would need, right?


Top
 Profile  
 
PostPosted: Tue Aug 22, 2017 3:27 am 
Offline
User avatar

Joined: Fri Nov 12, 2004 2:49 pm
Posts: 7271
Location: Chexbres, VD, Switzerland
tepples wrote:
I encourage you to propose a fork in your own user space. Or did you and did I miss it?

I did exactly that but eventually I lost interest because the whole topic is a whole mess anyway. As already pointed out the "mirroring" terminology is already bad for vertical or horizontal mirroring, and becomes awful for describing anything else. My personal taste goes for the "arrangement" or "tilemap" terminology, but since the tile maps are not continious the arrangement terminology is the best. Saying a "64x30" tilemap seems to imply a row of continuous 64 characters, which is not the case when vertical mirroring is used.

In addition to that the term confuses mapper controlled and hardwired mirroring, which are two entirely different things hardware wise. That's why in my opinion when a MMC1 is configured to have, say, "vertical mirroring" it is not actual vertical mirroring but an emulation of vertical mirroring because the MMC1 controls the pin and it is not hard-wired. But other people refused to agree with me on this one, so it only brings more confusion to say mapper controlled mirroring can also be horizontal and vertical mirroring when it is in fact completely different than true hard-wired mirroring.

And I'm not even starting on iNES format which has complicated support for this. What a mess.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 32 posts ]  Go to page 1, 2, 3  Next

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group