diff --git a/BizHawk.Client.Common/inputAdapters/InputManager.cs b/BizHawk.Client.Common/inputAdapters/InputManager.cs
index e4e998d650..91647cac6a 100644
--- a/BizHawk.Client.Common/inputAdapters/InputManager.cs
+++ b/BizHawk.Client.Common/inputAdapters/InputManager.cs
@@ -21,7 +21,6 @@ namespace BizHawk.Client.Common
Global.MovieInputSourceAdapter.Source = Global.MultitrackRewiringAdapter;
Global.ControllerOutput.Source = Global.MovieOutputHardpoint;
- Global.Emulator.Controller = Global.ControllerOutput;
Global.MovieSession.MovieControllerAdapter.Definition = Global.MovieInputSourceAdapter.Definition;
// connect the movie session before MovieOutputHardpoint if it is doing anything
diff --git a/BizHawk.Client.EmuHawk/MainForm.cs b/BizHawk.Client.EmuHawk/MainForm.cs
index 52a07a3fbf..6d26cc5d2e 100644
--- a/BizHawk.Client.EmuHawk/MainForm.cs
+++ b/BizHawk.Client.EmuHawk/MainForm.cs
@@ -2840,7 +2840,7 @@ namespace BizHawk.Client.EmuHawk
if (!renderSound) atten = 0;
bool render = !_throttle.skipNextFrame || (_currAviWriter?.UsesVideo ?? false);
- Emulator.FrameAdvance(render, renderSound);
+ Emulator.FrameAdvance(Global.ControllerOutput, render, renderSound);
Global.MovieSession.HandleMovieAfterFrameLoop();
diff --git a/BizHawk.Client.EmuHawk/tools/BatchRunner.cs b/BizHawk.Client.EmuHawk/tools/BatchRunner.cs
index 0f96036f2c..7e25ff3e1e 100644
--- a/BizHawk.Client.EmuHawk/tools/BatchRunner.cs
+++ b/BizHawk.Client.EmuHawk/tools/BatchRunner.cs
@@ -162,7 +162,7 @@ namespace BizHawk.Client.EmuHawk
{
current.GI = ldr.Game;
current.CoreType = emu.GetType();
- emu.Controller = new Controller(emu.ControllerDefinition);
+ var controller = new Controller(emu.ControllerDefinition);
current.BoardName = emu.HasBoardInfo() ? emu.AsBoardInfo().BoardName : null;
// hack
if (emu is Emulation.Cores.Nintendo.GBA.VBANext)
@@ -179,7 +179,7 @@ namespace BizHawk.Client.EmuHawk
{
int nsamp;
short[] samp;
- emu.FrameAdvance(true, true);
+ emu.FrameAdvance(controller, true, true);
// some cores really really really like it if you drain their audio every frame
if (emu.HasSoundProvider())
diff --git a/BizHawk.Client.MultiHawk/EmulatorWindow.cs b/BizHawk.Client.MultiHawk/EmulatorWindow.cs
index a073db93da..ba20d5fa89 100644
--- a/BizHawk.Client.MultiHawk/EmulatorWindow.cs
+++ b/BizHawk.Client.MultiHawk/EmulatorWindow.cs
@@ -373,7 +373,7 @@ namespace BizHawk.Client.MultiHawk
public void FrameAdvance()
{
- Emulator.FrameAdvance(true);
+ Emulator.FrameAdvance(Global.ControllerOutput, true);
}
public void SaveRam()
diff --git a/BizHawk.Client.MultiHawk/InputManager.cs b/BizHawk.Client.MultiHawk/InputManager.cs
index 93cc40452a..a1e7470727 100644
--- a/BizHawk.Client.MultiHawk/InputManager.cs
+++ b/BizHawk.Client.MultiHawk/InputManager.cs
@@ -37,11 +37,6 @@ namespace BizHawk.Client.MultiHawk
Global.MovieInputSourceAdapter.Source = Global.MultitrackRewiringAdapter;
Global.ControllerOutput.Source = Global.MovieOutputHardpoint;
- foreach (var window in _mainForm.EmulatorWindows)
- {
- window.Emulator.Controller = Global.ControllerOutput;
- }
-
Global.MovieSession.MovieControllerAdapter.Definition = Global.MovieInputSourceAdapter.Definition;
// connect the movie session before MovieOutputHardpoint if it is doing anything
diff --git a/BizHawk.Emulation.Common/Base Implementations/NullEmulator.cs b/BizHawk.Emulation.Common/Base Implementations/NullEmulator.cs
index 74f5ca5bae..7c34d89ebe 100644
--- a/BizHawk.Emulation.Common/Base Implementations/NullEmulator.cs
+++ b/BizHawk.Emulation.Common/Base Implementations/NullEmulator.cs
@@ -33,9 +33,7 @@ namespace BizHawk.Emulation.Common
public ControllerDefinition ControllerDefinition => NullController.Instance.Definition;
- public IController Controller { get; set; }
-
- public void FrameAdvance(bool render, bool rendersound)
+ public void FrameAdvance(IController controller, bool render, bool rendersound)
{
if (render == false)
{
diff --git a/BizHawk.Emulation.Common/Interfaces/IEmulator.cs b/BizHawk.Emulation.Common/Interfaces/IEmulator.cs
index 05194aceb5..5c29306c3c 100644
--- a/BizHawk.Emulation.Common/Interfaces/IEmulator.cs
+++ b/BizHawk.Emulation.Common/Interfaces/IEmulator.cs
@@ -24,21 +24,17 @@ namespace BizHawk.Emulation.Common
///
ControllerDefinition ControllerDefinition { get; }
- ///
- /// Sets the controller instance that the core will use for input.
- /// Tee provided by the client must provide the buttons specified the buttons
- /// defined by the provided by the core
- ///
- IController Controller { set; }
-
///
/// Runs the emulator core for 1 frame
/// note that (some?) cores expect you to call SoundProvider.GetSamples() after each FrameAdvance()
/// please do this, even when rendersound = false
+ /// The instance that the core will use for input.
+ /// The provided by the client must provide the buttons specified by the core through the property
+ ///
/// Whether or not to render video, cores will pass false here in cases such as frame skipping
/// Whether or not to render audio, cores will pass here false here in cases such as fast forwarding where bypassing sound may improve speed
///
- void FrameAdvance(bool render, bool rendersound = true);
+ void FrameAdvance(IController controller, bool render, bool rendersound = true);
///
/// Gets the current frame count
diff --git a/BizHawk.Emulation.Cores/Calculator/TI83.IEmulator.cs b/BizHawk.Emulation.Cores/Calculator/TI83.IEmulator.cs
index b51018078b..5b0a165d8a 100644
--- a/BizHawk.Emulation.Cores/Calculator/TI83.IEmulator.cs
+++ b/BizHawk.Emulation.Cores/Calculator/TI83.IEmulator.cs
@@ -11,10 +11,9 @@ namespace BizHawk.Emulation.Cores.Calculators
get { return TI83Controller; }
}
- public IController Controller { private get; set; }
-
- public void FrameAdvance(bool render, bool rendersound)
+ public void FrameAdvance(IController controller, bool render, bool rendersound)
{
+ _controller = controller;
_lagged = true;
Cpu.Debug = Tracer.Enabled;
@@ -25,7 +24,7 @@ namespace BizHawk.Emulation.Cores.Calculators
//I eyeballed this speed
for (int i = 0; i < 5; i++)
{
- _onPressed = Controller.IsPressed("ON");
+ _onPressed = controller.IsPressed("ON");
//and this was derived from other emus
Cpu.ExecuteCycles(10000);
diff --git a/BizHawk.Emulation.Cores/Calculator/TI83.cs b/BizHawk.Emulation.Cores/Calculator/TI83.cs
index 837be34fb5..826e7c0f20 100644
--- a/BizHawk.Emulation.Cores/Calculator/TI83.cs
+++ b/BizHawk.Emulation.Cores/Calculator/TI83.cs
@@ -60,6 +60,8 @@ namespace BizHawk.Emulation.Cores.Calculators
private readonly Z80A Cpu = new Z80A();
private readonly byte[] Rom;
+ private IController _controller;
+
private byte[] _ram;
private byte[] _vram = new byte[0x300];
private int _romPageLow3Bits;
@@ -204,7 +206,7 @@ namespace BizHawk.Emulation.Cores.Calculators
// 4-7 - Unknown
//if (onPressed && maskOn) ret |= 1;
//if (!onPressed) ret |= 0x8;
- return (byte)((Controller.IsPressed("ON") ? _maskOn : 8) | (LinkActive ? 0 : 2));
+ return (byte)((_controller.IsPressed("ON") ? _maskOn : 8) | (LinkActive ? 0 : 2));
}
case 4: // PORT_INTCTRL
@@ -230,80 +232,79 @@ namespace BizHawk.Emulation.Cores.Calculators
//Console.WriteLine("keyboardMask: {0:X2}",keyboardMask);
if ((_keyboardMask & 1) == 0)
{
- if (Controller.IsPressed("DOWN")) ret ^= 1;
- if (Controller.IsPressed("LEFT")) ret ^= 2;
- if (Controller.IsPressed("RIGHT")) ret ^= 4;
- if (Controller.IsPressed("UP")) ret ^= 8;
+ if (_controller.IsPressed("DOWN")) ret ^= 1;
+ if (_controller.IsPressed("LEFT")) ret ^= 2;
+ if (_controller.IsPressed("RIGHT")) ret ^= 4;
+ if (_controller.IsPressed("UP")) ret ^= 8;
}
if ((_keyboardMask & 2) == 0)
{
- if (Controller.IsPressed("ENTER")) ret ^= 1;
- if (Controller.IsPressed("PLUS")) ret ^= 2;
- if (Controller.IsPressed("MINUS")) ret ^= 4;
- if (Controller.IsPressed("MULTIPLY")) ret ^= 8;
- if (Controller.IsPressed("DIVIDE")) ret ^= 16;
- if (Controller.IsPressed("EXP")) ret ^= 32;
- if (Controller.IsPressed("CLEAR")) ret ^= 64;
+ if (_controller.IsPressed("ENTER")) ret ^= 1;
+ if (_controller.IsPressed("PLUS")) ret ^= 2;
+ if (_controller.IsPressed("MINUS")) ret ^= 4;
+ if (_controller.IsPressed("MULTIPLY")) ret ^= 8;
+ if (_controller.IsPressed("DIVIDE")) ret ^= 16;
+ if (_controller.IsPressed("EXP")) ret ^= 32;
+ if (_controller.IsPressed("CLEAR")) ret ^= 64;
}
if ((_keyboardMask & 4) == 0)
{
- if (Controller.IsPressed("DASH")) ret ^= 1;
- if (Controller.IsPressed("3")) ret ^= 2;
- if (Controller.IsPressed("6")) ret ^= 4;
- if (Controller.IsPressed("9")) ret ^= 8;
- if (Controller.IsPressed("PARACLOSE")) ret ^= 16;
- if (Controller.IsPressed("TAN")) ret ^= 32;
- if (Controller.IsPressed("VARS")) ret ^= 64;
+ if (_controller.IsPressed("DASH")) ret ^= 1;
+ if (_controller.IsPressed("3")) ret ^= 2;
+ if (_controller.IsPressed("6")) ret ^= 4;
+ if (_controller.IsPressed("9")) ret ^= 8;
+ if (_controller.IsPressed("PARACLOSE")) ret ^= 16;
+ if (_controller.IsPressed("TAN")) ret ^= 32;
+ if (_controller.IsPressed("VARS")) ret ^= 64;
}
if ((_keyboardMask & 8) == 0)
{
- if (Controller.IsPressed("DOT")) ret ^= 1;
- if (Controller.IsPressed("2")) ret ^= 2;
- if (Controller.IsPressed("5")) ret ^= 4;
- if (Controller.IsPressed("8")) ret ^= 8;
- if (Controller.IsPressed("PARAOPEN")) ret ^= 16;
- if (Controller.IsPressed("COS")) ret ^= 32;
- if (Controller.IsPressed("PRGM")) ret ^= 64;
- if (Controller.IsPressed("STAT")) ret ^= 128;
+ if (_controller.IsPressed("DOT")) ret ^= 1;
+ if (_controller.IsPressed("2")) ret ^= 2;
+ if (_controller.IsPressed("5")) ret ^= 4;
+ if (_controller.IsPressed("8")) ret ^= 8;
+ if (_controller.IsPressed("PARAOPEN")) ret ^= 16;
+ if (_controller.IsPressed("COS")) ret ^= 32;
+ if (_controller.IsPressed("PRGM")) ret ^= 64;
+ if (_controller.IsPressed("STAT")) ret ^= 128;
}
if ((_keyboardMask & 16) == 0)
{
- if (Controller.IsPressed("0")) ret ^= 1;
- if (Controller.IsPressed("1")) ret ^= 2;
- if (Controller.IsPressed("4")) ret ^= 4;
- if (Controller.IsPressed("7")) ret ^= 8;
- if (Controller.IsPressed("COMMA")) ret ^= 16;
- if (Controller.IsPressed("SIN")) ret ^= 32;
- if (Controller.IsPressed("MATRIX")) ret ^= 64;
- if (Controller.IsPressed("X")) ret ^= 128;
+ if (_controller.IsPressed("0")) ret ^= 1;
+ if (_controller.IsPressed("1")) ret ^= 2;
+ if (_controller.IsPressed("4")) ret ^= 4;
+ if (_controller.IsPressed("7")) ret ^= 8;
+ if (_controller.IsPressed("COMMA")) ret ^= 16;
+ if (_controller.IsPressed("SIN")) ret ^= 32;
+ if (_controller.IsPressed("MATRIX")) ret ^= 64;
+ if (_controller.IsPressed("X")) ret ^= 128;
}
if ((_keyboardMask & 32) == 0)
{
- if (Controller.IsPressed("STO")) ret ^= 2;
- if (Controller.IsPressed("LN")) ret ^= 4;
- if (Controller.IsPressed("LOG")) ret ^= 8;
- if (Controller.IsPressed("SQUARED")) ret ^= 16;
- if (Controller.IsPressed("NEG1")) ret ^= 32;
- if (Controller.IsPressed("MATH"))
- ret ^= 64;
- if (Controller.IsPressed("ALPHA")) ret ^= 128;
+ if (_controller.IsPressed("STO")) ret ^= 2;
+ if (_controller.IsPressed("LN")) ret ^= 4;
+ if (_controller.IsPressed("LOG")) ret ^= 8;
+ if (_controller.IsPressed("SQUARED")) ret ^= 16;
+ if (_controller.IsPressed("NEG1")) ret ^= 32;
+ if (_controller.IsPressed("MATH")) ret ^= 64;
+ if (_controller.IsPressed("ALPHA")) ret ^= 128;
}
if ((_keyboardMask & 64) == 0)
{
- if (Controller.IsPressed("GRAPH")) ret ^= 1;
- if (Controller.IsPressed("TRACE")) ret ^= 2;
- if (Controller.IsPressed("ZOOM")) ret ^= 4;
- if (Controller.IsPressed("WINDOW")) ret ^= 8;
- if (Controller.IsPressed("Y")) ret ^= 16;
- if (Controller.IsPressed("2ND")) ret ^= 32;
- if (Controller.IsPressed("MODE")) ret ^= 64;
- if (Controller.IsPressed("DEL")) ret ^= 128;
+ if (_controller.IsPressed("GRAPH")) ret ^= 1;
+ if (_controller.IsPressed("TRACE")) ret ^= 2;
+ if (_controller.IsPressed("ZOOM")) ret ^= 4;
+ if (_controller.IsPressed("WINDOW")) ret ^= 8;
+ if (_controller.IsPressed("Y")) ret ^= 16;
+ if (_controller.IsPressed("2ND")) ret ^= 32;
+ if (_controller.IsPressed("MODE")) ret ^= 64;
+ if (_controller.IsPressed("DEL")) ret ^= 128;
}
return (byte)ret;
diff --git a/BizHawk.Emulation.Cores/Computers/AppleII/AppleII.IEmulator.cs b/BizHawk.Emulation.Cores/Computers/AppleII/AppleII.IEmulator.cs
index 33a5fe7961..8e41c8ba8c 100644
--- a/BizHawk.Emulation.Cores/Computers/AppleII/AppleII.IEmulator.cs
+++ b/BizHawk.Emulation.Cores/Computers/AppleII/AppleII.IEmulator.cs
@@ -8,17 +8,15 @@ namespace BizHawk.Emulation.Cores.Computers.AppleII
public ControllerDefinition ControllerDefinition => AppleIIController;
- public IController Controller { private get; set; }
-
public int Frame { get; private set; }
public string SystemId => "AppleII";
public bool DeterministicEmulation => true;
- public void FrameAdvance(bool render, bool rendersound)
+ public void FrameAdvance(IController controller, bool render, bool rendersound)
{
- FrameAdv(render, rendersound);
+ FrameAdv(controller, render, rendersound);
}
public void ResetCounters()
diff --git a/BizHawk.Emulation.Cores/Computers/AppleII/AppleII.cs b/BizHawk.Emulation.Cores/Computers/AppleII/AppleII.cs
index 63abe8d7b5..38a91b7c74 100644
--- a/BizHawk.Emulation.Cores/Computers/AppleII/AppleII.cs
+++ b/BizHawk.Emulation.Cores/Computers/AppleII/AppleII.cs
@@ -140,7 +140,7 @@ namespace BizHawk.Emulation.Cores.Computers.AppleII
});
}
- private void FrameAdv(bool render, bool rendersound)
+ private void FrameAdv(IController controller, bool render, bool rendersound)
{
if (_tracer.Enabled)
{
@@ -151,28 +151,28 @@ namespace BizHawk.Emulation.Cores.Computers.AppleII
_machine.Cpu.TraceCallback = null;
}
- if (Controller.IsPressed("Next Disk") && !_nextPressed)
+ if (controller.IsPressed("Next Disk") && !_nextPressed)
{
_nextPressed = true;
IncrementDisk();
}
- else if (Controller.IsPressed("Previous Disk") && !_prevPressed)
+ else if (controller.IsPressed("Previous Disk") && !_prevPressed)
{
_prevPressed = true;
DecrementDisk();
}
- if (!Controller.IsPressed("Next Disk"))
+ if (!controller.IsPressed("Next Disk"))
{
_nextPressed = false;
}
- if (!Controller.IsPressed("Previous Disk"))
+ if (!controller.IsPressed("Previous Disk"))
{
_prevPressed = false;
}
- _machine.BizFrameAdvance(RealButtons.Where(b => Controller.IsPressed(b)));
+ _machine.BizFrameAdvance(RealButtons.Where(b => controller.IsPressed(b)));
if (IsLagFrame)
{
LagCount++;
diff --git a/BizHawk.Emulation.Cores/Computers/Commodore64/C64.cs b/BizHawk.Emulation.Cores/Computers/Commodore64/C64.cs
index 03e4aff476..d1ced3b781 100644
--- a/BizHawk.Emulation.Cores/Computers/Commodore64/C64.cs
+++ b/BizHawk.Emulation.Cores/Computers/Commodore64/C64.cs
@@ -139,8 +139,7 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64
[SaveState.DoNotSave]
public ControllerDefinition ControllerDefinition { get { return C64ControllerDefinition; } }
- [SaveState.DoNotSave]
- public IController Controller { private get { return _board.Controller; } set { _board.Controller = value; } }
+
[SaveState.DoNotSave]
public IEmulatorServiceProvider ServiceProvider { get; private set; }
@@ -153,8 +152,9 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64
}
// process frame
- public void FrameAdvance(bool render, bool rendersound)
+ public void FrameAdvance(IController controller, bool render, bool rendersound)
{
+ _board.Controller = controller;
do
{
DoCycle();
diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.Core.cs b/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.Core.cs
index 2e603a6d38..0f8a6820a3 100644
--- a/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.Core.cs
+++ b/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.Core.cs
@@ -365,8 +365,11 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
Cpu.S = 0xFD;
}
- public void FrameAdvance(bool render, bool rendersound)
+ private IController _controller;
+
+ public void FrameAdvance(IController controller, bool render, bool rendersound)
{
+ _controller = controller;
StartFrameCond();
while (_tia.LineCount < _tia.NominalNumScanlines)
Cycle();
@@ -392,27 +395,27 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
_frame++;
_islag = true;
- if (Controller.IsPressed("Power"))
+ if (_controller.IsPressed("Power"))
{
HardReset();
}
- if (Controller.IsPressed("Toggle Left Difficulty") && !_leftDifficultySwitchHeld)
+ if (_controller.IsPressed("Toggle Left Difficulty") && !_leftDifficultySwitchHeld)
{
_leftDifficultySwitchPressed ^= true;
_leftDifficultySwitchHeld = true;
}
- else if (!Controller.IsPressed("Toggle Left Difficulty"))
+ else if (!_controller.IsPressed("Toggle Left Difficulty"))
{
_leftDifficultySwitchHeld = false;
}
- if (Controller.IsPressed("Toggle Right Difficulty") && !_rightDifficultySwitchHeld)
+ if (_controller.IsPressed("Toggle Right Difficulty") && !_rightDifficultySwitchHeld)
{
_rightDifficultySwitchPressed ^= true;
_rightDifficultySwitchHeld = true;
}
- else if (!Controller.IsPressed("Toggle Right Difficulty"))
+ else if (!_controller.IsPressed("Toggle Right Difficulty"))
{
_rightDifficultySwitchHeld = false;
}
@@ -453,11 +456,11 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
InputCallbacks.Call();
byte value = 0xFF;
- if (Controller.IsPressed("P1 Up")) { value &= 0xEF; }
- if (Controller.IsPressed("P1 Down")) { value &= 0xDF; }
- if (Controller.IsPressed("P1 Left")) { value &= 0xBF; }
- if (Controller.IsPressed("P1 Right")) { value &= 0x7F; }
- if (Controller.IsPressed("P1 Button")) { value &= 0xF7; }
+ if (_controller.IsPressed("P1 Up")) { value &= 0xEF; }
+ if (_controller.IsPressed("P1 Down")) { value &= 0xDF; }
+ if (_controller.IsPressed("P1 Left")) { value &= 0xBF; }
+ if (_controller.IsPressed("P1 Right")) { value &= 0x7F; }
+ if (_controller.IsPressed("P1 Button")) { value &= 0xF7; }
if (!peek)
{
@@ -472,11 +475,11 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
InputCallbacks.Call();
byte value = 0xFF;
- if (Controller.IsPressed("P2 Up")) { value &= 0xEF; }
- if (Controller.IsPressed("P2 Down")) { value &= 0xDF; }
- if (Controller.IsPressed("P2 Left")) { value &= 0xBF; }
- if (Controller.IsPressed("P2 Right")) { value &= 0x7F; }
- if (Controller.IsPressed("P2 Button")) { value &= 0xF7; }
+ if (_controller.IsPressed("P2 Up")) { value &= 0xEF; }
+ if (_controller.IsPressed("P2 Down")) { value &= 0xDF; }
+ if (_controller.IsPressed("P2 Left")) { value &= 0xBF; }
+ if (_controller.IsPressed("P2 Right")) { value &= 0x7F; }
+ if (_controller.IsPressed("P2 Button")) { value &= 0xF7; }
if (!peek)
{
@@ -489,8 +492,8 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
internal byte ReadConsoleSwitches(bool peek)
{
byte value = 0xFF;
- bool select = Controller.IsPressed("Select");
- bool reset = Controller.IsPressed("Reset");
+ bool select = _controller.IsPressed("Select");
+ bool reset = _controller.IsPressed("Reset");
if (reset) { value &= 0xFE; }
if (select) { value &= 0xFD; }
diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.cs b/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.cs
index a223301e40..aae14890ac 100644
--- a/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.cs
+++ b/BizHawk.Emulation.Cores/Consoles/Atari/2600/Atari2600.cs
@@ -73,8 +73,6 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
public ControllerDefinition ControllerDefinition { get { return Atari2600ControllerDefinition; } }
- public IController Controller { private get; set; }
-
public int Frame { get { return _frame; } set { _frame = value; } }
public bool DeterministicEmulation { get; set; }
@@ -132,12 +130,13 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
using (Atari2600 emu = new Atari2600(new CoreComm(null, null), newgame, rom, null, null))
{
- emu.Controller = new NullController();
-
List framecounts = new List();
emu._tia.FrameEndCallBack = (i) => framecounts.Add(i);
for (int i = 0; i < 71; i++) // run for 71 * 262 lines, since we're in NTSC mode
- emu.FrameAdvance(false, false);
+ {
+ emu.FrameAdvance(NullController.Instance, false, false);
+ }
+
int numpal = framecounts.Count((i) => i > 287);
bool pal = numpal >= 25;
Console.WriteLine("PAL Detection: {0} lines, {1}", numpal, pal);
diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/7800/Atari7800.cs b/BizHawk.Emulation.Cores/Consoles/Atari/7800/Atari7800.cs
index 3d818e62c4..3fb84cf2f8 100644
--- a/BizHawk.Emulation.Cores/Consoles/Atari/7800/Atari7800.cs
+++ b/BizHawk.Emulation.Cores/Consoles/Atari/7800/Atari7800.cs
@@ -99,18 +99,18 @@ namespace BizHawk.Emulation.Cores.Atari.Atari7800
public GameInfo game;
- public void FrameAdvance(bool render, bool rendersound)
+ public void FrameAdvance(IController controller, bool render, bool rendersound)
{
_frame++;
- if (Controller.IsPressed("Power"))
+ if (controller.IsPressed("Power"))
{
// it seems that theMachine.Reset() doesn't clear ram, etc
// this should leave hsram intact but clear most other things
HardReset();
}
- ControlAdapter.Convert(Controller, theMachine.InputState);
+ ControlAdapter.Convert(controller, theMachine.InputState);
theMachine.ComputeNextFrame(_avProvider.Framebuffer);
_islag = theMachine.InputState.Lagged;
@@ -149,8 +149,6 @@ namespace BizHawk.Emulation.Cores.Atari.Atari7800
public Atari7800Control ControlAdapter { get; private set; }
public ControllerDefinition ControllerDefinition { get; private set; }
- public IController Controller { private get; set; }
-
private class ConsoleLogger : ILogger
{
diff --git a/BizHawk.Emulation.Cores/Consoles/Atari/lynx/Lynx.cs b/BizHawk.Emulation.Cores/Consoles/Atari/lynx/Lynx.cs
index d16b09983d..b79a7cfd11 100644
--- a/BizHawk.Emulation.Cores/Consoles/Atari/lynx/Lynx.cs
+++ b/BizHawk.Emulation.Cores/Consoles/Atari/lynx/Lynx.cs
@@ -123,16 +123,16 @@ namespace BizHawk.Emulation.Cores.Atari.Lynx
public IEmulatorServiceProvider ServiceProvider { get; }
- public void FrameAdvance(bool render, bool rendersound = true)
+ public void FrameAdvance(IController controller, bool render, bool rendersound = true)
{
Frame++;
- if (Controller.IsPressed("Power"))
+ if (controller.IsPressed("Power"))
{
LibLynx.Reset(Core);
}
int samples = _soundbuff.Length;
- IsLagFrame = LibLynx.Advance(Core, GetButtons(), _videobuff, _soundbuff, ref samples);
+ IsLagFrame = LibLynx.Advance(Core, GetButtons(controller), _videobuff, _soundbuff, ref samples);
_numsamp = samples / 2; // sound provider wants number of sample pairs
if (IsLagFrame)
{
@@ -173,20 +173,19 @@ namespace BizHawk.Emulation.Cores.Atari.Lynx
};
public ControllerDefinition ControllerDefinition { get { return LynxTroller; } }
- public IController Controller { private get; set; }
- private LibLynx.Buttons GetButtons()
+ private LibLynx.Buttons GetButtons(IController controller)
{
LibLynx.Buttons ret = 0;
- if (Controller.IsPressed("A")) ret |= LibLynx.Buttons.A;
- if (Controller.IsPressed("B")) ret |= LibLynx.Buttons.B;
- if (Controller.IsPressed("Up")) ret |= LibLynx.Buttons.Up;
- if (Controller.IsPressed("Down")) ret |= LibLynx.Buttons.Down;
- if (Controller.IsPressed("Left")) ret |= LibLynx.Buttons.Left;
- if (Controller.IsPressed("Right")) ret |= LibLynx.Buttons.Right;
- if (Controller.IsPressed("Pause")) ret |= LibLynx.Buttons.Pause;
- if (Controller.IsPressed("Option 1")) ret |= LibLynx.Buttons.Option_1;
- if (Controller.IsPressed("Option 2")) ret |= LibLynx.Buttons.Option_2;
+ if (controller.IsPressed("A")) ret |= LibLynx.Buttons.A;
+ if (controller.IsPressed("B")) ret |= LibLynx.Buttons.B;
+ if (controller.IsPressed("Up")) ret |= LibLynx.Buttons.Up;
+ if (controller.IsPressed("Down")) ret |= LibLynx.Buttons.Down;
+ if (controller.IsPressed("Left")) ret |= LibLynx.Buttons.Left;
+ if (controller.IsPressed("Right")) ret |= LibLynx.Buttons.Right;
+ if (controller.IsPressed("Pause")) ret |= LibLynx.Buttons.Pause;
+ if (controller.IsPressed("Option 1")) ret |= LibLynx.Buttons.Option_1;
+ if (controller.IsPressed("Option 2")) ret |= LibLynx.Buttons.Option_2;
return ret;
}
diff --git a/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoVision.cs b/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoVision.cs
index 51831218c7..ff55a581ac 100644
--- a/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoVision.cs
+++ b/BizHawk.Emulation.Cores/Consoles/Coleco/ColecoVision.cs
@@ -76,12 +76,13 @@ namespace BizHawk.Emulation.Cores.ColecoVision
private readonly ColecoVisionControllerDeck ControllerDeck;
- public IController Controller { private get; set; }
-
private const ushort RamSizeMask = 0x03FF;
- public void FrameAdvance(bool render, bool renderSound)
+ private IController _controller;
+
+ public void FrameAdvance(IController controller, bool render, bool renderSound)
{
+ _controller = controller;
Cpu.Debug = Tracer.Enabled;
Frame++;
_isLag = true;
@@ -92,8 +93,8 @@ namespace BizHawk.Emulation.Cores.ColecoVision
Cpu.Logger = (s) => Tracer.Put(s);
}
- byte tempRet1 = ControllerDeck.ReadPort1(Controller, true, true);
- byte tempRet2 = ControllerDeck.ReadPort2(Controller, true, true);
+ byte tempRet1 = ControllerDeck.ReadPort1(controller, true, true);
+ byte tempRet2 = ControllerDeck.ReadPort2(controller, true, true);
bool intPending = (!tempRet1.Bit(4)) | (!tempRet2.Bit(4));
diff --git a/BizHawk.Emulation.Cores/Consoles/Coleco/Input.cs b/BizHawk.Emulation.Cores/Consoles/Coleco/Input.cs
index 9dcbcae9bd..f3479971e5 100644
--- a/BizHawk.Emulation.Cores/Consoles/Coleco/Input.cs
+++ b/BizHawk.Emulation.Cores/Consoles/Coleco/Input.cs
@@ -11,13 +11,13 @@
byte retval;
if (InputPortSelection == InputPortMode.Left)
{
- retval = ControllerDeck.ReadPort1(Controller, true, false);
+ retval = ControllerDeck.ReadPort1(_controller, true, false);
return retval;
}
if (InputPortSelection == InputPortMode.Right)
{
- retval = ControllerDeck.ReadPort1(Controller, false, false);
+ retval = ControllerDeck.ReadPort1(_controller, false, false);
return retval;
}
return 0x7F;
@@ -29,13 +29,13 @@
byte retval;
if (InputPortSelection == InputPortMode.Left)
{
- retval = ControllerDeck.ReadPort2(Controller, true, false);
+ retval = ControllerDeck.ReadPort2(_controller, true, false);
return retval;
}
if (InputPortSelection == InputPortMode.Right)
{
- retval = ControllerDeck.ReadPort2(Controller, false, false);
+ retval = ControllerDeck.ReadPort2(_controller, false, false);
return retval;
}
return 0x7F;
diff --git a/BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.IEmulator.cs b/BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.IEmulator.cs
index 5d5beefd5f..7f7c1e717d 100644
--- a/BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.IEmulator.cs
+++ b/BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.IEmulator.cs
@@ -8,9 +8,7 @@ namespace BizHawk.Emulation.Cores.Intellivision
public ControllerDefinition ControllerDefinition => _controllerDeck.Definition;
- public IController Controller { private get; set; }
-
- public void FrameAdvance(bool render, bool rendersound)
+ public void FrameAdvance(IController controller, bool render, bool rendersound)
{
if (_tracer.Enabled)
{
@@ -25,7 +23,7 @@ namespace BizHawk.Emulation.Cores.Intellivision
_sticRow = -1;
// read the controller state here for now
- GetControllerState();
+ GetControllerState(controller);
// this timer tracks cycles stolen by the STIC during the visible part of the frame, quite a large number of them actually
int delayCycles = 700;
@@ -117,12 +115,12 @@ namespace BizHawk.Emulation.Cores.Intellivision
_lagcount++;
}
- if (Controller.IsPressed("Power"))
+ if (controller.IsPressed("Power"))
{
HardReset();
}
- if (Controller.IsPressed("Reset"))
+ if (controller.IsPressed("Reset"))
{
SoftReset();
}
diff --git a/BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.cs b/BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.cs
index c88e2e2744..809ba7acbb 100644
--- a/BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.cs
+++ b/BizHawk.Emulation.Cores/Consoles/Intellivision/Intellivision.cs
@@ -117,14 +117,14 @@ namespace BizHawk.Emulation.Cores.Intellivision
GraphicsRom = grom;
}
- private void GetControllerState()
+ private void GetControllerState(IController controller)
{
InputCallbacks.Call();
- ushort port1 = _controllerDeck.ReadPort1(Controller);
+ ushort port1 = _controllerDeck.ReadPort1(controller);
_psg.Register[15] = (ushort)(0xFF - port1);
- ushort port2 = _controllerDeck.ReadPort2(Controller);
+ ushort port2 = _controllerDeck.ReadPort2(controller);
_psg.Register[14] = (ushort)(0xFF - port2);
}
diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/MGBAHawk.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/MGBAHawk.cs
index d6d0196889..ae313818fb 100644
--- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/MGBAHawk.cs
+++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/MGBAHawk.cs
@@ -70,12 +70,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA
public ControllerDefinition ControllerDefinition => GBA.GBAController;
- public IController Controller { get; set; }
-
- public void FrameAdvance(bool render, bool rendersound = true)
+ public void FrameAdvance(IController controller, bool render, bool rendersound = true)
{
Frame++;
- if (Controller.IsPressed("Power"))
+ if (controller.IsPressed("Power"))
{
LibmGBA.BizReset(_core);
@@ -85,15 +83,15 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA
IsLagFrame = LibmGBA.BizAdvance(
_core,
- VBANext.GetButtons(Controller),
+ VBANext.GetButtons(controller),
_videobuff,
ref _nsamp,
_soundbuff,
RTCTime(),
- (short)Controller.GetFloat("Tilt X"),
- (short)Controller.GetFloat("Tilt Y"),
- (short)Controller.GetFloat("Tilt Z"),
- (byte)(255 - Controller.GetFloat("Light Sensor")));
+ (short)controller.GetFloat("Tilt X"),
+ (short)controller.GetFloat("Tilt Y"),
+ (short)controller.GetFloat("Tilt Z"),
+ (byte)(255 - controller.GetFloat("Light Sensor")));
if (IsLagFrame)
{
diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/VBANext.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/VBANext.cs
index 3629e5dafa..fd2498cd0e 100644
--- a/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/VBANext.cs
+++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/GBA/VBANext.cs
@@ -97,16 +97,16 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA
public IEmulatorServiceProvider ServiceProvider { get; private set; }
- public void FrameAdvance(bool render, bool rendersound = true)
+ public void FrameAdvance(IController controller, bool render, bool rendersound = true)
{
Frame++;
- if (Controller.IsPressed("Power"))
+ if (controller.IsPressed("Power"))
LibVBANext.Reset(Core);
SyncTraceCallback();
- IsLagFrame = LibVBANext.FrameAdvance(Core, GetButtons(Controller), _videobuff, _soundbuff, out _numsamp, _videopalette);
+ IsLagFrame = LibVBANext.FrameAdvance(Core, GetButtons(controller), _videobuff, _soundbuff, out _numsamp, _videopalette);
if (IsLagFrame)
LagCount++;
@@ -205,7 +205,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA
#region Controller
public ControllerDefinition ControllerDefinition { get { return GBA.GBAController; } }
- public IController Controller { get; set; }
public static LibVBANext.Buttons GetButtons(IController c)
{
diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.IEmulator.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.IEmulator.cs
index 2013e33324..b13d7e4dc8 100644
--- a/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.IEmulator.cs
+++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.IEmulator.cs
@@ -11,11 +11,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
public ControllerDefinition ControllerDefinition => GbController;
- public IController Controller { get; set; }
-
- public void FrameAdvance(bool render, bool rendersound)
+ public void FrameAdvance(IController controller, bool render, bool rendersound)
{
- FrameAdvancePrep();
+ FrameAdvancePrep(controller);
if (_syncSettings.EqualLengthFrames)
{
while (true)
diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.cs
index 10c012ad73..66f76e68d3 100644
--- a/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.cs
+++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Gambatte.cs
@@ -257,34 +257,34 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
_inputCallbacks = ics;
}
- internal void FrameAdvancePrep()
+ internal void FrameAdvancePrep(IController controller)
{
Frame++;
// update our local copy of the controller data
CurrentButtons = 0;
- if (Controller.IsPressed("Up"))
+ if (controller.IsPressed("Up"))
CurrentButtons |= LibGambatte.Buttons.UP;
- if (Controller.IsPressed("Down"))
+ if (controller.IsPressed("Down"))
CurrentButtons |= LibGambatte.Buttons.DOWN;
- if (Controller.IsPressed("Left"))
+ if (controller.IsPressed("Left"))
CurrentButtons |= LibGambatte.Buttons.LEFT;
- if (Controller.IsPressed("Right"))
+ if (controller.IsPressed("Right"))
CurrentButtons |= LibGambatte.Buttons.RIGHT;
- if (Controller.IsPressed("A"))
+ if (controller.IsPressed("A"))
CurrentButtons |= LibGambatte.Buttons.A;
- if (Controller.IsPressed("B"))
+ if (controller.IsPressed("B"))
CurrentButtons |= LibGambatte.Buttons.B;
- if (Controller.IsPressed("Select"))
+ if (controller.IsPressed("Select"))
CurrentButtons |= LibGambatte.Buttons.SELECT;
- if (Controller.IsPressed("Start"))
+ if (controller.IsPressed("Start"))
CurrentButtons |= LibGambatte.Buttons.START;
// the controller callback will set this to false if it actually gets called during the frame
IsLagFrame = true;
- if (Controller.IsPressed("Power"))
+ if (controller.IsPressed("Power"))
{
LibGambatte.gambatte_reset(GambatteState, GetCurrentTime());
}
diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/GambatteLink.IEmulator.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/GambatteLink.IEmulator.cs
index bc4757f97e..8aec5da41f 100644
--- a/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/GambatteLink.IEmulator.cs
+++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/GambatteLink.IEmulator.cs
@@ -9,16 +9,14 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
public ControllerDefinition ControllerDefinition => DualGbController;
- public IController Controller { get; set; }
-
- public void FrameAdvance(bool render, bool rendersound = true)
+ public void FrameAdvance(IController controller, bool render, bool rendersound = true)
{
LCont.Clear();
RCont.Clear();
foreach (var s in DualGbController.BoolButtons)
{
- if (Controller.IsPressed(s))
+ if (controller.IsPressed(s))
{
if (s.Contains("P1 "))
{
@@ -31,7 +29,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
}
}
- bool cablediscosignalNew = Controller.IsPressed("Toggle Cable");
+ bool cablediscosignalNew = controller.IsPressed("Toggle Cable");
if (cablediscosignalNew && !_cablediscosignal)
{
_cableconnected ^= true;
@@ -42,8 +40,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
_cablediscosignal = cablediscosignalNew;
Frame++;
- L.FrameAdvancePrep();
- R.FrameAdvancePrep();
+ L.FrameAdvancePrep(controller);
+ R.FrameAdvancePrep(controller);
unsafe
{
diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/GambatteLink.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/GambatteLink.cs
index 27068b460d..4045604f5f 100644
--- a/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/GambatteLink.cs
+++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/GambatteLink.cs
@@ -26,8 +26,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
LibGambatte.gambatte_linkstatus(L.GambatteState, 259);
LibGambatte.gambatte_linkstatus(R.GambatteState, 259);
- L.Controller = LCont;
- R.Controller = RCont;
L.ConnectInputCallbackSystem(_inputCallbacks);
R.ConnectInputCallbackSystem(_inputCallbacks);
L.ConnectMemoryCallbackSystem(_memorycallbacks);
diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64.cs
index 0153d90070..06e502c0c6 100644
--- a/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64.cs
+++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64.cs
@@ -227,8 +227,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64
RunThreadAction(() => { _pendingThreadTerminate = true; });
}
- public void FrameAdvance(bool render, bool rendersound)
+ public void FrameAdvance(IController controller, bool render, bool rendersound)
{
+ _inputProvider.Controller = controller;
+
IsVIFrame = false;
if (Tracer != null && Tracer.Enabled)
@@ -242,12 +244,12 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64
_audioProvider.RenderSound = rendersound;
- if (Controller.IsPressed("Reset"))
+ if (controller.IsPressed("Reset"))
{
api.soft_reset();
}
- if (Controller.IsPressed("Power"))
+ if (controller.IsPressed("Power"))
{
api.hard_reset();
}
@@ -274,12 +276,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64
get { return _inputProvider.ControllerDefinition; }
}
- public IController Controller
- {
- get { return _inputProvider.Controller; }
- set { _inputProvider.Controller = value; }
- }
-
public void ResetCounters()
{
Frame = 0;
diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.Core.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.Core.cs
index 651db7e1c7..e338c72273 100644
--- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.Core.cs
+++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.Core.cs
@@ -291,10 +291,14 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
}
+ private IController _controller;
+
bool resetSignal;
bool hardResetSignal;
- public void FrameAdvance(bool render, bool rendersound)
+ public void FrameAdvance(IController controller, bool render, bool rendersound)
{
+ _controller = controller;
+
if (Tracer.Enabled)
cpu.TraceCallback = (s) => Tracer.Put(s);
else
@@ -317,32 +321,32 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
//if (resetSignal)
//Controller.UnpressButton("Reset"); TODO fix this
- resetSignal = Controller.IsPressed("Reset");
- hardResetSignal = Controller.IsPressed("Power");
+ resetSignal = controller.IsPressed("Reset");
+ hardResetSignal = controller.IsPressed("Power");
if (Board is FDS)
{
var b = Board as FDS;
- if (Controller.IsPressed("FDS Eject"))
+ if (controller.IsPressed("FDS Eject"))
b.Eject();
for (int i = 0; i < b.NumSides; i++)
- if (Controller.IsPressed("FDS Insert " + i))
+ if (controller.IsPressed("FDS Insert " + i))
b.InsertSide(i);
}
if (_isVS)
{
- if (Controller.IsPressed("Service Switch"))
+ if (controller.IsPressed("Service Switch"))
VS_service = 1;
else
VS_service = 0;
- if (Controller.IsPressed("Insert Coin P1"))
+ if (controller.IsPressed("Insert Coin P1"))
VS_coin_inserted |= 1;
else
VS_coin_inserted &= 2;
- if (Controller.IsPressed("Insert Coin P2"))
+ if (controller.IsPressed("Insert Coin P2"))
VS_coin_inserted |= 2;
else
VS_coin_inserted &= 1;
@@ -698,7 +702,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
void write_joyport(byte value)
{
var si = new StrobeInfo(latched4016, value);
- ControllerDeck.Strobe(si, Controller);
+ ControllerDeck.Strobe(si, _controller);
latched4016 = value;
}
@@ -710,11 +714,11 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
if (_isVS)
{
// for whatever reason, in VS left and right controller have swapped regs
- ret = addr == 0x4017 ? ControllerDeck.ReadA(Controller) : ControllerDeck.ReadB(Controller);
+ ret = addr == 0x4017 ? ControllerDeck.ReadA(_controller) : ControllerDeck.ReadB(_controller);
}
else
{
- ret = addr == 0x4016 ? ControllerDeck.ReadA(Controller) : ControllerDeck.ReadB(Controller);
+ ret = addr == 0x4016 ? ControllerDeck.ReadA(_controller) : ControllerDeck.ReadB(_controller);
}
ret &= 0x1f;
diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.cs
index df41d5a016..800ca1882a 100644
--- a/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.cs
+++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/NES/NES.cs
@@ -354,8 +354,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
public ControllerDefinition ControllerDefinition { get; private set; }
- public IController Controller { private get; set; }
-
private int _frame;
public int Frame { get { return _frame; } set { _frame = value; } }
diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.cs
index 0e7543d50b..9559ddfee5 100644
--- a/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.cs
+++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.cs
@@ -112,7 +112,6 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES
#region Controller
public ControllerDefinition ControllerDefinition { get; private set; }
- public IController Controller { private get; set; }
void SetControllerDefinition()
{
@@ -155,43 +154,43 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES
private static PadEnt[] PadP1 = GetPadList(1);
private static PadEnt[] PadP2 = GetPadList(2);
- private int GetPad(IEnumerable buttons)
+ private int GetPad(IController controller, IEnumerable buttons)
{
int ret = 0;
foreach (var b in buttons)
{
- if (Controller.IsPressed(b.Name))
+ if (controller.IsPressed(b.Name))
ret |= b.Mask;
}
return ret;
}
- void SetPads(out int j1, out int j2)
+ void SetPads(IController controller, out int j1, out int j2)
{
if (_syncSettings.LeftPortConnected)
- j1 = GetPad(PadP1) | unchecked((int)0xffffff00);
+ j1 = GetPad(controller, PadP1) | unchecked((int)0xffffff00);
else
j1 = 0;
if (_syncSettings.RightPortConnected)
- j2 = GetPad(_syncSettings.LeftPortConnected ? PadP2 : PadP1) | unchecked((int)0xffffff00);
+ j2 = GetPad(controller, _syncSettings.LeftPortConnected ? PadP2 : PadP1) | unchecked((int)0xffffff00);
else
j2 = 0;
}
#endregion
- public void FrameAdvance(bool render, bool rendersound = true)
+ public void FrameAdvance(IController controller, bool render, bool rendersound = true)
{
CheckDisposed();
using (FP.Save())
{
- if (Controller.IsPressed("Power"))
+ if (controller.IsPressed("Power"))
QN.qn_reset(Context, true);
- if (Controller.IsPressed("Reset"))
+ if (controller.IsPressed("Reset"))
QN.qn_reset(Context, false);
int j1, j2;
- SetPads(out j1, out j2);
+ SetPads(controller, out j1, out j2);
if (Tracer.Enabled)
QN.qn_set_tracecb(Context, _tracecb);
diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesCore.IEmulator.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesCore.IEmulator.cs
index b7e415577d..78b4f9c454 100644
--- a/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesCore.IEmulator.cs
+++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesCore.IEmulator.cs
@@ -10,10 +10,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
public ControllerDefinition ControllerDefinition => _controllerDeck.Definition;
- public IController Controller { private get; set; }
-
- public void FrameAdvance(bool render, bool rendersound)
+ public void FrameAdvance(IController controller, bool render, bool rendersound)
{
+ _controller = controller;
+
/* if the input poll callback is called, it will set this to false
* this has to be done before we save the per-frame state in deterministic
* mode, because in there, the core actually advances, and might advance
@@ -40,7 +40,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
bw.Write(CoreSaveState());
bw.Write(false); // not framezero
var ssc = new SaveController();
- ssc.CopyFrom(Controller);
+ ssc.CopyFrom(controller);
ssc.Serialize(bw);
bw.Close();
_savestatebuff = ms.ToArray();
@@ -49,13 +49,13 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
// speedup when sound rendering is not needed
Api.QUERY_set_audio_sample(rendersound ? _soundcb : null);
- bool resetSignal = Controller.IsPressed("Reset");
+ bool resetSignal = controller.IsPressed("Reset");
if (resetSignal)
{
Api.CMD_reset();
}
- bool powerSignal = Controller.IsPressed("Power");
+ bool powerSignal = controller.IsPressed("Power");
if (powerSignal)
{
Api.CMD_power();
diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesCore.IStatable.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesCore.IStatable.cs
index de565bf3d7..c5ce9019c7 100644
--- a/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesCore.IStatable.cs
+++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesCore.IStatable.cs
@@ -60,12 +60,12 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
{
var ssc = new SaveController(ControllerDefinition);
ssc.DeSerialize(reader);
- IController tmp = Controller;
- Controller = ssc;
+ IController tmp = _controller;
+ _controller = ssc;
_nocallbacks = true;
- FrameAdvance(false, false);
+ FrameAdvance(ssc, false, false);
_nocallbacks = false;
- Controller = tmp;
+ _controller = tmp;
ssc.Serialize(bw);
}
else // hack: dummy controller info
diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesCore.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesCore.cs
index bc270de070..924973f3d8 100644
--- a/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesCore.cs
+++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES/LibsnesCore.cs
@@ -190,6 +190,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
private readonly LibsnesApi.snes_trace_t _tracecb;
private readonly LibsnesApi.snes_audio_sample_t _soundcb;
+ private IController _controller;
private LoadParams _currLoadParams;
private SpeexResampler _resampler;
private int _timeFrameCounter;
@@ -418,7 +419,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
/// for regular controllers, one bit D0 of button status. for other controls, varying ranges depending on id
private short snes_input_state(int port, int device, int index, int id)
{
- return _controllerDeck.CoreInputState(Controller, port, device, index, id);
+ return _controllerDeck.CoreInputState(_controller, port, device, index, id);
}
private void snes_input_poll()
diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES9X/Snes9x.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES9X/Snes9x.cs
index 85d0f588a9..31ff2e9bb1 100644
--- a/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES9X/Snes9x.cs
+++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES9X/Snes9x.cs
@@ -19,8 +19,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES9X
get { return NullController.Instance.Definition; }
}
- public IController Controller { private get; set; }
-
#endregion
public void Dispose()
@@ -39,7 +37,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES9X
public IEmulatorServiceProvider ServiceProvider { get; private set; }
- public void FrameAdvance(bool render, bool rendersound = true)
+ public void FrameAdvance(IController controller, bool render, bool rendersound = true)
{
Frame++;
diff --git a/BizHawk.Emulation.Cores/Consoles/PC Engine/PCEngine.IEmulator.cs b/BizHawk.Emulation.Cores/Consoles/PC Engine/PCEngine.IEmulator.cs
index b8ed72cb9b..ce4d1af49a 100644
--- a/BizHawk.Emulation.Cores/Consoles/PC Engine/PCEngine.IEmulator.cs
+++ b/BizHawk.Emulation.Cores/Consoles/PC Engine/PCEngine.IEmulator.cs
@@ -8,10 +8,9 @@ namespace BizHawk.Emulation.Cores.PCEngine
public ControllerDefinition ControllerDefinition => PCEngineController;
- public IController Controller { private get; set; }
-
- public void FrameAdvance(bool render, bool rendersound)
+ public void FrameAdvance(IController controller, bool render, bool rendersound)
{
+ _controller = controller;
_lagged = true;
DriveLightOn = false;
Frame++;
diff --git a/BizHawk.Emulation.Cores/Consoles/PC Engine/PCEngine.Input.cs b/BizHawk.Emulation.Cores/Consoles/PC Engine/PCEngine.Input.cs
index 54fb357fad..c40788c08a 100644
--- a/BizHawk.Emulation.Cores/Consoles/PC Engine/PCEngine.Input.cs
+++ b/BizHawk.Emulation.Cores/Consoles/PC Engine/PCEngine.Input.cs
@@ -74,18 +74,18 @@ namespace BizHawk.Emulation.Cores.PCEngine
_lagged = false;
if (SEL == false) // return buttons
{
- if (Controller.IsPressed("P" + player + " B1")) value &= 0xFE;
- if (Controller.IsPressed("P" + player + " B2")) value &= 0xFD;
- if (Controller.IsPressed("P" + player + " Select")) value &= 0xFB;
- if (Controller.IsPressed("P" + player + " Run")) value &= 0xF7;
+ if (_controller.IsPressed("P" + player + " B1")) value &= 0xFE;
+ if (_controller.IsPressed("P" + player + " B2")) value &= 0xFD;
+ if (_controller.IsPressed("P" + player + " Select")) value &= 0xFB;
+ if (_controller.IsPressed("P" + player + " Run")) value &= 0xF7;
}
else
{
//return directions
- if (Controller.IsPressed("P" + player + " Up")) value &= 0xFE;
- if (Controller.IsPressed("P" + player + " Right")) value &= 0xFD;
- if (Controller.IsPressed("P" + player + " Down")) value &= 0xFB;
- if (Controller.IsPressed("P" + player + " Left")) value &= 0xF7;
+ if (_controller.IsPressed("P" + player + " Up")) value &= 0xFE;
+ if (_controller.IsPressed("P" + player + " Right")) value &= 0xFD;
+ if (_controller.IsPressed("P" + player + " Down")) value &= 0xFB;
+ if (_controller.IsPressed("P" + player + " Left")) value &= 0xF7;
}
}
diff --git a/BizHawk.Emulation.Cores/Consoles/PC Engine/PCEngine.cs b/BizHawk.Emulation.Cores/Consoles/PC Engine/PCEngine.cs
index 6f198ea5b7..021d38d468 100644
--- a/BizHawk.Emulation.Cores/Consoles/PC Engine/PCEngine.cs
+++ b/BizHawk.Emulation.Cores/Consoles/PC Engine/PCEngine.cs
@@ -113,6 +113,7 @@ namespace BizHawk.Emulation.Cores.PCEngine
private VPC VPC;
private ScsiCDBus SCSI;
private ADPCM ADPCM;
+ private IController _controller;
public HuC6280PSG PSG;
internal CDAudio CDAudio;
@@ -141,7 +142,6 @@ namespace BizHawk.Emulation.Cores.PCEngine
private void Init(GameInfo game, byte[] rom)
{
- Controller = NullController.Instance;
Cpu = new HuC6280(MemoryCallbacks);
VCE = new VCE();
VDC1 = new VDC(this, Cpu, VCE);
diff --git a/BizHawk.Emulation.Cores/Consoles/Sega/SMS/SMS.IEmulator.cs b/BizHawk.Emulation.Cores/Consoles/Sega/SMS/SMS.IEmulator.cs
index 1caf482386..6692a45d6b 100644
--- a/BizHawk.Emulation.Cores/Consoles/Sega/SMS/SMS.IEmulator.cs
+++ b/BizHawk.Emulation.Cores/Consoles/Sega/SMS/SMS.IEmulator.cs
@@ -19,10 +19,9 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem
}
}
- public IController Controller { private get; set; }
-
- public void FrameAdvance(bool render, bool rendersound)
+ public void FrameAdvance(IController controller, bool render, bool rendersound)
{
+ _controller = controller;
_lagged = true;
Frame++;
PSG.BeginFrame(Cpu.TotalExecutedCycles);
@@ -39,7 +38,7 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem
if (IsGameGear == false)
{
- Cpu.NonMaskableInterrupt = Controller.IsPressed("Pause");
+ Cpu.NonMaskableInterrupt = controller.IsPressed("Pause");
}
if (IsGame3D && Settings.Fix3D)
diff --git a/BizHawk.Emulation.Cores/Consoles/Sega/SMS/SMS.Input.cs b/BizHawk.Emulation.Cores/Consoles/Sega/SMS/SMS.Input.cs
index 2b9afb0d22..06fa88e9ea 100644
--- a/BizHawk.Emulation.Cores/Consoles/Sega/SMS/SMS.Input.cs
+++ b/BizHawk.Emulation.Cores/Consoles/Sega/SMS/SMS.Input.cs
@@ -31,15 +31,15 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem
_lagged = false;
byte value = 0xFF;
- if (Controller.IsPressed("P1 Up")) value &= 0xFE;
- if (Controller.IsPressed("P1 Down")) value &= 0xFD;
- if (Controller.IsPressed("P1 Left")) value &= 0xFB;
- if (Controller.IsPressed("P1 Right")) value &= 0xF7;
- if (Controller.IsPressed("P1 B1")) value &= 0xEF;
- if (Controller.IsPressed("P1 B2")) value &= 0xDF;
+ if (_controller.IsPressed("P1 Up")) value &= 0xFE;
+ if (_controller.IsPressed("P1 Down")) value &= 0xFD;
+ if (_controller.IsPressed("P1 Left")) value &= 0xFB;
+ if (_controller.IsPressed("P1 Right")) value &= 0xF7;
+ if (_controller.IsPressed("P1 B1")) value &= 0xEF;
+ if (_controller.IsPressed("P1 B2")) value &= 0xDF;
- if (Controller.IsPressed("P2 Up")) value &= 0xBF;
- if (Controller.IsPressed("P2 Down")) value &= 0x7F;
+ if (_controller.IsPressed("P2 Up")) value &= 0xBF;
+ if (_controller.IsPressed("P2 Down")) value &= 0x7F;
return value;
}
@@ -50,12 +50,12 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem
_lagged = false;
byte value = 0xFF;
- if (Controller.IsPressed("P2 Left")) value &= 0xFE;
- if (Controller.IsPressed("P2 Right")) value &= 0xFD;
- if (Controller.IsPressed("P2 B1")) value &= 0xFB;
- if (Controller.IsPressed("P2 B2")) value &= 0xF7;
+ if (_controller.IsPressed("P2 Left")) value &= 0xFE;
+ if (_controller.IsPressed("P2 Right")) value &= 0xFD;
+ if (_controller.IsPressed("P2 B1")) value &= 0xFB;
+ if (_controller.IsPressed("P2 B2")) value &= 0xF7;
- if (Controller.IsPressed("Reset")) value &= 0xEF;
+ if (_controller.IsPressed("Reset")) value &= 0xEF;
if ((Port3F & 0x0F) == 5)
{
@@ -83,8 +83,8 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem
}
byte value = 0xFF;
- if ((Controller.IsPressed("Pause") && !IsGameGear) ||
- (Controller.IsPressed("P1 Start") && IsGameGear))
+ if ((_controller.IsPressed("Pause") && !IsGameGear) ||
+ (_controller.IsPressed("P1 Start") && IsGameGear))
{
value ^= 0x80;
}
diff --git a/BizHawk.Emulation.Cores/Consoles/Sega/SMS/SMS.cs b/BizHawk.Emulation.Cores/Consoles/Sega/SMS/SMS.cs
index 8dd55effa4..bc66dad4fd 100644
--- a/BizHawk.Emulation.Cores/Consoles/Sega/SMS/SMS.cs
+++ b/BizHawk.Emulation.Cores/Consoles/Sega/SMS/SMS.cs
@@ -46,6 +46,7 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem
public bool IsSG1000 { get; set; }
private bool HasYM2413 = false;
+ private IController _controller;
private int frame = 0;
@@ -113,11 +114,6 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem
HasYM2413 = true;
}
- if (Controller == null)
- {
- Controller = NullController.Instance;
- }
-
Cpu = new Z80A
{
RegisterSP = 0xDFF0,
diff --git a/BizHawk.Emulation.Cores/Consoles/Sega/SMS/TerebiOekaki.cs b/BizHawk.Emulation.Cores/Consoles/Sega/SMS/TerebiOekaki.cs
index 19bba7e8e0..a42a1b2704 100644
--- a/BizHawk.Emulation.Cores/Consoles/Sega/SMS/TerebiOekaki.cs
+++ b/BizHawk.Emulation.Cores/Consoles/Sega/SMS/TerebiOekaki.cs
@@ -22,10 +22,10 @@
}
if (address == 0xA000)
{
- if (Controller.IsPressed("P1 Left")) xCoord++;
- if (Controller.IsPressed("P1 Right")) xCoord++;
- if (Controller.IsPressed("P1 Up")) yCoord--;
- if (Controller.IsPressed("P1 Down")) yCoord++;
+ if (_controller.IsPressed("P1 Left")) xCoord++;
+ if (_controller.IsPressed("P1 Right")) xCoord++;
+ if (_controller.IsPressed("P1 Up")) yCoord--;
+ if (_controller.IsPressed("P1 Down")) yCoord++;
return 0;
//if (!Controller["P1 B1"]) return 0;
diff --git a/BizHawk.Emulation.Cores/Consoles/Sega/Saturn/Yabause.cs b/BizHawk.Emulation.Cores/Consoles/Sega/Saturn/Yabause.cs
index 5da1aca69b..f04cf1aa12 100644
--- a/BizHawk.Emulation.Cores/Consoles/Sega/Saturn/Yabause.cs
+++ b/BizHawk.Emulation.Cores/Consoles/Sega/Saturn/Yabause.cs
@@ -167,8 +167,6 @@ namespace BizHawk.Emulation.Cores.Sega.Saturn
get { return SaturnController; }
}
- public IController Controller { private get; set; }
-
public bool GLMode { get; private set; }
public void SetGLRes(int factor, int width, int height)
@@ -203,7 +201,7 @@ namespace BizHawk.Emulation.Cores.Sega.Saturn
LibYabause.libyabause_glresize(width, height);
}
- public void FrameAdvance(bool render, bool rendersound = true)
+ public void FrameAdvance(IController controller, bool render, bool rendersound = true)
{
int w, h, nsamp;
@@ -214,64 +212,64 @@ namespace BizHawk.Emulation.Cores.Sega.Saturn
LibYabause.Buttons1 p21 = (LibYabause.Buttons1)0xff;
LibYabause.Buttons2 p22 = (LibYabause.Buttons2)0xff;
- if (Controller.IsPressed("P1 A"))
+ if (controller.IsPressed("P1 A"))
p11 &= ~LibYabause.Buttons1.A;
- if (Controller.IsPressed("P1 B"))
+ if (controller.IsPressed("P1 B"))
p11 &= ~LibYabause.Buttons1.B;
- if (Controller.IsPressed("P1 C"))
+ if (controller.IsPressed("P1 C"))
p11 &= ~LibYabause.Buttons1.C;
- if (Controller.IsPressed("P1 Start"))
+ if (controller.IsPressed("P1 Start"))
p11 &= ~LibYabause.Buttons1.S;
- if (Controller.IsPressed("P1 Left"))
+ if (controller.IsPressed("P1 Left"))
p11 &= ~LibYabause.Buttons1.L;
- if (Controller.IsPressed("P1 Right"))
+ if (controller.IsPressed("P1 Right"))
p11 &= ~LibYabause.Buttons1.R;
- if (Controller.IsPressed("P1 Up"))
+ if (controller.IsPressed("P1 Up"))
p11 &= ~LibYabause.Buttons1.U;
- if (Controller.IsPressed("P1 Down"))
+ if (controller.IsPressed("P1 Down"))
p11 &= ~LibYabause.Buttons1.D;
- if (Controller.IsPressed("P1 L"))
+ if (controller.IsPressed("P1 L"))
p12 &= ~LibYabause.Buttons2.L;
- if (Controller.IsPressed("P1 R"))
+ if (controller.IsPressed("P1 R"))
p12 &= ~LibYabause.Buttons2.R;
- if (Controller.IsPressed("P1 X"))
+ if (controller.IsPressed("P1 X"))
p12 &= ~LibYabause.Buttons2.X;
- if (Controller.IsPressed("P1 Y"))
+ if (controller.IsPressed("P1 Y"))
p12 &= ~LibYabause.Buttons2.Y;
- if (Controller.IsPressed("P1 Z"))
+ if (controller.IsPressed("P1 Z"))
p12 &= ~LibYabause.Buttons2.Z;
- if (Controller.IsPressed("P2 A"))
+ if (controller.IsPressed("P2 A"))
p21 &= ~LibYabause.Buttons1.A;
- if (Controller.IsPressed("P2 B"))
+ if (controller.IsPressed("P2 B"))
p21 &= ~LibYabause.Buttons1.B;
- if (Controller.IsPressed("P2 C"))
+ if (controller.IsPressed("P2 C"))
p21 &= ~LibYabause.Buttons1.C;
- if (Controller.IsPressed("P2 Start"))
+ if (controller.IsPressed("P2 Start"))
p21 &= ~LibYabause.Buttons1.S;
- if (Controller.IsPressed("P2 Left"))
+ if (controller.IsPressed("P2 Left"))
p21 &= ~LibYabause.Buttons1.L;
- if (Controller.IsPressed("P2 Right"))
+ if (controller.IsPressed("P2 Right"))
p21 &= ~LibYabause.Buttons1.R;
- if (Controller.IsPressed("P2 Up"))
+ if (controller.IsPressed("P2 Up"))
p21 &= ~LibYabause.Buttons1.U;
- if (Controller.IsPressed("P2 Down"))
+ if (controller.IsPressed("P2 Down"))
p21 &= ~LibYabause.Buttons1.D;
- if (Controller.IsPressed("P2 L"))
+ if (controller.IsPressed("P2 L"))
p22 &= ~LibYabause.Buttons2.L;
- if (Controller.IsPressed("P2 R"))
+ if (controller.IsPressed("P2 R"))
p22 &= ~LibYabause.Buttons2.R;
- if (Controller.IsPressed("P2 X"))
+ if (controller.IsPressed("P2 X"))
p22 &= ~LibYabause.Buttons2.X;
- if (Controller.IsPressed("P2 Y"))
+ if (controller.IsPressed("P2 Y"))
p22 &= ~LibYabause.Buttons2.Y;
- if (Controller.IsPressed("P2 Z"))
+ if (controller.IsPressed("P2 Z"))
p22 &= ~LibYabause.Buttons2.Z;
- if (Controller.IsPressed("Reset"))
+ if (controller.IsPressed("Reset"))
LibYabause.libyabause_softreset();
- if (Controller.IsPressed("Power"))
+ if (controller.IsPressed("Power"))
LibYabause.libyabause_hardreset();
LibYabause.libyabause_setpads(p11, p12, p21, p22);
diff --git a/BizHawk.Emulation.Cores/Consoles/Sega/gpgx/GPGX.IEmulator.cs b/BizHawk.Emulation.Cores/Consoles/Sega/gpgx/GPGX.IEmulator.cs
index 8181b04f79..b2b07ce299 100644
--- a/BizHawk.Emulation.Cores/Consoles/Sega/gpgx/GPGX.IEmulator.cs
+++ b/BizHawk.Emulation.Cores/Consoles/Sega/gpgx/GPGX.IEmulator.cs
@@ -9,14 +9,12 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx
public ControllerDefinition ControllerDefinition { get; private set; }
- public IController Controller { private get; set; }
-
// TODO: use render and rendersound
- public void FrameAdvance(bool render, bool rendersound = true)
+ public void FrameAdvance(IController controller, bool render, bool rendersound = true)
{
- if (Controller.IsPressed("Reset"))
+ if (controller.IsPressed("Reset"))
LibGPGX.gpgx_reset(false);
- if (Controller.IsPressed("Power"))
+ if (controller.IsPressed("Power"))
LibGPGX.gpgx_reset(true);
// do we really have to get each time? nothing has changed
@@ -25,7 +23,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx
ControlConverter.ScreenWidth = vwidth;
ControlConverter.ScreenHeight = vheight;
- ControlConverter.Convert(Controller, input);
+ ControlConverter.Convert(controller, input);
if (!LibGPGX.gpgx_put_control(input, inputsize))
throw new Exception("gpgx_put_control() failed!");
diff --git a/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGX.IEmulator.cs b/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGX.IEmulator.cs
index 382a0935d2..40a945657f 100644
--- a/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGX.IEmulator.cs
+++ b/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGX.IEmulator.cs
@@ -9,14 +9,12 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx64
public ControllerDefinition ControllerDefinition { get; private set; }
- public IController Controller { private get; set; }
-
// TODO: use render and rendersound
- public void FrameAdvance(bool render, bool rendersound = true)
+ public void FrameAdvance(IController controller, bool render, bool rendersound = true)
{
- if (Controller.IsPressed("Reset"))
+ if (controller.IsPressed("Reset"))
Core.gpgx_reset(false);
- if (Controller.IsPressed("Power"))
+ if (controller.IsPressed("Power"))
Core.gpgx_reset(true);
// this shouldn't be needed, as nothing has changed
@@ -25,7 +23,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx64
ControlConverter.ScreenWidth = vwidth;
ControlConverter.ScreenHeight = vheight;
- ControlConverter.Convert(Controller, input);
+ ControlConverter.Convert(controller, input);
if (!Core.gpgx_put_control(input, inputsize))
throw new Exception("gpgx_put_control() failed!");
diff --git a/BizHawk.Emulation.Cores/Consoles/Sony/PSP/PSP.cs b/BizHawk.Emulation.Cores/Consoles/Sony/PSP/PSP.cs
index a3fa094cf8..8cbbeb28cc 100644
--- a/BizHawk.Emulation.Cores/Consoles/Sony/PSP/PSP.cs
+++ b/BizHawk.Emulation.Cores/Consoles/Sony/PSP/PSP.cs
@@ -39,7 +39,6 @@ namespace BizHawk.Emulation.Cores.Sony.PSP
};
public ControllerDefinition ControllerDefinition { get { return PSPController; } }
- public IController Controller { private get; set; }
public bool DeterministicEmulation { get { return true; } }
public string SystemId { get { return "PSP"; } }
public CoreComm CoreComm { get; private set; }
@@ -106,10 +105,9 @@ namespace BizHawk.Emulation.Cores.Sony.PSP
}
}
- private void UpdateInput()
+ private void UpdateInput(IController c)
{
PPSSPPDll.Buttons b = 0;
- var c = Controller;
if (c.IsPressed("Up")) b |= PPSSPPDll.Buttons.UP;
if (c.IsPressed("Down")) b |= PPSSPPDll.Buttons.DOWN;
if (c.IsPressed("Left")) b |= PPSSPPDll.Buttons.LEFT;
@@ -136,10 +134,10 @@ namespace BizHawk.Emulation.Cores.Sony.PSP
}
- public void FrameAdvance(bool render, bool rendersound = true)
+ public void FrameAdvance(IController controller, bool render, bool rendersound = true)
{
Frame++;
- UpdateInput();
+ UpdateInput(controller);
PPSSPPDll.BizAdvance(screenbuffer, input);
// problem 1: audio can be 48khz, if a particular core parameter is set. we're not accounting for that.
diff --git a/BizHawk.Emulation.Cores/Consoles/Sony/PSX/Octoshock.cs b/BizHawk.Emulation.Cores/Consoles/Sony/PSX/Octoshock.cs
index b9fd849359..3a56875142 100644
--- a/BizHawk.Emulation.Cores/Consoles/Sony/PSX/Octoshock.cs
+++ b/BizHawk.Emulation.Cores/Consoles/Sony/PSX/Octoshock.cs
@@ -495,51 +495,51 @@ namespace BizHawk.Emulation.Cores.Sony.PSX
if (fioCfg.Devices8[slot] == OctoshockDll.ePeripheralType.NegCon)
{
//1,2,4 skipped (would be Select, L3, R3 on other pads)
- if (Controller.IsPressed(pstring + "Start")) buttons |= 8;
- if (Controller.IsPressed(pstring + "Up")) buttons |= 16;
- if (Controller.IsPressed(pstring + "Right")) buttons |= 32;
- if (Controller.IsPressed(pstring + "Down")) buttons |= 64;
- if (Controller.IsPressed(pstring + "Left")) buttons |= 128;
+ if (_controller.IsPressed(pstring + "Start")) buttons |= 8;
+ if (_controller.IsPressed(pstring + "Up")) buttons |= 16;
+ if (_controller.IsPressed(pstring + "Right")) buttons |= 32;
+ if (_controller.IsPressed(pstring + "Down")) buttons |= 64;
+ if (_controller.IsPressed(pstring + "Left")) buttons |= 128;
//256,512,1024 skipped (would be L2, R2, L1 on other pads)
- if (Controller.IsPressed(pstring + "R")) buttons |= 2048;
- if (Controller.IsPressed(pstring + "B")) buttons |= 4096;
- if (Controller.IsPressed(pstring + "A")) buttons |= 8192;
+ if (_controller.IsPressed(pstring + "R")) buttons |= 2048;
+ if (_controller.IsPressed(pstring + "B")) buttons |= 4096;
+ if (_controller.IsPressed(pstring + "A")) buttons |= 8192;
- byte twist = (byte)Controller.GetFloat(pstring + "Twist");
- byte analog1 = (byte)Controller.GetFloat(pstring + "1");
- byte analog2 = (byte)Controller.GetFloat(pstring + "2");
- byte analogL = (byte)Controller.GetFloat(pstring + "L");
+ byte twist = (byte)_controller.GetFloat(pstring + "Twist");
+ byte analog1 = (byte)_controller.GetFloat(pstring + "1");
+ byte analog2 = (byte)_controller.GetFloat(pstring + "2");
+ byte analogL = (byte)_controller.GetFloat(pstring + "L");
OctoshockDll.shock_Peripheral_SetPadInput(psx, portNum, buttons, twist, analog1, analog2, analogL);
}
else
{
- if (Controller.IsPressed(pstring + "Select")) buttons |= 1;
- if (Controller.IsPressed(pstring + "Start")) buttons |= 8;
- if (Controller.IsPressed(pstring + "Up")) buttons |= 16;
- if (Controller.IsPressed(pstring + "Right")) buttons |= 32;
- if (Controller.IsPressed(pstring + "Down")) buttons |= 64;
- if (Controller.IsPressed(pstring + "Left")) buttons |= 128;
- if (Controller.IsPressed(pstring + "L2")) buttons |= 256;
- if (Controller.IsPressed(pstring + "R2")) buttons |= 512;
- if (Controller.IsPressed(pstring + "L1")) buttons |= 1024;
- if (Controller.IsPressed(pstring + "R1")) buttons |= 2048;
- if (Controller.IsPressed(pstring + "Triangle")) buttons |= 4096;
- if (Controller.IsPressed(pstring + "Circle")) buttons |= 8192;
- if (Controller.IsPressed(pstring + "Cross")) buttons |= 16384;
- if (Controller.IsPressed(pstring + "Square")) buttons |= 32768;
+ if (_controller.IsPressed(pstring + "Select")) buttons |= 1;
+ if (_controller.IsPressed(pstring + "Start")) buttons |= 8;
+ if (_controller.IsPressed(pstring + "Up")) buttons |= 16;
+ if (_controller.IsPressed(pstring + "Right")) buttons |= 32;
+ if (_controller.IsPressed(pstring + "Down")) buttons |= 64;
+ if (_controller.IsPressed(pstring + "Left")) buttons |= 128;
+ if (_controller.IsPressed(pstring + "L2")) buttons |= 256;
+ if (_controller.IsPressed(pstring + "R2")) buttons |= 512;
+ if (_controller.IsPressed(pstring + "L1")) buttons |= 1024;
+ if (_controller.IsPressed(pstring + "R1")) buttons |= 2048;
+ if (_controller.IsPressed(pstring + "Triangle")) buttons |= 4096;
+ if (_controller.IsPressed(pstring + "Circle")) buttons |= 8192;
+ if (_controller.IsPressed(pstring + "Cross")) buttons |= 16384;
+ if (_controller.IsPressed(pstring + "Square")) buttons |= 32768;
byte left_x = 0, left_y = 0, right_x = 0, right_y = 0;
if (fioCfg.Devices8[slot] == OctoshockDll.ePeripheralType.DualShock || fioCfg.Devices8[slot] == OctoshockDll.ePeripheralType.DualAnalog)
{
- if (Controller.IsPressed(pstring + "L3")) buttons |= 2;
- if (Controller.IsPressed(pstring + "R3")) buttons |= 4;
- if (Controller.IsPressed(pstring + "MODE")) buttons |= 65536;
+ if (_controller.IsPressed(pstring + "L3")) buttons |= 2;
+ if (_controller.IsPressed(pstring + "R3")) buttons |= 4;
+ if (_controller.IsPressed(pstring + "MODE")) buttons |= 65536;
- left_x = (byte)Controller.GetFloat(pstring + "LStick X");
- left_y = (byte)Controller.GetFloat(pstring + "LStick Y");
- right_x = (byte)Controller.GetFloat(pstring + "RStick X");
- right_y = (byte)Controller.GetFloat(pstring + "RStick Y");
+ left_x = (byte)_controller.GetFloat(pstring + "LStick X");
+ left_y = (byte)_controller.GetFloat(pstring + "LStick Y");
+ right_x = (byte)_controller.GetFloat(pstring + "RStick X");
+ right_y = (byte)_controller.GetFloat(pstring + "RStick Y");
}
OctoshockDll.shock_Peripheral_SetPadInput(psx, portNum, buttons, left_x, left_y, right_x, right_y);
@@ -692,7 +692,7 @@ namespace BizHawk.Emulation.Cores.Sony.PSX
//if tray open is requested, and valid, apply it
//in the first frame, go ahead and open it up so we have a chance to put a disc in it
- if (Controller.IsPressed("Open") && !CurrentTrayOpen || Frame == 0)
+ if (_controller.IsPressed("Open") && !CurrentTrayOpen || Frame == 0)
{
OctoshockDll.shock_OpenTray(psx);
CurrentTrayOpen = true;
@@ -700,7 +700,7 @@ namespace BizHawk.Emulation.Cores.Sony.PSX
//change the disc if needed, and valid
//also if frame is 0, we need to set a disc no matter what
- int requestedDisc = (int)Controller.GetFloat("Disc Select");
+ int requestedDisc = (int)_controller.GetFloat("Disc Select");
if (requestedDisc != CurrentDiscIndexMounted && CurrentTrayOpen
|| Frame == 0
)
@@ -728,22 +728,25 @@ namespace BizHawk.Emulation.Cores.Sony.PSX
}
//if tray close is requested, and valid, apply it.
- if (Controller.IsPressed("Close") && CurrentTrayOpen)
+ if (_controller.IsPressed("Close") && CurrentTrayOpen)
{
OctoshockDll.shock_CloseTray(psx);
CurrentTrayOpen = false;
}
//if frame is 0 and user has made no preference, close the tray
- if (!Controller.IsPressed("Close") && !Controller.IsPressed("Open") && Frame == 0 && CurrentTrayOpen)
+ if (!_controller.IsPressed("Close") && !_controller.IsPressed("Open") && Frame == 0 && CurrentTrayOpen)
{
OctoshockDll.shock_CloseTray(psx);
CurrentTrayOpen = false;
}
}
- public void FrameAdvance(bool render, bool rendersound)
+ private IController _controller;
+
+ public void FrameAdvance(IController controller, bool render, bool rendersound)
{
+ _controller = controller;
FrameAdvance_PrepDiscState();
//clear drive light. itll get set to light up by sector-reading callbacks
@@ -780,7 +783,7 @@ namespace BizHawk.Emulation.Cores.Sony.PSX
OctoshockDll.shock_SetTraceCallback(psx, IntPtr.Zero, null);
//apply soft reset if needed
- if (Controller.IsPressed("Reset"))
+ if (_controller.IsPressed("Reset"))
OctoshockDll.shock_SoftReset(psx);
//------------------------
@@ -844,7 +847,6 @@ namespace BizHawk.Emulation.Cores.Sony.PSX
}
public ControllerDefinition ControllerDefinition { get; private set; }
- public IController Controller { private get; set; }
public int Frame { get; private set; }
public int LagCount { get; set; }
diff --git a/BizHawk.Emulation.Cores/Consoles/WonderSwan/WonderSwan.Controller.cs b/BizHawk.Emulation.Cores/Consoles/WonderSwan/WonderSwan.Controller.cs
index 1a8bcec7b5..286eac3b04 100644
--- a/BizHawk.Emulation.Cores/Consoles/WonderSwan/WonderSwan.Controller.cs
+++ b/BizHawk.Emulation.Cores/Consoles/WonderSwan/WonderSwan.Controller.cs
@@ -42,36 +42,35 @@ namespace BizHawk.Emulation.Cores.WonderSwan
}
};
public ControllerDefinition ControllerDefinition { get { return WonderSwanController; } }
- public IController Controller { private get; set; }
- BizSwan.Buttons GetButtons()
+ BizSwan.Buttons GetButtons(IController controller)
{
BizSwan.Buttons ret = 0;
- if (Controller.IsPressed("P1 X1")) ret |= BizSwan.Buttons.X1;
- if (Controller.IsPressed("P1 X2")) ret |= BizSwan.Buttons.X2;
- if (Controller.IsPressed("P1 X3")) ret |= BizSwan.Buttons.X3;
- if (Controller.IsPressed("P1 X4")) ret |= BizSwan.Buttons.X4;
- if (Controller.IsPressed("P1 Y1")) ret |= BizSwan.Buttons.Y1;
- if (Controller.IsPressed("P1 Y2")) ret |= BizSwan.Buttons.Y2;
- if (Controller.IsPressed("P1 Y3")) ret |= BizSwan.Buttons.Y3;
- if (Controller.IsPressed("P1 Y4")) ret |= BizSwan.Buttons.Y4;
- if (Controller.IsPressed("P1 Start")) ret |= BizSwan.Buttons.Start;
- if (Controller.IsPressed("P1 B")) ret |= BizSwan.Buttons.B;
- if (Controller.IsPressed("P1 A")) ret |= BizSwan.Buttons.A;
+ if (controller.IsPressed("P1 X1")) ret |= BizSwan.Buttons.X1;
+ if (controller.IsPressed("P1 X2")) ret |= BizSwan.Buttons.X2;
+ if (controller.IsPressed("P1 X3")) ret |= BizSwan.Buttons.X3;
+ if (controller.IsPressed("P1 X4")) ret |= BizSwan.Buttons.X4;
+ if (controller.IsPressed("P1 Y1")) ret |= BizSwan.Buttons.Y1;
+ if (controller.IsPressed("P1 Y2")) ret |= BizSwan.Buttons.Y2;
+ if (controller.IsPressed("P1 Y3")) ret |= BizSwan.Buttons.Y3;
+ if (controller.IsPressed("P1 Y4")) ret |= BizSwan.Buttons.Y4;
+ if (controller.IsPressed("P1 Start")) ret |= BizSwan.Buttons.Start;
+ if (controller.IsPressed("P1 B")) ret |= BizSwan.Buttons.B;
+ if (controller.IsPressed("P1 A")) ret |= BizSwan.Buttons.A;
- if (Controller.IsPressed("P2 X1")) ret |= BizSwan.Buttons.R_X1;
- if (Controller.IsPressed("P2 X2")) ret |= BizSwan.Buttons.R_X2;
- if (Controller.IsPressed("P2 X3")) ret |= BizSwan.Buttons.R_X3;
- if (Controller.IsPressed("P2 X4")) ret |= BizSwan.Buttons.R_X4;
- if (Controller.IsPressed("P2 Y1")) ret |= BizSwan.Buttons.R_Y1;
- if (Controller.IsPressed("P2 Y2")) ret |= BizSwan.Buttons.R_Y2;
- if (Controller.IsPressed("P2 Y3")) ret |= BizSwan.Buttons.R_Y3;
- if (Controller.IsPressed("P2 Y4")) ret |= BizSwan.Buttons.R_Y4;
- if (Controller.IsPressed("P2 Start")) ret |= BizSwan.Buttons.R_Start;
- if (Controller.IsPressed("P2 B")) ret |= BizSwan.Buttons.R_B;
- if (Controller.IsPressed("P2 A")) ret |= BizSwan.Buttons.R_A;
+ if (controller.IsPressed("P2 X1")) ret |= BizSwan.Buttons.R_X1;
+ if (controller.IsPressed("P2 X2")) ret |= BizSwan.Buttons.R_X2;
+ if (controller.IsPressed("P2 X3")) ret |= BizSwan.Buttons.R_X3;
+ if (controller.IsPressed("P2 X4")) ret |= BizSwan.Buttons.R_X4;
+ if (controller.IsPressed("P2 Y1")) ret |= BizSwan.Buttons.R_Y1;
+ if (controller.IsPressed("P2 Y2")) ret |= BizSwan.Buttons.R_Y2;
+ if (controller.IsPressed("P2 Y3")) ret |= BizSwan.Buttons.R_Y3;
+ if (controller.IsPressed("P2 Y4")) ret |= BizSwan.Buttons.R_Y4;
+ if (controller.IsPressed("P2 Start")) ret |= BizSwan.Buttons.R_Start;
+ if (controller.IsPressed("P2 B")) ret |= BizSwan.Buttons.R_B;
+ if (controller.IsPressed("P2 A")) ret |= BizSwan.Buttons.R_A;
- if (Controller.IsPressed("Rotate")) ret |= BizSwan.Buttons.Rotate;
+ if (controller.IsPressed("Rotate")) ret |= BizSwan.Buttons.Rotate;
return ret;
}
diff --git a/BizHawk.Emulation.Cores/Consoles/WonderSwan/WonderSwan.cs b/BizHawk.Emulation.Cores/Consoles/WonderSwan/WonderSwan.cs
index a79a40f107..6f77792096 100644
--- a/BizHawk.Emulation.Cores/Consoles/WonderSwan/WonderSwan.cs
+++ b/BizHawk.Emulation.Cores/Consoles/WonderSwan/WonderSwan.cs
@@ -68,17 +68,17 @@ namespace BizHawk.Emulation.Cores.WonderSwan
}
}
- public void FrameAdvance(bool render, bool rendersound = true)
+ public void FrameAdvance(IController controller, bool render, bool rendersound = true)
{
Frame++;
IsLagFrame = true;
- if (Controller.IsPressed("Power"))
+ if (controller.IsPressed("Power"))
BizSwan.bizswan_reset(Core);
bool rotate = false;
int soundbuffsize = sbuff.Length;
- IsLagFrame = BizSwan.bizswan_advance(Core, GetButtons(), !render, vbuff, sbuff, ref soundbuffsize, ref rotate);
+ IsLagFrame = BizSwan.bizswan_advance(Core, GetButtons(controller), !render, vbuff, sbuff, ref soundbuffsize, ref rotate);
if (soundbuffsize == sbuff.Length)
throw new Exception();
sbuffcontains = soundbuffsize;
diff --git a/BizHawk.Emulation.Cores/Libretro/LibretroCore.cs b/BizHawk.Emulation.Cores/Libretro/LibretroCore.cs
index c670fbe683..9c5c911102 100644
--- a/BizHawk.Emulation.Cores/Libretro/LibretroCore.cs
+++ b/BizHawk.Emulation.Cores/Libretro/LibretroCore.cs
@@ -157,8 +157,11 @@ namespace BizHawk.Emulation.Cores.Libretro
[FeatureNotImplemented]
public int TotalExecutedCycles { get { throw new NotImplementedException(); } }
- public void FrameAdvance(bool render, bool rendersound)
+ private IController _controller;
+
+ public void FrameAdvance(IController controller, bool render, bool rendersound)
{
+ _controller = controller;
api.CMD_Run();
}
@@ -291,7 +294,6 @@ namespace BizHawk.Emulation.Cores.Libretro
}
public ControllerDefinition ControllerDefinition { get; private set; }
- public IController Controller { get; set; }
int timeFrameCounter;
public int Frame { get { return timeFrameCounter; } set { timeFrameCounter = value; } }
diff --git a/BizHawk.Emulation.Cores/Libretro/LibretroCore_InputCallbacks.cs b/BizHawk.Emulation.Cores/Libretro/LibretroCore_InputCallbacks.cs
index a6378c8386..5f9ded0a89 100644
--- a/BizHawk.Emulation.Cores/Libretro/LibretroCore_InputCallbacks.cs
+++ b/BizHawk.Emulation.Cores/Libretro/LibretroCore_InputCallbacks.cs
@@ -30,9 +30,9 @@ namespace BizHawk.Emulation.Cores.Libretro
{
switch ((LibretroApi.RETRO_DEVICE_ID_POINTER)id)
{
- case LibretroApi.RETRO_DEVICE_ID_POINTER.X: return (short)Controller.GetFloat("Pointer X");
- case LibretroApi.RETRO_DEVICE_ID_POINTER.Y: return (short)Controller.GetFloat("Pointer Y");
- case LibretroApi.RETRO_DEVICE_ID_POINTER.PRESSED: return (short)(Controller.IsPressed("Pointer Pressed") ? 1 : 0);
+ case LibretroApi.RETRO_DEVICE_ID_POINTER.X: return (short)_controller.GetFloat("Pointer X");
+ case LibretroApi.RETRO_DEVICE_ID_POINTER.Y: return (short)_controller.GetFloat("Pointer Y");
+ case LibretroApi.RETRO_DEVICE_ID_POINTER.PRESSED: return (short)(_controller.IsPressed("Pointer Pressed") ? 1 : 0);
}
return 0;
}
@@ -184,7 +184,7 @@ namespace BizHawk.Emulation.Cores.Libretro
case LibretroApi.RETRO_KEY.UNDO: button = "Undo"; break;
}
- return (short)(Controller.IsPressed("Key " + button) ? 1 : 0);
+ return (short)(_controller.IsPressed("Key " + button) ? 1 : 0);
}
case LibretroApi.RETRO_DEVICE.JOYPAD:
@@ -219,7 +219,7 @@ namespace BizHawk.Emulation.Cores.Libretro
private bool GetButton(uint pnum, string type, string button)
{
string key = string.Format("P{0} {1} {2}", pnum, type, button);
- bool b = Controller.IsPressed(key);
+ bool b = _controller.IsPressed(key);
if (b == true)
{
return true; //debugging placeholder