openMSX
TalentTDC600.cc
Go to the documentation of this file.
1 // For some documentation see:
2 // https://www.msx.org/wiki/Talent_TDC-600
3 // https://msxmakers.design.blog/proyectos/proyecto-tdc-600/tdc-600-como-funciona/
4 
5 #include "TalentTDC600.hh"
6 #include "serialize.hh"
7 
8 namespace openmsx {
9 
11  : MSXFDC(config)
12  , controller(getScheduler(), reinterpret_cast<DiskDrive**>(drives),
13  getCliComm(), getCurrentTime())
14 {
16 }
17 
18 void TalentTDC600::reset(EmuTime::param time)
19 {
20  controller.reset(time);
21 }
22 
23 byte TalentTDC600::readMem(word address, EmuTime::param time)
24 {
25  if (0x4000 <= address && address < 0x8000) {
26  return MSXFDC::readMem(address, time);
27  }
28  address &= 0x7fff;
29  if (address < 0x1000) {
30  if (address & 1) {
31  return controller.readDataPort(time);
32  } else {
33  return controller.readStatus(time);
34  }
35  }
36  return 0xff;
37 }
38 
39 byte TalentTDC600::peekMem(word address, EmuTime::param time) const
40 {
41  if (0x4000 <= address && address < 0x8000) {
42  return MSXFDC::peekMem(address, time);
43  }
44  address &= 0x7fff;
45  if (address < 0x1000) {
46  if (address & 1) {
47  return controller.peekDataPort(time);
48  } else {
49  return controller.peekStatus();
50  }
51  }
52  return 0xff;
53 }
54 
55 const byte* TalentTDC600::getReadCacheLine(word start) const
56 {
57  if (0x4000 <= start && start < 0x8000) {
58  return MSXFDC::getReadCacheLine(start);
59  }
60  start &= 0x7fff;
61  if (start < 0x1000) {
62  return nullptr;
63  }
64  return unmappedRead;
65 }
66 
67 void TalentTDC600::writeMem(word address, byte value, EmuTime::param time)
68 {
69  address &= 0x7fff;
70  if (address < 0x1000) {
71  if (address & 1) {
72  controller.writeDataPort(value, time);
73  }
74  } else if (address < 0x2000) {
75  controller.writeControlReg0(value, time);
76  }
77 }
78 
80 {
81  address &= 0x7fff;
82  if (address < 0x2000) {
83  return nullptr;
84  }
85  return unmappedWrite;
86 }
87 
88 
89 template<typename Archive>
90 void TalentTDC600::serialize(Archive& ar, unsigned /*version*/)
91 {
92  ar.template serializeBase<MSXFDC>(*this);
93  ar.serialize("TC8566AF", controller);
94 }
97 
98 } // namespace openmsx
This (abstract) class defines the DiskDrive interface.
Definition: DiskDrive.hh:13
static byte unmappedRead[0x10000]
Definition: MSXDevice.hh:301
EmuTime::param getCurrentTime() const
Definition: MSXDevice.cc:126
static byte unmappedWrite[0x10000]
Definition: MSXDevice.hh:302
byte peekMem(word address, EmuTime::param time) const override
Read a byte from a given memory location.
Definition: MSXFDC.cc:54
const byte * getReadCacheLine(word start) const override
Test that the memory in the interval [start, start + CacheLine::SIZE) is cacheable for reading.
Definition: MSXFDC.cc:59
byte readMem(word address, EmuTime::param time) override
Read a byte from a location at a certain time from this device.
Definition: MSXFDC.cc:49
void writeDataPort(byte value, EmuTime::param time)
Definition: TC8566AF.cc:335
byte peekDataPort(EmuTime::param time) const
Definition: TC8566AF.cc:143
byte readDataPort(EmuTime::param time)
Definition: TC8566AF.cc:155
byte readStatus(EmuTime::param time)
Definition: TC8566AF.cc:130
void reset(EmuTime::param time)
Definition: TC8566AF.cc:83
void writeControlReg0(byte data, EmuTime::param time)
Definition: TC8566AF.cc:315
byte peekStatus() const
Definition: TC8566AF.cc:123
TalentTDC600(const DeviceConfig &config)
Definition: TalentTDC600.cc:10
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.
Definition: TalentTDC600.cc:67
void reset(EmuTime::param time) override
This method is called on reset.
Definition: TalentTDC600.cc:18
const byte * getReadCacheLine(word start) const override
Test that the memory in the interval [start, start + CacheLine::SIZE) is cacheable for reading.
Definition: TalentTDC600.cc:55
byte * getWriteCacheLine(word address) const override
Test that the memory in the interval [start, start + CacheLine::SIZE) is cacheable for writing.
Definition: TalentTDC600.cc:79
byte peekMem(word address, EmuTime::param time) const override
Read a byte from a given memory location.
Definition: TalentTDC600.cc:39
byte readMem(word address, EmuTime::param time) override
Read a byte from a location at a certain time from this device.
Definition: TalentTDC600.cc:23
void serialize(Archive &ar, unsigned version)
Definition: TalentTDC600.cc:90
This file implemented 3 utility functions:
Definition: Autofire.cc:9
REGISTER_MSXDEVICE(ChakkariCopy, "ChakkariCopy")
uint16_t word
16 bit unsigned integer
Definition: openmsx.hh:29
#define INSTANTIATE_SERIALIZE_METHODS(CLASS)
Definition: serialize.hh:998