18 YM2413::Debuggable::Debuggable(
19 MSXMotherBoard& motherBoard_,
const std::string& name_)
20 : SimpleDebuggable(motherBoard_, name_ +
" regs",
"MSX-MUSIC", 0x40)
24 byte YM2413::Debuggable::read(
unsigned address)
27 return ym2413.core->peekReg(address);
30 void YM2413::Debuggable::write(
unsigned address,
byte value, EmuTime::param time)
33 ym2413.pokeReg(address, value, time);
39 static std::unique_ptr<YM2413Core> createCore(
const DeviceConfig& config)
41 auto core = config.getChildData(
"ym2413-core",
"");
42 if (core ==
"Okazaki") {
43 return std::make_unique<YM2413Okazaki::YM2413>();
44 }
else if (core ==
"Burczynski") {
45 return std::make_unique<YM2413Burczynski::YM2413>();
46 }
else if (core ==
"NukeYKT") {
47 return std::make_unique<YM2413NukeYKT::YM2413>();
48 }
else if (core ==
"Original-NukeYKT") {
49 return std::make_unique<YM2413OriginalNukeYKT::YM2413>();
50 }
else if (core.empty()) {
54 if (config.getChildDataAsBool(
"alternative",
false)) {
55 return std::make_unique<YM2413Burczynski::YM2413>();
57 return std::make_unique<YM2413Okazaki::YM2413>();
60 throw MSXException(
"Unknown YM2413 core '", core,
61 "'. Must be one of 'Okazaki', 'Burczynski', 'NukeYKT', 'Original-NukeYKT'.");
64 constexpr
auto INPUT_RATE = unsigned(
cstd::round(YM2413Core::CLOCK_FREQ / 72.0));
68 , core(createCore(config))
69 , debuggable(config.getMotherBoard(),
getName())
90 auto offset = unsigned(18 * fractional);
91 assert(integral == 0);
94 core->writePort(port, value, offset);
100 core->pokeReg(reg, value);
103 void YM2413::setOutputRate(
unsigned hostSampleRate,
double speed)
106 core->setSpeed(speed);
109 void YM2413::generateChannels(
float** bufs,
unsigned num)
111 core->generateChannels(bufs, num);
114 float YM2413::getAmplificationFactorImpl()
const
116 return core->getAmplificationFactor();
120 template<
typename Archive>
123 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)
std::string getName(KeyCode keyCode)
Translate key code to key name.
This file implemented 3 utility functions:
#define OUTER(type, member)
#define INSTANTIATE_SERIALIZE_METHODS(CLASS)