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() { }
|
||||
}
|
||||
}
|
|
@ -28,7 +28,7 @@ namespace BizHawk.Emulation.Consoles.Sega
|
|||
public IList<string> Options;
|
||||
|
||||
// SaveRAM
|
||||
public byte[] SaveRAM = new byte[BankSize*2];
|
||||
public byte[] SaveRAM = new byte[BankSize * 2];
|
||||
public byte SaveRamBank;
|
||||
|
||||
public byte[] SaveRam { get { return SaveRAM; } }
|
||||
|
@ -79,7 +79,7 @@ namespace BizHawk.Emulation.Consoles.Sega
|
|||
SoundMixer = new SoundMixer(YM2413, PSG);
|
||||
if (HasYM2413 && Options.Contains("WhenFMDisablePSG"))
|
||||
SoundMixer.DisableSource(PSG);
|
||||
ActiveSoundProvider = HasYM2413 ? (ISoundProvider) SoundMixer : PSG;
|
||||
ActiveSoundProvider = HasYM2413 ? (ISoundProvider)SoundMixer : PSG;
|
||||
|
||||
SystemRam = new byte[0x2000];
|
||||
if (Options.Contains("CMMapper") == false)
|
||||
|
@ -112,8 +112,8 @@ namespace BizHawk.Emulation.Consoles.Sega
|
|||
{
|
||||
RomData = game.GetRomData();
|
||||
if (RomData.Length % BankSize != 0)
|
||||
Array.Resize(ref RomData, ((RomData.Length/BankSize) + 1)*BankSize);
|
||||
RomBanks = (byte)(RomData.Length/BankSize);
|
||||
Array.Resize(ref RomData, ((RomData.Length / BankSize) + 1) * BankSize);
|
||||
RomBanks = (byte)(RomData.Length / BankSize);
|
||||
Options = game.GetOptions();
|
||||
DisplayType = DisplayType.NTSC;
|
||||
CoreOutputComm.VsyncRate = DisplayType == DisplayType.NTSC ? 60d : 50d;
|
||||
|
@ -150,7 +150,7 @@ namespace BizHawk.Emulation.Consoles.Sega
|
|||
case 0xDC: return ReadControls1();
|
||||
case 0xC1:
|
||||
case 0xDD: return ReadControls2();
|
||||
case 0xF2: return HasYM2413 ? YM2413.DetectionValue : (byte) 0xFF;
|
||||
case 0xF2: return HasYM2413 ? YM2413.DetectionValue : (byte)0xFF;
|
||||
}
|
||||
return 0xFF;
|
||||
}
|
||||
|
@ -220,7 +220,7 @@ namespace BizHawk.Emulation.Consoles.Sega
|
|||
}
|
||||
if (HasYM2413)
|
||||
{
|
||||
writer.Write("FMRegs " );
|
||||
writer.Write("FMRegs ");
|
||||
YM2413.opll.reg.SaveAsHex(writer);
|
||||
}
|
||||
writer.WriteLine("[/SMS]");
|
||||
|
@ -345,12 +345,12 @@ namespace BizHawk.Emulation.Consoles.Sega
|
|||
set
|
||||
{
|
||||
if (value.NotIn(validRegions))
|
||||
throw new Exception("Passed value "+value+" is not a valid region!");
|
||||
throw new Exception("Passed value " + value + " is not a valid region!");
|
||||
region = value;
|
||||
}
|
||||
}
|
||||
|
||||
private readonly string[] validRegions = {"Export", "Japan"};
|
||||
private readonly string[] validRegions = { "Export", "Japan" };
|
||||
|
||||
private IList<MemoryDomain> memoryDomains;
|
||||
|
||||
|
@ -364,8 +364,8 @@ namespace BizHawk.Emulation.Consoles.Sega
|
|||
addr => Vdp.VRAM[addr & 0x3FFF],
|
||||
(addr, value) => Vdp.VRAM[addr & 0x3FFF] = value);
|
||||
var SaveRamDomain = new MemoryDomain("Save RAM", SaveRAM.Length, Endian.Little,
|
||||
addr => SaveRAM[addr%SaveRAM.Length],
|
||||
(addr, value) => { SaveRAM[addr%SaveRAM.Length]=value; SaveRamModified=true;});
|
||||
addr => SaveRAM[addr % SaveRAM.Length],
|
||||
(addr, value) => { SaveRAM[addr % SaveRAM.Length] = value; SaveRamModified = true; });
|
||||
var SystemBusDomain = new MemoryDomain("System Bus", 0x10000, Endian.Little,
|
||||
addr => Cpu.ReadMemory((ushort)addr),
|
||||
(addr, value) => Cpu.WriteMemory((ushort)addr, value));
|
||||
|
@ -380,6 +380,6 @@ namespace BizHawk.Emulation.Consoles.Sega
|
|||
public IList<MemoryDomain> MemoryDomains { get { return memoryDomains; } }
|
||||
public MemoryDomain MainMemory { get { return memoryDomains[0]; } }
|
||||
|
||||
public void Dispose() {}
|
||||
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