22 if (!beginAddr || !endAddr || !
isEnabled())
return;
25 assert(*beginAddr < 0x100 && *endAddr < 0x100 && *beginAddr <= *endAddr);
26 for (
unsigned port = *beginAddr; port <= *endAddr; ++port) {
28 auto& dev = ios.emplace_back(std::make_unique<MSXWatchIODevice>(
31 dev->getDevicePtr() = devices[port];
32 devices[port] = dev.get();
39 if (!beginAddr || !endAddr || !
isEnabled())
return;
42 assert(*beginAddr < 0x100 && *endAddr < 0x100 && *beginAddr <= *endAddr);
43 for (
unsigned port = *beginAddr; port <= *endAddr; ++port) {
46 while (*prev != ios[port - *beginAddr].get()) {
47 prev = &checked_cast<MSXWatchIODevice*>(*prev)->getDevicePtr();
50 *prev = checked_cast<MSXWatchIODevice*>(*prev)->getDevicePtr();
56void WatchPoint::doReadCallback(
MSXMotherBoard& motherBoard,
unsigned port)
59 if (cpuInterface.isFastForward())
return;
63 auto& interp = reactor.getInterpreter();
68 auto keepAlive = shared_from_this();
71 cpuInterface.removeWatchPoint(keepAlive);
74 interp.unsetVariable(
"wp_last_address");
77void WatchPoint::doWriteCallback(MSXMotherBoard& motherBoard,
unsigned port,
unsigned value)
79 auto& cpuInterface = motherBoard.getCPUInterface();
80 if (cpuInterface.isFastForward())
return;
82 auto& reactor = motherBoard.getReactor();
83 auto& cliComm = reactor.getGlobalCliComm();
84 auto& interp = reactor.getInterpreter();
85 interp.setVariable(TclObject(
"wp_last_address"), TclObject(
int(port)));
86 interp.setVariable(TclObject(
"wp_last_value"), TclObject(
int(value)));
89 auto keepAlive = shared_from_this();
90 auto scopedBlock = motherBoard.getStateChangeDistributor().tempBlockNewEventsDuringReplay();
92 cpuInterface.removeWatchPoint(keepAlive);
95 interp.unsetVariable(
"wp_last_address");
96 interp.unsetVariable(
"wp_last_value");
109const std::string& MSXWatchIODevice::getName()
const
115byte MSXWatchIODevice::peekIO(
word port, EmuTime::param time)
const
118 return device->
peekIO(port, time);
121byte MSXWatchIODevice::readIO(
word port, EmuTime::param time)
127 return device->
readIO(port, time);
130void MSXWatchIODevice::writeIO(
word port,
byte value, EmuTime::param time)
135 device->
writeIO(port, value, time);
bool checkAndExecute(GlobalCliComm &cliComm, Interpreter &interp)
An MSXDevice is an emulated hardware component connected to the bus of the emulated MSX.
MSXMotherBoard & getMotherBoard() const
Get the mother board this device belongs to.
virtual void writeIO(word port, byte value, EmuTime::param time)
Write a byte to a given IO port at a certain time to this device.
virtual byte peekIO(word port, EmuTime::param time) const
Read a byte from a given IO port.
virtual const std::string & getName() const
Returns a human-readable name for this device.
virtual byte readIO(word port, EmuTime::param time)
Read a byte from an IO port at a certain time from this device.
const HardwareConfig * getMachineConfig() const
MSXCPUInterface & getCPUInterface()
StateChangeDistributor & getStateChangeDistributor()
MSXWatchIODevice(const HardwareConfig &hwConf, WatchPoint &wp)
GlobalCliComm & getGlobalCliComm()
auto tempBlockNewEventsDuringReplay()
void registerIOWatch(MSXMotherBoard &motherBoard, std::span< MSXDevice *, 256 > devices)
void unregisterIOWatch(std::span< MSXDevice *, 256 > devices)
This file implemented 3 utility functions:
uint16_t word
16 bit unsigned integer
auto remove(ForwardRange &&range, const T &value)