Movie - clean up some code that has gotten crusty in the frame loop and refactored it, fixed logical errors at the end of a movie regarding playback, rewind, and loadstate. Movies now go correctly into finished or play mode under various circumstances. Removed the stop on frame code because it was breaking things, this will be a regression in functionality in tastudio until it is rethought.

This commit is contained in:
adelikat 2012-08-25 23:31:54 +00:00
parent 7a9e5d856b
commit 7ad3ea9ef5
3 changed files with 76 additions and 61 deletions

View File

@ -130,7 +130,6 @@ namespace BizHawk.MultiClient
if (ReadOnly)
{
if (!Global.MovieSession.Movie.CheckTimeLines(path, false))
{
return false; //Timeline/GUID error
@ -223,5 +222,74 @@ namespace BizHawk.MultiClient
Global.MovieSession.Movie.DumpLogIntoSavestateText(writer);
}
}
private void HandleMovieOnFrameLoop()
{
switch (Global.MovieSession.Movie.Mode)
{
case MOVIEMODE.RECORD:
Global.MovieSession.Movie.CaptureState();
if (Global.MovieSession.MultiTrack.IsActive)
{
Global.MovieSession.LatchMultitrackPlayerInput(Global.MovieInputSourceAdapter, Global.MultitrackRewiringControllerAdapter);
}
else
{
Global.MovieSession.LatchInputFromPlayer(Global.MovieInputSourceAdapter);
}
//the movie session makes sure that the correct input has been read and merged to its MovieControllerAdapter;
//this has been wired to Global.MovieOutputHardpoint in RewireInputChain
Global.MovieSession.Movie.CommitFrame(Global.Emulator.Frame, Global.MovieOutputHardpoint);
break;
case MOVIEMODE.PLAY:
int x = Global.MovieSession.Movie.LogLength();
if (Global.Emulator.Frame >= Global.MovieSession.Movie.LogLength())
{
Global.MovieSession.Movie.SetMovieFinished();
}
else
{
Global.MovieSession.Movie.CaptureState();
Global.MovieSession.LatchInputFromLog();
}
x++;
break;
case MOVIEMODE.FINISHED:
int xx = Global.MovieSession.Movie.LogLength();
if (Global.Emulator.Frame < Global.MovieSession.Movie.LogLength()) //This scenario can happen from rewinding (suddenly we are back in the movie, so hook back up to the movie
{
Global.MovieSession.Movie.StartPlayback();
Global.MovieSession.LatchInputFromLog();
}
else
{
Global.MovieSession.LatchInputFromPlayer(Global.MovieInputSourceAdapter);
}
xx++;
break;
case MOVIEMODE.INACTIVE:
Global.MovieSession.LatchInputFromPlayer(Global.MovieInputSourceAdapter);
break;
}
//adelikat; Scheduled for deletion: RestoreReadWriteOnStop, should just be a type of movie finished, we need a menu item for what to do when a movie finishes (closes, resumes recording, goes into finished mode)
//if (StopOnFrame != -1 && StopOnFrame == Global.Emulator.Frame + 1)
//{
// if (StopOnFrame == Global.MovieSession.Movie.LogLength())
// {
// Global.MovieSession.Movie.SetMovieFinished();
// }
// if (Global.MovieSession.Movie.TastudioOn == true)
// {
// PauseEmulator();
// StopOnFrame = -1;
// }
// if (RestoreReadWriteOnStop == true)
// {
// Global.MovieSession.Movie.Mode = MOVIEMODE.RECORD;
// RestoreReadWriteOnStop = false;
// }
//}
}
}
}

View File

@ -1916,66 +1916,7 @@ namespace BizHawk.MultiClient
else if (!Global.Config.MuteFrameAdvance)
genSound = true;
if (Global.MovieSession.Movie.Mode == MOVIEMODE.RECORD || Global.MovieSession.Movie.Mode == MOVIEMODE.PLAY)
{
Global.MovieSession.Movie.CaptureState();
Global.MovieSession.LatchInputFromLog();
if (Global.MovieSession.Movie.Mode == MOVIEMODE.RECORD)
{
if (Global.MovieSession.MultiTrack.IsActive)
{
Global.MovieSession.LatchMultitrackPlayerInput(Global.MovieInputSourceAdapter, Global.MultitrackRewiringControllerAdapter);
}
else
{
Global.MovieSession.LatchInputFromPlayer(Global.MovieInputSourceAdapter);
}
//the movie session makes sure that the correct input has been read and merged to its MovieControllerAdapter;
//this has been wired to Global.MovieOutputHardpoint in RewireInputChain
Global.MovieSession.Movie.CommitFrame(Global.Emulator.Frame, Global.MovieOutputHardpoint);
}
}
else if (Global.MovieSession.Movie.Mode == MOVIEMODE.INACTIVE || Global.MovieSession.Movie.Mode == MOVIEMODE.FINISHED)
{
Global.MovieSession.LatchInputFromPlayer(Global.MovieInputSourceAdapter);
}
if (-1 != StopOnFrame && StopOnFrame == Global.Emulator.Frame + 1)
{
if (StopOnFrame == Global.MovieSession.Movie.LogLength())
{
Global.MovieSession.Movie.SetMovieFinished();
}
if (true == Global.MovieSession.Movie.TastudioOn)
{
PauseEmulator();
StopOnFrame = -1;
}
if (RestoreReadWriteOnStop == true)
{
Global.MovieSession.Movie.Mode = MOVIEMODE.RECORD;
RestoreReadWriteOnStop = false;
}
}
if (Global.MovieSession.Movie.Mode == MOVIEMODE.FINISHED)
{
if (Global.MovieSession.Movie.LogLength() > Global.Emulator.Frame + 1)
{
Global.MovieSession.Movie.StartPlayback();
//Global.MovieSession.MovieControllerAdapter.SetControllersAsMnemonic(Global.MovieSession.Movie.GetInputFrame(Global.Emulator.Frame));
//Global.MovieMode = true;
//adelikat: is Global.MovieMode doing anything anymore? if not we shoudl remove this variable
Global.MovieSession.LatchInputFromLog();
}
}
//TODO: adelikat: don't know what this should do so leaving it commented out
//if (Global.MovieSession.Movie.Mode == MOVIEMODE.RECORD && Global.MovieSession.MultiTrack.IsActive)
//{
// Global.MovieSession.MovieControllerAdapter.SetControllersAsMnemonic(Global.MovieSession.Movie.GetInputFrame(Global.Emulator.Frame-1));
//}
HandleMovieOnFrameLoop();
//=======================================
MemoryPulse.Pulse();
@ -2044,6 +1985,8 @@ namespace BizHawk.MultiClient
Global.Sound.UpdateSound(NullSound.SilenceProvider);
}
/// <summary>
/// Update all tools that are frame dependent like Ram Search before processing
/// </summary>

View File

@ -738,6 +738,10 @@ namespace BizHawk.MultiClient
else
return false; //For now throw an error if recording, ideally what should happen is that the state gets loaded, and the movie set to movie finished, the movie at its current state is preserved and the state is loaded just fine. This should probably also only happen if checktimelines passes
}
else if (Mode == MOVIEMODE.FINISHED)
{
Mode = MOVIEMODE.PLAY;
}
if (stateFrame == 0)
{