revert bd9ec3c57d
, fix bk2 framebuffer load
This commit is contained in:
parent
4ad7736ca7
commit
0af4d125b2
|
@ -1,17 +0,0 @@
|
|||
using System.IO;
|
||||
|
||||
using BizHawk.Emulation.Common;
|
||||
|
||||
namespace BizHawk.Client.Common
|
||||
{
|
||||
public interface IQuickBmpFile
|
||||
{
|
||||
void Copy(IVideoProvider src, IVideoProvider dst);
|
||||
|
||||
bool Load(IVideoProvider v, Stream s);
|
||||
|
||||
bool LoadAuto(Stream s, out IVideoProvider vp);
|
||||
|
||||
void Save(IVideoProvider v, Stream s, int w, int h);
|
||||
}
|
||||
}
|
|
@ -2,18 +2,14 @@
|
|||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
using BizHawk.Client.Common;
|
||||
using BizHawk.Common;
|
||||
using BizHawk.Emulation.Common;
|
||||
|
||||
// ReSharper disable FieldCanBeMadeReadOnly.Local
|
||||
// ReSharper disable InconsistentNaming
|
||||
// ReSharper disable StyleCop.SA1304
|
||||
// ReSharper disable StyleCop.SA1307
|
||||
// ReSharper disable StyleCop.SA1401
|
||||
namespace BizHawk.Client.EmuHawk
|
||||
namespace BizHawk.Client.Common
|
||||
{
|
||||
public readonly struct QuickBmpFile : IQuickBmpFile
|
||||
public readonly struct QuickBmpFile
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
private class BITMAPFILEHEADER
|
||||
|
@ -332,14 +328,6 @@ namespace BizHawk.Client.EmuHawk
|
|||
s.Write(dst, 0, dst.Length);
|
||||
}
|
||||
|
||||
public static readonly QuickBmpFile INSTANCE = default;
|
||||
|
||||
readonly void IQuickBmpFile.Copy(IVideoProvider src, IVideoProvider dst) => Copy(src, dst);
|
||||
|
||||
readonly bool IQuickBmpFile.Load(IVideoProvider v, Stream s) => Load(v, s);
|
||||
|
||||
public readonly bool LoadAuto(Stream s, out IVideoProvider vp) => Load(vp = new LoadedBMP(), s);
|
||||
|
||||
readonly void IQuickBmpFile.Save(IVideoProvider v, Stream s, int w, int h) => Save(v, s, w, h);
|
||||
public static bool LoadAuto(Stream s, out IVideoProvider vp) => Load(vp = new LoadedBMP(), s);
|
||||
}
|
||||
}
|
|
@ -17,20 +17,16 @@ namespace BizHawk.Client.Common
|
|||
|
||||
private IMovie _queuedMovie;
|
||||
|
||||
private readonly IQuickBmpFile _quickBmpFile;
|
||||
|
||||
public MovieSession(
|
||||
IMovieConfig settings,
|
||||
string backDirectory,
|
||||
IDialogParent dialogParent,
|
||||
IQuickBmpFile quickBmpFile,
|
||||
Action pauseCallback,
|
||||
Action modeChangedCallback)
|
||||
{
|
||||
Settings = settings;
|
||||
BackupDirectory = backDirectory;
|
||||
_dialogParent = dialogParent;
|
||||
_quickBmpFile = quickBmpFile;
|
||||
_pauseCallback = pauseCallback
|
||||
?? throw new ArgumentNullException(paramName: nameof(pauseCallback));
|
||||
_modeChangedCallback = modeChangedCallback
|
||||
|
@ -313,7 +309,7 @@ namespace BizHawk.Client.Common
|
|||
// TODO: change IMovies to take HawkFiles only and not path
|
||||
if (Path.GetExtension(path)?.EndsWith("tasproj") ?? false)
|
||||
{
|
||||
return new TasMovie(this, path, _quickBmpFile);
|
||||
return new TasMovie(this, path);
|
||||
}
|
||||
|
||||
return new Bk2Movie(this, path);
|
||||
|
|
|
@ -160,9 +160,8 @@ namespace BizHawk.Client.Common
|
|||
bl.GetLump(BinaryStateLump.Framebuffer, false,
|
||||
br =>
|
||||
{
|
||||
var fb = br.ReadAllBytes();
|
||||
SavestateFramebuffer = new int[fb.Length / sizeof(int)];
|
||||
Buffer.BlockCopy(fb, 0, SavestateFramebuffer, 0, fb.Length);
|
||||
QuickBmpFile.LoadAuto(br.BaseStream, out var bmp);
|
||||
SavestateFramebuffer = bmp.GetVideoBuffer();
|
||||
});
|
||||
}
|
||||
else if (StartsFromSaveRam)
|
||||
|
|
|
@ -58,12 +58,9 @@ namespace BizHawk.Client.Common
|
|||
{
|
||||
private readonly ITasMovie _movie;
|
||||
|
||||
private readonly IQuickBmpFile _quickBmpFile;
|
||||
|
||||
public TasBranchCollection(ITasMovie movie, IQuickBmpFile quickBmpFile)
|
||||
public TasBranchCollection(ITasMovie movie)
|
||||
{
|
||||
_movie = movie;
|
||||
_quickBmpFile = quickBmpFile;
|
||||
}
|
||||
|
||||
public int Current { get; set; } = -1;
|
||||
|
@ -155,13 +152,13 @@ namespace BizHawk.Client.Common
|
|||
bs.PutLump(nframebuffer, s =>
|
||||
{
|
||||
var vp = new BitmapBufferVideoProvider(b.OSDFrameBuffer);
|
||||
_quickBmpFile.Save(vp, s, b.OSDFrameBuffer.Width, b.OSDFrameBuffer.Height);
|
||||
QuickBmpFile.Save(vp, s, b.OSDFrameBuffer.Width, b.OSDFrameBuffer.Height);
|
||||
});
|
||||
|
||||
bs.PutLump(ncoreframebuffer, s =>
|
||||
{
|
||||
var vp = new BitmapBufferVideoProvider(b.CoreFrameBuffer);
|
||||
_quickBmpFile.Save(vp, s, b.CoreFrameBuffer.Width, b.CoreFrameBuffer.Height);
|
||||
QuickBmpFile.Save(vp, s, b.CoreFrameBuffer.Width, b.CoreFrameBuffer.Height);
|
||||
});
|
||||
|
||||
bs.PutLump(nmarkers, tw => tw.WriteLine(b.Markers.ToString()));
|
||||
|
@ -241,13 +238,13 @@ namespace BizHawk.Client.Common
|
|||
|
||||
bl.GetLump(nframebuffer, abort: true, (s, _) =>
|
||||
{
|
||||
_quickBmpFile.LoadAuto(s, out var vp);
|
||||
QuickBmpFile.LoadAuto(s, out var vp);
|
||||
b.OSDFrameBuffer = new BitmapBuffer(vp.BufferWidth, vp.BufferHeight, vp.GetVideoBuffer());
|
||||
});
|
||||
|
||||
bl.GetLump(ncoreframebuffer, abort: false, (s, _) =>
|
||||
{
|
||||
_quickBmpFile.LoadAuto(s, out var vp);
|
||||
QuickBmpFile.LoadAuto(s, out var vp);
|
||||
b.CoreFrameBuffer = new BitmapBuffer(vp.BufferWidth, vp.BufferHeight, vp.GetVideoBuffer());
|
||||
});
|
||||
|
||||
|
|
|
@ -18,10 +18,10 @@ namespace BizHawk.Client.Common
|
|||
public const double CurrentVersion = 1.1;
|
||||
|
||||
/// <exception cref="InvalidOperationException">loaded core does not implement <see cref="IStatable"/></exception>
|
||||
internal TasMovie(IMovieSession session, string path, IQuickBmpFile quickBmpFile)
|
||||
internal TasMovie(IMovieSession session, string path)
|
||||
: base(session, path)
|
||||
{
|
||||
Branches = new TasBranchCollection(this, quickBmpFile);
|
||||
Branches = new TasBranchCollection(this);
|
||||
ChangeLog = new TasMovieChangeLog(this);
|
||||
Header[HeaderKeys.MovieVersion] = $"BizHawk v2.0 Tasproj v{CurrentVersion.ToString(CultureInfo.InvariantCulture)}";
|
||||
Markers = new TasMovieMarkerList(this);
|
||||
|
|
|
@ -18,14 +18,11 @@ namespace BizHawk.Client.Common
|
|||
private readonly IVideoProvider _videoProvider;
|
||||
private readonly IMovieSession _movieSession;
|
||||
|
||||
private readonly IQuickBmpFile _quickBmpFile;
|
||||
|
||||
private readonly IDictionary<string, object> _userBag;
|
||||
|
||||
public SavestateFile(
|
||||
IEmulator emulator,
|
||||
IMovieSession movieSession,
|
||||
IQuickBmpFile quickBmpFile,
|
||||
IDictionary<string, object> userBag)
|
||||
{
|
||||
if (!emulator.HasSavestates())
|
||||
|
@ -41,7 +38,6 @@ namespace BizHawk.Client.Common
|
|||
}
|
||||
|
||||
_movieSession = movieSession;
|
||||
_quickBmpFile = quickBmpFile;
|
||||
_userBag = userBag;
|
||||
}
|
||||
|
||||
|
@ -88,7 +84,7 @@ namespace BizHawk.Client.Common
|
|||
|
||||
using (new SimpleTime("Save Framebuffer"))
|
||||
{
|
||||
bs.PutLump(BinaryStateLump.Framebuffer, s => _quickBmpFile.Save(_videoProvider, s, outWidth, outHeight));
|
||||
bs.PutLump(BinaryStateLump.Framebuffer, s => QuickBmpFile.Save(_videoProvider, s, outWidth, outHeight));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -168,7 +164,7 @@ namespace BizHawk.Client.Common
|
|||
|
||||
if (_videoProvider != null)
|
||||
{
|
||||
bl.GetLump(BinaryStateLump.Framebuffer, false, br => PopulateFramebuffer(br, _videoProvider, _quickBmpFile));
|
||||
bl.GetLump(BinaryStateLump.Framebuffer, false, br => PopulateFramebuffer(br, _videoProvider));
|
||||
}
|
||||
|
||||
string userData = "";
|
||||
|
@ -199,13 +195,13 @@ namespace BizHawk.Client.Common
|
|||
return true;
|
||||
}
|
||||
|
||||
private static void PopulateFramebuffer(BinaryReader br, IVideoProvider videoProvider, IQuickBmpFile quickBmpFile)
|
||||
private static void PopulateFramebuffer(BinaryReader br, IVideoProvider videoProvider)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (new SimpleTime("Load Framebuffer"))
|
||||
{
|
||||
quickBmpFile.Load(videoProvider, br.BaseStream);
|
||||
QuickBmpFile.Load(videoProvider, br.BaseStream);
|
||||
}
|
||||
}
|
||||
catch
|
||||
|
|
|
@ -41,9 +41,6 @@ namespace BizHawk.Client.EmuHawk
|
|||
/// <remarks>only referenced from <see cref="PlaybackBox"/></remarks>
|
||||
bool PressRewind { get; set; }
|
||||
|
||||
/// <remarks>only referenced from <see cref="TAStudio"/></remarks>
|
||||
IQuickBmpFile QuickBmpFile { get; }
|
||||
|
||||
/// <remarks>only referenced from <see cref="GenericDebugger"/></remarks>
|
||||
event Action<bool> OnPauseChanged;
|
||||
|
||||
|
|
|
@ -407,7 +407,6 @@ namespace BizHawk.Client.EmuHawk
|
|||
Config.Movies,
|
||||
Config.PathEntries.MovieBackupsAbsolutePath(),
|
||||
this,
|
||||
QuickBmpFile,
|
||||
PauseEmulator,
|
||||
SetMainformMovieInfo);
|
||||
|
||||
|
@ -4235,7 +4234,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
if (!Emulator.HasSavestates()) return false;
|
||||
if (IsSavestateSlave) return Master.LoadState();
|
||||
|
||||
if (!new SavestateFile(Emulator, MovieSession, QuickBmpFile, MovieSession.UserBag).Load(path, this))
|
||||
if (!new SavestateFile(Emulator, MovieSession, MovieSession.UserBag).Load(path, this))
|
||||
{
|
||||
AddOnScreenMessage("Loadstate error!");
|
||||
return false;
|
||||
|
@ -4305,7 +4304,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
try
|
||||
{
|
||||
new SavestateFile(Emulator, MovieSession, QuickBmpFile, MovieSession.UserBag).Create(path, Config.Savestates);
|
||||
new SavestateFile(Emulator, MovieSession, MovieSession.UserBag).Create(path, Config.Savestates);
|
||||
|
||||
EmuClient.OnStateSaved(this, userFriendlyStateName);
|
||||
RA?.OnSaveState(path);
|
||||
|
@ -4851,8 +4850,6 @@ namespace BizHawk.Client.EmuHawk
|
|||
_ = LoadRom(args[0]);
|
||||
}
|
||||
|
||||
public IQuickBmpFile QuickBmpFile { get; } = EmuHawk.QuickBmpFile.INSTANCE;
|
||||
|
||||
private IRetroAchievements RA { get; set; }
|
||||
|
||||
private void OpenRetroAchievements()
|
||||
|
|
|
@ -220,7 +220,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
Movie.LoadBranch(branch);
|
||||
Tastudio.LoadState(new(branch.Frame, new MemoryStream(branch.CoreData, false)));
|
||||
Movie.TasStateManager.Capture(Tastudio.Emulator.Frame, Tastudio.Emulator.AsStatable());
|
||||
Tastudio.MainForm.QuickBmpFile.Copy(new BitmapBufferVideoProvider(branch.CoreFrameBuffer), Tastudio.VideoProvider);
|
||||
QuickBmpFile.Copy(new BitmapBufferVideoProvider(branch.CoreFrameBuffer), Tastudio.VideoProvider);
|
||||
|
||||
if (Tastudio.Settings.OldControlSchemeForBranches && Tastudio.TasPlaybackBox.RecordingMode)
|
||||
Movie.Truncate(branch.Frame);
|
||||
|
|
Loading…
Reference in New Issue