openMSX
Y8950KeyboardConnector.cc
Go to the documentation of this file.
2 #include "Y8950KeyboardDevice.hh"
4 #include "checked_cast.hh"
5 #include "serialize.hh"
6 #include <memory>
7 
8 namespace openmsx {
9 
11  PluggingController& pluggingController_)
12  : Connector(pluggingController_, "audiokeyboardport",
13  std::make_unique<DummyY8950KeyboardDevice>())
14  , data(255)
15 {
16 }
17 
18 void Y8950KeyboardConnector::write(byte newData, EmuTime::param time)
19 {
20  if (newData != data) {
21  data = newData;
22  getPluggedKeyb().write(data, time);
23  }
24 }
25 
26 byte Y8950KeyboardConnector::read(EmuTime::param time)
27 {
28  return getPluggedKeyb().read(time);
29 }
30 
31 byte Y8950KeyboardConnector::peek(EmuTime::param time) const
32 {
33  // TODO implement proper peek
34  return const_cast<Y8950KeyboardConnector*>(this)->read(time);
35 }
36 
38 {
39  return "MSX-AUDIO keyboard connector";
40 }
41 
42 std::string_view Y8950KeyboardConnector::getClass() const
43 {
44  return "Y8950 Keyboard Port";
45 }
46 
47 void Y8950KeyboardConnector::plug(Pluggable& dev, EmuTime::param time)
48 {
49  Connector::plug(dev, time);
50  getPluggedKeyb().write(data, time);
51 }
52 
54 {
55  return *checked_cast<Y8950KeyboardDevice*>(&getPlugged());
56 }
57 
58 template<typename Archive>
59 void Y8950KeyboardConnector::serialize(Archive& ar, unsigned /*version*/)
60 {
61  ar.template serializeBase<Connector>(*this);
62  // don't serialize 'data', done in Y8950
63 }
65 
66 } // namespace openmsx
serialize.hh
openmsx::Y8950KeyboardDevice::read
virtual byte read(EmuTime::param time)=0
Read data from the device.
openmsx::DummyY8950KeyboardDevice
Definition: DummyY8950KeyboardDevice.hh:9
openmsx::Y8950KeyboardConnector::serialize
void serialize(Archive &ar, unsigned version)
Definition: Y8950KeyboardConnector.cc:59
openmsx::Y8950KeyboardConnector::getPluggedKeyb
Y8950KeyboardDevice & getPluggedKeyb() const
Definition: Y8950KeyboardConnector.cc:53
openmsx::Y8950KeyboardConnector::getClass
std::string_view getClass() const final override
A Connector belong to a certain class.
Definition: Y8950KeyboardConnector.cc:42
openmsx::Pluggable
Definition: Pluggable.hh:12
openmsx::Y8950KeyboardConnector::Y8950KeyboardConnector
Y8950KeyboardConnector(PluggingController &pluggingController)
Definition: Y8950KeyboardConnector.cc:10
openmsx::Y8950KeyboardConnector::plug
void plug(Pluggable &dev, EmuTime::param time) override
This plugs a Pluggable in this Connector.
Definition: Y8950KeyboardConnector.cc:47
Y8950KeyboardConnector.hh
openmsx::Y8950KeyboardDevice::write
virtual void write(byte data, EmuTime::param time)=0
Send data to the device.
INSTANTIATE_SERIALIZE_METHODS
#define INSTANTIATE_SERIALIZE_METHODS(CLASS)
Definition: serialize.hh:981
openmsx::Connector::plug
virtual void plug(Pluggable &device, EmuTime::param time)
This plugs a Pluggable in this Connector.
Definition: Connector.cc:25
openmsx::Y8950KeyboardConnector::read
byte read(EmuTime::param time)
Definition: Y8950KeyboardConnector.cc:26
checked_cast.hh
openmsx::Y8950KeyboardDevice
Definition: Y8950KeyboardDevice.hh:10
openmsx::Y8950KeyboardConnector
Definition: Y8950KeyboardConnector.hh:12
openmsx::Connector
Represents something you can plug devices into.
Definition: Connector.hh:21
Y8950KeyboardDevice.hh
DummyY8950KeyboardDevice.hh
openmsx::Y8950KeyboardConnector::getDescription
std::string_view getDescription() const final override
Get a description for this connector.
Definition: Y8950KeyboardConnector.cc:37
openmsx::PluggingController
Central administration of Connectors and Pluggables.
Definition: PluggingController.hh:22
openmsx
This file implemented 3 utility functions:
Definition: Autofire.cc:5
openmsx::Connector::getPlugged
Pluggable & getPlugged() const
Returns the Pluggable currently plugged in.
Definition: Connector.hh:59
openmsx::Y8950KeyboardConnector::write
void write(byte data, EmuTime::param time)
Definition: Y8950KeyboardConnector.cc:18
openmsx::Y8950KeyboardConnector::peek
byte peek(EmuTime::param time) const
Definition: Y8950KeyboardConnector.cc:31