18 #ifndef MT32EMU_MEMORY_REGION_H 19 #define MT32EMU_MEMORY_REGION_H 25 #include "Structures.h" 29 enum MemoryRegionType {
30 MR_PatchTemp, MR_RhythmTemp, MR_TimbreTemp, MR_Patches, MR_Timbres, MR_System, MR_Display, MR_Reset
41 MemoryRegionType type;
42 Bit32u startAddr, entrySize, entries;
44 MemoryRegion(
Synth *useSynth, Bit8u *useRealMemory, Bit8u *useMaxTable, MemoryRegionType useType, Bit32u useStartAddr, Bit32u useEntrySize, Bit32u useEntries) {
46 realMemory = useRealMemory;
47 maxTable = useMaxTable;
49 startAddr = useStartAddr;
50 entrySize = useEntrySize;
53 int lastTouched(Bit32u addr, Bit32u len)
const {
54 return (offset(addr) + len - 1) / entrySize;
56 int firstTouchedOffset(Bit32u addr)
const {
57 return offset(addr) % entrySize;
59 int firstTouched(Bit32u addr)
const {
60 return offset(addr) / entrySize;
62 Bit32u regionEnd()
const {
63 return startAddr + entrySize * entries;
65 bool contains(Bit32u addr)
const {
66 return addr >= startAddr && addr < regionEnd();
68 int offset(Bit32u addr)
const {
69 return addr - startAddr;
71 Bit32u getClampedLen(Bit32u addr, Bit32u len)
const {
72 if (addr + len > regionEnd())
73 return regionEnd() - addr;
76 Bit32u next(Bit32u addr, Bit32u len)
const {
77 if (addr + len > regionEnd()) {
78 return regionEnd() - addr;
82 Bit8u getMaxValue(
int off)
const {
85 return maxTable[off % entrySize];
87 Bit8u *getRealMemory()
const {
90 bool isReadable()
const {
91 return getRealMemory() != NULL;
93 void read(
unsigned int entry,
unsigned int off, Bit8u *dst,
unsigned int len)
const;
94 void write(
unsigned int entry,
unsigned int off,
const Bit8u *src,
unsigned int len,
bool init =
false)
const;
134 #endif // #ifndef MT32EMU_MEMORY_REGION_H Definition: Structures.h:47
Definition: Structures.h:111
Definition: MemoryRegion.h:127
Definition: MemoryRegion.h:121
Definition: Structures.h:136
Definition: MemoryRegion.h:105
Definition: Structures.h:160
Definition: MemoryRegion.h:109
Definition: MemoryRegion.h:97
Definition: Structures.h:143
Definition: Structures.h:155
Definition: MemoryRegion.h:35
Definition: MemoryRegion.h:101
Definition: MemoryRegion.h:113
Definition: MemoryRegion.h:117