Before I redo the first stage I noticed the room ID address never changes location, and while the position ones do, they seem to always be the same for said ID. So here's a script that displays position depending on the room:
Download Scooby.luaLanguage: lua
memory.usememorydomain("Combined WRAM")
local Scooby = {ptr = 0x0112EC, x = 0x000000, y = 0x000000, speedx = 0x000000, speedy = 0x000000}
local Shaggy = {ptr = 0x0130C0, x = 0x000000, y = 0x000000, speedx = 0x000000, speedy = 0x000000}
function update(name)
if (name == "Scooby") then
local char = memory.read_s32_le(Scooby.ptr) - 0x02000000
Scooby.x = char + 0xC
Scooby.y = char + 0x10
Scooby.speedx = char + 0x14
Scooby.speedy = char + 0x18
else
local char = memory.read_s32_le(Shaggy.ptr) - 0x02000000
Shaggy.x = char + 0xC
Shaggy.y = char + 0x10
Shaggy.speedx = char + 0x14
Shaggy.speedy = char + 0x18
end
end
-- gui.drawText(int x, int y, string message, [Color? forecolor = null], [Color? backcolor = null], [int? fontsize = null], [string fontfamily = null], [string fontstyle = null])
while true do
local Scooby_ptr = memory.read_s32_le(Scooby.ptr) --for debug + updating pointers
local Shaggy_ptr = memory.read_s32_le(Shaggy.ptr)
local GhostHP = memory.readbyte(0x0113A4)
--Update Pointers
if (Scooby_ptr ~= Scooby.x-0xc+0x02000000 and Scooby_ptr ~= 0) then --this will happen if changed rooms or just started script
update("Scooby") --placing this here as to not lag my computer :P
end
if (Shaggy_ptr ~= Shaggy.x-0xc+0x02000000 and Shaggy_ptr ~= 0) then --pointer + 0xC points to x position. to find the pointer again, subtract 0xC from x address and add 0x02000000
update() --Updates Shaggy instead
end
--Displays X,Y,SpeedX,SpeedY
if (Scooby.x ~= 0x0 or Shaggy.x ~= 0x0) then --Check if the memory address of x is pointing to 0x0.
gui.drawText(0,140,"Scooby:"..string.format('%.6f',memory.read_u32_le(Scooby.x)/65536.0)..","..string.format('%.6f',memory.read_u32_le(Scooby.y)/65536.0)..","..memory.read_s32_le(Scooby.speedx)..","..memory.read_s32_le(Scooby.speedy),null,null,10,null,null)
gui.drawText(0,150,"Shaggy:"..string.format('%.6f',memory.read_u32_le(Shaggy.x)/65536.0)..","..string.format('%.6f',memory.read_u32_le(Shaggy.y)/65536.0)..","..memory.read_s32_le(Shaggy.speedx)..","..memory.read_s32_le(Shaggy.speedy),null,null,10,null,null)
end
--Display Ghosts HP
if (GhostHP > 0) then
gui.drawText(170,20,"HP:"..memory.readbyte(0x0113A4),null,null,10,null,null)
end
--Debugging
--gui.drawText(0,90,"Pointer (Scooby): 0x"..bizstring.hex(memory.read_s32_le(Scooby.ptr)),null,null,10,null,null)
--gui.drawText(0,105,"Pointer (Shaggy): 0x"..bizstring.hex(memory.read_s32_le(Shaggy.ptr)),null,null,10,null,null)
--Other things
gui.drawText(0,120,''..(memory.readbyte(0x00000D) > 0 and 'Cutscene' or ''),null,null,10,null,null) --If it's 1, there's dialogue/cutscene. Else no.
gui.drawText(0,130,"Room ID: 0x"..bizstring.hex(memory.readbyte(0x0006B9)),null,null,10,null,null)
emu.frameadvance()
end
Edit:
Going to the first camera at room 0x0E without partner switching is faster by 125 frames.
It takes 163 frames initially to grab the Scooby snacks on room 0x0E, but then reduces to 153 frames since I don't need to delay at room 0x0F anymore.
It takes 160 frames to grab Scooby snacks on room 0x10 for the first time instead, with no possible savings later.
room 0x21
at this point, getting damaged once makes me run at 889 speed temp. normal is 553
getting damaged from first ghost - 149 frames faster
getting damaged from the 2nd - too far
getting damaged from the 3rd ghost - 154 frames faster
getting damaged from the 4th ghost - 153 frames faster
Edit2: In an attempt to figure out how room's affect position addresses, I think I found a pointer: 0x0112EC seems to point towards the player's positions so far. I changed my script to reflect that. :)