Post subject: Question on pointers
Skilled player (1741)
Joined: 9/17/2009
Posts: 4981
Location: ̶C̶a̶n̶a̶d̶a̶ "Kanatah"
For some games, the relevant memory addresses for a run changes location every now and then. I have no idea how to find the pointer(s) for said addresses, and not every emulator has debugging tools, but I made a list of possible locations where said addresses may be. Using that list, would it be possible to locate the original pointer and offsets?
Joined: 12/31/2009
Posts: 174
It is possible without debugging tools but would require knowing the game's basic memory structure or luck. Your best bet would be to create a large sample of save states with the address being in different locations. Then you can use the displacements to find the pointer. Example: Save state 1: Address at 0x02045350 Save state 2: Address at 0x02046420 (+0x10D0) Save state 3: Address at 0x02042588 (- 0x3E98) Save state 4: Address at 0x02045434 (+0x2EAC) If I scanned each save state in that order, I would look for those differences to find pointers/offsets. It takes a long time but it works if you get a large enough sample to scan with.
Editor, Expert player (2329)
Joined: 5/15/2007
Posts: 3933
Location: Germany
you can use a lua script to run a custom memory search function to find the offset. Examples: http://pastebin.com/Ei3KJKX4 (kirby super star ultra) You slide to the left - Kirby's speed becomes -704 - then you click somewhere to run the custom function that searches for addresses that have that value. Then chances are you have the offset for all other addresses that you need, as well. http://tasvideos.org/forum/viewtopic.php?p=414994#414994 (Yoshi's topsy turvy) Likewise procedure: walk left so yoshi's speed becomes -512, then do the search.
local speed=-512
local z=0
local memorys={}
 
function MSearch()
        for i=0,53000 do
                memorys[i]=memory.readwordsigned(0x02000000+2*i)
 
                if memorys[i]==speed then
                        z=2*i
                        break
                end
        end    
end

(...)

while true do

        Xspeed = memory.readwordsigned(0x02000000+z)
        Yspeed = memory.readwordsigned(0x02000000+z+4)
        Angle = memory.readbyteunsigned(0x02000000+z-22)

(...)

emu.frameadvance()
end
Skilled player (1741)
Joined: 9/17/2009
Posts: 4981
Location: ̶C̶a̶n̶a̶d̶a̶ "Kanatah"
Kinda late, but thanks! The speed for the game at a glance appears rather tied to the character I'm using, but I'm positive I can find some way to use the (somewhat) constant spawn/starting locations instead. :)