openMSX
MSXMotherBoard.cc
Go to the documentation of this file.
1#include "MSXMotherBoard.hh"
2
3#include "BooleanSetting.hh"
5#include "CassettePort.hh"
6#include "Command.hh"
7#include "CommandException.hh"
8#include "ConfigException.hh"
9#include "Debugger.hh"
10#include "DeviceFactory.hh"
11#include "EventDelay.hh"
12#include "EventDistributor.hh"
13#include "FileException.hh"
14#include "GlobalCliComm.hh"
15#include "GlobalSettings.hh"
16#include "HardwareConfig.hh"
17#include "InfoTopic.hh"
18#include "JoystickPort.hh"
19#include "LedStatus.hh"
20#include "MSXCPU.hh"
21#include "MSXCPUInterface.hh"
22#include "MSXCliComm.hh"
24#include "MSXDevice.hh"
25#include "MSXDeviceSwitch.hh"
27#include "MSXMapperIO.hh"
28#include "MSXMixer.hh"
29#include "Observer.hh"
30#include "PanasonicMemory.hh"
31#include "PluggingController.hh"
32#include "Reactor.hh"
33#include "RealTime.hh"
34#include "RenShaTurbo.hh"
35#include "ReverseManager.hh"
36#include "Schedulable.hh"
37#include "Scheduler.hh"
38#include "SimpleDebuggable.hh"
40#include "TclObject.hh"
41#include "XMLElement.hh"
42#include "serialize.hh"
43#include "serialize_stl.hh"
44
45#include "ScopedAssign.hh"
46#include "one_of.hh"
47#include "ranges.hh"
48#include "stl.hh"
49#include "unreachable.hh"
50#include "view.hh"
51
52#include <cassert>
53#include <functional>
54#include <iostream>
55#include <memory>
56
57using std::make_unique;
58using std::string;
59
60namespace openmsx {
61
63{
64public:
65 explicit AddRemoveUpdate(MSXMotherBoard& motherBoard);
71private:
72 MSXMotherBoard& motherBoard;
73};
74
75class ResetCmd final : public RecordedCommand
76{
77public:
78 explicit ResetCmd(MSXMotherBoard& motherBoard);
79 void execute(std::span<const TclObject> tokens, TclObject& result,
80 EmuTime::param time) override;
81 [[nodiscard]] string help(std::span<const TclObject> tokens) const override;
82private:
83 MSXMotherBoard& motherBoard;
84};
85
86class LoadMachineCmd final : public Command
87{
88public:
89 explicit LoadMachineCmd(MSXMotherBoard& motherBoard);
90 void execute(std::span<const TclObject> tokens, TclObject& result) override;
91 [[nodiscard]] string help(std::span<const TclObject> tokens) const override;
92 void tabCompletion(std::vector<string>& tokens) const override;
93private:
94 MSXMotherBoard& motherBoard;
95};
96
97class ListExtCmd final : public Command
98{
99public:
100 explicit ListExtCmd(MSXMotherBoard& motherBoard);
101 void execute(std::span<const TclObject> tokens, TclObject& result) override;
102 [[nodiscard]] string help(std::span<const TclObject> tokens) const override;
103private:
104 MSXMotherBoard& motherBoard;
105};
106
107class RemoveExtCmd final : public RecordedCommand
108{
109public:
110 explicit RemoveExtCmd(MSXMotherBoard& motherBoard);
111 void execute(std::span<const TclObject> tokens, TclObject& result,
112 EmuTime::param time) override;
113 [[nodiscard]] string help(std::span<const TclObject> tokens) const override;
114 void tabCompletion(std::vector<string>& tokens) const override;
115private:
116 MSXMotherBoard& motherBoard;
117};
118
119class MachineNameInfo final : public InfoTopic
120{
121public:
122 explicit MachineNameInfo(MSXMotherBoard& motherBoard);
123 void execute(std::span<const TclObject> tokens,
124 TclObject& result) const override;
125 [[nodiscard]] string help(std::span<const TclObject> tokens) const override;
126private:
127 MSXMotherBoard& motherBoard;
128};
129
130class MachineTypeInfo final : public InfoTopic
131{
132public:
133 explicit MachineTypeInfo(MSXMotherBoard& motherBoard);
134 void execute(std::span<const TclObject> tokens,
135 TclObject& result) const override;
136 [[nodiscard]] string help(std::span<const TclObject> tokens) const override;
137private:
138 MSXMotherBoard& motherBoard;
139};
140
141class MachineExtensionInfo final : public InfoTopic
142{
143public:
144 explicit MachineExtensionInfo(MSXMotherBoard& motherBoard);
145 void execute(std::span<const TclObject> tokens,
146 TclObject& result) const override;
147 [[nodiscard]] string help(std::span<const TclObject> tokens) const override;
148 void tabCompletion(std::vector<string>& tokens) const override;
149private:
150 MSXMotherBoard& motherBoard;
151};
152
153class MachineMediaInfo final : public InfoTopic
154{
155public:
156 explicit MachineMediaInfo(MSXMotherBoard& motherBoard);
158 assert(providers.empty());
159 }
160 void execute(std::span<const TclObject> tokens,
161 TclObject& result) const override;
162 [[nodiscard]] string help(std::span<const TclObject> tokens) const override;
163 void tabCompletion(std::vector<string>& tokens) const override;
164 void registerProvider(std::string_view name, MediaInfoProvider& provider);
166private:
167 struct ProviderInfo {
168 ProviderInfo(std::string_view n, MediaInfoProvider* p)
169 : name(n), provider(p) {} // clang-15 workaround
170 std::string_view name;
171 MediaInfoProvider* provider;
172 };
173 // There will only be a handful of providers, use an unsorted vector.
174 std::vector<ProviderInfo> providers;
175};
176
177class DeviceInfo final : public InfoTopic
178{
179public:
180 explicit DeviceInfo(MSXMotherBoard& motherBoard);
181 void execute(std::span<const TclObject> tokens,
182 TclObject& result) const override;
183 [[nodiscard]] string help(std::span<const TclObject> tokens) const override;
184 void tabCompletion(std::vector<string>& tokens) const override;
185private:
186 MSXMotherBoard& motherBoard;
187};
188
189class FastForwardHelper final : private Schedulable
190{
191public:
192 explicit FastForwardHelper(MSXMotherBoard& motherBoard);
193 void setTarget(EmuTime::param targetTime);
194private:
195 void executeUntil(EmuTime::param time) override;
196 MSXMotherBoard& motherBoard;
197};
198
200{
201public:
202 explicit JoyPortDebuggable(MSXMotherBoard& motherBoard);
203 [[nodiscard]] byte read(unsigned address, EmuTime::param time) override;
204 void write(unsigned address, byte value) override;
205};
206
207class SettingObserver final : public Observer<Setting>
208{
209public:
210 explicit SettingObserver(MSXMotherBoard& motherBoard);
211 void update(const Setting& setting) noexcept override;
212private:
213 MSXMotherBoard& motherBoard;
214};
215
216
217static unsigned machineIDCounter = 0;
218
220 : reactor(reactor_)
221 , machineID(strCat("machine", ++machineIDCounter))
222 , msxCliComm(make_unique<MSXCliComm>(*this, reactor.getGlobalCliComm()))
223 , msxEventDistributor(make_unique<MSXEventDistributor>())
224 , stateChangeDistributor(make_unique<StateChangeDistributor>())
225 , msxCommandController(make_unique<MSXCommandController>(
226 reactor.getGlobalCommandController(), reactor,
227 *this, *msxEventDistributor, machineID))
228 , scheduler(make_unique<Scheduler>())
229 , msxMixer(make_unique<MSXMixer>(
230 reactor.getMixer(), *this,
231 reactor.getGlobalSettings()))
232 , videoSourceSetting(*msxCommandController)
233 , suppressMessagesSetting(*msxCommandController, "suppressmessages",
234 "Suppress info, warning and error messages for this machine. "
235 "Intended use is for scripts that create temporary machines "
236 "of which you don't want to see warning messages about blank "
237 "SRAM content or PSG port directions for instance.",
238 false, Setting::Save::NO)
239 , fastForwardHelper(make_unique<FastForwardHelper>(*this))
240 , settingObserver(make_unique<SettingObserver>(*this))
241 , powerSetting(reactor.getGlobalSettings().getPowerSetting())
242{
243 slotManager = make_unique<CartridgeSlotManager>(*this);
244 reverseManager = make_unique<ReverseManager>(*this);
245 resetCommand = make_unique<ResetCmd>(*this);
246 loadMachineCommand = make_unique<LoadMachineCmd>(*this);
247 listExtCommand = make_unique<ListExtCmd>(*this);
248 extCommand = make_unique<ExtCmd>(*this, "ext");
249 removeExtCommand = make_unique<RemoveExtCmd>(*this);
250 machineNameInfo = make_unique<MachineNameInfo>(*this);
251 machineTypeInfo = make_unique<MachineTypeInfo>(*this);
252 machineExtensionInfo = make_unique<MachineExtensionInfo>(*this);
253 machineMediaInfo = make_unique<MachineMediaInfo>(*this);
254 deviceInfo = make_unique<DeviceInfo>(*this);
255 debugger = make_unique<Debugger>(*this);
256
257 // Do this before machine-specific settings are created, otherwise
258 // a setting-info CliComm message is send with a machine id that hasn't
259 // been announced yet over CliComm.
260 addRemoveUpdate = make_unique<AddRemoveUpdate>(*this);
261
262 // TODO: Initialization of this field cannot be done much earlier because
263 // EventDelay creates a setting, calling getMSXCliComm()
264 // on MSXMotherBoard, so "pimpl" has to be set up already.
265 eventDelay = make_unique<EventDelay>(
266 *scheduler, *msxCommandController,
267 reactor.getEventDistributor(), *msxEventDistributor,
268 *reverseManager);
269 realTime = make_unique<RealTime>(
270 *this, reactor.getGlobalSettings(), *eventDelay);
271
272 powerSetting.attach(*settingObserver);
273 suppressMessagesSetting.attach(*settingObserver);
274}
275
277{
278 suppressMessagesSetting.detach(*settingObserver);
279 powerSetting.detach(*settingObserver);
280 deleteMachine();
281
282 assert(mapperIOCounter == 0);
283 assert(availableDevices.empty());
284 assert(extensions.empty());
285 assert(!machineConfig2);
286 assert(!getMachineConfig());
287}
288
289void MSXMotherBoard::deleteMachine()
290{
291 while (!extensions.empty()) {
292 try {
293 removeExtension(*extensions.back());
294 } catch (MSXException& e) {
295 std::cerr << "Internal error: failed to remove "
296 "extension while deleting a machine: "
297 << e.getMessage() << '\n';
298 assert(false);
299 }
300 }
301
302 machineConfig2.reset();
303 machineConfig = nullptr;
304}
305
307{
308 assert(!getMachineConfig());
309 machineConfig = machineConfig_;
310
311 // make sure the CPU gets instantiated from the main thread
312 assert(!msxCpu);
313 msxCpu = make_unique<MSXCPU>(*this);
314 msxCpuInterface = make_unique<MSXCPUInterface>(*this);
315}
316
317std::string_view MSXMotherBoard::getMachineType() const
318{
319 if (const HardwareConfig* machine = getMachineConfig()) {
320 if (const auto* info = machine->getConfig().findChild("info")) {
321 if (const auto* type = info->findChild("type")) {
322 return type->getData();
323 }
324 }
325 }
326 return "";
327}
328
330{
331 const HardwareConfig* config = getMachineConfig();
332 assert(config);
333 return config->getConfig().getChild("devices").findChild("S1990") != nullptr;
334}
335
337{
338 const HardwareConfig* config = getMachineConfig();
339 assert(config);
340 const XMLElement& devices = config->getConfig().getChild("devices");
341 return devices.findChild("T7775") != nullptr ||
342 devices.findChild("T7937") != nullptr ||
343 devices.findChild("T9763") != nullptr ||
344 devices.findChild("T9769") != nullptr;
345}
346
347string MSXMotherBoard::loadMachine(const string& machine)
348{
349 assert(machineName.empty());
350 assert(extensions.empty());
351 assert(!machineConfig2);
352 assert(!getMachineConfig());
353
354 try {
355 machineConfig2 = HardwareConfig::createMachineConfig(*this, machine);
356 setMachineConfig(machineConfig2.get());
357 } catch (FileException& e) {
358 throw MSXException("Machine \"", machine, "\" not found: ",
359 e.getMessage());
360 } catch (MSXException& e) {
361 throw MSXException("Error in \"", machine, "\" machine: ",
362 e.getMessage());
363 }
364 try {
365 machineConfig->parseSlots();
366 machineConfig->createDevices();
367 } catch (MSXException& e) {
368 throw MSXException("Error in \"", machine, "\" machine: ",
369 e.getMessage());
370 }
371 if (powerSetting.getBoolean()) {
372 powerUp();
373 }
374 machineName = machine;
375 return machineName;
376}
377
378std::unique_ptr<HardwareConfig> MSXMotherBoard::loadExtension(std::string_view name, std::string_view slotName)
379{
380 try {
382 *this, string(name), slotName);
383 } catch (FileException& e) {
384 throw MSXException(
385 "Extension \"", name, "\" not found: ", e.getMessage());
386 } catch (MSXException& e) {
387 throw MSXException(
388 "Error in \"", name, "\" extension: ", e.getMessage());
389 }
390}
391
393 std::string_view name, std::unique_ptr<HardwareConfig> extension)
394{
395 try {
396 extension->parseSlots();
397 extension->createDevices();
398 } catch (MSXException& e) {
399 throw MSXException(
400 "Error in \"", name, "\" extension: ", e.getMessage());
401 }
402 string result = extension->getName();
403 extensions.push_back(std::move(extension));
405 return result;
406}
407
408HardwareConfig* MSXMotherBoard::findExtension(std::string_view extensionName)
409{
410 auto it = ranges::find(extensions, extensionName, &HardwareConfig::getName);
411 return (it != end(extensions)) ? it->get() : nullptr;
412}
413
415{
416 extension.testRemove();
418 auto it = rfind_unguarded(extensions, &extension,
419 [](auto& e) { return e.get(); });
420 extensions.erase(it);
421}
422
424{
425 return *msxCliComm;
426}
427
429{
430 assert(getMachineConfig()); // needed for PluggableFactory::createAll()
431 if (!pluggingController) {
432 pluggingController = make_unique<PluggingController>(*this);
433 }
434 return *pluggingController;
435}
436
438{
439 assert(getMachineConfig()); // because CPU needs to know if we're
440 // emulating turbor or not
441 return *msxCpu;
442}
443
445{
446 assert(getMachineConfig());
447 return *msxCpuInterface;
448}
449
451{
452 if (!panasonicMemory) {
453 panasonicMemory = make_unique<PanasonicMemory>(*this);
454 }
455 return *panasonicMemory;
456}
457
459{
460 if (!deviceSwitch) {
462 }
463 return *deviceSwitch;
464}
465
467{
468 if (!cassettePort) {
469 assert(getMachineConfig());
470 if (getMachineConfig()->getConfig().findChild("CassettePort")) {
471 cassettePort = make_unique<CassettePort>(*getMachineConfig());
472 } else {
473 cassettePort = make_unique<DummyCassettePort>(*this);
474 }
475 }
476 return *cassettePort;
477}
478
480{
481 assert(port < 2);
482 if (!joystickPort[0]) {
483 assert(getMachineConfig());
484 // some MSX machines only have 1 instead of 2 joystick ports
485 std::string_view ports = getMachineConfig()->getConfig().getChildData(
486 "JoystickPorts", "AB");
487 if (ports != one_of("AB", "", "A", "B")) {
488 throw ConfigException(
489 "Invalid JoystickPorts specification, "
490 "should be one of '', 'A', 'B' or 'AB'.");
491 }
493 if (ports == one_of("AB", "A")) {
494 joystickPort[0] = make_unique<JoystickPort>(
495 ctrl, "joyporta", "MSX Joystick port A");
496 } else {
497 joystickPort[0] = make_unique<DummyJoystickPort>();
498 }
499 if (ports == one_of("AB", "B")) {
500 joystickPort[1] = make_unique<JoystickPort>(
501 ctrl, "joyportb", "MSX Joystick port B");
502 } else {
503 joystickPort[1] = make_unique<DummyJoystickPort>();
504 }
505 joyPortDebuggable = make_unique<JoyPortDebuggable>(*this);
506 }
507 return *joystickPort[port];
508}
509
511{
512 if (!renShaTurbo) {
513 assert(getMachineConfig());
514 renShaTurbo = make_unique<RenShaTurbo>(
515 *this,
516 getMachineConfig()->getConfig());
517 }
518 return *renShaTurbo;
519}
520
522{
523 if (!ledStatus) {
524 (void)getMSXCliComm(); // force init, to be on the safe side
525 ledStatus = make_unique<LedStatus>(
526 reactor.getRTScheduler(),
527 *msxCommandController,
528 *msxCliComm);
529 }
530 return *ledStatus;
531}
532
534{
535 return *msxCommandController;
536}
537
539{
540 return msxCommandController->getMachineInfoCommand();
541}
542
543EmuTime::param MSXMotherBoard::getCurrentTime() const
544{
545 return scheduler->getCurrentTime();
546}
547
549{
550 if (!powered) {
551 return false;
552 }
553 assert(getMachineConfig()); // otherwise powered cannot be true
554
555 getCPU().execute(false);
556 return true;
557}
558
559void MSXMotherBoard::fastForward(EmuTime::param time, bool fast)
560{
561 assert(powered);
562 assert(getMachineConfig());
563
564 if (time <= getCurrentTime()) return;
565
566 ScopedAssign sa(fastForwarding, fast);
567 realTime->disable();
568 msxMixer->mute();
569 fastForwardHelper->setTarget(time);
570 while (time > getCurrentTime()) {
571 // note: this can run (slightly) past the requested time
572 getCPU().execute(true); // fast-forward mode
573 }
574 realTime->enable();
575 msxMixer->unmute();
576}
577
579{
580 if (getMachineConfig()) {
581 getCPU().setPaused(true);
582 }
583 msxMixer->mute();
584}
585
587{
588 if (getMachineConfig()) {
589 getCPU().setPaused(false);
590 }
591 msxMixer->unmute();
592}
593
595{
596 availableDevices.push_back(&device);
597}
598
600{
601 move_pop_back(availableDevices, rfind_unguarded(availableDevices, &device));
602}
603
605{
606 if (!powered) return;
607 assert(getMachineConfig());
608
609 EmuTime::param time = getCurrentTime();
611 for (auto& d : availableDevices) {
612 d->reset(time);
613 }
614 getCPU().doReset(time);
615 // let everyone know we're booting, note that the fact that this is
616 // done after the reset call to the devices is arbitrary here
618}
619
621{
622 byte result = 0xff;
623 for (auto& d : availableDevices) {
624 result &= d->readIRQVector();
625 }
626 return result;
627}
628
630{
631 if (powered) return;
632 if (!getMachineConfig()) return;
633
634 powered = true;
635 // TODO: If our "powered" field is always equal to the power setting,
636 // there is not really a point in keeping it.
637 // TODO: assert disabled see note in Reactor::run() where this method
638 // is called
639 //assert(powerSetting.getBoolean() == powered);
640 powerSetting.setBoolean(true);
641 // TODO: We could make the power LED a device, so we don't have to handle
642 // it separately here.
644
645 EmuTime::param time = getCurrentTime();
647 for (auto& d : availableDevices) {
648 d->powerUp(time);
649 }
650 getCPU().doReset(time);
651 msxMixer->unmute();
652 // let everyone know we're booting, note that the fact that this is
653 // done after the reset call to the devices is arbitrary here
655}
656
657void MSXMotherBoard::powerDown()
658{
659 if (!powered) return;
660
661 powered = false;
662 // TODO: This assertion fails in 1 case: when quitting with a running MSX.
663 // How do we want the Reactor to shutdown: immediately or after
664 // handling all pending commands/events/updates?
665 //assert(powerSetting.getBoolean() == powered);
666 powerSetting.setBoolean(false);
668
669 msxMixer->mute();
670
671 EmuTime::param time = getCurrentTime();
672 for (auto& d : availableDevices) {
673 d->powerDown(time);
674 }
675}
676
677void MSXMotherBoard::activate(bool active_)
678{
679 active = active_;
680 auto event = active ? Event(MachineActivatedEvent())
682 msxEventDistributor->distributeEvent(event, scheduler->getCurrentTime());
683 if (active) {
684 realTime->resync();
685 }
686}
687
694
699
701{
702 auto it = ranges::find(availableDevices, name, &MSXDevice::getName);
703 return (it != end(availableDevices)) ? *it : nullptr;
704}
705
707{
708 if (mapperIOCounter == 0) {
710 getCPUInterface().register_IO_InOut_range(0xfc, 4, mapperIO.get());
711 }
712 ++mapperIOCounter;
713 return *mapperIO;
714}
715
717{
718 assert(mapperIO);
719 assert(mapperIOCounter);
720 --mapperIOCounter;
721 if (mapperIOCounter == 0) {
722 getCPUInterface().unregister_IO_InOut_range(0xfc, 4, mapperIO.get());
723 mapperIO.reset();
724 }
725}
726
727string MSXMotherBoard::getUserName(const string& hwName)
728{
729 auto& s = userNames[hwName];
730 unsigned n = 0;
731 string userName;
732 do {
733 userName = strCat("untitled", ++n);
734 } while (contains(s, userName));
735 s.push_back(userName);
736 return userName;
737}
738
739void MSXMotherBoard::freeUserName(const string& hwName, const string& userName)
740{
741 auto& s = userNames[hwName];
742 move_pop_back(s, rfind_unguarded(s, userName));
743}
744
745void MSXMotherBoard::registerMediaInfo(std::string_view name, MediaInfoProvider& provider)
746{
747 machineMediaInfo->registerProvider(name, provider);
748}
749
751{
752 machineMediaInfo->unregisterProvider(provider);
753}
754
755
756// AddRemoveUpdate
757
759 : motherBoard(motherBoard_)
760{
761 motherBoard.getReactor().getGlobalCliComm().update(
762 CliComm::UpdateType::HARDWARE, motherBoard.getMachineID(), "add");
763}
764
770
771
772// ResetCmd
774 : RecordedCommand(motherBoard_.getCommandController(),
775 motherBoard_.getStateChangeDistributor(),
776 motherBoard_.getScheduler(),
777 "reset")
778 , motherBoard(motherBoard_)
779{
780}
781
782void ResetCmd::execute(std::span<const TclObject> /*tokens*/, TclObject& /*result*/,
783 EmuTime::param /*time*/)
784{
785 motherBoard.doReset();
786}
787
788string ResetCmd::help(std::span<const TclObject> /*tokens*/) const
789{
790 return "Resets the MSX.";
791}
792
793
794// LoadMachineCmd
796 : Command(motherBoard_.getCommandController(), "load_machine")
797 , motherBoard(motherBoard_)
798{
799 // The load_machine command should always directly follow a
800 // create_machine command:
801 // - It's not allowed to use load_machine on a machine that has
802 // already a machine configuration loaded earlier.
803 // - We also disallow executing most machine-specific commands on an
804 // 'empty machine' (an 'empty machine', is a machine returned by
805 // create_machine before the load_machine command is executed, so a
806 // machine without a machine configuration). The only exception is
807 // this load_machine command and machine_info.
808 //
809 // So if the only allowed command on an empty machine is
810 // 'load_machine', (and an empty machine by itself isn't very useful),
811 // then why isn't create_machine and load_machine merged into a single
812 // command? The only reason for this is that load_machine sends out
813 // events (machine specific) and maybe you already want to know the ID
814 // of the new machine (this is returned by create_machine) before those
815 // events will be send.
816 //
817 // Why not allow all commands on an empty machine? In the past we did
818 // allow this, though it often was the source of bugs. We could in each
819 // command (when needed) check for an empty machine and then return
820 // some dummy/empty result or some error. But because I can't think of
821 // any really useful command for an empty machine, it seemed easier to
822 // just disallow most commands.
824}
825
826void LoadMachineCmd::execute(std::span<const TclObject> tokens, TclObject& result)
827{
828 checkNumArgs(tokens, 2, "machine");
829 if (motherBoard.getMachineConfig()) {
830 throw CommandException("Already loaded a config in this machine.");
831 }
832 result = motherBoard.loadMachine(string(tokens[1].getString()));
833}
834
835string LoadMachineCmd::help(std::span<const TclObject> /*tokens*/) const
836{
837 return "Load a msx machine configuration into an empty machine.";
838}
839
840void LoadMachineCmd::tabCompletion(std::vector<string>& tokens) const
841{
842 completeString(tokens, Reactor::getHwConfigs("machines"));
843}
844
845
846// ListExtCmd
848 : Command(motherBoard_.getCommandController(), "list_extensions")
849 , motherBoard(motherBoard_)
850{
851}
852
853void ListExtCmd::execute(std::span<const TclObject> /*tokens*/, TclObject& result)
854{
855 result.addListElements(
857}
858
859string ListExtCmd::help(std::span<const TclObject> /*tokens*/) const
860{
861 return "Return a list of all inserted extensions.";
862}
863
864
865// ExtCmd
866ExtCmd::ExtCmd(MSXMotherBoard& motherBoard_, std::string commandName_)
867 : RecordedCommand(motherBoard_.getCommandController(),
868 motherBoard_.getStateChangeDistributor(),
869 motherBoard_.getScheduler(),
870 commandName_)
871 , motherBoard(motherBoard_)
872 , commandName(std::move(commandName_))
873{
874}
875
876void ExtCmd::execute(std::span<const TclObject> tokens, TclObject& result,
877 EmuTime::param /*time*/)
878{
879 checkNumArgs(tokens, Between{2, 3}, "extension");
880 if (tokens.size() == 3 && tokens[1].getString() != "insert") {
881 throw SyntaxError();
882 }
883 try {
884 auto name = tokens[tokens.size() - 1].getString();
885 auto slotName = (commandName.size() == 4)
886 ? std::string_view(&commandName[3], 1)
887 : "any";
888 auto extension = motherBoard.loadExtension(name, slotName);
889 if (slotName != "any") {
890 const auto& manager = motherBoard.getSlotManager();
891 if (const auto* extConf = manager.getConfigForSlot(commandName[3] - 'a')) {
892 // still a cartridge inserted, (try to) remove it now
893 motherBoard.removeExtension(*extConf);
894 }
895 }
896 result = motherBoard.insertExtension(name, std::move(extension));
897 } catch (MSXException& e) {
898 throw CommandException(std::move(e).getMessage());
899 }
900}
901
902string ExtCmd::help(std::span<const TclObject> /*tokens*/) const
903{
904 return "Insert a hardware extension.";
905}
906
907void ExtCmd::tabCompletion(std::vector<string>& tokens) const
908{
909 completeString(tokens, Reactor::getHwConfigs("extensions"));
910}
911
912
913// RemoveExtCmd
915 : RecordedCommand(motherBoard_.getCommandController(),
916 motherBoard_.getStateChangeDistributor(),
917 motherBoard_.getScheduler(),
918 "remove_extension")
919 , motherBoard(motherBoard_)
920{
921}
922
923void RemoveExtCmd::execute(std::span<const TclObject> tokens, TclObject& /*result*/,
924 EmuTime::param /*time*/)
925{
926 checkNumArgs(tokens, 2, "extension");
927 std::string_view extName = tokens[1].getString();
928 HardwareConfig* extension = motherBoard.findExtension(extName);
929 if (!extension) {
930 throw CommandException("No such extension: ", extName);
931 }
932 try {
933 motherBoard.removeExtension(*extension);
934 } catch (MSXException& e) {
935 throw CommandException("Can't remove extension '", extName,
936 "': ", e.getMessage());
937 }
938}
939
940string RemoveExtCmd::help(std::span<const TclObject> /*tokens*/) const
941{
942 return "Remove an extension from the MSX machine.";
943}
944
945void RemoveExtCmd::tabCompletion(std::vector<string>& tokens) const
946{
947 if (tokens.size() == 2) {
949 motherBoard.getExtensions(),
950 [](auto& e) -> std::string_view { return e->getName(); }));
951 }
952}
953
954
955// MachineNameInfo
956
958 : InfoTopic(motherBoard_.getMachineInfoCommand(), "config_name")
959 , motherBoard(motherBoard_)
960{
961}
962
963void MachineNameInfo::execute(std::span<const TclObject> /*tokens*/,
964 TclObject& result) const
965{
966 result = motherBoard.getMachineName();
967}
968
969string MachineNameInfo::help(std::span<const TclObject> /*tokens*/) const
970{
971 return "Returns the configuration name for this machine.";
972}
973
974// MachineTypeInfo
975
977 : InfoTopic(motherBoard_.getMachineInfoCommand(), "type")
978 , motherBoard(motherBoard_)
979{
980}
981
982void MachineTypeInfo::execute(std::span<const TclObject> /*tokens*/,
983 TclObject& result) const
984{
985 result = motherBoard.getMachineType();
986}
987
988string MachineTypeInfo::help(std::span<const TclObject> /*tokens*/) const
989{
990 return "Returns the machine type for this machine.";
991}
992
993
994// MachineExtensionInfo
995
997 : InfoTopic(motherBoard_.getMachineInfoCommand(), "extension")
998 , motherBoard(motherBoard_)
999{
1000}
1001
1002void MachineExtensionInfo::execute(std::span<const TclObject> tokens,
1003 TclObject& result) const
1004{
1005 checkNumArgs(tokens, Between{2, 3}, Prefix{2}, "?extension-instance-name?");
1006 if (tokens.size() == 2) {
1007 result.addListElements(
1009 } else if (tokens.size() == 3) {
1010 std::string_view extName = tokens[2].getString();
1011 const HardwareConfig* extension = motherBoard.findExtension(extName);
1012 if (!extension) {
1013 throw CommandException("No such extension: ", extName);
1014 }
1015 if (extension->getType() == HardwareConfig::Type::EXTENSION) {
1016 // A 'true' extension, as specified in an XML file
1017 result.addDictKeyValue("config", extension->getConfigName());
1018 } else {
1019 assert(extension->getType() == HardwareConfig::Type::ROM);
1020 // A ROM cartridge, peek into the internal config for the original filename
1021 const auto& filename = extension->getConfig()
1022 .getChild("devices").getChild("primary").getChild("secondary")
1023 .getChild("ROM").getChild("rom").getChildData("filename");
1024 result.addDictKeyValue("rom", filename);
1025 }
1026 TclObject deviceList;
1027 deviceList.addListElements(
1029 result.addDictKeyValue("devices", deviceList);
1030 }
1031}
1032
1033string MachineExtensionInfo::help(std::span<const TclObject> /*tokens*/) const
1034{
1035 return "Returns information about the given extension instance.";
1036}
1037
1038void MachineExtensionInfo::tabCompletion(std::vector<string>& tokens) const
1039{
1040 if (tokens.size() == 3) {
1042 motherBoard.getExtensions(),
1043 [](auto& e) -> std::string_view { return e->getName(); }));
1044 }
1045}
1046
1047
1048// MachineMediaInfo
1049
1051 : InfoTopic(motherBoard_.getMachineInfoCommand(), "media")
1052{
1053}
1054
1055void MachineMediaInfo::execute(std::span<const TclObject> tokens,
1056 TclObject& result) const
1057{
1058 checkNumArgs(tokens, Between{2, 3}, Prefix{2}, "?media-slot-name?");
1059 if (tokens.size() == 2) {
1060 result.addListElements(
1061 view::transform(providers, &ProviderInfo::name));
1062 } else if (tokens.size() == 3) {
1063 auto name = tokens[2].getString();
1064 if (auto it = ranges::find(providers, name, &ProviderInfo::name);
1065 it != providers.end()) {
1066 it->provider->getMediaInfo(result);
1067 } else {
1068 throw CommandException("No info about media slot ", name);
1069 }
1070 }
1071}
1072
1073string MachineMediaInfo::help(std::span<const TclObject> /*tokens*/) const
1074{
1075 return "Returns information about the given media slot.";
1076}
1077
1078void MachineMediaInfo::tabCompletion(std::vector<string>& tokens) const
1079{
1080 if (tokens.size() == 3) {
1082 providers, &ProviderInfo::name));
1083 }
1084}
1085
1086void MachineMediaInfo::registerProvider(std::string_view name, MediaInfoProvider& provider)
1087{
1088 assert(!contains(providers, name, &ProviderInfo::name));
1089 assert(!contains(providers, &provider, &ProviderInfo::provider));
1090 providers.emplace_back(name, &provider);
1091}
1092
1094{
1095 move_pop_back(providers,
1096 rfind_unguarded(providers, &provider, &ProviderInfo::provider));
1097}
1098
1099// DeviceInfo
1100
1102 : InfoTopic(motherBoard_.getMachineInfoCommand(), "device")
1103 , motherBoard(motherBoard_)
1104{
1105}
1106
1107void DeviceInfo::execute(std::span<const TclObject> tokens, TclObject& result) const
1108{
1109 checkNumArgs(tokens, Between{2, 3}, Prefix{2}, "?device?");
1110 switch (tokens.size()) {
1111 case 2:
1112 result.addListElements(
1113 view::transform(motherBoard.availableDevices,
1114 [](auto& d) { return d->getName(); }));
1115 break;
1116 case 3: {
1117 std::string_view deviceName = tokens[2].getString();
1118 const MSXDevice* device = motherBoard.findDevice(deviceName);
1119 if (!device) {
1120 throw CommandException("No such device: ", deviceName);
1121 }
1122 device->getDeviceInfo(result);
1123 break;
1124 }
1125 }
1126}
1127
1128string DeviceInfo::help(std::span<const TclObject> /*tokens*/) const
1129{
1130 return "Without any arguments, returns the list of used device names.\n"
1131 "With a device name as argument, returns the type (and for some "
1132 "devices the subtype) of the given device.";
1133}
1134
1135void DeviceInfo::tabCompletion(std::vector<string>& tokens) const
1136{
1137 if (tokens.size() == 3) {
1139 motherBoard.availableDevices,
1140 [](auto& d) -> std::string_view { return d->getName(); }));
1141 }
1142}
1143
1144
1145// FastForwardHelper
1146
1148 : Schedulable(motherBoard_.getScheduler())
1149 , motherBoard(motherBoard_)
1150{
1151}
1152
1153void FastForwardHelper::setTarget(EmuTime::param targetTime)
1154{
1155 setSyncPoint(targetTime);
1156}
1157
1158void FastForwardHelper::executeUntil(EmuTime::param /*time*/)
1159{
1160 motherBoard.exitCPULoopSync();
1161}
1162
1163
1164// class JoyPortDebuggable
1165
1167 : SimpleDebuggable(motherBoard_, "joystickports", "MSX Joystick Ports", 2)
1168{
1169}
1170
1171byte JoyPortDebuggable::read(unsigned address, EmuTime::param time)
1172{
1173 return getMotherBoard().getJoystickPort(address).read(time);
1174}
1175
1176void JoyPortDebuggable::write(unsigned /*address*/, byte /*value*/)
1177{
1178 // ignore
1179}
1180
1181
1182// class SettingObserver
1183
1185 : motherBoard(motherBoard_)
1186{
1187}
1188
1190{
1191 if (&setting == &motherBoard.powerSetting) {
1192 if (motherBoard.powerSetting.getBoolean()) {
1193 motherBoard.powerUp();
1194 } else {
1195 motherBoard.powerDown();
1196 }
1197 } else if (&setting == &motherBoard.suppressMessagesSetting) {
1198 motherBoard.msxCliComm->setSuppressMessages(motherBoard.suppressMessagesSetting.getBoolean());
1199 } else {
1201 }
1202}
1203
1204
1205// serialize
1206// version 1: initial version
1207// version 2: added reRecordCount
1208// version 3: removed reRecordCount (moved to ReverseManager)
1209// version 4: moved joystickportA/B from MSXPSG to here
1210// version 5: do serialize renShaTurbo
1211template<typename Archive>
1212void MSXMotherBoard::serialize(Archive& ar, unsigned version)
1213{
1214 // don't serialize:
1215 // machineID, userNames, availableDevices, addRemoveUpdate,
1216 // sharedStuffMap, msxCliComm, msxEventDistributor,
1217 // msxCommandController, slotManager, eventDelay,
1218 // debugger, msxMixer, panasonicMemory, ledStatus
1219
1220 // Scheduler must come early so that devices can query current time
1221 ar.serialize("scheduler", *scheduler);
1222 // MSXMixer has already set sync points, those are invalid now
1223 // the following call will fix this
1224 if constexpr (Archive::IS_LOADER) {
1225 msxMixer->reInit();
1226 }
1227
1228 ar.serialize("name", machineName);
1229 ar.serializeWithID("config", machineConfig2, std::ref(*this));
1230 assert(getMachineConfig() == machineConfig2.get());
1231 ar.serializeWithID("extensions", extensions, std::ref(*this));
1232
1233 if (mapperIO) ar.serialize("mapperIO", *mapperIO);
1234
1235 if (auto& devSwitch = getDeviceSwitch();
1236 devSwitch.hasRegisteredDevices()) {
1237 ar.serialize("deviceSwitch", devSwitch);
1238 }
1239
1240 if (getMachineConfig()) {
1241 ar.serialize("cpu", getCPU());
1242 }
1243 ar.serialize("cpuInterface", getCPUInterface());
1244
1245 if (auto* port = dynamic_cast<CassettePort*>(&getCassettePort())) {
1246 ar.serialize("cassetteport", *port);
1247 }
1248 if (ar.versionAtLeast(version, 4)) {
1249 if (auto* port = dynamic_cast<JoystickPort*>(
1250 joystickPort[0].get())) {
1251 ar.serialize("joystickportA", *port);
1252 }
1253 if (auto* port = dynamic_cast<JoystickPort*>(
1254 joystickPort[1].get())) {
1255 ar.serialize("joystickportB", *port);
1256 }
1257 }
1258 if (ar.versionAtLeast(version, 5)) {
1259 if (renShaTurbo) ar.serialize("renShaTurbo", *renShaTurbo);
1260 }
1261
1262 if constexpr (Archive::IS_LOADER) {
1263 powered = true; // must come before changing power setting
1264 powerSetting.setBoolean(true);
1266 msxMixer->unmute();
1267 }
1268
1269 if (version == 2) {
1270 assert(Archive::IS_LOADER);
1271 unsigned reRecordCount = 0; // silence warning
1272 ar.serialize("reRecordCount", reRecordCount);
1273 getReverseManager().setReRecordCount(reRecordCount);
1274 }
1275}
1277
1278} // namespace openmsx
BaseSetting * setting
Assign new value to some variable and restore the original value when this object goes out of scope.
AddRemoveUpdate(const AddRemoveUpdate &)=delete
AddRemoveUpdate & operator=(AddRemoveUpdate &&)=delete
AddRemoveUpdate(MSXMotherBoard &motherBoard)
AddRemoveUpdate(AddRemoveUpdate &&)=delete
AddRemoveUpdate & operator=(const AddRemoveUpdate &)=delete
bool getBoolean() const noexcept
Sent when the MSX resets or powers up.
Definition Event.hh:370
void setAllowedInEmptyMachine(bool value)
Definition Command.hh:67
static void completeString(std::vector< std::string > &tokens, ITER begin, ITER end, bool caseSensitive=true)
Definition Completer.hh:138
void checkNumArgs(std::span< const TclObject > tokens, unsigned exactly, const char *errMessage) const
Definition Completer.cc:181
static std::unique_ptr< MSXDeviceSwitch > createDeviceSwitch(const HardwareConfig &hwConf)
static std::unique_ptr< MSXMapperIO > createMapperIO(const HardwareConfig &hwConf)
DeviceInfo(MSXMotherBoard &motherBoard)
void execute(std::span< const TclObject > tokens, TclObject &result) const override
Show info on this topic.
string help(std::span< const TclObject > tokens) const override
Print help for this topic.
void tabCompletion(std::vector< string > &tokens) const override
Attempt tab completion for this command.
void distributeEvent(Event &&event)
Schedule the given event for delivery.
void tabCompletion(std::vector< std::string > &tokens) const override
Attempt tab completion for this command.
ExtCmd(MSXMotherBoard &motherBoard, std::string commandName)
void execute(std::span< const 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.
std::string help(std::span< const TclObject > tokens) const override
Print help for this command.
void setTarget(EmuTime::param targetTime)
FastForwardHelper(MSXMotherBoard &motherBoard)
void update(UpdateType type, std::string_view name, std::string_view value) override
const std::string & getConfigName() const
static std::unique_ptr< HardwareConfig > createMachineConfig(MSXMotherBoard &motherBoard, std::string machineName)
const auto & getDevices() const
const std::string & getName() const
const XMLElement & getConfig() const
static std::unique_ptr< HardwareConfig > createExtensionConfig(MSXMotherBoard &motherBoard, std::string extensionName, std::string_view slotName)
void testRemove() const
Checks whether this HardwareConfig can be deleted.
void write(unsigned address, byte value) override
JoyPortDebuggable(MSXMotherBoard &motherBoard)
byte read(unsigned address, EmuTime::param time) override
virtual uint8_t read(EmuTime::param time)=0
void setLed(Led led, bool status)
Definition LedStatus.cc:44
void execute(std::span< const TclObject > tokens, TclObject &result) override
Execute this command.
ListExtCmd(MSXMotherBoard &motherBoard)
string help(std::span< const TclObject > tokens) const override
Print help for this command.
LoadMachineCmd(MSXMotherBoard &motherBoard)
string help(std::span< const TclObject > tokens) const override
Print help for this command.
void execute(std::span< const TclObject > tokens, TclObject &result) override
Execute this command.
void tabCompletion(std::vector< string > &tokens) const override
Attempt tab completion for this command.
void unregister_IO_InOut_range(byte port, unsigned num, MSXDevice *device)
void reset()
Reset (the slot state)
void register_IO_InOut_range(byte port, unsigned num, MSXDevice *device)
void exitCPULoopSync()
See CPUCore::exitCPULoopSync()
Definition MSXCPU.cc:130
void doReset(EmuTime::param time)
Reset CPU.
Definition MSXCPU.cc:84
void setPaused(bool paused)
(un)pause CPU.
Definition MSXCPU.cc:359
void exitCPULoopAsync()
See CPUCore::exitCPULoopAsync()
Definition MSXCPU.cc:135
void update(UpdateType type, std::string_view name, std::string_view value) override
Definition MSXCliComm.cc:21
An MSXDevice is an emulated hardware component connected to the bus of the emulated MSX.
Definition MSXDevice.hh:36
void getDeviceInfo(TclObject &result) const
Get device info.
Definition MSXDevice.cc:385
virtual const std::string & getName() const
Returns a human-readable name for this device.
Definition MSXDevice.cc:375
HardwareConfig * findExtension(std::string_view extensionName)
PluggingController & getPluggingController()
void activate(bool active)
void setMachineConfig(HardwareConfig *machineConfig)
RenShaTurbo & getRenShaTurbo()
void freeUserName(const std::string &hwName, const std::string &userName)
bool execute()
Run emulation.
EmuTime::param getCurrentTime() const
Convenience method: This is the same as getScheduler().getCurrentTime().
const HardwareConfig * getMachineConfig() const
MSXCPUInterface & getCPUInterface()
std::string getUserName(const std::string &hwName)
Keep track of which 'usernames' are in use.
std::unique_ptr< HardwareConfig > loadExtension(std::string_view extensionName, std::string_view slotName)
std::string loadMachine(const std::string &machine)
std::string_view getMachineName() const
void registerMediaInfo(std::string_view name, MediaInfoProvider &provider)
Register and unregister providers of media info, for the media info topic.
MSXDevice * findDevice(std::string_view name)
Find a MSXDevice by name.
CommandController & getCommandController()
void pause()
Pause MSX machine.
std::string insertExtension(std::string_view name, std::unique_ptr< HardwareConfig > extension)
void fastForward(EmuTime::param time, bool fast)
Run emulation until a certain time in fast forward mode.
void exitCPULoopAsync()
See CPU::exitCPULoopAsync().
MSXMotherBoard(const MSXMotherBoard &)=delete
void unregisterMediaInfo(MediaInfoProvider &provider)
MSXDeviceSwitch & getDeviceSwitch()
void serialize(Archive &ar, unsigned version)
CartridgeSlotManager & getSlotManager()
void removeDevice(MSXDevice &device)
std::string_view getMachineID() const
void removeExtension(const HardwareConfig &extension)
ReverseManager & getReverseManager()
JoystickPortIf & getJoystickPort(unsigned port)
std::string_view getMachineType() const
const Extensions & getExtensions() const
CassettePortInterface & getCassettePort()
void addDevice(MSXDevice &device)
All MSXDevices should be registered by the MotherBoard.
PanasonicMemory & getPanasonicMemory()
MSXMapperIO & createMapperIO()
All memory mappers in one MSX machine share the same four (logical) memory mapper registers.
InfoCommand & getMachineInfoCommand()
Send when a machine is (de)activated.
Definition Event.hh:392
void execute(std::span< const TclObject > tokens, TclObject &result) const override
Show info on this topic.
string help(std::span< const TclObject > tokens) const override
Print help for this topic.
void tabCompletion(std::vector< string > &tokens) const override
Attempt tab completion for this topic.
MachineExtensionInfo(MSXMotherBoard &motherBoard)
void unregisterProvider(MediaInfoProvider &provider)
void registerProvider(std::string_view name, MediaInfoProvider &provider)
string help(std::span< const TclObject > tokens) const override
Print help for this topic.
void execute(std::span< const TclObject > tokens, TclObject &result) const override
Show info on this topic.
MachineMediaInfo(MSXMotherBoard &motherBoard)
void tabCompletion(std::vector< string > &tokens) const override
Attempt tab completion for this topic.
void execute(std::span< const TclObject > tokens, TclObject &result) const override
Show info on this topic.
MachineNameInfo(MSXMotherBoard &motherBoard)
string help(std::span< const TclObject > tokens) const override
Print help for this topic.
string help(std::span< const TclObject > tokens) const override
Print help for this topic.
void execute(std::span< const TclObject > tokens, TclObject &result) const override
Show info on this topic.
MachineTypeInfo(MSXMotherBoard &motherBoard)
Generic Gang-of-Four Observer class, templatized edition.
Definition Observer.hh:10
Central administration of Connectors and Pluggables.
Contains the main loop of openMSX.
Definition Reactor.hh:75
GlobalSettings & getGlobalSettings()
Definition Reactor.hh:117
GlobalCliComm & getGlobalCliComm()
Definition Reactor.hh:90
RTScheduler & getRTScheduler()
Definition Reactor.hh:88
EventDistributor & getEventDistributor()
Definition Reactor.hh:89
static std::vector< std::string > getHwConfigs(std::string_view type)
Definition Reactor.cc:348
Commands that directly influence the MSX state should send and events so that they can be recorded by...
RemoveExtCmd(MSXMotherBoard &motherBoard)
void tabCompletion(std::vector< string > &tokens) const override
Attempt tab completion for this command.
void execute(std::span< const 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.
string help(std::span< const TclObject > tokens) const override
Print help for this command.
Ren-Sha Turbo is the autofire in several MSX 2+ models and in the MSX turbo R.
string help(std::span< const TclObject > tokens) const override
Print help for this command.
void execute(std::span< const 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.
ResetCmd(MSXMotherBoard &motherBoard)
void setReRecordCount(unsigned count)
Every class that wants to get scheduled at some point must inherit from this class.
void setSyncPoint(EmuTime::param timestamp)
SettingObserver(MSXMotherBoard &motherBoard)
void update(const Setting &setting) noexcept override
MSXMotherBoard & getMotherBoard() const
void detach(Observer< T > &observer)
Definition Subject.hh:60
void attach(Observer< T > &observer)
Definition Subject.hh:54
void addListElements(ITER first, ITER last)
Definition TclObject.hh:134
void addDictKeyValue(const Key &key, const Value &value)
Definition TclObject.hh:147
const XMLElement * findChild(std::string_view childName) const
Definition XMLElement.cc:21
const XMLElement & getChild(std::string_view childName) const
Definition XMLElement.cc:55
std::string_view getChildData(std::string_view childName) const
Definition XMLElement.cc:64
This file implemented 3 utility functions:
Definition Autofire.cc:11
std::variant< KeyUpEvent, KeyDownEvent, MouseMotionEvent, MouseButtonUpEvent, MouseButtonDownEvent, MouseWheelEvent, JoystickAxisMotionEvent, JoystickHatEvent, JoystickButtonUpEvent, JoystickButtonDownEvent, OsdControlReleaseEvent, OsdControlPressEvent, WindowEvent, TextEvent, FileDropEvent, QuitEvent, FinishFrameEvent, CliCommandEvent, GroupEvent, BootEvent, FrameDrawnEvent, BreakEvent, SwitchRendererEvent, TakeReverseSnapshotEvent, AfterTimedEvent, MachineLoadedEvent, MachineActivatedEvent, MachineDeactivatedEvent, MidiInReaderEvent, MidiInWindowsEvent, MidiInCoreMidiEvent, MidiInCoreMidiVirtualEvent, MidiInALSAEvent, Rs232TesterEvent, Rs232NetEvent, ImGuiDelayedActionEvent, ImGuiActiveEvent > Event
Definition Event.hh:445
auto find(InputRange &&range, const T &value)
Definition ranges.hh:162
STL namespace.
constexpr auto transform(Range &&range, UnaryOp op)
Definition view.hh:520
#define INSTANTIATE_SERIALIZE_METHODS(CLASS)
void move_pop_back(VECTOR &v, typename VECTOR::iterator it)
Erase the pointed to element from the given vector.
Definition stl.hh:137
auto rfind_unguarded(RANGE &range, const VAL &val, Proj proj={})
Similar to the find(_if)_unguarded functions above, but searches from the back to front.
Definition stl.hh:112
constexpr bool contains(ITER first, ITER last, const VAL &val)
Check if a range contains a given value, using linear search.
Definition stl.hh:35
std::string strCat()
Definition strCat.hh:703
#define UNREACHABLE
constexpr auto end(const zstring_view &x)