| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
#ifndef MSXSCCPLUSCART_HH |
| 5 |
#define MSXSCCPLUSCART_HH |
| 6 |
|
| 7 |
#include "SCC.hh" |
| 8 |
|
| 9 |
#include "MSXDevice.hh" |
| 10 |
#include "Ram.hh" |
| 11 |
#include "RomBlockDebuggable.hh" |
| 12 |
|
| 13 |
#include <array> |
| 14 |
#include <cstdint> |
| 15 |
|
| 16 |
namespace openmsx { |
| 17 |
|
| 18 |
class MSXSCCPlusCart final : public MSXDevice |
| 19 |
{ |
| 20 |
public: |
| 21 |
struct MapperConfig { |
| 22 |
unsigned numBlocks; |
| 23 |
byte registerMask; |
| 24 |
byte registerOffset; |
| 25 |
}; |
| 26 |
|
| 27 |
public: |
| 28 |
explicit MSXSCCPlusCart(const DeviceConfig& config); |
| 29 |
|
| 30 |
void powerUp(EmuTime time) override; |
| 31 |
void reset(EmuTime time) override; |
| 32 |
[[nodiscard]] byte readMem(uint16_t address, EmuTime time) override; |
| 33 |
[[nodiscard]] byte peekMem(uint16_t address, EmuTime time) const override; |
| 34 |
void writeMem(uint16_t address, byte value, EmuTime time) override; |
| 35 |
[[nodiscard]] const byte* getReadCacheLine(uint16_t start) const override; |
| 36 |
[[nodiscard]] byte* getWriteCacheLine(uint16_t start) override; |
| 37 |
|
| 38 |
template<typename Archive> |
| 39 |
void serialize(Archive& ar, unsigned version); |
| 40 |
|
| 41 |
private: |
| 42 |
void setMapper(int region, byte value); |
| 43 |
void setModeRegister(byte value); |
| 44 |
void checkEnable(); |
| 45 |
|
| 46 |
private: |
| 47 |
const MapperConfig mapperConfig; |
| 48 |
Ram ram; |
| 49 |
SCC scc; |
| 50 |
RomBlockDebuggable romBlockDebug; |
| 51 |
std::array<byte*, 4> internalMemoryBank; |
| 52 |
enum SCCEnable : uint8_t {EN_NONE, EN_SCC, EN_SCCPLUS} enable; |
| 53 |
byte modeRegister; |
| 54 |
std::array<bool, 4> isRamSegment; |
| 55 |
std::array<bool, 4> isMapped; |
| 56 |
std::array<byte, 4> mapper; |
| 57 |
}; |
| 58 |
|
| 59 |
} |
| 60 |
|
| 61 |
#endif |