OXYGENHUB
◆ main openmsx / src / sound / MSXPSG.hh
1.3 KiB · C++ · last changed chore(): initial commit 1 month ago source blame history raw
1
#ifndef MSXPSG_HH
2
#define MSXPSG_HH
3
4
#include "AY8910.hh"
5
#include "AY8910Periphery.hh"
6
7
#include "MSXDevice.hh"
8
#include "serialize_meta.hh"
9
10
#include <array>
11
12
namespace openmsx {
13
14
class CassettePortInterface;
15
class RenShaTurbo;
16
class JoystickPortIf;
17
18
class MSXPSG final : public MSXDevice, public AY8910Periphery
19
{
20
public:
21
	explicit MSXPSG(const DeviceConfig& config);
22
	~MSXPSG() override;
23
24
	void reset(EmuTime time) override;
25
	void powerDown(EmuTime time) override;
26
	[[nodiscard]] byte readIO(uint16_t port, EmuTime time) override;
27
	[[nodiscard]] byte peekIO(uint16_t port, EmuTime time) const override;
28
	void writeIO(uint16_t port, byte value, EmuTime time) override;
29
30
	template<typename Archive>
31
	void serialize(Archive& ar, unsigned version);
32
33
private:
34
	// AY8910Periphery: port A input, port B output
35
	[[nodiscard]] byte readA(EmuTime time) override;
36
	void writeB(byte value, EmuTime time) override;
37
38
private:
39
	CassettePortInterface& cassette;
40
	RenShaTurbo& renShaTurbo;
41
42
	std::array<JoystickPortIf*, 2> ports;
43
	int selectedPort = 0;
44
	int registerLatch;
45
	byte prev = 255;
46
	const byte keyLayout; // 0x40 or 0x00
47
	const byte addressMask; // controls address mirroring
48
	AY8910 ay8910; // must come after initialisation of most stuff above
49
};
50
SERIALIZE_CLASS_VERSION(MSXPSG, 2);
51
52
} // namespace openmsx
53
54
#endif