24[[nodiscard]]
static TurboRFDC::Type parseType(
const DeviceConfig& config)
26 auto ioRegs = config.getChildData(
"io_regs", {});
27 if (ioRegs ==
"7FF2") {
29 }
else if (ioRegs ==
"7FF8") {
31 }
else if (ioRegs.empty()) {
36 "Invalid 'io_regs' specification: expected one of "
37 "'7FF2' or '7FF8', but got: ", ioRegs);
43 , controller(getScheduler(), drives, getCliComm(), getCurrentTime())
44 , romBlockDebug(*this,
std::span{&bank, 1}, 0x4000, 0x4000, 14)
47 , type(parseType(config))
49 auto size =
rom->size();
50 if ((size % 0x4000) != 0) {
51 throw MSXException(
"TurboRFDC rom size must be a multiple of 16kB");
56 if ((size / 0x4000) > 256) {
65 controller.
reset(time);
71 if (0x3FF0 <= (address & 0x3FFF)) {
78 switch (address & 0xF) {
90 switch (address & 0xF) {
104 if (0x3FF0 <= (address & 0x3FFF)) {
108 switch (address & 0xF) {
109 case 0x0:
return bank;
126 switch (address & 0xF) {
131 switch (address & 0xF) {
141 case 0xC:
return 0xFC;
142 case 0xD:
return 0xFC;
143 case 0xE:
return 0xFF;
144 case 0xF:
return 0x3F;
145 default:
return 0xFF;
147 }
else if ((0x4000 <= address) && (address < 0x8000)) {
148 return memory[address & 0x3FFF];
158 }
else if ((0x4000 <= start) && (start < 0x8000)) {
159 return &memory[start & 0x3FFF];
167 EmuTime time = time_;
168 if (0x3FF0 <= (address & 0x3FFF)) {
172 if (address == 0x7FF0) {
176 switch (address & 0x3FFF) {
189 switch (address & 0x3FFF) {
204void TurboRFDC::setBank(
byte value)
207 bank = value & blockMask;
208 memory = subspan<0x4000>(*
rom, 0x4000 * bank);
222template<
typename Archive>
225 ar.template serializeBase<MSXFDC>(*
this);
226 ar.serialize(
"TC8566AF", controller,
228 if constexpr (Archive::IS_LOADER) {
#define REGISTER_MSXDEVICE(CLASS, NAME)
EmuTime waitCyclesR800(EmuTime::param time, unsigned cycles)
void invalidateDeviceRCache()
static std::array< byte, 0x10000 > unmappedRead
static std::array< byte, 0x10000 > unmappedWrite
EmuTime::param getCurrentTime() const
uint8_t peekStatus() const
void writeControlReg0(uint8_t value, EmuTime::param time)
void writeDataPort(uint8_t value, EmuTime::param time)
void writeControlReg1(uint8_t value, EmuTime::param time)
uint8_t peekDataPort(EmuTime::param time) const
void reset(EmuTime::param time)
uint8_t readDataPort(EmuTime::param time)
bool peekDiskChanged(unsigned driveNum) const
uint8_t readStatus(EmuTime::param time)
bool diskChanged(unsigned driveNum)
void reset(EmuTime::param time) override
This method is called on reset.
byte * getWriteCacheLine(word address) override
Test that the memory in the interval [start, start + CacheLine::SIZE) is cacheable for writing.
void serialize(Archive &ar, unsigned version)
byte peekMem(word address, EmuTime::param time) const override
Read a byte from a given memory location.
TurboRFDC(const DeviceConfig &config)
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.
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 file implemented 3 utility functions:
uint8_t byte
8 bit unsigned integer
uint16_t word
16 bit unsigned integer
constexpr To narrow_cast(From &&from) noexcept
constexpr auto subspan(Range &&range, size_t offset, size_t count=std::dynamic_extent)
#define INSTANTIATE_SERIALIZE_METHODS(CLASS)