Sega Master System / Mark III / Game Gear
The Master System and later hardware supports multiple media - the card and cartridge - as well as featuring an expansion port and a BIOS. All of these are executed from the same space - the memory region $0000-$BFFF. Obviously there has to be some arbitration method to allow them to share this space without problems. This is done by hardware controlling various other sections' ENABLE control lines; this functionality is accessed via port $3E.
Earlier systems (the Mark III and earlier) either only had one media slot, or used a hardware method to activate only one slot: the cartridge provides a bridge between VCC and a line connected to the card's OE line, thereby disabling the card if both are connected simultaneously. (This precedence was reversed in BIOS-using systems.)
|Bit||Function||No effect on|
|7||Expansion slot enable||SMS2, GG, Genesis|
|6||Cartridge slot enable||GG, Genesis|
|5||Card slot enable||SMS2, GG, Genesis|
|3||BIOS ROM enable||Genesis|
|2||I/O enable||GG, Genesis|
All bits are active low: writing a value of
1 disables the
corresponding functionality, writing
0 enables it.
The BIOS runs code from RAM which disables the BIOS ROM and enables the three other slots in turn (card, cartridge, expansion). It then performs detection routines and runs the code from the first slot with valid data.
The YM2413 hardware is mapped such that it conflicts with the I/O hardware's mapping in the Z80's I/O port map. The YM2413 subsystem includes hardware to automatically disable the I/O hardware when appropriate; but when detecting the YM2413 hardware, it is necessary to disable I/O via port $3E to avoid false detection.
When enabled, the GG BIOS maps to $0000-$03FF; the rest of the lower 48KB maps to the cartridge as normal. When disabled, the first 1KB of the cartridge fills that space.