From 467a8f37eba1b1dc032ea40ca7fef300d1a222c4 Mon Sep 17 00:00:00 2001 From: adelikat Date: Sun, 11 May 2014 13:05:59 +0000 Subject: [PATCH] N64 Input convert some magic 127's into constants, nothing useful about this commit --- .../Consoles/Nintendo/N64/N64Input.cs | 35 +++++++++++++++---- 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64Input.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64Input.cs index ef24bf5531..40067688ee 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64Input.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64Input.cs @@ -65,6 +65,11 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64 ThisFrameInputPolled = false; } + private const sbyte _maxAnalogX = 127; + private const sbyte _minAnalogX = -127; + private const sbyte _maxAnalogY = 127; + private const sbyte _minAnalogY = -127; + /// /// Translates controller input from EmuHawk into /// N64 controller data @@ -79,14 +84,32 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64 // Analog stick up = +Y string p = "P" + (i + 1); sbyte x; - if (Controller.IsPressed(p + " A Left")) { x = -127; } - else if (Controller.IsPressed(p + " A Right")) { x = 127; } - else { x = (sbyte)Controller.GetFloat(p + " X Axis"); } + if (Controller.IsPressed(p + " A Left")) + { + x = _minAnalogX; + } + else if (Controller.IsPressed(p + " A Right")) + { + x = _maxAnalogX; + } + else + { + x = (sbyte)Controller.GetFloat(p + " X Axis"); + } sbyte y; - if (Controller.IsPressed(p + " A Up")) { y = 127; } - else if (Controller.IsPressed(p + " A Down")) { y = -127; } - else { y = (sbyte)Controller.GetFloat(p + " Y Axis"); } + if (Controller.IsPressed(p + " A Up")) + { + y = _maxAnalogY; + } + else if (Controller.IsPressed(p + " A Down")) + { + y = _minAnalogY; + } + else + { + y = (sbyte)Controller.GetFloat(p + " Y Axis"); + } int value = ReadController(i + 1); value |= (x & 0xFF) << 16;