openMSX
RomRType.cc
Go to the documentation of this file.
1 // R-Type cartridges
2 //
3 // The address to change banks:
4 // first 16kb: fixed at 0x0f or 0x17 (both have the same content)
5 // second 16kb: 0x4000 - 0x7FFF (0x7000 and 0x7800 used)
6 // bit 4 selects ROM chip,
7 // if low bit 3-0 select page
8 // high 2-0
9 // Thanks to n_n for investigating this on a real cartridge.
10 
11 #include "RomRType.hh"
12 #include "serialize.hh"
13 
14 namespace openmsx {
15 
16 RomRType::RomRType(const DeviceConfig& config, Rom&& rom_)
17  : Rom16kBBlocks(config, std::move(rom_))
18 {
19  reset(EmuTime::dummy());
20 }
21 
22 void RomRType::reset(EmuTime::param /*time*/)
23 {
24  setUnmapped(0);
25  setRom(1, 0x17);
26  setRom(2, 0);
27  setUnmapped(3);
28 }
29 
30 void RomRType::writeMem(word address, byte value, EmuTime::param /*time*/)
31 {
32  if ((0x4000 <= address) && (address < 0x8000)) {
33  value &= (value & 0x10) ? 0x17 : 0x1F;
34  setRom(2, value);
35  }
36 }
37 
38 byte* RomRType::getWriteCacheLine(word address) const
39 {
40  if ((0x4000 <= address) && (address < 0x8000)) {
41  return nullptr;
42  } else {
43  return unmappedWrite;
44  }
45 }
46 
47 REGISTER_MSXDEVICE(RomRType, "RomRType");
48 
49 } // namespace openmsx
RomRType.hh
serialize.hh
openmsx::DeviceConfig
Definition: DeviceConfig.hh:19
openmsx::MSXDevice::unmappedWrite
static byte unmappedWrite[0x10000]
Definition: MSXDevice.hh:293
openmsx::RomRType::RomRType
RomRType(const DeviceConfig &config, Rom &&rom)
Definition: RomRType.cc:16
openmsx::RomRType::reset
void reset(EmuTime::param time) override
This method is called on reset.
Definition: RomRType.cc:22
openmsx::RomRType
Definition: RomRType.hh:8
openmsx::REGISTER_MSXDEVICE
REGISTER_MSXDEVICE(ChakkariCopy, "ChakkariCopy")
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
openmsx::Rom
Definition: Rom.hh:20
openmsx::word
uint16_t word
16 bit unsigned integer
Definition: openmsx.hh:29
openmsx::RomRType::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: RomRType.cc:30
openmsx::RomRType::getWriteCacheLine
byte * getWriteCacheLine(word address) const override
Test that the memory in the interval [start, start + CacheLine::SIZE) is cacheable for writing.
Definition: RomRType.cc:38
openmsx
Thanks to enen for testing this on a real cartridge:
Definition: Autofire.cc:5