20 MSXMotherBoard& motherBoard_,
const std::string& name_)
21 : SimpleDebuggable(motherBoard_, name_ +
" regs",
"MSX-MUSIC", 0x40)
25byte YM2413::Debuggable::read(
unsigned address)
27 const auto& ym2413 =
OUTER(YM2413, debuggable);
28 return ym2413.core->peekReg(narrow<uint8_t>(address));
31void YM2413::Debuggable::write(
unsigned address,
byte value, EmuTime::param time)
33 auto& ym2413 =
OUTER(YM2413, debuggable);
34 ym2413.pokeReg(narrow<uint8_t>(address), value, time);
40static std::unique_ptr<YM2413Core> createCore(
const DeviceConfig& config)
42 auto core = config.getChildData(
"ym2413-core",
"");
43 if (core ==
"Okazaki") {
44 return std::make_unique<YM2413Okazaki::YM2413>();
45 }
else if (core ==
"Burczynski") {
46 return std::make_unique<YM2413Burczynski::YM2413>();
47 }
else if (core ==
"NukeYKT") {
48 return std::make_unique<YM2413NukeYKT::YM2413>();
49 }
else if (core ==
"Original-NukeYKT") {
50 return std::make_unique<YM2413OriginalNukeYKT::YM2413>();
51 }
else if (core.empty()) {
55 if (config.getChildDataAsBool(
"alternative",
false)) {
56 return std::make_unique<YM2413Burczynski::YM2413>();
58 return std::make_unique<YM2413Okazaki::YM2413>();
61 throw MSXException(
"Unknown YM2413 core '", core,
62 "'. Must be one of 'Okazaki', 'Burczynski', 'NukeYKT', 'Original-NukeYKT'.");
65static constexpr auto INPUT_RATE = unsigned(
cstd::round(YM2413Core::CLOCK_FREQ / 72.0));
67YM2413::YM2413(
const std::string& name_,
const DeviceConfig& config)
69 , core(createCore(config))
70 , debuggable(config.getMotherBoard(), getName())
91 auto offset = narrow_cast<int>(18 * fractional);
92 assert(integral == 0);
96 core->writePort(port, value, offset);
102 core->pokeReg(reg, value);
105void YM2413::setOutputRate(
unsigned hostSampleRate,
double speed)
108 core->setSpeed(speed);
111void YM2413::generateChannels(std::span<float*> bufs,
unsigned num)
113 assert(bufs.size() == 9 + 5);
114 core->generateChannels(bufs.first<9 + 5>(), num);
117float YM2413::getAmplificationFactorImpl()
const
119 return core->getAmplificationFactor();
123template<
typename Archive>
126 ar.serializePolymorphic(
"ym2413", *core);
IntegralFractional getTicksTillAsIntFloat(EmuTime::param e) const
DynamicClock & getEmuClock()
void setOutputRate(unsigned hostSampleRate, double speed) override
When a SoundDevice registers itself with the Mixer, the Mixer sets the required sampleRate through th...
void updateStream(EmuTime::param time)
void unregisterSound()
Unregisters this sound device with the Mixer.
void registerSound(const DeviceConfig &config)
Registers this sound device with the Mixer.
void pokeReg(byte reg, byte value, EmuTime::param time)
void writePort(bool port, byte value, EmuTime::param time)
void serialize(Archive &ar, unsigned version)
void reset(EmuTime::param time)
constexpr double round(double x)
This file implemented 3 utility functions:
#define OUTER(type, member)
#define INSTANTIATE_SERIALIZE_METHODS(CLASS)