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
8namespace openmsx {
9
11 : MSXFDC(config)
12 , controller(getScheduler(), drives, getCliComm(), getCurrentTime())
13{
15}
16
17void TalentTDC600::reset(EmuTime::param time)
18{
19 controller.reset(time);
20}
21
22byte TalentTDC600::readMem(word address, EmuTime::param 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
38byte TalentTDC600::peekMem(word address, EmuTime::param 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
54const byte* TalentTDC600::getReadCacheLine(word 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
66void TalentTDC600::writeMem(word address, byte value, EmuTime::param 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
79{
80 address &= 0x7fff;
81 if (address < 0x2000) {
82 return nullptr;
83 }
84 return unmappedWrite.data();
85}
86
87
88template<typename Archive>
89void TalentTDC600::serialize(Archive& ar, unsigned /*version*/)
90{
91 ar.template serializeBase<MSXFDC>(*this);
92 ar.serialize("TC8566AF", controller);
93}
96
97} // namespace openmsx
#define REGISTER_MSXDEVICE(CLASS, NAME)
Definition MSXDevice.hh:356
static std::array< byte, 0x10000 > unmappedRead
Definition MSXDevice.hh:306
static std::array< byte, 0x10000 > unmappedWrite
Definition MSXDevice.hh:307
EmuTime::param getCurrentTime() const
Definition MSXDevice.cc:125
byte peekMem(word address, EmuTime::param time) const override
Read a byte from a given memory location.
Definition MSXFDC.cc:55
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:60
byte readMem(word address, EmuTime::param time) override
Read a byte from a location at a certain time from this device.
Definition MSXFDC.cc:50
uint8_t peekStatus() const
Definition TC8566AF.cc:116
void writeControlReg0(uint8_t value, EmuTime::param time)
Definition TC8566AF.cc:318
void writeDataPort(uint8_t value, EmuTime::param time)
Definition TC8566AF.cc:338
uint8_t peekDataPort(EmuTime::param time) const
Definition TC8566AF.cc:139
void reset(EmuTime::param time)
Definition TC8566AF.cc:77
uint8_t readDataPort(EmuTime::param time)
Definition TC8566AF.cc:151
uint8_t readStatus(EmuTime::param time)
Definition TC8566AF.cc:123
TalentTDC600(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.
void reset(EmuTime::param time) override
This method is called on reset.
const byte * getReadCacheLine(word start) const override
Test that the memory in the interval [start, start + CacheLine::SIZE) is cacheable for reading.
byte peekMem(word address, EmuTime::param time) const override
Read a byte from a given memory location.
byte readMem(word address, EmuTime::param time) override
Read a byte from a location at a certain time from this device.
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)
This file implemented 3 utility functions:
Definition Autofire.cc:11
uint16_t word
16 bit unsigned integer
Definition openmsx.hh:29
#define INSTANTIATE_SERIALIZE_METHODS(CLASS)