openMSX
MSXSCCPlusCart.hh
Go to the documentation of this file.
1// Note: this device is actually called SCC-I. But this would take a lot of
2// renaming, which isn't worth it right now. TODO rename this :)
3
4#ifndef MSXSCCPLUSCART_HH
5#define MSXSCCPLUSCART_HH
6
7#include "MSXDevice.hh"
8#include "SCC.hh"
9#include "Ram.hh"
10#include "RomBlockDebuggable.hh"
11#include <array>
12
13namespace openmsx {
14
15class MSXSCCPlusCart final : public MSXDevice
16{
17public:
18 struct MapperConfig {
19 unsigned numBlocks; // number of 8kB blocks
20 byte registerMask; // mapper selection bits to ignore
21 byte registerOffset; // first mapped block
22 };
23
24public:
25 explicit MSXSCCPlusCart(const DeviceConfig& config);
26
27 void powerUp(EmuTime::param time) override;
28 void reset(EmuTime::param time) override;
29 [[nodiscard]] byte readMem(word address, EmuTime::param time) override;
30 [[nodiscard]] byte peekMem(word address, EmuTime::param time) const override;
31 void writeMem(word address, byte value, EmuTime::param time) override;
32 [[nodiscard]] const byte* getReadCacheLine(word start) const override;
33 [[nodiscard]] byte* getWriteCacheLine(word start) const override;
34
35 template<typename Archive>
36 void serialize(Archive& ar, unsigned version);
37
38private:
39 void setMapper(int region, byte value);
40 void setModeRegister(byte value);
41 void checkEnable();
42
43private:
44 const MapperConfig mapperConfig;
45 Ram ram;
46 SCC scc;
47 RomBlockDebuggable romBlockDebug;
48 std::array<byte*, 4> internalMemoryBank; // 4 blocks of 8kB starting at #4000
49 enum SCCEnable {EN_NONE, EN_SCC, EN_SCCPLUS} enable;
50 byte modeRegister;
51 std::array<bool, 4> isRamSegment;
52 std::array<bool, 4> isMapped;
53 std::array<byte, 4> mapper;
54};
55
56} // namespace openmsx
57
58#endif
An MSXDevice is an emulated hardware component connected to the bus of the emulated MSX.
Definition MSXDevice.hh:36
const byte * getReadCacheLine(word start) const override
Test that the memory in the interval [start, start + CacheLine::SIZE) is cacheable for reading.
void reset(EmuTime::param time) override
This method is called on reset.
void serialize(Archive &ar, unsigned version)
void writeMem(word address, byte value, EmuTime::param time) override
Write a given byte to a given location at a certain time to this device.
byte peekMem(word address, EmuTime::param time) const override
Read a byte from a given memory location.
byte readMem(word address, EmuTime::param time) override
Read a byte from a location at a certain time from this device.
byte * getWriteCacheLine(word start) const override
Test that the memory in the interval [start, start + CacheLine::SIZE) is cacheable for writing.
void powerUp(EmuTime::param time) override
This method is called when MSX is powered up.
This file implemented 3 utility functions:
Definition Autofire.cc:11
uint16_t word
16 bit unsigned integer
Definition openmsx.hh:29