MemoryAccessor - Pythonic way to read and write the memory¶
- class desmume.emulator.MemoryAccessor(signed, mem: DeSmuME_Memory)[source]¶
Bases:
objectPythonic accessor class for manipulating the memory.
Access a single unsigned byte of memory at offset 0x100:
>>> emu_memory = DeSmuME().memory >>> emu_memory.unsigned[0x100] <<< 3
Access a subset of the memory as bytes:
>>> emu_memory = DeSmuME().memory >>> emu_memory.unsigned[0x100:0x200] <<< bytes(...)
Access a subset of the memory as signed integers:
>>> emu_memory = DeSmuME().memory >>> emu_memory.signed[0x100:0x200] <<< [-3, 2, ...]
Access a subset of memory as 4-byte unsigned integers:
>>> emu_memory = DeSmuME().memory >>> emu_memory.unsigned[0x100:0x200:4] <<< [-236, 1002, ...]
Writing to memory works the same way. It doesn’t matter if you use the signed or unsigned accessor for this, both work the same:
>>> emu_memory = DeSmuME().memory >>> emu_memory.unsigned[0x100] = 2
You can also use the
read_*methods instead for a more verbose way to read the memory as integers. For writing those methods can be found in theDeSmuME_Memoryparent object.Should not be instantiated manually!