openMSX
RomNeo16.cc
Go to the documentation of this file.
1#include "RomNeo16.hh"
2#include "serialize.hh"
3#include "xrange.hh"
4
5namespace openmsx {
6
7RomNeo16::RomNeo16(const DeviceConfig& config, Rom&& rom_)
8 : Rom16kBBlocks(config, std::move(rom_))
9{
10 reset(EmuTime::dummy());
11}
12
13void RomNeo16::reset(EmuTime::param /*time*/)
14{
15 for (auto i : xrange(3)) {
16 setRom(i, 0);
17 blockReg[i] = 0;
18 }
19 setUnmapped(3);
20}
21
22void RomNeo16::writeMem(word address, byte value, EmuTime::param /*time*/)
23{
24 unsigned bbb = (address >> 11) & 0b111;
25 if ((bbb < 2) || (bbb & 1)) return;
26 unsigned region = (bbb >> 1) - 1;
27 if ((address & 1) == 0) {
28 blockReg[region] = uint16_t((blockReg[region] & 0xFF00) | value);
29 } else {
30 blockReg[region] = uint16_t((blockReg[region] & 0x00FF) | ((value & 0b1111) << 8));
31 }
32 setRom(region, blockReg[region]);
33}
34
36{
37 unsigned bbb = (address >> 11) & 0b111;
38 return ((bbb < 2) || (bbb & 1)) ? unmappedWrite.data() : nullptr;
39}
40
41template<typename Archive>
42void RomNeo16::serialize(Archive& ar, unsigned /*version*/)
43{
44 ar.template serializeBase<Rom16kBBlocks>(*this);
45 ar.serialize("blockReg", blockReg);
46}
48
49} // namespace openmsx
#define REGISTER_MSXDEVICE(CLASS, NAME)
Definition MSXDevice.hh:356
static std::array< byte, 0x10000 > unmappedWrite
Definition MSXDevice.hh:307
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 reset(EmuTime::param time) override
This method is called on reset.
Definition RomNeo16.cc:13
void serialize(Archive &ar, unsigned version)
Definition RomNeo16.cc:42
RomNeo16(const DeviceConfig &config, Rom &&rom)
Definition RomNeo16.cc:7
void writeMem(word address, byte value, EmuTime::param time) override
Write a given byte to a given location at a certain time to this device.
Definition RomNeo16.cc:22
byte * getWriteCacheLine(word address) override
Test that the memory in the interval [start, start + CacheLine::SIZE) is cacheable for writing.
Definition RomNeo16.cc:35
This file implemented 3 utility functions:
Definition Autofire.cc:11
uint16_t word
16 bit unsigned integer
Definition openmsx.hh:29
STL namespace.
constexpr auto xrange(T e)
Definition xrange.hh:132