Movie refactoring - round 2

This commit is contained in:
adelikat 2012-09-03 19:42:53 +00:00
parent c9b3f7bedf
commit 8f408737da
14 changed files with 682 additions and 476 deletions

View File

@ -340,16 +340,18 @@ namespace BizHawk.MultiClient
private string MakeFrameCounter() private string MakeFrameCounter()
{ {
if (Global.MovieSession.Movie.Mode == MOVIEMODE.FINISHED) if (Global.MovieSession.Movie.IsFinished)
{ {
return Global.Emulator.Frame.ToString() + "/" + Global.MovieSession.Movie.TotalFrames.ToString() + " (Finished)"; return Global.Emulator.Frame.ToString() + "/" + Global.MovieSession.Movie.Frames.ToString() + " (Finished)";
} }
else if (Global.MovieSession.Movie.Mode == MOVIEMODE.PLAY) else if (Global.MovieSession.Movie.IsPlaying)
{ {
return Global.Emulator.Frame.ToString() + "/" + Global.MovieSession.Movie.TotalFrames.ToString(); return Global.Emulator.Frame.ToString() + "/" + Global.MovieSession.Movie.Frames.ToString();
} }
else if (Global.MovieSession.Movie.Mode == MOVIEMODE.RECORD) else if (Global.MovieSession.Movie.IsRecording)
{
return Global.Emulator.Frame.ToString(); return Global.Emulator.Frame.ToString();
}
else else
{ {
return Global.Emulator.Frame.ToString(); return Global.Emulator.Frame.ToString();
@ -421,22 +423,31 @@ namespace BizHawk.MultiClient
public string MakeInputDisplay() public string MakeInputDisplay()
{ {
StringBuilder s; StringBuilder s;
if (Global.MovieSession.Movie.Mode == MOVIEMODE.INACTIVE || Global.MovieSession.Movie.Mode == MOVIEMODE.FINISHED) if (Global.MovieSession.Movie.IsPlaying)
{
s = new StringBuilder(Global.GetOutputControllersAsMnemonic()); s = new StringBuilder(Global.GetOutputControllersAsMnemonic());
}
else else
s = new StringBuilder(Global.MovieSession.Movie.GetInputFrame(Global.Emulator.Frame - 1)); {
s.Replace(".", " ").Replace("|", "").Replace("l", ""); //If l is ever a mnemonic this will squash it. s = new StringBuilder(Global.MovieSession.Movie.GetInput(Global.Emulator.Frame - 1));
}
s.Replace(".", " ").Replace("|", "").Replace("l", ""); //Note: if l is ever a mnemonic this will squash it. But this is done because on the NES core I put l in the command mnemonic to indicate lag (was a bad a idea)
return s.ToString(); return s.ToString();
} }
public string MakeRerecordCount() public string MakeRerecordCount()
{ {
if (Global.MovieSession.Movie.Mode != MOVIEMODE.INACTIVE) if (Global.MovieSession.Movie.IsActive)
{
return "Rerecord Count: " + Global.MovieSession.Movie.Rerecords.ToString(); return "Rerecord Count: " + Global.MovieSession.Movie.Rerecords.ToString();
}
else else
{
return ""; return "";
} }
}
/// <summary> /// <summary>
/// Display all screen info objects like fps, frame counter, lag counter, and input display /// Display all screen info objects like fps, frame counter, lag counter, and input display
@ -457,12 +468,14 @@ namespace BizHawk.MultiClient
Color c; Color c;
float x = GetX(g, Global.Config.DispInpx, Global.Config.DispInpanchor, MessageFont, input); float x = GetX(g, Global.Config.DispInpx, Global.Config.DispInpanchor, MessageFont, input);
float y = GetY(g, Global.Config.DispInpy, Global.Config.DispInpanchor, MessageFont, input); float y = GetY(g, Global.Config.DispInpy, Global.Config.DispInpanchor, MessageFont, input);
if (Global.MovieSession.Movie.Mode == MOVIEMODE.PLAY) if (Global.MovieSession.Movie.IsPlaying && !Global.MovieSession.Movie.IsRecording)
{ {
c = Color.FromArgb(Global.Config.MovieInput); c = Color.FromArgb(Global.Config.MovieInput);
} }
else else
{
c = Color.FromArgb(Global.Config.MessagesColor); c = Color.FromArgb(Global.Config.MessagesColor);
}
g.DrawString(input, MessageFont, Color.Black, x+1,y+1); g.DrawString(input, MessageFont, Color.Black, x+1,y+1);
g.DrawString(input, MessageFont, c, x,y); g.DrawString(input, MessageFont, c, x,y);
@ -513,38 +526,37 @@ namespace BizHawk.MultiClient
g.DrawString(rerec, MessageFont, FixedMessagesColor, x, y); g.DrawString(rerec, MessageFont, FixedMessagesColor, x, y);
} }
if (Global.MovieSession.Movie.Mode == MOVIEMODE.PLAY)
{
//TODO //TODO
//int r = (int)g.ClipBounds.Width; //if (Global.MovieSession.Movie.IsPlaying)
//Point[] p = { new Point(r - 20, 2), //{
// new Point(r - 4, 12), // //int r = (int)g.ClipBounds.Width;
// new Point(r - 20, 22) }; // //Point[] p = { new Point(r - 20, 2),
//g.FillPolygon(new SolidBrush(Color.Red), p); // // new Point(r - 4, 12),
//g.DrawPolygon(new Pen(new SolidBrush(Color.Pink)), p); // // new Point(r - 20, 22) };
// //g.FillPolygon(new SolidBrush(Color.Red), p);
// //g.DrawPolygon(new Pen(new SolidBrush(Color.Pink)), p);
} //}
else if (Global.MovieSession.Movie.Mode == MOVIEMODE.RECORD) //else if (Global.MovieSession.Movie.IsRecording)
//{
// //g.FillEllipse(new SolidBrush(Color.Red), new Rectangle((int)g.ClipBounds.Width - 22, 2, 20, 20));
// //g.DrawEllipse(new Pen(new SolidBrush(Color.Pink)), new Rectangle((int)g.ClipBounds.Width - 22, 2, 20, 20));
//}
if (Global.MovieSession.Movie.IsActive && Global.Config.DisplaySubtitles)
{ {
//TODO
//g.FillEllipse(new SolidBrush(Color.Red), new Rectangle((int)g.ClipBounds.Width - 22, 2, 20, 20));
//g.DrawEllipse(new Pen(new SolidBrush(Color.Pink)), new Rectangle((int)g.ClipBounds.Width - 22, 2, 20, 20));
}
if (Global.MovieSession.Movie.Mode != MOVIEMODE.INACTIVE && Global.Config.DisplaySubtitles)
{
List<Subtitle> s = Global.MovieSession.Movie.Subtitles.GetSubtitles(Global.Emulator.Frame); List<Subtitle> s = Global.MovieSession.Movie.Subtitles.GetSubtitles(Global.Emulator.Frame);
if (s == null) return; if (s == null)
{
return;
}
for (int i = 0; i < s.Count; i++) for (int i = 0; i < s.Count; i++)
{ {
g.DrawString(s[i].Message, MessageFont, Color.Black, g.DrawString(s[i].Message, MessageFont, Color.Black, s[i].X + 1, s[i].Y + 1);
s[i].X + 1, s[i].Y + 1); g.DrawString(s[i].Message, MessageFont, Color.FromArgb((int)s[i].Color), s[i].X, s[i].Y);
g.DrawString(s[i].Message, MessageFont, Color.FromArgb((int)s[i].Color),
s[i].X, s[i].Y);
} }
} }
} }
} }

View File

@ -1790,7 +1790,22 @@ namespace BizHawk.MultiClient
//---------------------------------------------------- //----------------------------------------------------
public string movie_mode() public string movie_mode()
{ {
return Global.MovieSession.Movie.Mode.ToString(); if (Global.MovieSession.Movie.IsFinished)
{
return "FINISHED";
}
else if (Global.MovieSession.Movie.IsPlaying)
{
return "PLAY";
}
else if (Global.MovieSession.Movie.IsRecording)
{
return "RECORD";
}
else
{
return "INACTIVE";
}
} }
public string movie_rerecordcount() public string movie_rerecordcount()
@ -1800,20 +1815,24 @@ namespace BizHawk.MultiClient
public void movie_stop() public void movie_stop()
{ {
Global.MovieSession.Movie.StopMovie(); Global.MovieSession.Movie.Stop();
} }
public bool movie_isloaded() public bool movie_isloaded()
{ {
if (Global.MovieSession.Movie.Mode == MOVIEMODE.INACTIVE) if (Global.MovieSession.Movie.IsActive)
return false; {
else
return true; return true;
} }
else
{
return false;
}
}
public int movie_length() public int movie_length()
{ {
return Global.MovieSession.Movie.TotalFrames; return Global.MovieSession.Movie.Frames;
} }
public string movie_filename() public string movie_filename()
@ -1838,7 +1857,7 @@ namespace BizHawk.MultiClient
{ {
LuaTable input = lua.NewTable(); LuaTable input = lua.NewTable();
string s = Global.MovieSession.Movie.GetInputFrame(LuaInt(frame)); string s = Global.MovieSession.Movie.GetInput(LuaInt(frame));
MovieControllerAdapter m = new MovieControllerAdapter(); MovieControllerAdapter m = new MovieControllerAdapter();
m.Type = Global.MovieSession.MovieControllerAdapter.Type; m.Type = Global.MovieSession.MovieControllerAdapter.Type;
m.SetControllersAsMnemonic(s); m.SetControllersAsMnemonic(s);
@ -1850,15 +1869,15 @@ namespace BizHawk.MultiClient
public bool movie_getrerecordcounting() public bool movie_getrerecordcounting()
{ {
return Global.MovieSession.Movie.RerecordCounting; return Global.MovieSession.Movie.IsCountingRerecords;
} }
public void movie_setrerecordcounting(object lua_input) public void movie_setrerecordcounting(object lua_input)
{ {
if (lua_input.ToString().ToUpper() == "TRUE" || lua_input.ToString() == "1") if (lua_input.ToString().ToUpper() == "TRUE" || lua_input.ToString() == "1")
Global.MovieSession.Movie.RerecordCounting = true; Global.MovieSession.Movie.IsCountingRerecords = true;
else else
Global.MovieSession.Movie.RerecordCounting = false; Global.MovieSession.Movie.IsCountingRerecords = false;
} }
//---------------------------------------------------- //----------------------------------------------------
//Input library //Input library

View File

@ -968,20 +968,7 @@ namespace BizHawk.MultiClient
cmiLoadLastRom.Visible = false; cmiLoadLastRom.Visible = false;
toolStripSeparator_afterRomLoading.Visible = false; toolStripSeparator_afterRomLoading.Visible = false;
if (Global.MovieSession.Movie.Mode == MOVIEMODE.INACTIVE) if (Global.MovieSession.Movie.IsActive)
{
cmiRecordMovie.Visible = true;
cmiPlayMovie.Visible = true;
cmiRestartMovie.Visible = false;
cmiStopMovie.Visible = false;
cmiLoadLastMovie.Visible = true;
cmiMakeMovieBackup.Visible = false;
cmiViewSubtitles.Visible = false;
cmiViewComments.Visible = false;
toolStripSeparator_afterMovie.Visible = true;
cmiAddSubtitle.Visible = false;
}
else
{ {
cmiRecordMovie.Visible = false; cmiRecordMovie.Visible = false;
cmiPlayMovie.Visible = false; cmiPlayMovie.Visible = false;
@ -1005,6 +992,19 @@ namespace BizHawk.MultiClient
cmiAddSubtitle.Visible = true; cmiAddSubtitle.Visible = true;
} }
} }
else
{
cmiRecordMovie.Visible = true;
cmiPlayMovie.Visible = true;
cmiRestartMovie.Visible = false;
cmiStopMovie.Visible = false;
cmiLoadLastMovie.Visible = true;
cmiMakeMovieBackup.Visible = false;
cmiViewSubtitles.Visible = false;
cmiViewComments.Visible = false;
toolStripSeparator_afterMovie.Visible = true;
cmiAddSubtitle.Visible = false;
}
cmiUndoSavestate.Visible = true; cmiUndoSavestate.Visible = true;
@ -1135,23 +1135,25 @@ namespace BizHawk.MultiClient
private void viewCommentsToolStripMenuItem_Click(object sender, EventArgs e) private void viewCommentsToolStripMenuItem_Click(object sender, EventArgs e)
{ {
if (Global.MovieSession.Movie.Mode == MOVIEMODE.INACTIVE) return; if (Global.MovieSession.Movie.IsActive)
{
EditCommentsForm c = new EditCommentsForm(); EditCommentsForm c = new EditCommentsForm();
c.ReadOnly = ReadOnly; c.ReadOnly = ReadOnly;
c.GetMovie(Global.MovieSession.Movie); c.GetMovie(Global.MovieSession.Movie);
c.ShowDialog(); c.ShowDialog();
} }
}
private void viewSubtitlesToolStripMenuItem_Click(object sender, EventArgs e) private void viewSubtitlesToolStripMenuItem_Click(object sender, EventArgs e)
{ {
if (Global.MovieSession.Movie.Mode == MOVIEMODE.INACTIVE) return; if (Global.MovieSession.Movie.IsActive)
{
EditSubtitlesForm s = new EditSubtitlesForm(); EditSubtitlesForm s = new EditSubtitlesForm();
s.ReadOnly = ReadOnly; s.ReadOnly = ReadOnly;
s.GetMovie(Global.MovieSession.Movie); s.GetMovie(Global.MovieSession.Movie);
s.ShowDialog(); s.ShowDialog();
} }
}
private void debuggerToolStripMenuItem1_Click(object sender, EventArgs e) private void debuggerToolStripMenuItem1_Click(object sender, EventArgs e)
{ {
@ -1200,16 +1202,16 @@ namespace BizHawk.MultiClient
private void movieToolStripMenuItem_DropDownOpened(object sender, EventArgs e) private void movieToolStripMenuItem_DropDownOpened(object sender, EventArgs e)
{ {
if (Global.MovieSession.Movie.Mode == MOVIEMODE.INACTIVE) if (Global.MovieSession.Movie.IsActive)
{
stopMovieToolStripMenuItem.Enabled = false;
playFromBeginningToolStripMenuItem.Enabled = false;
}
else
{ {
stopMovieToolStripMenuItem.Enabled = true; stopMovieToolStripMenuItem.Enabled = true;
playFromBeginningToolStripMenuItem.Enabled = true; playFromBeginningToolStripMenuItem.Enabled = true;
} }
else
{
stopMovieToolStripMenuItem.Enabled = false;
playFromBeginningToolStripMenuItem.Enabled = false;
}
readonlyToolStripMenuItem.Checked = ReadOnly; readonlyToolStripMenuItem.Checked = ReadOnly;
bindSavestatesToMoviesToolStripMenuItem.Checked = Global.Config.BindSavestatesToMovies; bindSavestatesToMoviesToolStripMenuItem.Checked = Global.Config.BindSavestatesToMovies;

View File

@ -20,7 +20,10 @@ namespace BizHawk.MultiClient
LoadRom(Global.MainForm.CurrentlyOpenRom); LoadRom(Global.MainForm.CurrentlyOpenRom);
if (!record) if (!record)
{
Global.MovieSession.Movie.LoadMovie(); Global.MovieSession.Movie.LoadMovie();
}
Global.Config.RecentMovies.Add(m.Filename); Global.Config.RecentMovies.Add(m.Filename);
if (Global.MovieSession.Movie.StartsFromSavestate) if (Global.MovieSession.Movie.StartsFromSavestate)
{ {
@ -42,13 +45,13 @@ namespace BizHawk.MultiClient
public void SetMainformMovieInfo() public void SetMainformMovieInfo()
{ {
if (Global.MovieSession.Movie.Mode == MOVIEMODE.PLAY || Global.MovieSession.Movie.Mode == MOVIEMODE.FINISHED) if (Global.MovieSession.Movie.IsPlaying)
{ {
Text = DisplayNameForSystem(Global.Game.System) + " - " + Global.Game.Name + " - " + Path.GetFileName(Global.MovieSession.Movie.Filename); Text = DisplayNameForSystem(Global.Game.System) + " - " + Global.Game.Name + " - " + Path.GetFileName(Global.MovieSession.Movie.Filename);
PlayRecordStatus.Image = BizHawk.MultiClient.Properties.Resources.Play; PlayRecordStatus.Image = BizHawk.MultiClient.Properties.Resources.Play;
PlayRecordStatus.ToolTipText = "Movie is in playback mode"; PlayRecordStatus.ToolTipText = "Movie is in playback mode";
} }
else if (Global.MovieSession.Movie.Mode == MOVIEMODE.RECORD) else if (Global.MovieSession.Movie.IsRecording)
{ {
Text = DisplayNameForSystem(Global.Game.System) + " - " + Global.Game.Name + " - " + Path.GetFileName(Global.MovieSession.Movie.Filename); Text = DisplayNameForSystem(Global.Game.System) + " - " + Global.Game.Name + " - " + Path.GetFileName(Global.MovieSession.Movie.Filename);
PlayRecordStatus.Image = BizHawk.MultiClient.Properties.Resources.RecordHS; PlayRecordStatus.Image = BizHawk.MultiClient.Properties.Resources.RecordHS;
@ -62,14 +65,6 @@ namespace BizHawk.MultiClient
} }
} }
public bool MovieActive()
{
if (Global.MovieSession.Movie.Mode != MOVIEMODE.INACTIVE)
return true;
else
return false;
}
public void PlayMovie() public void PlayMovie()
{ {
PlayMovie p = new PlayMovie(); PlayMovie p = new PlayMovie();
@ -84,7 +79,7 @@ namespace BizHawk.MultiClient
public void PlayMovieFromBeginning() public void PlayMovieFromBeginning()
{ {
if (Global.MovieSession.Movie.Mode != MOVIEMODE.INACTIVE) if (Global.MovieSession.Movie.IsActive)
{ {
LoadRom(CurrentlyOpenRom); LoadRom(CurrentlyOpenRom);
if (Global.MovieSession.Movie.StartsFromSavestate) if (Global.MovieSession.Movie.StartsFromSavestate)
@ -102,15 +97,20 @@ namespace BizHawk.MultiClient
public void StopMovie() public void StopMovie()
{ {
string message = "Movie "; string message = "Movie ";
if (Global.MovieSession.Movie.Mode == MOVIEMODE.RECORD) if (Global.MovieSession.Movie.IsRecording)
message += "recording ";
else if (Global.MovieSession.Movie.Mode == MOVIEMODE.PLAY
|| Global.MovieSession.Movie.Mode == MOVIEMODE.FINISHED)
message += "playback ";
message += "stopped.";
if (Global.MovieSession.Movie.Mode != MOVIEMODE.INACTIVE)
{ {
Global.MovieSession.Movie.StopMovie(); message += "recording ";
}
else if (Global.MovieSession.Movie.IsPlaying)
{
message += "playback ";
}
message += "stopped.";
if (Global.MovieSession.Movie.IsActive)
{
Global.MovieSession.Movie.Stop();
Global.OSD.AddMessage(message); Global.OSD.AddMessage(message);
SetMainformMovieInfo(); SetMainformMovieInfo();
Global.MainForm.ReadOnly = true; Global.MainForm.ReadOnly = true;
@ -120,12 +120,12 @@ namespace BizHawk.MultiClient
private bool HandleMovieLoadState(string path) private bool HandleMovieLoadState(string path)
{ {
//Note, some of the situations in these IF's may be identical and could be combined but I intentionally separated it out for clarity //Note, some of the situations in these IF's may be identical and could be combined but I intentionally separated it out for clarity
if (Global.MovieSession.Movie.Mode == MOVIEMODE.INACTIVE) if (!Global.MovieSession.Movie.IsActive)
{ {
return true; return true;
} }
else if (Global.MovieSession.Movie.Mode == MOVIEMODE.RECORD) else if (Global.MovieSession.Movie.IsRecording)
{ {
if (ReadOnly) if (ReadOnly)
@ -151,7 +151,7 @@ namespace BizHawk.MultiClient
} }
} }
else if (Global.MovieSession.Movie.Mode == MOVIEMODE.PLAY) else if (Global.MovieSession.Movie.IsPlaying && !Global.MovieSession.Movie.IsFinished)
{ {
if (ReadOnly) if (ReadOnly)
{ {
@ -167,12 +167,12 @@ namespace BizHawk.MultiClient
{ {
return false; //GUID Error return false; //GUID Error
} }
Global.MovieSession.Movie.ResumeRecording(); Global.MovieSession.Movie.Record();
SetMainformMovieInfo(); SetMainformMovieInfo();
Global.MovieSession.Movie.LoadLogFromSavestateText(path); Global.MovieSession.Movie.LoadLogFromSavestateText(path);
} }
} }
else if (Global.MovieSession.Movie.Mode == MOVIEMODE.FINISHED) else if (Global.MovieSession.Movie.IsFinished)
{ {
if (ReadOnly) if (ReadOnly)
{ {
@ -181,7 +181,7 @@ namespace BizHawk.MultiClient
{ {
return false; //Timeline/GUID error return false; //Timeline/GUID error
} }
else if (Global.MovieSession.Movie.Mode == MOVIEMODE.FINISHED) //TimeLine check can change a movie to finished, hence the check here (not a good design) else if (Global.MovieSession.Movie.IsFinished) //TimeLine check can change a movie to finished, hence the check here (not a good design)
{ {
Global.MovieSession.LatchInputFromPlayer(Global.MovieInputSourceAdapter); Global.MovieSession.LatchInputFromPlayer(Global.MovieInputSourceAdapter);
} }
@ -199,7 +199,7 @@ namespace BizHawk.MultiClient
{ {
return false; //GUID Error return false; //GUID Error
} }
else if (Global.MovieSession.Movie.Mode == MOVIEMODE.FINISHED) else if (Global.MovieSession.Movie.IsFinished)
{ {
Global.MovieSession.LatchInputFromPlayer(Global.MovieInputSourceAdapter); Global.MovieSession.LatchInputFromPlayer(Global.MovieInputSourceAdapter);
} }
@ -217,7 +217,7 @@ namespace BizHawk.MultiClient
private void HandleMovieSaveState(StreamWriter writer) private void HandleMovieSaveState(StreamWriter writer)
{ {
if (Global.MovieSession.Movie.Mode != MOVIEMODE.INACTIVE) if (Global.MovieSession.Movie.IsActive)
{ {
Global.MovieSession.Movie.DumpLogIntoSavestateText(writer); Global.MovieSession.Movie.DumpLogIntoSavestateText(writer);
} }
@ -225,9 +225,39 @@ namespace BizHawk.MultiClient
private void HandleMovieOnFrameLoop() private void HandleMovieOnFrameLoop()
{ {
switch (Global.MovieSession.Movie.Mode) if (!Global.MovieSession.Movie.IsActive)
{
Global.MovieSession.LatchInputFromPlayer(Global.MovieInputSourceAdapter);
}
else if (Global.MovieSession.Movie.IsFinished)
{
if (Global.Emulator.Frame < Global.MovieSession.Movie.Frames) //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);
}
}
else if (Global.MovieSession.Movie.IsPlaying)
{
if (Global.Emulator.Frame >= Global.MovieSession.Movie.Frames)
{
Global.MovieSession.Movie.Finish();
}
else
{
Global.MovieSession.Movie.CaptureState();
Global.MovieSession.LatchInputFromLog();
}
}
else if (Global.MovieSession.Movie.IsRecording)
{ {
case MOVIEMODE.RECORD:
Global.MovieSession.Movie.CaptureState(); Global.MovieSession.Movie.CaptureState();
if (Global.MovieSession.MultiTrack.IsActive) if (Global.MovieSession.MultiTrack.IsActive)
{ {
@ -240,39 +270,9 @@ namespace BizHawk.MultiClient
//the movie session makes sure that the correct input has been read and merged to its MovieControllerAdapter; //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 //this has been wired to Global.MovieOutputHardpoint in RewireInputChain
Global.MovieSession.Movie.CommitFrame(Global.Emulator.Frame, Global.MovieOutputHardpoint); Global.MovieSession.Movie.CommitFrame(Global.Emulator.Frame, Global.MovieOutputHardpoint);
break;
case MOVIEMODE.PLAY:
int x = Global.MovieSession.Movie.TotalFrames;
if (Global.Emulator.Frame >= Global.MovieSession.Movie.TotalFrames)
{
Global.MovieSession.Movie.SetMovieFinished();
}
else
{
Global.MovieSession.Movie.CaptureState();
Global.MovieSession.LatchInputFromLog();
}
x++;
break;
case MOVIEMODE.FINISHED:
int xx = Global.MovieSession.Movie.TotalFrames;
if (Global.Emulator.Frame < Global.MovieSession.Movie.TotalFrames) //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) //adelikat TODO: 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 != -1 && StopOnFrame == Global.Emulator.Frame + 1)
//{ //{
// if (StopOnFrame == Global.MovieSession.Movie.LogLength()) // if (StopOnFrame == Global.MovieSession.Movie.LogLength())

View File

@ -143,7 +143,7 @@ namespace BizHawk.MultiClient
{ {
Global.CheatList.SaveSettings(); Global.CheatList.SaveSettings();
CloseGame(); CloseGame();
Global.MovieSession.Movie.StopMovie(); Global.MovieSession.Movie.Stop();
CloseTools(); CloseTools();
SaveConfig(); SaveConfig();
}; };
@ -219,14 +219,19 @@ namespace BizHawk.MultiClient
if (cmdMovie != null) if (cmdMovie != null)
{ {
if (Global.Game == null) if (Global.Game == null)
OpenROM();
if (Global.Game != null)
{ {
Movie m = new Movie(cmdMovie, MOVIEMODE.PLAY); OpenROM();
}
else
{
Movie m = new Movie(cmdMovie);
m.Play();
ReadOnly = true; ReadOnly = true;
// if user is dumping and didnt supply dump length, make it as long as the loaded movie // if user is dumping and didnt supply dump length, make it as long as the loaded movie
if (autoDumpLength == 0) if (autoDumpLength == 0)
autoDumpLength = m.TotalFrames; {
autoDumpLength = m.Frames;
}
StartNewMovie(m, false); StartNewMovie(m, false);
Global.Config.RecentMovies.Add(cmdMovie); Global.Config.RecentMovies.Add(cmdMovie);
} }
@ -234,19 +239,26 @@ namespace BizHawk.MultiClient
else if (Global.Config.AutoLoadMostRecentMovie && !Global.Config.RecentMovies.IsEmpty()) else if (Global.Config.AutoLoadMostRecentMovie && !Global.Config.RecentMovies.IsEmpty())
{ {
if (Global.Game == null) if (Global.Game == null)
OpenROM();
if (Global.Game != null)
{ {
Movie m = new Movie(Global.Config.RecentMovies.GetRecentFileByPosition(0), MOVIEMODE.PLAY); OpenROM();
}
else
{
Movie m = new Movie(Global.Config.RecentMovies.GetRecentFileByPosition(0));
m.Play();
ReadOnly = true; ReadOnly = true;
StartNewMovie(m, false); StartNewMovie(m, false);
} }
} }
if (cmdLoadState != null && Global.Game != null) if (cmdLoadState != null && Global.Game != null)
{
LoadState("QuickSave" + cmdLoadState); LoadState("QuickSave" + cmdLoadState);
}
else if (Global.Config.AutoLoadLastSaveSlot && Global.Game != null) else if (Global.Config.AutoLoadLastSaveSlot && Global.Game != null)
{
LoadState("QuickSave" + Global.Config.SaveSlot.ToString()); LoadState("QuickSave" + Global.Config.SaveSlot.ToString());
}
if (Global.Config.AutoLoadRamWatch) if (Global.Config.AutoLoadRamWatch)
{ {
@ -514,7 +526,8 @@ namespace BizHawk.MultiClient
private void LoadMoviesFromRecent(string movie) private void LoadMoviesFromRecent(string movie)
{ {
Movie m = new Movie(movie, MOVIEMODE.PLAY); Movie m = new Movie(movie);
m.Play();
if (!m.Loaded) if (!m.Loaded)
{ {
@ -915,7 +928,7 @@ namespace BizHawk.MultiClient
else if (IsValidMovieExtension(Path.GetExtension(filePaths[0]))) else if (IsValidMovieExtension(Path.GetExtension(filePaths[0])))
{ {
Movie m = new Movie(filePaths[0], MOVIEMODE.PLAY); Movie m = new Movie(filePaths[0]);
StartNewMovie(m, false); StartNewMovie(m, false);
} }
@ -1491,7 +1504,7 @@ namespace BizHawk.MultiClient
Global.Emulator = new NullEmulator(); Global.Emulator = new NullEmulator();
Global.ActiveController = Global.NullControls; Global.ActiveController = Global.NullControls;
Global.AutoFireController = Global.AutofireNullControls; Global.AutoFireController = Global.AutofireNullControls;
Global.MovieSession.Movie.StopMovie(); Global.MovieSession.Movie.Stop();
} }
private static void SaveRam() private static void SaveRam()
@ -1729,7 +1742,7 @@ namespace BizHawk.MultiClient
case "Soft Reset": SoftReset(); break; case "Soft Reset": SoftReset(); break;
case "Toggle MultiTrack": case "Toggle MultiTrack":
{ {
if (Global.MovieSession.Movie.Mode > MOVIEMODE.INACTIVE) if (Global.MovieSession.Movie.IsActive)
{ {
Global.MovieSession.MultiTrack.IsActive = !Global.MovieSession.MultiTrack.IsActive; Global.MovieSession.MultiTrack.IsActive = !Global.MovieSession.MultiTrack.IsActive;
if (Global.MovieSession.MultiTrack.IsActive) if (Global.MovieSession.MultiTrack.IsActive)
@ -1859,7 +1872,7 @@ namespace BizHawk.MultiClient
runFrame = true; runFrame = true;
} }
bool ReturnToRecording = Global.MovieSession.Movie.Mode == MOVIEMODE.RECORD; bool ReturnToRecording = Global.MovieSession.Movie.IsRecording;
if (Global.Config.RewindEnabled && (Global.ClientControls["Rewind"] || PressRewind)) if (Global.Config.RewindEnabled && (Global.ClientControls["Rewind"] || PressRewind))
{ {
Rewind(1); Rewind(1);
@ -1873,14 +1886,18 @@ namespace BizHawk.MultiClient
runFrame = true; runFrame = true;
} }
//we don't want to capture input when rewinding, even in record mode //we don't want to capture input when rewinding, even in record mode
if (Global.MovieSession.Movie.Mode == MOVIEMODE.RECORD) if (Global.MovieSession.Movie.IsRecording)
Global.MovieSession.Movie.Mode = MOVIEMODE.PLAY; {
Global.MovieSession.Movie.Play();
} }
if (true == UpdateFrame) }
if (UpdateFrame == true)
{ {
runFrame = true; runFrame = true;
if (Global.MovieSession.Movie.Mode == MOVIEMODE.RECORD) if (Global.MovieSession.Movie.IsRecording)
Global.MovieSession.Movie.Mode = MOVIEMODE.PLAY; {
Global.MovieSession.Movie.Play();
}
} }
bool genSound = false; bool genSound = false;
@ -1975,7 +1992,7 @@ namespace BizHawk.MultiClient
UpdateToolsAfter(); UpdateToolsAfter();
if (ReturnToRecording) if (ReturnToRecording)
{ {
Global.MovieSession.Movie.Mode = MOVIEMODE.RECORD; Global.MovieSession.Movie.Record();
} }
PressRewind = false; PressRewind = false;
} }
@ -1983,7 +2000,7 @@ namespace BizHawk.MultiClient
{ {
if (ReturnToRecording) if (ReturnToRecording)
{ {
Global.MovieSession.Movie.Mode = MOVIEMODE.RECORD; Global.MovieSession.Movie.Record();
} }
UpdateFrame = false; UpdateFrame = false;
} }
@ -2651,14 +2668,18 @@ namespace BizHawk.MultiClient
public void ToggleReadOnly() public void ToggleReadOnly()
{ {
if (Global.MovieSession.Movie.Mode > MOVIEMODE.INACTIVE) if (Global.MovieSession.Movie.IsActive)
{ {
ReadOnly ^= true; ReadOnly ^= true;
if (ReadOnly) if (ReadOnly)
{
Global.OSD.AddMessage("Movie read-only mode"); Global.OSD.AddMessage("Movie read-only mode");
}
else else
{
Global.OSD.AddMessage("Movie read+write mode"); Global.OSD.AddMessage("Movie read+write mode");
} }
}
else else
{ {
Global.OSD.AddMessage("No movie active"); Global.OSD.AddMessage("No movie active");
@ -2728,10 +2749,12 @@ namespace BizHawk.MultiClient
if (Global.Emulator.ControllerDefinition.BoolButtons.Contains("Reset")) if (Global.Emulator.ControllerDefinition.BoolButtons.Contains("Reset"))
{ {
Global.ClickyVirtualPadController.Click("Reset"); Global.ClickyVirtualPadController.Click("Reset");
if (Global.MovieSession.Movie.Mode == MOVIEMODE.INACTIVE && Global.Emulator is NES) if (!Global.MovieSession.Movie.IsActive && Global.Emulator is NES)
{
Global.Emulator.ResetFrameCounter(); Global.Emulator.ResetFrameCounter();
} }
} }
}
public void UpdateStatusSlots() public void UpdateStatusSlots()
{ {
@ -3319,5 +3342,12 @@ namespace BizHawk.MultiClient
} }
} }
public void ClearSaveRAM()
{
string x = PathManager.SaveRamPath(Global.Game);
var file = new FileInfo(PathManager.SaveRamPath(Global.Game));
if (file.Exists) file.Delete();
}
} }
} }

View File

@ -94,9 +94,9 @@ namespace BizHawk.MultiClient
{ {
if (file.Extension.ToUpper() == "STATE") if (file.Extension.ToUpper() == "STATE")
{ {
Movie m = new Movie(file.FullName, MOVIEMODE.INACTIVE); Movie m = new Movie(file.FullName);
m.LoadMovie(); //State files will have to load everything unfortunately m.LoadMovie(); //State files will have to load everything unfortunately
if (m.TotalFrames == 0) if (m.Frames == 0)
{ {
MessageBox.Show("No input log detected in this savestate, aborting", "Can not load file", MessageBoxButtons.OK, MessageBoxIcon.Hand); MessageBox.Show("No input log detected in this savestate, aborting", "Can not load file", MessageBoxButtons.OK, MessageBoxIcon.Hand);
return; return;
@ -125,9 +125,9 @@ namespace BizHawk.MultiClient
int x = IsDuplicate(filename); int x = IsDuplicate(filename);
if (x == 0) if (x == 0)
{ {
Movie m = new Movie(file.CanonicalFullPath, MOVIEMODE.INACTIVE); Movie m = new Movie(file.CanonicalFullPath);
m.LoadMovie(); //State files will have to load everything unfortunately m.LoadMovie(); //State files will have to load everything unfortunately
if (m.TotalFrames > 0) if (m.Frames > 0)
{ {
MovieList.Add(m); MovieList.Add(m);
sortReverse = false; sortReverse = false;
@ -167,24 +167,35 @@ namespace BizHawk.MultiClient
private int IsDuplicate(string filename) private int IsDuplicate(string filename)
{ {
for (int x = 0; x < MovieList.Count; x++) for (int x = 0; x < MovieList.Count; x++)
{
if (MovieList[x].Filename == filename) if (MovieList[x].Filename == filename)
{
return x; return x;
}
}
return 0; return 0;
} }
private void PreLoadMovieFile(HawkFile path, bool force) private void PreLoadMovieFile(HawkFile path, bool force)
{ {
Movie m = new Movie(path.CanonicalFullPath, MOVIEMODE.INACTIVE); Movie m = new Movie(path.CanonicalFullPath);
m.PreLoadText(); m.PreLoadText();
if (path.Extension == ".FM2") if (path.Extension == ".FM2")
{
m.Header.SetHeaderLine(MovieHeader.PLATFORM, "NES"); m.Header.SetHeaderLine(MovieHeader.PLATFORM, "NES");
}
else if (path.Extension == ".MC2") else if (path.Extension == ".MC2")
{
m.Header.SetHeaderLine(MovieHeader.PLATFORM, "PCE"); m.Header.SetHeaderLine(MovieHeader.PLATFORM, "PCE");
}
//Don't do this from browse //Don't do this from browse
if (m.Header.GetHeaderLine(MovieHeader.GAMENAME) == Global.Game.Name || if (m.Header.GetHeaderLine(MovieHeader.GAMENAME) == Global.Game.Name ||
Global.Config.PlayMovie_MatchGameName == false || force) Global.Config.PlayMovie_MatchGameName == false || force)
{
MovieList.Add(m); MovieList.Add(m);
} }
}
private void UpdateList() private void UpdateList()
{ {

View File

@ -57,7 +57,8 @@ namespace BizHawk.MultiClient
} }
MovieToRecord = new Movie(path, MOVIEMODE.RECORD); MovieToRecord = new Movie(path);
MovieToRecord.Record();
//Header //Header
MovieToRecord.Header.SetHeaderLine(MovieHeader.AUTHOR, AuthorBox.Text); MovieToRecord.Header.SetHeaderLine(MovieHeader.AUTHOR, AuthorBox.Text);
@ -75,7 +76,7 @@ namespace BizHawk.MultiClient
if (StartFromCombo.SelectedItem.ToString() == "Now") if (StartFromCombo.SelectedItem.ToString() == "Now")
{ {
MovieToRecord.FlagStartsFromSavestate(); MovieToRecord.StartsFromSavestate = true;
var temppath = path + ".tmp"; var temppath = path + ".tmp";
var writer = new StreamWriter(temppath); var writer = new StreamWriter(temppath);
Global.Emulator.SaveStateText(writer); Global.Emulator.SaveStateText(writer);

View File

@ -163,7 +163,7 @@ namespace BizHawk.MultiClient
{ {
for (int i = 0; i < frames; i++) for (int i = 0; i < frames; i++)
{ {
if (RewindBuf.Count == 0 || (true == Global.MovieSession.Movie.Loaded && 0 == Global.MovieSession.Movie.TotalFrames)) if (RewindBuf.Count == 0 || (true == Global.MovieSession.Movie.Loaded && 0 == Global.MovieSession.Movie.Frames))
{ {
return; return;
} }

View File

@ -290,7 +290,7 @@ namespace BizHawk.MultiClient
public static string SaveRamPath(GameInfo game) public static string SaveRamPath(GameInfo game)
{ {
string name = FilesystemSafeName(game); string name = FilesystemSafeName(game);
if (Global.MainForm.MovieActive()) if (Global.MovieSession.Movie.IsActive)
{ {
name += "." + Path.GetFileNameWithoutExtension(Global.MovieSession.Movie.Filename); name += "." + Path.GetFileNameWithoutExtension(Global.MovieSession.Movie.Filename);
@ -335,8 +335,12 @@ namespace BizHawk.MultiClient
public static string SaveStatePrefix(GameInfo game) public static string SaveStatePrefix(GameInfo game)
{ {
string name = FilesystemSafeName(game); string name = FilesystemSafeName(game);
if (Global.Config.BindSavestatesToMovies && Global.MainForm.MovieActive())
if (Global.Config.BindSavestatesToMovies && Global.MovieSession.Movie.IsActive)
{
name += "." + Path.GetFileNameWithoutExtension(Global.MovieSession.Movie.Filename); name += "." + Path.GetFileNameWithoutExtension(Global.MovieSession.Movie.Filename);
}
switch (game.System) switch (game.System)
{ {
case "A26": return Path.Combine(MakeAbsolutePath(Global.Config.PathAtariSavestates, "A26"), name); case "A26": return Path.Combine(MakeAbsolutePath(Global.Config.PathAtariSavestates, "A26"), name);

View File

@ -9,20 +9,19 @@ using System.Globalization;
namespace BizHawk.MultiClient namespace BizHawk.MultiClient
{ {
public enum MOVIEMODE { INACTIVE, PLAY, RECORD, FINISHED };
public class Movie public class Movie
{ {
#region Constructors #region Constructors
public Movie(string filename, MOVIEMODE m) public Movie(string filename)
{ {
Mode = m; Mode = MOVIEMODE.INACTIVE;
lastlog = 0; lastlog = 0;
Rerecords = 0; Rerecords = 0;
this.Filename = filename; this.Filename = filename;
IsText = true; IsText = true;
frames = 0; preload_framecount = 0;
RerecordCounting = true; IsCountingRerecords = true;
StartsFromSavestate = false; StartsFromSavestate = false;
if (filename.Length > 0) if (filename.Length > 0)
Loaded = true; Loaded = true;
@ -33,27 +32,37 @@ namespace BizHawk.MultiClient
Filename = ""; Filename = "";
Mode = MOVIEMODE.INACTIVE; Mode = MOVIEMODE.INACTIVE;
IsText = true; IsText = true;
frames = 0; preload_framecount = 0;
StartsFromSavestate = false; StartsFromSavestate = false;
Loaded = false; Loaded = false;
RerecordCounting = true; IsCountingRerecords = true;
} }
#endregion #endregion
#region Properties #region Properties
public MovieHeader Header = new MovieHeader(); public MovieHeader Header = new MovieHeader();
public SubtitleList Subtitles = new SubtitleList(); public SubtitleList Subtitles = new SubtitleList();
public bool MakeBackup = true; //make backup before altering movie public bool MakeBackup = true; //make backup before altering movie
public bool TastudioOn = false; //Remove this once the memory mangement issues with save states for tastudio has been solved. public string Filename;
public bool IsText { get; private set; } public bool IsCountingRerecords;
public string Filename { get; private set; }
public MOVIEMODE Mode { get; set; }
public int Rerecords { get; private set; }
public bool RerecordCounting { get; set; }
public bool StartsFromSavestate { get; private set; }
public bool Loaded { get; private set; } public bool Loaded { get; private set; }
public bool IsText { get; private set; }
public int Rerecords
{
get
{
return rerecords;
}
set
{
rerecords = value;
Header.SetHeaderLine(MovieHeader.RERECORDS, Rerecords.ToString());
}
}
public string SysID public string SysID
{ {
@ -79,7 +88,7 @@ namespace BizHawk.MultiClient
} }
} }
public int TotalFrames public int Frames
{ {
get get
{ {
@ -89,7 +98,27 @@ namespace BizHawk.MultiClient
} }
else else
{ {
return frames; return preload_framecount;
}
}
}
public bool StartsFromSavestate
{
get
{
return startsfromsavestate;
}
set
{
startsfromsavestate = value;
if (value == true)
{
Header.AddHeaderLine(MovieHeader.STARTSFROMSAVESTATE, "1");
}
else
{
Header.RemoveHeaderLine(MovieHeader.STARTSFROMSAVESTATE);
} }
} }
} }
@ -110,16 +139,132 @@ namespace BizHawk.MultiClient
} }
} }
#endregion public bool StateCapturing
#region Public Methods
public void UpdateFileName(string filename)
{ {
this.Filename = filename; get
{
return statecapturing;
}
set
{
Log.ClearStates();
statecapturing = value;
}
} }
public void StopMovie() #endregion
#region Public Mode Methods
public bool IsPlaying
{
get
{
if (Mode == MOVIEMODE.PLAY || Mode == MOVIEMODE.FINISHED)
{
return true;
}
else
{
return false;
}
}
}
public bool IsRecording
{
get
{
if (Mode == MOVIEMODE.RECORD)
{
return true;
}
else
{
return false;
}
}
}
public bool IsActive
{
get
{
if (Mode == MOVIEMODE.INACTIVE)
{
return false;
}
else
{
return true;
}
}
}
public bool IsFinished
{
get
{
if (Mode == MOVIEMODE.FINISHED)
{
return true;
}
else
{
return false;
}
}
}
//TODO: merge this with record? or better distinguish between the two events
/// <summary>
/// Tells the movie to start recording from the beginning, this will clear sram, and the movie log
/// </summary>
/// <param name="truncate"></param>
public void StartNewRecording(bool truncate = true)
{
Global.MainForm.ClearSaveRAM();
Mode = MOVIEMODE.RECORD;
if (Global.Config.EnableBackupMovies && MakeBackup && Log.MovieLength() > 0)
{
WriteBackup();
MakeBackup = false;
}
if (truncate)
{
Log.Clear();
}
}
//TODO: merge this with Play, play vs resume play?
public void StartPlayback()
{
Global.MainForm.ClearSaveRAM();
Mode = MOVIEMODE.PLAY;
Global.MainForm.StopOnFrame = Frames; //TODO: Get rid of this stuff
}
/// <summary>
/// Tells the movie to recording mode
/// </summary>
public void Record()
{
Mode = MOVIEMODE.RECORD;
}
//TODO: all the constructors for a movie that call this or record after, need to be rethought, what about clearing sram??
/// <summary>
/// Tells the movie to go into playback mode
/// </summary>
public void Play()
{
//TODO: determine if movie finished is correct here
//Also, consider the management of the read-only flag
//Really this hsouldn't be a method, it should be a consequence of other factors that should be managed
Mode = MOVIEMODE.PLAY;
}
public void Stop()
{ {
if (Mode == MOVIEMODE.RECORD) if (Mode == MOVIEMODE.RECORD)
{ {
@ -129,20 +274,184 @@ namespace BizHawk.MultiClient
Mode = MOVIEMODE.INACTIVE; Mode = MOVIEMODE.INACTIVE;
} }
public void Finish()
{
if (Mode == MOVIEMODE.PLAY)
{
Mode = MOVIEMODE.FINISHED;
}
}
#endregion
#region Public File Handling
public void WriteMovie()
{
if (!Loaded) return;
if (Filename == "") return;
Directory.CreateDirectory(new FileInfo(Filename).Directory.FullName);
if (IsText)
WriteText(Filename);
else
WriteBinary(Filename);
}
public void WriteBackup()
{
if (!Loaded) return;
if (Filename == "") return;
Directory.CreateDirectory(new FileInfo(Filename).Directory.FullName);
string BackupName = Filename;
BackupName = BackupName.Insert(Filename.LastIndexOf("."), String.Format(".{0:yyyy-MM-dd HH.mm.ss}", DateTime.Now));
Global.OSD.AddMessage("Backup movie saved to " + BackupName);
if (IsText)
{
WriteText(BackupName);
}
else
{
WriteBinary(BackupName);
}
}
/// <summary>
/// Load Header information only for displaying file information in dialogs such as play movie
/// </summary>
/// <returns></returns>
public bool PreLoadText()
{
Loaded = false;
var file = new FileInfo(Filename);
if (file.Exists == false)
return false;
else
{
Header.Clear();
Log.Clear();
}
using (StreamReader sr = file.OpenText())
{
string str = "";
while ((str = sr.ReadLine()) != null)
{
if (str == "" || Header.AddHeaderFromLine(str))
continue;
if (str.StartsWith("subtitle") || str.StartsWith("sub"))
Subtitles.AddSubtitle(str);
else if (str[0] == '|')
{
string frames = sr.ReadToEnd();
int length = str.Length;
// Account for line breaks of either size.
if (frames.IndexOf("\r\n") != -1)
length++;
length++;
// Count the remaining frames and the current one.
this.preload_framecount = (frames.Length / length) + 1;
break;
}
else
Header.Comments.Add(str);
}
sr.Close();
}
return true;
}
public bool LoadMovie()
{
var file = new FileInfo(Filename);
if (file.Exists == false)
{
Loaded = false;
return false;
}
return LoadText();
}
#endregion
#region Public Log Editing
public string GetInput(int frame)
{
lastlog = frame;
if (frame < Log.MovieLength())
{
return Log.GetFrame(frame);
}
else
{
return "";
}
}
public void ModifyFrame(string record, int frame)
{
Log.SetFrameAt(frame, record);
}
public void ClearFrame(int frame)
{
MnemonicsGenerator mg = new MnemonicsGenerator();
Log.SetFrameAt(frame, mg.GetEmptyMnemonic());
}
public void AppendFrame(string record)
{
Log.AddFrame(record);
}
public void InsertFrame(string record, int frame)
{
Log.AddFrameAt(record, frame);
}
public void InsertBlankFrame(int frame)
{
MnemonicsGenerator mg = new MnemonicsGenerator();
Log.AddFrameAt(mg.GetEmptyMnemonic(), frame);
}
public void DeleteFrame(int frame)
{
if (frame <= StateLastIndex)
{
if (frame <= StateFirstIndex)
{
RewindToFrame(0);
}
else
{
RewindToFrame(frame);
}
}
Log.DeleteFrame(frame);
}
public void TruncateMovie(int frame)
{
Log.TruncateMovie(frame);
}
#endregion
#region Public Misc Methods
public void CaptureState() public void CaptureState()
{ {
if (TastudioOn == true) if (StateCapturing == true)
{ {
byte[] state = Global.Emulator.SaveStateBinary(); byte[] state = Global.Emulator.SaveStateBinary();
Log.AddState(state); Log.AddState(state);
} }
} }
public void ClearStates()
{
Log.ClearStates();
}
public void RewindToFrame(int frame) public void RewindToFrame(int frame)
{ {
if (Mode == MOVIEMODE.INACTIVE || Mode == MOVIEMODE.FINISHED) if (Mode == MOVIEMODE.INACTIVE || Mode == MOVIEMODE.FINISHED)
@ -189,55 +498,6 @@ namespace BizHawk.MultiClient
} }
} }
public void DeleteFrame(int frame)
{
if (frame <= StateLastIndex)
{
if (frame <= StateFirstIndex)
{
RewindToFrame(0);
}
else
{
RewindToFrame(frame);
}
}
Log.DeleteFrame(frame);
}
public void ClearSaveRAM()
{
string x = PathManager.SaveRamPath(Global.Game);
var file = new FileInfo(PathManager.SaveRamPath(Global.Game));
if (file.Exists) file.Delete();
}
public void StartNewRecording() { StartNewRecording(true); }
public void StartNewRecording(bool truncate)
{
ClearSaveRAM();
Mode = MOVIEMODE.RECORD;
if (Global.Config.EnableBackupMovies && MakeBackup && Log.MovieLength() > 0)
{
WriteBackup();
MakeBackup = false;
}
if (truncate) Log.Clear();
}
public void StartPlayback()
{
ClearSaveRAM();
Mode = MOVIEMODE.PLAY;
Global.MainForm.StopOnFrame = TotalFrames;
}
public void ResumeRecording()
{
Mode = MOVIEMODE.RECORD;
}
public void CommitFrame(int frameNum, IController source) public void CommitFrame(int frameNum, IController source)
{ {
//if (Global.Emulator.Frame < Log.Length()) //if (Global.Emulator.Frame < Log.Length())
@ -256,127 +516,6 @@ namespace BizHawk.MultiClient
Log.SetFrameAt(frameNum, mg.GetControllersAsMnemonic()); Log.SetFrameAt(frameNum, mg.GetControllersAsMnemonic());
} }
public string GetInputFrame(int frame)
{
lastlog = frame;
if (frame < Log.MovieLength())
return Log.GetFrame(frame);
else
return "";
}
public void ModifyFrame(string record, int frame)
{
Log.SetFrameAt(frame, record);
}
public void ClearFrame(int frame)
{
MnemonicsGenerator mg = new MnemonicsGenerator();
Log.SetFrameAt(frame, mg.GetEmptyMnemonic());
}
public void AppendFrame(string record)
{
Log.AddFrame(record);
}
public void InsertFrame(string record, int frame)
{
Log.AddFrameAt(record, frame);
}
public void InsertBlankFrame(int frame)
{
MnemonicsGenerator mg = new MnemonicsGenerator();
Log.AddFrameAt(mg.GetEmptyMnemonic(), frame);
}
public void WriteMovie()
{
if (!Loaded) return;
if (Filename == "") return;
Directory.CreateDirectory(new FileInfo(Filename).Directory.FullName);
if (IsText)
WriteText(Filename);
else
WriteBinary(Filename);
}
public void WriteBackup()
{
if (!Loaded) return;
if (Filename == "") return;
Directory.CreateDirectory(new FileInfo(Filename).Directory.FullName);
string BackupName = Filename;
BackupName = BackupName.Insert(Filename.LastIndexOf("."), String.Format(".{0:yyyy-MM-dd HH.mm.ss}", DateTime.Now));
Global.OSD.AddMessage("Backup movie saved to " + BackupName);
if (IsText)
WriteText(BackupName);
else
WriteBinary(BackupName);
}
/// <summary>
/// Load Header information only for displaying file information in dialogs such as play movie
/// </summary>
/// <returns></returns>
public bool PreLoadText()
{
Loaded = false;
var file = new FileInfo(Filename);
if (file.Exists == false)
return false;
else
{
Header.Clear();
Log.Clear();
}
using (StreamReader sr = file.OpenText())
{
string str = "";
while ((str = sr.ReadLine()) != null)
{
if (str == "" || Header.AddHeaderFromLine(str))
continue;
if (str.StartsWith("subtitle") || str.StartsWith("sub"))
Subtitles.AddSubtitle(str);
else if (str[0] == '|')
{
string frames = sr.ReadToEnd();
int length = str.Length;
// Account for line breaks of either size.
if (frames.IndexOf("\r\n") != -1)
length++;
length++;
// Count the remaining frames and the current one.
this.frames = (frames.Length / length) + 1;
break;
}
else
Header.Comments.Add(str);
}
sr.Close();
}
return true;
}
public bool LoadMovie()
{
var file = new FileInfo(Filename);
if (file.Exists == false)
{
Loaded = false;
return false;
}
return LoadText();
}
public void DumpLogIntoSavestateText(TextWriter writer) public void DumpLogIntoSavestateText(TextWriter writer)
{ {
writer.WriteLine("[Input]"); writer.WriteLine("[Input]");
@ -475,31 +614,8 @@ namespace BizHawk.MultiClient
Log.TruncateStates(stateFrame); Log.TruncateStates(stateFrame);
Log.TruncateMovie(stateFrame); Log.TruncateMovie(stateFrame);
} }
IncrementRerecords();
reader.Close();
}
public void IncrementRerecords()
{
if (RerecordCounting)
{
Rerecords++; Rerecords++;
Header.UpdateRerecordCount(Rerecords); reader.Close();
}
}
public void SetRerecords(int value)
{
Rerecords = value;
Header.SetHeaderLine(MovieHeader.RERECORDS, Rerecords.ToString());
}
public void SetMovieFinished()
{
if (Mode == MOVIEMODE.PLAY)
{
Mode = MOVIEMODE.FINISHED;
}
} }
public string GetTime(bool preLoad) public string GetTime(bool preLoad)
@ -509,7 +625,7 @@ namespace BizHawk.MultiClient
double seconds; double seconds;
if (preLoad) if (preLoad)
{ {
seconds = GetSeconds(frames); seconds = GetSeconds(preload_framecount);
} }
else else
{ {
@ -643,30 +759,22 @@ namespace BizHawk.MultiClient
return true; return true;
} }
public void FlagStartsFromSavestate()
{
StartsFromSavestate = true;
Header.AddHeaderLine(MovieHeader.STARTSFROMSAVESTATE, "1");
}
public void TruncateMovie(int frame)
{
Log.TruncateMovie(frame);
}
#endregion #endregion
#region Private Fields #region Private Fields
private int frames; //Not a a reliable number, used for preloading (when no log has yet been loaded), this is only for quick stat compilation for dialogs such as play movie private int preload_framecount; //Not a a reliable number, used for preloading (when no log has yet been loaded), this is only for quick stat compilation for dialogs such as play movie
private MovieLog Log = new MovieLog(); private MovieLog Log = new MovieLog();
private int lastlog; private int lastlog;
private int rerecords;
private bool statecapturing;
private bool startsfromsavestate;
private enum MOVIEMODE { INACTIVE, PLAY, RECORD, FINISHED };
private MOVIEMODE Mode = MOVIEMODE.INACTIVE;
#endregion #endregion
#region Private Methods #region Helpers
private void WriteText(string file) private void WriteText(string file)
{ {
@ -956,16 +1064,22 @@ namespace BizHawk.MultiClient
private int CompareLength(Movie Other) private int CompareLength(Movie Other)
{ {
int otherLength = Other.frames; int otherLength = Other.preload_framecount;
int thisLength = this.frames; int thisLength = this.preload_framecount;
if (thisLength < otherLength) if (thisLength < otherLength)
{
return -1; return -1;
}
else if (thisLength > otherLength) else if (thisLength > otherLength)
{
return 1; return 1;
}
else else
{
return 0; return 0;
} }
}
#endregion #endregion
} }

View File

@ -120,7 +120,7 @@ namespace BizHawk.MultiClient
case '1': case '1':
break; break;
case '2': case '2':
if (m.TotalFrames != 0) if (m.Frames != 0)
warningMsg = "hard reset"; warningMsg = "hard reset";
break; break;
case '4': case '4':
@ -196,7 +196,8 @@ namespace BizHawk.MultiClient
{ {
errorMsg = ""; errorMsg = "";
warningMsg = ""; warningMsg = "";
Movie m = new Movie(path + "." + Global.Config.MovieExtension, MOVIEMODE.PLAY); Movie m = new Movie(path + "." + Global.Config.MovieExtension);
m.Play();
FileInfo file = new FileInfo(path); FileInfo file = new FileInfo(path);
StreamReader sr = file.OpenText(); StreamReader sr = file.OpenText();
string emulator = ""; string emulator = "";
@ -264,7 +265,7 @@ namespace BizHawk.MultiClient
{ {
rerecordCount = 0; rerecordCount = 0;
} }
m.SetRerecords(rerecordCount); m.Rerecords = rerecordCount;
} }
else if (line.ToLower().StartsWith("guid")) else if (line.ToLower().StartsWith("guid"))
m.Header.SetHeaderLine(MovieHeader.GUID, ParseHeader(line, "guid")); m.Header.SetHeaderLine(MovieHeader.GUID, ParseHeader(line, "guid"));
@ -346,7 +347,8 @@ namespace BizHawk.MultiClient
{ {
errorMsg = ""; errorMsg = "";
warningMsg = ""; warningMsg = "";
Movie m = new Movie(path + "." + Global.Config.MovieExtension, MOVIEMODE.PLAY); Movie m = new Movie(path + "." + Global.Config.MovieExtension);
m.Play();
FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read); FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read);
BinaryReader r = new BinaryReader(fs); BinaryReader r = new BinaryReader(fs);
// 000 4-byte signature: 46 43 4D 1A "FCM\x1A" // 000 4-byte signature: 46 43 4D 1A "FCM\x1A"
@ -406,7 +408,7 @@ namespace BizHawk.MultiClient
uint frameCount = r.ReadUInt32(); uint frameCount = r.ReadUInt32();
// 010 4-byte little-endian unsigned int: rerecord count // 010 4-byte little-endian unsigned int: rerecord count
uint rerecordCount = r.ReadUInt32(); uint rerecordCount = r.ReadUInt32();
m.SetRerecords((int)rerecordCount); m.Rerecords = (int)rerecordCount;
// 014 4-byte little-endian unsigned int: length of controller data in bytes // 014 4-byte little-endian unsigned int: length of controller data in bytes
uint movieDataSize = r.ReadUInt32(); uint movieDataSize = r.ReadUInt32();
/* /*
@ -601,7 +603,8 @@ namespace BizHawk.MultiClient
{ {
errorMsg = ""; errorMsg = "";
warningMsg = ""; warningMsg = "";
Movie m = new Movie(path + "." + Global.Config.MovieExtension, MOVIEMODE.PLAY); Movie m = new Movie(path + "." + Global.Config.MovieExtension);
m.Play();
FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read); FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read);
BinaryReader r = new BinaryReader(fs); BinaryReader r = new BinaryReader(fs);
// 000 4-byte signature: 46 4D 56 1A "FMV\x1A" // 000 4-byte signature: 46 4D 56 1A "FMV\x1A"
@ -652,7 +655,7 @@ namespace BizHawk.MultiClient
loaded, the number is 0. Famtasia however displays "1" in such case. It always adds 1 to the number found in loaded, the number is 0. Famtasia however displays "1" in such case. It always adds 1 to the number found in
the file. the file.
*/ */
m.SetRerecords(((int)rerecordCount) + 1); m.Rerecords = ((int)rerecordCount) + 1;
// 00E 2-byte little-endian unsigned int: unknown, set to 0000 // 00E 2-byte little-endian unsigned int: unknown, set to 0000
r.ReadInt16(); r.ReadInt16();
// 010 64-byte zero-terminated emulator identifier string // 010 64-byte zero-terminated emulator identifier string
@ -731,7 +734,8 @@ namespace BizHawk.MultiClient
{ {
errorMsg = ""; errorMsg = "";
warningMsg = ""; warningMsg = "";
Movie m = new Movie(path + "." + Global.Config.MovieExtension, MOVIEMODE.PLAY); Movie m = new Movie(path + "." + Global.Config.MovieExtension);
m.Play();
FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read); FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read);
BinaryReader r = new BinaryReader(fs); BinaryReader r = new BinaryReader(fs);
// 000 16-byte signature and format version: "Gens Movie TEST9" // 000 16-byte signature and format version: "Gens Movie TEST9"
@ -749,7 +753,7 @@ namespace BizHawk.MultiClient
m.Header.Comments.Add(EMULATIONORIGIN + " Gens"); m.Header.Comments.Add(EMULATIONORIGIN + " Gens");
// 010 4-byte little-endian unsigned int: rerecord count // 010 4-byte little-endian unsigned int: rerecord count
uint rerecordCount = r.ReadUInt32(); uint rerecordCount = r.ReadUInt32();
m.SetRerecords((int)rerecordCount); m.Rerecords = (int)rerecordCount;
// 014 ASCII-encoded controller config for player 1. '3' or '6'. // 014 ASCII-encoded controller config for player 1. '3' or '6'.
string player1Config = r.ReadStringFixedAscii(1); string player1Config = r.ReadStringFixedAscii(1);
// 015 ASCII-encoded controller config for player 2. '3' or '6'. // 015 ASCII-encoded controller config for player 2. '3' or '6'.
@ -845,7 +849,8 @@ namespace BizHawk.MultiClient
{ {
errorMsg = ""; errorMsg = "";
warningMsg = ""; warningMsg = "";
Movie m = new Movie(path + "." + Global.Config.MovieExtension, MOVIEMODE.PLAY); Movie m = new Movie(path + "." + Global.Config.MovieExtension);
m.Play();
FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read); FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read);
BinaryReader r = new BinaryReader(fs); BinaryReader r = new BinaryReader(fs);
// 000 8-byte "MDFNMOVI" signature // 000 8-byte "MDFNMOVI" signature
@ -873,7 +878,7 @@ namespace BizHawk.MultiClient
m.Header.SetHeaderLine(MovieHeader.GAMENAME, gameName); m.Header.SetHeaderLine(MovieHeader.GAMENAME, gameName);
// 070 uint32 Re-record Count // 070 uint32 Re-record Count
uint rerecordCount = r.ReadUInt32(); uint rerecordCount = r.ReadUInt32();
m.SetRerecords((int)rerecordCount); m.Rerecords = (int)rerecordCount;
// 074 5-byte Console indicator (pce, ngp, pcfx, wswan) // 074 5-byte Console indicator (pce, ngp, pcfx, wswan)
string platform = RemoveNull(r.ReadStringFixedAscii(5)); string platform = RemoveNull(r.ReadStringFixedAscii(5));
Dictionary<string, Dictionary<string, object>> platforms = new Dictionary<string, Dictionary<string, object>>() Dictionary<string, Dictionary<string, object>> platforms = new Dictionary<string, Dictionary<string, object>>()
@ -968,7 +973,8 @@ namespace BizHawk.MultiClient
{ {
errorMsg = ""; errorMsg = "";
warningMsg = ""; warningMsg = "";
Movie m = new Movie(path + "." + Global.Config.MovieExtension, MOVIEMODE.PLAY); Movie m = new Movie(path + "." + Global.Config.MovieExtension);
m.Play();
FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read); FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read);
BinaryReader r = new BinaryReader(fs); BinaryReader r = new BinaryReader(fs);
// 0000: 4-byte signature: "MMV\0" // 0000: 4-byte signature: "MMV\0"
@ -988,7 +994,7 @@ namespace BizHawk.MultiClient
uint frameCount = r.ReadUInt32(); uint frameCount = r.ReadUInt32();
// 000c: 4-byte little endian unsigned int: rerecord count // 000c: 4-byte little endian unsigned int: rerecord count
uint rerecordCount = r.ReadUInt32(); uint rerecordCount = r.ReadUInt32();
m.SetRerecords((int)rerecordCount); m.Rerecords = (int)rerecordCount;
// 0010: 4-byte little endian flag: begin from reset? // 0010: 4-byte little endian flag: begin from reset?
uint reset = r.ReadUInt32(); uint reset = r.ReadUInt32();
if (reset == 0) if (reset == 0)
@ -1083,7 +1089,8 @@ namespace BizHawk.MultiClient
{ {
errorMsg = ""; errorMsg = "";
warningMsg = ""; warningMsg = "";
Movie m = new Movie(path + "." + Global.Config.MovieExtension, MOVIEMODE.PLAY); Movie m = new Movie(path + "." + Global.Config.MovieExtension);
m.Play();
FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read); FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read);
BinaryReader r = new BinaryReader(fs); BinaryReader r = new BinaryReader(fs);
// 000 4-byte signature: 4E 53 53 1A "NSS\x1A" // 000 4-byte signature: 4E 53 53 1A "NSS\x1A"
@ -1240,7 +1247,7 @@ namespace BizHawk.MultiClient
m.Header.SetHeaderLine("PAL", pal.ToString()); m.Header.SetHeaderLine("PAL", pal.ToString());
// 004 4-byte little-endian unsigned int: rerecord count // 004 4-byte little-endian unsigned int: rerecord count
uint rerecordCount = r.ReadUInt32(); uint rerecordCount = r.ReadUInt32();
m.SetRerecords((int)rerecordCount); m.Rerecords = (int)rerecordCount;
/* /*
008 4-byte little-endian unsigned int: length of movie description 008 4-byte little-endian unsigned int: length of movie description
00C (variable) null-terminated UTF-8 text, movie description (currently not implemented) 00C (variable) null-terminated UTF-8 text, movie description (currently not implemented)
@ -1332,10 +1339,11 @@ namespace BizHawk.MultiClient
// SMV 1.43 file format: http://code.google.com/p/snes9x-rr/wiki/SMV143 // SMV 1.43 file format: http://code.google.com/p/snes9x-rr/wiki/SMV143
private static Movie ImportSMV143(BinaryReader r, string path) private static Movie ImportSMV143(BinaryReader r, string path)
{ {
Movie m = new Movie(path + "." + Global.Config.MovieExtension, MOVIEMODE.PLAY); Movie m = new Movie(path + "." + Global.Config.MovieExtension);
m.Play();
uint GUID = r.ReadUInt32(); uint GUID = r.ReadUInt32();
m.Header.SetHeaderLine(MovieHeader.GUID, GUID.ToString()); //TODO: format to hex string m.Header.SetHeaderLine(MovieHeader.GUID, GUID.ToString()); //TODO: format to hex string
m.SetRerecords((int)r.ReadUInt32()); m.Rerecords = (int)r.ReadUInt32();
uint frameCount = r.ReadUInt32(); uint frameCount = r.ReadUInt32();
byte ControllerFlags = r.ReadByte(); byte ControllerFlags = r.ReadByte();
@ -1387,7 +1395,8 @@ namespace BizHawk.MultiClient
// SMV 1.51 file format: http://code.google.com/p/snes9x-rr/wiki/SMV151 // SMV 1.51 file format: http://code.google.com/p/snes9x-rr/wiki/SMV151
private static Movie ImportSMV151(BinaryReader r, string path) private static Movie ImportSMV151(BinaryReader r, string path)
{ {
Movie m = new Movie(path + "." + Global.Config.MovieExtension, MOVIEMODE.PLAY); Movie m = new Movie(path + "." + Global.Config.MovieExtension);
m.Play();
m.Header.Comments.Add(EMULATIONORIGIN + " Snes9x version 1.51"); m.Header.Comments.Add(EMULATIONORIGIN + " Snes9x version 1.51");
m.Header.Comments.Add(MOVIEORIGIN + " .SMV"); m.Header.Comments.Add(MOVIEORIGIN + " .SMV");
return m; return m;
@ -1395,7 +1404,8 @@ namespace BizHawk.MultiClient
private static Movie ImportSMV152(BinaryReader r, string path) private static Movie ImportSMV152(BinaryReader r, string path)
{ {
Movie m = new Movie(path + "." + Global.Config.MovieExtension, MOVIEMODE.PLAY); Movie m = new Movie(path + "." + Global.Config.MovieExtension);
m.Play();
uint GUID = r.ReadUInt32(); uint GUID = r.ReadUInt32();
m.Header.Comments.Add(EMULATIONORIGIN + " Snes9x version 1.52"); m.Header.Comments.Add(EMULATIONORIGIN + " Snes9x version 1.52");
m.Header.Comments.Add(MOVIEORIGIN + " .SMV"); m.Header.Comments.Add(MOVIEORIGIN + " .SMV");
@ -1407,7 +1417,8 @@ namespace BizHawk.MultiClient
{ {
errorMsg = ""; errorMsg = "";
warningMsg = ""; warningMsg = "";
Movie m = new Movie(path + "." + Global.Config.MovieExtension, MOVIEMODE.PLAY); Movie m = new Movie(path + "." + Global.Config.MovieExtension);
m.Play();
FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read); FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read);
BinaryReader r = new BinaryReader(fs); BinaryReader r = new BinaryReader(fs);
// 000 4-byte signature: 56 42 4D 1A "VBM\x1A" // 000 4-byte signature: 56 42 4D 1A "VBM\x1A"
@ -1438,7 +1449,7 @@ namespace BizHawk.MultiClient
uint frameCount = r.ReadUInt32(); uint frameCount = r.ReadUInt32();
// 010 4-byte little-endian unsigned int: rerecord count // 010 4-byte little-endian unsigned int: rerecord count
uint rerecordCount = r.ReadUInt32(); uint rerecordCount = r.ReadUInt32();
m.SetRerecords((int)rerecordCount); m.Rerecords = (int)rerecordCount;
// 014 1-byte flags: (movie start flags) // 014 1-byte flags: (movie start flags)
byte flags = r.ReadByte(); byte flags = r.ReadByte();
// bit 0: if "1", movie starts from an embedded "quicksave" snapshot // bit 0: if "1", movie starts from an embedded "quicksave" snapshot
@ -1633,7 +1644,8 @@ namespace BizHawk.MultiClient
{ {
errorMsg = ""; errorMsg = "";
warningMsg = ""; warningMsg = "";
Movie m = new Movie(path + "." + Global.Config.MovieExtension, MOVIEMODE.PLAY); Movie m = new Movie(path + "." + Global.Config.MovieExtension);
m.Play();
FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read); FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read);
BinaryReader r = new BinaryReader(fs); BinaryReader r = new BinaryReader(fs);
// 000 12-byte signature: "VirtuaNES MV" // 000 12-byte signature: "VirtuaNES MV"
@ -1688,7 +1700,7 @@ namespace BizHawk.MultiClient
r.ReadUInt64(); r.ReadUInt64();
// 01C 4-byte little-endian integer: rerecord count // 01C 4-byte little-endian integer: rerecord count
uint rerecordCount = r.ReadUInt32(); uint rerecordCount = r.ReadUInt32();
m.SetRerecords((int)rerecordCount); m.Rerecords = (int)rerecordCount;
/* /*
020 BYTE RenderMethod 020 BYTE RenderMethod
0=POST_ALL,1=PRE_ALL 0=POST_ALL,1=PRE_ALL

View File

@ -45,7 +45,7 @@ namespace BizHawk.MultiClient
/// </summary> /// </summary>
public void LatchInputFromLog() public void LatchInputFromLog()
{ {
string loggedFrame = Movie.GetInputFrame(Global.Emulator.Frame); string loggedFrame = Movie.GetInput(Global.Emulator.Frame);
MovieControllerAdapter.SetControllersAsMnemonic(loggedFrame); MovieControllerAdapter.SetControllersAsMnemonic(loggedFrame);
} }
} }

View File

@ -18,11 +18,8 @@
components.Dispose(); components.Dispose();
} }
//Todo remove once save state log memory issues are fixed Global.MovieSession.Movie.StateCapturing = false;
Global.MovieSession.Movie.TastudioOn = false; Global.MainForm.StopOnFrame = Global.MovieSession.Movie.Frames; //TODO: remove this StopOnFrame stuff
Global.MovieSession.Movie.ClearStates();
Global.MainForm.StopOnFrame = Global.MovieSession.Movie.TotalFrames;
base.Dispose(disposing); base.Dispose(disposing);
} }

View File

@ -63,14 +63,18 @@ namespace BizHawk.MultiClient
{ {
if (!this.IsHandleCreated || this.IsDisposed) return; if (!this.IsHandleCreated || this.IsDisposed) return;
TASView.BlazingFast = true; TASView.BlazingFast = true;
if (Global.MovieSession.Movie.Mode == MOVIEMODE.INACTIVE) if (Global.MovieSession.Movie.IsActive)
TASView.ItemCount = 0;
else
DisplayList();
if (Global.MovieSession.Movie.Mode == MOVIEMODE.PLAY)
{ {
string str = Global.MovieSession.Movie.GetInputFrame(Global.Emulator.Frame); DisplayList();
}
else
{
TASView.ItemCount = 0;
}
if (Global.MovieSession.Movie.IsPlaying && !Global.MovieSession.Movie.IsFinished)
{
string str = Global.MovieSession.Movie.GetInput(Global.Emulator.Frame);
if (Global.Config.TASUpdatePads == true && str != "") if (Global.Config.TASUpdatePads == true && str != "")
{ {
switch (Global.Emulator.SystemId) switch (Global.Emulator.SystemId)
@ -126,9 +130,9 @@ namespace BizHawk.MultiClient
color = Color.LightGreen; //special case for frame 0. Normally we need to go back an extra frame, but for frame 0 we can reload the rom. color = Color.LightGreen; //special case for frame 0. Normally we need to go back an extra frame, but for frame 0 we can reload the rom.
if (index > Global.MovieSession.Movie.StateFirstIndex && index <= Global.MovieSession.Movie.StateLastIndex) if (index > Global.MovieSession.Movie.StateFirstIndex && index <= Global.MovieSession.Movie.StateLastIndex)
color = Color.LightGreen; color = Color.LightGreen;
if ("" != Global.MovieSession.Movie.GetInputFrame(index) && if ("" != Global.MovieSession.Movie.GetInput(index) &&
Global.COMMANDS[Global.MovieInputSourceAdapter.Type.Name].ContainsKey("Lag") && Global.COMMANDS[Global.MovieInputSourceAdapter.Type.Name].ContainsKey("Lag") &&
Global.MovieSession.Movie.GetInputFrame(index)[1] == Global.COMMANDS[Global.MovieInputSourceAdapter.Type.Name]["Lag"][0]) Global.MovieSession.Movie.GetInput(index)[1] == Global.COMMANDS[Global.MovieInputSourceAdapter.Type.Name]["Lag"][0])
color = Color.Pink; color = Color.Pink;
if (index == Global.Emulator.Frame) if (index == Global.Emulator.Frame)
{ {
@ -141,19 +145,19 @@ namespace BizHawk.MultiClient
text = ""; text = "";
//If this is just for an actual frame and not just the list view cursor at the end //If this is just for an actual frame and not just the list view cursor at the end
if (Global.MovieSession.Movie.TotalFrames != index) if (Global.MovieSession.Movie.Frames != index)
{ {
if (column == 0) if (column == 0)
text = String.Format("{0:#,##0}", index); text = String.Format("{0:#,##0}", index);
if (column == 1) if (column == 1)
text = Global.MovieSession.Movie.GetInputFrame(index); text = Global.MovieSession.Movie.GetInput(index);
} }
} }
private void DisplayList() private void DisplayList()
{ {
TASView.ItemCount = Global.MovieSession.Movie.TotalFrames; TASView.ItemCount = Global.MovieSession.Movie.Frames;
if (Global.MovieSession.Movie.TotalFrames == Global.Emulator.Frame && Global.MovieSession.Movie.StateLastIndex == Global.Emulator.Frame - 1) if (Global.MovieSession.Movie.Frames == Global.Emulator.Frame && Global.MovieSession.Movie.StateLastIndex == Global.Emulator.Frame - 1)
{ {
//If we're at the end of the movie add one to show the cursor as a blank frame //If we're at the end of the movie add one to show the cursor as a blank frame
TASView.ItemCount++; TASView.ItemCount++;
@ -178,9 +182,9 @@ namespace BizHawk.MultiClient
Global.MainForm.PauseEmulator(); Global.MainForm.PauseEmulator();
Engaged = true; Engaged = true;
Global.OSD.AddMessage("TAStudio engaged"); Global.OSD.AddMessage("TAStudio engaged");
if (Global.MovieSession.Movie.Mode != MOVIEMODE.INACTIVE) if (Global.MovieSession.Movie.IsActive)
{ {
Global.MovieSession.Movie.TastudioOn = true; Global.MovieSession.Movie.StateCapturing = true;
Global.MainForm.StopOnFrame = -1; Global.MainForm.StopOnFrame = -1;
ReadOnlyCheckBox.Checked = Global.MainForm.ReadOnly; ReadOnlyCheckBox.Checked = Global.MainForm.ReadOnly;
} }
@ -357,10 +361,10 @@ namespace BizHawk.MultiClient
private void RewindButton_Click(object sender, EventArgs e) private void RewindButton_Click(object sender, EventArgs e)
{ {
if (Global.MovieSession.Movie.Mode == MOVIEMODE.FINISHED || Global.MovieSession.Movie.Mode == MOVIEMODE.INACTIVE) if (Global.MovieSession.Movie.IsFinished || !Global.MovieSession.Movie.IsActive)
{ {
Global.MainForm.Rewind(1); Global.MainForm.Rewind(1);
if (Global.Emulator.Frame <= Global.MovieSession.Movie.TotalFrames) if (Global.Emulator.Frame <= Global.MovieSession.Movie.Frames)
{ {
Global.MovieSession.Movie.StartPlayback(); Global.MovieSession.Movie.StartPlayback();
} }
@ -389,9 +393,9 @@ namespace BizHawk.MultiClient
Global.MainForm.SetReadOnly(true); Global.MainForm.SetReadOnly(true);
ReadOnlyCheckBox.BackColor = System.Drawing.SystemColors.Control; ReadOnlyCheckBox.BackColor = System.Drawing.SystemColors.Control;
if (Global.MovieSession.Movie.Mode != MOVIEMODE.INACTIVE) if (Global.MovieSession.Movie.IsActive)
{ {
Global.MovieSession.Movie.Mode = MOVIEMODE.PLAY; Global.MovieSession.Movie.Play();
toolTip1.SetToolTip(this.ReadOnlyCheckBox, "Currently Read-Only Mode"); toolTip1.SetToolTip(this.ReadOnlyCheckBox, "Currently Read-Only Mode");
} }
} }
@ -399,9 +403,9 @@ namespace BizHawk.MultiClient
{ {
Global.MainForm.SetReadOnly(false); Global.MainForm.SetReadOnly(false);
ReadOnlyCheckBox.BackColor = Color.LightCoral; ReadOnlyCheckBox.BackColor = Color.LightCoral;
if (Global.MovieSession.Movie.Mode != MOVIEMODE.INACTIVE) if (Global.MovieSession.Movie.IsActive)
{ {
Global.MovieSession.Movie.Mode = MOVIEMODE.RECORD; Global.MovieSession.Movie.Record();
toolTip1.SetToolTip(this.ReadOnlyCheckBox, "Currently Read+Write Mode"); toolTip1.SetToolTip(this.ReadOnlyCheckBox, "Currently Read+Write Mode");
} }
} }
@ -421,7 +425,7 @@ namespace BizHawk.MultiClient
} }
else else
{ {
Global.MainForm.StopOnFrame = Global.MovieSession.Movie.TotalFrames; Global.MainForm.StopOnFrame = Global.MovieSession.Movie.Frames;
} }
this.FastFowardToEnd.Checked ^= true; this.FastFowardToEnd.Checked ^= true;
@ -495,7 +499,7 @@ namespace BizHawk.MultiClient
if ("" != fileName) if ("" != fileName)
{ {
Global.MovieSession.Movie.UpdateFileName(fileName); Global.MovieSession.Movie.Filename = fileName;
Global.MovieSession.Movie.WriteMovie(); Global.MovieSession.Movie.WriteMovie();
} }
} }
@ -668,7 +672,7 @@ namespace BizHawk.MultiClient
ListView.SelectedIndexCollection list = TASView.SelectedIndices; ListView.SelectedIndexCollection list = TASView.SelectedIndices;
for (int index = 0; index < list.Count; index++) for (int index = 0; index < list.Count; index++)
{ {
Global.MovieSession.Movie.InsertFrame(Global.MovieSession.Movie.GetInputFrame(list[index]), list[index]); Global.MovieSession.Movie.InsertFrame(Global.MovieSession.Movie.GetInput(list[index]), list[index]);
} }
UpdateValues(); UpdateValues();
@ -769,7 +773,7 @@ namespace BizHawk.MultiClient
{ {
ClipboardEntry entry = new ClipboardEntry(); ClipboardEntry entry = new ClipboardEntry();
entry.frame = list[i]; entry.frame = list[i];
entry.inputstr = Global.MovieSession.Movie.GetInputFrame(list[i]); entry.inputstr = Global.MovieSession.Movie.GetInput(list[i]);
Clipboard.Add(entry); Clipboard.Add(entry);
} }
UpdateSlicerDisplay(); UpdateSlicerDisplay();
@ -853,7 +857,7 @@ namespace BizHawk.MultiClient
{ {
ClipboardEntry entry = new ClipboardEntry(); ClipboardEntry entry = new ClipboardEntry();
entry.frame = list[i]; entry.frame = list[i];
entry.inputstr = Global.MovieSession.Movie.GetInputFrame(list[i]); entry.inputstr = Global.MovieSession.Movie.GetInput(list[i]);
Clipboard.Add(entry); Clipboard.Add(entry);
Global.MovieSession.Movie.DeleteFrame(list[0]); Global.MovieSession.Movie.DeleteFrame(list[0]);
} }