openMSX
RomArc.cc
Go to the documentation of this file.
1 // Parallax' Arc
2 
3 #include "RomArc.hh"
4 #include "MSXCPUInterface.hh"
5 #include "serialize.hh"
6 
7 namespace openmsx {
8 
9 RomArc::RomArc(const DeviceConfig& config, Rom&& rom_)
10  : Rom16kBBlocks(config, std::move(rom_))
11 {
12  setUnmapped(0);
13  setRom(1, 0);
14  setRom(2, 1);
15  setUnmapped(3);
16 
17  reset(EmuTime::dummy());
18 
19  getCPUInterface().register_IO_Out(0x7f, this);
20  getCPUInterface().register_IO_In (0x7f, this);
21 }
22 
24 {
25  getCPUInterface().unregister_IO_Out(0x7f, this);
26  getCPUInterface().unregister_IO_In (0x7f, this);
27 }
28 
29 void RomArc::reset(EmuTime::param /*time*/)
30 {
31  offset = 0x00;
32 }
33 
34 void RomArc::writeIO(word /*port*/, byte value, EmuTime::param /*time*/)
35 {
36  if (value == 0x35) {
37  ++offset;
38  }
39 }
40 
41 byte RomArc::readIO(word port, EmuTime::param time)
42 {
43  return RomArc::peekIO(port, time);
44 }
45 
46 byte RomArc::peekIO(word /*port*/, EmuTime::param /*time*/) const
47 {
48  return ((offset & 0x03) == 0x03) ? 0xda : 0xff;
49 }
50 
51 template<typename Archive>
52 void RomArc::serialize(Archive& ar, unsigned /*version*/)
53 {
54  ar.template serializeBase<Rom16kBBlocks>(*this);
55  ar.serialize("offset", offset);
56 }
59 
60 } // 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:134
RomArc(const DeviceConfig &config, Rom &&rom)
Definition: RomArc.cc:9
void serialize(Archive &ar, unsigned version)
Definition: RomArc.cc:52
byte readIO(word port, EmuTime::param time) override
Read a byte from an IO port at a certain time from this device.
Definition: RomArc.cc:41
byte peekIO(word port, EmuTime::param time) const override
Read a byte from a given IO port.
Definition: RomArc.cc:46
~RomArc() override
Definition: RomArc.cc:23
void reset(EmuTime::param time) override
This method is called on reset.
Definition: RomArc.cc:29
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: RomArc.cc:34
void setRom(byte region, unsigned block)
Selects a block of the ROM image for reading in a certain region.
Definition: RomBlocks.cc:105
void setUnmapped(byte region)
Select 'unmapped' memory for this region.
Definition: RomBlocks.cc:92
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
#define INSTANTIATE_SERIALIZE_METHODS(CLASS)
Definition: serialize.hh:998