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 }
58 REGISTER_MSXDEVICE(RomArc, "RomArc");
59 
60 } // namespace openmsx
RomArc.hh
serialize.hh
openmsx::DeviceConfig
Definition: DeviceConfig.hh:19
openmsx::MSXCPUInterface::register_IO_Out
void register_IO_Out(byte port, MSXDevice *device)
Devices can register their Out ports.
Definition: MSXCPUInterface.cc:350
openmsx::MSXDevice::getCPUInterface
MSXCPUInterface & getCPUInterface() const
Definition: MSXDevice.cc:138
openmsx::RomArc
Definition: RomArc.hh:8
openmsx::REGISTER_MSXDEVICE
REGISTER_MSXDEVICE(ChakkariCopy, "ChakkariCopy")
openmsx::RomArc::readIO
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
openmsx::RomBlocks::setRom
void setRom(byte region, unsigned block)
Selects a block of the ROM image for reading in a certain region.
Definition: RomBlocks.cc:104
openmsx::RomArc::writeIO
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
openmsx::RomBlocks::setUnmapped
void setUnmapped(byte region)
Select 'unmapped' memory for this region.
Definition: RomBlocks.cc:91
openmsx::RomBlocks
Definition: RomBlocks.hh:13
INSTANTIATE_SERIALIZE_METHODS
#define INSTANTIATE_SERIALIZE_METHODS(CLASS)
Definition: serialize.hh:981
openmsx::RomArc::reset
void reset(EmuTime::param time) override
This method is called on reset.
Definition: RomArc.cc:29
openmsx::MSXCPUInterface::register_IO_In
void register_IO_In(byte port, MSXDevice *device)
Devices can register their In ports.
Definition: MSXCPUInterface.cc:338
openmsx::RomArc::RomArc
RomArc(const DeviceConfig &config, Rom &&rom)
Definition: RomArc.cc:9
openmsx::Rom
Definition: Rom.hh:20
openmsx::MSXCPUInterface::unregister_IO_In
void unregister_IO_In(byte port, MSXDevice *device)
Definition: MSXCPUInterface.cc:344
openmsx::word
uint16_t word
16 bit unsigned integer
Definition: openmsx.hh:29
openmsx::RomArc::serialize
void serialize(Archive &ar, unsigned version)
Definition: RomArc.cc:52
MSXCPUInterface.hh
openmsx::MSXCPUInterface::unregister_IO_Out
void unregister_IO_Out(byte port, MSXDevice *device)
Definition: MSXCPUInterface.cc:356
openmsx::RomArc::peekIO
byte peekIO(word port, EmuTime::param time) const override
Read a byte from a given IO port.
Definition: RomArc.cc:46
openmsx
Thanks to enen for testing this on a real cartridge:
Definition: Autofire.cc:5
openmsx::RomArc::~RomArc
~RomArc() override
Definition: RomArc.cc:23