openMSX
CheckedRam.hh
Go to the documentation of this file.
1 #ifndef CHECKEDRAM_HH
2 #define CHECKEDRAM_HH
3 
4 #include "Ram.hh"
5 #include "TclCallback.hh"
6 #include "CacheLine.hh"
7 #include "Observer.hh"
8 #include "openmsx.hh"
9 #include <vector>
10 #include <bitset>
11 
12 namespace openmsx {
13 
14 class DeviceConfig;
15 class MSXCPU;
16 class Setting;
17 
27 class CheckedRam final : private Observer<Setting>
28 {
29 public:
30  CheckedRam(const DeviceConfig& config, const std::string& name,
31  const std::string& description, unsigned size);
32  ~CheckedRam();
33 
34  byte read(unsigned addr);
35  byte peek(unsigned addr) const { return ram[addr]; }
36  void write(unsigned addr, byte value);
37 
38  const byte* getReadCacheLine(unsigned addr) const;
39  byte* getWriteCacheLine(unsigned addr) const;
40  byte* getRWCacheLines(unsigned addr, unsigned size) const;
41 
42  unsigned getSize() const { return ram.getSize(); }
43  void clear();
44 
51  Ram& getUncheckedRam() { return ram; }
52 
53  // TODO
54  //template<typename Archive>
55  //void serialize(Archive& ar, unsigned version);
56 
57 private:
58  void init();
59 
60  // Observer<Setting>
61  void update(const Setting& setting) override;
62 
63  std::vector<bool> completely_initialized_cacheline;
64  std::vector<std::bitset<CacheLine::SIZE>> uninitialized;
65  Ram ram;
66  MSXCPU& msxcpu;
67  TclCallback umrCallback;
68 };
69 
70 } // namespace openmsx
71 
72 #endif
openmsx.hh
openmsx::CheckedRam::getSize
unsigned getSize() const
Definition: CheckedRam.hh:42
openmsx::CheckedRam::getWriteCacheLine
byte * getWriteCacheLine(unsigned addr) const
Definition: CheckedRam.cc:53
openmsx::CheckedRam::~CheckedRam
~CheckedRam()
Definition: CheckedRam.cc:31
openmsx::CheckedRam::read
byte read(unsigned addr)
Definition: CheckedRam.cc:36
openmsx::DeviceConfig
Definition: DeviceConfig.hh:19
utf8::unchecked::size
size_t size(std::string_view utf8)
Definition: utf8_unchecked.hh:227
openmsx::CheckedRam::getRWCacheLines
byte * getRWCacheLines(unsigned addr, unsigned size) const
Definition: CheckedRam.cc:59
openmsx::MSXCPU
MSXCPU
Definition: MSXCPU.cc:563
openmsx::Setting
Definition: Setting.hh:119
Ram.hh
openmsx::CheckedRam::clear
void clear()
Definition: CheckedRam.cc:93
Observer.hh
openmsx::CheckedRam::peek
byte peek(unsigned addr) const
Definition: CheckedRam.hh:35
openmsx::CheckedRam::CheckedRam
CheckedRam(const DeviceConfig &config, const std::string &name, const std::string &description, unsigned size)
Definition: CheckedRam.cc:19
openmsx::MSXCPU
Definition: MSXCPU.hh:28
openmsx::CheckedRam::write
void write(unsigned addr, byte value)
Definition: CheckedRam.cc:72
CacheLine.hh
TclCallback.hh
openmsx::Ram
Definition: Ram.hh:15
openmsx::CheckedRam
This class keeps track of which bytes in the Ram have been written to.
Definition: CheckedRam.hh:27
openmsx::CheckedRam::getUncheckedRam
Ram & getUncheckedRam()
Give access to the unchecked Ram.
Definition: CheckedRam.hh:51
openmsx
Thanks to enen for testing this on a real cartridge:
Definition: Autofire.cc:5
openmsx::Observer
Generic Gang-of-Four Observer class, templatized edition.
Definition: Observer.hh:9
openmsx::Ram::getSize
unsigned getSize() const
Definition: Ram.hh:33
openmsx::CheckedRam::getReadCacheLine
const byte * getReadCacheLine(unsigned addr) const
Definition: CheckedRam.cc:47
openmsx::TclCallback
Definition: TclCallback.hh:13