有人问,我就贴一下
function nextrng(r1, r2, r3)
return AND(XOR(SHIFT(r3, 5), SHIFT(r2, -11), SHIFT(r1, -1), SHIFT(r2,15)),0xFFFF)
end
function rngsim(n)
local rngbase=0x03000000
local result = { memory.readword(rngbase+4), memory.readword(rngbase+2), memory.readword(rngbase+0) }
for i = 4, n do
result[i] = nextrng(result[i-3],result[i-2],result[i-1])
end
return result
end
local phit = 0x0203A550
local pdmg = 0x0203E1BE
local pcrt = 0x0203A556
local ehit = 0x0203A5D0
local edmg = 0x0203E1BC
local ecrt = 0x0203A5D6
no255 = function (addr)
local ret = memory.readbyte (addr)
if ret == 255 then
return ""
else
return ret
end
end
nolong = function (addr)
local ret = no255 (addr)
if ret == 100 then
return "100"
else
return " " .. ret
end
end
gui.register (function ()
local nsim = 20
local rngs = rngsim(nsim)
for i = 1, nsim do
gui.text(228, 8*(i-1), string.format("%3d", rngs[i]/655))
end
gui.text(224,0,"1:")
gui.text(224,8,"2:")
gui.text(224,16,"3:")
gui.text(224,24,"N:")
-- emu.frameadvance()
end)