Introduction

Because the Z80 CPU only has a 64KB address space, and only 48KB of this is mapped to the cartridge on the Master System and Game Gear, "mappers" are used to allow the use of larger ROMs, as well as on-cartridge RAM. Smaller games (typically 32KB for released software) do not need a mapper.

The terminology can be confusing. In this document the word "paging", which usually means the same as "mapping", is not used. "Mapping", of course, refers to the act of presenting some range of a chip's address space at some, usually mismatching, range of the Z80's address space. "Mapper" refers to the hardware that performs mapping. "Slot" refers to an area of the Z80 address space into which various areas of ROM or RAM can be mapped. "Bank" refers to the area of ROM or RAM thus mapped.

The Sega mapper

There are several revisions of the Sega mapper, which was sometimes produced as a discrete chip but integrated into the ROM chip in most cases. It defines four 16KB slots in the memory map. Any 16KB bank of ROM may be mapped into any of the first three slots; additionally, up to two 16KB RAM banks can be mapped into the last two slots. The mapper hardware is controlled by writes to memory addresses $fffc-$ffff.

This is the mapper used in 99% of software, and is assumed to be there (for games larger than 48KB) by the BIOS.

The only difference between revisions is that unused functionality is removed from some of them, for example some versions only support ROM banking in slot 2 and some only support 128KB ROMs. Emulating a "full" mapper in all cases does not cause any problems.

Information about certain mapper chips can be found on the SMS Paging Chips page.

Registers

Address $fffc: RAM mapping and miscellaneous functions

BitFunction
7"ROM write" enable
6-5Unused
4RAM enable ($c000-$ffff)
3RAM enable ($8000-$bfff)
2RAM bank select
1-0Bank shift

Addresses $fffd-$ffff: ROM mapping

Control registerROM bank select for slot
$fffd0 ($0000-$3fff)
$fffe1 ($4000-$7fff)
$ffff2 ($8000-$bfff)

The registers are thought to be undefined after a reset for games using the 831001 and 832011 ROMs and 315-5208 mapper. The 315-5235 mapper is reset to FFFC=00, FFFD=00, FFFE=01, FFFF=02 after a power-up reset.

ROM mapping

The ROM may be considered as an array of 16KB banks. The 8-bit value written to a ROM mapping control register from $fffd to $ffff selects which of these is mapped to the relevant slot.

Depending on the mapper revision, the number of significant bits in the bank selection register may vary - for example, some revisions have 3 significant bits (supporting 8 banks, 128KB total size), others have 5 (512KB), with the largest known supporting 6 bits (1MB). Some software may also set higher-order bits than those that are relevant to its ROM size. Provided the ROM is a power-of-two size, these issues do not cause problems, because ROM mirroring will nullify the effect.

When mapping in slot 0, the first 1KB is unaffected, in order to preserve the interrupt vectors. The remaining 15KB is mapped with the last 15KB of the relevant bank.

Most games only use slot 2; very few use slot 0.

Because the control registers overlap in the memory map with a RAM mirror, this mirrored RAM allows the last value written to each register to be read back (from the RAM copy). The registers are, however, strictly write-only. Overwriting the RAM mirror at another address will not affect mapping.

Note also the bank shifting feature described below.

RAM mapping

The control register at $fffc enables mapping of on-cartridge RAM to the address space used by the in-console RAM ($c000-$ffff) or to slot 2 (region $8000-$bfff).

When bit 3 is 1, RAM will be mapped into slot 2, overriding any ROM banking via the control register at $ffff. When 0, ROM banking is effective.

When bit 4 is 1, RAM will be mapped into the address range used by the (mirrored) on-board RAM. To avoid bus contention, this should therefore be disabled using port $3E. No known software uses this feature.

The bank select bit chooses between the first 16KB bank of SRAM (0) and the second (1), but only for slot 2. Thus, if the register were set to %---111--, 32KB of cartridge RAM would be exposed to the Z80 address bus between $8000 and $ffff (with the second 16KB mapped as the first and vice versa).

It is worth noting that most games with on-cartridge RAM have less than 32KB; most seem to have just 8KB, which is mirrored to fill both 16KB slots.

ROM bank shifting

Bits 1-0 of the control register at $fffc define a shift value that is added to any bank number written to $fffd-f:

Bit 1Bit 0ShiftBanks $00-$1F map to
00$00$00-$07, $08-$0F, $10-$17, $18-$1F
01$18$18-$1F, $00-$07, $08-$0F, $10-$17
10$10$10-$17, $18-$1F, $00-$07, $08-$0F
11$08$08-$0F, $10-$17, $18-$1F, $00-$07

If only these bits are changed, there is no effect until one of the registers at $fffd-f is written to, at which point all three will have the shift applied. The $0000-$03ff region remains unmapped as before. No known software uses this feature. Because it is only featured on one type of 512KB mapper chip, its behaviour with other ROM sizes is undefined.

"ROM Write" enable

Bit 7 of the control register at $fffc controls write protection for the "ROM" (which may be emulated using RAM in development hardware). Setting this bit to 0 write protects it. This feature is not known to be used by any software.

The Codemasters mapper

ROM mapping

This mapper presents three 16KB slots to the address bus as before. However, the control registers are mapped to all 16KB of each bank and the first 1KB is no longer protected. (Codemasters games write to the lowest address in each bank.)

Control registervalid mirror addressesSlot
$0000$0001-$3FFF0 ($0000-$3fff)
$4000$4001-$7FFF1 ($4000-$7fff)
$8000$8001-$BFFF2 ($8000-$bfff)

The mapper is initialised with banks 0, 1 and 0 in slots 0, 1 and 2 respectively.

When using slot 0, care must be taken to replace interrupt vectors appropriately. Also note that there is no RAM mirroring of mapper writes so there is no way to retrieve the last value written.

Most games seem to only use slot 2.

Due to the similarities with the Sega mapper, it is generally possible to patch Codemasters software to work with a Sega mapper.

RAM mapping

One Codemasters game, Ernie Els Golf, features 8KB of on-cart RAM. If the byte written to $4000 has the high bit set ($80) then the upper 8KB of slot 2 (from $a000 to $c000) is mapped to this on-cart RAM, while the lower 8KB will remain mapped to ROM as if the high bit were unset.

"Korean" mapper

Some Korean original software (eg. Run! Dodgeball King) uses an alternative mapper system which is a further simplification of the above. Slots 0 and 1 are fixed to banks 0 and 1 of ROM respectively, while the bank mapped to slot 2 is selected by a byte written to address $a000.

Control registerSlot
Fixed0 ($0000-$3fff)
Fixed1 ($4000-$7fff)
$a0002 ($8000-$bfff)

MSX and Nemesis mappers

Addresses $0000-$0003: 8K ROM bank mapping

Control registerROM bank select for slot
Fixed($0000-$3fff)
$00002 ($8000-$9fff)
$00013 ($a000-$bfff)
$00020 ($4000-$5fff)
$00031 ($6000-$7fff)

With the MSX mapper, the first 16K of ROM is fixed at $0000-$3fff. With the Nemesis mapper, the last 8K bank is fixed at $0000-$1fff, and the second 8K bank is fixed at $2000-$3fff.

Many Korean ports of MSX games were done using this mapper. Nemesis is the only known game that uses the Nemesis variant.

To clarify: the Nemesis mapper has the same behaviour as the MSX mapper, except that the first 8K of address space ($0000-$1fff) will always map to the final 8K page of ROM ($1e000:$1ffff)

Janggun Mapper

Control registerROM bank select for slotSize
Fixed($0000-$3fff)16K
$4000($4000-$5fff)8K
$6000($6000-$7fff)8K
$8000($8000-$9fff)8K
$a000($a000-$bfff)8K
$fffe($4000-$7fff)16K
$ffff($8000-$bfff)16K

Writes pass a value with the 0th to 5th bits representing the 8K bank to be selected, and a 1 bit value representing whether the bank data should be reversed on read. Slots 0 and 1, or slots 2 and 3 can be selected as 16K banks by writes to 0xfffe and 0xffff respectively. When writes to these addresses occur, flags are set based on the value of the 6th bit of the data being written. If the 6th bit is set to 1, the data read from these banks will be reversed (11000000 becomes 00000011). Additionally, writes to these addresses will be written to system RAM.

This mapper is used for Janggun-ui Adeul (Korea).




Return to top
0.041s