14 [[nodiscard]]
static byte getKeyboardLayout(
const MSXPSG& psg)
18 auto value = psg.getDeviceConfig().getChildData(
"keyboardlayout",
"50on");
20 if (cmp(value,
"50on")) {
22 }
else if (cmp(value,
"jis")) {
26 "Illegal keyboard layout configuration in '", psg.getName(),
27 "' device configuration: '", value,
28 "', expected 'jis' or '50on'.");
34 , cassette(getMotherBoard().getCassettePort())
35 , renShaTurbo(getMotherBoard().getRenShaTurbo())
39 , keyLayout(getKeyboardLayout(*
this))
40 , addressMask(config.getChildDataAsBool(
"mirrored_registers",
true) ? 0x0f : 0xff)
41 , ay8910(
getName(), *
this, config, getCurrentTime())
43 reset(getCurrentTime());
74 switch (port & 0x03) {
76 registerLatch = value & addressMask;
86 byte MSXPSG::readA(EmuTime::param time)
88 byte joystick = ports[selectedPort]->read(time) |
89 ((renShaTurbo.
getSignal(time)) ? 0x10 : 0x00);
92 byte pin67 = prev << (4 - 2 * selectedPort);
93 joystick &= (pin67| 0xCF);
95 byte cassetteInput = cassette.
cassetteIn(time) ? 0x80 : 0x00;
96 return joystick | keyLayout | cassetteInput;
99 void MSXPSG::writeB(
byte value, EmuTime::param time)
101 byte val0 = (value & 0x03) | ((value & 0x10) >> 2);
102 byte val1 = ((value & 0x0C) >> 2) | ((value & 0x20) >> 3);
103 ports[0]->write(val0, time);
104 ports[1]->write(val1, time);
105 selectedPort = (value & 0x40) >> 6;
107 if ((prev ^ value) & 0x80) {
115 template<
typename Archive>
118 ar.template serializeBase<MSXDevice>(*
this);
119 ar.serialize(
"ay8910", ay8910);
120 if (ar.versionBelow(version, 2)) {
121 assert(Archive::IS_LOADER);
123 ar.serialize(
"joystickportA", *checked_cast<JoystickPort*>(ports[0]),
124 "joystickportB", *checked_cast<JoystickPort*>(ports[1]));
126 ar.serialize(
"registerLatch", registerLatch);
128 ar.serialize(
"portB", portB);
129 if constexpr (Archive::IS_LOADER) {
void reset(EmuTime::param time)
byte readRegister(unsigned reg, EmuTime::param time)
byte peekRegister(unsigned reg, EmuTime::param time) const
void writeRegister(unsigned reg, byte value, EmuTime::param time)
virtual bool cassetteIn(EmuTime::param time)=0
Reads one bit from the cassette port.
void setLed(Led led, bool status)
An MSXDevice is an emulated hardware component connected to the bus of the emulated MSX.
MSXMotherBoard & getMotherBoard() const
Get the mother board this device belongs to.
LedStatus & getLedStatus() const
EmuTime::param getCurrentTime() const
JoystickPortIf & getJoystickPort(unsigned port)
MSXPSG(const DeviceConfig &config)
void powerDown(EmuTime::param time) override
This method is called when MSX is powered down.
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 serialize(Archive &ar, unsigned version)
void reset(EmuTime::param time) override
This method is called on reset.
byte readIO(word port, EmuTime::param time) override
Read a byte from an IO port at a certain time from this device.
byte peekIO(word port, EmuTime::param time) const override
Read a byte from a given IO port.
bool getSignal(EmuTime::param time)
Get the output signal in negative logic.
std::string getName(KeyCode keyCode)
Translate key code to key name.
This file implemented 3 utility functions:
REGISTER_MSXDEVICE(ChakkariCopy, "ChakkariCopy")
uint16_t word
16 bit unsigned integer
#define INSTANTIATE_SERIALIZE_METHODS(CLASS)