| e8555c89 Andy McCall |
1 |
#ifndef SUNRISEIDE_HH |
| 2 |
#define SUNRISEIDE_HH |
| 3 |
|
| 4 |
#include "MSXDevice.hh" |
| 5 |
#include "Rom.hh" |
| 6 |
#include "RomBlockDebuggable.hh" |
| 7 |
|
| 8 |
#include <memory> |
| 9 |
#include <span> |
| 10 |
|
| 11 |
namespace openmsx { |
| 12 |
|
| 13 |
using uint4_t = uint8_t; |
| 14 |
|
| 15 |
class IDEDevice; |
| 16 |
|
| 17 |
class SunriseIDE final : public MSXDevice |
| 18 |
{ |
| 19 |
public: |
| 20 |
explicit SunriseIDE(DeviceConfig& config); |
| 21 |
~SunriseIDE() override; |
| 22 |
|
| 23 |
void powerUp(EmuTime time) override; |
| 24 |
void reset(EmuTime time) override; |
| 25 |
|
| 26 |
[[nodiscard]] uint8_t readMem(uint16_t address, EmuTime time) override; |
| 27 |
void writeMem(uint16_t address, uint8_t value, EmuTime time) override; |
| 28 |
[[nodiscard]] const uint8_t* getReadCacheLine(uint16_t start) const override; |
| 29 |
|
| 30 |
template<typename Archive> |
| 31 |
void serialize(Archive& ar, unsigned version); |
| 32 |
|
| 33 |
private: |
| 34 |
[[nodiscard]] uint8_t getBank() const; |
| 35 |
void writeControl(uint8_t value); |
| 36 |
|
| 37 |
[[nodiscard]] uint8_t readDataLow(EmuTime time); |
| 38 |
[[nodiscard]] uint8_t readDataHigh(EmuTime time) const; |
| 39 |
[[nodiscard]] uint16_t readData(EmuTime time); |
| 40 |
[[nodiscard]] uint8_t readReg(uint4_t reg, EmuTime time); |
| 41 |
void writeDataLow(uint8_t value); |
| 42 |
void writeDataHigh(uint8_t value, EmuTime time); |
| 43 |
void writeData(uint16_t value, EmuTime time); |
| 44 |
void writeReg(uint4_t reg, uint8_t value, EmuTime time); |
| 45 |
|
| 46 |
private: |
| 47 |
struct Blocks final : RomBlockDebuggableBase { |
| 48 |
explicit Blocks(const SunriseIDE& device); |
| 49 |
[[nodiscard]] unsigned readExt(unsigned address) override; |
| 50 |
} romBlockDebug; |
| 51 |
|
| 52 |
Rom rom; |
| 53 |
std::array<std::unique_ptr<IDEDevice>, 2> device; |
| 54 |
std::span<const uint8_t, 0x4000> internalBank; |
| 55 |
uint8_t readLatch = 0; |
| 56 |
uint8_t writeLatch = 0; |
| 57 |
uint8_t selectedDevice; |
| 58 |
uint8_t control; |
| 59 |
bool ideRegsEnabled = false; |
| 60 |
bool softReset; |
| 61 |
}; |
| 62 |
|
| 63 |
} |
| 64 |
|
| 65 |
#endif |