some implementations necessary for the gameboy controller
This commit is contained in:
parent
6c6929b625
commit
52215061aa
|
@ -6,6 +6,11 @@ namespace BizHawk.Emulation.Consoles.Gameboy
|
|||
{
|
||||
public partial class Gameboy : IEmulator
|
||||
{
|
||||
|
||||
private int _lagcount = 0;
|
||||
private bool lagged = true;
|
||||
private bool islag = false;
|
||||
|
||||
public interface IDebuggerAPI
|
||||
{
|
||||
void DoEvents();
|
||||
|
@ -326,8 +331,28 @@ namespace BizHawk.Emulation.Consoles.Gameboy
|
|||
Registers = new TRegisters(this);
|
||||
|
||||
Registers.LCDC.Poke(0x91);
|
||||
SetupMemoryDomains();
|
||||
}
|
||||
|
||||
private IList<MemoryDomain> memoryDomains;
|
||||
|
||||
private void SetupMemoryDomains()
|
||||
{
|
||||
//TODO: WRAM (0 & 1? or both?)
|
||||
//TODO: VRAM
|
||||
//TODO: OAM
|
||||
//TODO: HRAM
|
||||
var domains = new List<MemoryDomain>(1);
|
||||
var SystemBusDomain = new MemoryDomain("System Bus", 0x10000, Endian.Little,
|
||||
addr => Cpu.ReadMemory((ushort)addr),
|
||||
(addr, value) => Cpu.WriteMemory((ushort)addr, value));
|
||||
domains.Add(SystemBusDomain);
|
||||
memoryDomains = domains.AsReadOnly();
|
||||
}
|
||||
|
||||
public IList<MemoryDomain> MemoryDomains { get { return memoryDomains; } }
|
||||
public MemoryDomain MainMemory { get { return memoryDomains[0]; } }
|
||||
|
||||
public byte ReadMemoryBios(ushort addr)
|
||||
{
|
||||
//we speculate that the bios unmaps itself after the first read of 0x100
|
||||
|
@ -651,9 +676,18 @@ namespace BizHawk.Emulation.Consoles.Gameboy
|
|||
|
||||
public void FrameAdvance(bool render)
|
||||
{
|
||||
lagged = true;
|
||||
Controller.UpdateControls(Frame++);
|
||||
Cpu.ExecuteCycles(4096);
|
||||
}
|
||||
|
||||
if (lagged)
|
||||
{
|
||||
_lagcount++;
|
||||
islag = true;
|
||||
}
|
||||
else
|
||||
islag = false;
|
||||
}
|
||||
|
||||
public CoreInputComm CoreInputComm { get; set; }
|
||||
public CoreOutputComm CoreOutputComm { get; private set; }
|
||||
|
@ -668,14 +702,10 @@ namespace BizHawk.Emulation.Consoles.Gameboy
|
|||
get { return new NullEmulator(); }
|
||||
}
|
||||
|
||||
public int Frame
|
||||
{
|
||||
get { return 0; }
|
||||
//get { throw new NotImplementedException(); }
|
||||
}
|
||||
public int Frame { get; set; }
|
||||
|
||||
public int LagCount { get { return -1; } set { return; } } //TODO: implement
|
||||
public bool IsLagFrame { get { return false; } } //TODO: implement
|
||||
public int LagCount { get { return _lagcount; } set { _lagcount = value; } }
|
||||
public bool IsLagFrame { get { return islag; } }
|
||||
|
||||
public byte[] SaveRam
|
||||
{
|
||||
|
@ -869,9 +899,6 @@ namespace BizHawk.Emulation.Consoles.Gameboy
|
|||
public bool DeterministicEmulation { get; set; }
|
||||
public string SystemId { get { return "GB"; } }
|
||||
|
||||
public IList<MemoryDomain> MemoryDomains { get { throw new NotImplementedException(); } }
|
||||
public MemoryDomain MainMemory { get { throw new NotImplementedException(); } }
|
||||
|
||||
public void Dispose() { }
|
||||
}
|
||||
}
|
|
@ -15,6 +15,7 @@
|
|||
NESController[1] = new NESControllerTemplate(false);
|
||||
NESController[2] = new NESControllerTemplate(false);
|
||||
NESController[3] = new NESControllerTemplate(false);
|
||||
GameBoyController = new NESControllerTemplate(true);
|
||||
TI83Controller[0] = new TI83ControllerTemplate(true);
|
||||
}
|
||||
|
||||
|
@ -390,6 +391,9 @@
|
|||
|
||||
//TI 83 settings
|
||||
public TI83ControllerTemplate[] TI83Controller = new TI83ControllerTemplate[1];
|
||||
|
||||
//GB settings
|
||||
public GBControllerTemplate GBController = new GBControllerTemplate();
|
||||
}
|
||||
|
||||
public class SMSControllerTemplate
|
||||
|
@ -509,6 +513,47 @@
|
|||
}
|
||||
}
|
||||
|
||||
public class GBControllerTemplate
|
||||
{
|
||||
public string Up;
|
||||
public string Down;
|
||||
public string Left;
|
||||
public string Right;
|
||||
public string A;
|
||||
public string B;
|
||||
public string Start;
|
||||
public string Select;
|
||||
public bool Enabled;
|
||||
public GBControllerTemplate() { }
|
||||
public GBControllerTemplate(bool defaults)
|
||||
{
|
||||
if (defaults)
|
||||
{
|
||||
Enabled = true;
|
||||
Up = "J1 Up, UpArrow";
|
||||
Down = "J1 Down, DownArrow";
|
||||
Left = "J1 Left, LeftArrow";
|
||||
Right = "J1 Right, RightArrow";
|
||||
A = "J1 B2, X";
|
||||
B = "J1 B1, Z";
|
||||
Start = "J1 B8, Return";
|
||||
Select = "J1 B7, Space";
|
||||
}
|
||||
else
|
||||
{
|
||||
Enabled = false;
|
||||
Up = "";
|
||||
Down = "";
|
||||
Right = "";
|
||||
Left = "";
|
||||
A = "";
|
||||
B = "";
|
||||
Start = "";
|
||||
Select = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class TI83ControllerTemplate
|
||||
{
|
||||
public string _0;
|
||||
|
|
|
@ -20,6 +20,7 @@ namespace BizHawk.MultiClient
|
|||
public static Controller GenControls;
|
||||
public static Controller TI83Controls;
|
||||
public static Controller NESControls;
|
||||
public static Controller GBControls;
|
||||
public static Controller ActiveController;
|
||||
public static Controller NullControls;
|
||||
}
|
||||
|
|
|
@ -200,6 +200,19 @@ namespace BizHawk.MultiClient
|
|||
return input.ToString();
|
||||
}
|
||||
|
||||
if (type.Name == "Gameboy Controller")
|
||||
{
|
||||
input.Append("|");
|
||||
input.Append(IsPressed("Right") ? "R" : ".");
|
||||
input.Append(IsPressed("Left") ? "L" : ".");
|
||||
input.Append(IsPressed("Down") ? "D" : ".");
|
||||
input.Append(IsPressed("Up") ? "U" : ".");
|
||||
input.Append(IsPressed("Start") ? "S" : ".");
|
||||
input.Append(IsPressed("Select") ? "s" : ".");
|
||||
input.Append(IsPressed("B") ? "B" : ".");
|
||||
input.Append(IsPressed("A") ? "A" : ".");
|
||||
}
|
||||
|
||||
if (type.Name == "NES Controls")
|
||||
{
|
||||
input.Append(IsPressed("Reset") ? "r" : ".");
|
||||
|
@ -376,6 +389,20 @@ namespace BizHawk.MultiClient
|
|||
if (mnemonic[19] != '.') programmaticallyPressedButtons.Add("P2 A");
|
||||
}
|
||||
|
||||
if (type.Name == "Gameboy Controller")
|
||||
{
|
||||
if (mnemonic.Length < 10) return;
|
||||
//if (mnemonic[1] != '.' && mnemonic[1] != '0') programmaticallyPressedButtons.Add("Reset");
|
||||
if (mnemonic[3] != '.') programmaticallyPressedButtons.Add("P1 Right");
|
||||
if (mnemonic[4] != '.') programmaticallyPressedButtons.Add("P1 Left");
|
||||
if (mnemonic[5] != '.') programmaticallyPressedButtons.Add("P1 Down");
|
||||
if (mnemonic[6] != '.') programmaticallyPressedButtons.Add("P1 Up");
|
||||
if (mnemonic[7] != '.') programmaticallyPressedButtons.Add("P1 Start");
|
||||
if (mnemonic[8] != '.') programmaticallyPressedButtons.Add("P1 Select");
|
||||
if (mnemonic[9] != '.') programmaticallyPressedButtons.Add("P1 B");
|
||||
if (mnemonic[10] != '.') programmaticallyPressedButtons.Add("P1 A");
|
||||
}
|
||||
|
||||
if (type.Name == "TI83 Controls")
|
||||
{
|
||||
if (mnemonic.Length < 50) return;
|
||||
|
|
|
@ -509,6 +509,18 @@ namespace BizHawk.MultiClient
|
|||
}
|
||||
Global.NESControls = nesControls;
|
||||
|
||||
var gbControls = new Controller(Gameboy.GbController);
|
||||
gbControls.BindMulti("Up", Global.Config.GBController.Up);
|
||||
gbControls.BindMulti("Down", Global.Config.GBController.Down);
|
||||
gbControls.BindMulti("Left", Global.Config.GBController.Left);
|
||||
gbControls.BindMulti("Right", Global.Config.GBController.Right);
|
||||
gbControls.BindMulti("A", Global.Config.GBController.A);
|
||||
gbControls.BindMulti("B", Global.Config.GBController.B);
|
||||
gbControls.BindMulti("Select", Global.Config.GBController.Select);
|
||||
gbControls.BindMulti("Start", Global.Config.GBController.Start);
|
||||
Global.GBControls = gbControls;
|
||||
|
||||
|
||||
var genControls = new Controller(Genesis.GenesisController);
|
||||
genControls.BindMulti("P1 Up", Global.Config.GenP1Up);
|
||||
genControls.BindMulti("P1 Left", Global.Config.GenP1Left);
|
||||
|
|
Loading…
Reference in New Issue