openMSX
MSXMotherBoard.hh
Go to the documentation of this file.
1 #ifndef MSXMOTHERBOARD_HH
2 #define MSXMOTHERBOARD_HH
3 
4 #include "EmuTime.hh"
5 #include "serialize_meta.hh"
6 #include "string_ref.hh"
7 #include "openmsx.hh"
8 #include "noncopyable.hh"
9 #include "RecordedCommand.hh"
10 #include <memory>
11 
12 namespace openmsx {
13 
14 class Reactor;
15 class MSXDevice;
16 class HardwareConfig;
17 class CliComm;
18 class MSXCommandController;
19 class Scheduler;
20 class CartridgeSlotManager;
21 class MSXEventDistributor;
22 class StateChangeDistributor;
23 class RealTime;
24 class Debugger;
25 class MSXMixer;
26 class PluggingController;
27 class MSXCPU;
28 class MSXCPUInterface;
29 class PanasonicMemory;
30 class MSXDeviceSwitch;
31 class CassettePortInterface;
32 class JoystickPortIf;
33 class RenShaTurbo;
34 class LedStatus;
35 class ReverseManager;
36 class CommandController;
37 class InfoCommand;
38 class MSXMapperIO;
39 class VideoSourceSetting;
40 
41 class MSXMotherBoard : private noncopyable
42 {
43 public:
44  explicit MSXMotherBoard(Reactor& reactor);
46 
47  const std::string& getMachineID();
48 
53  bool execute();
54 
57  void fastForward(EmuTime::param time, bool fast);
58 
60  void exitCPULoopAsync();
61  void exitCPULoopSync();
62 
66  void pause();
67  void unpause();
68 
69  void powerUp();
70 
71  void activate(bool active);
72  bool isActive() const;
73  bool isFastForwarding() const;
74 
76 
77  const HardwareConfig* getMachineConfig() const;
78  void setMachineConfig(HardwareConfig* machineConfig);
79  bool isTurboR() const;
80 
81  std::string loadMachine(const std::string& machine);
82 
83  HardwareConfig* findExtension(string_ref extensionName);
84  std::string loadExtension(string_ref extensionName, string_ref slotname);
85  std::string insertExtension(string_ref name,
86  std::unique_ptr<HardwareConfig> extension);
87  void removeExtension(const HardwareConfig& extension);
88 
89  // The following classes are unique per MSX machine
100  MSXCPU& getCPU();
105  JoystickPortIf& getJoystickPort(unsigned port);
109  Reactor& getReactor();
111 
112  // convenience methods
115 
119 
123  void addDevice(MSXDevice& device);
124  void removeDevice(MSXDevice& device);
125 
133 
142  struct SharedStuff {
143  SharedStuff() : stuff(nullptr), counter(0) {}
144  void* stuff;
145  unsigned counter;
146  };
148 
153  void destroyMapperIO();
154 
162  std::string getUserName(const std::string& hwName);
163  void freeUserName(const std::string& hwName,
164  const std::string& userName);
165 
166  template<typename Archive>
167  void serialize(Archive& ar, unsigned version);
168 
169  class Impl;
170 private:
171 #if UNIQUE_PTR_BUG // see openmsx.hh
172  std::unique_ptr<Impl> pimpl2;
173  Impl* pimpl;
174 #else
175  std::unique_ptr<Impl> pimpl;
176 #endif
177  friend class Impl;
178 };
180 
181 class ExtCmd final : public RecordedCommand
182 {
183 public:
184  ExtCmd(MSXMotherBoard& motherBoard, string_ref commandName);
185  void execute(array_ref<TclObject> tokens, TclObject& result,
186  EmuTime::param time) override;
187  std::string help(const std::vector<std::string>& tokens) const override;
188  void tabCompletion(std::vector<std::string>& tokens) const override;
189 private:
190  MSXMotherBoard& motherBoard;
191  std::string commandName;
192 };
193 
194 } // namespace openmsx
195 
196 #endif
Contains the main loop of openMSX.
Definition: Reactor.hh:62
PluggingController & getPluggingController()
ExtCmd(MSXMotherBoard &motherBoard, string_ref commandName)
MSXCPUInterface & getCPUInterface()
unsigned char byte
8 bit unsigned integer
Definition: openmsx.hh:33
void pause()
Pause MSX machine.
void removeDevice(MSXDevice &device)
SharedStuff & getSharedStuff(string_ref name)
Commands that directly influence the MSX state should send and events so that they can be recorded by...
void freeUserName(const std::string &hwName, const std::string &userName)
This class implements a subset of the proposal for std::string_ref (proposed for the next c++ standar...
Definition: string_ref.hh:18
Central administration of Connectors and Pluggables.
void fastForward(EmuTime::param time, bool fast)
Run emulation until a certain time in fast forward mode.
void tabCompletion(std::vector< std::string > &tokens) const override
Attempt tab completion for this command.
CassettePortInterface & getCassettePort()
void execute(array_ref< TclObject > tokens, TclObject &result, EmuTime::param time) override
This is like the execute() method of the Command class, it only has an extra time parameter...
const HardwareConfig * getMachineConfig() const
MSXDevice * findDevice(string_ref name)
Find a MSXDevice by name.
bool execute()
Run emulation.
InfoCommand & getMachineInfoCommand()
This class implements a subset of the proposal for std::array_ref (proposed for the next c++ standard...
Definition: array_ref.hh:19
SERIALIZE_CLASS_VERSION(CassettePlayer, 2)
std::string loadMachine(const std::string &machine)
void setMachineConfig(HardwareConfig *machineConfig)
std::string help(const std::vector< std::string > &tokens) const override
Print help for this command.
HardwareConfig * findExtension(string_ref extensionName)
MSXEventDistributor & getMSXEventDistributor()
PanasonicMemory & getPanasonicMemory()
std::string insertExtension(string_ref name, std::unique_ptr< HardwareConfig > extension)
Thanks to enen for testing this on a real cartridge:
Definition: Autofire.cc:7
An MSXDevice is an emulated hardware component connected to the bus of the emulated MSX...
Definition: MSXDevice.hh:32
const std::string & getMachineID()
CommandController & getCommandController()
std::string getUserName(const std::string &hwName)
Keep track of which 'usernames' are in use.
MSXMotherBoard(Reactor &reactor)
bool isFastForwarding() const
JoystickPortIf & getJoystickPort(unsigned port)
StateChangeDistributor & getStateChangeDistributor()
CartridgeSlotManager & getSlotManager()
void removeExtension(const HardwareConfig &extension)
MSXCommandController & getMSXCommandController()
VideoSourceSetting & getVideoSource()
void activate(bool active)
MSXMapperIO * createMapperIO()
All memory mappers in one MSX machine share the same four (logical) memory mapper registers...
void serialize(Archive &ar, unsigned version)
std::string loadExtension(string_ref extensionName, string_ref slotname)
Ren-Sha Turbo is the autofire in several MSX 2+ models and in the MSX turbo R.
Definition: RenShaTurbo.hh:21
EmuTime::param getCurrentTime()
Convenience method: This is the same as getScheduler().getCurrentTime().
Based on boost::noncopyable, see boost documentation: http://www.boost.org/libs/utility.
Definition: noncopyable.hh:12
ReverseManager & getReverseManager()
void addDevice(MSXDevice &device)
All MSXDevices should be registered by the MotherBoard.
MSXDeviceSwitch & getDeviceSwitch()
RenShaTurbo & getRenShaTurbo()
void exitCPULoopAsync()
See CPU::exitCPULoopAsync().
Some MSX device parts are shared between several MSX devices (e.g.