20 static std::unique_ptr<Keyboard> createKeyboard(
const DeviceConfig& config)
22 bool keyGhosting = config.getChildDataAsBool(
"key_ghosting",
true);
23 bool keyGhostingSGCprotected =
24 config.getChildDataAsBool(
"key_ghosting_sgc_protected",
true);
25 string_ref keyboardType = config.getChildData(
"keyboard_type",
"int");
26 bool hasKeypad = config.getChildDataAsBool(
"has_keypad",
true);
27 bool hasYesNoKeys = config.getChildDataAsBool(
"has_yesno_keys",
false);
28 bool codeKanaLocks = config.getChildDataAsBool(
"code_kana_locks",
false);
29 bool graphLocks = config.getChildDataAsBool(
"graph_locks",
false);
30 MSXMotherBoard& motherBoard = config.getMotherBoard();
31 return make_unique<Keyboard>(
33 motherBoard.getScheduler(),
34 motherBoard.getCommandController(),
35 motherBoard.getReactor().getEventDistributor(),
36 motherBoard.getMSXEventDistributor(),
37 motherBoard.getStateChangeDistributor(),
38 keyboardType, hasKeypad, hasYesNoKeys,
39 keyGhosting, keyGhostingSGCprotected,
40 codeKanaLocks, graphLocks);
45 , cassettePort(getMotherBoard().getCassettePort())
46 , renshaTurbo(getMotherBoard().getRenShaTurbo())
49 , keyboard(createKeyboard(config))
74 switch (port & 0x03) {
76 return i8255->readPortA(time);
78 return i8255->readPortB(time);
80 return i8255->readPortC(time);
82 return i8255->readControlPort(time);
91 switch (port & 0x03) {
93 return i8255->peekPortA(time);
95 return i8255->peekPortB(time);
97 return i8255->peekPortC(time);
99 return i8255->readControlPort(time);
108 switch (port & 0x03) {
110 i8255->writePortA(value, time);
113 i8255->writePortB(value, time);
116 i8255->writePortC(value, time);
119 i8255->writeControlPort(value, time);
154 if (selectedRow != 8) {
155 return keyboard->getKeys()[selectedRow];
157 return keyboard->getKeys()[8] | (renshaTurbo.
getSignal(time) ? 1:0);
183 if ((prevBits ^ value) & 1) {
184 cassettePort.
setMotor((value & 1) == 0, time);
186 if ((prevBits ^ value) & 2) {
189 if ((prevBits ^ value) & 4) {
192 if ((prevBits ^ value) & 8) {
193 click->setClick((value & 8) != 0, time);
203 template<
typename Archive>
206 ar.template serializeBase<MSXDevice>(*this);
207 ar.serialize(
"i8255", *i8255);
210 byte portC = (prevBits << 4) | (selectedRow << 0);
211 ar.serialize(
"portC", portC);
213 selectedRow = (portC >> 0) & 0xF;
214 nibble bits = (portC >> 4) & 0xF;
217 ar.serialize(
"keyboard", *keyboard);