OXYGENHUB
◆ main openmsx / src / sound / MSXSCCPlusCart.hh
1.6 KiB · C++ · last changed chore(): initial commit 1 month ago source blame history raw
e8555c89 Andy McCall 1
// Note: this device is actually called SCC-I. But this would take a lot of
2
// renaming, which isn't worth it right now. TODO rename this :)
3
4
#ifndef MSXSCCPLUSCART_HH
5
#define MSXSCCPLUSCART_HH
6
7
#include "SCC.hh"
8
9
#include "MSXDevice.hh"
10
#include "Ram.hh"
11
#include "RomBlockDebuggable.hh"
12
13
#include <array>
14
#include <cstdint>
15
16
namespace openmsx {
17
18
class MSXSCCPlusCart final : public MSXDevice
19
{
20
public:
21
	struct MapperConfig {
22
		unsigned numBlocks;  // number of 8kB blocks
23
		byte registerMask;   // mapper selection bits to ignore
24
		byte registerOffset; // first mapped block
25
	};
26
27
public:
28
	explicit MSXSCCPlusCart(const DeviceConfig& config);
29
30
	void powerUp(EmuTime time) override;
31
	void reset(EmuTime time) override;
32
	[[nodiscard]] byte readMem(uint16_t address, EmuTime time) override;
33
	[[nodiscard]] byte peekMem(uint16_t address, EmuTime time) const override;
34
	void writeMem(uint16_t address, byte value, EmuTime time) override;
35
	[[nodiscard]] const byte* getReadCacheLine(uint16_t start) const override;
36
	[[nodiscard]] byte* getWriteCacheLine(uint16_t start) override;
37
38
	template<typename Archive>
39
	void serialize(Archive& ar, unsigned version);
40
41
private:
42
	void setMapper(int region, byte value);
43
	void setModeRegister(byte value);
44
	void checkEnable();
45
46
private:
47
	const MapperConfig mapperConfig;
48
	Ram ram;
49
	SCC scc;
50
	RomBlockDebuggable romBlockDebug;
51
	std::array<byte*, 4> internalMemoryBank; // 4 blocks of 8kB starting at #4000
52
	enum SCCEnable : uint8_t {EN_NONE, EN_SCC, EN_SCCPLUS} enable;
53
	byte modeRegister;
54
	std::array<bool, 4> isRamSegment;
55
	std::array<bool, 4> isMapped;
56
	std::array<byte, 4> mapper;
57
};
58
59
} // namespace openmsx
60
61
#endif