openMSX
MSXPPI.hh
Go to the documentation of this file.
1 // This class implements the PPI (8255)
2 //
3 // PPI MSX-I/O Direction MSX-Function
4 // PortA 0xA8 Out Memory primary slot register
5 // PortB 0xA9 In Keyboard column inputs
6 // PortC 0xAA Out Keyboard row select / CAPS / CASo / CASm / SND
7 // Control 0xAB In/Out Mode select for PPI
8 //
9 // Direction indicates the direction normally used on MSX.
10 // Reading from an output port returns the last written byte.
11 // Writing to an input port has no immediate effect.
12 //
13 // PortA combined with upper half of PortC form groupA
14 // PortB lower groupB
15 // GroupA can be in programmed in 3 modes
16 // - basic input/output
17 // - strobed input/output
18 // - bidirectional
19 // GroupB can only use the first two modes.
20 // Only the first mode is used on MSX, only this mode is implemented yet.
21 //
22 // for more detail see
23 // http://w3.qahwah.net/joost/openMSX/8255.pdf
24 
25 #ifndef MSXPPI_HH
26 #define MSXPPI_HH
27 
28 #include "MSXDevice.hh"
29 #include "I8255Interface.hh"
30 #include "I8255.hh"
31 #include "Keyboard.hh"
32 #include "KeyClick.hh"
33 
34 namespace openmsx {
35 
36 class CassettePortInterface;
37 class RenShaTurbo;
38 
39 class MSXPPI final : public MSXDevice, public I8255Interface
40 {
41 public:
42  explicit MSXPPI(const DeviceConfig& config);
43  ~MSXPPI() override;
44 
45  void reset(EmuTime::param time) override;
46  void powerDown(EmuTime::param time) override;
47  [[nodiscard]] byte readIO(word port, EmuTime::param time) override;
48  [[nodiscard]] byte peekIO(word port, EmuTime::param time) const override;
49  void writeIO(word port, byte value, EmuTime::param time) override;
50 
51  template<typename Archive>
52  void serialize(Archive& ar, unsigned version);
53 
54 private:
55  // I8255Interface
56  [[nodiscard]] byte readA(EmuTime::param time) override;
57  [[nodiscard]] byte readB(EmuTime::param time) override;
58  [[nodiscard]] nibble readC0(EmuTime::param time) override;
59  [[nodiscard]] nibble readC1(EmuTime::param time) override;
60  [[nodiscard]] byte peekA(EmuTime::param time) const override;
61  [[nodiscard]] byte peekB(EmuTime::param time) const override;
62  [[nodiscard]] nibble peekC0(EmuTime::param time) const override;
63  [[nodiscard]] nibble peekC1(EmuTime::param time) const override;
64  void writeA(byte value, EmuTime::param time) override;
65  void writeB(byte value, EmuTime::param time) override;
66  void writeC0(nibble value, EmuTime::param time) override;
67  void writeC1(nibble value, EmuTime::param time) override;
68 
69 private:
70  CassettePortInterface& cassettePort;
71  RenShaTurbo& renshaTurbo;
72  I8255 i8255;
73  KeyClick click;
74  Keyboard keyboard;
75  nibble prevBits;
76  nibble selectedRow;
77 };
78 
79 } // namespace openmsx
80 
81 #endif
openmsx::MSXDevice
An MSXDevice is an emulated hardware component connected to the bus of the emulated MSX.
Definition: MSXDevice.hh:32
openmsx::MSXPPI::powerDown
void powerDown(EmuTime::param time) override
This method is called when MSX is powered down.
Definition: MSXPPI.cc:44
I8255.hh
openmsx::DeviceConfig
Definition: DeviceConfig.hh:20
openmsx::MSXPPI
Definition: MSXPPI.hh:40
openmsx::MSXPPI::serialize
void serialize(Archive &ar, unsigned version)
Definition: MSXPPI.cc:143
openmsx::MSXPPI::~MSXPPI
~MSXPPI() override
Definition: MSXPPI.cc:33
openmsx::MSXPPI::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: MSXPPI.cc:59
openmsx::MSXPPI::MSXPPI
MSXPPI(const DeviceConfig &config)
Definition: MSXPPI.cc:13
openmsx::nibble
uint8_t nibble
4 bit integer
Definition: openmsx.hh:23
MSXDevice.hh
openmsx::CassettePortInterface
Definition: CassettePort.hh:19
openmsx::Keyboard
Definition: Keyboard.hh:37
openmsx::I8255
Definition: I8255.hh:20
I8255Interface.hh
Keyboard.hh
openmsx::word
uint16_t word
16 bit unsigned integer
Definition: openmsx.hh:29
openmsx::MSXPPI::readIO
byte readIO(word port, EmuTime::param time) override
Read a byte from an IO port at a certain time from this device.
Definition: MSXPPI.cc:49
openmsx::KeyClick
Definition: KeyClick.hh:12
openmsx::RenShaTurbo
Ren-Sha Turbo is the autofire in several MSX 2+ models and in the MSX turbo R.
Definition: RenShaTurbo.hh:21
openmsx::I8255Interface
Definition: I8255Interface.hh:10
openmsx
This file implemented 3 utility functions:
Definition: Autofire.cc:5
openmsx::MSXPPI::peekIO
byte peekIO(word port, EmuTime::param time) const override
Read a byte from a given IO port.
Definition: MSXPPI.cc:54
openmsx::MSXPPI::reset
void reset(EmuTime::param time) override
This method is called on reset.
Definition: MSXPPI.cc:38
KeyClick.hh