Mirroring: Difference between revisions

From NESdev Wiki
Jump to navigationJump to search
(→‎4-Screen: None of MMC3, MMC5, m77, nor m99 "are capable of mapping some of their CHR[...] into the nametable space". The question of CHR as nametables is largely orthogonal to 4-screen layout; I don't think it belongs here.)
m (→‎Horizontal: Changed "doesn't" to "don't", as it wasn't gramatically correct before)
 
(55 intermediate revisions by 6 users not shown)
Line 1: Line 1:
There are two types of mirroring that appear commonly within the scope of NES emulation.
There are two types of '''mirroring''' on the NES:
 
* '''[[#Memory Mirroring|Memory Mirroring]]''' is when the same memory may be accessed at multiple addresses, causing an apparent duplication.
* '''[[#Nametable Mirroring|Nametable Mirroring]]''' describes the layout of the NES' 2x2 [[PPU nametables|background nametable]] graphics, usually achieved by mirrored memory.
 
 
== Memory Mirroring ==
 
Memory mirroring refers to the appearance of memory or I/O registers at more than one range of addresses, with the same byte being accessible at more than one address.
This occurs when the full address isn't completely ''decoded'', that is, when a chip ignores one or more address lines.
Because completely decoding an address usually takes a lot more pins on a chip, incomplete decoding is used to reduce the hardware required; if the mirror occupies otherwise unused address space, it poses no problems.
 
Within the NES, many things are mirrored:
* System memory at $0000-$07FF is mirrored at $0800-$0FFF, $1000-$17FF, and $1800-$1FFF - attempting to access memory at, for example, $0173 is the same as accessing memory at $0973, $1173, or $1973.
* PPU I/O registers at $2000-$2007 are mirrored at $2008-$200F, $2010-$2017, $2018-$201F, and so forth, all the way up to $3FF8-$3FFF.
* The single registers on most [[:Category:Discrete logic mappers|simple mappers]] are mirrored throughout $8000-$FFFF.
* Registers on many common ASIC mappers (such as the MMC1 and MMC3) are also mirrored, in groups, throughout $8000-$FFFF.
* Nametable mirroring, as described below, happens due to memory mirroring within PPU $2000-$2FFF (hence its name). However, in this case the memory mirroring is intentional and necessary.
* In [[NROM]]-128, the 16k PRG ROM is mirrored into both $8000-$BFFF and $C000-$FFFF.
* In most [[mapper]]s, banks past the end of PRG or CHR ROM show up as mirrors of earlier banks. For example, [[UNROM]] PRG banks 8-15 are duplicates of banks 0-7 respectively. [[Non-power-of-two ROM size]] may imply more complicated mirroring.


== Nametable Mirroring ==
== Nametable Mirroring ==
Line 14: Line 33:
Doing any horizontal scrolling using horizontal mirroring is hard to do smoothly because the data on the right of the screen is immediately show on the left due to mirroring. Clever use of hardware left-side screen clipping will hide all name table glitches, but because the attribute tables have a resolution of 2x2 tiles, there will always be attribute glitches on the left and/or the right side of the screen. The best possible way to hide it is to have 4 pixels with potentially wrong attributes on both sides, but most commercial games did worse than that having usually 8 or even more glitchy pixels, so that is why so many NES games have color glitches on the border of the screen.
Doing any horizontal scrolling using horizontal mirroring is hard to do smoothly because the data on the right of the screen is immediately show on the left due to mirroring. Clever use of hardware left-side screen clipping will hide all name table glitches, but because the attribute tables have a resolution of 2x2 tiles, there will always be attribute glitches on the left and/or the right side of the screen. The best possible way to hide it is to have 4 pixels with potentially wrong attributes on both sides, but most commercial games did worse than that having usually 8 or even more glitchy pixels, so that is why so many NES games have color glitches on the border of the screen.


Some televisions [[overscan]] up to 8 pixels on both left and right border, but most doesn't. Perfectionist programmers could use solid black sprites on the right border to hide attribute glitches and make the screen look symmetrical and hide absolutely all attribute glitches, as in the game ''Alfred Chicken'', but very few games do this because it reduces the number of sprites per scanline to 7 and wastes a lot of [[PPU OAM|OAM]] space (roughly 1/4 in 8x16 pixel sprite mode).
Some televisions [[overscan]] up to 8 pixels on both left and right border, but most don't. Perfectionist programmers could use solid black sprites on the right border to hide attribute glitches and make the screen look symmetrical and hide absolutely all attribute glitches, as in the game ''Alfred Chicken'', but very few games do this because it reduces the number of sprites per scanline to 7 and wastes a lot of [[PPU OAM|OAM]] space (roughly 1/4 in 8x16 pixel sprite mode).


To configure a cartridge board for horizontal mirroring, connect PPU A11 to CIRAM A10.  
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.
On cartridge boards made by Nintendo, this is selected by shorting the "V" solder pad (for "vertical arrangement").
<div style="clear:both"></div>
<div style="clear:both"></div>


Line 31: Line 50:


To configure a cartridge board for vertical mirroring, connect PPU A10 to CIRAM A10.  
To configure a cartridge board for vertical mirroring, connect PPU A10 to CIRAM A10.  
On cartridge boards made by Nintendo, this is selected by shorting the "H" solder pad (for "horizontal arrangement").  Note using inverse logic may make more sense, "Leaving the 'V' jumper open gives vertical mirroring" on Nintendo boards.
On cartridge boards made by Nintendo, this is selected by shorting the "H" solder pad (for "horizontal arrangement").
<div style="clear:both"></div>
<div style="clear:both"></div>


=== Single-Screen ===
=== Single-Screen ===
[[File:Single screen mirroring diagram.png|right]]
[[File:Single screen mirroring diagram overlaid.png|right]]


Single-screen mirroring is only available with certain mappers, such as the [[AxROM]], [[SxROM]], and [[TLSROM]] boards, resulting in '''two 32x30 tilemaps'''.
Single-screen mirroring is only available with certain mappers, such as the [[AxROM]], [[SxROM]], and [[TLSROM]] boards, resulting in '''two 32x30 tilemaps'''.
Line 41: Line 60:
Its main advantage is that it allows using a status bar at the top or bottom of the screen while also allowing the playfield to extend equally in any direction - this can be done by storing the status bar in one nametable, rendering the playfield in the other nametable, and switching mirroring (and scrolling parameters) at the appropriate screen location during rendering.
Its main advantage is that it allows using a status bar at the top or bottom of the screen while also allowing the playfield to extend equally in any direction - this can be done by storing the status bar in one nametable, rendering the playfield in the other nametable, and switching mirroring (and scrolling parameters) at the appropriate screen location during rendering.


There is also a lot of other things that can be drastically simplified when using 1-screen mirroring: The formulas used to calculate PPU address of data to be updated to the screen are also significantly simpler, and if the status bar have a variable size or is scrolling, all this would be a headache without 1-screen mirroring.
There are also a lot of other things that can be drastically simplified when using 1-screen mirroring: The formulas used to calculate PPU address of data to be updated to the screen are also significantly simpler, and if the status bar have a variable size or is scrolling, all this would be a headache without 1-screen mirroring.


When this mirroring is used to scroll horizontally, similar glitches and scrolling problems that those of horizontal mirroring will happen. However, as long as there is a status bar, no glitches will happen vertically since the data that falls off the bottom (or the top) of the screen will come in the area that is "hidden" by the status bar, regardless of overscan factors.
When this mirroring is used to scroll horizontally, similar glitches and scrolling problems that those of horizontal mirroring will happen. However, as long as there is a status bar, no glitches will happen vertically since the data that falls off the bottom (or the top) of the screen will come in the area that is "hidden" by the status bar, regardless of overscan factors.
Line 51: Line 70:
=== 4-Screen ===
=== 4-Screen ===
[[File:Four nametables diagram.png|right]]
[[File:Four nametables diagram.png|right]]
With additional RAM or ROM present on the cartridge, 4 unique nametables can be addressed through the CHR bus, creating a '''64x60 tilemap''', allowing for more flexible screen layouts. Very few games made use of this type of mirroring.
With additional RAM and/or PPU address mapping present on the cartridge, 4 unique nametables can be addressed through the PPU bus, creating a '''64x60 tilemap''', allowing for more flexible screen layouts. Very few games made use of this lack of mirroring.


Example games using 4-screen RAM nametables:
Games known to use 4-screen RAM nametables:
* ''Rad Racer 2''
* ''Rad Racer II''
* ''Gauntlet''
* ''Gauntlet''
* ''Napoleon Senki''
* ''Napoleon Senki''
* ''Rocman X (Sachen)''
* ''Rocman X (Sachen)''
* Every [[Vs. System]] game


Example games using 4-screen with [[:Category:Mappers with ROM nametables|ROM nametables]]:
Example games using 4-screen with [[:Category:Mappers with ROM nametables|ROM nametables]]:
* ''Final Lap''
* ''Final Lap''
* ''King of Kings''
* ''King of Kings''
Mappers known to be used with 4 screens of nametables:
* [[MMC3]] (''Rad Racer II'').
* [[iNES Mapper 206|iNES 206]] implements a subset of MMC3 features, and can use 4-screen RAM (''Gauntlet'').
* [[iNES Mapper 077|iNES 77]] maps RAM across the PPU memory space, combining with internal VRAM to provide 4 RAM nametables, and a combination of CHR-RAM and ROM for pattern tables (''Napoleon Senki'').
* [[Vs. System]] had twice as much VRAM as the NES, giving a permanent 4-screen setup. This is most visible as [[iNES Mapper 099|iNES 99]], but [[Vs. System#See also|several other mappers]] were also used on this hardware.
* [[Namco 163]] allows 1k CHR-ROM pages to be arbitrarily mapped into the 4 nametable screens (''Final Lap'', ''King of Kings'').
* The [[JY Company]] mapper allows 1k CHR-ROM pages to be arbitrarily mapped into the 4 nametable screens.
* [[UNROM 512]] and [[GTROM]] are homebrew mappers with 4-screen configurations.
Other mappers capable of uncommon 4-screen layouts:
* [[VRC6]] allows 1k CHR-ROM pages to be arbitrarily mapped into the 4 nametable screens.
* [[MMC5]] can use its internal RAM to create a 3rd nametable, while procedurally generating a blank data page for a 4th, allowing (just barely) 4 different screens to be mapped at once.
The [[iNES]] format can specify 4 nametables in the header, allowing 4-screen RAM nametables to be applied to any mapper that doesn't structurally conflict with this (if supported by the emulator).


There are several ways to implement extra nametable RAM on a cartridge board:
There are several ways to implement extra nametable RAM on a cartridge board:
* Add an extra 2 KB of RAM on the board. Decoder logic enables CIRAM only for $2000-$27FF and the cartridge RAM $2800-$2FFF.
* Add an extra 2 KiB of RAM on the board and combine it with the CIRAM already present in the console with a decoder chip in order to create linear accessible 4k block of RAM at $2000-$2FFF.
* Add a [[6264]] 8 KB RAM on the board. CIRAM /CE is pulled high, and the cartridge RAM is enabled at $2000-$3FFF. The PPU itself never uses $3000-$3FFF during rendering, but 8 KB RAMs are easier to find than 4 KB RAMs.
* Add a [[6264 static RAM|6264]] 8 KiB RAM on the board, replacing the CIRAM present in the console. This effectively "wastes" the CIRAM chip as a whole, 4 KB of (normally unused) extra memory at $3000-$3EFF. However this leads to a simpler, single-chip solution (in addition, 8 KiB RAM chips are today more common and less expensive than 2 KiB ones).
* Add a larger RAM on the board and map it to the entire PPU address space. This allows 8 KB of pattern tables at $0000-$1FFF, 4 KB of nametables at $2000-$2FFF, and almost 4 KB of extra memory at $3000-$3EFF.
* Add a larger RAM on the board and map it to the entire PPU address space. This allows 8 KiB of pattern tables at $0000-$1FFF and 4 KiB of nametables at $2000-$2FFF sharing the same RAM chip.
* [[INES Mapper 077]] uses a compromise among these solutions: an 8 KiB CHR RAM at $0800-$27FF and CIRAM at $2800-$2FFF. This leaves $0000-$07FF open for CHR ROM.
* [[INES Mapper 099]] always uses the 4 KiB of NTRAM that are built into the Vs. System board.
* [[MMC5]] provides an extra 1 KiB of RAM that can be used for nametables.
<div style="clear:both"></div>
<div style="clear:both"></div>


Line 80: Line 112:
File:ABCC mirroring diagram.png|3-screen horizontal
File:ABCC mirroring diagram.png|3-screen horizontal
File:ABBC mirroring diagram.png|3-screen diagonal
File:ABBC mirroring diagram.png|3-screen diagonal
File:Single screen 2000 mirroring diagram.png|1-screen fixed
</gallery>
</gallery>
Custom types of mirroring are available with [[iNES Mapper 119|TxSROM]] boards and with boards using the [[MMC5]] or [[Namco 163]] mapper, where the program can freely specify which nametable is which part of VRAM. The MMC5 also has RAM for a third nametable, so this opens many possibilities. So far only the MMC5 version of ''Castlevania 3'', and the ''Laser Invasion'' really uses this.


'''Diagonal mirroring''' (CIRAM A10 = PA11 XOR PA10) would appear to offer nearly glitch-free scrolling in all four directions without a status bar. Any glitches would show up on the corners, not a whole edge. (anyone have a proof of it ?)
Other uncommon types of mirroring are available in other boards, such as [[iNES Mapper 119|TxSROM]] variations of the MMC3, extended techniques available to the [[MMC5]], arbitrary VRAM mirroring arrangements by the [[Namco 163]], or ROM mirroring arrangements using mappers that allow [[:Category:Mappers with ROM nametables|ROM nametables]].


'''L-shaped mirroring''' (CIRAM A10 = PA11 OR PA10), seen in [[INES Mapper 243|mapper 243]] and the [[Sachen 8259]] family, allows scrolling in four directions as long as scrolling changes directions only at screen boundaries.
'''Diagonal mirroring''' (CIRAM A10 = PA11 XOR PA10) would facilitate changes in scrolling direction without having to flip between Horizontal and Vertical mirroring.


'''[[:Category:Mappers_with_ROM_nametables|ROM nametables]]''' can be used to temporarily replace the internal CIRAM nametables. Sometimes this is used to implement 4-Screen mirroring (see above), but a few mappers can only use it in combination with regular 2-Screen mirroring types. Its advantage is, while allowing the playfield without blinking pseudo 3D perspective when switching the screen, one of RAM side is that it can be used to the top or bottom of the status bar. This includes the [[iNES Mapper 068|Sunsoft-4]] used by ''After Burner'', and the [[JY Company]] mapper used for the unlicensed games ''Power Ranger III'' and ''IV''.
'''L-shaped mirroring''' (CIRAM A10 = PA11 OR PA10), seen in Sachen's [[INES Mapper 243|374N]] and [[Sachen 8259|8259 family]], allows scrolling in four directions as long as scrolling changes directions only at screen boundaries.
 
Unusual cases:
* ''Castlevania 3'' uses the third nametable RAM available on the [[MMC5]] ([[:Image:Castlevania III 3-Screen Mirroring.png|illustration]])
* ''Laser Invasion'' uses the third nametable RAM available on the [[MMC5]]
* ''After Burner'' uses the ROM nametables available on the [[iNES Mapper 068|Sunsoft-4]] (iNES 68), but it only supports 1/H/V arrangements.
* ''Mighty Morphin Power Rangers III, IV (JY Company)'' uses ROM nametables in a 3-Screen horizontal configuration, though the lower screen is never shown (But, lower screen has been used in the status bar).


=== Mirroring chart ===
=== Mirroring chart ===
This table helps to choose which mirroring to use, it is of course not an ultimate chart or anything, just a guide if someone is writing a game and don't know which mirroring to use.
This table lists the more simple and easy to understand mirroring and scrolling techniques. There are a huge variety of more complicated techniques. For a more comprehensive survey, see: [[List of games by mirroring technique]]
 
{| class="wikitable"
{| class="wikitable"
! Scrolling Type || With Status Bar || Without Status Bar || Game example || Comment
! Scrolling Type || Mirroring || Example Games || Comment
|-
|-
| 1-screen fixed Only || - || - || Donkey Kong||
| None
| Any
| ''Donkey Kong'', ''Tennis''
| With only a single fixed screen, any mirroring type can be used.
|-
|-
| Horizontal Only || Vertical || Vertical || Super Mario Bros.||
| Horizontal Only
| Vertical
| ''Super Mario Bros.'', ''Gimmick!''
| A [[status bar]] at the top is easy to accomplish with a [[sprite-0 hit]] (see ''Super Mario Bros.'').
|-
|-
| Vertical Only || Vertical, Single Screen, 3-screen V/H{{sup|3}} || Horizontal || Gun.Smoke, Recca||
| Vertical Only
| Horizontal
| ''Ice Climber'', ''Gun.Smoke''
| Without a status bar, horizontal mirroring is the best choice for vertical-only scrolling. With a status bar, vertical or single-screen mirroring give you a place in the nametable to render the status bar, and the scrolling seam should be hidden under the bar.
|-
|-
| Horizontal Only, field limited horizontally || Vertical || Vertical || Lode Runner || No data has to be loaded at all when scrolling horizontally, but the area is limited to two screens.
| Alternating Horizontal/Vertical
| Mapper switches H/V
| ''Metroid'', ''Air Fortress''
| Motion is limited to a single axis at any given time, and the direction can only change when a new screen is reached.
|-
|-
| Vertical Only, field limited vertically || Horizontal || Horizontal || Wrecking Crew || No data has to be loaded at all when scrolling vertically, but the area is limited to two screens (less the status bar if present).
| Limited Bidirectional
| Horizontal/Vertical
| ''Super Mario Bros. 3'', ''Fire Emblem''
| By limiting one of the scrolling axes to only 2-screens wide, this makes unlimited scrolling in the other axis simple. With unlimited horizontal scrolling there will be unavoidable attribute glitches at one side of the screen (see ''Super Mario Bros. 3''), but with unlimited vertical scrolling this can be hidden by [[overscan]] in NTSC regions (see ''Fire Emblem'').
|-
|-
| Horizontal/Vertical aligned screens || Vertical, Horizontal{{sup|2}}, Diagonal, 3-screen V/D{{sup|3}}, 4-screen{{sup|4}} || Alternate H/V, L-shaped, Diagonal, 3-screen D{{sup|3}}, 4-screen{{sup|4}} || Metroid, Mega Man series, Air Fortress, Guardian Legend || For use if scrolling direction changes only on a screen-based pattern, as in ''Metroid'' and ''Mega Man 3, 4, 5, 6''.
| Unlimited Bidirectional
Horizontal mirroring with a status bar works best with as status bar will have to change address when scrolling vertically (Also work as Diagonal mirroring) or playfield will have to be written twice to memory. (Panic Restaurant)
| Various
|-
| ''Castlevania II'', ''Battletoads'', ''Crystalis'', ''Final Fantasy''
| Horizontal/Vertical/Bidirectional aligned screens || Vertical <-> Single Screen{{sup|2}}, Horizontal{{sup|2}}, Vertical, 4-screen{{sup|4}} || Alternate V{{sup|1}}/H{{sup|2}}, Diagonal, 4-screen{{sup|4}} || Akumajou Special, Rockman 4 Minus Infinity || Horizontal or 4-screen mirroring with a status bar works best with as status bar will have to change address when scrolling vertically or playfield will have to be written twice to memory. (Teenage Mutant Ninja Turtles III: The Manhattan Project)
| Unlimited scrolling in both axes at once is an advanced technique requiring a game-specific solution.
Vertical mirroring Only with a status bar works best with a scanline counter IRQ. (Teenage Mutant Ninja Turtles II: The Arcade Game)
|-
| Bidirectional, field limited vertically || Horizontal{{sup|2}} || Horizontal{{sup|2}} || Super Mario Bros. 3 || No data has to be loaded at all when scrolling vertically, but the area is limited to two screens (less the status bar if present).
|-
| Bidirectional, field limited horizontally || Vertical || Vertical{{sup|1}} || Fire Emblem || No data has to be loaded at all when scrolling horizontally, but the area is limited to two screens.
Vertical mirroring with a status bar works best with a scanline counter IRQ.
|-
| Bidirectional, field limited 4-screen || 4-screen{{sup|4}} || 4-screen{{sup|4}} || Gauntlet || No data has to be loaded at all when scrolling 4-screen, but the area is limited to four screens (less the status bar if present).
|-
| Free bidirectional || Single Screen{{sup|2}}, Horizontal{{sup|2}}, Vertical, 4-screen{{sup|4}} || Vertical{{sup|1}}, Horizontal{{sup|2}}, Diagonal, 4-screen{{sup|4}} || Kirby's Adventure || If using horizontal or 4-screen mirroring with a status bar there are 2 possibilities:
# The status bar will have to change address when scrolling vertically (Double Dragon series, Conquest of Crystal Palace, Gradius II)
# The playfield will have to be written twice to memory (Kirby's Adventure, Little Nemo: The Dream Master), which only works if the status's bar size remains constant.
Vertical mirroring with a status bar works best with a scanline counter IRQ. (Jungle Book, Mickey's Safari in Letterland)
|-
| Depth screen || Vertical, Horizontal, 4-screen{{sup|4}} || Vertical, Horizontal, 4-screen{{sup|4}} || Mach Rider, Rad Racer || Bidirectional Pseudo 3D depth perspective works best with a CHR bank switching ROM nametables. (After Burner) 
|}
|}


* {{sup|1}}: Vertical glitches on PAL screens and on NTSC that doesn't overscan.
The best way to understand the mirroring techniques used in a game, use a debugging emulator to look at the nametables. [[Status bar|Status bars]] typically require a scrolling split at a timed location on the screen. This can be done most easily with a mapper based [[IRQ]], but can also be accomplished with a [[sprite-0 hit]] or other techniques.
* {{sup|2}}: Horizontal glitches will be unavoidable when scrolling (see above).
* {{sup|3}}: 3-screen mirroring, you can use only specific mapper of MMC5.
* {{sup|4}}: 4-screen mirroring, and can be used only when you added an additional RAM to the cartridge board.
 
== Memory Mirroring ==
 
Memory mirroring refers to the appearance of memory or I/O registers at more than one range of addresses, with the same byte being accessible at more than one address.
This occurs when the full address isn't completely ''decoded'', that is, when a chip ignores one or more address lines.
Because completely decoding an address usually takes a lot more pins on a chip, incomplete decoding is used to reduce the hardware required; if the mirror occupies otherwise unused address space, it poses no problems.
 
Within the NES, many things are mirrored:
* System memory at $0000-$07FF is mirrored at $0800-$0FFF, $1000-$17FF, and $1800-$1FFF - attempting to access memory at, for example, $0173 is the same as accessing memory at $0973, $1173, or $1973.
* PPU I/O registers at $2000-$2007 are mirrored at $2008-$200F, $2010-$2017, $2018-$201F, and so forth, all the way up to $3FF8-$3FFF.
* The single registers on most [[:Category:Discrete logic mappers|simple mappers]] are mirrored throughout $8000-$FFFF.
* Registers on many common ASIC mappers (such as the MMC1 and MMC3) are also mirrored, in groups, throughout $8000-$FFFF.
* Nametable mirroring, as described above, happens due to memory mirroring within PPU $2000-$2FFF (hence its name). However, in this case the memory mirroring is intentional and necessary.
* In [[NROM]]-128, the 16k PRG ROM is mirrored into both $8000-$BFFF and $C000-$FFFF.
* In most [[mapper]]s, banks past the end of PRG or CHR ROM show up as mirrors of earlier banks. For example, [[UNROM]] PRG banks 8-15 are duplicates of banks 0-7 respectively.


== See also ==
== See also ==


* [[PPU scrolling]]
* [[PPU scrolling]]

Latest revision as of 11:00, 15 November 2024

There are two types of mirroring on the NES:


Memory Mirroring

Memory mirroring refers to the appearance of memory or I/O registers at more than one range of addresses, with the same byte being accessible at more than one address. This occurs when the full address isn't completely decoded, that is, when a chip ignores one or more address lines. Because completely decoding an address usually takes a lot more pins on a chip, incomplete decoding is used to reduce the hardware required; if the mirror occupies otherwise unused address space, it poses no problems.

Within the NES, many things are mirrored:

  • System memory at $0000-$07FF is mirrored at $0800-$0FFF, $1000-$17FF, and $1800-$1FFF - attempting to access memory at, for example, $0173 is the same as accessing memory at $0973, $1173, or $1973.
  • PPU I/O registers at $2000-$2007 are mirrored at $2008-$200F, $2010-$2017, $2018-$201F, and so forth, all the way up to $3FF8-$3FFF.
  • The single registers on most simple mappers are mirrored throughout $8000-$FFFF.
  • Registers on many common ASIC mappers (such as the MMC1 and MMC3) are also mirrored, in groups, throughout $8000-$FFFF.
  • Nametable mirroring, as described below, happens due to memory mirroring within PPU $2000-$2FFF (hence its name). However, in this case the memory mirroring is intentional and necessary.
  • In NROM-128, the 16k PRG ROM is mirrored into both $8000-$BFFF and $C000-$FFFF.
  • In most mappers, banks past the end of PRG or CHR ROM show up as mirrors of earlier banks. For example, UNROM PRG banks 8-15 are duplicates of banks 0-7 respectively. Non-power-of-two ROM size may imply more complicated mirroring.

Nametable Mirroring

Nametable mirroring affects what is shown past the right and bottom edges of the current nametable. When mirroring is enabled for a particular axis (horizontal and/or vertical), the coordinates simply wrap around on the current nametable. A background "mirrored" in this way is repeated, not flipped. When mirroring is disabled, a second nametable is used. There are four common combinations of mirroring:

Horizontal

Horizontal mirroring diagram.png

A vertical arrangement of the nametables results in horizontal mirroring, which makes a 32x60 tilemap.

This is most commonly used for games which only scroll vertically or in all directions.

Doing any horizontal scrolling using horizontal mirroring is hard to do smoothly because the data on the right of the screen is immediately show on the left due to mirroring. Clever use of hardware left-side screen clipping will hide all name table glitches, but because the attribute tables have a resolution of 2x2 tiles, there will always be attribute glitches on the left and/or the right side of the screen. The best possible way to hide it is to have 4 pixels with potentially wrong attributes on both sides, but most commercial games did worse than that having usually 8 or even more glitchy pixels, so that is why so many NES games have color glitches on the border of the screen.

Some televisions overscan up to 8 pixels on both left and right border, but most don't. Perfectionist programmers could use solid black sprites on the right border to hide attribute glitches and make the screen look symmetrical and hide absolutely all attribute glitches, as in the game Alfred Chicken, but very few games do this because it reduces the number of sprites per scanline to 7 and wastes a lot of OAM space (roughly 1/4 in 8x16 pixel sprite mode).

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").

Vertical

Vertical mirroring diagram.png

A horizontal arrangement of the nametables results in vertical mirroring, which makes a 64x30 tilemap.

This is most commonly used for games which only scroll horizontally. Games that scroll vertically (by any amount and without status bar) and that never scroll horizontally by more than one screen would use this mirroring (e.g. Lode Runner, Bomberman, Fire Emblem, Crystal Mines), so that they don't have to load anything when scrolling horizontally.

Of course it is also used for games which scroll in both directions without a status bar. Because data that is on the top/bottom of the screen will immediately show up on the other side, a clever use of NTSC overscan can make it glitch-less multidirectional scrolling, but glitches will appear on PAL televisions (and NTSC televisions with a overscan range which is a little off). The best possible way to hide glitches is to make 4 pixels with wrong tiles and 4 additional pixels with wrong color on both sides, but most commercial games did much worse than this, that's why they look so bad if overscan is disabled.

Perfectionist programmers could use raster split to hide glitches (and possibly also provide more blanking time to update VRAM) as in the games Jurassic Park and M.C. Kids, but it was rarely done because it complicates the code a lot for little benefits.

To configure a cartridge board for vertical mirroring, connect PPU A10 to CIRAM A10. On cartridge boards made by Nintendo, this is selected by shorting the "H" solder pad (for "horizontal arrangement").

Single-Screen

Single screen mirroring diagram overlaid.png

Single-screen mirroring is only available with certain mappers, such as the AxROM, SxROM, and TLSROM boards, resulting in two 32x30 tilemaps.

Its main advantage is that it allows using a status bar at the top or bottom of the screen while also allowing the playfield to extend equally in any direction - this can be done by storing the status bar in one nametable, rendering the playfield in the other nametable, and switching mirroring (and scrolling parameters) at the appropriate screen location during rendering.

There are also a lot of other things that can be drastically simplified when using 1-screen mirroring: The formulas used to calculate PPU address of data to be updated to the screen are also significantly simpler, and if the status bar have a variable size or is scrolling, all this would be a headache without 1-screen mirroring.

When this mirroring is used to scroll horizontally, similar glitches and scrolling problems that those of horizontal mirroring will happen. However, as long as there is a status bar, no glitches will happen vertically since the data that falls off the bottom (or the top) of the screen will come in the area that is "hidden" by the status bar, regardless of overscan factors.

There are several different ways to configure a cartridge board for single-screen mirroring. Some boards have single screen mirroring which is mapper controlled like the MMC1 and AxROM. For AxROM connect the output of a register (e.g. 74HC161) to CIRAM A10 (AxROM latches PRG D4). A simpler way to create one screen mirroring that's fixed (non-changable by software) is to simply connect CIRAM A10 to Gnd or Vcc. The board that implements iNES Mapper 218 wires CIRAM A10 to PPU A10, A11, A12, or A13, so that the game can store tiles in CIRAM without having any CHR ROM or CHR RAM in the cartridge.

4-Screen

Four nametables diagram.png

With additional RAM and/or PPU address mapping present on the cartridge, 4 unique nametables can be addressed through the PPU bus, creating a 64x60 tilemap, allowing for more flexible screen layouts. Very few games made use of this lack of mirroring.

Games known to use 4-screen RAM nametables:

  • Rad Racer II
  • Gauntlet
  • Napoleon Senki
  • Rocman X (Sachen)
  • Every Vs. System game

Example games using 4-screen with ROM nametables:

  • Final Lap
  • King of Kings

Mappers known to be used with 4 screens of nametables:

  • MMC3 (Rad Racer II).
  • iNES 206 implements a subset of MMC3 features, and can use 4-screen RAM (Gauntlet).
  • iNES 77 maps RAM across the PPU memory space, combining with internal VRAM to provide 4 RAM nametables, and a combination of CHR-RAM and ROM for pattern tables (Napoleon Senki).
  • Vs. System had twice as much VRAM as the NES, giving a permanent 4-screen setup. This is most visible as iNES 99, but several other mappers were also used on this hardware.
  • Namco 163 allows 1k CHR-ROM pages to be arbitrarily mapped into the 4 nametable screens (Final Lap, King of Kings).
  • The JY Company mapper allows 1k CHR-ROM pages to be arbitrarily mapped into the 4 nametable screens.
  • UNROM 512 and GTROM are homebrew mappers with 4-screen configurations.

Other mappers capable of uncommon 4-screen layouts:

  • VRC6 allows 1k CHR-ROM pages to be arbitrarily mapped into the 4 nametable screens.
  • MMC5 can use its internal RAM to create a 3rd nametable, while procedurally generating a blank data page for a 4th, allowing (just barely) 4 different screens to be mapped at once.

The iNES format can specify 4 nametables in the header, allowing 4-screen RAM nametables to be applied to any mapper that doesn't structurally conflict with this (if supported by the emulator).

There are several ways to implement extra nametable RAM on a cartridge board:

  • Add an extra 2 KiB of RAM on the board and combine it with the CIRAM already present in the console with a decoder chip in order to create linear accessible 4k block of RAM at $2000-$2FFF.
  • Add a 6264 8 KiB RAM on the board, replacing the CIRAM present in the console. This effectively "wastes" the CIRAM chip as a whole, 4 KB of (normally unused) extra memory at $3000-$3EFF. However this leads to a simpler, single-chip solution (in addition, 8 KiB RAM chips are today more common and less expensive than 2 KiB ones).
  • Add a larger RAM on the board and map it to the entire PPU address space. This allows 8 KiB of pattern tables at $0000-$1FFF and 4 KiB of nametables at $2000-$2FFF sharing the same RAM chip.

Other

Other uncommon types of mirroring are available in other boards, such as TxSROM variations of the MMC3, extended techniques available to the MMC5, arbitrary VRAM mirroring arrangements by the Namco 163, or ROM mirroring arrangements using mappers that allow ROM nametables.

Diagonal mirroring (CIRAM A10 = PA11 XOR PA10) would facilitate changes in scrolling direction without having to flip between Horizontal and Vertical mirroring.

L-shaped mirroring (CIRAM A10 = PA11 OR PA10), seen in Sachen's 374N and 8259 family, allows scrolling in four directions as long as scrolling changes directions only at screen boundaries.

Unusual cases:

  • Castlevania 3 uses the third nametable RAM available on the MMC5 (illustration)
  • Laser Invasion uses the third nametable RAM available on the MMC5
  • After Burner uses the ROM nametables available on the Sunsoft-4 (iNES 68), but it only supports 1/H/V arrangements.
  • Mighty Morphin Power Rangers III, IV (JY Company) uses ROM nametables in a 3-Screen horizontal configuration, though the lower screen is never shown (But, lower screen has been used in the status bar).

Mirroring chart

This table lists the more simple and easy to understand mirroring and scrolling techniques. There are a huge variety of more complicated techniques. For a more comprehensive survey, see: List of games by mirroring technique

Scrolling Type Mirroring Example Games Comment
None Any Donkey Kong, Tennis With only a single fixed screen, any mirroring type can be used.
Horizontal Only Vertical Super Mario Bros., Gimmick! A status bar at the top is easy to accomplish with a sprite-0 hit (see Super Mario Bros.).
Vertical Only Horizontal Ice Climber, Gun.Smoke Without a status bar, horizontal mirroring is the best choice for vertical-only scrolling. With a status bar, vertical or single-screen mirroring give you a place in the nametable to render the status bar, and the scrolling seam should be hidden under the bar.
Alternating Horizontal/Vertical Mapper switches H/V Metroid, Air Fortress Motion is limited to a single axis at any given time, and the direction can only change when a new screen is reached.
Limited Bidirectional Horizontal/Vertical Super Mario Bros. 3, Fire Emblem By limiting one of the scrolling axes to only 2-screens wide, this makes unlimited scrolling in the other axis simple. With unlimited horizontal scrolling there will be unavoidable attribute glitches at one side of the screen (see Super Mario Bros. 3), but with unlimited vertical scrolling this can be hidden by overscan in NTSC regions (see Fire Emblem).
Unlimited Bidirectional Various Castlevania II, Battletoads, Crystalis, Final Fantasy Unlimited scrolling in both axes at once is an advanced technique requiring a game-specific solution.

The best way to understand the mirroring techniques used in a game, use a debugging emulator to look at the nametables. Status bars typically require a scrolling split at a timed location on the screen. This can be done most easily with a mapper based IRQ, but can also be accomplished with a sprite-0 hit or other techniques.

See also