openMSX
RomKonamiKeyboardMaster.cc
Go to the documentation of this file.
2 #include "MSXCPUInterface.hh"
3 #include "serialize.hh"
4 #include "unreachable.hh"
5 
6 namespace openmsx {
7 
9  const DeviceConfig& config, Rom&& rom_)
10  : Rom16kBBlocks(config, std::move(rom_))
11  , vlm5030("VLM5030", "Konami Keyboard Master's VLM5030",
12  rom.getFilename(), config)
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 
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
openmsx::VLM5030::writeData
void writeData(byte data)
latch control data
Definition: VLM5030.cc:428
serialize.hh
openmsx::DeviceConfig
Definition: DeviceConfig.hh:19
openmsx::MSXCPUInterface::register_IO_Out
void register_IO_Out(byte port, MSXDevice *device)
Devices can register their Out ports.
Definition: MSXCPUInterface.cc:350
openmsx::MSXDevice::getCPUInterface
MSXCPUInterface & getCPUInterface() const
Definition: MSXDevice.cc:138
openmsx::RomKonamiKeyboardMaster::writeIO
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.
Definition: RomKonamiKeyboardMaster.cc:40
openmsx::REGISTER_MSXDEVICE
REGISTER_MSXDEVICE(ChakkariCopy, "ChakkariCopy")
openmsx::RomKonamiKeyboardMaster::RomKonamiKeyboardMaster
RomKonamiKeyboardMaster(const DeviceConfig &config, Rom &&rom)
Definition: RomKonamiKeyboardMaster.cc:8
openmsx::RomKonamiKeyboardMaster
Definition: RomKonamiKeyboardMaster.hh:9
openmsx::VLM5030::writeControl
void writeControl(byte data, EmuTime::param time)
set RST / VCU / ST pins
Definition: VLM5030.cc:433
UNREACHABLE
#define UNREACHABLE
Definition: unreachable.hh:38
openmsx::RomBlocks::setRom
void setRom(byte region, unsigned block)
Selects a block of the ROM image for reading in a certain region.
Definition: RomBlocks.cc:104
openmsx::RomBlocks::setUnmapped
void setUnmapped(byte region)
Select 'unmapped' memory for this region.
Definition: RomBlocks.cc:91
openmsx::RomBlocks
Definition: RomBlocks.hh:13
INSTANTIATE_SERIALIZE_METHODS
#define INSTANTIATE_SERIALIZE_METHODS(CLASS)
Definition: serialize.hh:981
openmsx::VLM5030::reset
void reset()
Definition: VLM5030.cc:399
openmsx::VLM5030::getBSY
bool getBSY(EmuTime::param time) const
get BSY pin level
Definition: VLM5030.cc:421
openmsx::MSXCPUInterface::register_IO_In
void register_IO_In(byte port, MSXDevice *device)
Devices can register their In ports.
Definition: MSXCPUInterface.cc:338
openmsx::RomKonamiKeyboardMaster::reset
void reset(EmuTime::param time) override
This method is called on reset.
Definition: RomKonamiKeyboardMaster.cc:35
openmsx::Rom
Definition: Rom.hh:20
openmsx::RomKonamiKeyboardMaster::serialize
void serialize(Archive &ar, unsigned version)
Definition: RomKonamiKeyboardMaster.cc:72
openmsx::MSXCPUInterface::unregister_IO_In
void unregister_IO_In(byte port, MSXDevice *device)
Definition: MSXCPUInterface.cc:344
openmsx::RomKonamiKeyboardMaster::~RomKonamiKeyboardMaster
~RomKonamiKeyboardMaster() override
Definition: RomKonamiKeyboardMaster.cc:27
openmsx::word
uint16_t word
16 bit unsigned integer
Definition: openmsx.hh:29
MSXCPUInterface.hh
openmsx::RomKonamiKeyboardMaster::peekIO
byte peekIO(word port, EmuTime::param time) const override
Read a byte from a given IO port.
Definition: RomKonamiKeyboardMaster.cc:59
openmsx::MSXCPUInterface::unregister_IO_Out
void unregister_IO_Out(byte port, MSXDevice *device)
Definition: MSXCPUInterface.cc:356
unreachable.hh
openmsx
Thanks to enen for testing this on a real cartridge:
Definition: Autofire.cc:5
openmsx::RomKonamiKeyboardMaster::readIO
byte readIO(word port, EmuTime::param time) override
Read a byte from an IO port at a certain time from this device.
Definition: RomKonamiKeyboardMaster.cc:54
RomKonamiKeyboardMaster.hh