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