openMSX
MSXMemoryMapper.hh
Go to the documentation of this file.
1 #ifndef MSXMEMORYMAPPER_HH
2 #define MSXMEMORYMAPPER_HH
3 
4 #include "MSXDevice.hh"
5 #include "MSXMapperIO.hh"
6 #include "CheckedRam.hh"
7 #include "SimpleDebuggable.hh"
8 
9 namespace openmsx {
10 
12 {
13 public:
14  explicit MSXMemoryMapper(const DeviceConfig& config);
15  virtual ~MSXMemoryMapper() override;
16 
21  byte getSelectedSegment(byte page) const override { return registers[page]; }
22 
23  unsigned getSizeInBlocks() { return checkedRam.getSize() / 0x4000; }
24 
25  void reset(EmuTime::param time) override;
26  void powerUp(EmuTime::param time) override;
27  byte readIO(word port, EmuTime::param time) override;
28  byte peekIO(word port, EmuTime::param time) const override;
29  void writeIO(word port, byte value, EmuTime::param time) override;
30  byte readMem(word address, EmuTime::param time) override;
31  void writeMem(word address, byte value, EmuTime::param time) override;
32  const byte* getReadCacheLine(word start) const override;
33  byte* getWriteCacheLine(word start) const override;
34  byte peekMem(word address, EmuTime::param time) const override;
35 
36  template<typename Archive>
37  void serialize(Archive& ar, unsigned version);
38 
39 protected:
44  unsigned calcAddress(word address) const;
45 
48 
49 private:
50  unsigned getRamSize() const;
51 
52  struct Debuggable final : SimpleDebuggable {
53  Debuggable(MSXMotherBoard& motherBoard, const std::string& name);
54  byte read(unsigned address) override;
55  void write(unsigned address, byte value) override;
56  } debuggable;
57 };
59 
61 
62 } // namespace openmsx
63 
64 #endif
void powerUp(EmuTime::param time) override
This method is called when MSX is powered up.
MSXMemoryMapper(const DeviceConfig &config)
REGISTER_BASE_NAME_HELPER(MSXFDC, "FDC")
uint8_t byte
8 bit unsigned integer
Definition: openmsx.hh:26
unsigned getSize() const
Definition: CheckedRam.hh:41
byte readMem(word address, EmuTime::param time) override
Read a byte from a location at a certain time from this device.
void writeIO(word port, byte value, EmuTime::param time) override
Write a byte to a given IO port at a certain time to this device.
void reset(EmuTime::param time) override
This method is called on reset.
const byte * getReadCacheLine(word start) const override
Test that the memory in the interval [start, start + CacheLine::SIZE) is cacheable for reading...
This class keeps track of which bytes in the Ram have been written to.
Definition: CheckedRam.hh:27
virtual ~MSXMemoryMapper() override
SERIALIZE_CLASS_VERSION(CassettePlayer, 2)
Thanks to enen for testing this on a real cartridge:
Definition: Autofire.cc:5
An MSXDevice is an emulated hardware component connected to the bus of the emulated MSX...
Definition: MSXDevice.hh:31
uint16_t word
16 bit unsigned integer
Definition: openmsx.hh:29
byte getSelectedSegment(byte page) const override
Returns the currently selected segment for the given page.
byte * getWriteCacheLine(word start) const override
Test that the memory in the interval [start, start + CacheLine::SIZE) is cacheable for writing...
void serialize(Archive &ar, unsigned version)
byte peekIO(word port, EmuTime::param time) const override
Read a byte from a given IO port.
byte readIO(word port, EmuTime::param time) override
Read a byte from an IO port at a certain time from this device.
void writeMem(word address, byte value, EmuTime::param time) override
Write a given byte to a given location at a certain time to this device.
byte peekMem(word address, EmuTime::param time) const override
Read a byte from a given memory location.
unsigned calcAddress(word address) const
Converts a Z80 address to a RAM address.