15 config.getChildDataAsInt(
"sampleram", 256) * 1024,
16 getCurrentTime(), *this)
17 , dacValue(0x80), dacEnabled(false)
21 if (cmp(type,
"philips")) {
22 dac = std::make_unique<DACSound8U>(
23 getName() +
" 8-bit DAC",
"MSX-AUDIO 8-bit DAC",
58 if ((port & 0xE8) == 0x08) {
62 return (port & 1) ? y8950.
readReg(registerLatch, time)
69 if ((port & 0xE8) == 0x08) {
73 return (port & 1) ? y8950.
peekReg(registerLatch, time)
80 if ((port & 0xE8) == 0x08) {
84 dac->writeDAC(dacValue, time);
86 }
else if ((port & 0x01) == 0) {
88 registerLatch = value;
91 y8950.
writeReg(registerLatch, value, time);
97 return periphery->readMem(address, time);
101 return periphery->peekMem(address, time);
105 periphery->writeMem(address, value, time);
109 return periphery->getReadCacheLine(start);
113 return periphery->getWriteCacheLine(start);
116 void MSXAudio::enableDAC(
bool enable, EmuTime::param time)
118 if ((dacEnabled != enable) && dac) {
120 byte value = dacEnabled ? dacValue : 0x80;
121 dac->writeDAC(value, time);
125 template<
typename Archive>
128 ar.serializePolymorphic(
"periphery", *periphery);
129 ar.serialize(
"Y8950", y8950,
130 "registerLatch", registerLatch,
131 "dacValue", dacValue,
132 "dacEnabled", dacEnabled);
134 if constexpr (Archive::IS_LOADER) {
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 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 * getWriteCacheLine(word start) const override
Test that the memory in the interval [start, start + CacheLine::SIZE) is cacheable for writing.
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)
byte readStatus(EmuTime::param time) const
byte peekReg(byte rg, EmuTime::param time) const
void writeReg(byte rg, byte data, EmuTime::param time)
byte readReg(byte rg, EmuTime::param time)
byte peekStatus(EmuTime::param time) const
std::string getName(KeyCode keyCode)
Translate key code to key name.
This file implemented 3 utility functions:
REGISTER_MSXDEVICE(ChakkariCopy, "ChakkariCopy")
uint16_t word
16 bit unsigned integer
#define INSTANTIATE_SERIALIZE_METHODS(CLASS)