CNROM: Difference between revisions

From NESdev Wiki
Jump to navigationJump to search
No edit summary
(Don't link to old information. Don't have page link to itself.)
(19 intermediate revisions by 10 users not shown)
Line 1: Line 1:
{{User:Tepples/Infobox_iNES_mapper
[[Category:CNROM-like mappers]][[Category:Nintendo licensed mappers]][[Category:Expansion audio]]
{{Infobox iNES mapper
|name=CNROM
|name=CNROM
|company=Nintendo
|company=Nintendo, others
|mapper=3
|mapper=3
|othermappers=[[iNES Mapper 185|185]]
|othermappers=[[iNES Mapper 185|185]]
Line 9: Line 10:
|chrmax=32K
|chrmax=32K
|chrpage=8K
|chrpage=8K
|mirroring=Fixed H or V (solder pads)
|busconflicts=Yes
|busconflicts=Yes
|audio=No
}}
}}
[[Category:CNROM-like mappers]][[Category:Nintendo licensed mappers]]
{{nesdbbox
NES-[[CNROM]] (and its [[Famicom|HVC]] counterpart) is a particular Nintendo cartridge board which uses uses discrete logic to provide up to four 8 KB banks of CHR ROM. The most common usage of this board, as well as other third-party compatible boards, is assigned to [[iNES Mapper 003|iNES mapper 3]]. (See [[iNES Mapper 003]] for the suggested emulator implementation.)  A small collection of non-bankswitching CNROM boards that have an incompatible copy-protection issue are assigned to [[iNES Mapper 185]].
|ines|3|iNES 003
|ines|185|iNES 185
|unif_wild|CNROM|CNROM
}}
'''[[CNROM]]''' is a discrete-logic circuit board providing up to four 8 KB banks of CHR-ROM. Two iNES mapper numbers denote its two configurations:
* '''iNES Mapper 3''' denotes the common usage mounting 16-32 KiB of CHR-ROM.
** Submapper 0: Bus conflict behavior unknown
** Submapper 1: No bus conflicts
** Submapper 2: AND-type bus conflicts
* '''iNES Mapper 185''' denotes a special usage mounting only 8 KiB of CHR-ROM. CHR-ROM is disabled unless the correct bank number has been selected.
** Submapper 0: CHR-ROM-enabling CS1/CS2 values unknown
** Submapper 4: CS1/CS2=0 enables CHR-ROM, all other values disable CHR-ROM
** Submapper 5: CS1/CS2=1 enables CHR-ROM, all other values disable CHR-ROM
** Submapper 6: CS1/CS2=2 enables CHR-ROM, all other values disable CHR-ROM
** Submapper 7: CS1/CS2=3 enables CHR-ROM, all other values disable CHR-ROM
Two Bandai boards extend the functionality of CNROM:
* [https://nescartdb.com/profile/view/4090/family-trainer-4-jogging-race|''Family Trainer: Jogging Race''] is a simple [[#Oversize mapper 3 with up to 128 KiB|oversized]] version of CNROM and therefore is assigned to mapper 3 as well;
* [https://nescartdb.com/profile/view/3953/family-trainer-3-aerobics-studio|''Family Trainer: Aerobics Studio''] adds a [https://forums.nesdev.org/viewtopic.php?p=102300#p102300|Mitsubishi M50805 speech chip] using an [[#M5085 Speech: responds to writes to CPU $6000-$7FFF|extra register]]. The chip is currently unemulated, but once it is, the speech ROM data will be included as NES 2.0 Misc. ROM data.
The Namco game [https://nescartdb.com/profile/view/3844/hayauchi-super-igo|''Hayauchi Super Igo''] adds 2 KiB of PRG-RAM, denoted using mapper 3 and the appropriate value in the header's PRG-RAM size field.


== Banks ==
=Banks=
* CPU $8000-$FFFF: 16 KB PRG ROM, fixed (if 16 KB PRG ROM used, then this is the same as $C000-$FFFF)
* CPU $6000-$7FFF: 2 KiB of PRG-RAM, mirrored three times (''Hayauchi Super Igo'' only)
* CPU $C000-$FFFF: 16 KB PRG ROM, fixed
* CPU $8000-$FFFF: 32 KB unbanked PRG-ROM
* PPU $0000-$1FFF: 8 KB switchable CHR ROM bank
* PPU $0000-$1FFF: 8 KB switchable window into 32 KiB CHR-ROM
* Nametable arrangement: Fixed; solder pad selects between Horizontal and Vertical


== Registers ==
=Registers=
=== Bank select ($8000-$FFFF) ===
==Bank Select: responds to writes to CPU $8000-$FFFF==
  7  bit  0
===Regular mapper 3 with up to 32 KiB===
---- ----
  D~[..DC ..BA] A~[1... .... .... ....]
xxDD xxCC
      ||  ||
  ||  ||
      ||  ++- CHR A14..A13 (8 KiB bank)
  ||  ++- Select 8 KB CHR ROM bank for PPU $0000-$1FFF
      |+------ Output to Diode 2 (D2)
  ++------ Security diodes config
      +------- Output to Diode 1 (D1)


== Hardware ==
The original CNROM board is always subject to AND-type bus conflicts: the effective value is the value being written bitwise-AND'd with the PRG-ROM content at the address being written to. iNES Mapper 3's submapper indicates whether bus conflicts should actually be emulated. So far, the only .NES files requiring the absence of bus conflicts have been mapper hacks to mapper 3 from other mappers.
The CNROM board contains a [[74161|74HC161]] binary counter used as a quad D latch (4-bit register) to select the current CHR bank.


Early CNROM boards allow security diodes to be placed. If the latched bits 4 and 5 do not correspond to the configuration of the 2 diodes placed on the board while the PPU is rendering, the latched signal will conflict with some of the PPU's addresses bus and create bus conflicts. This system was probably created to make dumping cartridges harder, because the dumping device would have to write the correct value into the 74HC161 latch to dump the CHR ROM properly, or else bus conflicts will appear and possibly damage the dumping device.
===Oversize mapper 3 with up to 128 KiB===
This anti-dump precaution wasn't very effective, and Nintendo quickly gave up on this. Only Japanese games released in 1986 are known to have these diodes present.
D~[.... DCBA] A~[1... .... .... ....]
        ||||
        ++++- CHR A16..A13 (8 KiB bank)


Some Japanese CNROM games combine the diode security with special CHR ROM where higher addresses are actually additional chip enable signals. This will cause the game's CHR ROM to be disabled at all if the wrong CHR bank is selected, making only one actual 8K CHR bank available (the games could in theory run in a [[NROM]] board without being affected).
Among the licensed NES/Famicom library, this configuration is only used by Bandai's ''Family Trainer: Jogging Race''. Several unlicensed cartridges mount 64 KiB of CHR-ROM; although they work as oversize mapper 3 as well, they are canonically assigned to [[INES Mapper 148]] instead.
Those games typically turn the PPU off, switch in the wrong CHR bank (that return open bus) with wrong diode configuration, read a CHR byte in a specific place where the bus conflicts with the mapper will not appear even with the wrong diode config, then read the same byte with the correct bank and diode config latched, and enter in an infinite loop if the two reads matches. Those games have been assigned to [[iNES Mapper 185]]. Trying to dump them as regular NROM games will create bus conflicts with the dumping device, and even if this is bypassed the game will not run because the CHR ROM will be mirrored for all 8K bank select values.


=== Solder Pad Config ===
===Mapper 185===
* Horizontal mirroring : 'H' disconnected, 'V' connected.
D~[..DC ..BA] A~[1... .... .... ....]
* Vertical mirroring : 'H' connected, 'V' disconnected.
      ||  ||
      ||  |+- Chip Select 2 (CS2)
      ||  +-- Chip Select 1 (CS1)     
      |+------ Output to Diode 2 (D2)
      +------- Output to Diode 1 (D1)


* 16 KB PRG ROM : 'SL' connected, 'CL' disconnected.
Mapper 185 always has AND-type bus conflicts. The submapper number denotes the correct Chip Select value that enables CHR-ROM; if another value is active, CHR-ROM is disabled, meaning that reading from the pattern tables returns [[Open_bus_behavior#PPU_open_bus|open bus]]. Theoretically, this should return the LSB of the address read, but real-world behavior varies, and the earlier revision of Mighty Bomb Jack in fact relies on open bus at PPU address $0000 being something other than $00. If the correct Chip Select value is not known -- denoted by submapper 0, which applies to all .NES files without a [[NES 2.0]] header, the simple heuristic "Disable CHR-ROM for the first two reads $2007 after a reset and then enable it" will work with all known games.
* 32 KB PRG ROM : 'SL' disconnected, 'CL' connected.


* Bit 4 security implemented to '0' : D2 cathode set to '3' (CHR A12) and D2 anode set to '4' (latch).
{| class="datatable sortable"
* Bit 4 security implemented to '1' : D2 cathode set to '4' (latch) and D2 anode set to '3' (CHR A12).
! || bank || PPU addr || test || bank || PPU addr || test
* Bit 5 security implemented to '0' : D1 cathode set to '1' (CHR A10) and D1 anode set to '2' (latch).
|-
* Bit 5 security implemented to '1' : D1 cathode set to '2' (latch) and D1 anode set to '1' (CHR A10).
! Game !! colspan=3|Incorrect bank !! colspan=3|Must work <!-- specific test -->
* Security unimplemented : D1 and D2 not present.
|-
| [//nescartdb.com/profile/view/1262 Bird Week] || $F0 || $1FF0 || ≠ $0C || $0F || $1FF0 || = $0C
|-
| [//nescartdb.com/profile/view/1264 B-Wings] || $00 || $0000 || ≠ $3C || $33 || $0000 || = $3C
|-
| [//nescartdb.com/profile/view/1261 Mighty Bomb Jack (J, PRG0)] || $00 || $0000 || ≠ $00 || $11 || colspan=2|untested
|-
| Mighty Bomb Jack (J, PRG1) || $00 || $0001 || ≠ $3C || $11 || colspan=2|untested
|-
| Sansuu 1 Nen || $20 || $000C || ≠ $BC || $22 || $000C || = $BC
|-
| [//nescartdb.com/profile/view/1263 Sansuu 2 Nen] || $20 || $0003 || ≠ $42 || $22 || $0003 || = $42
|-
| [//nescartdb.com/profile/view/4061 Othello] || $20 || $0006 || ≠ $3F || $22 || $0006 || = $3F
|-
| [//nescartdb.com/profile/view/3791 Sansuu 3 Nen] || $00 || $0006 || ≠ $34 || $2A || $0006 || = $34
|-
| [//nescartdb.com/profile/view/3592 Spy vs Spy] || $13 || $1F20 || ≠ $55 || $21 || colspan=2|untested
|-
| [//nescartdb.com/profile/view/2332 Seicross] || $21 || $0700…$0707 || ≠ $20,$60,$70,$70,$70,$40,$08,$38 || $20 || colspan=2|untested
|}
The North American and PAL versions of ''Mighty Bomb Jack'' mount 32 KiB of CHR-ROM instead and so use normal [[INES Mapper 003|mapper 3]].


== Variants ==
==Speech Start/Message Select: responds to writes to CPU $6000-$7FFF==
CNROM operates identically to a [[GNROM]] with one PRG bank.
D~[.D.. .CBA] A~[011. .... .... ....]
    |    +++- Message number (0-7)
    +-------- M5085 /SYNC signal
A falling edge of the D bit starts the selected speech line. This register only exists on the PCB of ''Family Trainer: Aerobics Studio''.


The upper 2 bank select bits on the [[74161|74HC161]] were connected to security diodes.
=Hardware=
If they were connected to CHR ROM address lines instead, this board could have theoretically supported up to 128 KB of CHR ROM.
The 4-bit latch register is implemented using a [[74161|74HC161]] binary counter. On iNES Mapper 3, the latch's A and B outputs directly connect to the CHR-ROM chip's A14 and A13 inputs. On iNES Mapper 185, the particular ROM chip model (Sharp LH2367 or equivalent) changes the functionality of pins 26 (normally A13) and 27 (normally A14) into two programmable (during manufacturing) Chip Select inputs, effectively disabling CHR-ROM and tri-stating its data outputs when the one correct bank of four possible CHR-ROM banks is not selected, as a copy-protection mechanism.  
In fact, [[iNES Mapper 003]] encompasses both CNROM and similar boards that used more CHR ROM, such as those made by [http://bootgod.dyndns.org:7777/profile.php?id=4090 Bandai] and [http://bootgod.dyndns.org:7777/profile.php?id=1838 Panesian].


The [http://bootgod.dyndns.org:7777/profile.php?id=3953 Japanese version of ''Dance Aerobics''] adds a [http://forums.nesdev.org/viewtopic.php?p=102300#p102300 sound playback IC] to CNROM. It adds a [http://forums.nesdev.org/viewtopic.php?t=9449 register mapped from $6000-$7FFF] that can play one of eight voice recordings. However, the specifics of the compression are not yet known, and there is no standardized way to bundle audio data with [[iNES]] images.
==Security diodes==
As another copy protection mechanism, the CNROM circuit board has a spot for two diodes that produce additional bus conflicts to hinder cartridge dumping attempts. Diode 1 connects latch bit 'D' to CHR-ROM A10; Diode 2 connects latch bit 'C' to CHR-ROM A12. Each latch bit must be set such that the diode does ''not'' allow current to flow, because if it does, AND-type bus conflicts occur that may cause the wrong CHR-ROM A10 and A12 signals to be applied, depending on the relative output resistances of latch chip and console or dumping device. Both the NES PPU and modern Kazzo-like dumping devices have strong enough output drivers to always win these bus conflicts, but 1980s' dumping equipment will lose these bus conflicts and produce an unusable readout. Each diode can be mounted either with the anode or the cathode facing the latch output. As a diode will allow current to flow if the anode-side voltage is significantly higher than the cathode-side voltage, the latch bit must be 0 if it faces the anode, and 1 if it faces the cathode. The security diodes were mounted by most Nintendo-manufactured Japanese CNROM games manufactured in 1986 as well as Bandai-manufactured CNROM games from 1986 and 1987. They were never used on North American or PAL CNROM games, even as the NES-CNROM board has an unpopulated spot for them until at least revision -02. Emulators need not emulate the functionality of security diodes to run games correctly.


Theoretically the bank select register could be implemented with a [[74377|74HC377]] octal D latch, allowing up to 2 megabytes of CHR ROM.
==Solder Pad Configuration==
* Horizontal nametable arrangement ("vertical mirroring"): 'H' connected, 'V' disconnected.
* Vertical nametable arrangement ("horizontal mirroring"): 'H' disconnected, 'V' connected.
* 16 KB PRG-ROM: 'SL' connected, 'CL' disconnected.
* 32 KB PRG-ROM: 'SL' disconnected, 'CL' connected.


== Notes ==
[https://nescartdb.com/profile/view/3844/hayauchi-super-igo ''Hayauchi Super Igo''] is a CNROM-like board with a 2KB SRAM mapped at $6000, using a [[7410|74HC10]] as the address decoder.
Many CNROM games such as ''Milon's Secret Castle'' store data tables in otherwise unused portions of CHR ROM and access them through [[PPUDATA]] ($2007) reads. If an emulator can show the title screen of the [[NROM]] game ''Super Mario Bros.'', but CNROM games don't work, the emulator's PPUDATA readback is likely failing to consider CHR ROM bankswitching.


== See Also ==
Theoretically the bank select register could be implemented with a [[74377|74HC377]] octal D latch, allowing up to 2 megabytes of CHR ROM.
* [[iNES Mapper 003]] - The common emulator implementation used for this board, which includes some compatible additions.
* [[iNES Mapper 185]] - Emulation for a subset of CNROM boards that implement a weak form of copy protection.
*[http://nesdev.org/mappers.zip Comprehensive NES Mapper Document] by \Firebug\, information about mapper's initial state is inaccurate.

Revision as of 08:34, 8 February 2025

CNROM
Company Nintendo, others
Boards CNROM
PRG ROM capacity 32K
PRG ROM window n/a
PRG RAM capacity None
CHR capacity 32K
CHR window 8K
Nametable mirroring Fixed H or V, controlled by solder pads
Bus conflicts Yes
IRQ No
Audio No
iNES mappers 003, 185
NESCartDB
iNES 003
iNES 185
CNROM

CNROM is a discrete-logic circuit board providing up to four 8 KB banks of CHR-ROM. Two iNES mapper numbers denote its two configurations:

  • iNES Mapper 3 denotes the common usage mounting 16-32 KiB of CHR-ROM.
    • Submapper 0: Bus conflict behavior unknown
    • Submapper 1: No bus conflicts
    • Submapper 2: AND-type bus conflicts
  • iNES Mapper 185 denotes a special usage mounting only 8 KiB of CHR-ROM. CHR-ROM is disabled unless the correct bank number has been selected.
    • Submapper 0: CHR-ROM-enabling CS1/CS2 values unknown
    • Submapper 4: CS1/CS2=0 enables CHR-ROM, all other values disable CHR-ROM
    • Submapper 5: CS1/CS2=1 enables CHR-ROM, all other values disable CHR-ROM
    • Submapper 6: CS1/CS2=2 enables CHR-ROM, all other values disable CHR-ROM
    • Submapper 7: CS1/CS2=3 enables CHR-ROM, all other values disable CHR-ROM

Two Bandai boards extend the functionality of CNROM:

The Namco game Hayauchi Super Igo adds 2 KiB of PRG-RAM, denoted using mapper 3 and the appropriate value in the header's PRG-RAM size field.

Banks

  • CPU $6000-$7FFF: 2 KiB of PRG-RAM, mirrored three times (Hayauchi Super Igo only)
  • CPU $8000-$FFFF: 32 KB unbanked PRG-ROM
  • PPU $0000-$1FFF: 8 KB switchable window into 32 KiB CHR-ROM
  • Nametable arrangement: Fixed; solder pad selects between Horizontal and Vertical

Registers

Bank Select: responds to writes to CPU $8000-$FFFF

Regular mapper 3 with up to 32 KiB

D~[..DC ..BA] A~[1... .... .... ....]
     ||   ||
     ||   ++- CHR A14..A13 (8 KiB bank)
     |+------ Output to Diode 2 (D2)
     +------- Output to Diode 1 (D1)

The original CNROM board is always subject to AND-type bus conflicts: the effective value is the value being written bitwise-AND'd with the PRG-ROM content at the address being written to. iNES Mapper 3's submapper indicates whether bus conflicts should actually be emulated. So far, the only .NES files requiring the absence of bus conflicts have been mapper hacks to mapper 3 from other mappers.

Oversize mapper 3 with up to 128 KiB

D~[.... DCBA] A~[1... .... .... ....]
        ||||
        ++++- CHR A16..A13 (8 KiB bank)

Among the licensed NES/Famicom library, this configuration is only used by Bandai's Family Trainer: Jogging Race. Several unlicensed cartridges mount 64 KiB of CHR-ROM; although they work as oversize mapper 3 as well, they are canonically assigned to INES Mapper 148 instead.

Mapper 185

D~[..DC ..BA] A~[1... .... .... ....]
     ||   ||
     ||   |+- Chip Select 2 (CS2)
     ||   +-- Chip Select 1 (CS1)      
     |+------ Output to Diode 2 (D2)
     +------- Output to Diode 1 (D1)

Mapper 185 always has AND-type bus conflicts. The submapper number denotes the correct Chip Select value that enables CHR-ROM; if another value is active, CHR-ROM is disabled, meaning that reading from the pattern tables returns open bus. Theoretically, this should return the LSB of the address read, but real-world behavior varies, and the earlier revision of Mighty Bomb Jack in fact relies on open bus at PPU address $0000 being something other than $00. If the correct Chip Select value is not known -- denoted by submapper 0, which applies to all .NES files without a NES 2.0 header, the simple heuristic "Disable CHR-ROM for the first two reads $2007 after a reset and then enable it" will work with all known games.

bank PPU addr test bank PPU addr test
Game Incorrect bank Must work
Bird Week $F0 $1FF0 ≠ $0C $0F $1FF0 = $0C
B-Wings $00 $0000 ≠ $3C $33 $0000 = $3C
Mighty Bomb Jack (J, PRG0) $00 $0000 ≠ $00 $11 untested
Mighty Bomb Jack (J, PRG1) $00 $0001 ≠ $3C $11 untested
Sansuu 1 Nen $20 $000C ≠ $BC $22 $000C = $BC
Sansuu 2 Nen $20 $0003 ≠ $42 $22 $0003 = $42
Othello $20 $0006 ≠ $3F $22 $0006 = $3F
Sansuu 3 Nen $00 $0006 ≠ $34 $2A $0006 = $34
Spy vs Spy $13 $1F20 ≠ $55 $21 untested
Seicross $21 $0700…$0707 ≠ $20,$60,$70,$70,$70,$40,$08,$38 $20 untested

The North American and PAL versions of Mighty Bomb Jack mount 32 KiB of CHR-ROM instead and so use normal mapper 3.

Speech Start/Message Select: responds to writes to CPU $6000-$7FFF

D~[.D.. .CBA] A~[011. .... .... ....]
    |    +++- Message number (0-7)
    +-------- M5085 /SYNC signal

A falling edge of the D bit starts the selected speech line. This register only exists on the PCB of Family Trainer: Aerobics Studio.

Hardware

The 4-bit latch register is implemented using a 74HC161 binary counter. On iNES Mapper 3, the latch's A and B outputs directly connect to the CHR-ROM chip's A14 and A13 inputs. On iNES Mapper 185, the particular ROM chip model (Sharp LH2367 or equivalent) changes the functionality of pins 26 (normally A13) and 27 (normally A14) into two programmable (during manufacturing) Chip Select inputs, effectively disabling CHR-ROM and tri-stating its data outputs when the one correct bank of four possible CHR-ROM banks is not selected, as a copy-protection mechanism.

Security diodes

As another copy protection mechanism, the CNROM circuit board has a spot for two diodes that produce additional bus conflicts to hinder cartridge dumping attempts. Diode 1 connects latch bit 'D' to CHR-ROM A10; Diode 2 connects latch bit 'C' to CHR-ROM A12. Each latch bit must be set such that the diode does not allow current to flow, because if it does, AND-type bus conflicts occur that may cause the wrong CHR-ROM A10 and A12 signals to be applied, depending on the relative output resistances of latch chip and console or dumping device. Both the NES PPU and modern Kazzo-like dumping devices have strong enough output drivers to always win these bus conflicts, but 1980s' dumping equipment will lose these bus conflicts and produce an unusable readout. Each diode can be mounted either with the anode or the cathode facing the latch output. As a diode will allow current to flow if the anode-side voltage is significantly higher than the cathode-side voltage, the latch bit must be 0 if it faces the anode, and 1 if it faces the cathode. The security diodes were mounted by most Nintendo-manufactured Japanese CNROM games manufactured in 1986 as well as Bandai-manufactured CNROM games from 1986 and 1987. They were never used on North American or PAL CNROM games, even as the NES-CNROM board has an unpopulated spot for them until at least revision -02. Emulators need not emulate the functionality of security diodes to run games correctly.

Solder Pad Configuration

  • Horizontal nametable arrangement ("vertical mirroring"): 'H' connected, 'V' disconnected.
  • Vertical nametable arrangement ("horizontal mirroring"): 'H' disconnected, 'V' connected.
  • 16 KB PRG-ROM: 'SL' connected, 'CL' disconnected.
  • 32 KB PRG-ROM: 'SL' disconnected, 'CL' connected.

Hayauchi Super Igo is a CNROM-like board with a 2KB SRAM mapped at $6000, using a 74HC10 as the address decoder.

Theoretically the bank select register could be implemented with a 74HC377 octal D latch, allowing up to 2 megabytes of CHR ROM.