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 "AY8910.hh"
6 #include "AY8910Periphery.hh"
7 #include "serialize_meta.hh"
8 #include <array>
9 
10 namespace openmsx {
11 
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  [[nodiscard]] byte readIO(word port, EmuTime::param time) override;
25  [[nodiscard]] 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  [[nodiscard]] byte readA(EmuTime::param time) override;
34  void writeB(byte value, EmuTime::param time) override;
35 
36 private:
37  CassettePortInterface& cassette;
38  RenShaTurbo& renShaTurbo;
39 
40  std::array<JoystickPortIf*, 2> ports;
41  int selectedPort;
42  int registerLatch;
43  byte prev;
44  const byte keyLayout; // 0x40 or 0x00
45  const byte addressMask; // controls address mirroring
46  AY8910 ay8910; // must come after initialisation of most stuff above
47 };
49 
50 } // namespace openmsx
51 
52 #endif
Models the general purpose I/O ports of the AY8910.
This class implements the AY-3-8910 sound chip.
Definition: AY8910.hh:20
An MSXDevice is an emulated hardware component connected to the bus of the emulated MSX.
Definition: MSXDevice.hh:33
MSXPSG(const DeviceConfig &config)
Definition: MSXPSG.cc:32
void powerDown(EmuTime::param time) override
This method is called when MSX is powered down.
Definition: MSXPSG.cc:57
~MSXPSG() override
Definition: MSXPSG.cc:46
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:72
void serialize(Archive &ar, unsigned version)
Definition: MSXPSG.cc:116
void reset(EmuTime::param time) override
This method is called on reset.
Definition: MSXPSG.cc:51
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:62
byte peekIO(word port, EmuTime::param time) const override
Read a byte from a given IO port.
Definition: MSXPSG.cc:67
Ren-Sha Turbo is the autofire in several MSX 2+ models and in the MSX turbo R.
Definition: RenShaTurbo.hh:21
This file implemented 3 utility functions:
Definition: Autofire.cc:9
uint16_t word
16 bit unsigned integer
Definition: openmsx.hh:29
SERIALIZE_CLASS_VERSION(CassettePlayer, 2)