openMSX
MSXWatchIODevice.hh
Go to the documentation of this file.
1 #ifndef MSXWATCHIODEVICE_HH
2 #define MSXWATCHIODEVICE_HH
3 
4 #include "MSXMultiDevice.hh"
5 #include "WatchPoint.hh"
6 #include <memory>
7 
8 namespace openmsx {
9 
10 class MSXWatchIODevice;
11 
12 class WatchIO final : public WatchPoint
13  , public std::enable_shared_from_this<WatchIO>
14 {
15 public:
16  WatchIO(MSXMotherBoard& motherboard,
17  WatchPoint::Type type,
18  unsigned beginAddr, unsigned endAddr,
19  TclObject command, TclObject condition,
20  bool once, unsigned newId = -1);
21 
22  MSXWatchIODevice& getDevice(byte port);
23 
24 private:
25  void doReadCallback(unsigned port);
26  void doWriteCallback(unsigned port, unsigned value);
27 
28  MSXMotherBoard& motherboard;
29  std::vector<std::unique_ptr<MSXWatchIODevice>> ios;
30 
31  friend class MSXWatchIODevice;
32 };
33 
34 class MSXWatchIODevice final : public MSXMultiDevice
35 {
36 public:
37  MSXWatchIODevice(const HardwareConfig& hwConf, WatchIO& watchIO);
38 
39  MSXDevice*& getDevicePtr() { return device; }
40 
41 private:
42  // MSXDevice
43  std::string getName() const override;
44  byte readIO(word port, EmuTime::param time) override;
45  byte peekIO(word port, EmuTime::param time) const override;
46  void writeIO(word port, byte value, EmuTime::param time) override;
47 
48  WatchIO& watchIO;
49  MSXDevice* device;
50 };
51 
52 } // namespace openmsx
53 
54 #endif
openmsx::MSXDevice
An MSXDevice is an emulated hardware component connected to the bus of the emulated MSX.
Definition: MSXDevice.hh:31
openmsx::MSXMultiDevice
Definition: MSXMultiDevice.hh:8
openmsx::WatchPoint
Base class for CPU breakpoints.
Definition: WatchPoint.hh:13
MSXMultiDevice.hh
WatchPoint.hh
openmsx::WatchIO::WatchIO
WatchIO(MSXMotherBoard &motherboard, WatchPoint::Type type, unsigned beginAddr, unsigned endAddr, TclObject command, TclObject condition, bool once, unsigned newId=-1)
Definition: MSXWatchIODevice.cc:14
openmsx::WatchPoint::Type
Type
Definition: WatchPoint.hh:16
openmsx::MSXMotherBoard
Definition: MSXMotherBoard.hh:59
openmsx::MSXWatchIODevice
Definition: MSXWatchIODevice.hh:34
openmsx::MSXWatchIODevice::MSXWatchIODevice
MSXWatchIODevice(const HardwareConfig &hwConf, WatchIO &watchIO)
Definition: MSXWatchIODevice.cc:78
openmsx::word
uint16_t word
16 bit unsigned integer
Definition: openmsx.hh:29
openmsx::WatchIO
Definition: MSXWatchIODevice.hh:12
openmsx::MSXWatchIODevice::getDevicePtr
MSXDevice *& getDevicePtr()
Definition: MSXWatchIODevice.hh:39
openmsx::HardwareConfig
Definition: HardwareConfig.hh:21
openmsx::TclObject
Definition: TclObject.hh:21
openmsx
Thanks to enen for testing this on a real cartridge:
Definition: Autofire.cc:5
openmsx::WatchIO::getDevice
MSXWatchIODevice & getDevice(byte port)
Definition: MSXWatchIODevice.cc:28