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
string_view getFilename(string_view path)
Returns the file portion of a path name.
void serialize(Archive &ar, unsigned version)
void setRom(byte region, unsigned block)
Selects a block of the ROM image for reading in a certain region.
Definition: RomBlocks.cc:103
void writeControl(byte data, EmuTime::param time)
set RST / VCU / ST pins
Definition: VLM5030.cc:432
uint8_t byte
8 bit unsigned integer
Definition: openmsx.hh:26
STL namespace.
void writeData(byte data)
latch control data
Definition: VLM5030.cc:427
byte readIO(word port, EmuTime::param time) override
Read a byte from an IO port at a certain time from this device.
void unregister_IO_In(byte port, MSXDevice *device)
REGISTER_MSXDEVICE(ChakkariCopy, "ChakkariCopy")
byte peekIO(word port, EmuTime::param time) const override
Read a byte from a given IO port.
void register_IO_In(byte port, MSXDevice *device)
Devices can register their In ports.
void register_IO_Out(byte port, MSXDevice *device)
Devices can register their Out ports.
Thanks to enen for testing this on a real cartridge:
Definition: Autofire.cc:5
void unregister_IO_Out(byte port, MSXDevice *device)
uint16_t word
16 bit unsigned integer
Definition: openmsx.hh:29
#define INSTANTIATE_SERIALIZE_METHODS(CLASS)
Definition: serialize.hh:840
void setUnmapped(byte region)
Select &#39;unmapped&#39; memory for this region.
Definition: RomBlocks.cc:90
MSXCPUInterface & getCPUInterface() const
Definition: MSXDevice.cc:141
bool getBSY(EmuTime::param time) const
get BSY pin level
Definition: VLM5030.cc:420
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