openMSX
RomMSXWrite.cc
Go to the documentation of this file.
1 // Japanese MSX Write (1)
2 // Identical to ASCII 16kB cartridges, but with 2 extra switch addresses:
3 // 0x6FFF and 0x7FFF
4 
5 #include "RomMSXWrite.hh"
6 #include "CacheLine.hh"
7 #include "serialize.hh"
8 
9 namespace openmsx {
10 
12  : Rom16kBBlocks(config, std::move(rom_))
13 {
14  reset(EmuTime::dummy());
15 }
16 
17 void RomMSXWrite::reset(EmuTime::param /*time*/)
18 {
19  setUnmapped(0);
20  setRom(1, 0);
21  setRom(2, 0);
22  setUnmapped(3);
23 }
24 
25 void RomMSXWrite::writeMem(word address, byte value, EmuTime::param /*time*/)
26 {
27  if (((0x6000 <= address) && (address < 0x7800) && !(address & 0x0800)) ||
28  (address == 0x6FFF) || (address == 0x7FFF)) {
29  byte region = ((address >> 12) & 1) + 1;
30  setRom(region, value);
31  }
32 }
33 
35 {
36  if (((0x6000 <= address) && (address < 0x7800) && !(address & 0x0800)) ||
37  (address == (0x6FFF & CacheLine::HIGH)) ||
38  (address == (0x7FFF & CacheLine::HIGH))) {
39  return nullptr;
40  } else {
41  return unmappedWrite;
42  }
43 }
44 
45 REGISTER_MSXDEVICE(RomMSXWrite, "RomMSXWrite");
46 
47 } // namespace openmsx
serialize.hh
openmsx::DeviceConfig
Definition: DeviceConfig.hh:19
openmsx::MSXDevice::unmappedWrite
static byte unmappedWrite[0x10000]
Definition: MSXDevice.hh:293
openmsx::CacheLine::HIGH
constexpr unsigned HIGH
Definition: CacheLine.hh:10
openmsx::RomMSXWrite
Definition: RomMSXWrite.hh:8
openmsx::REGISTER_MSXDEVICE
REGISTER_MSXDEVICE(ChakkariCopy, "ChakkariCopy")
openmsx::RomMSXWrite::reset
void reset(EmuTime::param time) override
This method is called on reset.
Definition: RomMSXWrite.cc:17
RomMSXWrite.hh
openmsx::RomBlocks::setRom
void setRom(byte region, unsigned block)
Selects a block of the ROM image for reading in a certain region.
Definition: RomBlocks.cc:104
openmsx::RomBlocks::setUnmapped
void setUnmapped(byte region)
Select 'unmapped' memory for this region.
Definition: RomBlocks.cc:91
openmsx::RomBlocks
Definition: RomBlocks.hh:13
CacheLine.hh
openmsx::Rom
Definition: Rom.hh:20
openmsx::word
uint16_t word
16 bit unsigned integer
Definition: openmsx.hh:29
openmsx::RomMSXWrite::RomMSXWrite
RomMSXWrite(const DeviceConfig &config, Rom &&rom)
Definition: RomMSXWrite.cc:11
openmsx::RomMSXWrite::writeMem
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.
Definition: RomMSXWrite.cc:25
openmsx::RomMSXWrite::getWriteCacheLine
byte * getWriteCacheLine(word address) const override
Test that the memory in the interval [start, start + CacheLine::SIZE) is cacheable for writing.
Definition: RomMSXWrite.cc:34
openmsx
Thanks to enen for testing this on a real cartridge:
Definition: Autofire.cc:5