OXYGENHUB
◆ main openmsx / src / sound / YM2413.hh
1.2 KiB · C++ · last changed chore(): initial commit 1 month ago source blame history raw
e8555c89 Andy McCall 1
#ifndef YM2413_HH
2
#define YM2413_HH
3
4
#include "ResampledSoundDevice.hh"
5
6
#include "EmuTime.hh"
7
#include "SimpleDebuggable.hh"
8
9
#include <cstdint>
10
#include <memory>
11
#include <span>
12
#include <string>
13
14
namespace openmsx {
15
16
class YM2413Core;
17
18
class YM2413 final : public ResampledSoundDevice
19
{
20
public:
21
	YM2413(const std::string& name, const DeviceConfig& config);
22
	~YM2413();
23
24
	void reset(EmuTime time);
25
	void writePort(bool port, uint8_t value, EmuTime time);
26
	void pokeReg(uint8_t reg, uint8_t value, EmuTime time);
27
	[[nodiscard]] std::span<const uint8_t, 64> peekRegs() const;
28
29
	template<typename Archive>
30
	void serialize(Archive& ar, unsigned version);
31
32
private:
33
	// SoundDevice
34
	void setOutputRate(unsigned hostSampleRate, double speed) override;
35
	void generateChannels(std::span<float*> bufs, unsigned num) override;
36
	[[nodiscard]] float getAmplificationFactorImpl() const override;
37
38
private:
39
	const std::unique_ptr<YM2413Core> core;
40
41
	struct Debuggable final : SimpleDebuggable {
42
		Debuggable(MSXMotherBoard& motherBoard, const std::string& name);
43
		[[nodiscard]] uint8_t read(unsigned address) override;
44
		void write(unsigned address, uint8_t value, EmuTime time) override;
45
	} debuggable;
46
};
47
48
} // namespace openmsx
49
50
#endif