coreside, this is a short, so yeah...

This commit is contained in:
nattthebear 2017-04-16 18:08:57 -04:00
parent 7571781f87
commit 0393e9241b
4 changed files with 21 additions and 25 deletions

View File

@ -142,7 +142,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
public delegate void snes_video_refresh_t(int* data, int width, int height); public delegate void snes_video_refresh_t(int* data, int width, int height);
public delegate void snes_input_poll_t(); public delegate void snes_input_poll_t();
public delegate ushort snes_input_state_t(int port, int device, int index, int id); public delegate short snes_input_state_t(int port, int device, int index, int id);
public delegate void snes_input_notify_t(int index); public delegate void snes_input_notify_t(int index);
public delegate void snes_audio_sample_t(ushort left, ushort right); public delegate void snes_audio_sample_t(ushort left, ushort right);
public delegate void snes_scanlineStart_t(int line); public delegate void snes_scanlineStart_t(int line);

View File

@ -32,7 +32,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
int index = comm->index; int index = comm->index;
int id = (int)comm->id; int id = (int)comm->id;
if (input_state != null) if (input_state != null)
comm->value = input_state(port, device, index, id); comm->value = (uint)input_state(port, device, index, id);
break; break;
} }
case eMessage.eMessage_SIG_input_notify: case eMessage.eMessage_SIG_input_notify:

View File

@ -56,7 +56,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
} }
} }
public ushort CoreInputState(IController controller, int port, int device, int index, int id) public short CoreInputState(IController controller, int port, int device, int index, int id)
{ {
return _ports[port].GetState(_mergers[port].UnMerge(controller), index, id); return _ports[port].GetState(_mergers[port].UnMerge(controller), index, id);
} }
@ -76,7 +76,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
/// <param name="index">libsnes specific value, sometimes multitap number</param> /// <param name="index">libsnes specific value, sometimes multitap number</param>
/// <param name="id">libsnes specific value, sometimes button number</param> /// <param name="id">libsnes specific value, sometimes button number</param>
/// <returns></returns> /// <returns></returns>
ushort GetState(IController controller, int index, int id); short GetState(IController controller, int index, int id);
ControllerDefinition Definition { get; } ControllerDefinition Definition { get; }
@ -137,13 +137,13 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
public ControllerDefinition Definition { get; } = _definition; public ControllerDefinition Definition { get; } = _definition;
public ushort GetState(IController controller, int index, int id) public short GetState(IController controller, int index, int id)
{ {
if (id >= 12) if (id >= 12)
{ {
return 0; return 0;
} }
return (ushort)(controller.IsPressed(Buttons[id]) ? 1 : 0); return (short)(controller.IsPressed(Buttons[id]) ? 1 : 0);
} }
} }
@ -203,13 +203,13 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
public ControllerDefinition Definition { get; } = _definition; public ControllerDefinition Definition { get; } = _definition;
public ushort GetState(IController controller, int index, int id) public short GetState(IController controller, int index, int id)
{ {
if (id >= 12) if (id >= 12)
{ {
return 0; return 0;
} }
return (ushort)(controller.IsPressed(index + Buttons[id]) ? 1 : 0); return (short)(controller.IsPressed(index + Buttons[id]) ? 1 : 0);
} }
} }
@ -224,9 +224,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
public ControllerDefinition Definition { get; } = _definition; public ControllerDefinition Definition { get; } = _definition;
public ushort GetState(IController controller, int index, int id) public short GetState(IController controller, int index, int id)
{ {
return (ushort)(controller.IsPressed("0B" + (index << 4 & 16 | id)) ? 1 : 0); return (short)(controller.IsPressed("0B" + (index << 4 & 16 | id)) ? 1 : 0);
} }
} }
@ -238,7 +238,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
public ControllerDefinition Definition { get; } = _definition; public ControllerDefinition Definition { get; } = _definition;
public ushort GetState(IController controller, int index, int id) public short GetState(IController controller, int index, int id)
{ {
return 0; return 0;
} }
@ -255,38 +255,34 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
"0Left", "0Left",
"0Right" "0Right"
}, },
FloatControls = // should be in [0..700000] FloatControls =
{ {
"0X", "0X",
"0Y" "0Y"
}, },
FloatRanges = FloatRanges =
{ {
// what is the center point supposed to be here? new[] { -127f, 0f, 127f },
new[] { -127f, 0.0f, 128f }, new[] { -127f, 0f, 127f }
new[] { -127f, 0.0f, 128f },
new[] { -127f, 0.0f, 128f },
new[] { -127f, 0.0f, 128f }
} }
}; };
public ControllerDefinition Definition => _definition; public ControllerDefinition Definition => _definition;
public ushort GetState(IController controller, int index, int id) public short GetState(IController controller, int index, int id)
{ {
switch (id) switch (id)
{ {
default: default:
return 0; return 0;
case 0: case 0:
return (ushort)controller.GetFloat("0X"); return (short)controller.GetFloat("0X");
case 1: case 1:
return (ushort)controller.GetFloat("0Y"); return (short)controller.GetFloat("0Y");
case 2: case 2:
return (ushort)(controller.IsPressed("0Left") ? 1 : 0); return (short)(controller.IsPressed("0Left") ? 1 : 0);
case 3: case 3:
return (ushort)(controller.IsPressed("0Right") ? 1 : 0); return (short)(controller.IsPressed("0Right") ? 1 : 0);
} }
} }
} }

View File

@ -507,7 +507,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
/// <param name="index">meaningless for most controllers. for multitap, 0-3 for which multitap controller</param> /// <param name="index">meaningless for most controllers. for multitap, 0-3 for which multitap controller</param>
/// <param name="id">button ID enum; in the case of a regular controller, this corresponds to shift register position</param> /// <param name="id">button ID enum; in the case of a regular controller, this corresponds to shift register position</param>
/// <returns>for regular controllers, one bit D0 of button status. for other controls, varying ranges depending on id</returns> /// <returns>for regular controllers, one bit D0 of button status. for other controls, varying ranges depending on id</returns>
ushort snes_input_state(int port, int device, int index, int id) short snes_input_state(int port, int device, int index, int id)
{ {
return _controllerDeck.CoreInputState(Controller, port, device, index, id); return _controllerDeck.CoreInputState(Controller, port, device, index, id);
} }