14 , y8950(getName(), config,
15 config.getChildDataAsInt(
"sampleram", 256) * 1024,
16 getCurrentTime(), *this)
20 dac = std::make_unique<DACSound8U>(
21 getName() +
" 8-bit DAC",
"MSX-AUDIO 8-bit DAC",
56 if ((port & 0xE8) == 0x08) {
60 return (port & 1) ? y8950.
readReg(registerLatch, time)
67 if ((port & 0xE8) == 0x08) {
71 return (port & 1) ? y8950.
peekReg(registerLatch, time)
78 if ((port & 0xE8) == 0x08) {
82 dac->writeDAC(dacValue, time);
84 }
else if ((port & 0x01) == 0) {
86 registerLatch = value;
89 y8950.
writeReg(registerLatch, value, time);
95 return periphery->readMem(address, time);
99 return periphery->peekMem(address, time);
103 periphery->writeMem(address, value, time);
107 return periphery->getReadCacheLine(start);
111 return periphery->getWriteCacheLine(start);
114void MSXAudio::enableDAC(
bool enable, EmuTime::param time)
116 if ((dacEnabled != enable) && dac) {
118 byte value = dacEnabled ? dacValue : 0x80;
119 dac->writeDAC(value, time);
123template<
typename Archive>
126 ar.serializePolymorphic(
"periphery", *periphery);
127 ar.serialize(
"Y8950", y8950,
128 "registerLatch", registerLatch,
129 "dacValue", dacValue,
130 "dacEnabled", dacEnabled);
132 if constexpr (Archive::IS_LOADER) {
#define REGISTER_MSXDEVICE(CLASS, NAME)
std::string_view getChildData(std::string_view name) const
void powerUp(EmuTime::param time) override
This method is called when MSX is powered up.
byte peekMem(word address, EmuTime::param time) const override
Read a byte from a given memory location.
const byte * getReadCacheLine(word start) const override
Test that the memory in the interval [start, start + CacheLine::SIZE) is cacheable for reading.
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.
byte * getWriteCacheLine(word start) override
Test that the memory in the interval [start, start + CacheLine::SIZE) is cacheable for writing.
byte readIO(word port, EmuTime::param time) override
Read a byte from an IO port at a certain time from this device.
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.
MSXAudio(const DeviceConfig &config)
byte readMem(word address, EmuTime::param time) override
Read a byte from a location at a certain time from this device.
void serialize(Archive &ar, unsigned version)
void reset(EmuTime::param time) override
This method is called on reset.
byte peekIO(word port, EmuTime::param time) const override
Read a byte from a given IO port.
Y8950Periphery & createPeriphery(const std::string &soundDeviceName)
Creates a periphery object for this MSXAudio cartridge.
An MSXDevice is an emulated hardware component connected to the bus of the emulated MSX.
const DeviceConfig & getDeviceConfig2() const
virtual const std::string & getName() const
Returns a human-readable name for this device.
EmuTime::param getCurrentTime() const
static std::unique_ptr< Y8950Periphery > create(MSXAudio &audio, const DeviceConfig &config, const std::string &soundDeviceName)
Models the 4 general purpose I/O pins on the Y8950 (controlled by registers r#18 and r#19)
void reset(EmuTime::param time)
uint8_t peekReg(uint8_t rg, EmuTime::param time) const
uint8_t peekStatus(EmuTime::param time) const
uint8_t readStatus(EmuTime::param time) const
void writeReg(uint8_t rg, uint8_t data, EmuTime::param time)
uint8_t readReg(uint8_t rg, EmuTime::param time)
This file implemented 3 utility functions:
uint16_t word
16 bit unsigned integer
#define INSTANTIATE_SERIALIZE_METHODS(CLASS)