openMSX
RomBlockDebuggable.hh
Go to the documentation of this file.
1 #include "SimpleDebuggable.hh"
2 #include "MSXDevice.hh"
3 #include <string>
4 
5 namespace openmsx {
6 
8 {
9 public:
12  device.getMotherBoard(),
13  device.getName() + " romblocks",
14  "Shows for each byte of the mapper which memory block is selected.",
15  0x10000)
16  {
17  }
18 };
19 
21 {
22 public:
23  RomBlockDebuggable(const MSXDevice& device, const byte* blockNr_,
24  unsigned startAddress_, unsigned mappedSize_,
25  unsigned bankSizeShift_, unsigned debugShift_ = 0)
26  : RomBlockDebuggableBase(device)
27  , blockNr(blockNr_), startAddress(startAddress_)
28  , mappedSize(mappedSize_), bankSizeShift(bankSizeShift_)
29  , debugShift(debugShift_), debugMask(~((1 << debugShift) - 1))
30  {
31  }
32  RomBlockDebuggable(const MSXDevice& device, const byte* blockNr_,
33  unsigned startAddress_, unsigned mappedSize_,
34  unsigned bankSizeShift_, unsigned debugShift_,
35  unsigned debugMask_)
36  : RomBlockDebuggableBase(device)
37  , blockNr(blockNr_), startAddress(startAddress_)
38  , mappedSize(mappedSize_), bankSizeShift(bankSizeShift_)
39  , debugShift(debugShift_), debugMask(debugMask_)
40  {
41  }
42 
43  virtual byte read(unsigned address)
44  {
45  unsigned addr = address - startAddress;
46  if (addr < mappedSize) {
47  byte tmp = blockNr[(addr >> bankSizeShift) & debugMask];
48  return (tmp != 255) ? (tmp >> debugShift) : tmp;
49  } else {
50  return 255; // outside mapped address space
51  }
52  }
53 
54 private:
55  const byte* blockNr;
56  const unsigned startAddress;
57  const unsigned mappedSize;
58  const unsigned bankSizeShift;
59  const unsigned debugShift;
60  const unsigned debugMask;
61 };
62 
63 } // namespace openmsx