openMSX
MSXCPU.hh
Go to the documentation of this file.
1 #ifndef MSXCPU_HH
2 #define MSXCPU_HH
3 
4 #include "CPU.hh"
5 #include "Observer.hh"
6 #include "EmuTime.hh"
7 #include "noncopyable.hh"
8 #include <memory>
9 
10 namespace openmsx {
11 
12 class MSXMotherBoard;
13 class MSXCPUInterface;
14 class BooleanSetting;
15 class Z80TYPE;
16 class R800TYPE;
17 template <typename T> class CPUCore;
18 class Setting;
19 class TimeInfoTopic;
20 class CPUFreqInfoTopic;
21 class MSXCPUDebuggable;
22 class TclCallback;
23 
24 class MSXCPU : private Observer<Setting>, private noncopyable
25 {
26 public:
28 
29  explicit MSXCPU(MSXMotherBoard& motherboard);
30  ~MSXCPU();
31 
36  void doReset(EmuTime::param time);
37 
41  void setActiveCPU(CPUType cpu);
42 
46  void setDRAMmode(bool dram);
47 
52  void updateVisiblePage(byte page, byte primarySlot, byte secondarySlot);
53 
59  void invalidateMemCache(word start, unsigned size);
60 
68  void raiseIRQ();
69 
76  void lowerIRQ();
77 
85  void raiseNMI();
86 
93  void lowerNMI();
94 
100  bool isM1Cycle(unsigned address) const;
101 
103  void exitCPULoopSync();
105  void exitCPULoopAsync();
106 
110  bool isR800Active();
111 
115  void setZ80Freq(unsigned freq);
116 
117  void setInterface(MSXCPUInterface* interf);
118 
119  void disasmCommand(const std::vector<TclObject>& tokens,
120  TclObject& result) const;
121 
122  // Pause
123  void setPaused(bool paused);
124 
125  void setNextSyncPoint(EmuTime::param time);
126 
127  void wait(EmuTime::param time);
128  void waitCycles(unsigned cycles);
129  void waitCyclesR800(unsigned cycles);
130 
131  template<typename Archive>
132  void serialize(Archive& ar, unsigned version);
133 
134 private:
135  // only for MSXMotherBoard
136  void execute(bool fastForward);
137  friend class MSXMotherBoard;
138 
146  EmuTime::param getCurrentTime() const;
147 
148  // Observer<Setting>
149  void update(const Setting& setting);
150 
151  MSXMotherBoard& motherboard;
152  const std::unique_ptr<BooleanSetting> traceSetting;
153  const std::unique_ptr<TclCallback> diHaltCallback;
154  const std::unique_ptr<CPUCore<Z80TYPE>> z80;
155  const std::unique_ptr<CPUCore<R800TYPE>> r800;
156 
157  CPU* activeCPU;
158  CPU* newCPU;
159  EmuTime reference;
160 
161  friend class TimeInfoTopic;
162  friend class MSXCPUDebuggable;
163  const std::unique_ptr<TimeInfoTopic> timeInfo;
164  const std::unique_ptr<CPUFreqInfoTopic> z80FreqInfo;
165  const std::unique_ptr<CPUFreqInfoTopic> r800FreqInfo;
166  const std::unique_ptr<MSXCPUDebuggable> debuggable;
167 };
168 
169 } // namespace openmsx
170 
171 #endif