29 #include "SystemRAMBank.h"
35 namespace libsidplayfp
44 virtual void setCpuPort(uint8_t state) =0;
45 virtual uint8_t getLastReadByte()
const =0;
46 virtual event_clock_t getPhi2Time()
const =0;
93 static event_clock_t
const C64_CPU6510_DATA_PORT_FALL_OFF_CYCLES = 350000;
94 static event_clock_t
const C64_CPU8500_DATA_PORT_FALL_OFF_CYCLES = 1500000;
99 event_clock_t dataSetClk;
110 isFallingOff =
false;
114 uint8_t readBit(event_clock_t phi2time)
116 if (isFallingOff && dataSetClk < phi2time)
124 void writeBit(event_clock_t phi2time, uint8_t value)
126 dataSetClk = phi2time + C64_CPU6510_DATA_PORT_FALL_OFF_CYCLES;
127 dataSet = value & (1 << Bit);
148 static bool const tape_sense =
false;
172 uint8_t procPortPins;
178 procPortPins = (procPortPins & ~dir) | (data & dir);
180 dataRead = (data | ~dir) & (procPortPins | 0x17);
182 pla.setCpuPort((data | ~dir) & 0x07);
184 if ((dir & 0x20) == 0)
188 if (tape_sense && (dir & 0x10) == 0)
213 uint8_t
peek(uint_least16_t address)
override
221 uint8_t retval = dataRead;
229 retval |= dataBit6.readBit(pla.getPhi2Time());
236 retval |= dataBit7.readBit(pla.getPhi2Time());
242 return ramBank.
peek(address);
246 void poke(uint_least16_t address, uint8_t value)
override
258 if ((dir & 0x40) && !(value & 0x40))
259 dataBit6.writeBit(pla.getPhi2Time(), data);
262 if ((dir & 0x80) && !(value & 0x80))
263 dataBit7.writeBit(pla.getPhi2Time(), data);
269 value = pla.getLastReadByte();
276 dataBit6.writeBit(pla.getPhi2Time(), value);
279 dataBit7.writeBit(pla.getPhi2Time(), value);
287 value = pla.getLastReadByte();
293 ramBank.
poke(address, value);