if it looks like a duck, swims like a duck, and quacks like a duck, then it may or may not be a duck

This commit is contained in:
nattthebear 2017-04-29 07:54:31 -04:00
parent d3a1ec64dd
commit 7f3716a839
1 changed files with 14 additions and 6 deletions

View File

@ -18,6 +18,14 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
#region interfaces and such #region interfaces and such
/// <summary>
/// callback type for PPU to tell if there's light for a lightgun to detect
/// </summary>
/// <param name="x">x coordinate on screen</param>
/// <param name="y">y coordinate on screen</param>
/// <returns>true if there is light</returns>
public delegate bool LightgunDelegate(int x, int y);
/// <summary> /// <summary>
/// stores information about the strobe lines controlled by $4016 /// stores information about the strobe lines controlled by $4016
/// </summary> /// </summary>
@ -137,7 +145,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
ControlDefUnMerger RightU; ControlDefUnMerger RightU;
ControllerDefinition Definition; ControllerDefinition Definition;
public NesDeck(INesPort Left, INesPort Right, Func<int, int, bool> PPUCallback) public NesDeck(INesPort Left, INesPort Right, LightgunDelegate PPUCallback)
{ {
this.Left = Left; this.Left = Left;
this.Right = Right; this.Right = Right;
@ -547,7 +555,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
// Dummy interface to indicate zapper behavior, used as a means of type checking for zapper functionality // Dummy interface to indicate zapper behavior, used as a means of type checking for zapper functionality
public interface IZapper public interface IZapper
{ {
Func<int, int, bool> PPUCallback { get; set; } LightgunDelegate PPUCallback { get; set; }
} }
public class Zapper : INesPort, IFamicomExpansion, IZapper public class Zapper : INesPort, IFamicomExpansion, IZapper
@ -555,7 +563,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
/// <summary> /// <summary>
/// returns true if light was detected at the ppu coordinates specified /// returns true if light was detected at the ppu coordinates specified
/// </summary> /// </summary>
public Func<int, int, bool> PPUCallback { get; set; } public LightgunDelegate PPUCallback { get; set; }
static ControllerDefinition Definition = new ControllerDefinition static ControllerDefinition Definition = new ControllerDefinition
{ {
@ -605,7 +613,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
/// <summary> /// <summary>
/// returns true if light was detected at the ppu coordinates specified /// returns true if light was detected at the ppu coordinates specified
/// </summary /// </summary
public Func<int, int, bool> PPUCallback { get; set; } public LightgunDelegate PPUCallback { get; set; }
bool resetting = false; bool resetting = false;
uint latchedvalue = 0; uint latchedvalue = 0;
@ -684,7 +692,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
ControllerDefinition Definition; ControllerDefinition Definition;
public FamicomDeck(IFamicomExpansion ExpSlot, Func<int, int, bool> PPUCallback) public FamicomDeck(IFamicomExpansion ExpSlot, LightgunDelegate PPUCallback)
{ {
Player3 = ExpSlot; Player3 = ExpSlot;
List<ControlDefUnMerger> cdum; List<ControlDefUnMerger> cdum;
@ -1224,7 +1232,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
return (NESControlSettings)MemberwiseClone(); return (NESControlSettings)MemberwiseClone();
} }
public IControllerDeck Instantiate(Func<int, int, bool> PPUCallback) public IControllerDeck Instantiate(LightgunDelegate PPUCallback)
{ {
if (Famicom) if (Famicom)
{ {