1#ifndef ROMBLOCKDEBUGGABLE_HH
2#define ROMBLOCKDEBUGGABLE_HH
17 device.
getName() +
" romblocks",
18 "Shows for each byte of the mapper which memory block is selected.",
24 [[nodiscard]]
byte read(
unsigned address)
override {
25 return narrow_cast<byte>(
readExt(address));
29 [[nodiscard]]
virtual unsigned readExt(
unsigned address) = 0;
41 unsigned startAddress_,
unsigned mappedSize_,
42 unsigned bankSizeShift_,
unsigned debugShift_ = 0)
44 , blockNr(blockNr_.data()), startAddress(startAddress_)
45 , mappedSize(mappedSize_), bankSizeShift(bankSizeShift_)
46 , debugShift(debugShift_), debugMask(~((1 << debugShift) - 1))
48 assert((mappedSize >> bankSizeShift) == blockNr_.size());
51 unsigned startAddress_,
unsigned mappedSize_,
52 unsigned bankSizeShift_,
unsigned debugShift_,
55 , blockNr(blockNr_.data()), startAddress(startAddress_)
56 , mappedSize(mappedSize_), bankSizeShift(bankSizeShift_)
57 , debugShift(debugShift_), debugMask(debugMask_)
59 assert(((mappedSize >> bankSizeShift) & debugMask) < blockNr_.size());
62 [[nodiscard]]
unsigned readExt(
unsigned address)
override
64 unsigned addr = address - startAddress;
65 if (addr < mappedSize) {
66 byte tmp = blockNr[(addr >> bankSizeShift) & debugMask];
67 return (tmp != 255) ? (tmp >> debugShift) : tmp;
75 const unsigned startAddress;
76 const unsigned mappedSize;
77 const unsigned bankSizeShift;
78 const unsigned debugShift;
79 const unsigned debugMask;
An MSXDevice is an emulated hardware component connected to the bus of the emulated MSX.
byte read(unsigned address) override
RomBlockDebuggableBase(const MSXDevice &device)
virtual unsigned readExt(unsigned address)=0
~RomBlockDebuggableBase()=default
unsigned readExt(unsigned address) override
RomBlockDebuggable(const MSXDevice &device, std::span< const byte > blockNr_, unsigned startAddress_, unsigned mappedSize_, unsigned bankSizeShift_, unsigned debugShift_=0)
RomBlockDebuggable(const MSXDevice &device, std::span< const byte > blockNr_, unsigned startAddress_, unsigned mappedSize_, unsigned bankSizeShift_, unsigned debugShift_, unsigned debugMask_)
const std::string & getName() const
MSXMotherBoard & getMotherBoard() const
This file implemented 3 utility functions: