PCE: 5-player turbotap emulation

This commit is contained in:
beirich 2011-03-14 06:12:40 +00:00
parent 6d531065cf
commit c9c34ef1db
3 changed files with 55 additions and 33 deletions

View File

@ -6,7 +6,14 @@
new ControllerDefinition new ControllerDefinition
{ {
Name = "PC Engine Controller", Name = "PC Engine Controller",
BoolButtons = { "Up", "Down", "Left", "Right", "II", "I", "Select", "Run" } 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 ControllerDefinition ControllerDefinition { get { return PCEngineController; } }
@ -40,21 +47,21 @@
string input = "|"; string input = "|";
if (Controller.IsPressed("Up")) input += "U"; if (Controller.IsPressed("P1 Up")) input += "U";
else input += "."; else input += ".";
if (Controller.IsPressed("Down")) input += "D"; if (Controller.IsPressed("P1 Down")) input += "D";
else input += "."; else input += ".";
if (Controller.IsPressed("Left")) input += "L"; if (Controller.IsPressed("P1 Left")) input += "L";
else input += "."; else input += ".";
if (Controller.IsPressed("Right")) input += "R"; if (Controller.IsPressed("P1 Right")) input += "R";
else input += "."; else input += ".";
if (Controller.IsPressed("I")) input += "1"; if (Controller.IsPressed("P1 B1")) input += "1";
else input += "."; else input += ".";
if (Controller.IsPressed("II")) input += "2"; if (Controller.IsPressed("P1 B2")) input += "2";
else input += "."; else input += ".";
if (Controller.IsPressed("Select")) input += "S"; if (Controller.IsPressed("P1 Select")) input += "S";
else input += "."; else input += ".";
if (Controller.IsPressed("Run")) input += "R"; if (Controller.IsPressed("P1 Run")) input += "R";
else input += "."; else input += ".";
input += "|.|"; //TODO: Add commands like reset here input += "|.|"; //TODO: Add commands like reset here
@ -62,32 +69,46 @@
return input; return input;
} }
private byte inputSelector; private int SelectedController;
public bool SEL { get { return ((inputSelector & 1) != 0) ;} } private byte InputByte;
public bool SEL { get { return ((InputByte & 1) != 0) ;} }
public bool CLR { get { return ((InputByte & 2) != 0); } }
private void WriteInput(byte value) private void WriteInput(byte value)
{ {
inputSelector = value; bool prevSEL = SEL;
InputByte = value;
if (CLR == false && prevSEL == false && SEL == true)
SelectedController = (SelectedController + 1) % 6;
} }
private byte ReadInput() private byte ReadInput()
{ {
byte value = 0xBF; byte value = 0x3F;
if (CLR == false && SelectedController != 0)
{
if (SEL == false) // return buttons if (SEL == false) // return buttons
{ {
if (Controller["I"]) value &= 0xFE; if (Controller["P" + SelectedController + " B1"]) value &= 0xFE;
if (Controller["II"]) value &= 0xFD; if (Controller["P" + SelectedController + " B2"]) value &= 0xFD;
if (Controller["Select"]) value &= 0xFB; if (Controller["P" + SelectedController + " Select"]) value &= 0xFB;
if (Controller["Run"]) value &= 0xF7; if (Controller["P" + SelectedController + " Run"]) value &= 0xF7;
} else { //return directions }
if (Controller["Up"]) value &= 0xFE; else
if (Controller["Right"]) value &= 0xFD; {
if (Controller["Down"]) value &= 0xFB; //return directions
if (Controller["Left"]) value &= 0xF7; if (Controller["P" + SelectedController + " Up"]) value &= 0xFE;
if (Controller["P" + SelectedController + " Right"]) value &= 0xFD;
if (Controller["P" + SelectedController + " Down"]) value &= 0xFB;
if (Controller["P" + SelectedController + " Left"]) value &= 0xF7;
}
} }
if (Region == "Japan") value |= 0x40; if (Region == "Japan") value |= 0x40;
if (Type != NecSystemType.TurboCD)
value |= 0x80;
return value; return value;
} }
} }

View File

@ -100,6 +100,7 @@ namespace BizHawk.Emulation.Consoles.TurboGrafx
public void FrameAdvance(bool render) public void FrameAdvance(bool render)
{ {
Controller.UpdateControls(Frame++); Controller.UpdateControls(Frame++);
SelectedController = 0;
PSG.BeginFrame(Cpu.TotalExecutedCycles); PSG.BeginFrame(Cpu.TotalExecutedCycles);
if (SuperGrafx) if (SuperGrafx)

View File

@ -278,17 +278,17 @@ namespace BizHawk.MultiClient
Global.SMSControls = smsControls; Global.SMSControls = smsControls;
var pceControls = new Controller(PCEngine.PCEngineController); var pceControls = new Controller(PCEngine.PCEngineController);
for (int i = 0; i < 1 /*TODO*/; i++) for (int i = 0; i < 5; i++)
{ {
pceControls.BindMulti("Up", Global.Config.PCEController[i].Up); pceControls.BindMulti("P"+(i+1)+" Up", Global.Config.PCEController[i].Up);
pceControls.BindMulti("Down", Global.Config.PCEController[i].Down); pceControls.BindMulti("P"+(i+1)+" Down", Global.Config.PCEController[i].Down);
pceControls.BindMulti("Left", Global.Config.PCEController[i].Left); pceControls.BindMulti("P"+(i+1)+" Left", Global.Config.PCEController[i].Left);
pceControls.BindMulti("Right", Global.Config.PCEController[i].Right); pceControls.BindMulti("P"+(i+1)+" Right", Global.Config.PCEController[i].Right);
pceControls.BindMulti("II", Global.Config.PCEController[i].II); pceControls.BindMulti("P"+(i+1)+" B2", Global.Config.PCEController[i].II);
pceControls.BindMulti("I", Global.Config.PCEController[i].I); pceControls.BindMulti("P"+(i+1)+" B1", Global.Config.PCEController[i].I);
pceControls.BindMulti("Select", Global.Config.PCEController[i].Select); pceControls.BindMulti("P"+(i+1)+" Select", Global.Config.PCEController[i].Select);
pceControls.BindMulti("Run", Global.Config.PCEController[i].Run); pceControls.BindMulti("P"+(i+1)+" Run", Global.Config.PCEController[i].Run);
} }
Global.PCEControls = pceControls; Global.PCEControls = pceControls;