more gambatte wrapper stuff
This commit is contained in:
parent
9c71a24666
commit
588d6214d5
|
@ -110,9 +110,10 @@
|
||||||
<Compile Include="Consoles\Coleco\VDP.Mode4.cs" />
|
<Compile Include="Consoles\Coleco\VDP.Mode4.cs" />
|
||||||
<Compile Include="Consoles\Coleco\VDP.ModeTMS.cs" />
|
<Compile Include="Consoles\Coleco\VDP.ModeTMS.cs" />
|
||||||
<Compile Include="Consoles\Coleco\VDP.Tables.cs" />
|
<Compile Include="Consoles\Coleco\VDP.Tables.cs" />
|
||||||
|
<Compile Include="Consoles\Gambatte\Gambatte.cs" />
|
||||||
<Compile Include="Consoles\GB\Graphics.cs" />
|
<Compile Include="Consoles\GB\Graphics.cs" />
|
||||||
<Compile Include="Consoles\GB\Input.cs" />
|
<Compile Include="Consoles\GB\Input.cs" />
|
||||||
<Compile Include="Consoles\GB\LibGambatte.cs" />
|
<Compile Include="Consoles\Gambatte\LibGambatte.cs" />
|
||||||
<Compile Include="Consoles\GB\MemoryMap.cs" />
|
<Compile Include="Consoles\GB\MemoryMap.cs" />
|
||||||
<Compile Include="Consoles\GB\GB.cs" />
|
<Compile Include="Consoles\GB\GB.cs" />
|
||||||
<Compile Include="Consoles\Intellivision\Cartridge.cs" />
|
<Compile Include="Consoles\Intellivision\Cartridge.cs" />
|
||||||
|
|
|
@ -0,0 +1,209 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
|
namespace BizHawk.Emulation.Consoles.Gambatte
|
||||||
|
{
|
||||||
|
public class Gambatte : IEmulator, IVideoProvider
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// internal gambatte state
|
||||||
|
/// </summary>
|
||||||
|
IntPtr GambatteState = IntPtr.Zero;
|
||||||
|
|
||||||
|
|
||||||
|
public Gambatte(byte[] romdata)
|
||||||
|
{
|
||||||
|
// use temp file until we hack up the libgambatte api to take data directly
|
||||||
|
|
||||||
|
using (FileStream fs = new FileStream("gambattetmp.gb", FileMode.OpenOrCreate, FileAccess.Write))
|
||||||
|
{
|
||||||
|
fs.Write(romdata, 0, romdata.Length);
|
||||||
|
}
|
||||||
|
|
||||||
|
GambatteState = LibGambatte.gambatte_create();
|
||||||
|
|
||||||
|
if (GambatteState == IntPtr.Zero)
|
||||||
|
throw new Exception("gambatte_create() returned null???");
|
||||||
|
|
||||||
|
if (LibGambatte.gambatte_load(GambatteState, "gambattetmp.gb", 0) != 0)
|
||||||
|
throw new Exception("gambatte_load() returned non-zero (is this not a gb or gbc rom?)");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public IVideoProvider VideoProvider
|
||||||
|
{
|
||||||
|
get { return this; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public ISoundProvider SoundProvider
|
||||||
|
{
|
||||||
|
get { return new NullSound(); }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static readonly ControllerDefinition GbController = new ControllerDefinition
|
||||||
|
{
|
||||||
|
Name = "Gameboy Controller",
|
||||||
|
BoolButtons =
|
||||||
|
{
|
||||||
|
"Up", "Down", "Left", "Right", "A", "B", "Select", "Start"
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
public ControllerDefinition ControllerDefinition
|
||||||
|
{
|
||||||
|
get { return GbController; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public IController Controller { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
short[] soundscratch = new short[(35112 + 2064) * 2];
|
||||||
|
uint[] videoscratch = new uint[160 * 144];
|
||||||
|
public void FrameAdvance(bool render)
|
||||||
|
{
|
||||||
|
uint nsamp = 35112;
|
||||||
|
|
||||||
|
LibGambatte.gambatte_runfor(GambatteState, videoscratch, 160, soundscratch, ref nsamp);
|
||||||
|
|
||||||
|
// can't convert uint[] to int[], so we do this instead
|
||||||
|
// TODO: lie in the p/invoke layer and claim unsigned* is really int*
|
||||||
|
|
||||||
|
Buffer.BlockCopy(videoscratch, 0, VideoBuffer, 0, VideoBuffer.Length * sizeof(int));
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Frame
|
||||||
|
{
|
||||||
|
get { return 0; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public int LagCount { get; set; }
|
||||||
|
|
||||||
|
public bool IsLagFrame
|
||||||
|
{
|
||||||
|
get { return false; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public string SystemId
|
||||||
|
{
|
||||||
|
get { return "GB"; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool DeterministicEmulation { get; set; }
|
||||||
|
|
||||||
|
public byte[] ReadSaveRam
|
||||||
|
{
|
||||||
|
get { throw new NotImplementedException(); }
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool SaveRamModified
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ResetFrameCounter()
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SaveStateText(System.IO.TextWriter writer)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void LoadStateText(System.IO.TextReader reader)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SaveStateBinary(System.IO.BinaryWriter writer)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void LoadStateBinary(System.IO.BinaryReader reader)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte[] SaveStateBinary()
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public CoreInputComm CoreInputComm{ get; set; }
|
||||||
|
|
||||||
|
CoreOutputComm GbOutputComm = new CoreOutputComm
|
||||||
|
{
|
||||||
|
VsyncNum = 60,
|
||||||
|
VsyncDen = 1,
|
||||||
|
RomStatusAnnotation = "Bizwhackin it up",
|
||||||
|
RomStatusDetails = "LEVAR BURTON"
|
||||||
|
};
|
||||||
|
|
||||||
|
public CoreOutputComm CoreOutputComm
|
||||||
|
{
|
||||||
|
get { return GbOutputComm; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public IList<MemoryDomain> MemoryDomains
|
||||||
|
{
|
||||||
|
get { throw new NotImplementedException(); }
|
||||||
|
}
|
||||||
|
|
||||||
|
public MemoryDomain MainMemory
|
||||||
|
{
|
||||||
|
get { throw new NotImplementedException(); }
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
LibGambatte.gambatte_destroy(GambatteState);
|
||||||
|
GambatteState = IntPtr.Zero;
|
||||||
|
}
|
||||||
|
|
||||||
|
#region IVideoProvider
|
||||||
|
|
||||||
|
int[] VideoBuffer = new int[160 * 144];
|
||||||
|
|
||||||
|
public int[] GetVideoBuffer()
|
||||||
|
{
|
||||||
|
return VideoBuffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int VirtualWidth
|
||||||
|
{
|
||||||
|
// only sgb changes this
|
||||||
|
get { return 160; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public int BufferWidth
|
||||||
|
{
|
||||||
|
get { return 160; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public int BufferHeight
|
||||||
|
{
|
||||||
|
get { return 144; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public int BackgroundColor
|
||||||
|
{
|
||||||
|
get { return 0; }
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
|
@ -4,7 +4,7 @@ using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
namespace BizHawk.Emulation.Consoles.GB
|
namespace BizHawk.Emulation.Consoles.Gambatte
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// static bindings into libgambatte.dll
|
/// static bindings into libgambatte.dll
|
||||||
|
@ -42,7 +42,7 @@ namespace BizHawk.Emulation.Consoles.GB
|
||||||
/// <param name="core">opaque state pointer</param>
|
/// <param name="core">opaque state pointer</param>
|
||||||
/// <param name="filename">Path to rom image file. Typically a .gbc, .gb, or .zip-file (if zip-support is compiled in).</param>
|
/// <param name="filename">Path to rom image file. Typically a .gbc, .gb, or .zip-file (if zip-support is compiled in).</param>
|
||||||
/// <param name="flags">ORed combination of LoadFlags.</param>
|
/// <param name="flags">ORed combination of LoadFlags.</param>
|
||||||
/// <returns></returns>
|
/// <returns>0 on success, negative value on failure.</returns>
|
||||||
[DllImport("libgambatte.dll", CallingConvention = CallingConvention.Cdecl)]
|
[DllImport("libgambatte.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||||
public static extern int gambatte_load(IntPtr core, string filename, LoadFlags flags);
|
public static extern int gambatte_load(IntPtr core, string filename, LoadFlags flags);
|
||||||
|
|
|
@ -1381,9 +1381,14 @@ namespace BizHawk.MultiClient
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "GB":
|
case "GB":
|
||||||
|
/*
|
||||||
Gameboy gb = new Gameboy(game, rom.FileData, Global.Config.GameBoySkipBIOS);
|
Gameboy gb = new Gameboy(game, rom.FileData, Global.Config.GameBoySkipBIOS);
|
||||||
nextEmulator = gb;
|
nextEmulator = gb;
|
||||||
break;
|
break;
|
||||||
|
*/
|
||||||
|
Emulation.Consoles.Gambatte.Gambatte gambatte = new Emulation.Consoles.Gambatte.Gambatte(rom.FileData);
|
||||||
|
nextEmulator = gambatte;
|
||||||
|
break;
|
||||||
case "COLV":
|
case "COLV":
|
||||||
SMS c = new SMS(game, rom.RomData);//new ColecoVision(game, rom.FileData);
|
SMS c = new SMS(game, rom.RomData);//new ColecoVision(game, rom.FileData);
|
||||||
nextEmulator = c;
|
nextEmulator = c;
|
||||||
|
|
Loading…
Reference in New Issue