From 32d0e622fd958fb02086131ae58b1283518e7df3 Mon Sep 17 00:00:00 2001 From: Rozelette Date: Mon, 22 Mar 2021 11:03:33 -0500 Subject: padutils OK (#72) * padutils OK * Update to latest OOT --- src/boot_O2/padutils.c | 95 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 src/boot_O2/padutils.c (limited to 'src/boot_O2') diff --git a/src/boot_O2/padutils.c b/src/boot_O2/padutils.c new file mode 100644 index 000000000..ea51b3dc1 --- /dev/null +++ b/src/boot_O2/padutils.c @@ -0,0 +1,95 @@ +#include +#include + +void PadUtils_Init(Input* input) { + bzero(input, sizeof(Input)); +} + +void func_80085150(void) { +} + +void PadUtils_ResetPressRel(Input* input) { + input->press.button = 0; + input->rel.button = 0; +} + +u32 PadUtils_CheckCurExact(Input* input, u16 value) { + return value == input->cur.button; +} + +u32 PadUtils_CheckCur(Input* input, u16 key) { + return key == (input->cur.button & key); +} + +u32 PadUtils_CheckPressed(Input* input, u16 key) { + return key == (input->press.button & key); +} + +u32 PadUtils_CheckReleased(Input* input, u16 key) { + return key == (input->rel.button & key); +} + +u16 PadUtils_GetCurButton(Input* input) { + return input->cur.button; +} + +u16 PadUtils_GetPressButton(Input* input) { + return input->press.button; +} + +s8 PadUtils_GetCurX(Input* input) { + return input->cur.stick_x; +} + +s8 PadUtils_GetCurY(Input* input) { + return input->cur.stick_y; +} + +void PadUtils_SetRelXY(Input* input, s32 x, s32 y) { + input->rel.stick_x = x; + input->rel.stick_y = y; +} + +s8 PadUtils_GetRelXImpl(Input* input) { + return input->rel.stick_x; +} + +s8 PadUtils_GetRelYImpl(Input* input) { + return input->rel.stick_y; +} + +s8 PadUtils_GetRelX(Input* input) { + return PadUtils_GetRelXImpl(input); +} + +s8 PadUtils_GetRelY(Input* input) { + return PadUtils_GetRelYImpl(input); +} + +void PadUtils_UpdateRelXY(Input* input) { + s32 curX, curY; + s32 relX, relY; + + curX = PadUtils_GetCurX(input); + curY = PadUtils_GetCurY(input); + + if (curX > 7) { + relX = (curX < 0x43) ? curX - 7 : 0x43 - 7; + } else if (curX < -7) { + relX = (curX > -0x43) ? curX + 7 : -0x43 + 7; + } else { + relX = 0; + } + + if (curY > 7) { + relY = (curY < 0x43) ? curY - 7 : 0x43 - 7; + + } else if (curY < -7) { + relY = (curY > -0x43) ? curY + 7 : -0x43 + 7; + } else { + relY = 0; + } + + PadUtils_SetRelXY(input, relX, relY); +} + -- cgit v1.2.3