openMSX
MSXMegaRam.hh
Go to the documentation of this file.
1 #ifndef MSXMEGARAM_HH
2 #define MSXMEGARAM_HH
3 
4 #include "MSXDevice.hh"
5 #include "Ram.hh"
6 #include "RomBlockDebuggable.hh"
7 #include <memory>
8 
9 namespace openmsx {
10 
11 class Rom;
12 
13 class MSXMegaRam final : public MSXDevice
14 {
15 public:
16  explicit MSXMegaRam(const DeviceConfig& config);
17  ~MSXMegaRam() override;
18 
19  void powerUp(EmuTime::param time) override;
20  void reset(EmuTime::param time) override;
21  [[nodiscard]] byte readMem(word address, EmuTime::param time) override;
22  [[nodiscard]] const byte* getReadCacheLine(word address) const override;
23  void writeMem(word address, byte value,
24  EmuTime::param time) override;
25  [[nodiscard]] byte* getWriteCacheLine(word address) const override;
26 
27  [[nodiscard]] byte readIO(word port, EmuTime::param time) override;
28  [[nodiscard]] byte peekIO(word port, EmuTime::param time) const override;
29  void writeIO(word port, byte value, EmuTime::param time) override;
30 
31  template<typename Archive>
32  void serialize(Archive& ar, unsigned version);
33 
34 private:
35  void setBank(byte page, byte block);
36 
37 private:
38  const unsigned numBlocks; // must come before ram
39  Ram ram;
40  const std::unique_ptr<Rom> rom; // can be nullptr
41  RomBlockDebuggable romBlockDebug;
42  const byte maskBlocks;
43  byte bank[4];
44  bool writeMode;
45  bool romMode;
46 };
47 
48 } // namespace openmsx
49 
50 #endif
An MSXDevice is an emulated hardware component connected to the bus of the emulated MSX.
Definition: MSXDevice.hh:32
void reset(EmuTime::param time) override
This method is called on reset.
Definition: MSXMegaRam.cc:59
void powerUp(EmuTime::param time) override
This method is called when MSX is powered up.
Definition: MSXMegaRam.cc:49
byte readMem(word address, EmuTime::param time) override
Read a byte from a location at a certain time from this device.
Definition: MSXMegaRam.cc:65
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.
Definition: MSXMegaRam.cc:84
~MSXMegaRam() override
byte * getWriteCacheLine(word address) const override
Test that the memory in the interval [start, start + CacheLine::SIZE) is cacheable for writing.
Definition: MSXMegaRam.cc:94
byte readIO(word port, EmuTime::param time) override
Read a byte from an IO port at a certain time from this device.
Definition: MSXMegaRam.cc:107
void serialize(Archive &ar, unsigned version)
Definition: MSXMegaRam.cc:152
byte peekIO(word port, EmuTime::param time) const override
Read a byte from a given IO port.
Definition: MSXMegaRam.cc:123
MSXMegaRam(const DeviceConfig &config)
Definition: MSXMegaRam.cc:34
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.
Definition: MSXMegaRam.cc:128
const byte * getReadCacheLine(word address) const override
Test that the memory in the interval [start, start + CacheLine::SIZE) is cacheable for reading.
Definition: MSXMegaRam.cc:70
This file implemented 3 utility functions:
Definition: Autofire.cc:5
uint16_t word
16 bit unsigned integer
Definition: openmsx.hh:29