You may know, but I find a detailed explanation about the RNG of this game.
http://www.gamespot.com/ds/action/castlevaniaorderofecclesia/show_msgs.php?topic_id=m-1-46105317&pid=945837&page=12
I wrote up the RNG in Lua.
-- Castlevania: Order of Ecclesia - RNG simulator
require("bit")
-- pure 32-bit multiplier
function mul32(a, b)
-- separate the value into two 8-bit values to prevent type casting
local x, y, z = {}, {}, {}
x[1] = bit.band(a, 0xff)
x[2] = bit.band(bit.rshift(a, 8), 0xff)
x[3] = bit.band(bit.rshift(a, 16), 0xff)
x[4] = bit.band(bit.rshift(a, 24), 0xff)
y[1] = bit.band(b, 0xff)
y[2] = bit.band(bit.rshift(b, 8), 0xff)
y[3] = bit.band(bit.rshift(b, 16), 0xff)
y[4] = bit.band(bit.rshift(b, 24), 0xff)
-- calculate for each bytes
local v, c
v = x[1] * y[1]
z[1], c = bit.band(v, 0xff), bit.rshift(v, 8)
v = c + x[2] * y[1] + x[1] * y[2]
z[2], c = bit.band(v, 0xff), bit.rshift(v, 8)
v = c + x[3] * y[1] + x[2] * y[2] + x[1] * y[3]
z[3], c = bit.band(v, 0xff), bit.rshift(v, 8)
v = c + x[4] * y[1] + x[3] * y[2] + x[2] * y[3] + x[1] * y[4]
z[4], c = bit.band(v, 0xff), bit.rshift(v, 8)
v = c + x[4] * y[2] + x[3] * y[3] + x[2] * y[4]
z[5], c = bit.band(v, 0xff), bit.rshift(v, 8)
v = c + x[4] * y[3] + x[3] * y[4]
z[6], c = bit.band(v, 0xff), bit.rshift(v, 8)
v = c + x[4] * y[4]
z[7], z[8] = bit.band(v, 0xff), bit.rshift(v, 8)
-- compose them and return it
return bit.bor(z[1], bit.lshift(z[2], 8), bit.lshift(z[3], 16), bit.lshift(z[4], 24)),
bit.bor(z[5], bit.lshift(z[6], 8), bit.lshift(z[7], 16), bit.lshift(z[8], 24))
end
--------------------------------------------------------------------------------
local OoE_RN = 0
function OoE_Rand()
OoE_RN = bit.tobit(mul32(bit.arshift(OoE_RN, 8), 0x3243f6ad) + 0x1b0cb175)
return OoE_RN
end
--------------------------------------------------------------------------------
-- RNG test code
OoE_RN = 0xf7bc2d8b
for i = 1, 64 do
io.write(string.format("%08X", OoE_Rand()))
if i % 8 == 0 then
io.write("\n")
else
io.write(" ")
end
end
More complicated version:
http://code.google.com/p/gocha-tas/source/browse/trunk/OrderOfEcclesia/LuaScripts/CVOoE_RNG.lua
I'm really looking forward to next WIP time, by the way ;)
Edit: I'm gathering experiences
http://www.youtube.com/watch?v=SjF-kEwJBKw