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 "one_of.hh"
8 #include "serialize.hh"
9 
10 namespace openmsx {
11 
13  : Rom16kBBlocks(config, std::move(rom_))
14 {
15  reset(EmuTime::dummy());
16 }
17 
18 void RomMSXWrite::reset(EmuTime::param /*time*/)
19 {
20  setUnmapped(0);
21  setRom(1, 0);
22  setRom(2, 0);
23  setUnmapped(3);
24 }
25 
26 void RomMSXWrite::writeMem(word address, byte value, EmuTime::param /*time*/)
27 {
28  if (((0x6000 <= address) && (address < 0x7800) && !(address & 0x0800)) ||
29  (address == one_of(0x6FFF, 0x7FFF))) {
30  byte region = ((address >> 12) & 1) + 1;
31  setRom(region, value);
32  }
33 }
34 
36 {
37  if (((0x6000 <= address) && (address < 0x7800) && !(address & 0x0800)) ||
38  (address == one_of(0x6FFF & CacheLine::HIGH, 0x7FFF & CacheLine::HIGH))) {
39  return nullptr;
40  } else {
41  return unmappedWrite;
42  }
43 }
44 
45 REGISTER_MSXDEVICE(RomMSXWrite, "RomMSXWrite");
46 
47 } // namespace openmsx
one_of.hh
serialize.hh
openmsx::DeviceConfig
Definition: DeviceConfig.hh:19
openmsx::MSXDevice::unmappedWrite
static byte unmappedWrite[0x10000]
Definition: MSXDevice.hh:301
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:18
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
one_of
Definition: one_of.hh:7
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:12
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:26
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:35
openmsx
Thanks to enen for testing this on a real cartridge:
Definition: Autofire.cc:5