2011-07-22 01:14:13 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.IO;
|
2014-09-27 15:49:39 +00:00
|
|
|
|
using System.Windows.Forms;
|
2011-07-22 01:14:13 +00:00
|
|
|
|
|
2013-10-25 00:57:23 +00:00
|
|
|
|
using BizHawk.Client.Common;
|
2014-04-22 01:16:11 +00:00
|
|
|
|
using BizHawk.Emulation.Common;
|
2014-11-30 16:42:58 +00:00
|
|
|
|
using BizHawk.Emulation.Common.IEmulatorExtensions;
|
2014-05-18 15:54:56 +00:00
|
|
|
|
|
2013-11-03 03:54:37 +00:00
|
|
|
|
namespace BizHawk.Client.EmuHawk
|
2011-07-22 01:14:13 +00:00
|
|
|
|
{
|
|
|
|
|
partial class MainForm
|
|
|
|
|
{
|
2014-09-28 01:05:26 +00:00
|
|
|
|
public bool StartNewMovie(IMovie movie, bool record)
|
2011-07-22 01:14:13 +00:00
|
|
|
|
{
|
2015-03-23 21:16:13 +00:00
|
|
|
|
// SuuperW: Check changes. adelikat: this could break bk2 movies
|
|
|
|
|
// TODO: Clean up the saving process
|
2019-12-21 22:34:29 +00:00
|
|
|
|
if (movie.IsActive() && (movie.Changes || !(movie is TasMovie)))
|
2014-10-25 23:11:55 +00:00
|
|
|
|
{
|
|
|
|
|
movie.Save();
|
|
|
|
|
}
|
|
|
|
|
|
2014-09-27 15:49:39 +00:00
|
|
|
|
try
|
|
|
|
|
{
|
2019-12-20 16:07:08 +00:00
|
|
|
|
MovieSession.QueueNewMovie(movie, record, Emulator);
|
2014-09-27 15:49:39 +00:00
|
|
|
|
}
|
|
|
|
|
catch (MoviePlatformMismatchException ex)
|
|
|
|
|
{
|
2019-11-25 14:37:11 +00:00
|
|
|
|
using var ownerForm = new Form { TopMost = true };
|
2019-11-02 04:29:09 +00:00
|
|
|
|
MessageBox.Show(ownerForm, ex.Message, "Movie/Platform Mismatch", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
2014-09-28 01:05:26 +00:00
|
|
|
|
return false;
|
2014-09-27 15:49:39 +00:00
|
|
|
|
}
|
2014-06-01 00:40:13 +00:00
|
|
|
|
|
2015-11-06 14:31:50 +00:00
|
|
|
|
RebootCore();
|
2012-11-22 03:47:18 +00:00
|
|
|
|
|
2019-12-20 16:07:08 +00:00
|
|
|
|
if (MovieSession.PreviousNES_InQuickNES.HasValue)
|
2014-11-09 17:14:16 +00:00
|
|
|
|
{
|
2019-12-20 16:07:08 +00:00
|
|
|
|
Config.NES_InQuickNES = MovieSession.PreviousNES_InQuickNES.Value;
|
|
|
|
|
MovieSession.PreviousNES_InQuickNES = null;
|
2014-11-09 17:14:16 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-12-20 16:07:08 +00:00
|
|
|
|
if (MovieSession.PreviousSNES_InSnes9x.HasValue)
|
2014-11-09 17:14:16 +00:00
|
|
|
|
{
|
2019-12-20 16:07:08 +00:00
|
|
|
|
Config.SNES_InSnes9x = MovieSession.PreviousSNES_InSnes9x.Value;
|
|
|
|
|
MovieSession.PreviousSNES_InSnes9x = null;
|
2014-11-09 17:14:16 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-12-20 16:07:08 +00:00
|
|
|
|
if (MovieSession.PreviousGBA_UsemGBA.HasValue)
|
2015-06-21 13:32:53 +00:00
|
|
|
|
{
|
2019-12-20 16:07:08 +00:00
|
|
|
|
Config.GBA_UsemGBA = MovieSession.PreviousGBA_UsemGBA.Value;
|
|
|
|
|
MovieSession.PreviousGBA_UsemGBA = null;
|
2015-06-21 13:32:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-12-20 15:29:33 +00:00
|
|
|
|
Config.RecentMovies.Add(movie.Filename);
|
2013-12-14 06:58:09 +00:00
|
|
|
|
|
2016-12-04 17:27:26 +00:00
|
|
|
|
if (Emulator.HasSavestates() && movie.StartsFromSavestate)
|
2011-07-30 20:49:36 +00:00
|
|
|
|
{
|
2014-08-16 15:01:53 +00:00
|
|
|
|
if (movie.TextSavestate != null)
|
2014-08-02 15:32:48 +00:00
|
|
|
|
{
|
2016-12-04 17:27:26 +00:00
|
|
|
|
Emulator.AsStatable().LoadStateText(new StringReader(movie.TextSavestate));
|
2014-08-02 15:32:48 +00:00
|
|
|
|
}
|
2014-06-20 00:39:46 +00:00
|
|
|
|
else
|
2014-08-02 15:32:48 +00:00
|
|
|
|
{
|
2016-12-04 17:27:26 +00:00
|
|
|
|
Emulator.AsStatable().LoadStateBinary(new BinaryReader(new MemoryStream(movie.BinarySavestate, false)));
|
2014-08-02 15:32:48 +00:00
|
|
|
|
}
|
2016-12-04 16:30:51 +00:00
|
|
|
|
|
2016-12-04 17:27:26 +00:00
|
|
|
|
if (movie.SavestateFramebuffer != null && Emulator.HasVideoProvider())
|
2014-10-27 01:14:47 +00:00
|
|
|
|
{
|
|
|
|
|
var b1 = movie.SavestateFramebuffer;
|
2016-12-04 17:27:26 +00:00
|
|
|
|
var b2 = Emulator.AsVideoProvider().GetVideoBuffer();
|
2014-10-27 01:14:47 +00:00
|
|
|
|
int len = Math.Min(b1.Length, b2.Length);
|
|
|
|
|
for (int i = 0; i < len; i++)
|
|
|
|
|
{
|
|
|
|
|
b2[i] = b1[i];
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-12-04 16:30:51 +00:00
|
|
|
|
|
2016-12-04 17:27:26 +00:00
|
|
|
|
Emulator.ResetCounters();
|
2011-07-30 20:49:36 +00:00
|
|
|
|
}
|
2016-12-04 17:27:26 +00:00
|
|
|
|
else if (Emulator.HasSaveRam() && movie.StartsFromSaveRam)
|
2015-07-26 19:41:22 +00:00
|
|
|
|
{
|
2016-12-04 17:27:26 +00:00
|
|
|
|
Emulator.AsSaveRam().StoreSaveRam(movie.SaveRam);
|
2015-07-26 19:41:22 +00:00
|
|
|
|
}
|
2013-12-03 18:08:45 +00:00
|
|
|
|
|
2019-12-20 16:07:08 +00:00
|
|
|
|
MovieSession.RunQueuedMovie(record);
|
2013-12-14 06:58:09 +00:00
|
|
|
|
|
2014-07-07 19:48:58 +00:00
|
|
|
|
SetMainformMovieInfo();
|
|
|
|
|
|
2019-12-20 15:29:33 +00:00
|
|
|
|
Tools.Restart<VirtualpadTool>();
|
2014-09-28 01:05:26 +00:00
|
|
|
|
|
2015-07-19 20:40:55 +00:00
|
|
|
|
|
2019-12-20 16:07:08 +00:00
|
|
|
|
if (MovieSession.Movie.Hash != Game.Hash)
|
2015-07-19 20:40:55 +00:00
|
|
|
|
{
|
2019-12-17 20:55:26 +00:00
|
|
|
|
AddOnScreenMessage("Warning: Movie hash does not match the ROM");
|
2015-07-19 20:40:55 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-12-17 20:55:26 +00:00
|
|
|
|
return !(Emulator is NullEmulator);
|
2011-07-22 01:14:13 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void SetMainformMovieInfo()
|
|
|
|
|
{
|
2019-12-21 22:34:29 +00:00
|
|
|
|
if (MovieSession.Movie.IsPlaying())
|
2011-07-22 01:14:13 +00:00
|
|
|
|
{
|
2013-10-27 15:53:37 +00:00
|
|
|
|
PlayRecordStatusButton.Image = Properties.Resources.Play;
|
|
|
|
|
PlayRecordStatusButton.ToolTipText = "Movie is in playback mode";
|
|
|
|
|
PlayRecordStatusButton.Visible = true;
|
2011-07-22 01:14:13 +00:00
|
|
|
|
}
|
2019-12-21 22:34:29 +00:00
|
|
|
|
else if (MovieSession.Movie.IsRecording())
|
2011-07-22 01:14:13 +00:00
|
|
|
|
{
|
2013-10-27 15:53:37 +00:00
|
|
|
|
PlayRecordStatusButton.Image = Properties.Resources.RecordHS;
|
|
|
|
|
PlayRecordStatusButton.ToolTipText = "Movie is in record mode";
|
|
|
|
|
PlayRecordStatusButton.Visible = true;
|
2011-07-22 01:14:13 +00:00
|
|
|
|
}
|
2019-12-21 22:34:29 +00:00
|
|
|
|
else if (!MovieSession.Movie.IsActive())
|
2011-07-22 01:14:13 +00:00
|
|
|
|
{
|
2013-10-27 15:53:37 +00:00
|
|
|
|
PlayRecordStatusButton.Image = Properties.Resources.Blank;
|
|
|
|
|
PlayRecordStatusButton.ToolTipText = "No movie is active";
|
|
|
|
|
PlayRecordStatusButton.Visible = false;
|
2011-07-22 01:14:13 +00:00
|
|
|
|
}
|
2014-07-21 20:34:53 +00:00
|
|
|
|
|
|
|
|
|
SetWindowText();
|
2014-08-19 15:42:37 +00:00
|
|
|
|
UpdateStatusSlots();
|
2011-07-22 01:14:13 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-11-01 18:52:26 +00:00
|
|
|
|
public void RestartMovie()
|
2011-07-22 01:14:13 +00:00
|
|
|
|
{
|
2017-04-29 19:17:55 +00:00
|
|
|
|
if (IsSlave && Master.WantsToControlRestartMovie)
|
2011-07-22 01:14:13 +00:00
|
|
|
|
{
|
2017-04-29 19:17:55 +00:00
|
|
|
|
Master.RestartMovie();
|
2014-10-26 16:36:50 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2019-12-21 22:34:29 +00:00
|
|
|
|
if (MovieSession.Movie.IsActive())
|
2014-10-26 16:36:50 +00:00
|
|
|
|
{
|
2019-12-20 16:07:08 +00:00
|
|
|
|
StartNewMovie(MovieSession.Movie, false);
|
2019-12-17 20:55:26 +00:00
|
|
|
|
AddOnScreenMessage("Replaying movie file in read-only mode");
|
2014-10-26 16:36:50 +00:00
|
|
|
|
}
|
2011-07-22 01:14:13 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|