Merge branch 'a26peripherals'
This commit is contained in:
commit
a2a27fb634
|
@ -79,6 +79,8 @@ namespace BizHawk.Client.Common
|
||||||
["R3"] = '>',
|
["R3"] = '>',
|
||||||
|
|
||||||
["Button"] = 'B',
|
["Button"] = 'B',
|
||||||
|
["Button 1"] = '1',
|
||||||
|
["Button 2"] = '2',
|
||||||
["B1"] = '1',
|
["B1"] = '1',
|
||||||
["B2"] = '2',
|
["B2"] = '2',
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
|
|
||||||
using BizHawk.Emulation.Common;
|
using BizHawk.Emulation.Common;
|
||||||
|
using BizHawk.Emulation.Cores.Atari.Atari2600;
|
||||||
|
|
||||||
namespace BizHawk.Client.EmuHawk
|
namespace BizHawk.Client.EmuHawk
|
||||||
{
|
{
|
||||||
|
@ -10,11 +11,37 @@ namespace BizHawk.Client.EmuHawk
|
||||||
{
|
{
|
||||||
public IEnumerable<PadSchema> GetPadSchemas(IEmulator core)
|
public IEnumerable<PadSchema> GetPadSchemas(IEmulator core)
|
||||||
{
|
{
|
||||||
yield return StandardController(1);
|
var ss = ((Atari2600)core).GetSyncSettings().Clone();
|
||||||
yield return StandardController(2);
|
|
||||||
|
var port1 = PadSchemaFromSetting(ss.Port1, 1);
|
||||||
|
if (port1 != null)
|
||||||
|
{
|
||||||
|
yield return port1;
|
||||||
|
}
|
||||||
|
|
||||||
|
var port2 = PadSchemaFromSetting(ss.Port2, 2);
|
||||||
|
if (port2 != null)
|
||||||
|
{
|
||||||
|
yield return port2;
|
||||||
|
}
|
||||||
|
|
||||||
yield return ConsoleButtons();
|
yield return ConsoleButtons();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static PadSchema PadSchemaFromSetting(Atari2600ControllerTypes type, int controller)
|
||||||
|
{
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
default:
|
||||||
|
case Atari2600ControllerTypes.Unplugged:
|
||||||
|
return null;
|
||||||
|
case Atari2600ControllerTypes.Joystick:
|
||||||
|
return StandardController(controller);
|
||||||
|
case Atari2600ControllerTypes.Paddle:
|
||||||
|
return PaddleController(controller);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static PadSchema StandardController(int controller)
|
private static PadSchema StandardController(int controller)
|
||||||
{
|
{
|
||||||
return new PadSchema
|
return new PadSchema
|
||||||
|
@ -68,13 +95,61 @@ namespace BizHawk.Client.EmuHawk
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static PadSchema PaddleController(int controller)
|
||||||
|
{
|
||||||
|
return new PadSchema
|
||||||
|
{
|
||||||
|
DisplayName = "Player " + controller,
|
||||||
|
IsConsole = false,
|
||||||
|
DefaultSize = new Size(334, 94),
|
||||||
|
MaxSize = new Size(334, 94),
|
||||||
|
Buttons = new[]
|
||||||
|
{
|
||||||
|
new PadSchema.ButtonSchema
|
||||||
|
{
|
||||||
|
Name = "P" + controller + " Button 1",
|
||||||
|
DisplayName = "B1",
|
||||||
|
Location = new Point(5, 24),
|
||||||
|
Type = PadSchema.PadInputType.Boolean
|
||||||
|
},
|
||||||
|
new PadSchema.ButtonSchema
|
||||||
|
{
|
||||||
|
Name = "P" + controller + " Button 2",
|
||||||
|
DisplayName = "B2",
|
||||||
|
Location = new Point(5, 48),
|
||||||
|
Type = PadSchema.PadInputType.Boolean
|
||||||
|
},
|
||||||
|
new PadSchema.ButtonSchema
|
||||||
|
{
|
||||||
|
Name = "P" + controller + " Paddle X 1",
|
||||||
|
DisplayName = "Paddle X 1",
|
||||||
|
Location = new Point(55, 17),
|
||||||
|
Type = PadSchema.PadInputType.FloatSingle,
|
||||||
|
TargetSize = new Size(128, 69),
|
||||||
|
MaxValue = 127,
|
||||||
|
MinValue = -127
|
||||||
|
},
|
||||||
|
new PadSchema.ButtonSchema
|
||||||
|
{
|
||||||
|
Name = "P" + controller + " Paddle X 2",
|
||||||
|
DisplayName = "Paddle X 2",
|
||||||
|
Location = new Point(193, 17),
|
||||||
|
Type = PadSchema.PadInputType.FloatSingle,
|
||||||
|
TargetSize = new Size(128, 69),
|
||||||
|
MaxValue = 127,
|
||||||
|
MinValue = -127
|
||||||
|
},
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
private static PadSchema ConsoleButtons()
|
private static PadSchema ConsoleButtons()
|
||||||
{
|
{
|
||||||
return new PadSchema
|
return new PadSchema
|
||||||
{
|
{
|
||||||
DisplayName = "Console",
|
DisplayName = "Console",
|
||||||
IsConsole = true,
|
IsConsole = true,
|
||||||
DefaultSize = new Size(160, 50),
|
DefaultSize = new Size(185, 75),
|
||||||
Buttons = new[]
|
Buttons = new[]
|
||||||
{
|
{
|
||||||
new PadSchema.ButtonSchema
|
new PadSchema.ButtonSchema
|
||||||
|
@ -97,7 +172,21 @@ namespace BizHawk.Client.EmuHawk
|
||||||
DisplayName = "Power",
|
DisplayName = "Power",
|
||||||
Location = new Point(108, 15),
|
Location = new Point(108, 15),
|
||||||
Type = PadSchema.PadInputType.Boolean
|
Type = PadSchema.PadInputType.Boolean
|
||||||
}
|
},
|
||||||
|
new PadSchema.ButtonSchema
|
||||||
|
{
|
||||||
|
Name = "Toggle Left Difficulty",
|
||||||
|
DisplayName = "Left Difficulty",
|
||||||
|
Location = new Point(10, 40),
|
||||||
|
Type = PadSchema.PadInputType.Boolean
|
||||||
|
},
|
||||||
|
new PadSchema.ButtonSchema
|
||||||
|
{
|
||||||
|
Name = "Toggle Right Difficulty",
|
||||||
|
DisplayName = "Right Difficulty",
|
||||||
|
Location = new Point(92, 40),
|
||||||
|
Type = PadSchema.PadInputType.Boolean
|
||||||
|
},
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -284,6 +284,8 @@
|
||||||
<Compile Include="Consoles\Atari\2600\Atari2600.RomHeuristics.cs">
|
<Compile Include="Consoles\Atari\2600\Atari2600.RomHeuristics.cs">
|
||||||
<DependentUpon>Atari2600.cs</DependentUpon>
|
<DependentUpon>Atari2600.cs</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="Consoles\Atari\2600\Atari2600ControllerDeck.cs" />
|
||||||
|
<Compile Include="Consoles\Atari\2600\Atari2600Controllers.cs" />
|
||||||
<Compile Include="Consoles\Atari\2600\Mappers\m0840.cs" />
|
<Compile Include="Consoles\Atari\2600\Mappers\m0840.cs" />
|
||||||
<Compile Include="Consoles\Atari\2600\Mappers\m3E.cs" />
|
<Compile Include="Consoles\Atari\2600\Mappers\m3E.cs" />
|
||||||
<Compile Include="Consoles\Atari\2600\Mappers\m3F.cs" />
|
<Compile Include="Consoles\Atari\2600\Mappers\m3F.cs" />
|
||||||
|
|
|
@ -10,17 +10,6 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
|
||||||
{
|
{
|
||||||
public partial class Atari2600
|
public partial class Atari2600
|
||||||
{
|
{
|
||||||
private static readonly ControllerDefinition Atari2600ControllerDefinition = new ControllerDefinition
|
|
||||||
{
|
|
||||||
Name = "Atari 2600 Basic Controller",
|
|
||||||
BoolButtons =
|
|
||||||
{
|
|
||||||
"P1 Up", "P1 Down", "P1 Left", "P1 Right", "P1 Button",
|
|
||||||
"P2 Up", "P2 Down", "P2 Left", "P2 Right", "P2 Button",
|
|
||||||
"Reset", "Select", "Power", "Toggle Left Difficulty", "Toggle Right Difficulty"
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
private readonly GameInfo _game;
|
private readonly GameInfo _game;
|
||||||
|
|
||||||
private TIA _tia;
|
private TIA _tia;
|
||||||
|
@ -455,13 +444,8 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
|
||||||
internal byte ReadControls1(bool peek)
|
internal byte ReadControls1(bool peek)
|
||||||
{
|
{
|
||||||
InputCallbacks.Call();
|
InputCallbacks.Call();
|
||||||
byte value = 0xFF;
|
|
||||||
|
|
||||||
if (_controller.IsPressed("P1 Up")) { value &= 0xEF; }
|
byte value = _controllerDeck.ReadPort1(_controller);
|
||||||
if (_controller.IsPressed("P1 Down")) { value &= 0xDF; }
|
|
||||||
if (_controller.IsPressed("P1 Left")) { value &= 0xBF; }
|
|
||||||
if (_controller.IsPressed("P1 Right")) { value &= 0x7F; }
|
|
||||||
if (_controller.IsPressed("P1 Button")) { value &= 0xF7; }
|
|
||||||
|
|
||||||
if (!peek)
|
if (!peek)
|
||||||
{
|
{
|
||||||
|
@ -474,13 +458,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
|
||||||
internal byte ReadControls2(bool peek)
|
internal byte ReadControls2(bool peek)
|
||||||
{
|
{
|
||||||
InputCallbacks.Call();
|
InputCallbacks.Call();
|
||||||
byte value = 0xFF;
|
byte value = _controllerDeck.ReadPort2(_controller);
|
||||||
|
|
||||||
if (_controller.IsPressed("P2 Up")) { value &= 0xEF; }
|
|
||||||
if (_controller.IsPressed("P2 Down")) { value &= 0xDF; }
|
|
||||||
if (_controller.IsPressed("P2 Left")) { value &= 0xBF; }
|
|
||||||
if (_controller.IsPressed("P2 Right")) { value &= 0x7F; }
|
|
||||||
if (_controller.IsPressed("P2 Button")) { value &= 0xF7; }
|
|
||||||
|
|
||||||
if (!peek)
|
if (!peek)
|
||||||
{
|
{
|
||||||
|
@ -490,6 +468,20 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal int ReadPot1(int pot)
|
||||||
|
{
|
||||||
|
int value = _controllerDeck.ReadPot1(_controller, pot);
|
||||||
|
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal int ReadPot2(int pot)
|
||||||
|
{
|
||||||
|
int value = _controllerDeck.ReadPot2(_controller, pot);
|
||||||
|
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
internal byte ReadConsoleSwitches(bool peek)
|
internal byte ReadConsoleSwitches(bool peek)
|
||||||
{
|
{
|
||||||
byte value = 0xFF;
|
byte value = 0xFF;
|
||||||
|
|
|
@ -6,7 +6,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
|
||||||
{
|
{
|
||||||
public IEmulatorServiceProvider ServiceProvider { get; }
|
public IEmulatorServiceProvider ServiceProvider { get; }
|
||||||
|
|
||||||
public ControllerDefinition ControllerDefinition => Atari2600ControllerDefinition;
|
public ControllerDefinition ControllerDefinition => _controllerDeck.Definition;
|
||||||
|
|
||||||
public void FrameAdvance(IController controller, bool render, bool rendersound)
|
public void FrameAdvance(IController controller, bool render, bool rendersound)
|
||||||
{
|
{
|
||||||
|
|
|
@ -149,6 +149,18 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
|
||||||
|
|
||||||
public class A2600SyncSettings
|
public class A2600SyncSettings
|
||||||
{
|
{
|
||||||
|
[DefaultValue(Atari2600ControllerTypes.Joystick)]
|
||||||
|
[DisplayName("Port 1 Device")]
|
||||||
|
[Description("The type of controller plugged into the first controller port")]
|
||||||
|
[TypeConverter(typeof(DescribableEnumConverter))]
|
||||||
|
public Atari2600ControllerTypes Port1 { get; set; } = Atari2600ControllerTypes.Joystick;
|
||||||
|
|
||||||
|
[DefaultValue(Atari2600ControllerTypes.Joystick)]
|
||||||
|
[DisplayName("Port 2 Device")]
|
||||||
|
[Description("The type of controller plugged into the second controller port")]
|
||||||
|
[TypeConverter(typeof(DescribableEnumConverter))]
|
||||||
|
public Atari2600ControllerTypes Port2 { get; set; } = Atari2600ControllerTypes.Joystick;
|
||||||
|
|
||||||
[DisplayName("Black and White Mode")]
|
[DisplayName("Black and White Mode")]
|
||||||
[Description("Set the TV Type switch on the console to B&W or Color. This only affects the displayed image if the game supports it.")]
|
[Description("Set the TV Type switch on the console to B&W or Color. This only affects the displayed image if the game supports it.")]
|
||||||
[DefaultValue(false)]
|
[DefaultValue(false)]
|
||||||
|
|
|
@ -27,6 +27,8 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
|
||||||
Settings = (A2600Settings)settings ?? new A2600Settings();
|
Settings = (A2600Settings)settings ?? new A2600Settings();
|
||||||
SyncSettings = (A2600SyncSettings)syncSettings ?? new A2600SyncSettings();
|
SyncSettings = (A2600SyncSettings)syncSettings ?? new A2600SyncSettings();
|
||||||
|
|
||||||
|
_controllerDeck = new Atari2600ControllerDeck(SyncSettings.Port1, SyncSettings.Port2);
|
||||||
|
|
||||||
_leftDifficultySwitchPressed = SyncSettings.LeftDifficulty;
|
_leftDifficultySwitchPressed = SyncSettings.LeftDifficulty;
|
||||||
_rightDifficultySwitchPressed = SyncSettings.RightDifficulty;
|
_rightDifficultySwitchPressed = SyncSettings.RightDifficulty;
|
||||||
|
|
||||||
|
@ -58,6 +60,8 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
|
||||||
ser.Register<ISoundProvider>(_dcfilter);
|
ser.Register<ISoundProvider>(_dcfilter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private readonly Atari2600ControllerDeck _controllerDeck;
|
||||||
|
|
||||||
// IRegionable
|
// IRegionable
|
||||||
public DisplayType Region => _pal ? DisplayType.PAL : DisplayType.NTSC;
|
public DisplayType Region => _pal ? DisplayType.PAL : DisplayType.NTSC;
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,101 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
|
using BizHawk.Common;
|
||||||
|
using BizHawk.Common.ReflectionExtensions;
|
||||||
|
using BizHawk.Emulation.Common;
|
||||||
|
|
||||||
|
namespace BizHawk.Emulation.Cores.Atari.Atari2600
|
||||||
|
{
|
||||||
|
public class Atari2600ControllerDeck
|
||||||
|
{
|
||||||
|
private static readonly Type[] Implementors =
|
||||||
|
{
|
||||||
|
typeof(UnpluggedController), // Order must match Atari2600ControllerTypes enum values
|
||||||
|
typeof(StandardController),
|
||||||
|
typeof(PaddleController)
|
||||||
|
};
|
||||||
|
|
||||||
|
public Atari2600ControllerDeck(Atari2600ControllerTypes controller1, Atari2600ControllerTypes controller2)
|
||||||
|
{
|
||||||
|
Port1 = (IPort)Activator.CreateInstance(Implementors[(int)controller1], 1);
|
||||||
|
Port2 = (IPort)Activator.CreateInstance(Implementors[(int)controller2], 2);
|
||||||
|
|
||||||
|
Definition = new ControllerDefinition
|
||||||
|
{
|
||||||
|
Name = "Atari 2600 Controller",
|
||||||
|
BoolButtons = Port1.Definition.BoolButtons
|
||||||
|
.Concat(Port2.Definition.BoolButtons)
|
||||||
|
.Concat(new[]
|
||||||
|
{
|
||||||
|
"Reset", "Select", "Power", "Toggle Left Difficulty", "Toggle Right Difficulty"
|
||||||
|
})
|
||||||
|
.ToList()
|
||||||
|
};
|
||||||
|
|
||||||
|
Definition.FloatControls.AddRange(Port1.Definition.FloatControls);
|
||||||
|
Definition.FloatControls.AddRange(Port2.Definition.FloatControls);
|
||||||
|
|
||||||
|
Definition.FloatRanges.AddRange(Port1.Definition.FloatRanges);
|
||||||
|
Definition.FloatRanges.AddRange(Port2.Definition.FloatRanges);
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte ReadPort1(IController c)
|
||||||
|
{
|
||||||
|
return Port1.Read(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte ReadPort2(IController c)
|
||||||
|
{
|
||||||
|
return Port2.Read(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int ReadPot1(IController c, int pot)
|
||||||
|
{
|
||||||
|
return Port1.Read_Pot(c, pot);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int ReadPot2(IController c, int pot)
|
||||||
|
{
|
||||||
|
return Port2.Read_Pot(c, pot);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ControllerDefinition Definition { get; }
|
||||||
|
|
||||||
|
public void SyncState(Serializer ser)
|
||||||
|
{
|
||||||
|
ser.BeginSection("Port1");
|
||||||
|
Port1.SyncState(ser);
|
||||||
|
ser.EndSection();
|
||||||
|
|
||||||
|
ser.BeginSection("Port2");
|
||||||
|
Port2.SyncState(ser);
|
||||||
|
ser.EndSection();
|
||||||
|
}
|
||||||
|
|
||||||
|
private readonly IPort Port1;
|
||||||
|
private readonly IPort Port2;
|
||||||
|
|
||||||
|
private static Dictionary<string, Type> _controllerTypes;
|
||||||
|
|
||||||
|
public static Dictionary<string, Type> ValidControllerTypes
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (_controllerTypes == null)
|
||||||
|
{
|
||||||
|
_controllerTypes = typeof(Atari2600ControllerDeck).Assembly
|
||||||
|
.GetTypes()
|
||||||
|
.Where(t => typeof(IPort).IsAssignableFrom(t))
|
||||||
|
.Where(t => !t.IsAbstract && !t.IsInterface)
|
||||||
|
.ToDictionary(tkey => tkey.DisplayName());
|
||||||
|
}
|
||||||
|
|
||||||
|
return _controllerTypes;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string DefaultControllerName => typeof(StandardController).DisplayName();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,163 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
|
using BizHawk.Common;
|
||||||
|
using BizHawk.Emulation.Common;
|
||||||
|
|
||||||
|
namespace BizHawk.Emulation.Cores.Atari.Atari2600
|
||||||
|
{
|
||||||
|
public enum Atari2600ControllerTypes
|
||||||
|
{
|
||||||
|
Unplugged,
|
||||||
|
Joystick,
|
||||||
|
Paddle
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Represents a controller plugged into a controller port on the Colecovision
|
||||||
|
/// </summary>
|
||||||
|
public interface IPort
|
||||||
|
{
|
||||||
|
byte Read(IController c);
|
||||||
|
|
||||||
|
int Read_Pot(IController c, int pot);
|
||||||
|
|
||||||
|
ControllerDefinition Definition { get; }
|
||||||
|
|
||||||
|
void SyncState(Serializer ser);
|
||||||
|
|
||||||
|
int PortNum { get; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class UnpluggedController : IPort
|
||||||
|
{
|
||||||
|
public UnpluggedController(int portNum)
|
||||||
|
{
|
||||||
|
PortNum = portNum;
|
||||||
|
Definition = new ControllerDefinition
|
||||||
|
{
|
||||||
|
BoolButtons = new List<string>()
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte Read(IController c)
|
||||||
|
{
|
||||||
|
return 0xFF;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Read_Pot(IController c, int pot)
|
||||||
|
{
|
||||||
|
return -1; // indicates not applicable
|
||||||
|
}
|
||||||
|
|
||||||
|
public ControllerDefinition Definition { get; }
|
||||||
|
|
||||||
|
public void SyncState(Serializer ser)
|
||||||
|
{
|
||||||
|
// Do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
public int PortNum { get; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class StandardController : IPort
|
||||||
|
{
|
||||||
|
public StandardController(int portNum)
|
||||||
|
{
|
||||||
|
PortNum = portNum;
|
||||||
|
Definition = new ControllerDefinition
|
||||||
|
{
|
||||||
|
BoolButtons = BaseDefinition
|
||||||
|
.Select(b => $"P{PortNum} " + b)
|
||||||
|
.ToList()
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public ControllerDefinition Definition { get; }
|
||||||
|
|
||||||
|
public void SyncState(Serializer ser)
|
||||||
|
{
|
||||||
|
// Nothing todo, I think
|
||||||
|
}
|
||||||
|
|
||||||
|
public int PortNum { get; }
|
||||||
|
|
||||||
|
public byte Read(IController c)
|
||||||
|
{
|
||||||
|
byte result = 0xFF;
|
||||||
|
|
||||||
|
if (c.IsPressed($"P{PortNum} Up")) { result &= 0xEF; }
|
||||||
|
if (c.IsPressed($"P{PortNum} Down")) { result &= 0xDF; }
|
||||||
|
if (c.IsPressed($"P{PortNum} Left")) { result &= 0xBF; }
|
||||||
|
if (c.IsPressed($"P{PortNum} Right")) { result &= 0x7F; }
|
||||||
|
if (c.IsPressed($"P{PortNum} Button")) { result &= 0xF7; }
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Read_Pot(IController c, int pot)
|
||||||
|
{
|
||||||
|
return -1; // indicates not applicable
|
||||||
|
}
|
||||||
|
|
||||||
|
private static readonly string[] BaseDefinition =
|
||||||
|
{
|
||||||
|
"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 1" , "P" + PortNum + " Paddle X 2" },
|
||||||
|
FloatRanges = { new[] { -127.0f, 0, 127.0f }, new[] { -127.0f, 0, 127.0f } }
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public int PortNum { get; }
|
||||||
|
|
||||||
|
public void SyncState(Serializer ser)
|
||||||
|
{
|
||||||
|
// Nothing todo, I think
|
||||||
|
}
|
||||||
|
|
||||||
|
public ControllerDefinition Definition { get; }
|
||||||
|
|
||||||
|
private static readonly string[] BaseDefinition =
|
||||||
|
{
|
||||||
|
"Button 1",
|
||||||
|
"Button 2"
|
||||||
|
};
|
||||||
|
|
||||||
|
public byte Read(IController c)
|
||||||
|
{
|
||||||
|
byte result = 0xF0;
|
||||||
|
|
||||||
|
if (c.IsPressed($"P{PortNum} Button 1")) { result &= 0x70; }
|
||||||
|
if (c.IsPressed($"P{PortNum} Button 2")) { result &= 0xB0; }
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Read_Pot(IController c, int pot)
|
||||||
|
{
|
||||||
|
int x = (int)c.GetFloat(Definition.FloatControls[pot]);
|
||||||
|
|
||||||
|
x = -x;
|
||||||
|
x += 127;
|
||||||
|
|
||||||
|
x = x * 64 + 10;
|
||||||
|
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -871,7 +871,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
|
||||||
// 6105 roughly centers the paddle in Breakout
|
// 6105 roughly centers the paddle in Breakout
|
||||||
if (maskedAddr == 0x08) // INPT0
|
if (maskedAddr == 0x08) // INPT0
|
||||||
{
|
{
|
||||||
if (_capCharging && _core.Cpu.TotalExecutedCycles - _capChargeStart >= 6105)
|
if (_core.ReadPot1(0)>0 && _capCharging && _core.Cpu.TotalExecutedCycles - _capChargeStart >= _core.ReadPot1(0))
|
||||||
{
|
{
|
||||||
coll = 0x80;
|
coll = 0x80;
|
||||||
}
|
}
|
||||||
|
@ -885,7 +885,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
|
||||||
|
|
||||||
if (maskedAddr == 0x09) // INPT1
|
if (maskedAddr == 0x09) // INPT1
|
||||||
{
|
{
|
||||||
if (_capCharging && _core.Cpu.TotalExecutedCycles - _capChargeStart >= 6105)
|
if (_core.ReadPot1(1) > 0 && _capCharging && _core.Cpu.TotalExecutedCycles - _capChargeStart >= _core.ReadPot1(1))
|
||||||
{
|
{
|
||||||
coll = 0x80;
|
coll = 0x80;
|
||||||
}
|
}
|
||||||
|
@ -899,7 +899,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
|
||||||
|
|
||||||
if (maskedAddr == 0x0A) // INPT2
|
if (maskedAddr == 0x0A) // INPT2
|
||||||
{
|
{
|
||||||
if (_capCharging && _core.Cpu.TotalExecutedCycles - _capChargeStart >= 6105)
|
if (_core.ReadPot2(0) > 0 && _capCharging && _core.Cpu.TotalExecutedCycles - _capChargeStart >= _core.ReadPot2(0))
|
||||||
{
|
{
|
||||||
coll = 0x80;
|
coll = 0x80;
|
||||||
}
|
}
|
||||||
|
@ -913,7 +913,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
|
||||||
|
|
||||||
if (maskedAddr == 0x0B) // INPT3
|
if (maskedAddr == 0x0B) // INPT3
|
||||||
{
|
{
|
||||||
if (_capCharging && _core.Cpu.TotalExecutedCycles - _capChargeStart >= 6105)
|
if (_core.ReadPot2(1) > 0 && _capCharging && _core.Cpu.TotalExecutedCycles - _capChargeStart >= _core.ReadPot2(1))
|
||||||
{
|
{
|
||||||
coll = 0x80;
|
coll = 0x80;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue