Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2014
1,796
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.35 KB | None | 0 0
  1. mdword=memory.readdwordunsigned
  2. rshift=bit.rshift
  3.  
  4. function next(s)
  5.     local a=0x41C6*(s%65536)+rshift(s,16)*0x4E6D
  6.     local b=0x4E6D*(s%65536)+(a%65536)*65536+0x6073
  7.     local c=b%4294967296
  8.     return c
  9. end
  10.  
  11. function refresh()
  12.     currseed = mdword(0x021BFB14)
  13.     seed = mdword(0x021BFB18)
  14.     initial = mdword(0x021BFB18)
  15.     frame = 1
  16. end
  17.  
  18. frame = 1
  19. seed = mdword(0x021BFB18)
  20. initial = mdword(0x021BFB18)
  21.  
  22. while true do
  23.     currseed = mdword(0x021BFB14)
  24.    
  25.     -- Detect initial seeding
  26.     if mdword(0x021BFB18) == currseed then
  27.         if currseed ~= 0x00000000 then
  28.             refresh()
  29.         end
  30.     end
  31.    
  32.     -- Reset variables on game reset
  33.     if seed == 0 then
  34.         frame = 1
  35.         refresh()
  36.     end
  37.    
  38.     -- IRNG Frame Counter
  39.     if mdword(0x02100834) >= 624 then
  40.         iframe = 0
  41.     else
  42.         iframe = mdword(0x02100834)
  43.     end
  44.    
  45.     -- Print variables in corner of bottom screen
  46.     gui.text(0,180,string.format("Initial Seed: %08X", seed))
  47.     gui.text(0,170,string.format("Current Seed: %08X", currseed))
  48.     gui.text(0,160,string.format("IRNG Frame: %d", iframe))
  49.    
  50.     -- PRNG Frame Counting
  51.     if currseed ~= initial then
  52.         if currseed ~= 0x00000000 then
  53.             while initial ~= currseed do
  54.                 initial = next(initial)
  55.                 frame = frame+1
  56.             end
  57.         end
  58.     end
  59.    
  60.     gui.text(0,150,string.format("PRNG Frame: %d", frame))
  61.     gui.text(0,140,string.format("Delay: %d", mdword(0x021BF6A8)+1))
  62.     emu.frameadvance()
  63. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement