Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- lag counter by feos
- -- other stuff by Masterjun
- local function text(a,b,c,d,e)
- gui.text(a-1,b-1,c,"#000000","#00000000")
- gui.text(a ,b-1,c,"#000000","#00000000")
- gui.text(a+1,b-1,c,"#000000","#00000000")
- gui.text(a-1,b ,c,"#000000","#00000000")
- gui.text(a+1,b ,c,"#000000","#00000000")
- gui.text(a-1,b+1,c,"#000000","#00000000")
- gui.text(a ,b+1,c,"#000000","#00000000")
- gui.text(a+1,b+1,c,"#000000","#00000000")
- gui.text(a,b,c,d,e or "#00000000")
- end
- local function ASL(x)
- local c=0
- x = x*2
- if x>=256 then c=1 x=x%256 end
- return x,c
- end
- local function LSR(x)
- local c=0
- x = x/2
- if x%1~=0 then c=1 x=math.floor(x) end
- return x,c
- end
- local function ROL(x,c)
- x = x*2
- if c==1 then x=x+1 end
- if x>=256 then c=1 x=x%256 else c=0 end
- return x,c
- end
- local function ROR(x,c)
- x = x/2
- if c==1 then x=x+128 end
- if x%1~=0 then c=1 else c=0 end
- return x,c
- end
- local function nRNG(rng1,rng2)
- local a = rng1
- local c = 0
- for x=0x01,0x0B do
- rng1,c = ASL(rng1)
- rng2,c = ROL(rng2,c)
- a,c = ROL(a,c)
- a,c = ROL(a,c)
- a = XOR(a,rng1)
- a,c = ROL(a,c)
- a = XOR(a,rng1)
- a,c = LSR(a)
- a,c = LSR(a)
- a = XOR(a,0xFF)
- a = AND(a,0x01)
- a = OR(a,rng1)
- rng1 = a
- end
- return rng1,rng2
- end
- local function action(st,rng)
- local a=AND(st,rng,1)+memory.readbyte(0xC6DD+st)+memory.readbyte(0xC6DD+rng)
- local x=memory.readbyte(0xC7DD+st)+memory.readbyte(0xC7DD+rng)-memory.readbyte(0xC7DD+math.abs(st-rng))
- if memory.readbyte(0xC6DD+math.abs(st-rng))>a then x=x-1 end
- return x
- end
- local function main()
- local xgui = 9
- local ygui = 160
- local xcam = memory.readbyte(0x00DD)+memory.readbytesigned(0x00DE)*256
- local xspeed = memory.readbyte(0x05B9)+memory.readbytesigned(0x05BA)*256
- local yspeed = memory.readbyte(0x05BD)+memory.readbytesigned(0x05BE)*256
- local xpos = memory.readbyte(0x0083)+memory.readbytesigned(0x0095)*256
- local xsubpos = memory.readbyte(0x0071)
- local ypos = memory.readbyte(0x00B9)+memory.readbytesigned(0x00CB)*256
- local ysubpos = memory.readbyte(0x00A7)
- text(xgui,ygui,string.format("%d.%02X",xpos,xsubpos))
- text(xgui+48,ygui,string.format("%d.%02X",ypos,ysubpos))
- text(xgui,ygui+8,string.format("%+d",xspeed))
- text(xgui+48,ygui+8,string.format("%+d",yspeed))
- -- for i=0x00,0xFF do
- -- text(memory.readbyte(i),memory.readbyte(i+3),".")
- -- end
- -- text(memory.readbyte(0x90),memory.readbyte(0xC6),"!")
- -- text(48,48,string.format("%02X %02X",nRNG(0xF3,0x24)))
- -- text(48,56,string.format("%X",ROR(0xFF)))
- local rng1 = memory.readbyte(0x003E)
- local rng2 = memory.readbyte(0x003F)
- -- text(48,64,action(0x04,nRNG(rng1,rng2)))
- text(9,12,string.format("%02X %02X",rng1,rng2))
- for i=0,15 do
- rng1,rng2=nRNG(rng1,rng2)
- --text(9,24+i*8,string.format("%02X %02X %d %d",rng1,rng2,action(0x04,rng1,rng2),AND(rng1,7)))
- text(9,24+i*8,string.format("%02X %02X %d",rng1,rng2,action(0x04,rng1,rng2)))
- end
- end
- local lagged = false
- local function DetectLag()
- local LagFlag = memory.readbyte(0x01a5)
- if LagFlag == 1 then lagged = true
- else lagged = false
- end
- end
- local function SetLag()
- if lagged then emu.setlagflag(true)
- else emu.setlagflag(false)
- end
- end
- memory.registerexecute(0xC373, DetectLag)
- memory.registerexecute(0xC323, SetLag)
- gui.register(main)
- -- memory.registerexecute(0xD8A5, function()
- -- print(memory.readbyte(0x0083)+memory.readbytesigned(0x0095)*256+memory.readbyte(0x0071)/256)
- -- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement