OXYGENHUB
◆ main openmsx / src / sound / Y8950Periphery.hh
1.8 KiB · C++ · last changed chore(): initial commit 1 month ago source blame history raw
e8555c89 Andy McCall 1
#ifndef Y8950PERIPHERY_HH
2
#define Y8950PERIPHERY_HH
3
4
#include "EmuTime.hh"
5
6
#include <cstdint>
7
#include <memory>
8
#include <string>
9
10
namespace openmsx {
11
12
using uint4_t = uint8_t;
13
14
/** Models the 4 general purpose I/O pins on the Y8950
15
  * (controlled by registers r#18 and r#19)
16
  */
17
class Y8950Periphery
18
{
19
public:
20
	virtual ~Y8950Periphery() = default;
21
22
	virtual void reset();
23
24
	/** Write to (some of) the pins
25
	  * @param outputs A '1' bit indicates the corresponding bit is
26
	  *                programmed as output.
27
	  * @param values The actual value that is written, only bits for
28
	  *               which the corresponding bit in the 'outputs'
29
	  *               parameter is set are meaningful.
30
	  * @param time The moment in time the write occurs
31
	  */
32
	virtual void write(uint4_t outputs, uint4_t values, EmuTime time) = 0;
33
34
	/** Read from (some of) the pins
35
	  * Some of the pins might be programmed as output, but this method
36
	  * doesn't care about that, it should return the value of all pins
37
	  * as-if they were all programmed as input.
38
	  * @param time The moment in time the read occurs
39
	  */
40
	[[nodiscard]] virtual uint4_t read(EmuTime time) = 0;
41
42
	/** SP-OFF bit (bit 3 in Y8950 register 7) */
43
	virtual void setSPOFF(bool value, EmuTime time);
44
45
	[[nodiscard]] virtual uint8_t readMem(uint16_t address, EmuTime time);
46
	[[nodiscard]] virtual uint8_t peekMem(uint16_t address, EmuTime time) const;
47
	virtual void writeMem(uint16_t address, uint8_t value, EmuTime time);
48
	[[nodiscard]] virtual const uint8_t* getReadCacheLine(uint16_t start) const;
49
	[[nodiscard]] virtual uint8_t* getWriteCacheLine(uint16_t start);
50
};
51
52
class MSXAudio;
53
class DeviceConfig;
54
55
class Y8950PeripheryFactory
56
{
57
public:
58
	[[nodiscard]] static std::unique_ptr<Y8950Periphery> create(
59
		MSXAudio& audio, DeviceConfig& config,
60
		const std::string& soundDeviceName);
61
};
62
63
} // namespace openmsx
64
65
#endif