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 
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 
23  Y8950Periphery& createPeriphery(const std::string& soundDeviceName);
24 
25  void powerUp(EmuTime::param time) override;
26  void reset(EmuTime::param time) override;
27  byte readIO(word port, EmuTime::param time) override;
28  byte peekIO(word port, EmuTime::param time) const override;
29  void writeIO(word port, byte value, EmuTime::param time) override;
30  byte readMem(word address, EmuTime::param time) override;
31  byte peekMem(word address, EmuTime::param time) const override;
32  void writeMem(word address, byte value, EmuTime::param time) override;
33  const byte* getReadCacheLine(word start) const override;
34  byte* getWriteCacheLine(word start) const override;
35 
36  template<typename Archive>
37  void serialize(Archive& ar, unsigned version);
38 
39 private:
40  void enableDAC(bool enable, EmuTime::param time);
41 
42  std::unique_ptr<Y8950Periphery> periphery; // polymorphic
43  Y8950 y8950;
44  std::unique_ptr<DACSound8U> dac; // can be nullptr
45  int registerLatch;
46  byte dacValue;
47  bool dacEnabled;
48 
49  friend class MusicModulePeriphery;
51  friend class ToshibaAudioPeriphery;
52 };
53 
54 } // namespace openmsx
55 
56 #endif
openmsx::MSXDevice
An MSXDevice is an emulated hardware component connected to the bus of the emulated MSX.
Definition: MSXDevice.hh:31
openmsx::MSXAudio::serialize
void serialize(Archive &ar, unsigned version)
Definition: MSXAudio.cc:129
openmsx::MSXAudio::peekIO
byte peekIO(word port, EmuTime::param time) const override
Read a byte from a given IO port.
Definition: MSXAudio.cc:70
openmsx::MSXAudio::reset
void reset(EmuTime::param time) override
This method is called on reset.
Definition: MSXAudio.cc:50
openmsx::DeviceConfig
Definition: DeviceConfig.hh:19
openmsx::MSXAudio::readMem
byte readMem(word address, EmuTime::param time) override
Read a byte from a location at a certain time from this device.
Definition: MSXAudio.cc:98
openmsx::MSXAudio
Definition: MSXAudio.hh:14
openmsx::MSXAudio::createPeriphery
Y8950Periphery & createPeriphery(const std::string &soundDeviceName)
Creates a periphery object for this MSXAudio cartridge.
Definition: MSXAudio.cc:37
openmsx::MSXAudio::MSXAudio
MSXAudio(const DeviceConfig &config)
Definition: MSXAudio.cc:14
Y8950.hh
openmsx::Y8950Periphery
Models the 4 general purpose I/O pins on the Y8950 (controlled by registers r#18 and r#19)
Definition: Y8950Periphery.hh:14
openmsx::MSXAudio::getWriteCacheLine
byte * getWriteCacheLine(word start) const override
Test that the memory in the interval [start, start + CacheLine::SIZE) is cacheable for writing.
Definition: MSXAudio.cc:114
openmsx::MSXAudio::writeIO
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:81
openmsx::PanasonicAudioPeriphery
Definition: Y8950Periphery.cc:41
MSXDevice.hh
openmsx::MSXAudio::getReadCacheLine
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:110
openmsx::MSXAudio::powerUp
void powerUp(EmuTime::param time) override
This method is called when MSX is powered up.
Definition: MSXAudio.cc:44
openmsx::MSXAudio::~MSXAudio
~MSXAudio() override
Definition: MSXAudio.cc:30
openmsx::ToshibaAudioPeriphery
Definition: Y8950Periphery.cc:76
openmsx::word
uint16_t word
16 bit unsigned integer
Definition: openmsx.hh:29
openmsx::MSXAudio::writeMem
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:106
openmsx
Thanks to enen for testing this on a real cartridge:
Definition: Autofire.cc:5
openmsx::MusicModulePeriphery
Definition: Y8950Periphery.cc:24
openmsx::MSXAudio::peekMem
byte peekMem(word address, EmuTime::param time) const override
Read a byte from a given memory location.
Definition: MSXAudio.cc:102
openmsx::MSXAudio::readIO
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:57
openmsx::Y8950
Definition: Y8950.hh:23