openMSX
MSXTurboRPause.cc
Go to the documentation of this file.
1#include "MSXTurboRPause.hh"
2#include "LedStatus.hh"
3#include "MSXMotherBoard.hh"
4#include "serialize.hh"
5
6namespace openmsx {
7
9 : MSXDevice(config)
10 , pauseSetting(
11 getCommandController(), "turborpause",
12 "status of the TurboR pause", false)
13 , status(255)
14 , pauseLed(false)
15 , turboLed(false)
16 , hwPause(false)
17{
18 pauseSetting.attach(*this);
19 reset(EmuTime::dummy());
20}
21
23{
24 powerDown(EmuTime::dummy());
25 pauseSetting.detach(*this);
26}
27
28void MSXTurboRPause::powerDown(EmuTime::param time)
29{
30 writeIO(0, 0, time); // send LED OFF events (if needed)
31}
32
33void MSXTurboRPause::reset(EmuTime::param time)
34{
35 pauseSetting.setBoolean(false);
36 writeIO(0, 0, time);
37}
38
39byte MSXTurboRPause::readIO(word port, EmuTime::param time)
40{
41 return peekIO(port, time);
42}
43
44byte MSXTurboRPause::peekIO(word /*port*/, EmuTime::param /*time*/) const
45{
46 return pauseSetting.getBoolean() ? 1 : 0;
47}
48
49void MSXTurboRPause::writeIO(word /*port*/, byte value, EmuTime::param /*time*/)
50{
51 status = value;
52 bool newTurboLed = (status & 0x80) != 0;
53 if (newTurboLed != turboLed) {
54 turboLed = newTurboLed;
56 }
57 updatePause();
58}
59
60void MSXTurboRPause::update(const Setting& /*setting*/) noexcept
61{
62 updatePause();
63}
64
65void MSXTurboRPause::updatePause()
66{
67 bool newHwPause = (status & 0x02) && pauseSetting.getBoolean();
68 if (newHwPause != hwPause) {
69 hwPause = newHwPause;
70 if (hwPause) {
72 } else {
74 }
75 }
76
77 bool newPauseLed = (status & 0x01) || hwPause;
78 if (newPauseLed != pauseLed) {
79 pauseLed = newPauseLed;
81 }
82}
83
84template<typename Archive>
85void MSXTurboRPause::serialize(Archive& ar, unsigned /*version*/)
86{
87 ar.template serializeBase<MSXDevice>(*this);
88 ar.serialize("status", status);
89 if constexpr (Archive::IS_LOADER) {
90 writeIO(0, status, EmuTime::dummy());
91 }
92}
95
96} // namespace openmsx
bool getBoolean() const noexcept
void setLed(Led led, bool status)
Definition: LedStatus.cc:40
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
LedStatus & getLedStatus() const
Definition: MSXDevice.cc:154
void pause()
Pause MSX machine.
This class implements the MSX Turbo-R pause key.
void writeIO(word port, byte value, EmuTime::param time) override
Write a byte to a given IO port at a certain time to this device.
MSXTurboRPause(const DeviceConfig &config)
void powerDown(EmuTime::param time) override
This method is called when MSX is powered down.
byte readIO(word port, EmuTime::param time) override
Read a byte from an IO port at a certain time from this device.
byte peekIO(word port, EmuTime::param time) const override
Read a byte from a given IO port.
void reset(EmuTime::param time) override
This method is called on reset.
void serialize(Archive &ar, unsigned version)
void detach(Observer< T > &observer)
Definition: Subject.hh:56
void attach(Observer< T > &observer)
Definition: Subject.hh:50
This file implemented 3 utility functions:
Definition: Autofire.cc:9
REGISTER_MSXDEVICE(ChakkariCopy, "ChakkariCopy")
uint16_t word
16 bit unsigned integer
Definition: openmsx.hh:29
#define INSTANTIATE_SERIALIZE_METHODS(CLASS)
Definition: serialize.hh:1009