| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
#include "TalentTDC600.hh" |
| 6 |
#include "serialize.hh" |
| 7 |
|
| 8 |
namespace openmsx { |
| 9 |
|
| 10 |
TalentTDC600::TalentTDC600(DeviceConfig& config) |
| 11 |
: MSXFDC(config) |
| 12 |
, controller(getScheduler(), drives, getCliComm(), getCurrentTime()) |
| 13 |
{ |
| 14 |
reset(getCurrentTime()); |
| 15 |
} |
| 16 |
|
| 17 |
void TalentTDC600::reset(EmuTime time) |
| 18 |
{ |
| 19 |
controller.reset(time); |
| 20 |
} |
| 21 |
|
| 22 |
byte TalentTDC600::readMem(uint16_t address, EmuTime time) |
| 23 |
{ |
| 24 |
if (0x4000 <= address && address < 0x8000) { |
| 25 |
return MSXFDC::readMem(address, time); |
| 26 |
} |
| 27 |
address &= 0x7fff; |
| 28 |
if (address < 0x1000) { |
| 29 |
if (address & 1) { |
| 30 |
return controller.readDataPort(time); |
| 31 |
} else { |
| 32 |
return controller.readStatus(time); |
| 33 |
} |
| 34 |
} |
| 35 |
return 0xff; |
| 36 |
} |
| 37 |
|
| 38 |
byte TalentTDC600::peekMem(uint16_t address, EmuTime time) const |
| 39 |
{ |
| 40 |
if (0x4000 <= address && address < 0x8000) { |
| 41 |
return MSXFDC::peekMem(address, time); |
| 42 |
} |
| 43 |
address &= 0x7fff; |
| 44 |
if (address < 0x1000) { |
| 45 |
if (address & 1) { |
| 46 |
return controller.peekDataPort(time); |
| 47 |
} else { |
| 48 |
return controller.peekStatus(); |
| 49 |
} |
| 50 |
} |
| 51 |
return 0xff; |
| 52 |
} |
| 53 |
|
| 54 |
const byte* TalentTDC600::getReadCacheLine(uint16_t start) const |
| 55 |
{ |
| 56 |
if (0x4000 <= start && start < 0x8000) { |
| 57 |
return MSXFDC::getReadCacheLine(start); |
| 58 |
} |
| 59 |
start &= 0x7fff; |
| 60 |
if (start < 0x1000) { |
| 61 |
return nullptr; |
| 62 |
} |
| 63 |
return unmappedRead.data(); |
| 64 |
} |
| 65 |
|
| 66 |
void TalentTDC600::writeMem(uint16_t address, byte value, EmuTime time) |
| 67 |
{ |
| 68 |
address &= 0x7fff; |
| 69 |
if (address < 0x1000) { |
| 70 |
if (address & 1) { |
| 71 |
controller.writeDataPort(value, time); |
| 72 |
} |
| 73 |
} else if (address < 0x2000) { |
| 74 |
controller.writeControlReg0(value, time); |
| 75 |
} |
| 76 |
} |
| 77 |
|
| 78 |
byte* TalentTDC600::getWriteCacheLine(uint16_t address) |
| 79 |
{ |
| 80 |
address &= 0x7fff; |
| 81 |
if (address < 0x2000) { |
| 82 |
return nullptr; |
| 83 |
} |
| 84 |
return unmappedWrite.data(); |
| 85 |
} |
| 86 |
|
| 87 |
|
| 88 |
template<typename Archive> |
| 89 |
void TalentTDC600::serialize(Archive& ar, unsigned ) |
| 90 |
{ |
| 91 |
ar.template serializeBase<MSXFDC>(*this); |
| 92 |
ar.serialize("TC8566AF", controller); |
| 93 |
} |
| 94 |
INSTANTIATE_SERIALIZE_METHODS(TalentTDC600); |
| 95 |
REGISTER_MSXDEVICE(TalentTDC600, "TalentTDC600"); |
| 96 |
|
| 97 |
} |