slight refactor to IEmulator - make the IController property set only to more clearly express the client -> core relationship

This commit is contained in:
adelikat 2017-04-26 19:09:00 -05:00
parent 9249593f26
commit 3192cc70ae
23 changed files with 33 additions and 38 deletions

View File

@ -25,10 +25,11 @@ namespace BizHawk.Emulation.Common
ControllerDefinition ControllerDefinition { get; } ControllerDefinition ControllerDefinition { get; }
/// <summary> /// <summary>
/// Provides controller instance information to the core, such as what buttons are currently pressed /// Sets the controller instance that the core will use for input.
/// Note that the client is responsible for setting this property and updating its state /// Tee <seealso cref="IController"/> provided by the client must provide the buttons specified the buttons
/// defined by the <seealso cref="=ControllerDefinition"/> provided by the core
/// </summary> /// </summary>
IController Controller { get; set; } IController Controller { set; }
/// <summary> /// <summary>
/// Runs the emulator core for 1 frame /// Runs the emulator core for 1 frame

View File

@ -11,7 +11,7 @@ namespace BizHawk.Emulation.Cores.Calculators
get { return TI83Controller; } get { return TI83Controller; }
} }
public IController Controller { get; set; } public IController Controller { private get; set; }
public void FrameAdvance(bool render, bool rendersound) public void FrameAdvance(bool render, bool rendersound)
{ {

View File

@ -8,7 +8,7 @@ namespace BizHawk.Emulation.Cores.Computers.AppleII
public ControllerDefinition ControllerDefinition => AppleIIController; public ControllerDefinition ControllerDefinition => AppleIIController;
public IController Controller { get; set; } public IController Controller { private get; set; }
public int Frame { get; private set; } public int Frame { get; private set; }

View File

@ -142,7 +142,7 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64
[SaveState.DoNotSave] [SaveState.DoNotSave]
public ControllerDefinition ControllerDefinition { get { return C64ControllerDefinition; } } public ControllerDefinition ControllerDefinition { get { return C64ControllerDefinition; } }
[SaveState.DoNotSave] [SaveState.DoNotSave]
public IController Controller { get { return _board.Controller; } set { _board.Controller = value; } } public IController Controller { private get { return _board.Controller; } set { _board.Controller = value; } }
[SaveState.DoNotSave] [SaveState.DoNotSave]
public IEmulatorServiceProvider ServiceProvider { get; private set; } public IEmulatorServiceProvider ServiceProvider { get; private set; }

View File

@ -75,7 +75,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
public ControllerDefinition ControllerDefinition { get { return Atari2600ControllerDefinition; } } public ControllerDefinition ControllerDefinition { get { return Atari2600ControllerDefinition; } }
public IController Controller { get; set; } public IController Controller { private get; set; }
public int Frame { get { return _frame; } set { _frame = value; } } public int Frame { get { return _frame; } set { _frame = value; } }

View File

@ -151,7 +151,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari7800
public Atari7800Control ControlAdapter { get; private set; } public Atari7800Control ControlAdapter { get; private set; }
public ControllerDefinition ControllerDefinition { get; private set; } public ControllerDefinition ControllerDefinition { get; private set; }
public IController Controller { get; set; } public IController Controller { private get; set; }
private class ConsoleLogger : ILogger private class ConsoleLogger : ILogger

View File

@ -175,7 +175,7 @@ namespace BizHawk.Emulation.Cores.Atari.Lynx
}; };
public ControllerDefinition ControllerDefinition { get { return LynxTroller; } } public ControllerDefinition ControllerDefinition { get { return LynxTroller; } }
public IController Controller { get; set; } public IController Controller { private get; set; }
private LibLynx.Buttons GetButtons() private LibLynx.Buttons GetButtons()
{ {

View File

@ -76,7 +76,7 @@ namespace BizHawk.Emulation.Cores.ColecoVision
private readonly ColecoVisionControllerDeck ControllerDeck; private readonly ColecoVisionControllerDeck ControllerDeck;
public IController Controller { get; set; } public IController Controller { private get; set; }
private const ushort RamSizeMask = 0x03FF; private const ushort RamSizeMask = 0x03FF;

View File

@ -8,7 +8,7 @@ namespace BizHawk.Emulation.Cores.Intellivision
public ControllerDefinition ControllerDefinition => _controllerDeck.Definition; public ControllerDefinition ControllerDefinition => _controllerDeck.Definition;
public IController Controller { get; set; } public IController Controller { private get; set; }
public void FrameAdvance(bool render, bool rendersound) public void FrameAdvance(bool render, bool rendersound)
{ {

View File

@ -332,17 +332,17 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
if (_isVS) if (_isVS)
{ {
if (controller.IsPressed("Service Switch")) if (Controller.IsPressed("Service Switch"))
VS_service = 1; VS_service = 1;
else else
VS_service = 0; VS_service = 0;
if (controller.IsPressed("Insert Coin P1")) if (Controller.IsPressed("Insert Coin P1"))
VS_coin_inserted |= 1; VS_coin_inserted |= 1;
else else
VS_coin_inserted &= 2; VS_coin_inserted &= 2;
if (controller.IsPressed("Insert Coin P2")) if (Controller.IsPressed("Insert Coin P2"))
VS_coin_inserted |= 2; VS_coin_inserted |= 2;
else else
VS_coin_inserted &= 1; VS_coin_inserted &= 1;

View File

@ -42,7 +42,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
this.SyncSettings = (NESSyncSettings)SyncSettings ?? new NESSyncSettings(); this.SyncSettings = (NESSyncSettings)SyncSettings ?? new NESSyncSettings();
this.ControllerSettings = this.SyncSettings.Controls; this.ControllerSettings = this.SyncSettings.Controls;
CoreComm = comm; CoreComm = comm;
MemoryCallbacks = new MemoryCallbackSystem(); MemoryCallbacks = new MemoryCallbackSystem();
BootGodDB.Initialize(); BootGodDB.Initialize();
videoProvider = new MyVideoProvider(this); videoProvider = new MyVideoProvider(this);
@ -64,14 +64,14 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
PickVSPalette(cart); PickVSPalette(cart);
} }
ser.Register<IDisassemblable>(cpu); ser.Register<IDisassemblable>(cpu);
Tracer = new TraceBuffer { Header = cpu.TraceHeader }; Tracer = new TraceBuffer { Header = cpu.TraceHeader };
ser.Register<ITraceable>(Tracer); ser.Register<ITraceable>(Tracer);
ser.Register<IVideoProvider>(videoProvider); ser.Register<IVideoProvider>(videoProvider);
ser.Register<ISoundProvider>(magicSoundProvider); ser.Register<ISoundProvider>(magicSoundProvider);
if (Board is BANDAI_FCG_1) if (Board is BANDAI_FCG_1)
{ {
var reader = (Board as BANDAI_FCG_1).reader; var reader = (Board as BANDAI_FCG_1).reader;
@ -354,15 +354,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
public ControllerDefinition ControllerDefinition { get; private set; } public ControllerDefinition ControllerDefinition { get; private set; }
IController controller; public IController Controller { private get; set; }
public IController Controller
{
get { return controller; }
set { controller = value; }
}
int _frame;
private int _frame;
public int Frame { get { return _frame; } set { _frame = value; } } public int Frame { get { return _frame; } set { _frame = value; } }
public void ResetCounters() public void ResetCounters()

View File

@ -112,7 +112,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES
#region Controller #region Controller
public ControllerDefinition ControllerDefinition { get; private set; } public ControllerDefinition ControllerDefinition { get; private set; }
public IController Controller { get; set; } public IController Controller { private get; set; }
void SetControllerDefinition() void SetControllerDefinition()
{ {

View File

@ -10,7 +10,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
public ControllerDefinition ControllerDefinition => _controllerDeck.Definition; public ControllerDefinition ControllerDefinition => _controllerDeck.Definition;
public IController Controller { get; set; } public IController Controller { private get; set; }
public void FrameAdvance(bool render, bool rendersound) public void FrameAdvance(bool render, bool rendersound)
{ {

View File

@ -19,7 +19,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES9X
get { return NullController.Instance.Definition; } get { return NullController.Instance.Definition; }
} }
public IController Controller { get; set; } public IController Controller { private get; set; }
#endregion #endregion

View File

@ -8,7 +8,7 @@ namespace BizHawk.Emulation.Cores.PCEngine
public ControllerDefinition ControllerDefinition => PCEngineController; public ControllerDefinition ControllerDefinition => PCEngineController;
public IController Controller { get; set; } public IController Controller { private get; set; }
public void FrameAdvance(bool render, bool rendersound) public void FrameAdvance(bool render, bool rendersound)
{ {

View File

@ -15,6 +15,6 @@ namespace BizHawk.Emulation.Cores.Sega.Genesis
}; };
public ControllerDefinition ControllerDefinition { get { return GenesisController; } } public ControllerDefinition ControllerDefinition { get { return GenesisController; } }
public IController Controller { get; set; } public IController Controller { private get; set; }
} }
} }

View File

@ -19,7 +19,7 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem
} }
} }
public IController Controller { get; set; } public IController Controller { private get; set; }
public void FrameAdvance(bool render, bool rendersound) public void FrameAdvance(bool render, bool rendersound)
{ {

View File

@ -167,7 +167,7 @@ namespace BizHawk.Emulation.Cores.Sega.Saturn
get { return SaturnController; } get { return SaturnController; }
} }
public IController Controller { get; set; } public IController Controller { private get; set; }
public bool GLMode { get; private set; } public bool GLMode { get; private set; }

View File

@ -9,7 +9,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx
public ControllerDefinition ControllerDefinition { get; private set; } public ControllerDefinition ControllerDefinition { get; private set; }
public IController Controller { get; set; } public IController Controller { private get; set; }
// TODO: use render and rendersound // TODO: use render and rendersound
public void FrameAdvance(bool render, bool rendersound = true) public void FrameAdvance(bool render, bool rendersound = true)

View File

@ -9,7 +9,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx64
public ControllerDefinition ControllerDefinition { get; private set; } public ControllerDefinition ControllerDefinition { get; private set; }
public IController Controller { get; set; } public IController Controller { private get; set; }
// TODO: use render and rendersound // TODO: use render and rendersound
public void FrameAdvance(bool render, bool rendersound = true) public void FrameAdvance(bool render, bool rendersound = true)

View File

@ -39,7 +39,7 @@ namespace BizHawk.Emulation.Cores.Sony.PSP
}; };
public ControllerDefinition ControllerDefinition { get { return PSPController; } } public ControllerDefinition ControllerDefinition { get { return PSPController; } }
public IController Controller { get; set; } public IController Controller { private get; set; }
public bool DeterministicEmulation { get { return true; } } public bool DeterministicEmulation { get { return true; } }
public string SystemId { get { return "PSP"; } } public string SystemId { get { return "PSP"; } }
public CoreComm CoreComm { get; private set; } public CoreComm CoreComm { get; private set; }

View File

@ -819,7 +819,7 @@ namespace BizHawk.Emulation.Cores.Sony.PSX
} }
public ControllerDefinition ControllerDefinition { get; private set; } public ControllerDefinition ControllerDefinition { get; private set; }
public IController Controller { get; set; } public IController Controller { private get; set; }
public int Frame { get; private set; } public int Frame { get; private set; }
public int LagCount { get; set; } public int LagCount { get; set; }

View File

@ -37,12 +37,12 @@ namespace BizHawk.Emulation.Cores.WonderSwan
"P2 B", "P2 B",
"P2 A", "P2 A",
"Power", "Power",
"Rotate" "Rotate"
} }
}; };
public ControllerDefinition ControllerDefinition { get { return WonderSwanController; } } public ControllerDefinition ControllerDefinition { get { return WonderSwanController; } }
public IController Controller { get; set; } public IController Controller { private get; set; }
BizSwan.Buttons GetButtons() BizSwan.Buttons GetButtons()
{ {