openMSX
RomKonamiKeyboardMaster.cc
Go to the documentation of this file.
2#include "MSXCPUInterface.hh"
3#include "serialize.hh"
4#include "unreachable.hh"
5
6namespace 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 auto& cpuInterface = getCPUInterface();
22 for (auto port : {0x00, 0x20}) {
23 cpuInterface.register_IO_Out(narrow_cast<byte>(port), this);
24 cpuInterface.register_IO_In (narrow_cast<byte>(port), this);
25 }
26}
27
29{
30 auto& cpuInterface = getCPUInterface();
31 for (auto port : {0x00, 0x20}) {
32 cpuInterface.unregister_IO_Out(narrow_cast<byte>(port), this);
33 cpuInterface.unregister_IO_In (narrow_cast<byte>(port), this);
34 }
35}
36
37void RomKonamiKeyboardMaster::reset(EmuTime::param /*time*/)
38{
39 vlm5030.reset();
40}
41
42void RomKonamiKeyboardMaster::writeIO(word port, byte value, EmuTime::param time)
43{
44 switch (port & 0xFF) {
45 case 0x00:
46 vlm5030.writeData(value);
47 break;
48 case 0x20:
49 vlm5030.writeControl(value, time);
50 break;
51 default:
53 }
54}
55
56byte RomKonamiKeyboardMaster::readIO(word port, EmuTime::param time)
57{
58 return RomKonamiKeyboardMaster::peekIO(port, time);
59}
60
61byte RomKonamiKeyboardMaster::peekIO(word port, EmuTime::param time) const
62{
63 switch (port & 0xFF) {
64 case 0x00:
65 return vlm5030.getBSY(time) ? 0x10 : 0x00;
66 case 0x20:
67 return 0xFF;
68 default:
70 }
71}
72
73template<typename Archive>
74void RomKonamiKeyboardMaster::serialize(Archive& ar, unsigned /*version*/)
75{
76 ar.template serializeBase<Rom16kBBlocks>(*this);
77 ar.serialize("VLM5030", vlm5030);
78}
80REGISTER_MSXDEVICE(RomKonamiKeyboardMaster, "RomKonamiKeyboardMaster");
81
82} // namespace openmsx
#define REGISTER_MSXDEVICE(CLASS, NAME)
Definition MSXDevice.hh:356
MSXCPUInterface & getCPUInterface() const
Definition MSXDevice.cc:133
void setUnmapped(unsigned region)
Select 'unmapped' memory for this region.
Definition RomBlocks.cc:92
void setRom(unsigned region, unsigned block)
Selects a block of the ROM image for reading in a certain region.
Definition RomBlocks.cc:104
void serialize(Archive &ar, unsigned version)
byte peekIO(word port, EmuTime::param time) const override
Read a byte from a given IO port.
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.
byte readIO(word port, EmuTime::param time) override
Read a byte from an IO port at a certain time from this device.
void reset(EmuTime::param time) override
This method is called on reset.
RomKonamiKeyboardMaster(const DeviceConfig &config, Rom &&rom)
void writeData(uint8_t data)
latch control data
Definition VLM5030.cc:421
bool getBSY(EmuTime::param time) const
get BSY pin level
Definition VLM5030.cc:414
void writeControl(uint8_t data, EmuTime::param time)
set RST / VCU / ST pins
Definition VLM5030.cc:426
This file implemented 3 utility functions:
Definition Autofire.cc:11
uint16_t word
16 bit unsigned integer
Definition openmsx.hh:29
STL namespace.
#define INSTANTIATE_SERIALIZE_METHODS(CLASS)
#define UNREACHABLE