Luckily, DeSmuME has a
movie.play() function which automatically resets the emulator and runs the movie.
I made a quick script that you can adjust to fit your needs.
Things you might want to edit:
- the moviepath string at the top
- the getTime() function (currently only supports seconds, minutes and hours)
- the checkResult() function
- the frames to wait in the while true do loop (currently 7000)
- what to do when checkResult() returned true (currently prints the time)
Language: lua
local moviepath = "movie.dsm"
local function getTime(newtime)
local s = newtime%60
local m = math.floor(newtime/60)%60
local h = math.floor(newtime/3600)%24
return string.format("2009-JAN-01 %02d:%02d:%02d:000",h,m,s)
end
local function editFile(newtime)
local file = io.open(moviepath,"r")
local filestring = file:read("*a")
file:close()
filestring = filestring:gsub("(rtcStartNew )([^%c]+)","%1"..getTime(newtime))
file = io.open(moviepath,"w")
file:write(filestring)
file:close()
end
local function checkResult()
if memory.readbyte("0x02000000")==0xFF then
return true
end
return false
end
local newtime = 0
while true do
editFile(newtime)
movie.play(moviepath)
for i=1,7000 do -- frames to wait
emu.frameadvance()
end
if checkResult() then
print("it worked with "..getTime(newtime))
end
newtime=newtime+1
end