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 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{
33}
34
35void RomKonamiKeyboardMaster::reset(EmuTime::param /*time*/)
36{
37 vlm5030.reset();
38}
39
40void 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
54byte RomKonamiKeyboardMaster::readIO(word port, EmuTime::param time)
55{
56 return RomKonamiKeyboardMaster::peekIO(port, time);
57}
58
59byte 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
71template<typename Archive>
72void RomKonamiKeyboardMaster::serialize(Archive& ar, unsigned /*version*/)
73{
74 ar.template serializeBase<Rom16kBBlocks>(*this);
75 ar.serialize("VLM5030", vlm5030);
76}
78REGISTER_MSXDEVICE(RomKonamiKeyboardMaster, "RomKonamiKeyboardMaster");
79
80} // namespace openmsx
void register_IO_Out(byte port, MSXDevice *device)
Devices can register their Out ports.
void register_IO_In(byte port, MSXDevice *device)
Devices can register their In ports.
void unregister_IO_In(byte port, MSXDevice *device)
void unregister_IO_Out(byte port, MSXDevice *device)
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:424
bool getBSY(EmuTime::param time) const
get BSY pin level
Definition: VLM5030.cc:417
void writeControl(uint8_t data, EmuTime::param time)
set RST / VCU / ST pins
Definition: VLM5030.cc:429
This file implemented 3 utility functions:
Definition: Autofire.cc:9
REGISTER_MSXDEVICE(ChakkariCopy, "ChakkariCopy")
uint16_t word
16 bit unsigned integer
Definition: openmsx.hh:29
STL namespace.
#define INSTANTIATE_SERIALIZE_METHODS(CLASS)
Definition: serialize.hh:1021
#define UNREACHABLE
Definition: unreachable.hh:38