Post subject: Brute forcing interface in C++
Joined: 12/14/2019
Posts: 2
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
Joined: 12/14/2019
Posts: 2
Update: I've found a video from javidx9 on how to develop a nes emulator from scratch (https://www.youtube.com/watch?v=F8kx56OZQhg) He has a github with all the code (https://github.com/OneLoneCoder/olcNES) I checked with David (the dev behind this) and he said a sequence of joypad input on his code should yield same results on FCEUX (at least on games with simpler mappers) I will disable all APU sound logic, and simulate just CPU and PPU (PPU has interrupts that can change CPU behavior) and log RAM + Nametable + Registers as my state. Thanks! Davi