Refactor IEmulator and remove the IController property, instead pass it as a paramter to the FrameAdvance() method

This commit is contained in:
adelikat 2017-05-01 20:09:11 -05:00
parent b3ad3ce6ba
commit 698c6741ae
50 changed files with 354 additions and 394 deletions

View File

@ -21,7 +21,6 @@ namespace BizHawk.Client.Common
Global.MovieInputSourceAdapter.Source = Global.MultitrackRewiringAdapter; Global.MovieInputSourceAdapter.Source = Global.MultitrackRewiringAdapter;
Global.ControllerOutput.Source = Global.MovieOutputHardpoint; Global.ControllerOutput.Source = Global.MovieOutputHardpoint;
Global.Emulator.Controller = Global.ControllerOutput;
Global.MovieSession.MovieControllerAdapter.Definition = Global.MovieInputSourceAdapter.Definition; Global.MovieSession.MovieControllerAdapter.Definition = Global.MovieInputSourceAdapter.Definition;
// connect the movie session before MovieOutputHardpoint if it is doing anything // connect the movie session before MovieOutputHardpoint if it is doing anything

View File

@ -2840,7 +2840,7 @@ namespace BizHawk.Client.EmuHawk
if (!renderSound) atten = 0; if (!renderSound) atten = 0;
bool render = !_throttle.skipNextFrame || (_currAviWriter?.UsesVideo ?? false); bool render = !_throttle.skipNextFrame || (_currAviWriter?.UsesVideo ?? false);
Emulator.FrameAdvance(render, renderSound); Emulator.FrameAdvance(Global.ControllerOutput, render, renderSound);
Global.MovieSession.HandleMovieAfterFrameLoop(); Global.MovieSession.HandleMovieAfterFrameLoop();

View File

@ -162,7 +162,7 @@ namespace BizHawk.Client.EmuHawk
{ {
current.GI = ldr.Game; current.GI = ldr.Game;
current.CoreType = emu.GetType(); current.CoreType = emu.GetType();
emu.Controller = new Controller(emu.ControllerDefinition); var controller = new Controller(emu.ControllerDefinition);
current.BoardName = emu.HasBoardInfo() ? emu.AsBoardInfo().BoardName : null; current.BoardName = emu.HasBoardInfo() ? emu.AsBoardInfo().BoardName : null;
// hack // hack
if (emu is Emulation.Cores.Nintendo.GBA.VBANext) if (emu is Emulation.Cores.Nintendo.GBA.VBANext)
@ -179,7 +179,7 @@ namespace BizHawk.Client.EmuHawk
{ {
int nsamp; int nsamp;
short[] samp; 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 // some cores really really really like it if you drain their audio every frame
if (emu.HasSoundProvider()) if (emu.HasSoundProvider())

View File

@ -373,7 +373,7 @@ namespace BizHawk.Client.MultiHawk
public void FrameAdvance() public void FrameAdvance()
{ {
Emulator.FrameAdvance(true); Emulator.FrameAdvance(Global.ControllerOutput, true);
} }
public void SaveRam() public void SaveRam()

View File

@ -37,11 +37,6 @@ namespace BizHawk.Client.MultiHawk
Global.MovieInputSourceAdapter.Source = Global.MultitrackRewiringAdapter; Global.MovieInputSourceAdapter.Source = Global.MultitrackRewiringAdapter;
Global.ControllerOutput.Source = Global.MovieOutputHardpoint; Global.ControllerOutput.Source = Global.MovieOutputHardpoint;
foreach (var window in _mainForm.EmulatorWindows)
{
window.Emulator.Controller = Global.ControllerOutput;
}
Global.MovieSession.MovieControllerAdapter.Definition = Global.MovieInputSourceAdapter.Definition; Global.MovieSession.MovieControllerAdapter.Definition = Global.MovieInputSourceAdapter.Definition;
// connect the movie session before MovieOutputHardpoint if it is doing anything // connect the movie session before MovieOutputHardpoint if it is doing anything

View File

@ -33,9 +33,7 @@ namespace BizHawk.Emulation.Common
public ControllerDefinition ControllerDefinition => NullController.Instance.Definition; public ControllerDefinition ControllerDefinition => NullController.Instance.Definition;
public IController Controller { get; set; } public void FrameAdvance(IController controller, bool render, bool rendersound)
public void FrameAdvance(bool render, bool rendersound)
{ {
if (render == false) if (render == false)
{ {

View File

@ -24,21 +24,17 @@ namespace BizHawk.Emulation.Common
/// </summary> /// </summary>
ControllerDefinition ControllerDefinition { get; } ControllerDefinition ControllerDefinition { get; }
/// <summary>
/// Sets the controller instance that the core will use for input.
/// 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>
IController Controller { set; }
/// <summary> /// <summary>
/// Runs the emulator core for 1 frame /// Runs the emulator core for 1 frame
/// note that (some?) cores expect you to call SoundProvider.GetSamples() after each FrameAdvance() /// note that (some?) cores expect you to call SoundProvider.GetSamples() after each FrameAdvance()
/// please do this, even when rendersound = false /// please do this, even when rendersound = false
/// <param name="controller">The <seealso cref="IController"/> instance that the core will use for input.
/// The <seealso cref="IController"/> provided by the client must provide the buttons specified by the core through the <seealso cref="ControllerDefinition"/> property
/// </param>
/// <param name="render">Whether or not to render video, cores will pass false here in cases such as frame skipping</param> /// <param name="render">Whether or not to render video, cores will pass false here in cases such as frame skipping</param>
/// <param name="rendersound">Whether or not to render audio, cores will pass here false here in cases such as fast forwarding where bypassing sound may improve speed</param> /// <param name="rendersound">Whether or not to render audio, cores will pass here false here in cases such as fast forwarding where bypassing sound may improve speed</param>
/// </summary> /// </summary>
void FrameAdvance(bool render, bool rendersound = true); void FrameAdvance(IController controller, bool render, bool rendersound = true);
/// <summary> /// <summary>
/// Gets the current frame count /// Gets the current frame count

View File

@ -11,10 +11,9 @@ namespace BizHawk.Emulation.Cores.Calculators
get { return TI83Controller; } get { return TI83Controller; }
} }
public IController Controller { private get; set; } public void FrameAdvance(IController controller, bool render, bool rendersound)
public void FrameAdvance(bool render, bool rendersound)
{ {
_controller = controller;
_lagged = true; _lagged = true;
Cpu.Debug = Tracer.Enabled; Cpu.Debug = Tracer.Enabled;
@ -25,7 +24,7 @@ namespace BizHawk.Emulation.Cores.Calculators
//I eyeballed this speed //I eyeballed this speed
for (int i = 0; i < 5; i++) for (int i = 0; i < 5; i++)
{ {
_onPressed = Controller.IsPressed("ON"); _onPressed = controller.IsPressed("ON");
//and this was derived from other emus //and this was derived from other emus
Cpu.ExecuteCycles(10000); Cpu.ExecuteCycles(10000);

View File

@ -60,6 +60,8 @@ namespace BizHawk.Emulation.Cores.Calculators
private readonly Z80A Cpu = new Z80A(); private readonly Z80A Cpu = new Z80A();
private readonly byte[] Rom; private readonly byte[] Rom;
private IController _controller;
private byte[] _ram; private byte[] _ram;
private byte[] _vram = new byte[0x300]; private byte[] _vram = new byte[0x300];
private int _romPageLow3Bits; private int _romPageLow3Bits;
@ -204,7 +206,7 @@ namespace BizHawk.Emulation.Cores.Calculators
// 4-7 - Unknown // 4-7 - Unknown
//if (onPressed && maskOn) ret |= 1; //if (onPressed && maskOn) ret |= 1;
//if (!onPressed) ret |= 0x8; //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 case 4: // PORT_INTCTRL
@ -230,80 +232,79 @@ namespace BizHawk.Emulation.Cores.Calculators
//Console.WriteLine("keyboardMask: {0:X2}",keyboardMask); //Console.WriteLine("keyboardMask: {0:X2}",keyboardMask);
if ((_keyboardMask & 1) == 0) if ((_keyboardMask & 1) == 0)
{ {
if (Controller.IsPressed("DOWN")) ret ^= 1; if (_controller.IsPressed("DOWN")) ret ^= 1;
if (Controller.IsPressed("LEFT")) ret ^= 2; if (_controller.IsPressed("LEFT")) ret ^= 2;
if (Controller.IsPressed("RIGHT")) ret ^= 4; if (_controller.IsPressed("RIGHT")) ret ^= 4;
if (Controller.IsPressed("UP")) ret ^= 8; if (_controller.IsPressed("UP")) ret ^= 8;
} }
if ((_keyboardMask & 2) == 0) if ((_keyboardMask & 2) == 0)
{ {
if (Controller.IsPressed("ENTER")) ret ^= 1; if (_controller.IsPressed("ENTER")) ret ^= 1;
if (Controller.IsPressed("PLUS")) ret ^= 2; if (_controller.IsPressed("PLUS")) ret ^= 2;
if (Controller.IsPressed("MINUS")) ret ^= 4; if (_controller.IsPressed("MINUS")) ret ^= 4;
if (Controller.IsPressed("MULTIPLY")) ret ^= 8; if (_controller.IsPressed("MULTIPLY")) ret ^= 8;
if (Controller.IsPressed("DIVIDE")) ret ^= 16; if (_controller.IsPressed("DIVIDE")) ret ^= 16;
if (Controller.IsPressed("EXP")) ret ^= 32; if (_controller.IsPressed("EXP")) ret ^= 32;
if (Controller.IsPressed("CLEAR")) ret ^= 64; if (_controller.IsPressed("CLEAR")) ret ^= 64;
} }
if ((_keyboardMask & 4) == 0) if ((_keyboardMask & 4) == 0)
{ {
if (Controller.IsPressed("DASH")) ret ^= 1; if (_controller.IsPressed("DASH")) ret ^= 1;
if (Controller.IsPressed("3")) ret ^= 2; if (_controller.IsPressed("3")) ret ^= 2;
if (Controller.IsPressed("6")) ret ^= 4; if (_controller.IsPressed("6")) ret ^= 4;
if (Controller.IsPressed("9")) ret ^= 8; if (_controller.IsPressed("9")) ret ^= 8;
if (Controller.IsPressed("PARACLOSE")) ret ^= 16; if (_controller.IsPressed("PARACLOSE")) ret ^= 16;
if (Controller.IsPressed("TAN")) ret ^= 32; if (_controller.IsPressed("TAN")) ret ^= 32;
if (Controller.IsPressed("VARS")) ret ^= 64; if (_controller.IsPressed("VARS")) ret ^= 64;
} }
if ((_keyboardMask & 8) == 0) if ((_keyboardMask & 8) == 0)
{ {
if (Controller.IsPressed("DOT")) ret ^= 1; if (_controller.IsPressed("DOT")) ret ^= 1;
if (Controller.IsPressed("2")) ret ^= 2; if (_controller.IsPressed("2")) ret ^= 2;
if (Controller.IsPressed("5")) ret ^= 4; if (_controller.IsPressed("5")) ret ^= 4;
if (Controller.IsPressed("8")) ret ^= 8; if (_controller.IsPressed("8")) ret ^= 8;
if (Controller.IsPressed("PARAOPEN")) ret ^= 16; if (_controller.IsPressed("PARAOPEN")) ret ^= 16;
if (Controller.IsPressed("COS")) ret ^= 32; if (_controller.IsPressed("COS")) ret ^= 32;
if (Controller.IsPressed("PRGM")) ret ^= 64; if (_controller.IsPressed("PRGM")) ret ^= 64;
if (Controller.IsPressed("STAT")) ret ^= 128; if (_controller.IsPressed("STAT")) ret ^= 128;
} }
if ((_keyboardMask & 16) == 0) if ((_keyboardMask & 16) == 0)
{ {
if (Controller.IsPressed("0")) ret ^= 1; if (_controller.IsPressed("0")) ret ^= 1;
if (Controller.IsPressed("1")) ret ^= 2; if (_controller.IsPressed("1")) ret ^= 2;
if (Controller.IsPressed("4")) ret ^= 4; if (_controller.IsPressed("4")) ret ^= 4;
if (Controller.IsPressed("7")) ret ^= 8; if (_controller.IsPressed("7")) ret ^= 8;
if (Controller.IsPressed("COMMA")) ret ^= 16; if (_controller.IsPressed("COMMA")) ret ^= 16;
if (Controller.IsPressed("SIN")) ret ^= 32; if (_controller.IsPressed("SIN")) ret ^= 32;
if (Controller.IsPressed("MATRIX")) ret ^= 64; if (_controller.IsPressed("MATRIX")) ret ^= 64;
if (Controller.IsPressed("X")) ret ^= 128; if (_controller.IsPressed("X")) ret ^= 128;
} }
if ((_keyboardMask & 32) == 0) if ((_keyboardMask & 32) == 0)
{ {
if (Controller.IsPressed("STO")) ret ^= 2; if (_controller.IsPressed("STO")) ret ^= 2;
if (Controller.IsPressed("LN")) ret ^= 4; if (_controller.IsPressed("LN")) ret ^= 4;
if (Controller.IsPressed("LOG")) ret ^= 8; if (_controller.IsPressed("LOG")) ret ^= 8;
if (Controller.IsPressed("SQUARED")) ret ^= 16; if (_controller.IsPressed("SQUARED")) ret ^= 16;
if (Controller.IsPressed("NEG1")) ret ^= 32; if (_controller.IsPressed("NEG1")) ret ^= 32;
if (Controller.IsPressed("MATH")) if (_controller.IsPressed("MATH")) ret ^= 64;
ret ^= 64; if (_controller.IsPressed("ALPHA")) ret ^= 128;
if (Controller.IsPressed("ALPHA")) ret ^= 128;
} }
if ((_keyboardMask & 64) == 0) if ((_keyboardMask & 64) == 0)
{ {
if (Controller.IsPressed("GRAPH")) ret ^= 1; if (_controller.IsPressed("GRAPH")) ret ^= 1;
if (Controller.IsPressed("TRACE")) ret ^= 2; if (_controller.IsPressed("TRACE")) ret ^= 2;
if (Controller.IsPressed("ZOOM")) ret ^= 4; if (_controller.IsPressed("ZOOM")) ret ^= 4;
if (Controller.IsPressed("WINDOW")) ret ^= 8; if (_controller.IsPressed("WINDOW")) ret ^= 8;
if (Controller.IsPressed("Y")) ret ^= 16; if (_controller.IsPressed("Y")) ret ^= 16;
if (Controller.IsPressed("2ND")) ret ^= 32; if (_controller.IsPressed("2ND")) ret ^= 32;
if (Controller.IsPressed("MODE")) ret ^= 64; if (_controller.IsPressed("MODE")) ret ^= 64;
if (Controller.IsPressed("DEL")) ret ^= 128; if (_controller.IsPressed("DEL")) ret ^= 128;
} }
return (byte)ret; return (byte)ret;

View File

@ -8,17 +8,15 @@ namespace BizHawk.Emulation.Cores.Computers.AppleII
public ControllerDefinition ControllerDefinition => AppleIIController; public ControllerDefinition ControllerDefinition => AppleIIController;
public IController Controller { private get; set; }
public int Frame { get; private set; } public int Frame { get; private set; }
public string SystemId => "AppleII"; public string SystemId => "AppleII";
public bool DeterministicEmulation => true; 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() public void ResetCounters()

View File

@ -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) if (_tracer.Enabled)
{ {
@ -151,28 +151,28 @@ namespace BizHawk.Emulation.Cores.Computers.AppleII
_machine.Cpu.TraceCallback = null; _machine.Cpu.TraceCallback = null;
} }
if (Controller.IsPressed("Next Disk") && !_nextPressed) if (controller.IsPressed("Next Disk") && !_nextPressed)
{ {
_nextPressed = true; _nextPressed = true;
IncrementDisk(); IncrementDisk();
} }
else if (Controller.IsPressed("Previous Disk") && !_prevPressed) else if (controller.IsPressed("Previous Disk") && !_prevPressed)
{ {
_prevPressed = true; _prevPressed = true;
DecrementDisk(); DecrementDisk();
} }
if (!Controller.IsPressed("Next Disk")) if (!controller.IsPressed("Next Disk"))
{ {
_nextPressed = false; _nextPressed = false;
} }
if (!Controller.IsPressed("Previous Disk")) if (!controller.IsPressed("Previous Disk"))
{ {
_prevPressed = false; _prevPressed = false;
} }
_machine.BizFrameAdvance(RealButtons.Where(b => Controller.IsPressed(b))); _machine.BizFrameAdvance(RealButtons.Where(b => controller.IsPressed(b)));
if (IsLagFrame) if (IsLagFrame)
{ {
LagCount++; LagCount++;

View File

@ -139,8 +139,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]
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; }
@ -153,8 +152,9 @@ namespace BizHawk.Emulation.Cores.Computers.Commodore64
} }
// process frame // process frame
public void FrameAdvance(bool render, bool rendersound) public void FrameAdvance(IController controller, bool render, bool rendersound)
{ {
_board.Controller = controller;
do do
{ {
DoCycle(); DoCycle();

View File

@ -365,8 +365,11 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
Cpu.S = 0xFD; 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(); StartFrameCond();
while (_tia.LineCount < _tia.NominalNumScanlines) while (_tia.LineCount < _tia.NominalNumScanlines)
Cycle(); Cycle();
@ -392,27 +395,27 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
_frame++; _frame++;
_islag = true; _islag = true;
if (Controller.IsPressed("Power")) if (_controller.IsPressed("Power"))
{ {
HardReset(); HardReset();
} }
if (Controller.IsPressed("Toggle Left Difficulty") && !_leftDifficultySwitchHeld) if (_controller.IsPressed("Toggle Left Difficulty") && !_leftDifficultySwitchHeld)
{ {
_leftDifficultySwitchPressed ^= true; _leftDifficultySwitchPressed ^= true;
_leftDifficultySwitchHeld = true; _leftDifficultySwitchHeld = true;
} }
else if (!Controller.IsPressed("Toggle Left Difficulty")) else if (!_controller.IsPressed("Toggle Left Difficulty"))
{ {
_leftDifficultySwitchHeld = false; _leftDifficultySwitchHeld = false;
} }
if (Controller.IsPressed("Toggle Right Difficulty") && !_rightDifficultySwitchHeld) if (_controller.IsPressed("Toggle Right Difficulty") && !_rightDifficultySwitchHeld)
{ {
_rightDifficultySwitchPressed ^= true; _rightDifficultySwitchPressed ^= true;
_rightDifficultySwitchHeld = true; _rightDifficultySwitchHeld = true;
} }
else if (!Controller.IsPressed("Toggle Right Difficulty")) else if (!_controller.IsPressed("Toggle Right Difficulty"))
{ {
_rightDifficultySwitchHeld = false; _rightDifficultySwitchHeld = false;
} }
@ -453,11 +456,11 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
InputCallbacks.Call(); InputCallbacks.Call();
byte value = 0xFF; byte value = 0xFF;
if (Controller.IsPressed("P1 Up")) { value &= 0xEF; } if (_controller.IsPressed("P1 Up")) { value &= 0xEF; }
if (Controller.IsPressed("P1 Down")) { value &= 0xDF; } if (_controller.IsPressed("P1 Down")) { value &= 0xDF; }
if (Controller.IsPressed("P1 Left")) { value &= 0xBF; } if (_controller.IsPressed("P1 Left")) { value &= 0xBF; }
if (Controller.IsPressed("P1 Right")) { value &= 0x7F; } if (_controller.IsPressed("P1 Right")) { value &= 0x7F; }
if (Controller.IsPressed("P1 Button")) { value &= 0xF7; } if (_controller.IsPressed("P1 Button")) { value &= 0xF7; }
if (!peek) if (!peek)
{ {
@ -472,11 +475,11 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
InputCallbacks.Call(); InputCallbacks.Call();
byte value = 0xFF; byte value = 0xFF;
if (Controller.IsPressed("P2 Up")) { value &= 0xEF; } if (_controller.IsPressed("P2 Up")) { value &= 0xEF; }
if (Controller.IsPressed("P2 Down")) { value &= 0xDF; } if (_controller.IsPressed("P2 Down")) { value &= 0xDF; }
if (Controller.IsPressed("P2 Left")) { value &= 0xBF; } if (_controller.IsPressed("P2 Left")) { value &= 0xBF; }
if (Controller.IsPressed("P2 Right")) { value &= 0x7F; } if (_controller.IsPressed("P2 Right")) { value &= 0x7F; }
if (Controller.IsPressed("P2 Button")) { value &= 0xF7; } if (_controller.IsPressed("P2 Button")) { value &= 0xF7; }
if (!peek) if (!peek)
{ {
@ -489,8 +492,8 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
internal byte ReadConsoleSwitches(bool peek) internal byte ReadConsoleSwitches(bool peek)
{ {
byte value = 0xFF; byte value = 0xFF;
bool select = Controller.IsPressed("Select"); bool select = _controller.IsPressed("Select");
bool reset = Controller.IsPressed("Reset"); bool reset = _controller.IsPressed("Reset");
if (reset) { value &= 0xFE; } if (reset) { value &= 0xFE; }
if (select) { value &= 0xFD; } if (select) { value &= 0xFD; }

View File

@ -73,8 +73,6 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
public ControllerDefinition ControllerDefinition { get { return Atari2600ControllerDefinition; } } public ControllerDefinition ControllerDefinition { get { return Atari2600ControllerDefinition; } }
public IController Controller { private get; set; }
public int Frame { get { return _frame; } set { _frame = value; } } public int Frame { get { return _frame; } set { _frame = value; } }
public bool DeterministicEmulation { get; set; } 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)) using (Atari2600 emu = new Atari2600(new CoreComm(null, null), newgame, rom, null, null))
{ {
emu.Controller = new NullController();
List<int> framecounts = new List<int>(); List<int> framecounts = new List<int>();
emu._tia.FrameEndCallBack = (i) => framecounts.Add(i); 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 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); int numpal = framecounts.Count((i) => i > 287);
bool pal = numpal >= 25; bool pal = numpal >= 25;
Console.WriteLine("PAL Detection: {0} lines, {1}", numpal, pal); Console.WriteLine("PAL Detection: {0} lines, {1}", numpal, pal);

View File

@ -99,18 +99,18 @@ namespace BizHawk.Emulation.Cores.Atari.Atari7800
public GameInfo game; public GameInfo game;
public void FrameAdvance(bool render, bool rendersound) public void FrameAdvance(IController controller, bool render, bool rendersound)
{ {
_frame++; _frame++;
if (Controller.IsPressed("Power")) if (controller.IsPressed("Power"))
{ {
// it seems that theMachine.Reset() doesn't clear ram, etc // it seems that theMachine.Reset() doesn't clear ram, etc
// this should leave hsram intact but clear most other things // this should leave hsram intact but clear most other things
HardReset(); HardReset();
} }
ControlAdapter.Convert(Controller, theMachine.InputState); ControlAdapter.Convert(controller, theMachine.InputState);
theMachine.ComputeNextFrame(_avProvider.Framebuffer); theMachine.ComputeNextFrame(_avProvider.Framebuffer);
_islag = theMachine.InputState.Lagged; _islag = theMachine.InputState.Lagged;
@ -149,8 +149,6 @@ 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 { private get; set; }
private class ConsoleLogger : ILogger private class ConsoleLogger : ILogger
{ {

View File

@ -123,16 +123,16 @@ namespace BizHawk.Emulation.Cores.Atari.Lynx
public IEmulatorServiceProvider ServiceProvider { get; } public IEmulatorServiceProvider ServiceProvider { get; }
public void FrameAdvance(bool render, bool rendersound = true) public void FrameAdvance(IController controller, bool render, bool rendersound = true)
{ {
Frame++; Frame++;
if (Controller.IsPressed("Power")) if (controller.IsPressed("Power"))
{ {
LibLynx.Reset(Core); LibLynx.Reset(Core);
} }
int samples = _soundbuff.Length; 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 _numsamp = samples / 2; // sound provider wants number of sample pairs
if (IsLagFrame) if (IsLagFrame)
{ {
@ -173,20 +173,19 @@ namespace BizHawk.Emulation.Cores.Atari.Lynx
}; };
public ControllerDefinition ControllerDefinition { get { return LynxTroller; } } 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; LibLynx.Buttons ret = 0;
if (Controller.IsPressed("A")) ret |= LibLynx.Buttons.A; if (controller.IsPressed("A")) ret |= LibLynx.Buttons.A;
if (Controller.IsPressed("B")) ret |= LibLynx.Buttons.B; if (controller.IsPressed("B")) ret |= LibLynx.Buttons.B;
if (Controller.IsPressed("Up")) ret |= LibLynx.Buttons.Up; if (controller.IsPressed("Up")) ret |= LibLynx.Buttons.Up;
if (Controller.IsPressed("Down")) ret |= LibLynx.Buttons.Down; if (controller.IsPressed("Down")) ret |= LibLynx.Buttons.Down;
if (Controller.IsPressed("Left")) ret |= LibLynx.Buttons.Left; if (controller.IsPressed("Left")) ret |= LibLynx.Buttons.Left;
if (Controller.IsPressed("Right")) ret |= LibLynx.Buttons.Right; if (controller.IsPressed("Right")) ret |= LibLynx.Buttons.Right;
if (Controller.IsPressed("Pause")) ret |= LibLynx.Buttons.Pause; if (controller.IsPressed("Pause")) ret |= LibLynx.Buttons.Pause;
if (Controller.IsPressed("Option 1")) ret |= LibLynx.Buttons.Option_1; if (controller.IsPressed("Option 1")) ret |= LibLynx.Buttons.Option_1;
if (Controller.IsPressed("Option 2")) ret |= LibLynx.Buttons.Option_2; if (controller.IsPressed("Option 2")) ret |= LibLynx.Buttons.Option_2;
return ret; return ret;
} }

View File

@ -76,12 +76,13 @@ namespace BizHawk.Emulation.Cores.ColecoVision
private readonly ColecoVisionControllerDeck ControllerDeck; private readonly ColecoVisionControllerDeck ControllerDeck;
public IController Controller { private get; set; }
private const ushort RamSizeMask = 0x03FF; 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; Cpu.Debug = Tracer.Enabled;
Frame++; Frame++;
_isLag = true; _isLag = true;
@ -92,8 +93,8 @@ namespace BizHawk.Emulation.Cores.ColecoVision
Cpu.Logger = (s) => Tracer.Put(s); Cpu.Logger = (s) => Tracer.Put(s);
} }
byte tempRet1 = ControllerDeck.ReadPort1(Controller, true, true); byte tempRet1 = ControllerDeck.ReadPort1(controller, true, true);
byte tempRet2 = ControllerDeck.ReadPort2(Controller, true, true); byte tempRet2 = ControllerDeck.ReadPort2(controller, true, true);
bool intPending = (!tempRet1.Bit(4)) | (!tempRet2.Bit(4)); bool intPending = (!tempRet1.Bit(4)) | (!tempRet2.Bit(4));

View File

@ -11,13 +11,13 @@
byte retval; byte retval;
if (InputPortSelection == InputPortMode.Left) if (InputPortSelection == InputPortMode.Left)
{ {
retval = ControllerDeck.ReadPort1(Controller, true, false); retval = ControllerDeck.ReadPort1(_controller, true, false);
return retval; return retval;
} }
if (InputPortSelection == InputPortMode.Right) if (InputPortSelection == InputPortMode.Right)
{ {
retval = ControllerDeck.ReadPort1(Controller, false, false); retval = ControllerDeck.ReadPort1(_controller, false, false);
return retval; return retval;
} }
return 0x7F; return 0x7F;
@ -29,13 +29,13 @@
byte retval; byte retval;
if (InputPortSelection == InputPortMode.Left) if (InputPortSelection == InputPortMode.Left)
{ {
retval = ControllerDeck.ReadPort2(Controller, true, false); retval = ControllerDeck.ReadPort2(_controller, true, false);
return retval; return retval;
} }
if (InputPortSelection == InputPortMode.Right) if (InputPortSelection == InputPortMode.Right)
{ {
retval = ControllerDeck.ReadPort2(Controller, false, false); retval = ControllerDeck.ReadPort2(_controller, false, false);
return retval; return retval;
} }
return 0x7F; return 0x7F;

View File

@ -8,9 +8,7 @@ namespace BizHawk.Emulation.Cores.Intellivision
public ControllerDefinition ControllerDefinition => _controllerDeck.Definition; public ControllerDefinition ControllerDefinition => _controllerDeck.Definition;
public IController Controller { private get; set; } public void FrameAdvance(IController controller, bool render, bool rendersound)
public void FrameAdvance(bool render, bool rendersound)
{ {
if (_tracer.Enabled) if (_tracer.Enabled)
{ {
@ -25,7 +23,7 @@ namespace BizHawk.Emulation.Cores.Intellivision
_sticRow = -1; _sticRow = -1;
// read the controller state here for now // 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 // 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; int delayCycles = 700;
@ -117,12 +115,12 @@ namespace BizHawk.Emulation.Cores.Intellivision
_lagcount++; _lagcount++;
} }
if (Controller.IsPressed("Power")) if (controller.IsPressed("Power"))
{ {
HardReset(); HardReset();
} }
if (Controller.IsPressed("Reset")) if (controller.IsPressed("Reset"))
{ {
SoftReset(); SoftReset();
} }

View File

@ -117,14 +117,14 @@ namespace BizHawk.Emulation.Cores.Intellivision
GraphicsRom = grom; GraphicsRom = grom;
} }
private void GetControllerState() private void GetControllerState(IController controller)
{ {
InputCallbacks.Call(); InputCallbacks.Call();
ushort port1 = _controllerDeck.ReadPort1(Controller); ushort port1 = _controllerDeck.ReadPort1(controller);
_psg.Register[15] = (ushort)(0xFF - port1); _psg.Register[15] = (ushort)(0xFF - port1);
ushort port2 = _controllerDeck.ReadPort2(Controller); ushort port2 = _controllerDeck.ReadPort2(controller);
_psg.Register[14] = (ushort)(0xFF - port2); _psg.Register[14] = (ushort)(0xFF - port2);
} }

View File

@ -70,12 +70,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA
public ControllerDefinition ControllerDefinition => GBA.GBAController; public ControllerDefinition ControllerDefinition => GBA.GBAController;
public IController Controller { get; set; } public void FrameAdvance(IController controller, bool render, bool rendersound = true)
public void FrameAdvance(bool render, bool rendersound = true)
{ {
Frame++; Frame++;
if (Controller.IsPressed("Power")) if (controller.IsPressed("Power"))
{ {
LibmGBA.BizReset(_core); LibmGBA.BizReset(_core);
@ -85,15 +83,15 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA
IsLagFrame = LibmGBA.BizAdvance( IsLagFrame = LibmGBA.BizAdvance(
_core, _core,
VBANext.GetButtons(Controller), VBANext.GetButtons(controller),
_videobuff, _videobuff,
ref _nsamp, ref _nsamp,
_soundbuff, _soundbuff,
RTCTime(), RTCTime(),
(short)Controller.GetFloat("Tilt X"), (short)controller.GetFloat("Tilt X"),
(short)Controller.GetFloat("Tilt Y"), (short)controller.GetFloat("Tilt Y"),
(short)Controller.GetFloat("Tilt Z"), (short)controller.GetFloat("Tilt Z"),
(byte)(255 - Controller.GetFloat("Light Sensor"))); (byte)(255 - controller.GetFloat("Light Sensor")));
if (IsLagFrame) if (IsLagFrame)
{ {

View File

@ -97,16 +97,16 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA
public IEmulatorServiceProvider ServiceProvider { get; private set; } 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++; Frame++;
if (Controller.IsPressed("Power")) if (controller.IsPressed("Power"))
LibVBANext.Reset(Core); LibVBANext.Reset(Core);
SyncTraceCallback(); 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) if (IsLagFrame)
LagCount++; LagCount++;
@ -205,7 +205,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA
#region Controller #region Controller
public ControllerDefinition ControllerDefinition { get { return GBA.GBAController; } } public ControllerDefinition ControllerDefinition { get { return GBA.GBAController; } }
public IController Controller { get; set; }
public static LibVBANext.Buttons GetButtons(IController c) public static LibVBANext.Buttons GetButtons(IController c)
{ {

View File

@ -11,11 +11,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
public ControllerDefinition ControllerDefinition => GbController; public ControllerDefinition ControllerDefinition => GbController;
public IController Controller { get; set; } public void FrameAdvance(IController controller, bool render, bool rendersound)
public void FrameAdvance(bool render, bool rendersound)
{ {
FrameAdvancePrep(); FrameAdvancePrep(controller);
if (_syncSettings.EqualLengthFrames) if (_syncSettings.EqualLengthFrames)
{ {
while (true) while (true)

View File

@ -257,34 +257,34 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
_inputCallbacks = ics; _inputCallbacks = ics;
} }
internal void FrameAdvancePrep() internal void FrameAdvancePrep(IController controller)
{ {
Frame++; Frame++;
// update our local copy of the controller data // update our local copy of the controller data
CurrentButtons = 0; CurrentButtons = 0;
if (Controller.IsPressed("Up")) if (controller.IsPressed("Up"))
CurrentButtons |= LibGambatte.Buttons.UP; CurrentButtons |= LibGambatte.Buttons.UP;
if (Controller.IsPressed("Down")) if (controller.IsPressed("Down"))
CurrentButtons |= LibGambatte.Buttons.DOWN; CurrentButtons |= LibGambatte.Buttons.DOWN;
if (Controller.IsPressed("Left")) if (controller.IsPressed("Left"))
CurrentButtons |= LibGambatte.Buttons.LEFT; CurrentButtons |= LibGambatte.Buttons.LEFT;
if (Controller.IsPressed("Right")) if (controller.IsPressed("Right"))
CurrentButtons |= LibGambatte.Buttons.RIGHT; CurrentButtons |= LibGambatte.Buttons.RIGHT;
if (Controller.IsPressed("A")) if (controller.IsPressed("A"))
CurrentButtons |= LibGambatte.Buttons.A; CurrentButtons |= LibGambatte.Buttons.A;
if (Controller.IsPressed("B")) if (controller.IsPressed("B"))
CurrentButtons |= LibGambatte.Buttons.B; CurrentButtons |= LibGambatte.Buttons.B;
if (Controller.IsPressed("Select")) if (controller.IsPressed("Select"))
CurrentButtons |= LibGambatte.Buttons.SELECT; CurrentButtons |= LibGambatte.Buttons.SELECT;
if (Controller.IsPressed("Start")) if (controller.IsPressed("Start"))
CurrentButtons |= LibGambatte.Buttons.START; CurrentButtons |= LibGambatte.Buttons.START;
// the controller callback will set this to false if it actually gets called during the frame // the controller callback will set this to false if it actually gets called during the frame
IsLagFrame = true; IsLagFrame = true;
if (Controller.IsPressed("Power")) if (controller.IsPressed("Power"))
{ {
LibGambatte.gambatte_reset(GambatteState, GetCurrentTime()); LibGambatte.gambatte_reset(GambatteState, GetCurrentTime());
} }

View File

@ -9,16 +9,14 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
public ControllerDefinition ControllerDefinition => DualGbController; public ControllerDefinition ControllerDefinition => DualGbController;
public IController Controller { get; set; } public void FrameAdvance(IController controller, bool render, bool rendersound = true)
public void FrameAdvance(bool render, bool rendersound = true)
{ {
LCont.Clear(); LCont.Clear();
RCont.Clear(); RCont.Clear();
foreach (var s in DualGbController.BoolButtons) foreach (var s in DualGbController.BoolButtons)
{ {
if (Controller.IsPressed(s)) if (controller.IsPressed(s))
{ {
if (s.Contains("P1 ")) 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) if (cablediscosignalNew && !_cablediscosignal)
{ {
_cableconnected ^= true; _cableconnected ^= true;
@ -42,8 +40,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
_cablediscosignal = cablediscosignalNew; _cablediscosignal = cablediscosignalNew;
Frame++; Frame++;
L.FrameAdvancePrep(); L.FrameAdvancePrep(controller);
R.FrameAdvancePrep(); R.FrameAdvancePrep(controller);
unsafe unsafe
{ {

View File

@ -26,8 +26,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
LibGambatte.gambatte_linkstatus(L.GambatteState, 259); LibGambatte.gambatte_linkstatus(L.GambatteState, 259);
LibGambatte.gambatte_linkstatus(R.GambatteState, 259); LibGambatte.gambatte_linkstatus(R.GambatteState, 259);
L.Controller = LCont;
R.Controller = RCont;
L.ConnectInputCallbackSystem(_inputCallbacks); L.ConnectInputCallbackSystem(_inputCallbacks);
R.ConnectInputCallbackSystem(_inputCallbacks); R.ConnectInputCallbackSystem(_inputCallbacks);
L.ConnectMemoryCallbackSystem(_memorycallbacks); L.ConnectMemoryCallbackSystem(_memorycallbacks);

View File

@ -227,8 +227,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64
RunThreadAction(() => { _pendingThreadTerminate = true; }); RunThreadAction(() => { _pendingThreadTerminate = true; });
} }
public void FrameAdvance(bool render, bool rendersound) public void FrameAdvance(IController controller, bool render, bool rendersound)
{ {
_inputProvider.Controller = controller;
IsVIFrame = false; IsVIFrame = false;
if (Tracer != null && Tracer.Enabled) if (Tracer != null && Tracer.Enabled)
@ -242,12 +244,12 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64
_audioProvider.RenderSound = rendersound; _audioProvider.RenderSound = rendersound;
if (Controller.IsPressed("Reset")) if (controller.IsPressed("Reset"))
{ {
api.soft_reset(); api.soft_reset();
} }
if (Controller.IsPressed("Power")) if (controller.IsPressed("Power"))
{ {
api.hard_reset(); api.hard_reset();
} }
@ -274,12 +276,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64
get { return _inputProvider.ControllerDefinition; } get { return _inputProvider.ControllerDefinition; }
} }
public IController Controller
{
get { return _inputProvider.Controller; }
set { _inputProvider.Controller = value; }
}
public void ResetCounters() public void ResetCounters()
{ {
Frame = 0; Frame = 0;

View File

@ -291,10 +291,14 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
} }
private IController _controller;
bool resetSignal; bool resetSignal;
bool hardResetSignal; bool hardResetSignal;
public void FrameAdvance(bool render, bool rendersound) public void FrameAdvance(IController controller, bool render, bool rendersound)
{ {
_controller = controller;
if (Tracer.Enabled) if (Tracer.Enabled)
cpu.TraceCallback = (s) => Tracer.Put(s); cpu.TraceCallback = (s) => Tracer.Put(s);
else else
@ -317,32 +321,32 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
//if (resetSignal) //if (resetSignal)
//Controller.UnpressButton("Reset"); TODO fix this //Controller.UnpressButton("Reset"); TODO fix this
resetSignal = Controller.IsPressed("Reset"); resetSignal = controller.IsPressed("Reset");
hardResetSignal = Controller.IsPressed("Power"); hardResetSignal = controller.IsPressed("Power");
if (Board is FDS) if (Board is FDS)
{ {
var b = Board as FDS; var b = Board as FDS;
if (Controller.IsPressed("FDS Eject")) if (controller.IsPressed("FDS Eject"))
b.Eject(); b.Eject();
for (int i = 0; i < b.NumSides; i++) for (int i = 0; i < b.NumSides; i++)
if (Controller.IsPressed("FDS Insert " + i)) if (controller.IsPressed("FDS Insert " + i))
b.InsertSide(i); b.InsertSide(i);
} }
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;
@ -698,7 +702,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
void write_joyport(byte value) void write_joyport(byte value)
{ {
var si = new StrobeInfo(latched4016, value); var si = new StrobeInfo(latched4016, value);
ControllerDeck.Strobe(si, Controller); ControllerDeck.Strobe(si, _controller);
latched4016 = value; latched4016 = value;
} }
@ -710,11 +714,11 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
if (_isVS) if (_isVS)
{ {
// for whatever reason, in VS left and right controller have swapped regs // 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 else
{ {
ret = addr == 0x4016 ? ControllerDeck.ReadA(Controller) : ControllerDeck.ReadB(Controller); ret = addr == 0x4016 ? ControllerDeck.ReadA(_controller) : ControllerDeck.ReadB(_controller);
} }
ret &= 0x1f; ret &= 0x1f;

View File

@ -354,8 +354,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
public ControllerDefinition ControllerDefinition { get; private set; } public ControllerDefinition ControllerDefinition { get; private set; }
public IController Controller { private get; set; }
private int _frame; private int _frame;
public int Frame { get { return _frame; } set { _frame = value; } } public int Frame { get { return _frame; } set { _frame = value; } }

View File

@ -112,7 +112,6 @@ 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 { private get; set; }
void SetControllerDefinition() void SetControllerDefinition()
{ {
@ -155,43 +154,43 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES
private static PadEnt[] PadP1 = GetPadList(1); private static PadEnt[] PadP1 = GetPadList(1);
private static PadEnt[] PadP2 = GetPadList(2); private static PadEnt[] PadP2 = GetPadList(2);
private int GetPad(IEnumerable<PadEnt> buttons) private int GetPad(IController controller, IEnumerable<PadEnt> buttons)
{ {
int ret = 0; int ret = 0;
foreach (var b in buttons) foreach (var b in buttons)
{ {
if (Controller.IsPressed(b.Name)) if (controller.IsPressed(b.Name))
ret |= b.Mask; ret |= b.Mask;
} }
return ret; return ret;
} }
void SetPads(out int j1, out int j2) void SetPads(IController controller, out int j1, out int j2)
{ {
if (_syncSettings.LeftPortConnected) if (_syncSettings.LeftPortConnected)
j1 = GetPad(PadP1) | unchecked((int)0xffffff00); j1 = GetPad(controller, PadP1) | unchecked((int)0xffffff00);
else else
j1 = 0; j1 = 0;
if (_syncSettings.RightPortConnected) if (_syncSettings.RightPortConnected)
j2 = GetPad(_syncSettings.LeftPortConnected ? PadP2 : PadP1) | unchecked((int)0xffffff00); j2 = GetPad(controller, _syncSettings.LeftPortConnected ? PadP2 : PadP1) | unchecked((int)0xffffff00);
else else
j2 = 0; j2 = 0;
} }
#endregion #endregion
public void FrameAdvance(bool render, bool rendersound = true) public void FrameAdvance(IController controller, bool render, bool rendersound = true)
{ {
CheckDisposed(); CheckDisposed();
using (FP.Save()) using (FP.Save())
{ {
if (Controller.IsPressed("Power")) if (controller.IsPressed("Power"))
QN.qn_reset(Context, true); QN.qn_reset(Context, true);
if (Controller.IsPressed("Reset")) if (controller.IsPressed("Reset"))
QN.qn_reset(Context, false); QN.qn_reset(Context, false);
int j1, j2; int j1, j2;
SetPads(out j1, out j2); SetPads(controller, out j1, out j2);
if (Tracer.Enabled) if (Tracer.Enabled)
QN.qn_set_tracecb(Context, _tracecb); QN.qn_set_tracecb(Context, _tracecb);

View File

@ -10,10 +10,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
public ControllerDefinition ControllerDefinition => _controllerDeck.Definition; public ControllerDefinition ControllerDefinition => _controllerDeck.Definition;
public IController Controller { private get; set; } public void FrameAdvance(IController controller, bool render, bool rendersound)
public void FrameAdvance(bool render, bool rendersound)
{ {
_controller = controller;
/* if the input poll callback is called, it will set this to false /* 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 * 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 * 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(CoreSaveState());
bw.Write(false); // not framezero bw.Write(false); // not framezero
var ssc = new SaveController(); var ssc = new SaveController();
ssc.CopyFrom(Controller); ssc.CopyFrom(controller);
ssc.Serialize(bw); ssc.Serialize(bw);
bw.Close(); bw.Close();
_savestatebuff = ms.ToArray(); _savestatebuff = ms.ToArray();
@ -49,13 +49,13 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
// speedup when sound rendering is not needed // speedup when sound rendering is not needed
Api.QUERY_set_audio_sample(rendersound ? _soundcb : null); Api.QUERY_set_audio_sample(rendersound ? _soundcb : null);
bool resetSignal = Controller.IsPressed("Reset"); bool resetSignal = controller.IsPressed("Reset");
if (resetSignal) if (resetSignal)
{ {
Api.CMD_reset(); Api.CMD_reset();
} }
bool powerSignal = Controller.IsPressed("Power"); bool powerSignal = controller.IsPressed("Power");
if (powerSignal) if (powerSignal)
{ {
Api.CMD_power(); Api.CMD_power();

View File

@ -60,12 +60,12 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
{ {
var ssc = new SaveController(ControllerDefinition); var ssc = new SaveController(ControllerDefinition);
ssc.DeSerialize(reader); ssc.DeSerialize(reader);
IController tmp = Controller; IController tmp = _controller;
Controller = ssc; _controller = ssc;
_nocallbacks = true; _nocallbacks = true;
FrameAdvance(false, false); FrameAdvance(ssc, false, false);
_nocallbacks = false; _nocallbacks = false;
Controller = tmp; _controller = tmp;
ssc.Serialize(bw); ssc.Serialize(bw);
} }
else // hack: dummy controller info else // hack: dummy controller info

View File

@ -190,6 +190,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
private readonly LibsnesApi.snes_trace_t _tracecb; private readonly LibsnesApi.snes_trace_t _tracecb;
private readonly LibsnesApi.snes_audio_sample_t _soundcb; private readonly LibsnesApi.snes_audio_sample_t _soundcb;
private IController _controller;
private LoadParams _currLoadParams; private LoadParams _currLoadParams;
private SpeexResampler _resampler; private SpeexResampler _resampler;
private int _timeFrameCounter; private int _timeFrameCounter;
@ -418,7 +419,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
/// <returns>for regular controllers, one bit D0 of button status. for other controls, varying ranges depending on id</returns> /// <returns>for regular controllers, one bit D0 of button status. for other controls, varying ranges depending on id</returns>
private short snes_input_state(int port, int device, int index, int 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() private void snes_input_poll()

View File

@ -19,8 +19,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES9X
get { return NullController.Instance.Definition; } get { return NullController.Instance.Definition; }
} }
public IController Controller { private get; set; }
#endregion #endregion
public void Dispose() public void Dispose()
@ -39,7 +37,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES9X
public IEmulatorServiceProvider ServiceProvider { get; private set; } 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++; Frame++;

View File

@ -8,10 +8,9 @@ namespace BizHawk.Emulation.Cores.PCEngine
public ControllerDefinition ControllerDefinition => PCEngineController; public ControllerDefinition ControllerDefinition => PCEngineController;
public IController Controller { private get; set; } public void FrameAdvance(IController controller, bool render, bool rendersound)
public void FrameAdvance(bool render, bool rendersound)
{ {
_controller = controller;
_lagged = true; _lagged = true;
DriveLightOn = false; DriveLightOn = false;
Frame++; Frame++;

View File

@ -74,18 +74,18 @@ namespace BizHawk.Emulation.Cores.PCEngine
_lagged = false; _lagged = false;
if (SEL == false) // return buttons if (SEL == false) // return buttons
{ {
if (Controller.IsPressed("P" + player + " B1")) value &= 0xFE; if (_controller.IsPressed("P" + player + " B1")) value &= 0xFE;
if (Controller.IsPressed("P" + player + " B2")) value &= 0xFD; if (_controller.IsPressed("P" + player + " B2")) value &= 0xFD;
if (Controller.IsPressed("P" + player + " Select")) value &= 0xFB; if (_controller.IsPressed("P" + player + " Select")) value &= 0xFB;
if (Controller.IsPressed("P" + player + " Run")) value &= 0xF7; if (_controller.IsPressed("P" + player + " Run")) value &= 0xF7;
} }
else else
{ {
//return directions //return directions
if (Controller.IsPressed("P" + player + " Up")) value &= 0xFE; if (_controller.IsPressed("P" + player + " Up")) value &= 0xFE;
if (Controller.IsPressed("P" + player + " Right")) value &= 0xFD; if (_controller.IsPressed("P" + player + " Right")) value &= 0xFD;
if (Controller.IsPressed("P" + player + " Down")) value &= 0xFB; if (_controller.IsPressed("P" + player + " Down")) value &= 0xFB;
if (Controller.IsPressed("P" + player + " Left")) value &= 0xF7; if (_controller.IsPressed("P" + player + " Left")) value &= 0xF7;
} }
} }

View File

@ -113,6 +113,7 @@ namespace BizHawk.Emulation.Cores.PCEngine
private VPC VPC; private VPC VPC;
private ScsiCDBus SCSI; private ScsiCDBus SCSI;
private ADPCM ADPCM; private ADPCM ADPCM;
private IController _controller;
public HuC6280PSG PSG; public HuC6280PSG PSG;
internal CDAudio CDAudio; internal CDAudio CDAudio;
@ -141,7 +142,6 @@ namespace BizHawk.Emulation.Cores.PCEngine
private void Init(GameInfo game, byte[] rom) private void Init(GameInfo game, byte[] rom)
{ {
Controller = NullController.Instance;
Cpu = new HuC6280(MemoryCallbacks); Cpu = new HuC6280(MemoryCallbacks);
VCE = new VCE(); VCE = new VCE();
VDC1 = new VDC(this, Cpu, VCE); VDC1 = new VDC(this, Cpu, VCE);

View File

@ -19,10 +19,9 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem
} }
} }
public IController Controller { private get; set; } public void FrameAdvance(IController controller, bool render, bool rendersound)
public void FrameAdvance(bool render, bool rendersound)
{ {
_controller = controller;
_lagged = true; _lagged = true;
Frame++; Frame++;
PSG.BeginFrame(Cpu.TotalExecutedCycles); PSG.BeginFrame(Cpu.TotalExecutedCycles);
@ -39,7 +38,7 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem
if (IsGameGear == false) if (IsGameGear == false)
{ {
Cpu.NonMaskableInterrupt = Controller.IsPressed("Pause"); Cpu.NonMaskableInterrupt = controller.IsPressed("Pause");
} }
if (IsGame3D && Settings.Fix3D) if (IsGame3D && Settings.Fix3D)

View File

@ -31,15 +31,15 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem
_lagged = false; _lagged = false;
byte value = 0xFF; byte value = 0xFF;
if (Controller.IsPressed("P1 Up")) value &= 0xFE; if (_controller.IsPressed("P1 Up")) value &= 0xFE;
if (Controller.IsPressed("P1 Down")) value &= 0xFD; if (_controller.IsPressed("P1 Down")) value &= 0xFD;
if (Controller.IsPressed("P1 Left")) value &= 0xFB; if (_controller.IsPressed("P1 Left")) value &= 0xFB;
if (Controller.IsPressed("P1 Right")) value &= 0xF7; if (_controller.IsPressed("P1 Right")) value &= 0xF7;
if (Controller.IsPressed("P1 B1")) value &= 0xEF; if (_controller.IsPressed("P1 B1")) value &= 0xEF;
if (Controller.IsPressed("P1 B2")) value &= 0xDF; if (_controller.IsPressed("P1 B2")) value &= 0xDF;
if (Controller.IsPressed("P2 Up")) value &= 0xBF; if (_controller.IsPressed("P2 Up")) value &= 0xBF;
if (Controller.IsPressed("P2 Down")) value &= 0x7F; if (_controller.IsPressed("P2 Down")) value &= 0x7F;
return value; return value;
} }
@ -50,12 +50,12 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem
_lagged = false; _lagged = false;
byte value = 0xFF; byte value = 0xFF;
if (Controller.IsPressed("P2 Left")) value &= 0xFE; if (_controller.IsPressed("P2 Left")) value &= 0xFE;
if (Controller.IsPressed("P2 Right")) value &= 0xFD; if (_controller.IsPressed("P2 Right")) value &= 0xFD;
if (Controller.IsPressed("P2 B1")) value &= 0xFB; if (_controller.IsPressed("P2 B1")) value &= 0xFB;
if (Controller.IsPressed("P2 B2")) value &= 0xF7; if (_controller.IsPressed("P2 B2")) value &= 0xF7;
if (Controller.IsPressed("Reset")) value &= 0xEF; if (_controller.IsPressed("Reset")) value &= 0xEF;
if ((Port3F & 0x0F) == 5) if ((Port3F & 0x0F) == 5)
{ {
@ -83,8 +83,8 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem
} }
byte value = 0xFF; byte value = 0xFF;
if ((Controller.IsPressed("Pause") && !IsGameGear) || if ((_controller.IsPressed("Pause") && !IsGameGear) ||
(Controller.IsPressed("P1 Start") && IsGameGear)) (_controller.IsPressed("P1 Start") && IsGameGear))
{ {
value ^= 0x80; value ^= 0x80;
} }

View File

@ -46,6 +46,7 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem
public bool IsSG1000 { get; set; } public bool IsSG1000 { get; set; }
private bool HasYM2413 = false; private bool HasYM2413 = false;
private IController _controller;
private int frame = 0; private int frame = 0;
@ -113,11 +114,6 @@ namespace BizHawk.Emulation.Cores.Sega.MasterSystem
HasYM2413 = true; HasYM2413 = true;
} }
if (Controller == null)
{
Controller = NullController.Instance;
}
Cpu = new Z80A Cpu = new Z80A
{ {
RegisterSP = 0xDFF0, RegisterSP = 0xDFF0,

View File

@ -22,10 +22,10 @@
} }
if (address == 0xA000) if (address == 0xA000)
{ {
if (Controller.IsPressed("P1 Left")) xCoord++; if (_controller.IsPressed("P1 Left")) xCoord++;
if (Controller.IsPressed("P1 Right")) xCoord++; if (_controller.IsPressed("P1 Right")) xCoord++;
if (Controller.IsPressed("P1 Up")) yCoord--; if (_controller.IsPressed("P1 Up")) yCoord--;
if (Controller.IsPressed("P1 Down")) yCoord++; if (_controller.IsPressed("P1 Down")) yCoord++;
return 0; return 0;
//if (!Controller["P1 B1"]) return 0; //if (!Controller["P1 B1"]) return 0;

View File

@ -167,8 +167,6 @@ namespace BizHawk.Emulation.Cores.Sega.Saturn
get { return SaturnController; } get { return SaturnController; }
} }
public IController Controller { private get; set; }
public bool GLMode { get; private set; } public bool GLMode { get; private set; }
public void SetGLRes(int factor, int width, int height) public void SetGLRes(int factor, int width, int height)
@ -203,7 +201,7 @@ namespace BizHawk.Emulation.Cores.Sega.Saturn
LibYabause.libyabause_glresize(width, height); 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; int w, h, nsamp;
@ -214,64 +212,64 @@ namespace BizHawk.Emulation.Cores.Sega.Saturn
LibYabause.Buttons1 p21 = (LibYabause.Buttons1)0xff; LibYabause.Buttons1 p21 = (LibYabause.Buttons1)0xff;
LibYabause.Buttons2 p22 = (LibYabause.Buttons2)0xff; LibYabause.Buttons2 p22 = (LibYabause.Buttons2)0xff;
if (Controller.IsPressed("P1 A")) if (controller.IsPressed("P1 A"))
p11 &= ~LibYabause.Buttons1.A; p11 &= ~LibYabause.Buttons1.A;
if (Controller.IsPressed("P1 B")) if (controller.IsPressed("P1 B"))
p11 &= ~LibYabause.Buttons1.B; p11 &= ~LibYabause.Buttons1.B;
if (Controller.IsPressed("P1 C")) if (controller.IsPressed("P1 C"))
p11 &= ~LibYabause.Buttons1.C; p11 &= ~LibYabause.Buttons1.C;
if (Controller.IsPressed("P1 Start")) if (controller.IsPressed("P1 Start"))
p11 &= ~LibYabause.Buttons1.S; p11 &= ~LibYabause.Buttons1.S;
if (Controller.IsPressed("P1 Left")) if (controller.IsPressed("P1 Left"))
p11 &= ~LibYabause.Buttons1.L; p11 &= ~LibYabause.Buttons1.L;
if (Controller.IsPressed("P1 Right")) if (controller.IsPressed("P1 Right"))
p11 &= ~LibYabause.Buttons1.R; p11 &= ~LibYabause.Buttons1.R;
if (Controller.IsPressed("P1 Up")) if (controller.IsPressed("P1 Up"))
p11 &= ~LibYabause.Buttons1.U; p11 &= ~LibYabause.Buttons1.U;
if (Controller.IsPressed("P1 Down")) if (controller.IsPressed("P1 Down"))
p11 &= ~LibYabause.Buttons1.D; p11 &= ~LibYabause.Buttons1.D;
if (Controller.IsPressed("P1 L")) if (controller.IsPressed("P1 L"))
p12 &= ~LibYabause.Buttons2.L; p12 &= ~LibYabause.Buttons2.L;
if (Controller.IsPressed("P1 R")) if (controller.IsPressed("P1 R"))
p12 &= ~LibYabause.Buttons2.R; p12 &= ~LibYabause.Buttons2.R;
if (Controller.IsPressed("P1 X")) if (controller.IsPressed("P1 X"))
p12 &= ~LibYabause.Buttons2.X; p12 &= ~LibYabause.Buttons2.X;
if (Controller.IsPressed("P1 Y")) if (controller.IsPressed("P1 Y"))
p12 &= ~LibYabause.Buttons2.Y; p12 &= ~LibYabause.Buttons2.Y;
if (Controller.IsPressed("P1 Z")) if (controller.IsPressed("P1 Z"))
p12 &= ~LibYabause.Buttons2.Z; p12 &= ~LibYabause.Buttons2.Z;
if (Controller.IsPressed("P2 A")) if (controller.IsPressed("P2 A"))
p21 &= ~LibYabause.Buttons1.A; p21 &= ~LibYabause.Buttons1.A;
if (Controller.IsPressed("P2 B")) if (controller.IsPressed("P2 B"))
p21 &= ~LibYabause.Buttons1.B; p21 &= ~LibYabause.Buttons1.B;
if (Controller.IsPressed("P2 C")) if (controller.IsPressed("P2 C"))
p21 &= ~LibYabause.Buttons1.C; p21 &= ~LibYabause.Buttons1.C;
if (Controller.IsPressed("P2 Start")) if (controller.IsPressed("P2 Start"))
p21 &= ~LibYabause.Buttons1.S; p21 &= ~LibYabause.Buttons1.S;
if (Controller.IsPressed("P2 Left")) if (controller.IsPressed("P2 Left"))
p21 &= ~LibYabause.Buttons1.L; p21 &= ~LibYabause.Buttons1.L;
if (Controller.IsPressed("P2 Right")) if (controller.IsPressed("P2 Right"))
p21 &= ~LibYabause.Buttons1.R; p21 &= ~LibYabause.Buttons1.R;
if (Controller.IsPressed("P2 Up")) if (controller.IsPressed("P2 Up"))
p21 &= ~LibYabause.Buttons1.U; p21 &= ~LibYabause.Buttons1.U;
if (Controller.IsPressed("P2 Down")) if (controller.IsPressed("P2 Down"))
p21 &= ~LibYabause.Buttons1.D; p21 &= ~LibYabause.Buttons1.D;
if (Controller.IsPressed("P2 L")) if (controller.IsPressed("P2 L"))
p22 &= ~LibYabause.Buttons2.L; p22 &= ~LibYabause.Buttons2.L;
if (Controller.IsPressed("P2 R")) if (controller.IsPressed("P2 R"))
p22 &= ~LibYabause.Buttons2.R; p22 &= ~LibYabause.Buttons2.R;
if (Controller.IsPressed("P2 X")) if (controller.IsPressed("P2 X"))
p22 &= ~LibYabause.Buttons2.X; p22 &= ~LibYabause.Buttons2.X;
if (Controller.IsPressed("P2 Y")) if (controller.IsPressed("P2 Y"))
p22 &= ~LibYabause.Buttons2.Y; p22 &= ~LibYabause.Buttons2.Y;
if (Controller.IsPressed("P2 Z")) if (controller.IsPressed("P2 Z"))
p22 &= ~LibYabause.Buttons2.Z; p22 &= ~LibYabause.Buttons2.Z;
if (Controller.IsPressed("Reset")) if (controller.IsPressed("Reset"))
LibYabause.libyabause_softreset(); LibYabause.libyabause_softreset();
if (Controller.IsPressed("Power")) if (controller.IsPressed("Power"))
LibYabause.libyabause_hardreset(); LibYabause.libyabause_hardreset();
LibYabause.libyabause_setpads(p11, p12, p21, p22); LibYabause.libyabause_setpads(p11, p12, p21, p22);

View File

@ -9,14 +9,12 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx
public ControllerDefinition ControllerDefinition { get; private set; } public ControllerDefinition ControllerDefinition { get; private 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(IController controller, bool render, bool rendersound = true)
{ {
if (Controller.IsPressed("Reset")) if (controller.IsPressed("Reset"))
LibGPGX.gpgx_reset(false); LibGPGX.gpgx_reset(false);
if (Controller.IsPressed("Power")) if (controller.IsPressed("Power"))
LibGPGX.gpgx_reset(true); LibGPGX.gpgx_reset(true);
// do we really have to get each time? nothing has changed // 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.ScreenWidth = vwidth;
ControlConverter.ScreenHeight = vheight; ControlConverter.ScreenHeight = vheight;
ControlConverter.Convert(Controller, input); ControlConverter.Convert(controller, input);
if (!LibGPGX.gpgx_put_control(input, inputsize)) if (!LibGPGX.gpgx_put_control(input, inputsize))
throw new Exception("gpgx_put_control() failed!"); throw new Exception("gpgx_put_control() failed!");

View File

@ -9,14 +9,12 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx64
public ControllerDefinition ControllerDefinition { get; private set; } public ControllerDefinition ControllerDefinition { get; private 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(IController controller, bool render, bool rendersound = true)
{ {
if (Controller.IsPressed("Reset")) if (controller.IsPressed("Reset"))
Core.gpgx_reset(false); Core.gpgx_reset(false);
if (Controller.IsPressed("Power")) if (controller.IsPressed("Power"))
Core.gpgx_reset(true); Core.gpgx_reset(true);
// this shouldn't be needed, as nothing has changed // this shouldn't be needed, as nothing has changed
@ -25,7 +23,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx64
ControlConverter.ScreenWidth = vwidth; ControlConverter.ScreenWidth = vwidth;
ControlConverter.ScreenHeight = vheight; ControlConverter.ScreenHeight = vheight;
ControlConverter.Convert(Controller, input); ControlConverter.Convert(controller, input);
if (!Core.gpgx_put_control(input, inputsize)) if (!Core.gpgx_put_control(input, inputsize))
throw new Exception("gpgx_put_control() failed!"); throw new Exception("gpgx_put_control() failed!");

View File

@ -39,7 +39,6 @@ namespace BizHawk.Emulation.Cores.Sony.PSP
}; };
public ControllerDefinition ControllerDefinition { get { return PSPController; } } public ControllerDefinition ControllerDefinition { get { return PSPController; } }
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; }
@ -106,10 +105,9 @@ namespace BizHawk.Emulation.Cores.Sony.PSP
} }
} }
private void UpdateInput() private void UpdateInput(IController c)
{ {
PPSSPPDll.Buttons b = 0; PPSSPPDll.Buttons b = 0;
var c = Controller;
if (c.IsPressed("Up")) b |= PPSSPPDll.Buttons.UP; if (c.IsPressed("Up")) b |= PPSSPPDll.Buttons.UP;
if (c.IsPressed("Down")) b |= PPSSPPDll.Buttons.DOWN; if (c.IsPressed("Down")) b |= PPSSPPDll.Buttons.DOWN;
if (c.IsPressed("Left")) b |= PPSSPPDll.Buttons.LEFT; 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++; Frame++;
UpdateInput(); UpdateInput(controller);
PPSSPPDll.BizAdvance(screenbuffer, input); PPSSPPDll.BizAdvance(screenbuffer, input);
// problem 1: audio can be 48khz, if a particular core parameter is set. we're not accounting for that. // problem 1: audio can be 48khz, if a particular core parameter is set. we're not accounting for that.

View File

@ -495,51 +495,51 @@ namespace BizHawk.Emulation.Cores.Sony.PSX
if (fioCfg.Devices8[slot] == OctoshockDll.ePeripheralType.NegCon) if (fioCfg.Devices8[slot] == OctoshockDll.ePeripheralType.NegCon)
{ {
//1,2,4 skipped (would be Select, L3, R3 on other pads) //1,2,4 skipped (would be Select, L3, R3 on other pads)
if (Controller.IsPressed(pstring + "Start")) buttons |= 8; if (_controller.IsPressed(pstring + "Start")) buttons |= 8;
if (Controller.IsPressed(pstring + "Up")) buttons |= 16; if (_controller.IsPressed(pstring + "Up")) buttons |= 16;
if (Controller.IsPressed(pstring + "Right")) buttons |= 32; if (_controller.IsPressed(pstring + "Right")) buttons |= 32;
if (Controller.IsPressed(pstring + "Down")) buttons |= 64; if (_controller.IsPressed(pstring + "Down")) buttons |= 64;
if (Controller.IsPressed(pstring + "Left")) buttons |= 128; if (_controller.IsPressed(pstring + "Left")) buttons |= 128;
//256,512,1024 skipped (would be L2, R2, L1 on other pads) //256,512,1024 skipped (would be L2, R2, L1 on other pads)
if (Controller.IsPressed(pstring + "R")) buttons |= 2048; if (_controller.IsPressed(pstring + "R")) buttons |= 2048;
if (Controller.IsPressed(pstring + "B")) buttons |= 4096; if (_controller.IsPressed(pstring + "B")) buttons |= 4096;
if (Controller.IsPressed(pstring + "A")) buttons |= 8192; if (_controller.IsPressed(pstring + "A")) buttons |= 8192;
byte twist = (byte)Controller.GetFloat(pstring + "Twist"); byte twist = (byte)_controller.GetFloat(pstring + "Twist");
byte analog1 = (byte)Controller.GetFloat(pstring + "1"); byte analog1 = (byte)_controller.GetFloat(pstring + "1");
byte analog2 = (byte)Controller.GetFloat(pstring + "2"); byte analog2 = (byte)_controller.GetFloat(pstring + "2");
byte analogL = (byte)Controller.GetFloat(pstring + "L"); byte analogL = (byte)_controller.GetFloat(pstring + "L");
OctoshockDll.shock_Peripheral_SetPadInput(psx, portNum, buttons, twist, analog1, analog2, analogL); OctoshockDll.shock_Peripheral_SetPadInput(psx, portNum, buttons, twist, analog1, analog2, analogL);
} }
else else
{ {
if (Controller.IsPressed(pstring + "Select")) buttons |= 1; if (_controller.IsPressed(pstring + "Select")) buttons |= 1;
if (Controller.IsPressed(pstring + "Start")) buttons |= 8; if (_controller.IsPressed(pstring + "Start")) buttons |= 8;
if (Controller.IsPressed(pstring + "Up")) buttons |= 16; if (_controller.IsPressed(pstring + "Up")) buttons |= 16;
if (Controller.IsPressed(pstring + "Right")) buttons |= 32; if (_controller.IsPressed(pstring + "Right")) buttons |= 32;
if (Controller.IsPressed(pstring + "Down")) buttons |= 64; if (_controller.IsPressed(pstring + "Down")) buttons |= 64;
if (Controller.IsPressed(pstring + "Left")) buttons |= 128; if (_controller.IsPressed(pstring + "Left")) buttons |= 128;
if (Controller.IsPressed(pstring + "L2")) buttons |= 256; if (_controller.IsPressed(pstring + "L2")) buttons |= 256;
if (Controller.IsPressed(pstring + "R2")) buttons |= 512; if (_controller.IsPressed(pstring + "R2")) buttons |= 512;
if (Controller.IsPressed(pstring + "L1")) buttons |= 1024; if (_controller.IsPressed(pstring + "L1")) buttons |= 1024;
if (Controller.IsPressed(pstring + "R1")) buttons |= 2048; if (_controller.IsPressed(pstring + "R1")) buttons |= 2048;
if (Controller.IsPressed(pstring + "Triangle")) buttons |= 4096; if (_controller.IsPressed(pstring + "Triangle")) buttons |= 4096;
if (Controller.IsPressed(pstring + "Circle")) buttons |= 8192; if (_controller.IsPressed(pstring + "Circle")) buttons |= 8192;
if (Controller.IsPressed(pstring + "Cross")) buttons |= 16384; if (_controller.IsPressed(pstring + "Cross")) buttons |= 16384;
if (Controller.IsPressed(pstring + "Square")) buttons |= 32768; if (_controller.IsPressed(pstring + "Square")) buttons |= 32768;
byte left_x = 0, left_y = 0, right_x = 0, right_y = 0; 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 (fioCfg.Devices8[slot] == OctoshockDll.ePeripheralType.DualShock || fioCfg.Devices8[slot] == OctoshockDll.ePeripheralType.DualAnalog)
{ {
if (Controller.IsPressed(pstring + "L3")) buttons |= 2; if (_controller.IsPressed(pstring + "L3")) buttons |= 2;
if (Controller.IsPressed(pstring + "R3")) buttons |= 4; if (_controller.IsPressed(pstring + "R3")) buttons |= 4;
if (Controller.IsPressed(pstring + "MODE")) buttons |= 65536; if (_controller.IsPressed(pstring + "MODE")) buttons |= 65536;
left_x = (byte)Controller.GetFloat(pstring + "LStick X"); left_x = (byte)_controller.GetFloat(pstring + "LStick X");
left_y = (byte)Controller.GetFloat(pstring + "LStick Y"); left_y = (byte)_controller.GetFloat(pstring + "LStick Y");
right_x = (byte)Controller.GetFloat(pstring + "RStick X"); right_x = (byte)_controller.GetFloat(pstring + "RStick X");
right_y = (byte)Controller.GetFloat(pstring + "RStick Y"); right_y = (byte)_controller.GetFloat(pstring + "RStick Y");
} }
OctoshockDll.shock_Peripheral_SetPadInput(psx, portNum, buttons, left_x, left_y, right_x, right_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 //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 //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); OctoshockDll.shock_OpenTray(psx);
CurrentTrayOpen = true; CurrentTrayOpen = true;
@ -700,7 +700,7 @@ namespace BizHawk.Emulation.Cores.Sony.PSX
//change the disc if needed, and valid //change the disc if needed, and valid
//also if frame is 0, we need to set a disc no matter what //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 if (requestedDisc != CurrentDiscIndexMounted && CurrentTrayOpen
|| Frame == 0 || Frame == 0
) )
@ -728,22 +728,25 @@ namespace BizHawk.Emulation.Cores.Sony.PSX
} }
//if tray close is requested, and valid, apply it. //if tray close is requested, and valid, apply it.
if (Controller.IsPressed("Close") && CurrentTrayOpen) if (_controller.IsPressed("Close") && CurrentTrayOpen)
{ {
OctoshockDll.shock_CloseTray(psx); OctoshockDll.shock_CloseTray(psx);
CurrentTrayOpen = false; CurrentTrayOpen = false;
} }
//if frame is 0 and user has made no preference, close the tray //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); OctoshockDll.shock_CloseTray(psx);
CurrentTrayOpen = false; 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(); FrameAdvance_PrepDiscState();
//clear drive light. itll get set to light up by sector-reading callbacks //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); OctoshockDll.shock_SetTraceCallback(psx, IntPtr.Zero, null);
//apply soft reset if needed //apply soft reset if needed
if (Controller.IsPressed("Reset")) if (_controller.IsPressed("Reset"))
OctoshockDll.shock_SoftReset(psx); OctoshockDll.shock_SoftReset(psx);
//------------------------ //------------------------
@ -844,7 +847,6 @@ namespace BizHawk.Emulation.Cores.Sony.PSX
} }
public ControllerDefinition ControllerDefinition { get; private set; } public ControllerDefinition ControllerDefinition { get; private 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

@ -42,36 +42,35 @@ namespace BizHawk.Emulation.Cores.WonderSwan
} }
}; };
public ControllerDefinition ControllerDefinition { get { return WonderSwanController; } } public ControllerDefinition ControllerDefinition { get { return WonderSwanController; } }
public IController Controller { private get; set; }
BizSwan.Buttons GetButtons() BizSwan.Buttons GetButtons(IController controller)
{ {
BizSwan.Buttons ret = 0; BizSwan.Buttons ret = 0;
if (Controller.IsPressed("P1 X1")) ret |= BizSwan.Buttons.X1; if (controller.IsPressed("P1 X1")) ret |= BizSwan.Buttons.X1;
if (Controller.IsPressed("P1 X2")) ret |= BizSwan.Buttons.X2; if (controller.IsPressed("P1 X2")) ret |= BizSwan.Buttons.X2;
if (Controller.IsPressed("P1 X3")) ret |= BizSwan.Buttons.X3; if (controller.IsPressed("P1 X3")) ret |= BizSwan.Buttons.X3;
if (Controller.IsPressed("P1 X4")) ret |= BizSwan.Buttons.X4; if (controller.IsPressed("P1 X4")) ret |= BizSwan.Buttons.X4;
if (Controller.IsPressed("P1 Y1")) ret |= BizSwan.Buttons.Y1; if (controller.IsPressed("P1 Y1")) ret |= BizSwan.Buttons.Y1;
if (Controller.IsPressed("P1 Y2")) ret |= BizSwan.Buttons.Y2; if (controller.IsPressed("P1 Y2")) ret |= BizSwan.Buttons.Y2;
if (Controller.IsPressed("P1 Y3")) ret |= BizSwan.Buttons.Y3; if (controller.IsPressed("P1 Y3")) ret |= BizSwan.Buttons.Y3;
if (Controller.IsPressed("P1 Y4")) ret |= BizSwan.Buttons.Y4; if (controller.IsPressed("P1 Y4")) ret |= BizSwan.Buttons.Y4;
if (Controller.IsPressed("P1 Start")) ret |= BizSwan.Buttons.Start; if (controller.IsPressed("P1 Start")) ret |= BizSwan.Buttons.Start;
if (Controller.IsPressed("P1 B")) ret |= BizSwan.Buttons.B; if (controller.IsPressed("P1 B")) ret |= BizSwan.Buttons.B;
if (Controller.IsPressed("P1 A")) ret |= BizSwan.Buttons.A; if (controller.IsPressed("P1 A")) ret |= BizSwan.Buttons.A;
if (Controller.IsPressed("P2 X1")) ret |= BizSwan.Buttons.R_X1; if (controller.IsPressed("P2 X1")) ret |= BizSwan.Buttons.R_X1;
if (Controller.IsPressed("P2 X2")) ret |= BizSwan.Buttons.R_X2; if (controller.IsPressed("P2 X2")) ret |= BizSwan.Buttons.R_X2;
if (Controller.IsPressed("P2 X3")) ret |= BizSwan.Buttons.R_X3; if (controller.IsPressed("P2 X3")) ret |= BizSwan.Buttons.R_X3;
if (Controller.IsPressed("P2 X4")) ret |= BizSwan.Buttons.R_X4; if (controller.IsPressed("P2 X4")) ret |= BizSwan.Buttons.R_X4;
if (Controller.IsPressed("P2 Y1")) ret |= BizSwan.Buttons.R_Y1; if (controller.IsPressed("P2 Y1")) ret |= BizSwan.Buttons.R_Y1;
if (Controller.IsPressed("P2 Y2")) ret |= BizSwan.Buttons.R_Y2; if (controller.IsPressed("P2 Y2")) ret |= BizSwan.Buttons.R_Y2;
if (Controller.IsPressed("P2 Y3")) ret |= BizSwan.Buttons.R_Y3; if (controller.IsPressed("P2 Y3")) ret |= BizSwan.Buttons.R_Y3;
if (Controller.IsPressed("P2 Y4")) ret |= BizSwan.Buttons.R_Y4; if (controller.IsPressed("P2 Y4")) ret |= BizSwan.Buttons.R_Y4;
if (Controller.IsPressed("P2 Start")) ret |= BizSwan.Buttons.R_Start; if (controller.IsPressed("P2 Start")) ret |= BizSwan.Buttons.R_Start;
if (Controller.IsPressed("P2 B")) ret |= BizSwan.Buttons.R_B; if (controller.IsPressed("P2 B")) ret |= BizSwan.Buttons.R_B;
if (Controller.IsPressed("P2 A")) ret |= BizSwan.Buttons.R_A; 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; return ret;
} }

View File

@ -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++; Frame++;
IsLagFrame = true; IsLagFrame = true;
if (Controller.IsPressed("Power")) if (controller.IsPressed("Power"))
BizSwan.bizswan_reset(Core); BizSwan.bizswan_reset(Core);
bool rotate = false; bool rotate = false;
int soundbuffsize = sbuff.Length; 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) if (soundbuffsize == sbuff.Length)
throw new Exception(); throw new Exception();
sbuffcontains = soundbuffsize; sbuffcontains = soundbuffsize;

View File

@ -157,8 +157,11 @@ namespace BizHawk.Emulation.Cores.Libretro
[FeatureNotImplemented] [FeatureNotImplemented]
public int TotalExecutedCycles { get { throw new NotImplementedException(); } } 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(); api.CMD_Run();
} }
@ -291,7 +294,6 @@ namespace BizHawk.Emulation.Cores.Libretro
} }
public ControllerDefinition ControllerDefinition { get; private set; } public ControllerDefinition ControllerDefinition { get; private set; }
public IController Controller { get; set; }
int timeFrameCounter; int timeFrameCounter;
public int Frame { get { return timeFrameCounter; } set { timeFrameCounter = value; } } public int Frame { get { return timeFrameCounter; } set { timeFrameCounter = value; } }

View File

@ -30,9 +30,9 @@ namespace BizHawk.Emulation.Cores.Libretro
{ {
switch ((LibretroApi.RETRO_DEVICE_ID_POINTER)id) 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.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.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.PRESSED: return (short)(_controller.IsPressed("Pointer Pressed") ? 1 : 0);
} }
return 0; return 0;
} }
@ -184,7 +184,7 @@ namespace BizHawk.Emulation.Cores.Libretro
case LibretroApi.RETRO_KEY.UNDO: button = "Undo"; break; 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: case LibretroApi.RETRO_DEVICE.JOYPAD:
@ -219,7 +219,7 @@ namespace BizHawk.Emulation.Cores.Libretro
private bool GetButton(uint pnum, string type, string button) private bool GetButton(uint pnum, string type, string button)
{ {
string key = string.Format("P{0} {1} {2}", pnum, type, 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) if (b == true)
{ {
return true; //debugging placeholder return true; //debugging placeholder