OXYGENHUB
◆ main openmsx / src / memory / MegaFlashRomSCCPlus.hh
1.5 KiB · C++ · last changed chore(): initial commit 1 month ago source blame history raw
1
#ifndef MEGAFLASHROMSCCPLUS_HH
2
#define MEGAFLASHROMSCCPLUS_HH
3
4
#include "AmdFlash.hh"
5
#include "MSXRom.hh"
6
7
#include "AY8910.hh"
8
#include "SCC.hh"
9
10
#include <array>
11
#include <cstdint>
12
13
namespace openmsx {
14
15
class MegaFlashRomSCCPlus final : public MSXRom
16
{
17
public:
18
	MegaFlashRomSCCPlus(DeviceConfig& config, Rom&& rom);
19
	~MegaFlashRomSCCPlus() override;
20
21
	void powerUp(EmuTime time) override;
22
	void reset(EmuTime time) override;
23
	[[nodiscard]] byte peekMem(uint16_t address, EmuTime time) const override;
24
	[[nodiscard]] byte readMem(uint16_t address, EmuTime time) override;
25
	[[nodiscard]] const byte* getReadCacheLine(uint16_t address) const override;
26
	void writeMem(uint16_t address, byte value, EmuTime time) override;
27
	[[nodiscard]] byte* getWriteCacheLine(uint16_t address) override;
28
29
	void writeIO(uint16_t port, byte value, EmuTime time) override;
30
31
	template<typename Archive>
32
	void serialize(Archive& ar, unsigned version);
33
34
private:
35
	[[nodiscard]] byte readMem2(uint16_t addr, EmuTime time);
36
37
	enum class SCCMode { NONE, SCC, SCCPLUS };
38
	[[nodiscard]] SCCMode getSCCMode() const;
39
40
	[[nodiscard]] unsigned getSubslot(unsigned address) const;
41
	[[nodiscard]] unsigned getFlashAddr(unsigned addr) const;
42
	[[nodiscard]] bool isSCCAccessEnabled() const;
43
44
private:
45
	SCC scc;
46
	AY8910 psg;
47
	AmdFlash flash;
48
49
	byte configReg;
50
	byte offsetReg;
51
	byte subslotReg;
52
	std::array<std::array<byte, 4>, 4> bankRegs;
53
	byte psgLatch;
54
	byte sccModeReg;
55
	std::array<byte, 4> sccBanks;
56
};
57
58
} // namespace openmsx
59
60
#endif