openMSX
MSXPSG.hh
Go to the documentation of this file.
1 #ifndef MSXPSG_HH
2 #define MSXPSG_HH
3 
4 #include "MSXDevice.hh"
5 #include "AY8910Periphery.hh"
6 #include "serialize_meta.hh"
7 #include <memory>
8 
9 namespace openmsx {
10 
11 class AY8910;
12 class CassettePortInterface;
13 class RenShaTurbo;
14 class JoystickPortIf;
15 
16 class MSXPSG final : public MSXDevice, public AY8910Periphery
17 {
18 public:
19  explicit MSXPSG(const DeviceConfig& config);
20  ~MSXPSG() override;
21 
22  void reset(EmuTime::param time) override;
23  void powerDown(EmuTime::param time) override;
24  byte readIO(word port, EmuTime::param time) override;
25  byte peekIO(word port, EmuTime::param time) const override;
26  void writeIO(word port, byte value, EmuTime::param time) override;
27 
28  template<typename Archive>
29  void serialize(Archive& ar, unsigned version);
30 
31 private:
32  // AY8910Periphery: port A input, port B output
33  byte readA(EmuTime::param time) override;
34  void writeB(byte value, EmuTime::param time) override;
35 
36  CassettePortInterface& cassette;
37  RenShaTurbo& renShaTurbo;
38 
39  JoystickPortIf* ports[2];
40  int selectedPort;
41  int registerLatch;
42  byte prev;
43  const byte keyLayout; // 0x40 or 0x00
44  const byte addressMask; // controls address mirroring
45  // TODO could be by-value, but visual studio doesn't support
46  // initialization of arrays (ports[2]) in the initializer list yet.
47  std::unique_ptr<AY8910> ay8910; // must come after initialisation of most stuff above
48 };
50 
51 } // namespace openmsx
52 
53 #endif
openmsx::MSXDevice
An MSXDevice is an emulated hardware component connected to the bus of the emulated MSX.
Definition: MSXDevice.hh:32
openmsx::MSXPSG::reset
void reset(EmuTime::param time) override
This method is called on reset.
Definition: MSXPSG.cc:36
openmsx::MSXPSG::readIO
byte readIO(word port, EmuTime::param time) override
Read a byte from an IO port at a certain time from this device.
Definition: MSXPSG.cc:47
openmsx::MSXPSG::serialize
void serialize(Archive &ar, unsigned version)
Definition: MSXPSG.cc:101
openmsx::MSXPSG::writeIO
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.
Definition: MSXPSG.cc:57
openmsx::DeviceConfig
Definition: DeviceConfig.hh:20
openmsx::MSXPSG
Definition: MSXPSG.hh:17
serialize_meta.hh
openmsx::MSXPSG::MSXPSG
MSXPSG(const DeviceConfig &config)
Definition: MSXPSG.cc:15
openmsx::AY8910
AY8910
Definition: AY8910.cc:1025
openmsx::AY8910Periphery
Models the general purpose I/O ports of the AY8910.
Definition: AY8910Periphery.hh:15
openmsx::JoystickPortIf
Definition: JoystickPort.hh:13
openmsx::MSXPSG::peekIO
byte peekIO(word port, EmuTime::param time) const override
Read a byte from a given IO port.
Definition: MSXPSG.cc:52
openmsx::SERIALIZE_CLASS_VERSION
SERIALIZE_CLASS_VERSION(CassettePlayer, 2)
openmsx::MSXPSG::~MSXPSG
~MSXPSG() override
Definition: MSXPSG.cc:31
MSXDevice.hh
openmsx::CassettePortInterface
Definition: CassettePort.hh:19
openmsx::word
uint16_t word
16 bit unsigned integer
Definition: openmsx.hh:29
openmsx::RenShaTurbo
Ren-Sha Turbo is the autofire in several MSX 2+ models and in the MSX turbo R.
Definition: RenShaTurbo.hh:21
openmsx::MSXPSG::powerDown
void powerDown(EmuTime::param time) override
This method is called when MSX is powered down.
Definition: MSXPSG.cc:42
openmsx
This file implemented 3 utility functions:
Definition: Autofire.cc:5
AY8910Periphery.hh