OXYGENHUB
◆ main openmsx / src / sound / MSXAudio.hh
1.6 KiB · C++ · last changed chore(): initial commit 1 month ago source blame history raw
e8555c89 Andy McCall 1
#ifndef MSXAUDIO_HH
2
#define MSXAUDIO_HH
3
4
#include "MSXDevice.hh"
5
#include "Y8950.hh"
6
#include <memory>
7
#include <string>
8
9
namespace openmsx {
10
11
class Y8950Periphery;
12
class DACSound8U;
13
14
class MSXAudio final : public MSXDevice
15
{
16
public:
17
	explicit MSXAudio(const DeviceConfig& config);
18
	~MSXAudio() override;
19
20
	/** Creates a periphery object for this MSXAudio cartridge.
21
	  * The ownership of the object remains with the MSXAudio instance.
22
	  */
23
	[[nodiscard]] Y8950Periphery& createPeriphery(const std::string& soundDeviceName);
24
25
	void powerUp(EmuTime time) override;
26
	void reset(EmuTime time) override;
27
	[[nodiscard]] byte readIO(uint16_t port, EmuTime time) override;
28
	[[nodiscard]] byte peekIO(uint16_t port, EmuTime time) const override;
29
	void writeIO(uint16_t port, byte value, EmuTime time) override;
30
	[[nodiscard]] byte readMem(uint16_t address, EmuTime time) override;
31
	[[nodiscard]] byte peekMem(uint16_t address, EmuTime time) const override;
32
	void writeMem(uint16_t address, byte value, EmuTime time) override;
33
	[[nodiscard]] const byte* getReadCacheLine(uint16_t start) const override;
34
	[[nodiscard]] byte* getWriteCacheLine(uint16_t start) override;
35
36
	template<typename Archive>
37
	void serialize(Archive& ar, unsigned version);
38
39
private:
40
	void enableDAC(bool enable, EmuTime time);
41
42
private:
43
	std::unique_ptr<Y8950Periphery> periphery; // polymorphic
44
	Y8950 y8950;
45
	std::unique_ptr<DACSound8U> dac; // can be nullptr
46
	byte registerLatch;
47
	byte dacValue = 0x80;
48
	bool dacEnabled = false;
49
50
	friend class MusicModulePeriphery;
51
	friend class PanasonicAudioPeriphery;
52
	friend class ToshibaAudioPeriphery;
53
};
54
55
} // namespace openmsx
56
57
#endif