| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
#include "CanonWordProcessor.hh" |
| 22 |
|
| 23 |
#include "CacheLine.hh" |
| 24 |
#include "MSXException.hh" |
| 25 |
#include "serialize.hh" |
| 26 |
|
| 27 |
namespace openmsx { |
| 28 |
|
| 29 |
CanonWordProcessor::CanonWordProcessor(DeviceConfig& config) |
| 30 |
: MSXDevice(config) |
| 31 |
, programRom (strCat(config.getAttributeValue("id"), "_program"), "rom", config, "program") |
| 32 |
, dictionaryRom(strCat(config.getAttributeValue("id"), "_dictionary"), "rom", config, "dictionary") |
| 33 |
{ |
| 34 |
if (programRom.size() != 32*1024) { |
| 35 |
throw MSXException("Program ROM must be 32kB."); |
| 36 |
} |
| 37 |
if (dictionaryRom.size() != 3*128*1024) { |
| 38 |
throw MSXException("Dictionary ROM must be 3x 128kB."); |
| 39 |
} |
| 40 |
reset(EmuTime::dummy()); |
| 41 |
} |
| 42 |
|
| 43 |
void CanonWordProcessor::reset(EmuTime time) |
| 44 |
{ |
| 45 |
writeMem(0xbfff, 0xff, time); |
| 46 |
} |
| 47 |
|
| 48 |
byte CanonWordProcessor::readMem(uint16_t address, EmuTime time) |
| 49 |
{ |
| 50 |
return peekMem(address, time); |
| 51 |
} |
| 52 |
|
| 53 |
byte CanonWordProcessor::peekMem(uint16_t address, EmuTime ) const |
| 54 |
{ |
| 55 |
if ((0xbff8 <= address) && (address <= 0xbfff)) { |
| 56 |
return 0xc0; |
| 57 |
} else { |
| 58 |
if (const auto* a = readHelper(address)) { |
| 59 |
return *a; |
| 60 |
} |
| 61 |
return 0xc0; |
| 62 |
} |
| 63 |
} |
| 64 |
|
| 65 |
const byte* CanonWordProcessor::getReadCacheLine(uint16_t start) const |
| 66 |
{ |
| 67 |
if ((start & CacheLine::HIGH) == (0xbfff & CacheLine::HIGH)) { |
| 68 |
return nullptr; |
| 69 |
} else { |
| 70 |
return readHelper(start); |
| 71 |
} |
| 72 |
} |
| 73 |
|
| 74 |
const byte* CanonWordProcessor::readHelper(uint16_t address) const |
| 75 |
{ |
| 76 |
if ((0x4000 <= address) && (address <= 0x7fff)) { |
| 77 |
auto chip = (select & 0b00'111'000) >> 3; |
| 78 |
auto bank = (select & 0b00'011'111); |
| 79 |
address &= 0x3fff; |
| 80 |
switch (chip) { |
| 81 |
case 0b000: |
| 82 |
return &programRom[address]; |
| 83 |
case 0b100: case 0b101: case 0b110: |
| 84 |
return &dictionaryRom[0x4000 * bank + address]; |
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
} |
| 90 |
return nullptr; |
| 91 |
} else { |
| 92 |
|
| 93 |
return &programRom[0x4000 + (address & 0x3fff)]; |
| 94 |
} |
| 95 |
} |
| 96 |
|
| 97 |
void CanonWordProcessor::writeMem(uint16_t address, byte value, EmuTime ) |
| 98 |
{ |
| 99 |
if ((0xbff8 <= address) && (address <= 0xbfff)) { |
| 100 |
select = ~value; |
| 101 |
invalidateDeviceRCache(0x4000, 0x4000); |
| 102 |
} |
| 103 |
} |
| 104 |
|
| 105 |
byte* CanonWordProcessor::getWriteCacheLine(uint16_t ) |
| 106 |
{ |
| 107 |
return nullptr; |
| 108 |
} |
| 109 |
|
| 110 |
template<typename Archive> |
| 111 |
void CanonWordProcessor::serialize(Archive& ar, unsigned ) |
| 112 |
{ |
| 113 |
ar.template serializeBase<MSXDevice>(*this); |
| 114 |
ar.serialize("select", select); |
| 115 |
} |
| 116 |
INSTANTIATE_SERIALIZE_METHODS(CanonWordProcessor); |
| 117 |
REGISTER_MSXDEVICE(CanonWordProcessor, "CanonWordProcessor"); |
| 118 |
|
| 119 |
} |