OXYGENHUB
◆ main openmsx / src / memory / MSXMegaRam.hh
1.3 KiB · C++ · last changed chore(): initial commit 1 month ago source blame history raw
e8555c89 Andy McCall 1
#ifndef MSXMEGARAM_HH
2
#define MSXMEGARAM_HH
3
4
#include "MSXDevice.hh"
5
#include "Ram.hh"
6
#include "RomBlockDebuggable.hh"
7
#include <array>
8
#include <memory>
9
10
namespace openmsx {
11
12
class Rom;
13
14
class MSXMegaRam final : public MSXDevice
15
{
16
public:
17
	explicit MSXMegaRam(DeviceConfig& config);
18
	~MSXMegaRam() override;
19
20
	void powerUp(EmuTime time) override;
21
	void reset(EmuTime time) override;
22
	[[nodiscard]] byte readMem(uint16_t address, EmuTime time) override;
23
	[[nodiscard]] const byte* getReadCacheLine(uint16_t address) const override;
24
	void writeMem(uint16_t address, byte value,
25
	              EmuTime time) override;
26
	[[nodiscard]] byte* getWriteCacheLine(uint16_t address) override;
27
28
	[[nodiscard]] byte readIO(uint16_t port, EmuTime time) override;
29
	[[nodiscard]] byte peekIO(uint16_t port, EmuTime time) const override;
30
	void writeIO(uint16_t port, byte value, EmuTime time) override;
31
32
	template<typename Archive>
33
	void serialize(Archive& ar, unsigned version);
34
35
private:
36
	void setBank(byte page, byte block);
37
38
private:
39
	const unsigned numBlocks; // must come before ram
40
	Ram ram;
41
	const std::unique_ptr<Rom> rom; // can be nullptr
42
	RomBlockDebuggable romBlockDebug;
43
	const byte maskBlocks;
44
	std::array<byte, 4> bank;
45
	bool writeMode;
46
	bool romMode;
47
};
48
49
} // namespace openmsx
50
51
#endif