openMSX
PrinterPortSimpl.cc
Go to the documentation of this file.
1 #include "PrinterPortSimpl.hh"
2 #include "DACSound8U.hh"
3 #include "DeviceConfig.hh"
4 #include "XMLElement.hh"
5 #include "serialize.hh"
6 #include <memory>
7 
8 namespace openmsx {
9 
11  : hwConf(hwConf_)
12 {
13 }
14 
16 
17 bool PrinterPortSimpl::getStatus(EmuTime::param /*time*/)
18 {
19  return true; // TODO check
20 }
21 
22 void PrinterPortSimpl::setStrobe(bool /*strobe*/, EmuTime::param /*time*/)
23 {
24  // ignore strobe // TODO check
25 }
26 
27 void PrinterPortSimpl::writeData(byte data, EmuTime::param time)
28 {
29  dac->writeDAC(data, time);
30 }
31 
32 static XMLElement createXML()
33 {
34  XMLElement xml("simpl");
35  xml.addChild("sound").addChild("volume", "12000");
36  return xml;
37 }
38 
39 void PrinterPortSimpl::createDAC()
40 {
41  static XMLElement xml = createXML();
42  dac = std::make_unique<DACSound8U>("simpl", getDescription(),
43  DeviceConfig(hwConf, xml));
44 }
45 
46 void PrinterPortSimpl::plugHelper(Connector& /*connector*/, EmuTime::param /*time*/)
47 {
48  createDAC();
49 }
50 
51 void PrinterPortSimpl::unplugHelper(EmuTime::param /*time*/)
52 {
53  dac.reset();
54 }
55 
56 const std::string& PrinterPortSimpl::getName() const
57 {
58  static const std::string name("simpl");
59  return name;
60 }
61 
62 std::string_view PrinterPortSimpl::getDescription() const
63 {
64  return "Play samples via your printer port.";
65 }
66 
67 template<typename Archive>
68 void PrinterPortSimpl::serialize(Archive& ar, unsigned /*version*/)
69 {
70  if (isPluggedIn()) {
71  if (ar.isLoader()) {
72  createDAC();
73  }
74  ar.serialize("dac", *dac);
75  }
76 }
79 
80 } // namespace openmsx
openmsx::PrinterPortSimpl::PrinterPortSimpl
PrinterPortSimpl(const HardwareConfig &hwConf)
Definition: PrinterPortSimpl.cc:10
openmsx::PrinterPortSimpl::getStatus
bool getStatus(EmuTime::param time) override
Returns the STATUS signal: false = low = ready, true = high = not ready.
Definition: PrinterPortSimpl.cc:17
serialize.hh
openmsx::PrinterPortSimpl::writeData
void writeData(byte data, EmuTime::param time) override
Sets the data signals.
Definition: PrinterPortSimpl.cc:27
openmsx::XMLElement
XMLElement
Definition: XMLElement.cc:350
openmsx::PrinterPortSimpl::plugHelper
void plugHelper(Connector &connector, EmuTime::param time) override
Definition: PrinterPortSimpl.cc:46
openmsx::PrinterPortSimpl::getName
const std::string & getName() const override
Name used to identify this pluggable.
Definition: PrinterPortSimpl.cc:56
XMLElement.hh
openmsx::Pluggable
Definition: Pluggable.hh:12
PrinterPortSimpl.hh
openmsx::PrinterPortSimpl::~PrinterPortSimpl
~PrinterPortSimpl() override
openmsx::XMLElement
Definition: XMLElement.hh:16
INSTANTIATE_SERIALIZE_METHODS
#define INSTANTIATE_SERIALIZE_METHODS(CLASS)
Definition: serialize.hh:981
DACSound8U.hh
openmsx::PrinterPortSimpl::serialize
void serialize(Archive &ar, unsigned version)
Definition: PrinterPortSimpl.cc:68
openmsx::PrinterPortSimpl::getDescription
std::string_view getDescription() const override
Description for this pluggable.
Definition: PrinterPortSimpl.cc:62
openmsx::PrinterPortSimpl::setStrobe
void setStrobe(bool strobe, EmuTime::param time) override
Sets the strobe signal: false = low, true = high.
Definition: PrinterPortSimpl.cc:22
openmsx::Connector
Represents something you can plug devices into.
Definition: Connector.hh:21
openmsx::HardwareConfig
Definition: HardwareConfig.hh:22
openmsx::PrinterPortSimpl::unplugHelper
void unplugHelper(EmuTime::param time) override
Definition: PrinterPortSimpl.cc:51
openmsx::Pluggable::isPluggedIn
bool isPluggedIn() const
Returns true if this pluggable is currently plugged into a connector.
Definition: Pluggable.hh:49
DeviceConfig.hh
openmsx
This file implemented 3 utility functions:
Definition: Autofire.cc:5
openmsx::REGISTER_POLYMORPHIC_INITIALIZER
REGISTER_POLYMORPHIC_INITIALIZER(Pluggable, CassettePlayer, "CassettePlayer")
openmsx::PrinterPortSimpl
Definition: PrinterPortSimpl.hh:13