openMSX
MSXAudio.hh
Go to the documentation of this file.
1#ifndef MSXAUDIO_HH
2#define MSXAUDIO_HH
3
4#include "MSXDevice.hh"
5#include "Y8950.hh"
6#include <memory>
7#include <string>
8
9namespace openmsx {
10
11class Y8950Periphery;
12class DACSound8U;
13
14class MSXAudio final : public MSXDevice
15{
16public:
17 explicit MSXAudio(const DeviceConfig& config);
18 ~MSXAudio() override;
19
23 [[nodiscard]] Y8950Periphery& createPeriphery(const std::string& soundDeviceName);
24
25 void powerUp(EmuTime::param time) override;
26 void reset(EmuTime::param time) override;
27 [[nodiscard]] byte readIO(word port, EmuTime::param time) override;
28 [[nodiscard]] byte peekIO(word port, EmuTime::param time) const override;
29 void writeIO(word port, byte value, EmuTime::param time) override;
30 [[nodiscard]] byte readMem(word address, EmuTime::param time) override;
31 [[nodiscard]] byte peekMem(word address, EmuTime::param time) const override;
32 void writeMem(word address, byte value, EmuTime::param time) override;
33 [[nodiscard]] const byte* getReadCacheLine(word start) const override;
34 [[nodiscard]] byte* getWriteCacheLine(word start) const override;
35
36 template<typename Archive>
37 void serialize(Archive& ar, unsigned version);
38
39private:
40 void enableDAC(bool enable, EmuTime::param time);
41
42private:
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
53};
54
55} // namespace openmsx
56
57#endif
void powerUp(EmuTime::param time) override
This method is called when MSX is powered up.
Definition MSXAudio.cc:42
byte peekMem(word address, EmuTime::param time) const override
Read a byte from a given memory location.
Definition MSXAudio.cc:98
const byte * getReadCacheLine(word start) const override
Test that the memory in the interval [start, start + CacheLine::SIZE) is cacheable for reading.
Definition MSXAudio.cc:106
void writeIO(word port, byte value, EmuTime::param time) override
Write a byte to a given IO port at a certain time to this device.
Definition MSXAudio.cc:77
byte readIO(word port, EmuTime::param time) override
Read a byte from an IO port at a certain time from this device.
Definition MSXAudio.cc:55
void writeMem(word address, byte value, EmuTime::param time) override
Write a given byte to a given location at a certain time to this device.
Definition MSXAudio.cc:102
byte * getWriteCacheLine(word start) const override
Test that the memory in the interval [start, start + CacheLine::SIZE) is cacheable for writing.
Definition MSXAudio.cc:110
byte readMem(word address, EmuTime::param time) override
Read a byte from a location at a certain time from this device.
Definition MSXAudio.cc:94
void serialize(Archive &ar, unsigned version)
Definition MSXAudio.cc:125
void reset(EmuTime::param time) override
This method is called on reset.
Definition MSXAudio.cc:48
~MSXAudio() override
Definition MSXAudio.cc:28
byte peekIO(word port, EmuTime::param time) const override
Read a byte from a given IO port.
Definition MSXAudio.cc:66
Y8950Periphery & createPeriphery(const std::string &soundDeviceName)
Creates a periphery object for this MSXAudio cartridge.
Definition MSXAudio.cc:35
An MSXDevice is an emulated hardware component connected to the bus of the emulated MSX.
Definition MSXDevice.hh:36
Models the 4 general purpose I/O pins on the Y8950 (controlled by registers r#18 and r#19)
This file implemented 3 utility functions:
Definition Autofire.cc:9
uint16_t word
16 bit unsigned integer
Definition openmsx.hh:29