openMSX
RomBlockDebuggable.hh
Go to the documentation of this file.
1#ifndef ROMBLOCKDEBUGGABLE_HH
2#define ROMBLOCKDEBUGGABLE_HH
3
4#include "SimpleDebuggable.hh"
5#include "MSXDevice.hh"
6#include <span>
7#include <string>
8
9namespace openmsx {
10
12{
13public:
14 explicit RomBlockDebuggableBase(const MSXDevice& device)
16 device.getMotherBoard(),
17 device.getName() + " romblocks",
18 "Shows for each byte of the mapper which memory block is selected.",
19 0x10000)
20 {
21 }
22protected:
24};
25
27{
28public:
29 RomBlockDebuggable(const MSXDevice& device, std::span<const byte> blockNr_,
30 unsigned startAddress_, unsigned mappedSize_,
31 unsigned bankSizeShift_, unsigned debugShift_ = 0)
33 , blockNr(blockNr_.data()), startAddress(startAddress_)
34 , mappedSize(mappedSize_), bankSizeShift(bankSizeShift_)
35 , debugShift(debugShift_), debugMask(~((1 << debugShift) - 1))
36 {
37 assert((mappedSize >> bankSizeShift) == blockNr_.size()); // no need to include 'debugMask' here
38 }
39 RomBlockDebuggable(const MSXDevice& device, std::span<const byte> blockNr_,
40 unsigned startAddress_, unsigned mappedSize_,
41 unsigned bankSizeShift_, unsigned debugShift_,
42 unsigned debugMask_)
44 , blockNr(blockNr_.data()), startAddress(startAddress_)
45 , mappedSize(mappedSize_), bankSizeShift(bankSizeShift_)
46 , debugShift(debugShift_), debugMask(debugMask_)
47 {
48 assert(((mappedSize >> bankSizeShift) & debugMask) < blockNr_.size()); // here we do need 'debugMask'
49 }
50
51 [[nodiscard]] byte read(unsigned address) override
52 {
53 unsigned addr = address - startAddress;
54 if (addr < mappedSize) {
55 byte tmp = blockNr[(addr >> bankSizeShift) & debugMask];
56 return (tmp != 255) ? (tmp >> debugShift) : tmp;
57 } else {
58 return 255; // outside mapped address space
59 }
60 }
61
62private:
63 const byte* blockNr;
64 const unsigned startAddress;
65 const unsigned mappedSize;
66 const unsigned bankSizeShift;
67 const unsigned debugShift;
68 const unsigned debugMask;
69};
70
71} // namespace openmsx
72
73#endif
An MSXDevice is an emulated hardware component connected to the bus of the emulated MSX.
Definition MSXDevice.hh:36
RomBlockDebuggableBase(const MSXDevice &device)
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_)
byte read(unsigned address) override
const std::string & getName() const
MSXMotherBoard & getMotherBoard() const
This file implemented 3 utility functions:
Definition Autofire.cc:11