Option: Script keys instantly affect input table, rather than wait for frameadvance. Also, more robust unpaused rewind antics.
This commit is contained in:
parent
a80264a595
commit
9f23ee011f
|
@ -17,11 +17,15 @@ local dispX, dispY= 10, 99 -- For the display stuffs
|
||||||
|
|
||||||
local Past, Future= -10, 10 -- Keep Past negative; Range of display stuffs
|
local Past, Future= -10, 10 -- Keep Past negative; Range of display stuffs
|
||||||
|
|
||||||
|
local immediate= false -- true: Changes apply to list upon happening
|
||||||
|
-- false: Changes only apply on frame advance
|
||||||
|
|
||||||
-- Control scheme. You may want to change these.
|
-- Control scheme. You may want to change these.
|
||||||
local selectplayer = "S" -- For selecting which player
|
local selectplayer = "S" -- For selecting which player
|
||||||
local recordingtype= "space" -- For selecting how to record
|
local recordingtype= "space" -- For selecting how to record
|
||||||
|
local SetImmediate = "numpad5"--Toggle immediate option
|
||||||
|
|
||||||
local show, hide = "pageup", "pagedown" -- Opacity adjuster
|
local show, hide = "pageup", "pagedown" -- Opacity adjuster
|
||||||
local scrlup, scrldown = "numpad8", "numpad2" -- Move the input display
|
local scrlup, scrldown = "numpad8", "numpad2" -- Move the input display
|
||||||
local scrlleft, scrlright= "numpad4", "numpad6" -- Not a fast method, though.
|
local scrlleft, scrlright= "numpad4", "numpad6" -- Not a fast method, though.
|
||||||
local MorePast, LessPast = "numpad7", "numpad1" -- See more or less input!
|
local MorePast, LessPast = "numpad7", "numpad1" -- See more or less input!
|
||||||
|
@ -50,7 +54,6 @@ local repeater= 0 -- for holding a button
|
||||||
local rewinding= false -- For unpaused rewinding
|
local rewinding= false -- For unpaused rewinding
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--The stuff below is adapted from the original Rewinding script by Antony Lavelle
|
--The stuff below is adapted from the original Rewinding script by Antony Lavelle
|
||||||
|
|
||||||
local saveArray = {};--the Array in which the save states are stored
|
local saveArray = {};--the Array in which the save states are stored
|
||||||
|
@ -87,8 +90,8 @@ function press(button)
|
||||||
|
|
||||||
if keys[button] and not lastkeys[button] then
|
if keys[button] and not lastkeys[button] then
|
||||||
return true
|
return true
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -145,18 +148,17 @@ end -- Yes, a stateload on the same frame
|
||||||
function RewindThis()
|
function RewindThis()
|
||||||
--*****************************************************************************
|
--*****************************************************************************
|
||||||
--Added by DarkKobold; Made into function that returns T/F by FatRatKnight
|
--Added by DarkKobold; Made into function that returns T/F by FatRatKnight
|
||||||
-- Original Rewinder by Antony Lavelle. Seems quite useful here!
|
|
||||||
-- Loads a state that was saved just the frame prior
|
-- Loads a state that was saved just the frame prior
|
||||||
-- Lets you know whether it was successful by returning true or false.
|
-- Lets you know whether it was successful by returning true or false.
|
||||||
-- Accesses: rewindCount, saveArray, saveCount, saveMax
|
-- Accesses: rewindCount, saveArray, saveCount, saveMax
|
||||||
|
|
||||||
if rewindCount==0 then
|
if rewindCount<=0 then
|
||||||
return false -- Failed to rewind
|
return false -- Failed to rewind
|
||||||
else
|
else
|
||||||
savestate.load(saveArray[saveCount]);
|
savestate.load(saveArray[saveCount]);
|
||||||
saveCount = saveCount-1;
|
saveCount = saveCount-1;
|
||||||
rewindCount = rewindCount-1;
|
rewindCount = rewindCount-1;
|
||||||
if saveCount==0 then
|
if saveCount<=0 then
|
||||||
saveCount = saveMax;
|
saveCount = saveMax;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
@ -320,10 +322,23 @@ dispY= math.min(math.max(dispY,11-4*Past),225-4*Future)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local color= "white" -- immediate == true
|
||||||
|
if not immediate then
|
||||||
|
color= "blue"
|
||||||
|
for P= plmin, plmax do
|
||||||
|
local TestInput= GetNextInput(P)
|
||||||
|
for i=1, 8 do
|
||||||
|
if not TestInput or TestInput[btn[i]] ~= thisInput[P][btn[i]] then
|
||||||
|
color= "green"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
if pl <= players then
|
if pl <= players then
|
||||||
gui.drawbox(dispX+2,dispY-2,dispX+36,dispY+4,"blue")
|
gui.drawbox(dispX+2,dispY-2,dispX+36,dispY+4,color)
|
||||||
else
|
else
|
||||||
gui.drawbox(dispX+2,dispY-2,dispX+12 +16*players,dispY+4,"blue")
|
gui.drawbox(dispX+2,dispY-2,dispX+12 +16*players,dispY+4,color)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -344,8 +359,8 @@ function itisyourturn()
|
||||||
fc= movie.framecount() -- Definite change here!
|
fc= movie.framecount() -- Definite change here!
|
||||||
framed= "stateload" -- Don't even bother with NewFrame()...
|
framed= "stateload" -- Don't even bother with NewFrame()...
|
||||||
movie.rerecordcounting(true)
|
movie.rerecordcounting(true)
|
||||||
else
|
end
|
||||||
keys[rewind]= nil
|
if rewindCount <= 0 then
|
||||||
FCEU.pause()
|
FCEU.pause()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -356,16 +371,16 @@ function itisyourturn()
|
||||||
pl= pl + 1 -- self-explanatory.
|
pl= pl + 1 -- self-explanatory.
|
||||||
if (pl > players+1) or (players == 1) then
|
if (pl > players+1) or (players == 1) then
|
||||||
pl= 1 -- If not, it... Selects a player...
|
pl= 1 -- If not, it... Selects a player...
|
||||||
end -- Joy.
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- For standard player loops for allplayer option
|
-- For standard player loops for allplayer option
|
||||||
if pl > players then
|
if pl > players then
|
||||||
plmin= 1 -- Go from 1 to last player
|
plmin= 1
|
||||||
plmax= players -- The all players option
|
plmax= players
|
||||||
else
|
else
|
||||||
plmin= pl -- Go from selected player to itself
|
plmin= pl
|
||||||
plmax= pl -- The one player option
|
plmax= pl
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
@ -373,8 +388,10 @@ function itisyourturn()
|
||||||
if press(add) then -- Part of the reason for
|
if press(add) then -- Part of the reason for
|
||||||
for P= plmin, plmax do -- speedy insertions and
|
for P= plmin, plmax do -- speedy insertions and
|
||||||
BufLen[P]= BufLen[P]+1 -- deletions is due to the
|
BufLen[P]= BufLen[P]+1 -- deletions is due to the
|
||||||
BufInput[P][BufLen[P]]= {} -- fact that I don't shift
|
if BufLen[P] > 0 then -- fact that I don't shift
|
||||||
LoadStoredInput(P) -- frames upon add/remove.
|
BufInput[P][BufLen[P]]= {} -- frames immediately.
|
||||||
|
end
|
||||||
|
LoadStoredInput(P)
|
||||||
end
|
end
|
||||||
end -- I only shift once you
|
end -- I only shift once you
|
||||||
if press(remove) then -- begin rewind or load a
|
if press(remove) then -- begin rewind or load a
|
||||||
|
@ -384,6 +401,15 @@ function itisyourturn()
|
||||||
end -- to shift around.
|
end -- to shift around.
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Input: Should thisInput always instantly write to input table?
|
||||||
|
if press(SetImmediate) then
|
||||||
|
if not immediate then
|
||||||
|
immediate= true
|
||||||
|
else
|
||||||
|
immediate= false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- Option: Opacity
|
-- Option: Opacity
|
||||||
if press(hide) and opaque < 4 then
|
if press(hide) and opaque < 4 then
|
||||||
opaque= opaque+1
|
opaque= opaque+1
|
||||||
|
@ -529,6 +555,25 @@ function itisyourturn()
|
||||||
end
|
end
|
||||||
end -- Done with "options" if
|
end -- Done with "options" if
|
||||||
|
|
||||||
|
-- Force copy of thisInput into the input table if immediate is on
|
||||||
|
if immediate then
|
||||||
|
for P= 1, players do
|
||||||
|
if not GetNextInput(P) then
|
||||||
|
Pin[P][fc-BufLen[P]]= {}
|
||||||
|
end -- Inserted frames always defined! Don't check for that
|
||||||
|
|
||||||
|
if BufLen[P] > 0 then
|
||||||
|
for i= 1, 8 do
|
||||||
|
BufInput[P][BufLen[P]][btn[i]]= thisInput[P][btn[i]]
|
||||||
|
end
|
||||||
|
else
|
||||||
|
for i= 1, 8 do
|
||||||
|
Pin[P][fc-BufLen[P]][btn[i]]= thisInput[P][btn[i]]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- Display selected player. Or other odds and ends.
|
-- Display selected player. Or other odds and ends.
|
||||||
if pl <= players then
|
if pl <= players then
|
||||||
gui.text(30,10,pl)
|
gui.text(30,10,pl)
|
||||||
|
@ -561,10 +606,12 @@ while true do -- Main loop
|
||||||
-- Most of the stuff here by DarkKobold. Minor stuff by FatRatKnight
|
-- Most of the stuff here by DarkKobold. Minor stuff by FatRatKnight
|
||||||
-- Rewinding feature originally by Antony Lavelle.
|
-- Rewinding feature originally by Antony Lavelle.
|
||||||
-- Keep in mind stuff here only happens on a frame advance or when unpaused.
|
-- Keep in mind stuff here only happens on a frame advance or when unpaused.
|
||||||
|
|
||||||
|
FrameAdvance= true -- For the NewFrame function
|
||||||
FCEU.frameadvance()
|
FCEU.frameadvance()
|
||||||
|
|
||||||
if saveMax > 0 then -- Don't process if Rewind is disabled
|
if saveMax > 0 then -- Don't process if Rewind is disabled
|
||||||
if keys[rewind] then
|
if keys[rewind] and rewindCount > 0 then
|
||||||
rewinding= true
|
rewinding= true
|
||||||
else
|
else
|
||||||
saveCount=saveCount+1;
|
saveCount=saveCount+1;
|
||||||
|
@ -584,8 +631,7 @@ while true do -- Main loop
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
FrameAdvance= true -- For the NewFrame function
|
end -- Main loop ends
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
-- Possible inconveniences include:
|
-- Possible inconveniences include:
|
||||||
|
|
Loading…
Reference in New Issue