11 , rom(getName(),
"Kanji ROM", config)
12 , isLascom(config.getChildData(
"type", {}) ==
"lascom")
13 , highAddressMask(config.getChildData(
"type", {}) ==
"hangul" ? 0x7F : 0x3F)
15 auto size = rom.size();
16 if (size !=
one_of(0x20000u, 0x40000u)) {
17 throw MSXException(
"MSXKanji: wrong kanji ROM, it should be either 128kB or 256kB.");
19 if ((highAddressMask == 0x7F) && (size != 0x40000)) {
20 throw MSXException(
"MSXKanji: for hangul type, the font ROM must be 256kB.");
23 reset(EmuTime::dummy());
34 switch (port & 0x03) {
36 adr1 = (adr1 & 0x1f800) | ((value & 0x3f) << 5);
39 adr1 = (adr1 & 0x007e0) | ((value & highAddressMask) << 11);
42 adr2 = (adr2 & 0x3f800) | ((value & 0x3f) << 5);
45 adr2 = (adr2 & 0x207e0) | ((value & 0x3f) << 11);
52 byte result =
peekIO(port, time);
53 switch (port & 0x03) {
60 adr1 = (adr1 & ~0x1f) | ((adr1 + 1) & 0x1f);
63 adr2 = (adr2 & ~0x1f) | ((adr2 + 1) & 0x1f);
72 switch (port & 0x03) {
79 result = rom[adr1 & (rom.
size() - 1)];
82 if (rom.
size() == 0x40000) {
95template<
typename Archive>
98 ar.template serializeBase<MSXDevice>(*
this);
99 ar.serialize(
"adr1", adr1,
#define REGISTER_MSXDEVICE(CLASS, NAME)
An MSXDevice is an emulated hardware component connected to the bus of the emulated MSX.
void reset(EmuTime::param time) override
This method is called on reset.
void getExtraDeviceInfo(TclObject &result) const override
void serialize(Archive &ar, unsigned version)
MSXKanji(const DeviceConfig &config)
byte peekIO(word port, EmuTime::param time) const override
Read a byte from a given IO port.
byte readIO(word port, EmuTime::param time) override
Read a byte from an IO port at a certain time from this device.
void writeIO(word port, byte value, EmuTime::param time) override
Write a byte to a given IO port at a certain time to this device.
void getInfo(TclObject &result) const
Add dict values with info to result.
This file implemented 3 utility functions:
uint16_t word
16 bit unsigned integer
#define INSTANTIATE_SERIALIZE_METHODS(CLASS)