openMSX
MSXBunsetsu.cc
Go to the documentation of this file.
1 #include "MSXBunsetsu.hh"
2 #include "CacheLine.hh"
3 #include "serialize.hh"
4 
5 namespace openmsx {
6 
8  : MSXDevice(config)
9  , bunsetsuRom(getName() + "_1", "rom", config, "bunsetsu")
10  , jisyoRom (getName() + "_2", "rom", config, "jisyo")
11 {
12  reset(EmuTime::dummy());
13 }
14 
15 void MSXBunsetsu::reset(EmuTime::param /*time*/)
16 {
17  jisyoAddress = 0;
18 }
19 
20 byte MSXBunsetsu::readMem(word address, EmuTime::param /*time*/)
21 {
22  byte result;
23  if (address == 0xBFFF) {
24  result = jisyoRom[jisyoAddress];
25  jisyoAddress = (jisyoAddress + 1) & 0x1FFFF;
26  } else if ((0x4000 <= address) && (address < 0xC000)) {
27  result = bunsetsuRom[address - 0x4000];
28  } else {
29  result = 0xFF;
30  }
31  return result;
32 }
33 
34 void MSXBunsetsu::writeMem(word address, byte value, EmuTime::param /*time*/)
35 {
36  switch (address) {
37  case 0xBFFC:
38  jisyoAddress = (jisyoAddress & 0x1FF00) | value;
39  break;
40  case 0xBFFD:
41  jisyoAddress = (jisyoAddress & 0x100FF) | (value << 8);
42  break;
43  case 0xBFFE:
44  jisyoAddress = (jisyoAddress & 0x0FFFF) |
45  ((value & 1) << 16);
46  break;
47  }
48 }
49 
50 const byte* MSXBunsetsu::getReadCacheLine(word start) const
51 {
52  if ((start & CacheLine::HIGH) == (0xBFFF & CacheLine::HIGH)) {
53  return nullptr;
54  } else {
55  return &bunsetsuRom[start - 0x4000];
56  }
57 }
58 
60 {
61  if ((start & CacheLine::HIGH) == (0xBFFF & CacheLine::HIGH)) {
62  return nullptr;
63  } else {
64  return unmappedWrite;
65  }
66 }
67 
68 template<typename Archive>
69 void MSXBunsetsu::serialize(Archive& ar, unsigned /*version*/)
70 {
71  ar.template serializeBase<MSXDevice>(*this);
72  ar.serialize("jisyoAddress", jisyoAddress);
73 }
76 
77 } // namespace openmsx
openmsx::MSXDevice
An MSXDevice is an emulated hardware component connected to the bus of the emulated MSX.
Definition: MSXDevice.hh:32
serialize.hh
openmsx::MSXBunsetsu
Definition: MSXBunsetsu.hh:10
openmsx::DeviceConfig
Definition: DeviceConfig.hh:20
openmsx::MSXDevice::unmappedWrite
static byte unmappedWrite[0x10000]
Definition: MSXDevice.hh:301
openmsx::CacheLine::HIGH
constexpr unsigned HIGH
Definition: CacheLine.hh:10
openmsx::REGISTER_MSXDEVICE
REGISTER_MSXDEVICE(ChakkariCopy, "ChakkariCopy")
openmsx::Keys::getName
string getName(KeyCode keyCode)
Translate key code to key name.
Definition: Keys.cc:740
openmsx::MSXBunsetsu::MSXBunsetsu
MSXBunsetsu(const DeviceConfig &config)
Definition: MSXBunsetsu.cc:7
openmsx::MSXBunsetsu::serialize
void serialize(Archive &ar, unsigned version)
Definition: MSXBunsetsu.cc:69
INSTANTIATE_SERIALIZE_METHODS
#define INSTANTIATE_SERIALIZE_METHODS(CLASS)
Definition: serialize.hh:981
CacheLine.hh
openmsx::word
uint16_t word
16 bit unsigned integer
Definition: openmsx.hh:29
MSXBunsetsu.hh
openmsx::MSXBunsetsu::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: MSXBunsetsu.cc:34
openmsx::MSXBunsetsu::getWriteCacheLine
byte * getWriteCacheLine(word start) const override
Test that the memory in the interval [start, start + CacheLine::SIZE) is cacheable for writing.
Definition: MSXBunsetsu.cc:59
openmsx::MSXBunsetsu::getReadCacheLine
const byte * getReadCacheLine(word start) const override
Test that the memory in the interval [start, start + CacheLine::SIZE) is cacheable for reading.
Definition: MSXBunsetsu.cc:50
openmsx
Thanks to enen for testing this on a real cartridge:
Definition: Autofire.cc:5
openmsx::MSXBunsetsu::reset
void reset(EmuTime::param time) override
This method is called on reset.
Definition: MSXBunsetsu.cc:15
openmsx::MSXBunsetsu::readMem
byte readMem(word address, EmuTime::param time) override
Read a byte from a location at a certain time from this device.
Definition: MSXBunsetsu.cc:20