15 ? std::optional<
Rom>(std::in_place,
getName() +
" ROM",
"rom", config, romId)
18 if (needROM && (
rom->getSize() == 0)) {
20 "Empty ROM not allowed for \"",
getName(),
"\".");
22 bool singleSided = config.
findChild(
"singlesided") !=
nullptr;
24 if ((0 > numDrives) || (numDrives >= 4)) {
25 throw MSXException(
"Invalid number of drives: ", numDrives);
28 const auto* styleEl = config.
findChild(
"connectionstyle");
29 bool signalsNeedMotorOn = !styleEl || (styleEl->getData() ==
"Philips");
32 for (; i < numDrives; ++i) {
33 drives[i] = std::make_unique<RealDrive>(
35 !singleSided, trackMode);
38 drives[i] = std::make_unique<DummyDrive>();
44 for (
auto& drive :
drives) {
45 drive->setMotor(
false, time);
61 return &(*rom)[start & 0x3FFF];
65 template<
typename Archive>
68 ar.template serializeBase<MSXDevice>(*
this);
74 char tag[7] = {
'd',
'r',
'i',
'v',
'e',
'X', 0 };
76 if (
auto* drive =
dynamic_cast<RealDrive*
>(drv.get())) {
77 tag[5] = char(
'a' + i);
78 ar.serialize(tag, *drive);
const XMLElement * findChild(std::string_view name) const
int getChildDataAsInt(std::string_view name, int defaultValue) const
static constexpr EmuDuration msec(unsigned x)
An MSXDevice is an emulated hardware component connected to the bus of the emulated MSX.
MSXMotherBoard & getMotherBoard() const
Get the mother board this device belongs to.
virtual const std::string & getName() const
Returns a human-readable name for this device.
std::unique_ptr< DiskDrive > drives[4]
byte peekMem(word address, EmuTime::param time) const override
Read a byte from a given memory location.
void powerDown(EmuTime::param time) override
This method is called when MSX is powered down.
MSXFDC(const DeviceConfig &config, const std::string &romId={}, bool needROM=true, DiskDrive::TrackMode trackMode=DiskDrive::TrackMode::NORMAL)
void serialize(Archive &ar, unsigned version)
const byte * getReadCacheLine(word start) const override
Test that the memory in the interval [start, start + CacheLine::SIZE) is cacheable for reading.
byte readMem(word address, EmuTime::param time) override
Read a byte from a location at a certain time from this device.
This class implements a real drive, single or double sided.
constexpr auto enumerate(Iterable &&iterable)
Heavily inspired by Nathan Reed's blog post: Python-Like enumerate() In C++17 http://reedbeta....
std::string getName(KeyCode keyCode)
Translate key code to key name.
This file implemented 3 utility functions:
uint16_t word
16 bit unsigned integer
#define INSTANTIATE_SERIALIZE_METHODS(CLASS)