OXYGENHUB
◆ main openmsx / src / SG1000Pause.cc
1.3 KiB · C++ · last changed chore(): initial commit 1 month ago source blame history raw
1
#include "SG1000Pause.hh"
2
3
#include "Event.hh"
4
#include "MSXCPU.hh"
5
#include "MSXEventDistributor.hh"
6
#include "MSXMotherBoard.hh"
7
#include "SDLKey.hh"
8
#include "serialize.hh"
9
10
namespace openmsx {
11
12
SG1000Pause::SG1000Pause(const DeviceConfig& config)
13
	: MSXDevice(config)
14
	, Schedulable(getMotherBoard().getScheduler())
15
{
16
	getMotherBoard().getMSXEventDistributor().registerEventListener(*this);
17
}
18
19
SG1000Pause::~SG1000Pause()
20
{
21
	getMotherBoard().getMSXEventDistributor().unregisterEventListener(*this);
22
}
23
24
void SG1000Pause::signalMSXEvent(const Event& event, EmuTime time) noexcept
25
{
26
	visit(overloaded{
27
		[&](const KeyDownEvent& keyEvent) {
28
			if (keyEvent.getKeyCode() == SDLK_F5) {
29
				setSyncPoint(time);
30
			}
31
		},
32
		[](const EventBase&) { /*ignore*/ }
33
	}, event);
34
}
35
36
void SG1000Pause::executeUntil(EmuTime /*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
}
50
INSTANTIATE_SERIALIZE_METHODS(SG1000Pause);
51
REGISTER_MSXDEVICE(SG1000Pause, "SG1000Pause");
52
53
} // namespace openmsx