Skip to content

Commit

Permalink
remove built-in multitrack movie recorder, justification: tastudio is…
Browse files Browse the repository at this point in the history
… a much better alternative, it isn't used, and it's causing strain on better movie architecture, also this logic is easily done via lua script. It could be built from scratch one day in a way that plays nice with better movie architecture, if there's demand, but we need to remove this to keep moving forward
  • Loading branch information
adelikat committed Jun 13, 2020
1 parent 03d10ce commit 268ab96
Show file tree
Hide file tree
Showing 13 changed files with 24 additions and 362 deletions.
5 changes: 0 additions & 5 deletions src/BizHawk.Client.Common/config/Binding.cs
Original file line number Diff line number Diff line change
Expand Up @@ -186,11 +186,6 @@ public static List<Binding> DefaultValues
Bind("Movie", "Stop Movie"),
Bind("Movie", "Play from beginning"),
Bind("Movie", "Save Movie"),
Bind("Movie", "Toggle MultiTrack"),
Bind("Movie", "MT Select All"),
Bind("Movie", "MT Select None"),
Bind("Movie", "MT Increment Player"),
Bind("Movie", "MT Decrement Player"),

Bind("Tools", "RAM Watch"),
Bind("Tools", "RAM Search"),
Expand Down
63 changes: 1 addition & 62 deletions src/BizHawk.Client.Common/movie/MovieSession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ public MovieSession(
?? throw new ArgumentNullException($"{nameof(pauseCallback)} cannot be null.");
_modeChangedCallback = modeChangedCallback
?? throw new ArgumentNullException($"{nameof(modeChangedCallback)} CannotUnloadAppDomainException be null.");

MultiTrack.RewiringAdapter.Source = MovieIn;
}

public IMovieConfig Settings { get; }
Expand All @@ -57,8 +55,6 @@ public MovieSession(

public IMovieController MovieController { get; private set; } = new Bk2Controller("", NullController.Instance.Definition);

public MultitrackRecorder MultiTrack { get; } = new MultitrackRecorder();

public IMovieController GenerateMovieController(ControllerDefinition definition = null)
{
// TODO: expose Movie.LogKey and pass in here
Expand Down Expand Up @@ -242,7 +238,6 @@ public void RunQueuedMovie(bool recordMode, IEmulator emulator, IDictionary<stri

Movie = _queuedMovie;
_queuedMovie = null;
MultiTrack.Restart(Movie.Emulator.ControllerDefinition.PlayerCount);

Movie.ProcessSavestate(Movie.Emulator);
Movie.ProcessSram(Movie.Emulator);
Expand All @@ -258,31 +253,6 @@ public void RunQueuedMovie(bool recordMode, IEmulator emulator, IDictionary<stri
}
}

public void ToggleMultitrack()
{
if (Movie.IsActive())
{
if (Settings.VBAStyleMovieLoadState)
{
Output("Multi-track can not be used in Full Movie Loadstates mode");
}
else if (Movie is ITasMovie)
{
Output("Multi-track can not be used with tasproj movies");
}
else
{
MultiTrack.IsActive ^= true;
MultiTrack.SelectNone();
Output(MultiTrack.IsActive ? "MultiTrack Enabled" : "MultiTrack Disabled");
}
}
else
{
Output("MultiTrack cannot be enabled while not recording.");
}
}

public void StopMovie(bool saveChanges = true)
{
if (Movie.IsActive())
Expand All @@ -299,8 +269,6 @@ public void StopMovie(bool saveChanges = true)

message += "stopped.";

MultiTrack.Restart(1);

var result = Movie.Stop(saveChanges);
if (result)
{
Expand Down Expand Up @@ -347,28 +315,6 @@ private void Output(string message)
_messageCallback?.Invoke(message);
}

private void LatchInputToMultitrackUser()
{
if (MultiTrack.IsActive)
{
var rewiredSource = MultiTrack.RewiringAdapter;
rewiredSource.PlayerSource = 1;
rewiredSource.PlayerTargetMask = 1 << MultiTrack.CurrentPlayer;
if (MultiTrack.RecordAll)
{
rewiredSource.PlayerTargetMask = unchecked((int)0xFFFFFFFF);
}

if (Movie.InputLogLength > Movie.Emulator.Frame)
{
var input = Movie.GetInputState(Movie.Emulator.Frame);
MovieController.SetFrom(input);
}

MovieController.SetPlayerFrom(rewiredSource, MultiTrack.CurrentPlayer);
}
}

private void LatchInputToUser()
{
MovieOut.Source = MovieIn;
Expand Down Expand Up @@ -439,14 +385,7 @@ private void HandleFrameLoopForRecordMode()
}
else
{
if (MultiTrack.IsActive)
{
LatchInputToMultitrackUser();
}
else
{
LatchInputToUser();
}
LatchInputToUser();
}

Movie.RecordFrame(Movie.Emulator.Frame, MovieController);
Expand Down
30 changes: 0 additions & 30 deletions src/BizHawk.Client.Common/movie/bk2/Bk2Controller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,36 +59,6 @@ public void SetFrom(IController source)
}
}

public void SetPlayerFrom(IController playerSource, int controllerNum)
{
foreach (var button in playerSource.Definition.BoolButtons)
{
var bnp = ButtonNameParser.Parse(button);

if (bnp?.PlayerNum != controllerNum)
{
continue;
}

var val = playerSource.IsPressed(button);
_myBoolButtons[button] = val;
}

foreach (var button in Definition.AxisControls)
{
var bnp = ButtonNameParser.Parse(button);

if (bnp?.PlayerNum != controllerNum)
{
continue;
}

var val = playerSource.AxisValue(button);

_myAxisControls[button] = val;
}
}

public void SetFromSticky(IStickyController controller)
{
foreach (var button in Definition.BoolButtons)
Expand Down
73 changes: 20 additions & 53 deletions src/BizHawk.Client.Common/movie/bk2/Bk2Movie.InputLog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,69 +38,36 @@ public virtual bool ExtractInputLog(TextReader reader, out string errorMessage)
int? stateFrame = null;

// We are in record mode so replace the movie log with the one from the savestate
if (!Session.MultiTrack.IsActive)
if (Session.Settings.EnableBackupMovies && MakeBackup && Log.Count != 0)
{
if (Session.Settings.EnableBackupMovies && MakeBackup && Log.Count != 0)
SaveBackup();
MakeBackup = false;
}

Log.Clear();
string line;
while ((line = reader.ReadLine()) != null)
{
if (line.StartsWith("|"))
{
SaveBackup();
MakeBackup = false;
Log.Add(line);
}

Log.Clear();
string line;
while ((line = reader.ReadLine()) != null)
else if (line.StartsWith("Frame "))
{
if (line.StartsWith("|"))
{
Log.Add(line);
}
else if (line.StartsWith("Frame "))
var strs = line.Split(' ');
try
{
var strs = line.Split(' ');
try
{
stateFrame = int.Parse(strs[1]);
}
catch
{
errorMessage = "Savestate Frame number failed to parse";
return false;
}
stateFrame = int.Parse(strs[1]);
}
else if (line.StartsWith("LogKey:"))
catch
{
LogKey = line.Replace("LogKey:", "");
errorMessage = "Savestate Frame number failed to parse";
return false;
}
}
}
else
{
var i = 0;
string line;
while ((line = reader.ReadLine()) != null)
else if (line.StartsWith("LogKey:"))
{
if (line.StartsWith("|"))
{
SetFrameAt(i, line);
i++;
}
else if (line.StartsWith("Frame "))
{
var strs = line.Split(' ');
try
{
stateFrame = int.Parse(strs[1]);
}
catch
{
errorMessage = "Savestate Frame number failed to parse";
return false;
}
}
else if (line.StartsWith("LogKey:"))
{
LogKey = line.Replace("LogKey:", "");
}
LogKey = line.Replace("LogKey:", "");
}
}

Expand Down
10 changes: 3 additions & 7 deletions src/BizHawk.Client.Common/movie/bk2/Bk2Movie.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,14 +130,10 @@ public virtual void RecordFrame(int frame, IController source)
public virtual void Truncate(int frame)
{
// This is a bad way to do multitrack logic, pass the info in instead of going to the global
// and it is weird for Truncate to possibly not truncate
if (!Session.MultiTrack.IsActive)
if (frame < Log.Count)
{
if (frame < Log.Count)
{
Log.RemoveRange(frame, Log.Count - frame);
Changes = true;
}
Log.RemoveRange(frame, Log.Count - frame);
Changes = true;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@ public interface IMovieController : IController
/// </summary>
void SetFrom(IController source);

/// <summary>
/// Latches to only the buttons in the given <see cref="IController" /> for the given controller
/// </summary>
void SetPlayerFrom(IController playerSource, int controllerNum);

/// <summary>
/// Latches to the given <see cref="IStickyController" />
/// For buttons it latches autohold state, for analogs it latches mid value.
Expand Down
3 changes: 0 additions & 3 deletions src/BizHawk.Client.Common/movie/interfaces/IMovieSession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ public interface IMovieSession
string QueuedSyncSettings { get; }

IMovieController MovieController { get; }
MultitrackRecorder MultiTrack { get; }

/// <summary>
/// Provides a source for sticky controls ot use when recording
Expand Down Expand Up @@ -69,8 +68,6 @@ public interface IMovieSession
/// </summary>
void RunQueuedMovie(bool recordMode, IEmulator emulator, IDictionary<string, string> preferredCores);

void ToggleMultitrack();

void StopMovie(bool saveChanges = true);

/// <summary>
Expand Down
37 changes: 0 additions & 37 deletions src/BizHawk.Client.Common/movie/multitrack/ButtonNameParser.cs

This file was deleted.

Loading

0 comments on commit 268ab96

Please sign in to comment.