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 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
54private:
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
69private:
70 CassettePortInterface& cassettePort;
71 RenShaTurbo& renshaTurbo;
72 I8255 i8255;
73 KeyClick click;
74 Keyboard keyboard;
75 nibble prevBits = 15;
76 nibble selectedRow = 0;
77};
78
79} // namespace openmsx
80
81#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:42
~MSXPPI() override
Definition MSXPPI.cc:31
void reset(EmuTime::param time) override
This method is called on reset.
Definition MSXPPI.cc:36
byte peekIO(word port, EmuTime::param time) const override
Read a byte from a given IO port.
Definition MSXPPI.cc:52
void serialize(Archive &ar, unsigned version)
Definition MSXPPI.cc:140
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:47
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:57
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