13static constexpr byte ID = 0x08;
19 , firmwareSwitch(config)
20 , sram(config.findChild(
"sramname") ?
std::make_unique<
SRAM>(getName() +
" SRAM", 0x800, config) : nullptr)
21 , turboAvailable(config.getChildDataAsBool(
"hasturbo", false))
25 reset(EmuTime::dummy());
33 vdp = !refs.empty() ?
dynamic_cast<VDP*
>(refs[0]) :
nullptr;
46 error |= !cpuInterface.replace_IO_In (
byte(0x98 + i), vdp,
this);
49 error |= !cpuInterface.replace_IO_Out(
byte(0x98 + i), vdp,
this);
54 "Invalid Matsushita configuration: "
55 "VDP not on IO-ports 0x98-0x9B.");
65void MSXMatsushita::unwrap()
70 cpuInterface.replace_IO_In (
byte(0x98 + i),
this, vdp);
73 cpuInterface.replace_IO_Out(
byte(0x98 + i),
this, vdp);
89 switch (port & 0x0F) {
91 pattern =
byte((pattern << 2) | (pattern >> 6));
94 address = (address + 1) & 0x1FFF;
102 switch (port & 0x0F) {
106 byte result = firmwareSwitch.
getStatus() ? 0x7F : 0xFF;
112 if (turboAvailable) {
118 return byte((((pattern & 0x80) ? color2 : color1) << 4) |
119 (((pattern & 0x40) ? color2 : color1) << 0));
121 if (address < 0x800 && sram) {
122 return (*sram)[address];
133 switch (port & 0x0F) {
138 if (turboAvailable) {
141 turboEnabled =
false;
144 if (turboAvailable) {
151 color2 = (value & 0xF0) >> 4;
152 color1 = value & 0x0F;
159 address = (address & 0xFF00) | value;
163 address =
word((address & 0x00FF) | ((value & 0x1F) << 8));
167 if (address < 0x800 && sram) {
168 sram->write(address, value);
170 address = (address + 1) & 0x1FFF;
179 return vdp->
readIO(port, time);
185 return vdp->
peekIO(port, time);
195void MSXMatsushita::delay(EmuTime::param time)
197 if (turboAvailable && turboEnabled) {
199 if (time < lastTime.
getTime()) {
204 lastTime.
reset(time);
207template<
typename Archive>
210 ar.template serializeBase<MSXDevice>(*
this);
213 if (sram) ar.serialize(
"SRAM", *sram);
214 ar.serialize(
"address", address,
219 if (ar.versionAtLeast(version, 2)) {
220 ar.serialize(
"lastTime", lastTime,
221 "turboEnabled", turboEnabled);
226 "Loading an old savestate: the timing of the CPU-VDP "
227 "communication emulation has changed. This may cause "
228 "synchronization problems in replay.");
#define REGISTER_MSXDEVICE(CLASS, NAME)
void printWarning(std::string_view message)
constexpr void reset(EmuTime::param e)
Reset the clock to start ticking at the given time.
constexpr EmuTime::param getTime() const
Gets the time at which the last clock tick occurred.
void setZ80Freq(unsigned freq)
Switch the Z80 clock freq.
void wait(EmuTime::param time)
An MSXDevice is an emulated hardware component connected to the bus of the emulated MSX.
const Devices & getReferences() const
Get the device references that are specified for this device.
MSXCPUInterface & getCPUInterface() const
MSXCliComm & getCliComm() const
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.
byte readIO(word port, EmuTime::param time) override
Read a byte from an IO port at a certain time from this device.
void serialize(Archive &ar, unsigned version)
MSXMatsushita(const DeviceConfig &config)
void reset(EmuTime::param time) override
This method is called on reset.
byte peekSwitchedIO(word port, EmuTime::param time) const override
~MSXMatsushita() override
byte peekIO(word port, EmuTime::param time) const override
Read a byte from a given IO port.
void writeSwitchedIO(word port, byte value, EmuTime::param time) override
byte readSwitchedIO(word port, EmuTime::param time) override
Unified implementation of MSX Video Display Processors (VDPs).
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.
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.
This file implemented 3 utility functions:
uint8_t byte
8 bit unsigned integer
uint16_t word
16 bit unsigned integer
#define INSTANTIATE_SERIALIZE_METHODS(CLASS)
constexpr auto xrange(T e)