12 , romBlockDebug(*this)
13 , rom(
getName() +
" ROM",
"rom", config)
14 , internalBank(nullptr)
15 , ideRegsEnabled(false)
37 device[0]->reset(time);
38 device[1]->reset(time);
43 if (ideRegsEnabled && ((address & 0x3E00) == 0x3C00)) {
45 if ((address & 1) == 0) {
46 return readDataLow(time);
48 return readDataHigh(time);
51 if (ideRegsEnabled && ((address & 0x3F00) == 0x3E00)) {
53 return readReg(address & 0xF, time);
55 if ((0x4000 <= address) && (address < 0x8000)) {
57 return internalBank[address & 0x3FFF];
65 if (ideRegsEnabled && ((start & 0x3E00) == 0x3C00)) {
68 if (ideRegsEnabled && ((start & 0x3F00) == 0x3E00)) {
71 if ((0x4000 <= start) && (start < 0x8000)) {
72 return &internalBank[start & 0x3FFF];
79 if ((address & 0xBF04) == 0x0104) {
84 if (ideRegsEnabled && ((address & 0x3E00) == 0x3C00)) {
86 if ((address & 1) == 0) {
89 writeDataHigh(value, time);
93 if (ideRegsEnabled && ((address & 0x3F00) == 0x3E00)) {
95 writeReg(address & 0xF, value, time);
101 byte SunriseIDE::getBank()
const
104 if (bank >= (rom.
getSize() / 0x4000)) {
105 bank &= ((rom.
getSize() / 0x4000) - 1);
110 void SunriseIDE::writeControl(
byte value)
113 if (ideRegsEnabled != (control & 1)) {
114 ideRegsEnabled = control & 1;
121 byte bank = getBank();
122 if (internalBank != &rom[0x4000 * bank]) {
123 internalBank = &rom[0x4000 * bank];
128 byte SunriseIDE::readDataLow(EmuTime::param time)
130 word temp = readData(time);
131 readLatch = temp >> 8;
134 byte SunriseIDE::readDataHigh(EmuTime::param )
const
138 word SunriseIDE::readData(EmuTime::param time)
140 return device[selectedDevice]->readData(time);
143 byte SunriseIDE::readReg(
nibble reg, EmuTime::param time)
159 return readData(time) & 0xFF;
161 byte result = device[selectedDevice]->readReg(reg, time);
164 result |= selectedDevice ? 0x10 : 0x00;
171 void SunriseIDE::writeDataLow(
byte value)
175 void SunriseIDE::writeDataHigh(
byte value, EmuTime::param time)
177 word temp = (value << 8) | writeLatch;
178 writeData(temp, time);
180 void SunriseIDE::writeData(
word value, EmuTime::param time)
182 device[selectedDevice]->writeData(value, time);
185 void SunriseIDE::writeReg(
nibble reg,
byte value, EmuTime::param time)
188 if ((reg == 14) && !(value & 0x04)) {
195 writeData((value << 8) | value, time);
197 if ((reg == 14) && (value & 0x04)) {
200 device[0]->reset(time);
201 device[1]->reset(time);
204 selectedDevice = (value & 0x10) ? 1 : 0;
206 device[selectedDevice]->writeReg(reg, value, time);
212 template<
typename Archive>
215 ar.template serializeBase<MSXDevice>(*
this);
216 ar.serializePolymorphic(
"master", *device[0]);
217 ar.serializePolymorphic(
"slave", *device[1]);
218 ar.serialize(
"readLatch", readLatch,
219 "writeLatch", writeLatch,
220 "selectedDevice", selectedDevice,
222 "softReset", softReset);
224 if constexpr (Archive::IS_LOADER) {
226 writeControl(control);
233 SunriseIDE::Blocks::Blocks(
SunriseIDE& device)
238 byte SunriseIDE::Blocks::read(
unsigned address)
240 if ((address < 0x4000) || (address >= 0x8000))
return 255;
242 return ide.getBank();
const XMLElement * findChild(std::string_view name) const
An MSXDevice is an emulated hardware component connected to the bus of the emulated MSX.
void invalidateDeviceRCache()
static byte unmappedRead[0x10000]
EmuTime::param getCurrentTime() const
void reset(EmuTime::param time) override
This method is called on reset.
SunriseIDE(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 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.
void powerUp(EmuTime::param time) override
This method is called when MSX is powered up.
byte readMem(word address, EmuTime::param time) override
Read a byte from a location at a certain time from this device.
constexpr uint8_t reverseByte(uint8_t a)
Reverse the bits in a byte.
std::unique_ptr< IDEDevice > create(const DeviceConfig &config)
std::string getName(KeyCode keyCode)
Translate key code to key name.
This file implemented 3 utility functions:
uint8_t nibble
4 bit integer
REGISTER_MSXDEVICE(ChakkariCopy, "ChakkariCopy")
uint16_t word
16 bit unsigned integer
#define OUTER(type, member)
#define INSTANTIATE_SERIALIZE_METHODS(CLASS)