Class Mapper

Inheritance Relationships

Derived Types

Class Documentation

class Mapper

“Mapper” base class.

Mapper is a name for cartridge boards. Cartridges provided not only the data (program and graphic) but a lot of them also allowed to extend the features of the console. The main ability was bank-switching, which switched data blocks (“mapped” them - that’s the origin of the name) and effectively allowed developers to create bigger games.

There is a lot of mappers, this class is only a unified interface. A mapper can provide additional storage (e.g. RAM) and functions, but of course needs access to standard data blocks (PRG and CHR). This is emulated by a pointer to the Gamepak class.

This class only provides CIRAM. CIRAM is originally located in the PPU and provides a kind of built-in VRAM. Mapper can choose to: a) use CIRAM with fixed mirroring mode (the mode is specified in the header of ROM dump), b) use CIRAM and handle mirroring mode change itself (the mode in ROM dump is then ignored), c) not use CIRAM and handle VRAM itself altogether.

Note

Mapper is not a standalone component. It is meant to be used with the Gamepak component.

Subclassed by Mapper000, Mapper001

Public Types

enum class mirroringType_t

Type of CIRAM mirroring.

Values:

enumerator HORIZONTAL
enumerator VERTICAL
enumerator FOURSCREEN
enumerator SINGLE_LO
enumerator SINGLE_HI

Public Functions

Mapper() = default
virtual ~Mapper() = default
virtual void init()

Initialize mapper to the power-up state = clean all volatile memories.

virtual bool cpuRead(uint16_t addr, uint8_t &data) = 0

CPU read interface.

Parameters
  • addr – Address to read from.

  • data – Buffer to write to.

Returns

true If anything was read

virtual bool cpuWrite(uint16_t addr, uint8_t data) = 0

CPU write interface.

Parameters
  • addr – Address to write to.

  • data – Data to write.

Returns

true If anything was written.

virtual bool ppuRead(uint16_t addr, uint8_t &data) = 0

PPU read interface.

Parameters
  • addr – Address to read from.

  • data – Buffer to write to.

Returns

true If anything was read.

virtual bool ppuWrite(uint16_t addr, uint8_t data) = 0

PPU write interface.

Parameters
  • addr – Address to write to.

  • data – Data to write.

Returns

true If anything was written.

virtual void drawGUI() = 0

Draw a debugging GUI.

Protected Functions

virtual void CIRAMWrite(uint16_t address, uint8_t data)

Write to CIRAM if used.

Parameters
  • address – Address to write to.

  • data – Data to write.

virtual uint8_t CIRAMRead(uint16_t address)

Read from CIRAM if used.

Parameters

address – Address to read from.

Returns

Read data.

Protected Attributes

mirroringType_t m_mirroringType = mirroringType_t::HORIZONTAL
std::array<uint8_t, 0x800> m_CIRAM = {0x00}

PPU’s built-in video memory (VRAM/CIRAM) emulation.