50[[nodiscard]]
static std::shared_ptr<SRAM> getSram(
const DeviceConfig& config)
52 return config.getMotherBoard().getSharedStuff<
SRAM>(
54 strCat(config.getAttributeValue(
"id"),
" SRAM"), 0x2000, config);
62 , fsSram(getSram(config))
63 , firmwareSwitch(config)
67 "Rom for FSA1FM mapper must be 1MB in size "
68 "(some dumps are 2MB, those can be used as well).");
79 if ((0x4000 <= address) && (address < 0x6000)) {
81 return rom[(0x2000 * ((*fsSram)[0x1FC4] & 0x0F)) +
83 }
else if ((0x7FC0 <= address) && (address < 0x7FD0)) {
84 switch (address & 0x0F) {
86 return (*fsSram)[address & 0x1FFF];
88 return firmwareSwitch.
getStatus() ? 0xFB : 0xFF;
92 }
else if ((0x6000 <= address) && (address < 0x8000)) {
95 return (*fsSram)[address & 0x1FFF];
111 }
else if ((0x4000 <= address) && (address < 0x6000)) {
113 return &
rom[(0x2000 * ((*fsSram)[0x1FC4] & 0x0F)) +
115 }
else if ((0x6000 <= address) && (address < 0x8000)) {
117 return &(*fsSram)[address & 0x1FFF];
127 if ((0x6000 <= address) && (address < 0x8000)) {
128 if (address == 0x7FC4) {
132 fsSram->write(address & 0x1FFF, value);
141 }
else if ((0x6000 <= address) && (address < 0x8000)) {
149template<
typename Archive>
153 ar.template serializeBase<MSXDevice>(*
this);
164 , fsSram(getSram(config))
166 reset(EmuTime::dummy());
172 for (
auto region :
xrange(6)) {
173 changeBank(region, 0xA8);
183 if (0xC000 <= address) {
185 }
else if ((control & 0x04) && (0x7FF0 <= address) && (address < 0x7FF8)) {
187 return bankSelect[address & 7];
188 }
else if (isRam[address >> 13]) {
189 return (*fsSram)[address & 0x1FFF];
190 }
else if (isEmpty[address >> 13]) {
204 if (0xC000 <= address) {
208 }
else if (isRam[address >> 13]) {
209 return &(*fsSram)[address & 0x1FFF];
210 }
else if (isEmpty[address >> 13]) {
220 if ((0x6000 <= address) && (address < 0x7FF0)) {
222 switch (address & 0x1C00) {
224 changeBank(2, value);
227 changeBank(0, value);
230 changeBank(3, value);
233 changeBank(1, value);
236 changeBank(4, value);
242 changeBank(5, value);
248 }
else if (address == 0x7FF9) {
251 }
else if (isRam[address >> 13]) {
252 fsSram->write(address & 0x1FFF, value);
258 if ((0x6000 <= address) && (address < 0x8000)) {
260 }
else if (isRam[address >> 13]) {
267void RomFSA1FM2::changeBank(
unsigned region,
byte bank)
269 bankSelect[region] = bank;
270 if ((0x80 <= bank) && (bank < 0x90)) {
272 isRam[region] =
true;
273 isEmpty[region] =
false;
275 isRam[region] =
false;
276 isEmpty[region] =
true;
280 isRam[region] =
false;
281 isEmpty[region] =
false;
282 setRom(region, bank & 0x7F);
289template<
typename Archive>
292 ar.template serializeBase<Rom8kBBlocks>(*
this);
295 ar.serialize(
"SRAM", *fsSram,
296 "bankSelect", bankSelect,
298 if constexpr (Archive::IS_LOADER) {
300 for (
auto region :
xrange(8)) {
301 changeBank(region, bankSelect[region]);
#define REGISTER_MSXDEVICE(CLASS, NAME)
void invalidateDeviceRCache()
static std::array< byte, 0x10000 > unmappedRead
static std::array< byte, 0x10000 > unmappedWrite
void invalidateDeviceRWCache()
Calls MSXCPUInterface::invalidateXXCache() for the specific (part of) the slot that this device is lo...
void setUnmapped(unsigned region)
Select 'unmapped' memory for this region.
byte peekMem(word address, EmuTime::param time) const override
Read a byte from a given memory location.
void setRom(unsigned region, unsigned block)
Selects a block of the ROM image for reading in a certain region.
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 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 readMem(word address, EmuTime::param time) override
Read a byte from a location at a certain time from this device.
byte peekMem(word address, EmuTime::param time) const override
Read a byte from a given memory location.
void serialize(Archive &ar, unsigned version)
RomFSA1FM1(const DeviceConfig &config, Rom &&rom)
const byte * getReadCacheLine(word address) const override
Test that the memory in the interval [start, start + CacheLine::SIZE) is cacheable for reading.
byte * getWriteCacheLine(word address) override
Test that the memory in the interval [start, start + CacheLine::SIZE) is cacheable for writing.
byte readMem(word address, EmuTime::param time) override
Read a byte from a location at a certain time from this device.
byte * getWriteCacheLine(word address) override
Test that the memory in the interval [start, start + CacheLine::SIZE) is cacheable for writing.
const byte * getReadCacheLine(word address) const override
Test that the memory in the interval [start, start + CacheLine::SIZE) is cacheable for reading.
void serialize(Archive &ar, unsigned version)
void reset(EmuTime::param time) override
This method is called on reset.
RomFSA1FM2(const DeviceConfig &config, Rom &&rom)
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.
This file implemented 3 utility functions:
uint16_t word
16 bit unsigned integer
#define INSTANTIATE_SERIALIZE_METHODS(CLASS)
constexpr auto xrange(T e)