Atari 2600 - stub out the paddle controller
This commit is contained in:
parent
74dd25e831
commit
c3b890c60c
|
@ -1,90 +1,91 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
using BizHawk.Common;
|
using BizHawk.Common;
|
||||||
using BizHawk.Common.ReflectionExtensions;
|
using BizHawk.Common.ReflectionExtensions;
|
||||||
using BizHawk.Emulation.Common;
|
using BizHawk.Emulation.Common;
|
||||||
|
|
||||||
namespace BizHawk.Emulation.Cores.Atari.Atari2600
|
namespace BizHawk.Emulation.Cores.Atari.Atari2600
|
||||||
{
|
{
|
||||||
public class Atari2600ControllerDeck
|
public class Atari2600ControllerDeck
|
||||||
{
|
{
|
||||||
private static readonly Type[] Implementors =
|
private static readonly Type[] Implementors =
|
||||||
{
|
{
|
||||||
typeof(UnpluggedController), // Order must match Atari2600ControllerTypes enum values
|
typeof(UnpluggedController), // Order must match Atari2600ControllerTypes enum values
|
||||||
typeof(StandardController),
|
typeof(StandardController),
|
||||||
|
typeof(PaddleController)
|
||||||
};
|
};
|
||||||
|
|
||||||
public Atari2600ControllerDeck(Atari2600ControllerTypes controller1, Atari2600ControllerTypes controller2)
|
public Atari2600ControllerDeck(Atari2600ControllerTypes controller1, Atari2600ControllerTypes controller2)
|
||||||
{
|
{
|
||||||
Port1 = (IPort)Activator.CreateInstance(Implementors[(int)controller1], 1);
|
Port1 = (IPort)Activator.CreateInstance(Implementors[(int)controller1], 1);
|
||||||
Port2 = (IPort)Activator.CreateInstance(Implementors[(int)controller2], 2);
|
Port2 = (IPort)Activator.CreateInstance(Implementors[(int)controller2], 2);
|
||||||
|
|
||||||
Definition = new ControllerDefinition
|
Definition = new ControllerDefinition
|
||||||
{
|
{
|
||||||
Name = "Atari 2600 Controller",
|
Name = "Atari 2600 Controller",
|
||||||
BoolButtons = Port1.Definition.BoolButtons
|
BoolButtons = Port1.Definition.BoolButtons
|
||||||
.Concat(Port2.Definition.BoolButtons)
|
.Concat(Port2.Definition.BoolButtons)
|
||||||
.Concat(new[]
|
.Concat(new[]
|
||||||
{
|
{
|
||||||
"Reset", "Select", "Power", "Toggle Left Difficulty", "Toggle Right Difficulty"
|
"Reset", "Select", "Power", "Toggle Left Difficulty", "Toggle Right Difficulty"
|
||||||
})
|
})
|
||||||
.ToList()
|
.ToList()
|
||||||
};
|
};
|
||||||
|
|
||||||
Definition.FloatControls.AddRange(Port1.Definition.FloatControls);
|
Definition.FloatControls.AddRange(Port1.Definition.FloatControls);
|
||||||
Definition.FloatControls.AddRange(Port2.Definition.FloatControls);
|
Definition.FloatControls.AddRange(Port2.Definition.FloatControls);
|
||||||
|
|
||||||
Definition.FloatRanges.AddRange(Port1.Definition.FloatRanges);
|
Definition.FloatRanges.AddRange(Port1.Definition.FloatRanges);
|
||||||
Definition.FloatRanges.AddRange(Port2.Definition.FloatRanges);
|
Definition.FloatRanges.AddRange(Port2.Definition.FloatRanges);
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte ReadPort1(IController c)
|
public byte ReadPort1(IController c)
|
||||||
{
|
{
|
||||||
return Port1.Read(c);
|
return Port1.Read(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte ReadPort2(IController c)
|
public byte ReadPort2(IController c)
|
||||||
{
|
{
|
||||||
return Port2.Read(c);
|
return Port2.Read(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ControllerDefinition Definition { get; }
|
public ControllerDefinition Definition { get; }
|
||||||
|
|
||||||
public void SyncState(Serializer ser)
|
public void SyncState(Serializer ser)
|
||||||
{
|
{
|
||||||
ser.BeginSection("Port1");
|
ser.BeginSection("Port1");
|
||||||
Port1.SyncState(ser);
|
Port1.SyncState(ser);
|
||||||
ser.EndSection();
|
ser.EndSection();
|
||||||
|
|
||||||
ser.BeginSection("Port2");
|
ser.BeginSection("Port2");
|
||||||
Port2.SyncState(ser);
|
Port2.SyncState(ser);
|
||||||
ser.EndSection();
|
ser.EndSection();
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly IPort Port1;
|
private readonly IPort Port1;
|
||||||
private readonly IPort Port2;
|
private readonly IPort Port2;
|
||||||
|
|
||||||
private static Dictionary<string, Type> _controllerTypes;
|
private static Dictionary<string, Type> _controllerTypes;
|
||||||
|
|
||||||
public static Dictionary<string, Type> ValidControllerTypes
|
public static Dictionary<string, Type> ValidControllerTypes
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (_controllerTypes == null)
|
if (_controllerTypes == null)
|
||||||
{
|
{
|
||||||
_controllerTypes = typeof(Atari2600ControllerDeck).Assembly
|
_controllerTypes = typeof(Atari2600ControllerDeck).Assembly
|
||||||
.GetTypes()
|
.GetTypes()
|
||||||
.Where(t => typeof(IPort).IsAssignableFrom(t))
|
.Where(t => typeof(IPort).IsAssignableFrom(t))
|
||||||
.Where(t => !t.IsAbstract && !t.IsInterface)
|
.Where(t => !t.IsAbstract && !t.IsInterface)
|
||||||
.ToDictionary(tkey => tkey.DisplayName());
|
.ToDictionary(tkey => tkey.DisplayName());
|
||||||
}
|
}
|
||||||
|
|
||||||
return _controllerTypes;
|
return _controllerTypes;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string DefaultControllerName => typeof(StandardController).DisplayName();
|
public static string DefaultControllerName => typeof(StandardController).DisplayName();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,8 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
|
||||||
public enum Atari2600ControllerTypes
|
public enum Atari2600ControllerTypes
|
||||||
{
|
{
|
||||||
Unplugged,
|
Unplugged,
|
||||||
Joystick
|
Joystick,
|
||||||
|
Paddle
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -94,4 +95,45 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
|
||||||
"Up", "Down", "Left", "Right", "Button"
|
"Up", "Down", "Left", "Right", "Button"
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class PaddleController : IPort
|
||||||
|
{
|
||||||
|
public PaddleController(int portNum)
|
||||||
|
{
|
||||||
|
PortNum = portNum;
|
||||||
|
Definition = new ControllerDefinition
|
||||||
|
{
|
||||||
|
BoolButtons = BaseDefinition
|
||||||
|
.Select(b => $"P{PortNum} " + b)
|
||||||
|
.ToList(),
|
||||||
|
FloatControls = { "P" + PortNum + " Paddle X" },
|
||||||
|
FloatRanges = { new[] { -127.0f, 0, 127.0f }, } // No idea what values should be here
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public int PortNum { get; }
|
||||||
|
|
||||||
|
public void SyncState(Serializer ser)
|
||||||
|
{
|
||||||
|
// Nothing todo, I think
|
||||||
|
}
|
||||||
|
|
||||||
|
public ControllerDefinition Definition { get; }
|
||||||
|
|
||||||
|
private static readonly string[] BaseDefinition =
|
||||||
|
{
|
||||||
|
"Button"
|
||||||
|
};
|
||||||
|
|
||||||
|
public byte Read(IController c)
|
||||||
|
{
|
||||||
|
byte result = 0xFF;
|
||||||
|
|
||||||
|
if (c.IsPressed($"P{PortNum} Button")) { result &= 0xF7; } // TODO
|
||||||
|
|
||||||
|
//int x = (int)c.GetFloat(Definition.FloatControls[0]);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue