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 <string>
7
8namespace openmsx {
9
11{
12public:
13 explicit RomBlockDebuggableBase(const MSXDevice& device)
15 device.getMotherBoard(),
16 device.getName() + " romblocks",
17 "Shows for each byte of the mapper which memory block is selected.",
18 0x10000)
19 {
20 }
21protected:
23};
24
26{
27public:
28 RomBlockDebuggable(const MSXDevice& device, const byte* blockNr_,
29 unsigned startAddress_, unsigned mappedSize_,
30 unsigned bankSizeShift_, unsigned debugShift_ = 0)
32 , blockNr(blockNr_), startAddress(startAddress_)
33 , mappedSize(mappedSize_), bankSizeShift(bankSizeShift_)
34 , debugShift(debugShift_), debugMask(~((1 << debugShift) - 1))
35 {
36 }
37 RomBlockDebuggable(const MSXDevice& device, const byte* blockNr_,
38 unsigned startAddress_, unsigned mappedSize_,
39 unsigned bankSizeShift_, unsigned debugShift_,
40 unsigned debugMask_)
42 , blockNr(blockNr_), startAddress(startAddress_)
43 , mappedSize(mappedSize_), bankSizeShift(bankSizeShift_)
44 , debugShift(debugShift_), debugMask(debugMask_)
45 {
46 }
47
48 [[nodiscard]] byte read(unsigned address) override
49 {
50 unsigned addr = address - startAddress;
51 if (addr < mappedSize) {
52 byte tmp = blockNr[(addr >> bankSizeShift) & debugMask];
53 return (tmp != 255) ? (tmp >> debugShift) : tmp;
54 } else {
55 return 255; // outside mapped address space
56 }
57 }
58
59private:
60 const byte* blockNr;
61 const unsigned startAddress;
62 const unsigned mappedSize;
63 const unsigned bankSizeShift;
64 const unsigned debugShift;
65 const unsigned debugMask;
66};
67
68} // namespace openmsx
69
70#endif
An MSXDevice is an emulated hardware component connected to the bus of the emulated MSX.
Definition: MSXDevice.hh:33
RomBlockDebuggableBase(const MSXDevice &device)
RomBlockDebuggable(const MSXDevice &device, const byte *blockNr_, unsigned startAddress_, unsigned mappedSize_, unsigned bankSizeShift_, unsigned debugShift_=0)
RomBlockDebuggable(const MSXDevice &device, 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:9