OXYGENHUB
◆ main openmsx / src / input / CircuitDesignerRDDongle.cc
1.5 KiB · C++ · last changed chore(): initial commit 1 month ago source blame history raw
e8555c89 Andy McCall 1
#include "CircuitDesignerRDDongle.hh"
2
3
#include "serialize.hh"
4
#include "serialize_meta.hh"
5
6
/*
7
 The circuit designer RD dongle is a simple dongle that is used to protect the software.
8
 It needs to be plugged in Joystick port B, when it's not plugged in the software will
9
 add a reset command to the BLOAD hook which will reset the MSX.
10
11
     Pin 1 = Up
12
     Pin 6 = Button A
13
     Pin 7 = Button B
14
15
     Output  Input
16
     pin|pin|Pin (Up)
17
     7 | 6 | 1
18
     -----------------
19
     0 | 0 | 0
20
     0 | 1 | 1
21
     1 | 0 | 0
22
     1 | 1 | 0
23
*/
24
25
namespace openmsx {
26
27
// Pluggable
28
zstring_view CircuitDesignerRDDongle::getName() const
29
{
30
	return "circuit-designer-rd-dongle";
31
}
32
33
zstring_view CircuitDesignerRDDongle::getDescription() const
34
{
35
	return "Circuit Designer RD dongle";
36
}
37
38
void CircuitDesignerRDDongle::plugHelper(
39
	Connector& /*connector*/, EmuTime /*time*/)
40
{
41
}
42
43
void CircuitDesignerRDDongle::unplugHelper(EmuTime /*time*/)
44
{
45
}
46
47
48
// JoystickDevice
49
uint8_t CircuitDesignerRDDongle::read(EmuTime /*time*/)
50
{
51
	return status;
52
}
53
54
void CircuitDesignerRDDongle::write(uint8_t value, EmuTime /*time*/)
55
{
56
	if (!(value & WR_PIN7) && (value & WR_PIN6)) {
57
		status |=  JOY_UP;
58
	} else {
59
		status &= ~JOY_UP;
60
	}
61
}
62
63
template<typename Archive>
64
void CircuitDesignerRDDongle::serialize(Archive& /*ar*/, unsigned /*version*/)
65
{
66
	// no need to serialize 'status', port will anyway be re-written
67
	// on de-serialize
68
}
69
INSTANTIATE_SERIALIZE_METHODS(CircuitDesignerRDDongle);
70
REGISTER_POLYMORPHIC_INITIALIZER(Pluggable, CircuitDesignerRDDongle, "CircuitDesignerRDDongle");
71
72
} // namespace openmsx