Sort of different, but same concept. Here is the one I used for shining soul to dump all the possible RNG values to a file.
Language: lua
Max = 32767
--Read in the next bunch of RNG addresses
RNG1 = 0x03001438;
RNG2 = 0x0300143A;
RNG3 = 0x0300143C;
RNG4 = 0x0300143E;
RNGFile = io.open('SS2RNG.txt','w');
repeater = false
Ra1 = memory.readword(RNG1);
Ra2 = memory.readword(RNG2);
Ra3 = memory.readword(RNG3);
Ra4 = memory.readword(RNG4);
s = 0;
vba.frameadvance();
while not repeater do
s = s+1;
R1 = memory.readword(RNG1);
R2 = memory.readword(RNG2);
R3 = memory.readword(RNG3);
R4 = memory.readword(RNG4);
outs = string.format('%d %d %d %d\n',R1,R2,R3,R4);
RNGFile:write(outs);
vba.frameadvance();
if (R1 == Ra1) and (R2 == Ra2) and (R3 == Ra3) and (R4 == Ra4) then
repeater = true;
end;
end;
print('done');
print(s);
RNGFile:close();
And then, to play them back, and tell me my position in the loop
Language: lua
Max = 100000;
--Track RNG Movement
RNG1 = 0x03001D28;
RNG2 = 0x03001D2A;
RNG3 = 0x03001D2C;
RNG4 = 0x03001D2E;
RNGFile = io.open('SS2RNG.txt','r');
RL1 = {};
RL2 = {};
RL3 = {};
RL4 = {};
F = 0;
Exe = 0;
for i = 1,Max,1 do
RL1[i] = RNGFile:read("*n");
RL2[i] = RNGFile:read("*n");
RL3[i] = RNGFile:read("*n");
RL4[i] = RNGFile:read("*n");
end;
curpos = 1;
while (curpos ~= Max) and not found do
if (memory.readword(RNG1) == RL1[curpos]) and (memory.readword(RNG2) == RL2[curpos]) and (memory.readword(RNG3) == RL3[curpos]) and (memory.readword(RNG4) == RL4[curpos]) then
found = true;
else
curpos = curpos + 1;
end;
end;
Bad = false;
while not Bad do
found = false;
state = curpos;
cnt = 0;
curpos = curpos - 100;
while (cnt ~= 2) and not found do
cnt = cnt + 1;
if cnt == 2 then curpos = 1; end;
while (curpos ~= Max) and not found do
if (memory.readword(RNG1) == RL1[curpos]) and (memory.readword(RNG2) == RL2[curpos]) and (memory.readword(RNG3) == RL3[curpos]) and (memory.readword(RNG4) == RL4[curpos]) then
found = true;
else
curpos = curpos + 1;
end;
end;
end;
if not found then
Bad = true;
else
F = F + 1;
Exe = (curpos-state) + Exe;
gui.text(1,1,string.format('Exec = %d Pos = %d Avg = %f1.3',curpos-state, curpos, Exe/F));
end;
vba.frameadvance();
end;
print('RNG not found, script exiting.');
print(string.format('Expected: %d %d %d %d', RL1[state+1],RL2[state+1],RL3[state+1],RL4[state+1]));
print(string.format('Got: %d %d %d %d', memory.readword(RNG1), memory.readword(RNG2),memory.readword(RNG3),memory.readword(RNG4)));
RNGFile:close();