15 static byte getKeyboardLayout(
const MSXPSG& psg)
19 auto value = psg.getDeviceConfig().getChildData(
"keyboardlayout",
"50on");
21 if (cmp(value,
"50on")) {
23 }
else if (cmp(value,
"jis")) {
27 "Illegal keyboard layout configuration in '", psg.getName(),
28 "' device configuration: '", value,
29 "', expected 'jis' or '50on'.");
35 , cassette(getMotherBoard().getCassettePort())
36 , renShaTurbo(getMotherBoard().getRenShaTurbo())
39 , keyLayout(getKeyboardLayout(*this))
40 , addressMask(config.getChildDataAsBool(
"mirrored_registers", true) ? 0x0f : 0xff)
44 ay8910 = std::make_unique<AY8910>(
"PSG", *
this, config,
getCurrentTime());
67 return ay8910->readRegister(registerLatch, time);
72 return ay8910->peekRegister(registerLatch, time);
77 switch (port & 0x03) {
79 registerLatch = value & addressMask;
82 ay8910->writeRegister(registerLatch, value, time);
89 byte MSXPSG::readA(EmuTime::param time)
91 byte joystick = ports[selectedPort]->
read(time) |
92 ((renShaTurbo.
getSignal(time)) ? 0x10 : 0x00);
95 byte pin67 = prev << (4 - 2 * selectedPort);
96 joystick &= (pin67| 0xCF);
98 byte cassetteInput = cassette.
cassetteIn(time) ? 0x80 : 0x00;
99 return joystick | keyLayout | cassetteInput;
102 void MSXPSG::writeB(
byte value, EmuTime::param time)
104 byte val0 = (value & 0x03) | ((value & 0x10) >> 2);
105 byte val1 = ((value & 0x0C) >> 2) | ((value & 0x20) >> 3);
106 ports[0]->
write(val0, time);
107 ports[1]->
write(val1, time);
108 selectedPort = (value & 0x40) >> 6;
110 if ((prev ^ value) & 0x80) {
118 template<
typename Archive>
121 ar.template serializeBase<MSXDevice>(*
this);
122 ar.serialize(
"ay8910", *ay8910);
123 if (ar.versionBelow(version, 2)) {
124 assert(ar.isLoader());
126 ar.serialize(
"joystickportA", *checked_cast<JoystickPort*>(ports[0]),
127 "joystickportB", *checked_cast<JoystickPort*>(ports[1]));
129 ar.serialize(
"registerLatch", registerLatch);
131 ar.serialize(
"portB", portB);
virtual bool cassetteIn(EmuTime::param time)=0
Reads one bit from the cassette port.
virtual void write(byte value, EmuTime::param time)=0
virtual byte read(EmuTime::param time)=0
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.
This file implemented 3 utility functions:
REGISTER_MSXDEVICE(ChakkariCopy, "ChakkariCopy")
uint16_t word
16 bit unsigned integer
#define INSTANTIATE_SERIALIZE_METHODS(CLASS)