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
34namespace openmsx {
35
36class CassettePortInterface;
37class RenShaTurbo;
38
39class MSXPPI final : public MSXDevice, public I8255Interface
40{
41public:
42 explicit MSXPPI(const DeviceConfig& config);
43 ~MSXPPI() override;
44
45 [[nodiscard]] const Keyboard& getKeyboard() const;
46
47 void reset(EmuTime::param time) override;
48 void powerDown(EmuTime::param time) override;
49 [[nodiscard]] byte readIO(word port, EmuTime::param time) override;
50 [[nodiscard]] byte peekIO(word port, EmuTime::param time) const override;
51 void writeIO(word port, byte value, EmuTime::param time) override;
52
53 template<typename Archive>
54 void serialize(Archive& ar, unsigned version);
55
56private:
57 // I8255Interface
58 [[nodiscard]] byte readA(EmuTime::param time) override;
59 [[nodiscard]] byte readB(EmuTime::param time) override;
60 [[nodiscard]] nibble readC0(EmuTime::param time) override;
61 [[nodiscard]] nibble readC1(EmuTime::param time) override;
62 [[nodiscard]] byte peekA(EmuTime::param time) const override;
63 [[nodiscard]] byte peekB(EmuTime::param time) const override;
64 [[nodiscard]] nibble peekC0(EmuTime::param time) const override;
65 [[nodiscard]] nibble peekC1(EmuTime::param time) const override;
66 void writeA(byte value, EmuTime::param time) override;
67 void writeB(byte value, EmuTime::param time) override;
68 void writeC0(nibble value, EmuTime::param time) override;
69 void writeC1(nibble value, EmuTime::param time) override;
70
71private:
72 CassettePortInterface& cassettePort;
73 RenShaTurbo& renshaTurbo;
74 I8255 i8255;
75 KeyClick click;
76 Keyboard keyboard;
77 nibble prevBits = 15;
78 nibble selectedRow = 0;
79};
80
81} // namespace openmsx
82
83#endif
An MSXDevice is an emulated hardware component connected to the bus of the emulated MSX.
Definition MSXDevice.hh:36
void powerDown(EmuTime::param time) override
This method is called when MSX is powered down.
Definition MSXPPI.cc:46
~MSXPPI() override
Definition MSXPPI.cc:31
void reset(EmuTime::param time) override
This method is called on reset.
Definition MSXPPI.cc:40
const Keyboard & getKeyboard() const
Definition MSXPPI.cc:36
byte peekIO(word port, EmuTime::param time) const override
Read a byte from a given IO port.
Definition MSXPPI.cc:56
void serialize(Archive &ar, unsigned version)
Definition MSXPPI.cc:145
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:51
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:61
Ren-Sha Turbo is the autofire in several MSX 2+ models and in the MSX turbo R.
This file implemented 3 utility functions:
Definition Autofire.cc:11
uint8_t nibble
4 bit integer
Definition openmsx.hh:23
uint16_t word
16 bit unsigned integer
Definition openmsx.hh:29