Hello folks,
I have some ideas to brute force some game sections, but I am struggling to assemble the right API. I need to be able to read and write the whole memory, I tried playing around with LUA on FCEUX, I am able to acquire the memory with the following code:
Language: lua
mem_str = memory.readbyterange(0, 32767)
reg_str = ""
for k,r in ipairs({"a", "x", "y", "s", "p", "pc"}) do
reg_str = reg_str .. tostring(memory.getregister(r)) .. ";"
end
mem_str = mem_str .. reg_str
But I didn't find a way to write it back. The only writing mechanism was memory.writebyte(int address, int value), which writes a single byte, it would be very slow to write the whole memory this way.
I tried using the savestate interface, but the actual savestate objects are not surfaced, only their identifiers.
Language: lua
a = savestate.object()
savestate.save(a)
savestate.persist(a)
print (a)
Prints userdata:07617DD8
More specifically, what I want is:
string getMemory() //Gets memory + registers (exists)
void writeMemory(memory) // Writes memory + registers (essentially I can simulate my own savestate)
void SetJoypad(input) // (exists)
void FrameAdvance() // (exists)
I am aiming to hack around the FCEUX code and do this in C++, removing completely the whole graphics/sounds routines and emulating using the 4 routines above.
Any tips on how to achieve that would be greatly appreciated. :)
Thanks!
Davi