openMSX
Ram.hh
Go to the documentation of this file.
1 #ifndef RAM_HH
2 #define RAM_HH
3 
4 #include "MemBuffer.hh"
5 #include "openmsx.hh"
6 #include <string>
7 #include <memory>
8 
9 namespace openmsx {
10 
11 class XMLElement;
12 class DeviceConfig;
13 class RamDebuggable;
14 
15 class Ram
16 {
17 public:
19  Ram(const DeviceConfig& config, const std::string& name,
20  const std::string& description, unsigned size);
21 
23  Ram(const XMLElement& xml, unsigned size);
24 
25  ~Ram();
26 
27  const byte& operator[](unsigned addr) const {
28  return ram[addr];
29  }
30  byte& operator[](unsigned addr) {
31  return ram[addr];
32  }
33  unsigned getSize() const {
34  return size;
35  }
36 
37  const std::string& getName() const;
38  void clear(byte c = 0xff);
39 
40  template<typename Archive>
41  void serialize(Archive& ar, unsigned version);
42 
43 private:
44  const XMLElement& xml;
45  MemBuffer<byte> ram;
46  unsigned size; // must come before debuggable
47  const std::unique_ptr<RamDebuggable> debuggable; // can be nullptr
48 };
49 
50 } // namespace openmsx
51 
52 #endif
const std::string & getName() const
Definition: Ram.cc:95
uint8_t byte
8 bit unsigned integer
Definition: openmsx.hh:26
void clear(byte c=0xff)
Definition: Ram.cc:51
Thanks to enen for testing this on a real cartridge:
Definition: Autofire.cc:5
byte & operator[](unsigned addr)
Definition: Ram.hh:30
Ram(const DeviceConfig &config, const std::string &name, const std::string &description, unsigned size)
Create Ram object with an associated debuggable.
Definition: Ram.cc:30
void serialize(Archive &ar, unsigned version)
Definition: Ram.cc:120
unsigned getSize() const
Definition: Ram.hh:33
const byte & operator[](unsigned addr) const
Definition: Ram.hh:27