openMSX
RomKonamiKeyboardMaster.cc
Go to the documentation of this file.
3 #include "serialize.hh"
4 #include "unreachable.hh"
5 
6 namespace openmsx {
7 
8 RomKonamiKeyboardMaster::RomKonamiKeyboardMaster(
9  const DeviceConfig& config, Rom&& rom_)
11  , vlm5030("VLM5030", "Konami Keyboard Master's VLM5030",
13 {
14  setUnmapped(0);
15  setRom(1, 0);
16  setUnmapped(2);
17  setUnmapped(3);
18 
19  reset(EmuTime::dummy());
20 
21  getCPUInterface().register_IO_Out(0x00, this);
22  getCPUInterface().register_IO_Out(0x20, this);
23  getCPUInterface().register_IO_In(0x00, this);
24  getCPUInterface().register_IO_In(0x20, this);
25 }
26 
27 RomKonamiKeyboardMaster::~RomKonamiKeyboardMaster()
28 {
29  getCPUInterface().unregister_IO_Out(0x00, this);
30  getCPUInterface().unregister_IO_Out(0x20, this);
31  getCPUInterface().unregister_IO_In(0x00, this);
32  getCPUInterface().unregister_IO_In(0x20, this);
33 }
34 
35 void RomKonamiKeyboardMaster::reset(EmuTime::param /*time*/)
36 {
37  vlm5030.reset();
38 }
39 
40 void RomKonamiKeyboardMaster::writeIO(word port, byte value, EmuTime::param time)
41 {
42  switch (port & 0xFF) {
43  case 0x00:
44  vlm5030.writeData(value);
45  break;
46  case 0x20:
47  vlm5030.writeControl(value, time);
48  break;
49  default:
51  }
52 }
53 
54 byte RomKonamiKeyboardMaster::readIO(word port, EmuTime::param time)
55 {
56  return RomKonamiKeyboardMaster::peekIO(port, time);
57 }
58 
59 byte RomKonamiKeyboardMaster::peekIO(word port, EmuTime::param time) const
60 {
61  switch (port & 0xFF) {
62  case 0x00:
63  return vlm5030.getBSY(time) ? 0x10 : 0x00;
64  case 0x20:
65  return 0xFF;
66  default:
67  UNREACHABLE; return 0xFF;
68  }
69 }
70 
71 template<typename Archive>
72 void RomKonamiKeyboardMaster::serialize(Archive& ar, unsigned /*version*/)
73 {
74  ar.template serializeBase<Rom16kBBlocks>(*this);
75  ar.serialize("VLM5030", vlm5030);
76 }
78 REGISTER_MSXDEVICE(RomKonamiKeyboardMaster, "RomKonamiKeyboardMaster");
79 
80 } // namespace openmsx
bool getEnum() const noexcept
Definition: EnumSetting.hh:96
void serialize(Archive &ar, unsigned version)
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.
#define REGISTER_MSXDEVICE(CLASS, NAME)
Definition: MSXDevice.hh:307
#define INSTANTIATE_SERIALIZE_METHODS(CLASS)
Definition: serialize.hh:981
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.
RomKonamiKeyboardMaster(const DeviceConfig &config, Rom &&rom)
void reset(EmuTime::param time) override
This method is called on reset.
#define UNREACHABLE
Definition: unreachable.hh:38