BizHawk/BizHawk.Emulation.Cores/Consoles/PC Engine/PCEngine.Input.cs

55 lines
1014 B
C#
Raw Normal View History

namespace BizHawk.Emulation.Cores.PCEngine
2011-01-11 02:55:51 +00:00
{
public partial class PCEngine
{
2017-07-18 16:20:02 +00:00
private int _selectedController;
private byte _inputByte;
2017-07-18 16:20:02 +00:00
private bool Sel => (_inputByte & 1) != 0;
private bool Clr => (_inputByte & 2) != 0;
2017-04-25 17:57:42 +00:00
private void WriteInput(byte value)
{
2017-07-18 16:20:02 +00:00
bool prevSel = Sel;
_inputByte = value;
2017-07-18 16:20:02 +00:00
if (Sel && Clr)
2017-04-25 17:57:42 +00:00
{
2017-07-18 16:20:02 +00:00
_selectedController = 0;
2017-04-25 17:57:42 +00:00
}
2011-01-11 02:55:51 +00:00
2017-07-18 16:20:02 +00:00
if (Clr == false && prevSel == false && Sel)
2017-04-25 17:57:42 +00:00
{
2017-07-18 16:20:02 +00:00
_selectedController = _selectedController + 1;
2017-04-25 17:57:42 +00:00
}
}
2011-01-11 02:55:51 +00:00
private readonly PceControllerDeck _controllerDeck;
2017-04-25 17:57:42 +00:00
private byte ReadInput()
{
InputCallbacks.Call();
byte value = 0x3F;
2011-03-14 06:12:40 +00:00
2017-07-18 16:20:02 +00:00
int player = _selectedController + 1;
if (player < 6)
{
_lagged = false;
2017-07-18 16:20:02 +00:00
value &= _controllerDeck.Read(player, _controller, Sel);
}
2017-04-25 17:57:42 +00:00
if (Region == "Japan")
{
value |= 0x40;
}
if (Type != NecSystemType.TurboCD && BramEnabled == false)
2017-04-25 17:57:42 +00:00
{
value |= 0x80;
2017-04-25 17:57:42 +00:00
}
return value;
}
}
2011-01-11 02:55:51 +00:00
}