Skip to content

Commit e689270

Browse files
ISSOtmavivace
andauthored
Fix misc. formatting in "Other MBCs" chapter (#354)
* Fix misc. formatting in "Other MBCs" chapter * Apply requested PR changes * Apply suggestions and restructure the magic values chapter Co-authored-by: Antonio Vivace <[email protected]>
1 parent cc743a5 commit e689270

File tree

1 file changed

+62
-57
lines changed

1 file changed

+62
-57
lines changed

src/othermbc.md

Lines changed: 62 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -9,29 +9,27 @@ four games is switched in. In theory, a MBC1M board could be made for 1
99
Mbit or 512 kbit games by additionally not connecting A17 and A16
1010
outputs, but this appears not to have been done in licensed games.
1111

12-
**MMM01** is a more complex that allows for games of different sizes.
13-
[Docs on Tauwasser.eu](https://wiki.tauwasser.eu/view/MMM01)
14-
1512
**Bung** and **EMS** MBCs are reported to exist.
1613

1714
### EMS
1815

19-
PinoBatch learned the game selection protocol for EMS flash carts from
20-
beware, who in turn learned it from nitro2k01. Take this with a grain of
21-
salt, as it hasn't been verified on the authentic EMS hardware.
16+
::: warning To be verified
17+
18+
Take the following with a grain of salt, as it hasn't been verified on authentic EMS hardware.
19+
20+
:::
2221

23-
A [header](<#The Cartridge Header>) matching any of the
24-
following is detected as EMS mapper:
22+
A [header](<#The Cartridge Header>) matching any of the following is detected as EMS mapper:
2523

26-
- Header name is "EMSMENU", NUL-padded
27-
- Header name is "GB16M", NUL-padded
28-
- Cartridge type ($0147) = $1B and region ($014A) = $E1
24+
- Header name is "EMSMENU", NUL-padded
25+
- Header name is "GB16M", NUL-padded
26+
- Cartridge type ($0147) = $1B and region ($014A) = $E1
2927

3028
Registers:
3129

32-
$2000 write: Normal behavior, plus save written value in $2000 latch
33-
$1000 write: $A5 enables configure mode, $98 disables, and other values have no known effect
34-
$7000 write while configure mode is on: Copy $2000 latch to OR mask
30+
- $2000 write: Normal behavior, plus save written value in $2000 latch
31+
- $1000 write: $A5 enables configure mode, $98 disables it, and other values have no known effect
32+
- $7000 write while configure mode is on: Copy $2000 latch to OR mask
3533

3634
After the OR mask has been set, all reads from ROM will OR A21-A14 (the
3735
bank number) with the OR mask. This chooses which game is visible to the
@@ -40,70 +38,77 @@ nonsensical.
4038

4139
The mapper does not support an outer bank for battery SRAM.
4240

43-
To start a game, do the following in code run from RAM: Write $A5 to
44-
$1000, write game starting bank number to $2000, write any value to
45-
$7000, write $98 to $1000, write $01 to $2000 (so that 32K games
46-
work), jump to $0100.
41+
To start a game, perform the following steps with code running from RAM:
42+
43+
1. Write $A5 to $1000
44+
2. Write game's first bank number to $2000
45+
3. Write any value to $7000
46+
4. Write $98 to $1000
47+
5. Write $01 to $2000 (so that 32K games work)
48+
6. Jump to $0100
4749

4850
## Wisdom Tree
4951

50-
The Wisdom Tree mapper is a simple, cost-optimized one chip design
51-
consisting of a 74LS377 octal latch, aside from the ROM chip. Because
52+
The Wisdom Tree mapper is a simple, cost-optimized one-chip design
53+
consisting of a 74LS377 octal latch in addition to the ROM chip. Because
5254
the mapper consists of a single standard 74 series logic chip, it has
5355
two unusual properties:
5456

55-
First, unlike a usual MBC, it switches the whole 32 kiB ROM area instead
56-
of just the $4000-$7FFF area. If you want to use the interrupt vectors
57+
First, unlike a usual MBC, it switches the whole 32 KiB ROM area instead
58+
of just the $4000-$7FFF area. Therefore, if you want to use [the interrupt vectors](<#Interrupt Handling>)
5759
with this cart, you should duplicate them across all banks.
58-
Additionally, since the initial state of the '377 can't be guaranteed,
60+
Additionally, since the 74LS377's contents can't be guaranteed when powering on,
5961
the ROM header and some code for switching to a known bank should also
6062
be included in every bank. This also means that the Wisdom Tree mapper
61-
could be used as a multicart mapper for 32 kiB ROMs, assuming there was
63+
could be used as a multicart mapper for 32 KiB ROMs, assuming there is
6264
enough ROM space in each bank for some small initialization code, and
6365
none of the ROMs wrote to the $0000-$7FFF area. For example, if the
6466
last 5 bytes of all banks are unused, games can be patched as follows:
6567

66-
; At $0100 in all banks but the first
67-
nop
68-
jp $7FFB
69-
70-
; At $7FFB in all banks
71-
ld hl, $0100
72-
ld [hl], a
73-
jp hl
74-
75-
Second, because the '377 latches data on the *positive* edge, and the
76-
value on the Game Boy data bus is no longer valid when the positive edge
77-
of the write pulse arrives, the designer of this mapper chose to use the
68+
```rgbasm
69+
; At $0100 in all banks but the first
70+
nop
71+
jp $7FFB
72+
```
73+
```rgbasm
74+
; At $7FFB in all banks
75+
ld hl, $0100
76+
ld [hl], a
77+
jp hl
78+
```
79+
80+
Second, because the 74LS377 latches data on the [*positive* write pulse edge](https://www.allaboutcircuits.com/textbook/digital/chpt-10/edge-triggered-latches-flip-flops/),
81+
and the value on the Game Boy data bus is no longer valid when the
82+
positive edge arrives, the designer of this mapper chose to use the
7883
A7-A0 address lines for selecting a bank instead of the data lines.
7984
Thus, the value you write is ignored, and the lower 8 bits of the
8085
address is used. For example, to select bank $XX, you would write any
8186
value to address $YYXX, where $YY is in the range $00-$7F.
8287

83-
An emulator can detect a ROM designed for Wisdom Tree mapper in one of
84-
two ways:
8588

86-
- ROM contains "WISDOM TREE" or "WISDOM\\x00TREE" (the space can
87-
be $20 or $00), $0147 = $00, $0148 = $00, size \> 32k. This
88-
method works for the games released by Wisdom Tree, Inc.
89-
- $0147 = $C0, $014A = $D1. These are the values recommended by
90-
beware for 3rd party developers to indicate that the ROM is
91-
targeting Wisdom Tree mapper hardware. (See below.)
9289

9390
## Magic values for detection of multicarts in emulators
9491

92+
::: info proposal
93+
94+
The following information should not be considered a universally adopted
95+
standard, but it's instead just a proposed solution. Actual adoption may vary.
96+
97+
:::
98+
9599
Sometimes it may be useful to allow a ROM to be detected as a multicart
96100
in emulator, for example for development of a menu for physical
97-
multicart hardware. These are values suggested by beware, and supported
98-
in BGB, for signaling that your ROM is supposed to interface a multicart
99-
mapper. Emulator authors who are interested in supporting multicart
100-
mappers are encouraged to support detection of these values in addition
101-
to the values described in each section, which are heuristics based on
102-
ROMs in the wild, which may not always be suitable for newly produced
103-
software. The values are deliberately chosen to be high entropy
104-
("random") such that the risk of an accidental false positive is
105-
unlikely.
106-
107-
- $0147 = $c0, $014a = $d1 -\> Detect as Wisdom Tree
108-
- $0147 = $1b, $014a = $e1 -\> Detect as EMS multicart
109-
- $0147 = $be -\> Detect as Bung multicart
101+
multicart hardware.
102+
103+
Emulator authors who are interested in supporting the other multicart
104+
mappers are also encouraged to support detection of the following values.
105+
106+
- Wisdom Tree mapper
107+
- [ROM title](<#0134-0143 - Title>) is "WISDOM TREE" (the space may be a
108+
$00 NUL character instead), $0147 = $00, $0148 = $00, size \> 32k.
109+
This method works for the games released by Wisdom Tree, Inc.
110+
- $0147 = $C0, $014A = $D1.
111+
- Detect as EMS multicart
112+
- $0147 = $1b, $014a = $e1
113+
- Detect as Bung multicart
114+
- $0147 = $be

0 commit comments

Comments
 (0)