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  if (address == 0xBFFF) {
23  byte result = jisyoRom[jisyoAddress];
24  jisyoAddress = (jisyoAddress + 1) & 0x1FFFF;
25  return result;
26  } else if ((0x4000 <= address) && (address < 0xC000)) {
27  return bunsetsuRom[address - 0x4000];
28  } else {
29  return 0xFF;
30  }
31 }
32 
33 void MSXBunsetsu::writeMem(word address, byte value, EmuTime::param /*time*/)
34 {
35  switch (address) {
36  case 0xBFFC:
37  jisyoAddress = (jisyoAddress & 0x1FF00) | value;
38  break;
39  case 0xBFFD:
40  jisyoAddress = (jisyoAddress & 0x100FF) | (value << 8);
41  break;
42  case 0xBFFE:
43  jisyoAddress = (jisyoAddress & 0x0FFFF) |
44  ((value & 1) << 16);
45  break;
46  }
47 }
48 
49 const byte* MSXBunsetsu::getReadCacheLine(word start) const
50 {
51  if ((start & CacheLine::HIGH) == (0xBFFF & CacheLine::HIGH)) {
52  return nullptr;
53  } else {
54  return &bunsetsuRom[start - 0x4000];
55  }
56 }
57 
59 {
60  if ((start & CacheLine::HIGH) == (0xBFFF & CacheLine::HIGH)) {
61  return nullptr;
62  } else {
63  return unmappedWrite;
64  }
65 }
66 
67 template<typename Archive>
68 void MSXBunsetsu::serialize(Archive& ar, unsigned /*version*/)
69 {
70  ar.template serializeBase<MSXDevice>(*this);
71  ar.serialize("jisyoAddress", jisyoAddress);
72 }
75 
76 } // namespace openmsx
void reset(EmuTime::param time) override
This method is called on reset.
Definition: MSXBunsetsu.cc:15
byte * getWriteCacheLine(word start) const override
Test that the memory in the interval [start, start + CacheLine::SIZE) is cacheable for writing.
Definition: MSXBunsetsu.cc:58
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:33
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:49
MSXBunsetsu(const DeviceConfig &config)
Definition: MSXBunsetsu.cc:7
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
void serialize(Archive &ar, unsigned version)
Definition: MSXBunsetsu.cc:68
An MSXDevice is an emulated hardware component connected to the bus of the emulated MSX.
Definition: MSXDevice.hh:33
static byte unmappedWrite[0x10000]
Definition: MSXDevice.hh:302
constexpr unsigned HIGH
Definition: CacheLine.hh:10
std::string getName(KeyCode keyCode)
Translate key code to key name.
Definition: Keys.cc:741
This file implemented 3 utility functions:
Definition: Autofire.cc:9
REGISTER_MSXDEVICE(ChakkariCopy, "ChakkariCopy")
uint16_t word
16 bit unsigned integer
Definition: openmsx.hh:29
#define INSTANTIATE_SERIALIZE_METHODS(CLASS)
Definition: serialize.hh:998