59 unsigned ESE_SCC::getSramSize(
bool withSCSI)
const
62 if (sramSize !=
one_of(1024u, 512u, 256u, 128u)) {
65 " should be 128, 256, 512 or 1024kB and not ",
68 if (!withSCSI && sramSize == 1024) {
69 throw MSXException(
"1024kB SRAM is only allowed in WAVE-SCSI!");
71 return sramSize * 1024;
76 , sram(
getName() +
" SRAM", getSramSize(withSCSI), config)
77 , scc(
getName(), config, getCurrentTime())
78 , spc(withSCSI ? std::make_unique<
MB89352>(config) : nullptr)
79 , romBlockDebug(*this, mapper, 0x4000, 0x8000, 13)
80 , mapperMask((sram.getSize() / 0x2000) - 1)
102 if (spc) spc->reset(
true);
105 void ESE_SCC::setMapperLow(
unsigned page,
byte value)
110 bool newSccEnable = (value == 0x3f);
111 if (newSccEnable != sccEnable) {
112 sccEnable = newSccEnable;
116 byte newValue = value;
117 if (page == 0) newValue |= mapper[0] & 0x40;
118 newValue &= mapperMask;
119 if (mapper[page] != newValue) {
120 mapper[page] = newValue;
128 void ESE_SCC::setMapperHigh(
byte value)
130 writeEnable = (value & 0x10) != 0;
134 byte mapperHigh = value & 0x40;
135 bool newSpcEnable = mapperHigh && !writeEnable;
136 if (spcEnable != newSpcEnable) {
137 spcEnable = newSpcEnable;
141 byte newValue = ((mapper[0] & 0x3F) | mapperHigh) & mapperMask;
142 if (mapper[0] != newValue) {
143 mapper[0] = newValue;
153 unsigned page = address / 0x2000 - 2;
155 if (spcEnable && (page == 0)) {
157 if (address < 0x1000) {
158 return spc->readDREG();
160 return spc->readRegister(address & 0x0f);
164 if (sccEnable && (address >= 0x9800) && (address < 0xa000)) {
165 return scc.
readMem(address & 0xff, time);
168 return sram[mapper[page] * 0x2000 + (address & 0x1fff)];
173 unsigned page = address / 0x2000 - 2;
175 if (spcEnable && (page == 0)) {
177 if (address < 0x1000) {
178 return spc->peekDREG();
180 return spc->peekRegister(address & 0x0f);
184 if (sccEnable && (address >= 0x9800) && (address < 0xa000)) {
185 return scc.
peekMem(address & 0xff, time);
188 return sram[mapper[page] * 0x2000 + (address & 0x1fff)];
193 unsigned page = address / 0x2000 - 2;
195 if (spcEnable && (page == 0)) {
199 if (sccEnable && (address >= 0x9800) && (address < 0xa000)) {
203 return &sram[mapper[page] * 0x2000 + (address & 0x1fff)];
208 unsigned page = address / 0x2000 - 2;
210 if (spcEnable && (page == 0)) {
212 if (address < 0x1000) {
213 spc->writeDREG(value);
215 spc->writeRegister(address & 0x0f, value);
221 if (sccEnable && (0x9800 <= address) && (address < 0xa000)) {
222 scc.
writeMem(address & 0xff, value, time);
227 if ((address | 0x0001) == 0x7FFF) {
228 setMapperHigh(value);
233 if (writeEnable && (page < 2)) {
234 sram.
write(mapper[page] * 0x2000 + (address & 0x1FFF), value);
239 if (((address & 0x1800) == 0x1000)) {
240 setMapperLow(page, value);
251 template<
typename Archive>
254 ar.template serializeBase<MSXDevice>(*
this);
255 ar.serialize(
"sram", sram,
257 if (spc) ar.serialize(
"MB89352", *spc);
258 ar.serialize(
"mapper", mapper,
259 "spcEnable", spcEnable,
260 "sccEnable", sccEnable,
261 "writeEnable", writeEnable);
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.
const byte * getReadCacheLine(word address) 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 powerUp(EmuTime::param time) override
This method is called when MSX is powered up.
byte * getWriteCacheLine(word address) const override
Test that the memory in the interval [start, start + CacheLine::SIZE) is cacheable for writing.
ESE_SCC(const DeviceConfig &config, bool withSCSI)
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.
An MSXDevice is an emulated hardware component connected to the bus of the emulated MSX.
const XMLElement & getDeviceConfig() const
Get the configuration section for this device.
virtual const std::string & getName() const
Returns a human-readable name for this device.
void invalidateDeviceRWCache()
Calls MSXCPUInterface::invalidateXXCache() for the specific (part of) the slot that this device is lo...
void writeMem(byte address, byte value, EmuTime::param time)
void powerUp(EmuTime::param time)
byte readMem(byte address, EmuTime::param time)
void reset(EmuTime::param time)
byte peekMem(byte address, EmuTime::param time) const
void write(unsigned addr, byte value)
int getChildDataAsInt(std::string_view childName, int defaultValue) const
std::string getName(KeyCode keyCode)
Translate key code to key name.
This file implemented 3 utility functions:
REGISTER_MSXDEVICE(ChakkariCopy, "ChakkariCopy")
uint16_t word
16 bit unsigned integer
constexpr void iota(ForwardIt first, ForwardIt last, T value)
#define INSTANTIATE_SERIALIZE_METHODS(CLASS)
constexpr auto xrange(T e)