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) 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:41
byte peekMem(word address, EmuTime::param time) const override
Read a byte from a given memory location.
Definition MSXAudio.cc:97
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:105
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:76
byte * getWriteCacheLine(word start) override
Test that the memory in the interval [start, start + CacheLine::SIZE) is cacheable for writing.
Definition MSXAudio.cc:109
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:54
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:101
byte readMem(word address, EmuTime::param time) override
Read a byte from a location at a certain time from this device.
Definition MSXAudio.cc:93
void serialize(Archive &ar, unsigned version)
Definition MSXAudio.cc:124
void reset(EmuTime::param time) override
This method is called on reset.
Definition MSXAudio.cc:47
~MSXAudio() override
Definition MSXAudio.cc:27
byte peekIO(word port, EmuTime::param time) const override
Read a byte from a given IO port.
Definition MSXAudio.cc:65
Y8950Periphery & createPeriphery(const std::string &soundDeviceName)
Creates a periphery object for this MSXAudio cartridge.
Definition MSXAudio.cc:34
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:11
uint16_t word
16 bit unsigned integer
Definition openmsx.hh:29