mirror of
https://github.com/zeldaret/mm.git
synced 2026-09-10 11:55:10 -04:00
@@ -0,0 +1,95 @@
|
||||
#include <ultra64.h>
|
||||
#include <global.h>
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -203,8 +203,8 @@ s32 Fault_WaitForInputImpl() {
|
||||
while (1) {
|
||||
Fault_Sleep(0x10);
|
||||
Fault_UpdatePadImpl();
|
||||
kDown = curInput->pressEdge.buttons;
|
||||
if (kDown == 0x20) {
|
||||
kDown = curInput->press.button;
|
||||
if (kDown == BTN_L) {
|
||||
faultCtxt->faultActive = !faultCtxt->faultActive;
|
||||
}
|
||||
|
||||
@@ -217,16 +217,16 @@ s32 Fault_WaitForInputImpl() {
|
||||
}
|
||||
}
|
||||
|
||||
if (kDown == 0x8000 || kDown == 0x100) {
|
||||
if (kDown == BTN_A || kDown == BTN_DRIGHT) {
|
||||
return 0;
|
||||
}
|
||||
if (kDown == 0x200) {
|
||||
if (kDown == BTN_DLEFT) {
|
||||
return 1;
|
||||
}
|
||||
if (kDown == 0x800) {
|
||||
if (kDown == BTN_DUP) {
|
||||
FaultDrawer_SetOsSyncPrintfEnabled(1);
|
||||
}
|
||||
if (kDown == 0x400) {
|
||||
if (kDown == BTN_DDOWN) {
|
||||
FaultDrawer_SetOsSyncPrintfEnabled(0);
|
||||
}
|
||||
}
|
||||
@@ -463,8 +463,8 @@ void Fault_WaitForButtonCombo(void) {
|
||||
do {
|
||||
Fault_Sleep(0x10);
|
||||
Fault_UpdatePadImpl();
|
||||
} while (~(input->pressEdge.buttons | ~0x80) != 0);
|
||||
} while (~(input->current.buttons | ~0x231) != 0);
|
||||
} while (!CHECK_BTN_ALL(input->press.button, 0x80));
|
||||
} while (!CHECK_BTN_ALL(input->cur.button, BTN_DLEFT | BTN_L | BTN_R | BTN_CRIGHT));
|
||||
}
|
||||
|
||||
void Fault_DrawMemDumpPage(char* title, u32* addr, u32 param_3) {
|
||||
@@ -530,46 +530,46 @@ void Fault_DrawMemDump(u32 pc, u32 sp, u32 unk0, u32 unk1) {
|
||||
Fault_Sleep(0x10);
|
||||
Fault_UpdatePadImpl();
|
||||
|
||||
if (~(input->pressEdge.buttons | ~0x20) == 0) {
|
||||
if (CHECK_BTN_ALL(input->press.button, BTN_L)) {
|
||||
faultCtxt->faultActive = 0;
|
||||
}
|
||||
}
|
||||
do {
|
||||
Fault_Sleep(0x10);
|
||||
Fault_UpdatePadImpl();
|
||||
} while (input->pressEdge.buttons == 0);
|
||||
} while (input->press.button == 0);
|
||||
|
||||
if (~(input->pressEdge.buttons | ~0x1000) == 0) {
|
||||
if (CHECK_BTN_ALL(input->press.button, BTN_START)) == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
off = 0x10;
|
||||
if (~(input->current.buttons | ~0x8000) == 0) {
|
||||
if (CHECK_BTN_ALL(input->press.button, BTN_A)) {
|
||||
off = 0x100;
|
||||
}
|
||||
if (~(input->current.buttons | ~0x4000) == 0) {
|
||||
if (CHECK_BTN_ALL(input->press.button, BTN_B)) {
|
||||
off <<= 8;
|
||||
}
|
||||
if (~(input->pressEdge.buttons | ~0x800) == 0) {
|
||||
if (CHECK_BTN_ALL(input->press.button, BTN_DUP)) {
|
||||
addr -= off;
|
||||
}
|
||||
if (~(input->pressEdge.buttons | ~0x400) == 0) {
|
||||
if (CHECK_BTN_ALL(input->press.button, BTN_DDOWN)) {
|
||||
addr += off;
|
||||
}
|
||||
if (~(input->pressEdge.buttons | ~0x8) == 0) {
|
||||
if (CHECK_BTN_ALL(input->press.button, BTN_CUP)) {
|
||||
addr = pc;
|
||||
}
|
||||
if (~(input->pressEdge.buttons | ~0x4) == 0) {
|
||||
if (CHECK_BTN_ALL(input->press.button, BTN_CDOWN)) {
|
||||
addr = sp;
|
||||
}
|
||||
if (~(input->pressEdge.buttons | ~0x2) == 0) {
|
||||
if (CHECK_BTN_ALL(input->press.button, BTN_CLEFT)) {
|
||||
addr = unk0;
|
||||
}
|
||||
if (~(input->pressEdge.buttons | ~0x1) == 0) {
|
||||
if (CHECK_BTN_ALL(input->press.button, BTN_CRIGHT)) {
|
||||
addr = unk1;
|
||||
}
|
||||
|
||||
} while (~(input->pressEdge.buttons | ~0x20) != 0);
|
||||
} while (!CHECK_BTN_ALL(input->press.button, BTN_L));
|
||||
|
||||
faultCtxt->faultActive = 1;
|
||||
}
|
||||
@@ -764,7 +764,7 @@ void Fault_SetOptionsFromController3(void) {
|
||||
|
||||
input3 = &faultCtxt->padInput[3];
|
||||
|
||||
if (~(input3->pressEdge.buttons | ~0x80) == 0) {
|
||||
if (CHECK_BTN_ALL(input3->press.button, 0x80)) {
|
||||
faultCustomOptions = faultCustomOptions == 0;
|
||||
}
|
||||
|
||||
@@ -772,14 +772,14 @@ void Fault_SetOptionsFromController3(void) {
|
||||
graphPC = graphOSThread.context.pc;
|
||||
graphRA = graphOSThread.context.ra;
|
||||
graphSP = graphOSThread.context.sp;
|
||||
if (~(input3->current.buttons | ~0x10) == 0) {
|
||||
if (CHECK_BTN_ALL(input3->press.button, BTN_R)) {
|
||||
faultCopyToLog = !faultCopyToLog;
|
||||
FaultDrawer_SetOsSyncPrintfEnabled(faultCopyToLog);
|
||||
}
|
||||
if (~(input3->current.buttons | ~0x8000) == 0) {
|
||||
if (CHECK_BTN_ALL(input3->press.button, BTN_A)) {
|
||||
Fault_Log(D_80098A44, graphPC, graphRA, graphSP);
|
||||
}
|
||||
if (~(input3->current.buttons | ~0x4000) == 0) {
|
||||
if (CHECK_BTN_ALL(input3->press.button, BTN_B)) {
|
||||
FaultDrawer_SetDrawerFB(osViGetNextFramebuffer(), 0x140, 0xF0);
|
||||
Fault_DrawRec(0, 0xD7, 0x140, 9, 1);
|
||||
FaultDrawer_SetCharPad(-2, 0);
|
||||
|
||||
@@ -256,8 +256,8 @@ void ArmsHook_Shoot(ArmsHook* this, GlobalContext* globalCtx) {
|
||||
func_8019F1C0(&this->actor.projectedPos, 0x1813);
|
||||
}
|
||||
} else {
|
||||
if ((globalCtx->state.input[0].pressEdge.buttons &
|
||||
(A_BUTTON | B_BUTTON | R_TRIG | U_CBUTTONS | L_CBUTTONS | R_CBUTTONS | D_CBUTTONS))) {
|
||||
if (CHECK_BTN_ANY(globalCtx->state.input[0].press.button,
|
||||
BTN_A | BTN_B | BTN_R | BTN_CUP | BTN_CLEFT | BTN_CRIGHT | BTN_CDOWN)) {
|
||||
s32 pad;
|
||||
this->timer = 1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user