openMSX
DeviceFactory.cc
Go to the documentation of this file.
1 #include "DeviceFactory.hh"
2 #include "XMLElement.hh"
3 #include "DeviceConfig.hh"
4 #include "ChakkariCopy.hh"
5 #include "FraelSwitchableROM.hh"
6 #include "MSXRam.hh"
7 #include "MSXPPI.hh"
8 #include "SVIPPI.hh"
9 #include "VDP.hh"
10 #include "MSXE6Timer.hh"
11 #include "MSXFacMidiInterface.hh"
12 #include "MSXHiResTimer.hh"
14 #include "MSXTurboRPause.hh"
15 #include "MSXTurboRPCM.hh"
16 #include "MSXS1985.hh"
17 #include "MSXS1990.hh"
18 #include "ColecoJoystickIO.hh"
19 #include "ColecoSuperGameModule.hh"
20 #include "MSXPSG.hh"
21 #include "SVIPSG.hh"
22 #include "SNPSG.hh"
23 #include "MSXMusic.hh"
24 #include "MSXFmPac.hh"
25 #include "MSXAudio.hh"
26 #include "MSXMoonSound.hh"
27 #include "MSXOPL3Cartridge.hh"
28 #include "MSXYamahaSFG.hh"
29 #include "MusicModuleMIDI.hh"
30 #include "JVCMSXMIDI.hh"
31 #include "MSXKanji.hh"
32 #include "MSXBunsetsu.hh"
33 #include "MSXMemoryMapper.hh"
34 #include "MegaFlashRomSCCPlusSD.hh"
35 #include "MusicalMemoryMapper.hh"
36 #include "Carnivore2.hh"
37 #include "PanasonicRam.hh"
38 #include "MSXRTC.hh"
39 #include "PasswordCart.hh"
40 #include "RomFactory.hh"
41 #include "MSXPrinterPort.hh"
42 #include "SVIPrinterPort.hh"
43 #include "MSXSCCPlusCart.hh"
44 #include "PhilipsFDC.hh"
45 #include "MicrosolFDC.hh"
46 #include "AVTFDC.hh"
47 #include "NationalFDC.hh"
48 #include "VictorFDC.hh"
49 #include "SanyoFDC.hh"
50 #include "ToshibaFDC.hh"
51 #include "SpectravideoFDC.hh"
52 #include "TurboRFDC.hh"
53 #include "SVIFDC.hh"
54 #include "YamahaFDC.hh"
55 #include "SunriseIDE.hh"
56 #include "BeerIDE.hh"
57 #include "GoudaSCSI.hh"
58 #include "MegaSCSI.hh"
59 #include "ESE_RAM.hh"
60 #include "ESE_SCC.hh"
61 #include "MSXMatsushita.hh"
63 #include "MSXCielTurbo.hh"
64 #include "MSXKanji12.hh"
65 #include "MSXMidi.hh"
66 #include "MSXRS232.hh"
67 #include "MSXMegaRam.hh"
68 #include "MSXPac.hh"
69 #include "MSXHBI55.hh"
70 #include "DebugDevice.hh"
71 #include "V9990.hh"
72 #include "Video9000.hh"
73 #include "ADVram.hh"
74 #include "NowindInterface.hh"
75 #include "MSXMirrorDevice.hh"
76 #include "DummyDevice.hh"
77 #include "MSXDeviceSwitch.hh"
78 #include "MSXMapperIO.hh"
79 #include "VDPIODelay.hh"
80 #include "SensorKid.hh"
81 #include "CliComm.hh"
82 #include "MSXException.hh"
83 #include "components.hh"
84 #include "one_of.hh"
85 #include <memory>
86 
87 #if COMPONENT_LASERDISC
88 #include "PioneerLDControl.hh"
89 #endif
90 
91 using std::make_unique;
92 using std::unique_ptr;
93 
94 namespace openmsx {
95 
96 static unique_ptr<MSXDevice> createWD2793BasedFDC(const DeviceConfig& conf)
97 {
98  const XMLElement* styleEl = conf.findChild("connectionstyle");
99  std::string type;
100  if (!styleEl) {
101  conf.getCliComm().printWarning(
102  "WD2793 as FDC type without a connectionstyle is "
103  "deprecated, please update your config file to use "
104  "WD2793 with connectionstyle Philips!");
105  type = "Philips";
106  } else {
107  type = styleEl->getData();
108  }
109  if (type == one_of("Philips", "Sony")) {
110  return make_unique<PhilipsFDC>(conf);
111  } else if (type == "Microsol") {
112  return make_unique<MicrosolFDC>(conf);
113  } else if (type == "AVT") {
114  return make_unique<AVTFDC>(conf);
115  } else if (type == "National") {
116  return make_unique<NationalFDC>(conf);
117  } else if (type == "Sanyo") {
118  return make_unique<SanyoFDC>(conf);
119  } else if (type == "Toshiba") {
120  return make_unique<ToshibaFDC>(conf);
121  } else if (type == "Spectravideo") {
122  return make_unique<SpectravideoFDC>(conf);
123  } else if (type == "Victor") {
124  return make_unique<VictorFDC>(conf);
125  } else if (type == "Yamaha") {
126  return make_unique<YamahaFDC>(conf);
127  }
128  throw MSXException("Unknown WD2793 FDC connection style ", type);
129 }
130 
131 unique_ptr<MSXDevice> DeviceFactory::create(const DeviceConfig& conf)
132 {
133  unique_ptr<MSXDevice> result;
134  const std::string& type = conf.getXML()->getName();
135  if (type == "PPI") {
136  result = make_unique<MSXPPI>(conf);
137  } else if (type == "SVIPPI") {
138  result = make_unique<SVIPPI>(conf);
139  } else if (type == "RAM") {
140  result = make_unique<MSXRam>(conf);
141  } else if (type == "VDP") {
142  result = make_unique<VDP>(conf);
143  } else if (type == "E6Timer") {
144  result = make_unique<MSXE6Timer>(conf);
145  } else if (type == "HiResTimer") {
146  result = make_unique<MSXHiResTimer>(conf);
147  } else if (type == one_of("ResetStatusRegister", "F4Device")) {
148  result = make_unique<MSXResetStatusRegister>(conf);
149  } else if (type == "TurboRPause") {
150  result = make_unique<MSXTurboRPause>(conf);
151  } else if (type == "TurboRPCM") {
152  result = make_unique<MSXTurboRPCM>(conf);
153  } else if (type == "S1985") {
154  result = make_unique<MSXS1985>(conf);
155  } else if (type == "S1990") {
156  result = make_unique<MSXS1990>(conf);
157  } else if (type == "ColecoJoystick") {
158  result = make_unique<ColecoJoystickIO>(conf);
159  } else if (type == "SuperGameModule") {
160  result = make_unique<ColecoSuperGameModule>(conf);
161  } else if (type == "PSG") {
162  result = make_unique<MSXPSG>(conf);
163  } else if (type == "SVIPSG") {
164  result = make_unique<SVIPSG>(conf);
165  } else if (type == "SNPSG") {
166  result = make_unique<SNPSG>(conf);
167  } else if (type == "MSX-MUSIC") {
168  result = make_unique<MSXMusic>(conf);
169  } else if (type == "MSX-MUSIC-WX") {
170  result = make_unique<MSXMusicWX>(conf);
171  } else if (type == "FMPAC") {
172  result = make_unique<MSXFmPac>(conf);
173  } else if (type == "MSX-AUDIO") {
174  result = make_unique<MSXAudio>(conf);
175  } else if (type == "MusicModuleMIDI") {
176  result = make_unique<MusicModuleMIDI>(conf);
177  } else if (type == "JVCMSXMIDI") {
178  result = make_unique<JVCMSXMIDI>(conf);
179  } else if (type == "FACMIDIInterface") {
180  result = make_unique<MSXFacMidiInterface>(conf);
181  } else if (type == "YamahaSFG") {
182  result = make_unique<MSXYamahaSFG>(conf);
183  } else if (type == "MoonSound") {
184  result = make_unique<MSXMoonSound>(conf);
185  } else if (type == "OPL3Cartridge") {
186  result = make_unique<MSXOPL3Cartridge>(conf);
187  } else if (type == "Kanji") {
188  result = make_unique<MSXKanji>(conf);
189  } else if (type == "Bunsetsu") {
190  result = make_unique<MSXBunsetsu>(conf);
191  } else if (type == "MemoryMapper") {
192  result = make_unique<MSXMemoryMapper>(conf);
193  } else if (type == "PanasonicRAM") {
194  result = make_unique<PanasonicRam>(conf);
195  } else if (type == "RTC") {
196  result = make_unique<MSXRTC>(conf);
197  } else if (type == "PasswordCart") {
198  result = make_unique<PasswordCart>(conf);
199  } else if (type == "ROM") {
200  result = RomFactory::create(conf);
201  } else if (type == "PrinterPort") {
202  result = make_unique<MSXPrinterPort>(conf);
203  } else if (type == "SVIPrinterPort") {
204  result = make_unique<SVIPrinterPort>(conf);
205  } else if (type == "SCCplus") { // Note: it's actually called SCC-I
206  result = make_unique<MSXSCCPlusCart>(conf);
207  } else if (type == one_of("WD2793", "WD1770")) {
208  result = createWD2793BasedFDC(conf);
209  } else if (type == "Microsol") {
210  conf.getCliComm().printWarning(
211  "Microsol as FDC type is deprecated, please update "
212  "your config file to use WD2793 with connectionstyle "
213  "Microsol!");
214  result = make_unique<MicrosolFDC>(conf);
215  } else if (type == "MB8877A") {
216  conf.getCliComm().printWarning(
217  "MB8877A as FDC type is deprecated, please update your "
218  "config file to use WD2793 with connectionstyle National!");
219  result = make_unique<NationalFDC>(conf);
220  } else if (type == "TC8566AF") {
221  result = make_unique<TurboRFDC>(conf);
222  } else if (type == "SVIFDC") {
223  result = make_unique<SVIFDC>(conf);
224  } else if (type == "BeerIDE") {
225  result = make_unique<BeerIDE>(conf);
226  } else if (type == "SunriseIDE") {
227  result = make_unique<SunriseIDE>(conf);
228  } else if (type == "GoudaSCSI") {
229  result = make_unique<GoudaSCSI>(conf);
230  } else if (type == "MegaSCSI") {
231  result = make_unique<MegaSCSI>(conf);
232  } else if (type == "ESERAM") {
233  result = make_unique<ESE_RAM>(conf);
234  } else if (type == "WaveSCSI") {
235  result = make_unique<ESE_SCC>(conf, true);
236  } else if (type == "ESESCC") {
237  result = make_unique<ESE_SCC>(conf, false);
238  } else if (type == "Matsushita") {
239  result = make_unique<MSXMatsushita>(conf);
240  } else if (type == "VictorHC9xSystemControl") {
241  result = make_unique<MSXVictorHC9xSystemControl>(conf);
242  } else if (type == "CielTurbo") {
243  result = make_unique<MSXCielTurbo>(conf);
244  } else if (type == "Kanji12") {
245  result = make_unique<MSXKanji12>(conf);
246  } else if (type == "MSX-MIDI") {
247  result = make_unique<MSXMidi>(conf);
248  } else if (type == "MSX-RS232") {
249  result = make_unique<MSXRS232>(conf);
250  } else if (type == "MegaRam") {
251  result = make_unique<MSXMegaRam>(conf);
252  } else if (type == "PAC") {
253  result = make_unique<MSXPac>(conf);
254  } else if (type == "HBI55") {
255  result = make_unique<MSXHBI55>(conf);
256  } else if (type == "DebugDevice") {
257  result = make_unique<DebugDevice>(conf);
258  } else if (type == "V9990") {
259  result = make_unique<V9990>(conf);
260  } else if (type == "Video9000") {
261  result = make_unique<Video9000>(conf);
262  } else if (type == "ADVram") {
263  result = make_unique<ADVram>(conf);
264  } else if (type == "PioneerLDControl") {
265 #if COMPONENT_LASERDISC
266  result = make_unique<PioneerLDControl>(conf);
267 #else
268  throw MSXException("Laserdisc component not compiled in");
269 #endif
270  } else if (type == "Nowind") {
271  result = make_unique<NowindInterface>(conf);
272  } else if (type == "Mirror") {
273  result = make_unique<MSXMirrorDevice>(conf);
274  } else if (type == "SensorKid") {
275  result = make_unique<SensorKid>(conf);
276  } else if (type == "FraelSwitchableROM") {
277  result = make_unique<FraelSwitchableROM>(conf);
278  } else if (type == "ChakkariCopy") {
279  result = make_unique<ChakkariCopy>(conf);
280  } else if (type == "MegaFlashRomSCCPlusSD") {
281  result = make_unique<MegaFlashRomSCCPlusSD>(conf);
282  } else if (type == "MusicalMemoryMapper") {
283  result = make_unique<MusicalMemoryMapper>(conf);
284  } else if (type == "Carnivore2") {
285  result = make_unique<Carnivore2>(conf);
286  } else if (type == "T9769") {
287  // Ignore for now. We might want to create a real device for it later.
288  } else {
289  throw MSXException("Unknown device \"", type,
290  "\" specified in configuration");
291  }
292  if (result) result->init();
293  return result;
294 }
295 
296 static XMLElement createConfig(std::string name, std::string id)
297 {
298  XMLElement config(std::move(name));
299  config.addAttribute("id", std::move(id));
300  return config;
301 }
302 
303 unique_ptr<DummyDevice> DeviceFactory::createDummyDevice(
304  const HardwareConfig& hwConf)
305 {
306  static XMLElement xml(createConfig("Dummy", {}));
307  return make_unique<DummyDevice>(DeviceConfig(hwConf, xml));
308 }
309 
310 unique_ptr<MSXDeviceSwitch> DeviceFactory::createDeviceSwitch(
311  const HardwareConfig& hwConf)
312 {
313  static XMLElement xml(createConfig("DeviceSwitch", "DeviceSwitch"));
314  return make_unique<MSXDeviceSwitch>(DeviceConfig(hwConf, xml));
315 }
316 
317 unique_ptr<MSXMapperIO> DeviceFactory::createMapperIO(
318  const HardwareConfig& hwConf)
319 {
320  static XMLElement xml(createConfig("MapperIO", "MapperIO"));
321  return make_unique<MSXMapperIO>(DeviceConfig(hwConf, xml));
322 }
323 
324 unique_ptr<VDPIODelay> DeviceFactory::createVDPIODelay(
325  const HardwareConfig& hwConf, MSXCPUInterface& cpuInterface)
326 {
327  static XMLElement xml(createConfig("VDPIODelay", "VDPIODelay"));
328  return make_unique<VDPIODelay>(DeviceConfig(hwConf, xml), cpuInterface);
329 }
330 
331 } // namespace openmsx
MSXResetStatusRegister.hh
PanasonicRam.hh
MSXYamahaSFG.hh
openmsx::DeviceFactory::createVDPIODelay
static std::unique_ptr< VDPIODelay > createVDPIODelay(const HardwareConfig &hwConf, MSXCPUInterface &cpuInterface)
Definition: DeviceFactory.cc:324
one_of.hh
MicrosolFDC.hh
Carnivore2.hh
PhilipsFDC.hh
ToshibaFDC.hh
DummyDevice.hh
VDPIODelay.hh
SensorKid.hh
openmsx::DeviceFactory::createDeviceSwitch
static std::unique_ptr< MSXDeviceSwitch > createDeviceSwitch(const HardwareConfig &hwConf)
Definition: DeviceFactory.cc:310
openmsx::DeviceFactory::createMapperIO
static std::unique_ptr< MSXMapperIO > createMapperIO(const HardwareConfig &hwConf)
Definition: DeviceFactory.cc:317
openmsx::DeviceConfig
Definition: DeviceConfig.hh:20
VDP.hh
FraelSwitchableROM.hh
MSXHiResTimer.hh
MSXAudio.hh
openmsx::XMLElement
XMLElement
Definition: XMLElement.cc:350
VictorFDC.hh
Video9000.hh
TurboRFDC.hh
MSXHBI55.hh
MegaFlashRomSCCPlusSD.hh
SpectravideoFDC.hh
MSXException.hh
DebugDevice.hh
openmsx::MSXException
Definition: MSXException.hh:10
BeerIDE.hh
MSXPPI.hh
XMLElement.hh
SVIPrinterPort.hh
SNPSG.hh
MSXFmPac.hh
MSXTurboRPause.hh
openmsx::MSXCPUInterface
Definition: MSXCPUInterface.hh:64
PioneerLDControl.hh
MSXMapperIO.hh
openmsx::DeviceConfig::getCliComm
CliComm & getCliComm() const
Definition: DeviceConfig.cc:18
JVCMSXMIDI.hh
SVIPPI.hh
AVTFDC.hh
ESE_SCC.hh
MSXDeviceSwitch.hh
ADVram.hh
openmsx::CliComm::printWarning
void printWarning(std::string_view message)
Definition: CliComm.cc:10
MSXS1990.hh
openmsx::XMLElement
Definition: XMLElement.hh:16
V9990.hh
openmsx::RomFactory::create
unique_ptr< MSXDevice > create(const DeviceConfig &config)
Definition: RomFactory.cc:158
MSXTurboRPCM.hh
MSXMoonSound.hh
one_of
Definition: one_of.hh:7
NowindInterface.hh
MSXS1985.hh
MSXPac.hh
MusicModuleMIDI.hh
YamahaFDC.hh
MSXRam.hh
MSXMirrorDevice.hh
MSXMatsushita.hh
MSXKanji12.hh
MSXRTC.hh
SunriseIDE.hh
MSXMegaRam.hh
MSXKanji.hh
openmsx::DeviceFactory::create
static std::unique_ptr< MSXDevice > create(const DeviceConfig &conf)
Definition: DeviceFactory.cc:131
MSXVictorHC9xSystemControl.hh
openmsx::XMLElement::getName
const std::string & getName() const
Definition: XMLElement.hh:31
openmsx::DeviceFactory::createDummyDevice
static std::unique_ptr< DummyDevice > createDummyDevice(const HardwareConfig &hwConf)
Definition: DeviceFactory.cc:303
components.hh
ColecoJoystickIO.hh
MSXCielTurbo.hh
openmsx::DeviceConfig::getXML
const XMLElement * getXML() const
Definition: DeviceConfig.hh:47
NationalFDC.hh
MSXRS232.hh
MSXOPL3Cartridge.hh
MegaSCSI.hh
RomFactory.hh
MusicalMemoryMapper.hh
MSXBunsetsu.hh
openmsx::HardwareConfig
Definition: HardwareConfig.hh:22
MSXFacMidiInterface.hh
MSXPSG.hh
MSXSCCPlusCart.hh
MSXMidi.hh
MSXMusic.hh
CliComm.hh
DeviceConfig.hh
DeviceFactory.hh
ColecoSuperGameModule.hh
MSXMemoryMapper.hh
PasswordCart.hh
openmsx
This file implemented 3 utility functions:
Definition: Autofire.cc:5
SanyoFDC.hh
SVIPSG.hh
ChakkariCopy.hh
MSXPrinterPort.hh
ESE_RAM.hh
GoudaSCSI.hh
MSXE6Timer.hh
SVIFDC.hh