openMSX
BeerIDE.hh
Go to the documentation of this file.
1 #ifndef BEERIDE_HH
2 #define BEERIDE_HH
3 
4 // Based on the blueMSX implementation:
5 // Source: /cygdrive/d/Private/_SVNROOT/bluemsx/blueMSX/Src/Memory/romMapperBeerIDE.c,v Revision: 1.9 Date: 2008-03-31 19:42:22
6 
7 /*
8 PPI NAME IDE PIN
9 --- ---- -------
10 PA0 HD0 17 D0
11 PA1 HD1 15 D1
12 PA2 HD2 13 D2
13 PA3 HD3 11 D3
14 PA4 HD4 9 D4
15 PA5 HD5 7 D5
16 PA6 HD6 5 D6
17 PA7 HD7 3 D7
18 
19 PB0 HD8 4 D8
20 PB1 HD9 6 D9
21 PB2 HD10 8 D10
22 PB3 HD11 10 D11
23 PB4 HD12 12 D12
24 PB5 HD13 14 D13
25 PB6 HD14 16 D14
26 PB7 HD15 18 D15
27 
28 PC0 HA0 35 A0
29 PC1 HA1 33 A1
30 PC2 HA2 36 A2
31 PC3 N/A
32 PC4 N/A
33 PC5 HCS 37 /CS0
34 PC6 HWR 23 /IOWR
35 PC7 HRD 25 /IORD
36 */
37 
38 
39 #include "MSXDevice.hh"
40 #include "I8255Interface.hh"
41 #include "I8255.hh"
42 #include "Rom.hh"
43 #include <memory>
44 
45 namespace openmsx {
46 
47 class IDEDevice;
48 
49 class BeerIDE final : public MSXDevice, public I8255Interface
50 {
51 public:
52  explicit BeerIDE(const DeviceConfig& config);
53  ~BeerIDE() override;
54 
55  void reset(EmuTime::param time) override;
56 
57  byte readMem(word address, EmuTime::param time) override;
58  const byte* getReadCacheLine(word start) const override;
59 
60  byte peekIO(word port, EmuTime::param time) const override;
61  byte readIO(word port, EmuTime::param time) override;
62  void writeIO(word port, byte value, EmuTime::param time) override;
63 
64  template<typename Archive>
65  void serialize(Archive& ar, unsigned version);
66 
67 private:
68  void changeControl(byte value, EmuTime::param time);
69 
70  // I8255Interface
71  byte readA(EmuTime::param time) override;
72  byte readB(EmuTime::param time) override;
73  nibble readC0(EmuTime::param time) override;
74  nibble readC1(EmuTime::param time) override;
75  byte peekA(EmuTime::param time) const override;
76  byte peekB(EmuTime::param time) const override;
77  nibble peekC0(EmuTime::param time) const override;
78  nibble peekC1(EmuTime::param time) const override;
79  void writeA(byte value, EmuTime::param time) override;
80  void writeB(byte value, EmuTime::param time) override;
81  void writeC0(nibble value, EmuTime::param time) override;
82  void writeC1(nibble value, EmuTime::param time) override;
83 
84  I8255 i8255;
85  Rom rom;
86  std::unique_ptr<IDEDevice> device;
87  word dataReg;
88  byte controlReg;
89 };
90 
91 } // namespace openmsx
92 
93 #endif
uint8_t byte
8 bit unsigned integer
Definition: openmsx.hh:26
~BeerIDE() override
const byte * getReadCacheLine(word start) const override
Test that the memory in the interval [start, start + CacheLine::SIZE) is cacheable for reading...
Definition: BeerIDE.cc:37
void reset(EmuTime::param time) override
This method is called on reset.
Definition: BeerIDE.cc:21
void serialize(Archive &ar, unsigned version)
Definition: BeerIDE.cc:142
Thanks to enen for testing this on a real cartridge:
Definition: Autofire.cc:5
An MSXDevice is an emulated hardware component connected to the bus of the emulated MSX...
Definition: MSXDevice.hh:31
byte readMem(word address, EmuTime::param time) override
Read a byte from a location at a certain time from this device.
Definition: BeerIDE.cc:29
uint8_t nibble
4 bit integer
Definition: openmsx.hh:23
BeerIDE(const DeviceConfig &config)
Definition: BeerIDE.cc:8
uint16_t word
16 bit unsigned integer
Definition: openmsx.hh:29
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: BeerIDE.cc:55
byte readIO(word port, EmuTime::param time) override
Read a byte from an IO port at a certain time from this device.
Definition: BeerIDE.cc:45
byte peekIO(word port, EmuTime::param time) const override
Read a byte from a given IO port.
Definition: BeerIDE.cc:50