openMSX
SG1000Pause.cc
Go to the documentation of this file.
1 #include "SG1000Pause.hh"
2 #include "Event.hh"
3 #include "Keys.hh"
4 #include "MSXCPU.hh"
5 #include "MSXEventDistributor.hh"
6 #include "MSXMotherBoard.hh"
7 #include "checked_cast.hh"
8 #include "serialize.hh"
9 
10 namespace openmsx {
11 
13  : MSXDevice(config)
14  , Schedulable(getMotherBoard().getScheduler())
15 {
17 }
18 
20 {
22 }
23 
24 void SG1000Pause::signalMSXEvent(const Event& event, EmuTime::param time) noexcept
25 {
27  [&](const KeyDownEvent& keyEvent) {
28  if (keyEvent.getKeyCode() == Keys::K_F5) {
29  setSyncPoint(time);
30  }
31  },
32  [](const EventBase&) { /*ignore*/ }
33  }, event);
34 }
35 
36 void SG1000Pause::executeUntil(EmuTime::param /*time*/)
37 {
38  // We raise and then immediately lower the NMI request. This still triggers
39  // an interrupt, since our CPU core remembers the edge.
40  MSXCPU& cpu = getMotherBoard().getCPU();
41  cpu.raiseNMI();
42  cpu.lowerNMI();
43 }
44 
45 template<typename Archive>
46 void SG1000Pause::serialize(Archive& ar, unsigned /*version*/)
47 {
48  ar.template serializeBase<MSXDevice>(*this);
49 }
52 
53 } // namespace openmsx
void raiseNMI()
This method raises a non-maskable interrupt.
Definition: MSXCPU.cc:295
An MSXDevice is an emulated hardware component connected to the bus of the emulated MSX.
Definition: MSXDevice.hh:33
MSXMotherBoard & getMotherBoard() const
Get the mother board this device belongs to.
Definition: MSXDevice.cc:71
void registerEventListener(MSXEventListener &listener)
Registers a given object to receive certain events.
void unregisterEventListener(MSXEventListener &listener)
Unregisters a previously registered event listener.
MSXEventDistributor & getMSXEventDistributor()
This button is labeled "hold" on SG-1000, "pause" on SG-1000 mk 2 and "reset" on SC-3000.
Definition: SG1000Pause.hh:16
SG1000Pause(const DeviceConfig &config)
Definition: SG1000Pause.cc:12
void serialize(Archive &ar, unsigned version)
Definition: SG1000Pause.cc:46
Every class that wants to get scheduled at some point must inherit from this class.
Definition: Schedulable.hh:34
This file implemented 3 utility functions:
Definition: Autofire.cc:9
auto visit(Visitor &&visitor, const Event &event)
Definition: Event.hh:652
REGISTER_MSXDEVICE(ChakkariCopy, "ChakkariCopy")
#define INSTANTIATE_SERIALIZE_METHODS(CLASS)
Definition: serialize.hh:1009