OXYGENHUB
◆ main openmsx / src / memory / KonamiUltimateCollection.hh
1.8 KiB · C++ · last changed chore(): initial commit 1 month ago source blame history raw
1
#ifndef KONAMIULTIMATECOLLECTION_HH
2
#define KONAMIULTIMATECOLLECTION_HH
3
4
#include "AmdFlash.hh"
5
#include "DACSound8U.hh"
6
#include "MSXRom.hh"
7
#include "RomBlockDebuggable.hh"
8
#include "SCC.hh"
9
10
#include <array>
11
12
namespace openmsx {
13
14
class KonamiUltimateCollection final : public MSXRom
15
{
16
public:
17
	KonamiUltimateCollection(DeviceConfig& config, Rom&& rom);
18
19
	void powerUp(EmuTime time) override;
20
	void reset(EmuTime time) override;
21
	[[nodiscard]] byte peekMem(uint16_t address, EmuTime time) const 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, EmuTime time) override;
25
	[[nodiscard]] byte* getWriteCacheLine(uint16_t address) override;
26
27
	template<typename Archive>
28
	void serialize(Archive& ar, unsigned version);
29
30
private:
31
	[[nodiscard]] bool isSCCAccess(uint16_t addr) const;
32
	[[nodiscard]] unsigned getFlashAddr(unsigned addr) const;
33
34
	[[nodiscard]] bool isKonamiSCCmode()         const { return (mapperReg & 0x20) == 0; }
35
	[[nodiscard]] bool isFlashRomWriteEnabled()  const { return (mapperReg & 0x10) != 0; }
36
	[[nodiscard]] bool isBank0Disabled()         const { return (mapperReg & 0x08) != 0; }
37
	[[nodiscard]] bool isMapperRegisterEnabled() const { return (mapperReg & 0x04) == 0; }
38
	[[nodiscard]] bool areBankRegsEnabled()      const { return (mapperReg & 0x02) == 0; }
39
40
private:
41
	struct Blocks final : RomBlockDebuggableBase {
42
		explicit Blocks(const KonamiUltimateCollection& device)
43
			: RomBlockDebuggableBase(device) {}
44
		[[nodiscard]] unsigned readExt(unsigned address) override;
45
	} romBlockDebug;
46
47
	AmdFlash flash;
48
	SCC scc;
49
	DACSound8U dac;
50
51
	byte mapperReg;
52
	byte offsetReg;
53
	byte sccMode;
54
	std::array<byte, 4> bankRegs;
55
};
56
57
} // namespace openmsx
58
59
#endif