Memory and registers
The Lua code can access the emulated memory and registers directly through some FFI bindings:
PCSX.getMemPtr()will return a
cdata[uint8_t*]representing up to 8MB of emulated memory. This can be written to, but careful about the emulated i-cache in case code is being written to.
PCSX.getParPtr()will return a
cdata[uint8_t*]representing up to 512kB of the EXP1/Parallel port memory space. This can be written to.
PCSX.getRomPtr()will return a
cdata[uint8_t*]representing up to 512kB of the BIOS memory space. This can be written to.
PCSX.getScratchPtr()will return a
cdata[uint8_t*]representing up to 1kB for the scratchpad memory space.
PCSX.getRegisters()will return a structured cdata representing all the registers present in the CPU:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
The above methods will return direct pointers into the emulated memory, so it's easy to crash the emulator if you're not careful. The
getMemoryAsFile() method is safer, but will be slower:
PCSX.getMemoryAsFile()will return a
Fileobject representing the full 4GB of accessible memory. All operations on this file will be translated to the emulated memory space. This is slower than the direct access methods, but safer. Any read or write operation will be clamped to the emulated memory space, and will not crash the emulator.