2019-01-03 18:10:53 +00:00
|
|
|
|
using System;
|
|
|
|
|
|
|
|
|
|
using BizHawk.Emulation.Common;
|
|
|
|
|
|
|
|
|
|
using BizHawk.Emulation.Cores.Nintendo.GBHawk;
|
|
|
|
|
|
|
|
|
|
namespace BizHawk.Emulation.Cores.Nintendo.GBHawkLink
|
|
|
|
|
{
|
|
|
|
|
[Core(
|
|
|
|
|
"GBHawkLink",
|
|
|
|
|
"",
|
|
|
|
|
isPorted: false,
|
2019-02-07 00:44:51 +00:00
|
|
|
|
isReleased: true)]
|
2019-01-03 18:10:53 +00:00
|
|
|
|
[ServiceNotApplicable(typeof(IDriveLight))]
|
|
|
|
|
public partial class GBHawkLink : IEmulator, ISaveRam, IDebuggable, IStatable, IInputPollable, IRegionable, ILinkable,
|
|
|
|
|
ISettable<GBHawkLink.GBLinkSettings, GBHawkLink.GBLinkSyncSettings>
|
|
|
|
|
{
|
|
|
|
|
// we want to create two GBHawk instances that we will run concurrently
|
|
|
|
|
// maybe up to 4 eventually?
|
|
|
|
|
public GBHawk.GBHawk L;
|
|
|
|
|
public GBHawk.GBHawk R;
|
|
|
|
|
|
2019-01-03 23:31:35 +00:00
|
|
|
|
// if true, the link cable is currently connected
|
|
|
|
|
private bool _cableconnected = true;
|
|
|
|
|
|
|
|
|
|
// if true, the link cable toggle signal is currently asserted
|
|
|
|
|
private bool _cablediscosignal = false;
|
|
|
|
|
|
2019-01-12 20:57:25 +00:00
|
|
|
|
private bool do_r_next = false;
|
|
|
|
|
|
2019-01-03 18:10:53 +00:00
|
|
|
|
//[CoreConstructor("GB", "GBC")]
|
|
|
|
|
public GBHawkLink(CoreComm comm, GameInfo game_L, byte[] rom_L, GameInfo game_R, byte[] rom_R, /*string gameDbFn,*/ object settings, object syncSettings)
|
|
|
|
|
{
|
|
|
|
|
var ser = new BasicServiceProvider(this);
|
|
|
|
|
|
2019-01-03 23:31:35 +00:00
|
|
|
|
linkSettings = (GBLinkSettings)settings ?? new GBLinkSettings();
|
|
|
|
|
linkSyncSettings = (GBLinkSyncSettings)syncSettings ?? new GBLinkSyncSettings();
|
2019-02-09 15:55:45 +00:00
|
|
|
|
_controllerDeck = new GBHawkLinkControllerDeck(GBHawkLinkControllerDeck.DefaultControllerName, GBHawkLinkControllerDeck.DefaultControllerName);
|
2019-01-03 18:10:53 +00:00
|
|
|
|
|
|
|
|
|
CoreComm = comm;
|
|
|
|
|
|
2019-01-03 23:31:35 +00:00
|
|
|
|
var temp_set_L = new GBHawk.GBHawk.GBSettings();
|
|
|
|
|
var temp_set_R = new GBHawk.GBHawk.GBSettings();
|
|
|
|
|
|
|
|
|
|
var temp_sync_L = new GBHawk.GBHawk.GBSyncSettings();
|
|
|
|
|
var temp_sync_R = new GBHawk.GBHawk.GBSyncSettings();
|
|
|
|
|
|
|
|
|
|
temp_sync_L.ConsoleMode = linkSyncSettings.ConsoleMode_L;
|
|
|
|
|
temp_sync_R.ConsoleMode = linkSyncSettings.ConsoleMode_R;
|
|
|
|
|
|
|
|
|
|
temp_sync_L.DivInitialTime = linkSyncSettings.DivInitialTime_L;
|
|
|
|
|
temp_sync_R.DivInitialTime = linkSyncSettings.DivInitialTime_R;
|
|
|
|
|
temp_sync_L.RTCInitialTime = linkSyncSettings.RTCInitialTime_L;
|
|
|
|
|
temp_sync_R.RTCInitialTime = linkSyncSettings.RTCInitialTime_R;
|
|
|
|
|
|
2019-01-03 18:10:53 +00:00
|
|
|
|
L = new GBHawk.GBHawk(new CoreComm(comm.ShowMessage, comm.Notify) { CoreFileProvider = comm.CoreFileProvider },
|
2019-01-03 23:31:35 +00:00
|
|
|
|
game_L, rom_L, temp_set_L, temp_sync_L);
|
2019-01-03 18:10:53 +00:00
|
|
|
|
|
|
|
|
|
R = new GBHawk.GBHawk(new CoreComm(comm.ShowMessage, comm.Notify) { CoreFileProvider = comm.CoreFileProvider },
|
2019-01-03 23:31:35 +00:00
|
|
|
|
game_R, rom_R, temp_set_R, temp_sync_R);
|
2019-01-03 18:10:53 +00:00
|
|
|
|
|
|
|
|
|
ser.Register<IVideoProvider>(this);
|
2019-01-03 23:31:35 +00:00
|
|
|
|
ser.Register<ISoundProvider>(this);
|
2019-01-03 18:10:53 +00:00
|
|
|
|
|
|
|
|
|
_tracer = new TraceBuffer { Header = L.cpu.TraceHeader };
|
|
|
|
|
ser.Register<ITraceable>(_tracer);
|
|
|
|
|
|
|
|
|
|
ServiceProvider = ser;
|
|
|
|
|
|
|
|
|
|
SetupMemoryDomains();
|
|
|
|
|
|
|
|
|
|
HardReset();
|
2019-01-04 01:24:18 +00:00
|
|
|
|
|
|
|
|
|
LinkConnected = _cableconnected;
|
2019-01-03 18:10:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void HardReset()
|
|
|
|
|
{
|
|
|
|
|
L.HardReset();
|
|
|
|
|
R.HardReset();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public DisplayType Region => DisplayType.NTSC;
|
|
|
|
|
|
|
|
|
|
public int _frame = 0;
|
|
|
|
|
|
|
|
|
|
private readonly GBHawkLinkControllerDeck _controllerDeck;
|
|
|
|
|
|
|
|
|
|
private readonly ITraceable _tracer;
|
|
|
|
|
|
2019-01-03 23:31:35 +00:00
|
|
|
|
public bool LinkConnected { get; private set; }
|
2019-01-03 18:10:53 +00:00
|
|
|
|
|
|
|
|
|
private void ExecFetch(ushort addr)
|
|
|
|
|
{
|
|
|
|
|
MemoryCallbacks.CallExecutes(addr, "System Bus");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|