| 1 |
#include "MSXBunsetsu.hh" |
| 2 |
|
| 3 |
#include "CacheLine.hh" |
| 4 |
#include "serialize.hh" |
| 5 |
|
| 6 |
namespace openmsx { |
| 7 |
|
| 8 |
MSXBunsetsu::MSXBunsetsu(DeviceConfig& config) |
| 9 |
: MSXDevice(config) |
| 10 |
, bunsetsuRom(getName() + "_1", "rom", config, "bunsetsu") |
| 11 |
, jisyoRom (getName() + "_2", "rom", config, "jisyo") |
| 12 |
{ |
| 13 |
reset(EmuTime::dummy()); |
| 14 |
} |
| 15 |
|
| 16 |
void MSXBunsetsu::reset(EmuTime ) |
| 17 |
{ |
| 18 |
jisyoAddress = 0; |
| 19 |
} |
| 20 |
|
| 21 |
byte MSXBunsetsu::readMem(uint16_t address, EmuTime ) |
| 22 |
{ |
| 23 |
if (address == 0xBFFF) { |
| 24 |
byte result = jisyoRom[jisyoAddress]; |
| 25 |
jisyoAddress = (jisyoAddress + 1) & 0x1FFFF; |
| 26 |
return result; |
| 27 |
} else if ((0x4000 <= address) && (address < 0xC000)) { |
| 28 |
return bunsetsuRom[address - 0x4000]; |
| 29 |
} else { |
| 30 |
return 0xFF; |
| 31 |
} |
| 32 |
} |
| 33 |
|
| 34 |
void MSXBunsetsu::writeMem(uint16_t address, byte value, EmuTime ) |
| 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(uint16_t start) const |
| 51 |
{ |
| 52 |
if ((start & CacheLine::HIGH) == (0xBFFF & CacheLine::HIGH)) { |
| 53 |
return nullptr; |
| 54 |
} else { |
| 55 |
return &bunsetsuRom[start - 0x4000]; |
| 56 |
} |
| 57 |
} |
| 58 |
|
| 59 |
byte* MSXBunsetsu::getWriteCacheLine(uint16_t start) |
| 60 |
{ |
| 61 |
if ((start & CacheLine::HIGH) == (0xBFFF & CacheLine::HIGH)) { |
| 62 |
return nullptr; |
| 63 |
} else { |
| 64 |
return unmappedWrite.data(); |
| 65 |
} |
| 66 |
} |
| 67 |
|
| 68 |
template<typename Archive> |
| 69 |
void MSXBunsetsu::serialize(Archive& ar, unsigned ) |
| 70 |
{ |
| 71 |
ar.template serializeBase<MSXDevice>(*this); |
| 72 |
ar.serialize("jisyoAddress", jisyoAddress); |
| 73 |
} |
| 74 |
INSTANTIATE_SERIALIZE_METHODS(MSXBunsetsu); |
| 75 |
REGISTER_MSXDEVICE(MSXBunsetsu, "Bunsetsu"); |
| 76 |
|
| 77 |
} |