Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --unsafe state loader, but will refresh the screen faster
- function stateLoader(checkPointToLoad, isDesyncFix)
- if(checkPointToLoad ~= nil) then
- newCheckPoint = savestate.create(3)
- savestate.save(newCheckPoint)
- linda:set("finish", "start")
- linda:set("screenValue", "start")
- lanes.gen("*",prepareScreen)(print, emu, gui, stringHash)
- redrawCheckpoint(checkPointToLoad, isDesyncFix);
- emu.pause(); --pausing while kkapture still capture, might create some duplicate...
- screenVal = "start"
- while screenVal == "start" do
- screenVal=linda:receive(2.0, "screenValue")
- end
- lastCheckPointScreenshotValue = screenVal;
- lastCheckPoint = emu.framecount();
- redrawCheckpoint(checkPointToLoad, isDesyncFix);
- --print("Loading checkpoint #" .. checkPointToLoad)
- print("Loading checkpoint #" .. emu.framecount())
- end
- end
- function prepareScreen(print, emu, gui, stringHash)
- for i=1,100 do
- linda:send( "x", i ) -- TODO some busy wait loop... might help for waiting time. Should be a better way to wait..
- end
- co2 = coroutine.create(
- function (x)
- emu.unpause();
- coroutine.yield()
- end
- )
- screenValue=stringHash(gui.gdscreenshot());
- linda:send( "screenValue", screenValue )
- coroutine.resume(co2)
- end
- local function waitingThread(maxWait, checkPointToLoad, print, emu, gui, saveStateFolder, saveStateName,movieSaveStateFolder,movieName, savestate, isDesyncFix, separateThreadLoadState, gen)
- for i=1,maxWait do
- linda:send( "x", i ) -- looping as a way to wait for the other thread to end...
- end
- gen("*",separateThreadLoadState)(checkPointToLoad, print, emu, gui, saveStateFolder, saveStateName,movieSaveStateFolder,movieName, savestate, isDesyncFix)
- finish = "start"
- linda:set( "finish", "start" )
- while finish =="start" do
- finish=linda:receive(2.0, "finish")
- end
- end
- function separateThreadLoadState(checkPointToLoad, print, emu, gui, saveStateFolder, saveStateName, movieSaveStateFolder, movieName, savestate, isDesyncFix)
- newCheckPoint = nil;
- if(checkPointToLoad == "current") then
- newCheckPoint = savestate.create(3)
- savestate.save(newCheckPoint)
- else
- newCheckPoint = savestate.create(1)
- pathSaveState = (isDesyncFix==true and (desyncSaveStateFolder .. "/" .. desyncSaveStateName)
- or (saveStateFolder .. "/" .. saveStateName))
- saveStateFile = io.open(pathSaveState .. "-" .. checkPointToLoad, "rb")
- save = saveStateFile:read("*all")
- loadStateFile = io.open (movieSaveStateFolder .. "/" .. movieName .. ".000", "wb")
- loadStateFile:write(save)
- io.close(loadStateFile)
- end
- savestate.load(newCheckPoint)
- savestate.save(newCheckPoint) --save at slot1
- savestate.load(newCheckPoint)
- linda:send( "finish", "end" )
- end
- function redrawCheckpoint(checkPointToLoad, isDesyncFix)
- --TODO: use some table instead of using so many params
- lanes.gen("*",waitingThread)(100,checkPointToLoad,print,emu,gui,saveStateFolder,saveStateName,movieSaveStateFolder,movieName,savestate,isDesyncFix,separateThreadLoadState,lanes.gen)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement