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  [[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 
39 private:
40  void enableDAC(bool enable, EmuTime::param time);
41 
42 private:
43  std::unique_ptr<Y8950Periphery> periphery; // polymorphic
44  Y8950 y8950;
45  std::unique_ptr<DACSound8U> dac; // can be nullptr
46  int registerLatch;
47  byte dacValue;
48  bool dacEnabled;
49 
50  friend class MusicModulePeriphery;
52  friend class ToshibaAudioPeriphery;
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:43
byte peekMem(word address, EmuTime::param time) const override
Read a byte from a given memory location.
Definition: MSXAudio.cc:99
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:107
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:78
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:56
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:103
MSXAudio(const DeviceConfig &config)
Definition: MSXAudio.cc:12
byte * getWriteCacheLine(word start) const override
Test that the memory in the interval [start, start + CacheLine::SIZE) is cacheable for writing.
Definition: MSXAudio.cc:111
byte readMem(word address, EmuTime::param time) override
Read a byte from a location at a certain time from this device.
Definition: MSXAudio.cc:95
void serialize(Archive &ar, unsigned version)
Definition: MSXAudio.cc:126
void reset(EmuTime::param time) override
This method is called on reset.
Definition: MSXAudio.cc:49
~MSXAudio() override
Definition: MSXAudio.cc:29
byte peekIO(word port, EmuTime::param time) const override
Read a byte from a given IO port.
Definition: MSXAudio.cc:67
Y8950Periphery & createPeriphery(const std::string &soundDeviceName)
Creates a periphery object for this MSXAudio cartridge.
Definition: MSXAudio.cc:36
An MSXDevice is an emulated hardware component connected to the bus of the emulated MSX.
Definition: MSXDevice.hh:33
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