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 cpuInterface.register_IO_InOut(0x00, this);
23 cpuInterface.register_IO_InOut(0x20, this);
24}
25
27{
28 auto& cpuInterface = getCPUInterface();
29 cpuInterface.unregister_IO_InOut(0x00, this);
30 cpuInterface.unregister_IO_InOut(0x20, this);
31}
32
33void RomKonamiKeyboardMaster::reset(EmuTime::param /*time*/)
34{
35 vlm5030.reset();
36}
37
38void RomKonamiKeyboardMaster::writeIO(word port, byte value, EmuTime::param time)
39{
40 switch (port & 0xFF) {
41 case 0x00:
42 vlm5030.writeData(value);
43 break;
44 case 0x20:
45 vlm5030.writeControl(value, time);
46 break;
47 default:
49 }
50}
51
52byte RomKonamiKeyboardMaster::readIO(word port, EmuTime::param time)
53{
54 return RomKonamiKeyboardMaster::peekIO(port, time);
55}
56
57byte RomKonamiKeyboardMaster::peekIO(word port, EmuTime::param time) const
58{
59 switch (port & 0xFF) {
60 case 0x00:
61 return vlm5030.getBSY(time) ? 0x10 : 0x00;
62 case 0x20:
63 return 0xFF;
64 default:
66 }
67}
68
69template<typename Archive>
70void RomKonamiKeyboardMaster::serialize(Archive& ar, unsigned /*version*/)
71{
72 ar.template serializeBase<Rom16kBBlocks>(*this);
73 ar.serialize("VLM5030", vlm5030);
74}
76REGISTER_MSXDEVICE(RomKonamiKeyboardMaster, "RomKonamiKeyboardMaster");
77
78} // 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