OXYGENHUB
◆ main openmsx / src / MSXKanji.hh
1.8 KiB · C++ · last changed chore(): initial commit 1 month ago source blame history raw
1
#ifndef MSXKANJI_HH
2
#define MSXKANJI_HH
3
4
#include "MSXDevice.hh"
5
#include "Rom.hh"
6
7
namespace openmsx {
8
9
class MSXKanji final : public MSXDevice
10
{
11
public:
12
	explicit MSXKanji(DeviceConfig& config);
13
14
	[[nodiscard]] uint8_t readIO(uint16_t port, EmuTime time) override;
15
	[[nodiscard]] uint8_t peekIO(uint16_t port, EmuTime time) const override;
16
	void writeIO(uint16_t port, uint8_t value, EmuTime time) override;
17
	void reset(EmuTime time) override;
18
19
	void getExtraDeviceInfo(TclObject& result) const override;
20
21
	template<typename Archive>
22
	void serialize(Archive& ar, unsigned version);
23
24
private:
25
	struct ReadImplResult {
26
		bool valid = false;
27
		uint8_t value = 0xFF;
28
	};
29
	ReadImplResult readImpl(uint16_t port) const;
30
31
private:
32
	enum class Level2Via : uint8_t {
33
		//OnlyLevel1, // only level 1 is present, level2 ports (if configured) are mirrors for level1
34
		Read, // Level1 or level2 is decided via the port-set (level1 or 2) used for reading
35
		Write, // Level1 or level 2 is decided via the port-set used during writing.
36
		InterlockedWriteRead, // Write to port-set for level1/2 must be followed by read for the same set.
37
		                      // Reading from the other port-set returns 0xFF.
38
	};
39
40
	Rom rom;
41
	uint32_t adr; // 17 bits   (6 row + 6 column + 5 counter), the 18th bit (level) is not included
42
	              //  exception: for 'hangul', the address is 18 bit
43
	              // Note: adr[1] only used in mode "Level2Via::Read", other modes share adr[0] for level1+2
44
	uint8_t writeLevel; // '0' for level1, '1' for level2
45
46
	uint8_t highAddressMask;
47
	Level2Via level2Via;
48
	uint8_t portMask; // '1' if only level1 is present (level2 mirrors level1)
49
	                  // '3' is both level1 and level2 are present
50
};
51
SERIALIZE_CLASS_VERSION(MSXKanji, 2);
52
53
} // namespace openmsx
54
55
#endif