Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Script made by Masterjun to display stuff on the screen of Dolphin.
- -- Variables that need to be changed after the functions.
- -- Make sure that you checked "Graphics > Advanced > Show Statistics".
- --------------------------------------------------------------------------------
- --------------------------------------------------------------------------------
- --appends a string s to a table t as hex values
- local function appendstr(t,s)
- for i=1,#s do table.insert(t,string.byte(string.sub(s,i,i))) end
- table.insert(t,0x0A)
- return t
- end
- --converts a number into float
- local function tofloat(x)
- if x==0 then return 0 end
- local s = 1
- if x>=0x80000000 then
- s = -1
- x=x-0x80000000
- end
- local e = math.floor(x/0x800000)-127
- local m=(x%0x800000)/0x800000+1
- return s*(2^e)*m
- end
- --converts a table to a string
- local function tabletostr(x)
- local s = ""
- for k,v in pairs(x) do s=s..string.format("%02X",v) end
- return s
- end
- --takes two 4byte tables (the thing that returns when you getBytes(addr,4,true)
- --it turns the first one into a float string or gives the difference between the
- --first one and the second one
- --second argument is optional
- local function toflstr(x,y)
- local minus = 0
- local s
- local sx = tabletostr(x)
- local sy = ""
- if y then
- sy = tabletostr(y)
- minus=tofloat(tonumber(sy,16))
- end
- s = tostring(tofloat(tonumber(sx,16))-minus)
- return s
- end
- --scans for a string and returns the address of the first result
- --if there is no result it returns nil
- local function scanstr(str)
- local startaddr=0
- local stopaddr=0x7fffffffffffffff
- local scan = createMemScan()
- scan.OnlyOneResult=true
- scan.firstScan(soExactValue,vtString,rtTruncated,str,"",startaddr,stopaddr,
- "+W-C",fsmNotAligned,"",false,false,false,true)
- scan.waitTillDone()
- return scan.getOnlyResult()
- end
- --------------------------------------------------------------------------------
- --------------------------------------------------------------------------------
- -- And again make sure that you checked "Graphics > Advanced > Show Statistics".
- ----
- -- Enter here if you have 64bit Dolphin
- local DolphinIs64bit = false
- ----
- -- Here are Addresses that need to be changed either once, once at Dolphin start
- -- or once at game start. Since Addresses are written in hex, make sure you have
- -- the "0x" before the actual number.
- -----
- -- Follow this: http://tasvideos.org/forum/t/13462 tutorial to get a
- -- "pointerscan result". Doubleclick on the Address column and enter the address
- -- after the ' "Dolphin.exe"+ ' (don't forget the 0x).
- --
- -- Has to be adjusted: Once
- local GameRAMStartAddress = 0x045F80AC
- -----
- -----
- -- Choose "String" for Value Type and start a Scan searching "Textures created".
- -- There should be only one result, enter that address here.
- --
- -- Has to be adjusted: Once every game start
- local TexturesCreatedAddr = 0x1DAEF6DC
- -----
- -----
- -- Set the Value Type to "Array of byte" and uncheck "Writable" under Memory
- -- Scan Options. Make sure the "Hex" box is checked and search for
- --
- -- 48 63 D8 48 03 DF 48 83 7D C0 10
- -- if you have 64 bit Dolphin
- --
- -- 83 C4 0C 83 7C 24 1C 10 8D 3C 06
- -- if you have 32 bit Dolphin
- --
- -- There should be one result, rightclick that resuld and click "Disassemble
- -- this memory region". Enter the number after the "Dolphin.exe+" at the top.
- --
- -- Make sure to check "Writable" again, and really check it, because it has
- -- three states
- --
- -- Has to be adjusted: Once
- local ArrayOfBytesAddress = 0x3AFF0D
- -----
- -----
- -- "local FrameCounterAddress = nil" if you don't want it.
- -- Not necessary but it adds a neat Frame- and Movecounter to the screen.
- -- When playing or recording a movie scan for the VI-Count+1 (on the top of the
- -- game window) and setting the Value Type to 4 Bytes. The first one should be a
- -- green address, enter it here.
- --
- -- Has to be adjusted: Once every Dolphin start
- local FrameCounterAddress = 0x0476FDF0
- -----
- --------------------------------------------------------------------------------
- --------------------------------------------------------------------------------
- debug_removeBreakpoint(getAddress("Dolphin.exe")+ArrayOfBytesAddress)
- debug_setBreakpoint(getAddress("Dolphin.exe")+ArrayOfBytesAddress)
- function debugger_onBreakpoint()
- local mode=""
- if FrameCounterAddress then
- local curfc=readInteger(FrameCounterAddress)
- local fc=readInteger(FrameCounterAddress+0x08)
- local readonly=readBytes(FrameCounterAddress-((DolphinIs64bit and 0x30) or 0x28))
- mode=curfc.." [recording]"
- if readonly==2 then mode=curfc.."/"..fc.." [playback]"
- elseif readonly==0 then mode=curfc.."/"..fc.." [inactve]" end
- end
- local o=readInteger(getAddress("Dolphin.exe")+GameRAMStartAddress)
- -- local variable_name = readBytes(addressoffset+o,4,true)
- local xpos =readBytes(0x8C6504+o,4,true)
- local xposl=readBytes(0x8C6538+o,4,true)
- local ypos =readBytes(0x8C6508+o,4,true)
- local zpos =readBytes(0x8C650C+o,4,true)
- local zposl=readBytes(0x8C6558+o,4,true)
- local speed=readBytes(0xB079CC+o,4,true)
- local t = {0x0A,0x0A,0x0A,0x0A}
- --0x0A = new line
- t = appendstr(t,mode)
- t = appendstr(t,"")
- t = appendstr(t,"xpos: "..toflstr(xpos))
- t = appendstr(t,"xspeed: "..toflstr(xpos,xposl))
- t = appendstr(t,"ypos: "..toflstr(ypos))
- t = appendstr(t,"zpos: "..toflstr(zpos))
- t = appendstr(t,"zspeed: "..toflstr(zpos,zposl))
- t = appendstr(t,"speed: "..toflstr(speed))
- table.insert(t,0x00)
- --0x00 = end of text
- writeBytes(TexturesCreatedAddr,t)
- return 1
- end
- --print(string.format("0x%08X",scanstr("Textures created") or 0))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement