diff options
Diffstat (limited to 'Plugin.cs')
| -rwxr-xr-x | Plugin.cs | 90 |
1 files changed, 26 insertions, 64 deletions
@@ -1923,23 +1923,24 @@ namespace NewCamera #endif
Button b1 = 0u, b2 = 0u;
- uint PadDown = 0u, PadTrg = 0u, PadRel = 0u, PadChg = 0u;
+ uint b1u = 0u;
if (enableCombo && freeCameraCombo != null)
{
b1 = freeCameraCombo[0];
b2 = freeCameraCombo[1];
+ b1u = (uint)b1;
if (disableComboButton1 && comboButton1Down)
{
- uint b1u = (uint)b1;
- PadDown = MemoryUtil.Read<uint>(sMhController.Instance + 0x198);
- PadDown |= b1u;
- MemoryUtil.WriteBytes(sMhController.Instance + 0x198, BitConverter.GetBytes(PadDown));
+ MemoryUtil.GetRef<uint>(sMhController.Instance + 0x198) |= b1u;
}
}
writePadInputHook!.Original(unknownPtr, unknownPtr2, unknownPtr3);
- bool readInputsPostHook = false;
+ uint PadDown = MemoryUtil.Read<uint>(sMhController.Instance + 0x198);
+ uint PadRel = MemoryUtil.Read<uint>(sMhController.Instance + 0x1A4);
+ prevPadDown = (prevPadDown == null) ? PadDown : lastPadDown;
+ lastPadDown = PadDown;
PadLx = MemoryUtil.Read<int>(sMhController.Instance + 0x1B8);
PadLy = MemoryUtil.Read<int>(sMhController.Instance + 0x1BC);
@@ -1950,51 +1951,28 @@ namespace NewCamera {
if (disableComboButton1)
{
- if (!readInputsPostHook)
- {
- PadDown = MemoryUtil.Read<uint>(sMhController.Instance + 0x198);
- //PadOld = MemoryUtil.Read<uint>(sMhController.Instance + 0x19C);
- PadTrg = MemoryUtil.Read<uint>(sMhController.Instance + 0x1A0);
- PadRel = MemoryUtil.Read<uint>(sMhController.Instance + 0x1A4);
- PadChg = MemoryUtil.Read<uint>(sMhController.Instance + 0x1A8);
- prevPadDown = (prevPadDown == null) ? PadDown : lastPadDown;
- lastPadDown = PadDown;
- readInputsPostHook = true;
- }
-
- uint b1u = (uint)b1;
if (comboButton1Down || enableFreeCamera || !buttonWasDown(b2))
{
if ((PadDown & b1u) == b1u)
{
comboButton1Down = true;
}
- PadDown &= ~b1u;
- MemoryUtil.WriteBytes(sMhController.Instance + 0x198, BitConverter.GetBytes(PadDown));
+ MemoryUtil.GetRef<uint>(sMhController.Instance + 0x198) &= ~b1u;
}
+
if (comboButton1Down)
{
if (((PadRel & b1u) == b1u))
{
comboButton1Down = false;
}
- PadTrg &= ~b1u;
- PadRel &= ~b1u;
- PadChg &= ~b1u;
- MemoryUtil.WriteBytes(sMhController.Instance + 0x1A0, BitConverter.GetBytes(PadTrg));
- MemoryUtil.WriteBytes(sMhController.Instance + 0x1A4, BitConverter.GetBytes(PadRel));
- MemoryUtil.WriteBytes(sMhController.Instance + 0x1A8, BitConverter.GetBytes(PadChg));
+ MemoryUtil.GetRef<uint>(sMhController.Instance + 0x1A0) &= ~b1u;
+ MemoryUtil.GetRef<uint>(sMhController.Instance + 0x1A4) &= ~b1u;
+ MemoryUtil.GetRef<uint>(sMhController.Instance + 0x1A8) &= ~b1u;
}
}
}
- if (!readInputsPostHook)
- {
- PadDown = MemoryUtil.Read<uint>(sMhController.Instance + 0x198);
- prevPadDown = (prevPadDown == null) ? PadDown : lastPadDown;
- lastPadDown = PadDown;
- }
-
if ((comboButton1Down || (!disableComboButton1 && buttonWasDown(b1))))
{
if (buttonWasPressed(b2))
@@ -2058,15 +2036,6 @@ namespace NewCamera if (blockInput)
{
- if (!readInputsPostHook)
- {
- //PadOld = MemoryUtil.Read<uint>(sMhController.Instance + 0x19C);
- PadTrg = MemoryUtil.Read<uint>(sMhController.Instance + 0x1A0);
- PadRel = MemoryUtil.Read<uint>(sMhController.Instance + 0x1A4);
- PadChg = MemoryUtil.Read<uint>(sMhController.Instance + 0x1A8);
- readInputsPostHook = true;
- }
-
uint Mask = 0u;
uint StartSelectMask = (uint)Button.Options | (uint)Button.Share;
uint DPadMask = (uint)Button.Up | (uint)Button.Down | (uint)Button.Left | (uint)Button.Right;
@@ -2097,31 +2066,24 @@ namespace NewCamera }
if (enableCombo && freeCameraCombo != null)
{
- Mask &= ~((uint)b1 | (uint)b2);
+ Mask &= ~(b1u | (uint)b2);
}
-
- PadDown &= ~Mask;
- //PadOld &= ~Mask;
- PadTrg &= ~Mask;
- PadRel &= ~Mask;
- PadChg &= ~Mask;
- MemoryUtil.WriteBytes(sMhController.Instance + 0x198, BitConverter.GetBytes(PadDown));
- //MemoryUtil.WriteBytes(sMhController.Instance + 0x19C, BitConverter.GetBytes(PadOld));
- MemoryUtil.WriteBytes(sMhController.Instance + 0x1A0, BitConverter.GetBytes(PadTrg));
- MemoryUtil.WriteBytes(sMhController.Instance + 0x1A4, BitConverter.GetBytes(PadRel));
- MemoryUtil.WriteBytes(sMhController.Instance + 0x1A8, BitConverter.GetBytes(PadChg));
- MemoryUtil.WriteBytes(sMhController.Instance + 0x1C0, BitConverter.GetBytes(0)); // Left and right trigger.
- MemoryUtil.WriteBytes(sMhController.Instance + 0x1C1, BitConverter.GetBytes(0));
- MemoryUtil.WriteBytes(sMhController.Instance + 0x1B0, BitConverter.GetBytes(0)); // Rx/y.
- MemoryUtil.WriteBytes(sMhController.Instance + 0x1B4, BitConverter.GetBytes(0));
+ MemoryUtil.GetRef<uint>(sMhController.Instance + 0x198) &= ~Mask;
+ MemoryUtil.GetRef<uint>(sMhController.Instance + 0x1A0) &= ~Mask;
+ MemoryUtil.GetRef<uint>(sMhController.Instance + 0x1A8) &= ~Mask;
+ MemoryUtil.GetRef<uint>(sMhController.Instance + 0x1AC) &= ~Mask;
+ MemoryUtil.GetRef<int>(sMhController.Instance + 0x1C0) = 0; // Left trigger.
+ MemoryUtil.GetRef<int>(sMhController.Instance + 0x1C1) = 0; // Right trigger.
+ MemoryUtil.GetRef<int>(sMhController.Instance + 0x1B0) = 0; // Rx.
+ MemoryUtil.GetRef<int>(sMhController.Instance + 0x1B4) = 0; // Ry.
}
if (enableFreeCamera)
{
if (playerMovementLocked)
{
- MemoryUtil.WriteBytes(sMhController.Instance + 0x1B8, BitConverter.GetBytes(0)); // Lx/y.
- MemoryUtil.WriteBytes(sMhController.Instance + 0x1BC, BitConverter.GetBytes(0));
+ MemoryUtil.GetRef<int>(sMhController.Instance + 0x1B8) = 0; // Lx.
+ MemoryUtil.GetRef<int>(sMhController.Instance + 0x1BC) = 0; // Ly.
}
if (orbitPlayer)
@@ -2129,12 +2091,12 @@ namespace NewCamera if (plusRight != 0.0f && !playerMovementLocked)
{
int Lx = (int)(Int16.MaxValue * Math.Clamp(plusRight, -1.0f, 1.0f));
- MemoryUtil.WriteBytes(sMhController.Instance + 0x1B8, BitConverter.GetBytes(Lx));
+ MemoryUtil.GetRef<int>(sMhController.Instance + 0x1B8) = Lx;
}
if (plusForward != 0.0f)
{
int Ly = (int)(Int16.MaxValue * Math.Clamp(plusForward, -1.0f, 1.0f));
- MemoryUtil.WriteBytes(sMhController.Instance + 0x1BC, BitConverter.GetBytes(Ly));
+ MemoryUtil.GetRef<int>(sMhController.Instance + 0x1BC) = Ly;
}
}
@@ -4076,7 +4038,7 @@ namespace NewCamera float gameTime = MemoryUtil.Read<float>(timeAddr + 0x38);
if (ImGui.SliderFloat("Time of Day", ref gameTime, 0.0f, 24.0f))
{
- MemoryUtil.WriteBytes(timeAddr + 0x38, BitConverter.GetBytes(gameTime));
+ MemoryUtil.GetRef<float>(timeAddr + 0x38) = gameTime;
}
}
|