Print("".string.format("C-Gear turned on. Double Check.")) print("".string.format("If C-Gear was just turned on this frame, ignore.")) print("".string.format("")) wasrestored=0 end If wasrestored=1 then print("".string.format("Earlier restoration may have failed. print(strmtv,strnmt,string.format("%08X",lastm)) - debug for bad initialize If strmtv~=strnmt then - New untempered table value isn't as predicted, so the c-gear was turned on! Strnmt=string.format("%08X",nextmt) - Convert to a string hex so that they can be equated when their decimal isn't Strmtv=string.format("%08X",mtv) - Mersenne Twister untempered is in one format while the memory is in another ![]() If (lmtp>mtp and delay > 50 and notrestored=0) or (lmtp=mtp and lastm~=mtv) then Check to see if the MTRNG changed, only if tracking is enabled. If adv > 0 then - Refresh Frame Advancement Table if there's more than one advancement this frame.īreak - last frame's advanced RNG value matches the current. Print("".string.format("")) - Visual Line to separate.Įlseif test~=seed1 then - RNG advanced at least once. If inith>0x7FFFFFFF then wdword(storage+0x4*4,inith-0x100000000) else wdword(storage+0x4*4,inith) end Print("".string.format("Foreign Save State Detected, or Restart didn't refresh. Print("".string.format("Initial Seeding Detected. see if initial seeding happened (high32=mtseed) print("".string.format("Next: %08X", nextmt)) - debug Print("".string.format("Session Initial Seed: %08X%08X",inith,initl)) Nextmt=random_int32() - get first untempered mersenne value, this is the value that will replace the MTRNG seed in the memory when the table is redone If initm>0x7FFFFFFF then wdword(storage+0x4*2,initm-0x100000000) else wdword(storage+0x4*2,initm) end If initl>0x7FFFFFFF then wdword(storage+0x4*3,initl-0x100000000) else wdword(storage+0x4*3,initl) end If inith>0x7FFFFFFF then wdword(storage+0x4*4,inith-0x100000000) else wdword(storage+0x4*4,inith) end - dumb storage problems, have to make sure they are recognized as the right number type before storage Print("".string.format("MTRNG: %08X", initm))Ĭgearoff=mdword(storage+0x4*8) - remember if c-gear was turned on or not Print("".string.format("Either load a valid save state or resume with this one.")) Print("".string.format("Save state's session did not start with script.")) Inith=mdword(storage+0x4*4) - restore PRNG Steptable=mdword(storage+0x4*1) - restore mt Print("".string.format("Restoring session. If mdword(storage)=1 and delay>3 and mdword(storage+0x4*2)~=0 then If adv>200 then - RNG advanced a bunch, or the game/script was reset. Mt = bit.bxor(mt, bit.rshift(y, 1), mag01) Y = bit.bor(bit.band(mt, UPPER_MASK), bit.band(mt, LOWER_MASK)) Mt19937.randomseed(5489) - a default initial seed is used If (mti = N + 1) then - if init_genrand() has not been called, assumes i 0 and s_lim = N) then - generate N words at one time Local mti = N + 1 - mti=N+1 means mt is not initialized Local mt = - the array for the state vector Local LOWER_MASK = 0x7fffffff - least significant r bits Local UPPER_MASK = 0x80000000 - most significant w-r bits Local MATRIX_A = 0x9908b0df - constant vector a ported to Lua by gocha, based on mt19937ar.c Mersenne Twister: A random number generator To predict Mersenne advancement, it's a little harder. The lower seed is advanced as follows, if observed as a standalone 32 bit number: Lua sucks and only allows 16 bit multiplication, so 32 bit multiplication can't be used ![]() S frame detection function works off of seeing how many times the lower half was advanced Setup initial variables, rest of script detection will take care of them Local rshift, lshift=bit.rshift, bit.lshift ![]() Local bnd,br,bxr=bit.band,bit.bor,bit.bxor Setup Terminology abbreviations from FractalFusion Local research=0 - 0 on, 1 off only enable for dev features (unneeded) Local trackcgear=0 - 0 on, 1 off disable for Standard Abuse, enable for Entralink Abuse Local pos_m=0x0224F92C-0x20*game - Map Position -> XYZ Local mac=0x123456 - MAC Address of Emulator Local mtrng=0x021FED68-0x20*game - Mersenne Twister Table Top Local rng=0x021FFC58-0x20*game - PRNG Seed Location General Parameters for current game and setup (english)
0 Comments
Leave a Reply. |