openMSX
Ram.hh
Go to the documentation of this file.
1#ifndef RAM_HH
2#define RAM_HH
3
4#include "SimpleDebuggable.hh"
5#include "MemBuffer.hh"
6#include "openmsx.hh"
8#include <optional>
9#include <string>
10
11namespace openmsx {
12
13class XMLElement;
14class DeviceConfig;
15class Ram;
16
17class RamDebuggable final : public SimpleDebuggable
18{
19public:
20 RamDebuggable(MSXMotherBoard& motherBoard, const std::string& name,
21 static_string_view description, Ram& ram);
22 byte read(unsigned address) override;
23 void write(unsigned address, byte value) override;
24private:
25 Ram& ram;
26};
27
28class Ram
29{
30public:
32 Ram(const DeviceConfig& config, const std::string& name,
33 static_string_view description, unsigned size);
34
36 Ram(const XMLElement& xml, unsigned size);
37
38 [[nodiscard]] const byte& operator[](unsigned addr) const {
39 return ram[addr];
40 }
41 [[nodiscard]] byte& operator[](unsigned addr) {
42 return ram[addr];
43 }
44 [[nodiscard]] unsigned getSize() const {
45 return size;
46 }
47
48 [[nodiscard]] const std::string& getName() const;
49 void clear(byte c = 0xff);
50
51 template<typename Archive>
52 void serialize(Archive& ar, unsigned version);
53
54private:
55 const XMLElement& xml;
57 unsigned size; // must come before debuggable
58 const std::optional<RamDebuggable> debuggable; // can be nullopt
59};
60
61} // namespace openmsx
62
63#endif
byte read(unsigned address) override
Definition: Ram.cc:92
void write(unsigned address, byte value) override
Definition: Ram.cc:97
RamDebuggable(MSXMotherBoard &motherBoard, const std::string &name, static_string_view description, Ram &ram)
Definition: Ram.cc:84
Ram(const DeviceConfig &config, const std::string &name, static_string_view description, unsigned size)
Create Ram object with an associated debuggable.
Definition: Ram.cc:16
byte & operator[](unsigned addr)
Definition: Ram.hh:41
unsigned getSize() const
Definition: Ram.hh:44
void serialize(Archive &ar, unsigned version)
Definition: Ram.cc:104
const byte & operator[](unsigned addr) const
Definition: Ram.hh:38
void clear(byte c=0xff)
Definition: Ram.cc:35
const std::string & getName() const
Definition: Ram.cc:79
static_string_view
This file implemented 3 utility functions:
Definition: Autofire.cc:9
Ram
Definition: Ram.cc:108