This commit is contained in:
adelikat 2015-07-21 19:45:26 -04:00
commit 4629233c74
6 changed files with 86 additions and 88 deletions

View File

@ -1,56 +1,56 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Drawing; using System.Drawing;
using BizHawk.Emulation.Common; using BizHawk.Emulation.Common;
using BizHawk.Bizware.BizwareGL; using BizHawk.Bizware.BizwareGL;
namespace BizHawk.Client.EmuHawk namespace BizHawk.Client.Common
{ {
public class BitmapBufferVideoProvider : IVideoProvider, IDisposable public class BitmapBufferVideoProvider : IVideoProvider, IDisposable
{ {
BitmapBuffer bb; BitmapBuffer bb;
public BitmapBufferVideoProvider(BitmapBuffer bb) public BitmapBufferVideoProvider(BitmapBuffer bb)
{ {
this.bb = bb; this.bb = bb;
} }
public void Dispose() public void Dispose()
{ {
if (bb != null) bb.Dispose(); if (bb != null) bb.Dispose();
bb = null; bb = null;
} }
public int[] GetVideoBuffer() public int[] GetVideoBuffer()
{ {
return bb.Pixels; return bb.Pixels;
} }
public int VirtualWidth public int VirtualWidth
{ {
get { return bb.Width; } get { return bb.Width; }
} }
public int VirtualHeight public int VirtualHeight
{ {
get { return bb.Height; } get { return bb.Height; }
} }
public int BufferWidth public int BufferWidth
{ {
get { return bb.Width; } get { return bb.Width; }
} }
public int BufferHeight public int BufferHeight
{ {
get { return bb.Height; } get { return bb.Height; }
} }
public int BackgroundColor public int BackgroundColor
{ {
get { return 0; } get { return 0; }
} }
} }
} }

View File

@ -103,6 +103,7 @@
<Compile Include="7z\SevenZipSfx.cs" /> <Compile Include="7z\SevenZipSfx.cs" />
<Compile Include="7z\StreamWrappers.cs" /> <Compile Include="7z\StreamWrappers.cs" />
<Compile Include="BinarySaveStates.cs" /> <Compile Include="BinarySaveStates.cs" />
<Compile Include="BitmapBufferVideoProvider.cs" />
<Compile Include="config\Binding.cs" /> <Compile Include="config\Binding.cs" />
<Compile Include="config\Config.cs" /> <Compile Include="config\Config.cs" />
<Compile Include="config\ConfigService.cs" /> <Compile Include="config\ConfigService.cs" />

View File

@ -143,6 +143,25 @@ namespace BizHawk.Client.Common
} }
} }
public unsafe static void Copy(IVideoProvider src, IVideoProvider dst)
{
fixed (int* srcp = src.GetVideoBuffer(), dstp = dst.GetVideoBuffer())
{
Blit(new BMP
{
Data = srcp,
Width = src.BufferWidth,
Height = src.BufferHeight
},
new BMP
{
Data = dstp,
Width = src.BufferWidth,
Height = src.BufferHeight
});
}
}
public unsafe static bool Load(IVideoProvider v, Stream s) public unsafe static bool Load(IVideoProvider v, Stream s)
{ {
var bf = BITMAPFILEHEADER.FromStream(s); var bf = BITMAPFILEHEADER.FromStream(s);

View File

@ -3,6 +3,7 @@ using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using Newtonsoft.Json; using Newtonsoft.Json;
using BizHawk.Bizware.BizwareGL;
namespace BizHawk.Client.Common namespace BizHawk.Client.Common
{ {
@ -11,7 +12,7 @@ namespace BizHawk.Client.Common
public int Frame { get; set; } public int Frame { get; set; }
public byte[] CoreData { get; set; } public byte[] CoreData { get; set; }
public List<string> InputLog { get; set; } public List<string> InputLog { get; set; }
public int[] OSDFrameBuffer { get; set; } public BitmapBuffer OSDFrameBuffer { get; set; }
public TasLagLog LagLog { get; set; } public TasLagLog LagLog { get; set; }
} }
@ -42,15 +43,8 @@ namespace BizHawk.Client.Common
}); });
bs.PutLump(nframebuffer, delegate(Stream s) bs.PutLump(nframebuffer, delegate(Stream s)
{ {
// todo: do we want to do something more clever here? var vp = new BitmapBufferVideoProvider(b.OSDFrameBuffer);
byte[] buff = new byte[2048]; QuickBmpFile.Save(vp, s, 160, 120); // todo: choose size more smarterly
var src = b.OSDFrameBuffer;
for (int i = 0; i < src.Length; i += 512)
{
int n = Math.Min(512, src.Length - i);
Buffer.BlockCopy(src, i * 4, buff, 0, n * 4);
s.Write(buff, 0, n * 4);
}
}); });
bs.PutLump(nlaglog, delegate(BinaryWriter bw) bs.PutLump(nlaglog, delegate(BinaryWriter bw)
{ {
@ -103,15 +97,9 @@ namespace BizHawk.Client.Common
bl.GetLump(nframebuffer, true, delegate(Stream s, long length) bl.GetLump(nframebuffer, true, delegate(Stream s, long length)
{ {
int[] dst = new int[length / 4]; b.OSDFrameBuffer = new BitmapBuffer(160, 120); // todo: choose size more smarterly
byte[] buff = new byte[2048]; var vp = new BitmapBufferVideoProvider(b.OSDFrameBuffer);
for (int i = 0; i < dst.Length; i++) QuickBmpFile.Load(vp, s);
{
int n = Math.Min(512, dst.Length - i);
s.Read(buff, 0, n * 4);
Buffer.BlockCopy(buff, 0, dst, i * 4, n * 4);
}
b.OSDFrameBuffer = dst;
}); });
bl.GetLump(nlaglog, true, delegate(BinaryReader br) bl.GetLump(nlaglog, true, delegate(BinaryReader br)

View File

@ -131,7 +131,6 @@
</Compile> </Compile>
<Compile Include="AVOut\AviWriter.cs" /> <Compile Include="AVOut\AviWriter.cs" />
<Compile Include="AVOut\AVSync.cs" /> <Compile Include="AVOut\AVSync.cs" />
<Compile Include="AVOut\BitmapBufferVideoProvder.cs" />
<Compile Include="AVOut\BmpVideoProvder.cs" /> <Compile Include="AVOut\BmpVideoProvder.cs" />
<Compile Include="AVOut\FFmpegWriter.cs" /> <Compile Include="AVOut\FFmpegWriter.cs" />
<Compile Include="AVOut\FFmpegWriterForm.cs"> <Compile Include="AVOut\FFmpegWriterForm.cs">

View File

@ -81,8 +81,8 @@ namespace BizHawk.Client.EmuHawk
Frame = Global.Emulator.Frame, Frame = Global.Emulator.Frame,
CoreData = (byte[])((Global.Emulator as IStatable).SaveStateBinary().Clone()), CoreData = (byte[])((Global.Emulator as IStatable).SaveStateBinary().Clone()),
InputLog = Tastudio.CurrentTasMovie.InputLog.ToList(), InputLog = Tastudio.CurrentTasMovie.InputLog.ToList(),
//OSDFrameBuffer = GlobalWin.MainForm.CurrentFrameBuffer(captureOSD: true), OSDFrameBuffer = GlobalWin.MainForm.CaptureOSD(),
OSDFrameBuffer = (int[])(Global.Emulator.VideoProvider().GetVideoBuffer().Clone()), //OSDFrameBuffer = (int[])(Global.Emulator.VideoProvider().GetVideoBuffer().Clone()),
LagLog = Tastudio.CurrentTasMovie.TasLagLog.Clone() LagLog = Tastudio.CurrentTasMovie.TasLagLog.Clone()
}; };
@ -122,15 +122,6 @@ namespace BizHawk.Client.EmuHawk
} }
} }
private void Temp(int[] framebuffer)
{
var buff = Global.Emulator.VideoProvider().GetVideoBuffer();
for (int i = 0; i < buff.Length; i++)
{
buff[i] = framebuffer[i];
}
}
private void LoadBranch(TasBranch branch) private void LoadBranch(TasBranch branch)
{ {
Tastudio.CurrentTasMovie.LoadBranch(branch); Tastudio.CurrentTasMovie.LoadBranch(branch);
@ -138,7 +129,7 @@ namespace BizHawk.Client.EmuHawk
var stateInfo = new KeyValuePair<int, byte[]>(branch.Frame, branch.CoreData); var stateInfo = new KeyValuePair<int, byte[]>(branch.Frame, branch.CoreData);
Tastudio.LoadState(stateInfo); Tastudio.LoadState(stateInfo);
//SavestateManager.PopulateFramebuffer(branch.OSDFrameBuffer); //SavestateManager.PopulateFramebuffer(branch.OSDFrameBuffer);
Temp(branch.OSDFrameBuffer); //Temp(branch.OSDFrameBuffer);
GlobalWin.MainForm.PauseEmulator(); GlobalWin.MainForm.PauseEmulator();
GlobalWin.MainForm.PauseOnFrame = null; GlobalWin.MainForm.PauseOnFrame = null;
Tastudio.RefreshDialog(); Tastudio.RefreshDialog();