TAStudio - when creating a power-on movie make a savestate on frame 0, if starting from savestate, use the savestate from the movie as frame 0 in the greenzone
This commit is contained in:
parent
c571d07069
commit
103de3d34f
|
@ -12,13 +12,14 @@ namespace BizHawk.Client.Common
|
||||||
public sealed partial class TasMovie : Bk2Movie
|
public sealed partial class TasMovie : Bk2Movie
|
||||||
{
|
{
|
||||||
private List<bool> LagLog = new List<bool>();
|
private List<bool> LagLog = new List<bool>();
|
||||||
private readonly TasStateManager StateManager = new TasStateManager();
|
private readonly TasStateManager StateManager;
|
||||||
|
|
||||||
public TasMovie(string path) : base(path) { }
|
public TasMovie(string path) : base(path) { }
|
||||||
|
|
||||||
public TasMovie()
|
public TasMovie()
|
||||||
: base()
|
: base()
|
||||||
{
|
{
|
||||||
|
StateManager = new TasStateManager(this);
|
||||||
Header[HeaderKeys.MOVIEVERSION] = "BizHawk v2.0 Tasproj v1.0";
|
Header[HeaderKeys.MOVIEVERSION] = "BizHawk v2.0 Tasproj v1.0";
|
||||||
Markers = new TasMovieMarkerList();
|
Markers = new TasMovieMarkerList();
|
||||||
Markers.Add(0, StartsFromSavestate ? "Savestate" : "Power on");
|
Markers.Add(0, StartsFromSavestate ? "Savestate" : "Power on");
|
||||||
|
@ -229,5 +230,13 @@ namespace BizHawk.Client.Common
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Captures the current frame into the greenzone
|
||||||
|
/// </summary>
|
||||||
|
public void CaptureCurrentState()
|
||||||
|
{
|
||||||
|
StateManager.Capture();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,8 +15,11 @@ namespace BizHawk.Client.Common
|
||||||
{
|
{
|
||||||
private readonly SortedDictionary<int, byte[]> States = new SortedDictionary<int, byte[]>();
|
private readonly SortedDictionary<int, byte[]> States = new SortedDictionary<int, byte[]>();
|
||||||
|
|
||||||
public TasStateManager()
|
private readonly TasMovie _movie;
|
||||||
|
|
||||||
|
public TasStateManager(TasMovie movie)
|
||||||
{
|
{
|
||||||
|
_movie = movie;
|
||||||
Settings = new ManagerSettings();
|
Settings = new ManagerSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,6 +34,11 @@ namespace BizHawk.Client.Common
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
|
if (frame == 0 && _movie.StartsFromSavestate)
|
||||||
|
{
|
||||||
|
return _movie.BinarySavestate;
|
||||||
|
}
|
||||||
|
|
||||||
if (States.ContainsKey(frame))
|
if (States.ContainsKey(frame))
|
||||||
{
|
{
|
||||||
return States[frame];
|
return States[frame];
|
||||||
|
|
|
@ -125,6 +125,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
{
|
{
|
||||||
NewTasMovie();
|
NewTasMovie();
|
||||||
GlobalWin.MainForm.StartNewMovie(_tas, record: true);
|
GlobalWin.MainForm.StartNewMovie(_tas, record: true);
|
||||||
|
_tas.CaptureCurrentState();
|
||||||
}
|
}
|
||||||
|
|
||||||
EngageTastudio();
|
EngageTastudio();
|
||||||
|
@ -289,11 +290,19 @@ namespace BizHawk.Client.EmuHawk
|
||||||
// If in greenzone, loadstate
|
// If in greenzone, loadstate
|
||||||
// If near a greenzone item, load and emulate
|
// If near a greenzone item, load and emulate
|
||||||
// Do capturing and recording as needed
|
// Do capturing and recording as needed
|
||||||
if (_tas[frame - 1].HasState) // Go back 1 frame and emulate
|
|
||||||
|
var goToFrame = frame == 0 ? 0 : frame - 1;
|
||||||
|
|
||||||
|
if (_tas[goToFrame].HasState) // Go back 1 frame and emulate
|
||||||
{
|
{
|
||||||
_tas.SwitchToPlay();
|
_tas.SwitchToPlay();
|
||||||
Global.Emulator.LoadStateBinary(new BinaryReader(new MemoryStream(_tas[frame].State.ToArray())));
|
Global.Emulator.LoadStateBinary(new BinaryReader(new MemoryStream(_tas[goToFrame].State.ToArray())));
|
||||||
Global.Emulator.FrameAdvance(true);
|
|
||||||
|
if (goToFrame > 0) // We can't emulate up to frame 0!
|
||||||
|
{
|
||||||
|
Global.Emulator.FrameAdvance(true);
|
||||||
|
}
|
||||||
|
|
||||||
GlobalWin.DisplayManager.NeedsToPaint = true;
|
GlobalWin.DisplayManager.NeedsToPaint = true;
|
||||||
TasView.ensureVisible(frame);
|
TasView.ensureVisible(frame);
|
||||||
RefreshDialog();
|
RefreshDialog();
|
||||||
|
|
Loading…
Reference in New Issue