Displays the index number for RNGa and RNGb. Reverse lookup for RNGa and 139*value mod 256 for RNGb.
Might need to raise "max_number" value if not enough RNGa values.
console.clear()
local cur_rng=0x3E2AD2
local max_number=100000
local reverse_table={}
local function nextrng(rng,n)
for i=1,n do
local bool1= ((rng%0x400000)>=0x200000)
local bool2= ((rng%0x200000)>=0x100000)
if bool1~=bool2 then
nextbit=1
else
nextbit=0
end
rng=2*rng+nextbit
rng=rng%0x1000000
end
return rng
end
for i=1,max_number do
cur_rng=nextrng(cur_rng,1)
reverse_table[cur_rng]=i
end
console.write("Done")
while true do
local b=mainmemory.read_u24_be(0x37)
local c=mainmemory.read_u8(0x302)
if reverse_table[b] then
gui.text(10,50,"RNG Index = ".. reverse_table[b])
else
gui.text(10,50,"RNG Index = Unknown")
end
gui.text(10,65,"RNG2 Index = ".. (139*c)%256)
emu.frameadvance()
end