SHARE
TWEET

Kirbys Adventure - Info.lua

a guest Jun 9th, 2013 303 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- lag counter by feos
  2. -- other stuff by Masterjun
  3.  
  4. local function text(a,b,c,d,e)
  5.   gui.text(a-1,b-1,c,"#000000","#00000000")
  6.   gui.text(a  ,b-1,c,"#000000","#00000000")
  7.   gui.text(a+1,b-1,c,"#000000","#00000000")
  8.   gui.text(a-1,b  ,c,"#000000","#00000000")
  9.   gui.text(a+1,b  ,c,"#000000","#00000000")
  10.   gui.text(a-1,b+1,c,"#000000","#00000000")
  11.   gui.text(a  ,b+1,c,"#000000","#00000000")
  12.   gui.text(a+1,b+1,c,"#000000","#00000000")
  13.  
  14.   gui.text(a,b,c,d,e or "#00000000")
  15. end
  16.  
  17. local function ASL(x)
  18.   local c=0
  19.   x = x*2
  20.   if x>=256 then c=1 x=x%256 end
  21.   return x,c
  22. end
  23.  
  24. local function LSR(x)
  25.   local c=0
  26.   x = x/2
  27.   if x%1~=0 then c=1 x=math.floor(x) end
  28.   return x,c
  29. end
  30.  
  31. local function ROL(x,c)
  32.   x = x*2
  33.   if c==1 then x=x+1 end
  34.   if x>=256 then c=1 x=x%256 else c=0 end
  35.   return x,c
  36. end
  37. local function ROR(x,c)
  38.   x = x/2
  39.   if c==1 then x=x+128 end
  40.   if x%1~=0 then c=1 else c=0 end
  41.   return x,c
  42. end
  43.  
  44. local function nRNG(rng1,rng2)
  45.   local a = rng1
  46.   local c = 0
  47.   for x=0x01,0x0B do
  48.     rng1,c = ASL(rng1)
  49.     rng2,c = ROL(rng2,c)
  50.     a,c = ROL(a,c)
  51.     a,c = ROL(a,c)
  52.     a = XOR(a,rng1)
  53.     a,c = ROL(a,c)
  54.     a = XOR(a,rng1)
  55.     a,c = LSR(a)
  56.     a,c = LSR(a)
  57.     a = XOR(a,0xFF)
  58.     a = AND(a,0x01)
  59.     a = OR(a,rng1)
  60.     rng1 = a
  61.   end
  62.   return rng1,rng2
  63. end
  64.  
  65. local function action(st,rng)
  66.   local a=AND(st,rng,1)+memory.readbyte(0xC6DD+st)+memory.readbyte(0xC6DD+rng)
  67.   local x=memory.readbyte(0xC7DD+st)+memory.readbyte(0xC7DD+rng)-memory.readbyte(0xC7DD+math.abs(st-rng))
  68.   if memory.readbyte(0xC6DD+math.abs(st-rng))>a then x=x-1 end
  69.   return x
  70. end
  71.  
  72. local function main()
  73.   local xgui = 9
  74.   local ygui = 160
  75.  
  76.   local xcam = memory.readbyte(0x00DD)+memory.readbytesigned(0x00DE)*256
  77.  
  78.         local xspeed = memory.readbyte(0x05B9)+memory.readbytesigned(0x05BA)*256
  79.         local yspeed = memory.readbyte(0x05BD)+memory.readbytesigned(0x05BE)*256
  80.         local xpos = memory.readbyte(0x0083)+memory.readbytesigned(0x0095)*256
  81.   local xsubpos = memory.readbyte(0x0071)
  82.         local ypos = memory.readbyte(0x00B9)+memory.readbytesigned(0x00CB)*256
  83.   local ysubpos = memory.readbyte(0x00A7)
  84.  
  85.   text(xgui,ygui,string.format("%d.%02X",xpos,xsubpos))
  86.   text(xgui+48,ygui,string.format("%d.%02X",ypos,ysubpos))
  87.   text(xgui,ygui+8,string.format("%+d",xspeed))
  88.   text(xgui+48,ygui+8,string.format("%+d",yspeed))
  89.  
  90.   -- for i=0x00,0xFF do
  91.     -- text(memory.readbyte(i),memory.readbyte(i+3),".")
  92.   -- end
  93.  
  94.   -- text(memory.readbyte(0x90),memory.readbyte(0xC6),"!")
  95.  
  96.   -- text(48,48,string.format("%02X %02X",nRNG(0xF3,0x24)))
  97.   -- text(48,56,string.format("%X",ROR(0xFF)))
  98.  
  99.   local rng1 = memory.readbyte(0x003E)
  100.   local rng2 = memory.readbyte(0x003F)
  101.   -- text(48,64,action(0x04,nRNG(rng1,rng2)))
  102.   text(9,12,string.format("%02X %02X",rng1,rng2))
  103.  
  104.   for i=0,15 do
  105.     rng1,rng2=nRNG(rng1,rng2)
  106.     --text(9,24+i*8,string.format("%02X %02X %d %d",rng1,rng2,action(0x04,rng1,rng2),AND(rng1,7)))
  107.     text(9,24+i*8,string.format("%02X %02X %d",rng1,rng2,action(0x04,rng1,rng2)))
  108.   end
  109. end
  110.  
  111. local lagged = false
  112.  
  113. local function DetectLag()
  114.         local LagFlag = memory.readbyte(0x01a5)
  115.         if LagFlag == 1 then lagged = true
  116.         else lagged = false
  117.         end
  118. end
  119.  
  120. local function SetLag()
  121.         if lagged then emu.setlagflag(true)
  122.         else emu.setlagflag(false)
  123.         end
  124. end
  125.  
  126. memory.registerexecute(0xC373, DetectLag)
  127. memory.registerexecute(0xC323, SetLag)
  128. gui.register(main)
  129.  
  130. -- memory.registerexecute(0xD8A5, function()
  131.   -- print(memory.readbyte(0x0083)+memory.readbytesigned(0x0095)*256+memory.readbyte(0x0071)/256)
  132. -- end)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top