rehabilitate the GB core: fix videoprovider and input system
This commit is contained in:
parent
9c5f56308b
commit
42715fdca7
|
@ -4,7 +4,7 @@ using BizHawk.Emulation.CPUs.Z80GB;
|
||||||
|
|
||||||
namespace BizHawk.Emulation.Consoles.Gameboy
|
namespace BizHawk.Emulation.Consoles.Gameboy
|
||||||
{
|
{
|
||||||
public partial class Gameboy : IEmulator
|
public partial class Gameboy : IEmulator, IVideoProvider
|
||||||
{
|
{
|
||||||
|
|
||||||
private int _lagcount = 0;
|
private int _lagcount = 0;
|
||||||
|
@ -703,17 +703,16 @@ namespace BizHawk.Emulation.Consoles.Gameboy
|
||||||
|
|
||||||
public void FrameAdvance(bool render)
|
public void FrameAdvance(bool render)
|
||||||
{
|
{
|
||||||
lagged = true;
|
|
||||||
Controller.UpdateControls(Frame++);
|
Controller.UpdateControls(Frame++);
|
||||||
Cpu.ExecuteCycles(4096);
|
|
||||||
|
//40960 is not the right number.
|
||||||
if (lagged)
|
for (int i = 0; i < 40960; i++)
|
||||||
{
|
{
|
||||||
_lagcount++;
|
SingleStepInto();
|
||||||
islag = true;
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
islag = false;
|
//to make sure input is working
|
||||||
|
Console.WriteLine(Controller.IsPressed("Up"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public CoreInputComm CoreInputComm { get; set; }
|
public CoreInputComm CoreInputComm { get; set; }
|
||||||
|
@ -721,9 +720,35 @@ namespace BizHawk.Emulation.Consoles.Gameboy
|
||||||
|
|
||||||
public IVideoProvider VideoProvider
|
public IVideoProvider VideoProvider
|
||||||
{
|
{
|
||||||
get { return new NullEmulator(); }
|
get { return this; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int[] GetVideoBuffer()
|
||||||
|
{
|
||||||
|
//TODO - these need to be run once per scanline and accumulated into a 160*144 byte buffer held by the core
|
||||||
|
//then, in the call to GetVideoBuffer(), it gets adapted to gray according to the palette and returned
|
||||||
|
//(i.e. no real GB logic happens during GetVideoBuffer())
|
||||||
|
int[] buf = new int[160 * 144];
|
||||||
|
var linebuf = new byte[160];
|
||||||
|
int i = 0;
|
||||||
|
for (int y = 0; y < 144; y++)
|
||||||
|
{
|
||||||
|
RenderBGLine(y, linebuf, true);
|
||||||
|
RenderOBJLine(y, linebuf, true);
|
||||||
|
for (int x = 0; x < 160; x++)
|
||||||
|
{
|
||||||
|
int gray = linebuf[x]<<6;
|
||||||
|
gray |= (gray << 8) | (gray << 16);
|
||||||
|
buf[i++] = unchecked(gray | (int)0xFF000000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return buf;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int BufferWidth { get { return 160; } }
|
||||||
|
public int BufferHeight { get { return 144; } }
|
||||||
|
public int BackgroundColor { get { return 0; } }
|
||||||
|
|
||||||
public ISoundProvider SoundProvider
|
public ISoundProvider SoundProvider
|
||||||
{
|
{
|
||||||
get { return new NullEmulator(); }
|
get { return new NullEmulator(); }
|
||||||
|
|
|
@ -17,7 +17,8 @@ namespace BizHawk.MultiClient
|
||||||
NESController[1] = new NESControllerTemplate(false);
|
NESController[1] = new NESControllerTemplate(false);
|
||||||
NESController[2] = new NESControllerTemplate(false);
|
NESController[2] = new NESControllerTemplate(false);
|
||||||
NESController[3] = new NESControllerTemplate(false);
|
NESController[3] = new NESControllerTemplate(false);
|
||||||
GameBoyController = new NESControllerTemplate(true);
|
GBController[0] = new GBControllerTemplate(true);
|
||||||
|
GBAutoController[0] = new GBControllerTemplate(true);
|
||||||
TI83Controller[0] = new TI83ControllerTemplate(true);
|
TI83Controller[0] = new TI83ControllerTemplate(true);
|
||||||
|
|
||||||
GenesisController[0] = new GenControllerTemplate(true);
|
GenesisController[0] = new GenControllerTemplate(true);
|
||||||
|
@ -43,7 +44,6 @@ namespace BizHawk.MultiClient
|
||||||
PCEAutoController[3] = new PCEControllerTemplate(false);
|
PCEAutoController[3] = new PCEControllerTemplate(false);
|
||||||
PCEAutoController[4] = new PCEControllerTemplate(false);
|
PCEAutoController[4] = new PCEControllerTemplate(false);
|
||||||
|
|
||||||
GameBoyAutoController = new NESControllerTemplate(false);
|
|
||||||
ColecoController = new ColecoVisionControllerTemplate(true);
|
ColecoController = new ColecoVisionControllerTemplate(true);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -503,10 +503,6 @@ namespace BizHawk.MultiClient
|
||||||
//ColecoVision
|
//ColecoVision
|
||||||
public ColecoVisionControllerTemplate ColecoController = new ColecoVisionControllerTemplate(true);
|
public ColecoVisionControllerTemplate ColecoController = new ColecoVisionControllerTemplate(true);
|
||||||
|
|
||||||
//GameBoy Settings
|
|
||||||
public NESControllerTemplate GameBoyController = new NESControllerTemplate(true);
|
|
||||||
public NESControllerTemplate GameBoyAutoController = new NESControllerTemplate();
|
|
||||||
|
|
||||||
//NES settings
|
//NES settings
|
||||||
//public string NESReset = "Backspace";
|
//public string NESReset = "Backspace";
|
||||||
public NESControllerTemplate[] NESController = new NESControllerTemplate[4];
|
public NESControllerTemplate[] NESController = new NESControllerTemplate[4];
|
||||||
|
@ -516,8 +512,8 @@ namespace BizHawk.MultiClient
|
||||||
public TI83ControllerTemplate[] TI83Controller = new TI83ControllerTemplate[1];
|
public TI83ControllerTemplate[] TI83Controller = new TI83ControllerTemplate[1];
|
||||||
|
|
||||||
//GB settings
|
//GB settings
|
||||||
public GBControllerTemplate GBController = new GBControllerTemplate();
|
public GBControllerTemplate[] GBController = new GBControllerTemplate[1];
|
||||||
public GBControllerTemplate GBAutoController = new GBControllerTemplate();
|
public GBControllerTemplate[] GBAutoController = new GBControllerTemplate[1];
|
||||||
|
|
||||||
//GIF Animator Settings
|
//GIF Animator Settings
|
||||||
public int GifAnimatorNumFrames;
|
public int GifAnimatorNumFrames;
|
||||||
|
|
|
@ -678,26 +678,26 @@ namespace BizHawk.MultiClient
|
||||||
Global.AutofireNESControls = anesControls;
|
Global.AutofireNESControls = anesControls;
|
||||||
|
|
||||||
var gbControls = new Controller(Gameboy.GbController);
|
var gbControls = new Controller(Gameboy.GbController);
|
||||||
gbControls.BindMulti("Up", Global.Config.GBController.Up);
|
gbControls.BindMulti("Up", Global.Config.GBController[0].Up);
|
||||||
gbControls.BindMulti("Down", Global.Config.GBController.Down);
|
gbControls.BindMulti("Down", Global.Config.GBController[0].Down);
|
||||||
gbControls.BindMulti("Left", Global.Config.GBController.Left);
|
gbControls.BindMulti("Left", Global.Config.GBController[0].Left);
|
||||||
gbControls.BindMulti("Right", Global.Config.GBController.Right);
|
gbControls.BindMulti("Right", Global.Config.GBController[0].Right);
|
||||||
gbControls.BindMulti("A", Global.Config.GBController.A);
|
gbControls.BindMulti("A", Global.Config.GBController[0].A);
|
||||||
gbControls.BindMulti("B", Global.Config.GBController.B);
|
gbControls.BindMulti("B", Global.Config.GBController[0].B);
|
||||||
gbControls.BindMulti("Select", Global.Config.GBController.Select);
|
gbControls.BindMulti("Select", Global.Config.GBController[0].Select);
|
||||||
gbControls.BindMulti("Start", Global.Config.GBController.Start);
|
gbControls.BindMulti("Start", Global.Config.GBController[0].Start);
|
||||||
Global.GBControls = gbControls;
|
Global.GBControls = gbControls;
|
||||||
|
|
||||||
var agbControls = new AutofireController(Gameboy.GbController);
|
var agbControls = new AutofireController(Gameboy.GbController);
|
||||||
agbControls.Autofire = true;
|
agbControls.Autofire = true;
|
||||||
agbControls.BindMulti("Up", Global.Config.GBAutoController.Up);
|
agbControls.BindMulti("Up", Global.Config.GBAutoController[0].Up);
|
||||||
agbControls.BindMulti("Down", Global.Config.GBAutoController.Down);
|
agbControls.BindMulti("Down", Global.Config.GBAutoController[0].Down);
|
||||||
agbControls.BindMulti("Left", Global.Config.GBAutoController.Left);
|
agbControls.BindMulti("Left", Global.Config.GBAutoController[0].Left);
|
||||||
agbControls.BindMulti("Right", Global.Config.GBAutoController.Right);
|
agbControls.BindMulti("Right", Global.Config.GBAutoController[0].Right);
|
||||||
agbControls.BindMulti("A", Global.Config.GBAutoController.A);
|
agbControls.BindMulti("A", Global.Config.GBAutoController[0].A);
|
||||||
agbControls.BindMulti("B", Global.Config.GBAutoController.B);
|
agbControls.BindMulti("B", Global.Config.GBAutoController[0].B);
|
||||||
agbControls.BindMulti("Select", Global.Config.GBAutoController.Select);
|
agbControls.BindMulti("Select", Global.Config.GBAutoController[0].Select);
|
||||||
agbControls.BindMulti("Start", Global.Config.GBAutoController.Start);
|
agbControls.BindMulti("Start", Global.Config.GBAutoController[0].Start);
|
||||||
Global.AutofireGBControls = agbControls;
|
Global.AutofireGBControls = agbControls;
|
||||||
|
|
||||||
var genControls = new Controller(Genesis.GenesisController);
|
var genControls = new Controller(Genesis.GenesisController);
|
||||||
|
|
|
@ -103,8 +103,8 @@ namespace BizHawk.MultiClient
|
||||||
break;
|
break;
|
||||||
case "Gameboy":
|
case "Gameboy":
|
||||||
ControllerImage.Image = BizHawk.MultiClient.Properties.Resources.GBController;
|
ControllerImage.Image = BizHawk.MultiClient.Properties.Resources.GBController;
|
||||||
controller = new NESControllerTemplate[1] { Global.Config.GameBoyController };
|
controller = Global.Config.GBController;
|
||||||
autoController = new NESControllerTemplate[1] { Global.Config.GameBoyAutoController };
|
autoController = Global.Config.GBAutoController;
|
||||||
break;
|
break;
|
||||||
case "NES":
|
case "NES":
|
||||||
ControllerImage.Image = BizHawk.MultiClient.Properties.Resources.NESController;
|
ControllerImage.Image = BizHawk.MultiClient.Properties.Resources.NESController;
|
||||||
|
@ -275,8 +275,8 @@ namespace BizHawk.MultiClient
|
||||||
autoController = Global.Config.Atari2600AutoController;
|
autoController = Global.Config.Atari2600AutoController;
|
||||||
break;
|
break;
|
||||||
case "Gameboy":
|
case "Gameboy":
|
||||||
controller = new NESControllerTemplate[1] { Global.Config.GameBoyController };
|
controller = Global.Config.GBController;
|
||||||
autoController = new NESControllerTemplate[1] { Global.Config.GameBoyAutoController };
|
autoController = Global.Config.GBAutoController;
|
||||||
break;
|
break;
|
||||||
case "NES":
|
case "NES":
|
||||||
controller = Global.Config.NESController;
|
controller = Global.Config.NESController;
|
||||||
|
|
Loading…
Reference in New Issue