73 lines
2.8 KiB
C#
73 lines
2.8 KiB
C#
namespace BizHawk.Emulation.Consoles.TurboGrafx
|
|
{
|
|
public partial class PCEngine
|
|
{
|
|
public static readonly ControllerDefinition PCEngineController =
|
|
new ControllerDefinition
|
|
{
|
|
Name = "PC Engine Controller",
|
|
BoolButtons =
|
|
{
|
|
"P1 Up", "P1 Down", "P1 Left", "P1 Right", "P1 B2", "P1 B1", "P1 Select", "P1 Run",
|
|
"P2 Up", "P2 Down", "P2 Left", "P2 Right", "P2 B2", "P2 B1", "P2 Select", "P2 Run",
|
|
"P3 Up", "P3 Down", "P3 Left", "P3 Right", "P3 B2", "P3 B1", "P3 Select", "P3 Run",
|
|
"P4 Up", "P4 Down", "P4 Left", "P4 Right", "P4 B2", "P4 B1", "P4 Select", "P4 Run",
|
|
"P5 Up", "P5 Down", "P5 Left", "P5 Right", "P5 B2", "P5 B1", "P5 Select", "P5 Run"
|
|
}
|
|
};
|
|
|
|
public ControllerDefinition ControllerDefinition { get { return PCEngineController; } }
|
|
public IController Controller { get; set; }
|
|
|
|
private int SelectedController;
|
|
private byte InputByte;
|
|
public bool SEL { get { return ((InputByte & 1) != 0) ;} }
|
|
public bool CLR { get { return ((InputByte & 2) != 0); } }
|
|
|
|
private void WriteInput(byte value)
|
|
{
|
|
bool prevSEL = SEL;
|
|
InputByte = value;
|
|
|
|
if (SEL && CLR)
|
|
SelectedController = 0;
|
|
|
|
if (CLR == false && prevSEL == false && SEL == true)
|
|
SelectedController = (SelectedController + 1);
|
|
}
|
|
|
|
private byte ReadInput()
|
|
{
|
|
byte value = 0x3F;
|
|
|
|
int player = SelectedController + 1;
|
|
if (player < 6)
|
|
{
|
|
lagged = false;
|
|
if (SEL == false) // return buttons
|
|
{
|
|
if (Controller["P" + player + " B1"]) value &= 0xFE;
|
|
if (Controller["P" + player + " B2"]) value &= 0xFD;
|
|
if (Controller["P" + player + " Select"]) value &= 0xFB;
|
|
if (Controller["P" + player + " Run"]) value &= 0xF7;
|
|
}
|
|
else
|
|
{
|
|
//return directions
|
|
if (Controller["P" + player + " Up"]) value &= 0xFE;
|
|
if (Controller["P" + player + " Right"]) value &= 0xFD;
|
|
if (Controller["P" + player + " Down"]) value &= 0xFB;
|
|
if (Controller["P" + player + " Left"]) value &= 0xF7;
|
|
}
|
|
}
|
|
|
|
if (Region == "Japan") value |= 0x40;
|
|
|
|
/*if (Type != NecSystemType.TurboCD)
|
|
value |= 0x80;*/
|
|
|
|
return value;
|
|
}
|
|
}
|
|
}
|