A Lua script written by CasualPokePlayer that creates a savestate after each point scored while replaying back a max score TAS such as this one. For encoding purposes, replace the code at line 62 with `client.pause()`.
memory.usememorydomain("68K RAM");
local function Cond1()
-- wait until intro has passed
return emu.framecount() >= 4800;
end
local function Cond2()
-- wait until the "target distance" is reached
return memory.read_u32_be(0x6FDC) == 0x9E340;
end
local function Cond3()
-- wait until input is accepted at the score tally screen
return memory.readbyte(0x7139) == 1;
end
local function Cond4()
-- wait until the black screen after the score tally screen
return emu.islagged();
end
local step_conds = { Cond1, Cond2, Cond3, Cond4 }
local step
local function set_step(new_step)
step = new_step;
userdata.set("step", step);
end
set_step(1);
event.onloadstate(function(state_name)
step = userdata.get("step");
if (math.type(step) ~= "integer") then
set_step(1);
elseif (step < 1 or step > 4) then
set_step(1);
end
end, "loadstate_hook");
event.onexit(function()
event.unregisterbyname("loadstate_hook");
event.unregisterbyname("exit_hook");
end, "exit_hook");
while true do
while true do
if (step_conds[step]()) then
if (step == 4) then
set_step(2);
break
else
set_step(step + 1);
end
end
emu.frameadvance();
end
savestate.save(string.format("Desert_Bus_%d.state", memory.readbyte(0x7137)));
end