initial fce ultra 0.81 import
[fceu.git] / Documentation / tech / exp / mmc5_bank_switch.txt
CommitLineData
c62d2810 1MMC5 Bankswitching
2by Kevin Horton
3--------------------
4
55100: Controls paging of RAM and ROM
6
7Bits: ???? ??xx
8
9For xx:
10
1100: 32K bankswitching. Only 5117 can be used to control banks. 5114 thru
12 5116 have no effect.
13
14
1501: 16K bankswitching. Only 5115 and 5117 can be used to control banks.
16 5114 and 5116 have no effect.
17
18
1910: 8K/16K bankswitching. 5115-5117 are used. 5114 has no effect.
20
2111: 8K bankswitching. 5114-5117 are used.
22
23(See below for detailed description)
24
25--
26
275113: RAM page 6000-7FFF bank. Lower 3 bits are used, for a possible
28 64K of WRAM. (Note more bits *may* be possible for more RAM.
29 This has not been confirmed yet).
30
31Bits: ???? ?xxx
32
33WRAM follows a certain convention, based on the style of MMC5 board used.
348K and 32K carts are usually implemented with a single chip, while 16K
35carts use two 8K'ers. This is important since enabling changes, and hence
36valid banks.
37
38for xxx:
39
40 8K 16K 32K 40K 64K
41
420: bank 0 bank 0 bank 0 bank 0 bank 0
431: bank 0 bank 0 bank 1 bank 1 bank 1
442: bank 0 bank 0 bank 2 bank 2 bank 2
453: bank 0 bank 0 bank 3 bank 3 bank 3
464: open bus bank 1 open bus bank 4 bank 4
475: open bus bank 1 open bus bank 4 bank 5
486: open bus bank 1 open bus bank 4 bank 6
497: open bus bank 1 open bus bank 4 bank 7
50
51Note that the 40K and 64K examples are hypothetical. The first three,
52however *are* real and is what you find inside a real MMC5 cart.
53
54Also note, that 5114-5116 follow this identical convention, if set up
55to switch in RAM banks.
56
57--
58
59Bankswitching is a bit complicated. This table should make things clearer.
60The numbers at the top are what you write to 5100 to select mode.
61
62Legend:
63
64- = this has no effect
65--- = this register is not used, and writes to it are ignored
66R = PRG ROM/WRAM select. 0=WRAM, 1=PRG ROM
67b = bank bits
68
69
70
715100: 00 01 10 11
72
735114 --- --- --- Rbbb bbbb
745115 --- Rbbb bbb- Rbbb bbb- Rbbb bbbb
755116 --- --- Rbbb bbbb Rbbb bbbb
765117 -bbb bb-- -bbb bbb- -bbb bbbb -bbb bbbb
77
78
79Mode 00
80-------
81
82Only one 32K page can be selected. The lower 2 bits of the desired bank
83are ANDed out. writing 084h, 085h, 086h, and 087h to 5117 in this mode
84all result in selection of the same 32K. No RAM is available in this mode.
85
86Mode 01
87-------
88
89There are two selectable 16K pages. Similar to above, the lowest bit written
90is not used to select banks. In this mode, writing to 5115 selects 16K
91at 8000-BFFF, and 5117 selects 16K at C000-FFFF. RAM can be enabled in this
92mode for 8000-BFFF. If RAM is enabled for 8000-BFFF, remember that the
93lowest bank select bit is not used.
94
95Mode 10
96-------
97
98This is the oddest one. There is one 16K selectable page, and two 8K
99selectable pages. 5115 selects the 16K page at 8000-BFFF, 5116 selects
100an 8K page at C000-DFFF, and 5117 selects an 8K page at E000-FFFF.
101RAM can be enabled for 8000-DFFF. (16K of RAM at 8000-BFFF via bit 7 of
102D115, and 8K of RAM at C000-DFFF via bit 7 of d116). Note that RAM banking
103works the same as mode 01, above for the 16K bank.
104
105
106Mode 11
107-------
108
109There are 4 8K selectable pages. 5114 controls 8000-9FFF, etc. all the way
110up to 5117 that controls E000-FFFF. The first 3 pages can use RAM, while
111the last page cannot.
112
113
114--
115
116WRAM write enable.
117
1185102, 5103
119
120To enable writing to RAM, 5102 must have 02h written to it, and 5103
121must have 01h written to it. If this is not the case, you can still
122*read* the RAM, but writes to it have no effect. Supposidly only the
123lower two bits of 5102 and 5103 are checked, but I didn't verify this.
124I *did* however verify that setting the two registers to the above
125values allows writing. If voltage goes out of tolerance (Read: you
126turn the power on/off) the RAM writing is disabled. (To prevent
127corruption of saved-games during power cycling)
128