openMSX
MSXBunsetsu.cc
Go to the documentation of this file.
1#include "MSXBunsetsu.hh"
2#include "CacheLine.hh"
3#include "serialize.hh"
4
5namespace 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
15void MSXBunsetsu::reset(EmuTime::param /*time*/)
16{
17 jisyoAddress = 0;
18}
19
20byte 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
33void 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
49const 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.data();
64 }
65}
66
67template<typename Archive>
68void MSXBunsetsu::serialize(Archive& ar, unsigned /*version*/)
69{
70 ar.template serializeBase<MSXDevice>(*this);
71 ar.serialize("jisyoAddress", jisyoAddress);
72}
75
76} // namespace openmsx
#define REGISTER_MSXDEVICE(CLASS, NAME)
Definition MSXDevice.hh:356
byte * getWriteCacheLine(word start) override
Test that the memory in the interval [start, start + CacheLine::SIZE) is cacheable for writing.
void reset(EmuTime::param time) override
This method is called on reset.
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.
const byte * getReadCacheLine(word start) const override
Test that the memory in the interval [start, start + CacheLine::SIZE) is cacheable for reading.
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.
void serialize(Archive &ar, unsigned version)
An MSXDevice is an emulated hardware component connected to the bus of the emulated MSX.
Definition MSXDevice.hh:36
static std::array< byte, 0x10000 > unmappedWrite
Definition MSXDevice.hh:307
constexpr unsigned HIGH
Definition CacheLine.hh:10
This file implemented 3 utility functions:
Definition Autofire.cc:11
uint16_t word
16 bit unsigned integer
Definition openmsx.hh:29
#define INSTANTIATE_SERIALIZE_METHODS(CLASS)