summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorsilv3rwing07 <62714207+silv3rwing07@users.noreply.github.com>2020-04-14 10:17:25 -0700
committerGitHub <noreply@github.com>2020-04-14 13:17:25 -0400
commit5aef81071e501fbbe5298a433ead06a625cdb3d8 (patch)
tree686ccf568a7f05bd7741be96cd22f51d358451d4 /src
parent16646aa34d533b36e3a93985ae59cbefdf58b6d4 (diff)
padmgr and related (#71)
* In process of moving changes over from old repo * Merged in changes * Finished import of padmgr changes from old repo * Adjusted some volatile * Improving padmgr volatile situation * Almost matched osReadMempak * Working on osMempakDataCRC * Explanations and equivalents but no matches for osMempakAddrCRC and osMempakDataCRC * OK after merge * Matched osMempakAddrCRC and osMempakDataCRC * Matched osReadMempak * Updated PadMgr function names to be less like original code * Changed variable names to make them further from original code * Changed names and it stopped matching * Undid clang-format steamrollering whitespace memes * Cleaned up Input names * More formatting changes * Moved padmgr to z64.h, deleted padmgr.h
Diffstat (limited to 'src')
-rw-r--r--src/boot/z_locale.c9
-rw-r--r--src/code/code_800A9F30.c15
-rw-r--r--src/code/code_800D31A0.c5
-rw-r--r--src/code/fault.c30
-rw-r--r--src/code/graph.c4
-rw-r--r--src/code/main.c1
-rw-r--r--src/code/padmgr.c319
-rw-r--r--src/code/z_debug.c29
-rw-r--r--src/code/z_demo.c16
-rw-r--r--src/code/z_parameter.c6
-rw-r--r--src/code/z_sample.c2
-rw-r--r--src/libultra_code/osContStartReadData.c12
-rw-r--r--src/libultra_code/osMempakAddrCRC.c68
-rw-r--r--src/libultra_code/osReadMempak.c57
-rw-r--r--src/libultra_code/osRumblePak.c (renamed from src/libultra_code/osVibrationPack.c)28
-rw-r--r--src/overlays/actors/ovl_En_Ani/z_en_ani.c15
16 files changed, 440 insertions, 176 deletions
diff --git a/src/boot/z_locale.c b/src/boot/z_locale.c
index 4d2956e3e..10f6bb437 100644
--- a/src/boot/z_locale.c
+++ b/src/boot/z_locale.c
@@ -1,7 +1,6 @@
#include <ultra64.h>
#include <global.h>
#include <vt.h>
-#include <padmgr.h>
u32 gCurrentRegion = 0;
LocaleCartInfo sCartInfo;
@@ -39,13 +38,11 @@ void Locale_ResetRegion() {
}
u32 func_80001F48() {
- PadMgr* padMgr = (PadMgr*)(u32)&gPadMgr; // cast required to match
-
if (gCurrentRegion == REGION_NATIVE) {
return 0;
}
- if (padMgr->unk_2A8 & 4) {
+ if (gPadMgr.validCtrlrsMask & 4) {
return 0;
}
@@ -53,13 +50,11 @@ u32 func_80001F48() {
}
u32 func_80001F8C() {
- PadMgr* padMgr = (PadMgr*)(u32)&gPadMgr; // cast required to match
-
if (gCurrentRegion == REGION_NATIVE) {
return 0;
}
- if (padMgr->unk_2A8 & 4) {
+ if (gPadMgr.validCtrlrsMask & 4) {
return 1;
}
diff --git a/src/code/code_800A9F30.c b/src/code/code_800A9F30.c
index ddc8c0223..15475e872 100644
--- a/src/code/code_800A9F30.c
+++ b/src/code/code_800A9F30.c
@@ -1,13 +1,12 @@
#include <ultra64.h>
#include <global.h>
-#include <padmgr.h>
extern u8 D_80160FD0[];
extern PadMgr gPadMgr;
void func_800A9F30(s32 a, s32 b) {
func_800D2E30(&D_80160FD0);
- func_800C7948(a, &D_80160FD0);
+ PadMgr_RumbleSet(a, &D_80160FD0);
}
void func_800A9F6C(f32 a, u8 b, u8 c, u8 d) {
@@ -35,8 +34,8 @@ void func_800A9F6C(f32 a, u8 b, u8 c, u8 d) {
void func_800AA0B4(void) {
func_800D3140(&D_80160FD0);
- gPadMgr.unk_460 = func_800A9F30;
- gPadMgr.unk_464 = 0;
+ gPadMgr.retraceCallback = func_800A9F30;
+ gPadMgr.retraceCallbackValue = 0;
if (0) {} // Necessary to match
}
@@ -44,16 +43,16 @@ void func_800AA0B4(void) {
void func_800AA0F0(void) {
PadMgr* padmgr = &gPadMgr;
- if ((padmgr->unk_460 == func_800A9F30) && (padmgr->unk_464 == 0)) {
- padmgr->unk_460 = NULL;
- padmgr->unk_464 = 0;
+ if (((void*)padmgr->retraceCallback == (void*)func_800A9F30) && (padmgr->retraceCallbackValue == 0)) {
+ padmgr->retraceCallback = NULL;
+ padmgr->retraceCallbackValue = 0;
}
func_800D3178(&D_80160FD0);
}
u32 func_800AA148(void) {
- return ((gPadMgr.unk_2AE[0] ^ 1) == 0);
+ return ((gPadMgr.pakType[0] ^ 1) == 0);
}
void func_800AA15C(void) {
diff --git a/src/code/code_800D31A0.c b/src/code/code_800D31A0.c
index 54201e35f..ec5b7a9b0 100644
--- a/src/code/code_800D31A0.c
+++ b/src/code/code_800D31A0.c
@@ -1,5 +1,4 @@
#include <global.h>
-#include <padmgr.h>
#include <vt.h>
extern PadMgr gPadMgr;
@@ -14,9 +13,7 @@ void func_800D31A0() {
}
void func_800D31F0() {
- PadMgr* padMgr = (PadMgr*)(u32)&gPadMgr; // cast required to match
-
- D_8012DBC0 = (padMgr->unk_2A8 & 2) != 0;
+ D_8012DBC0 = (gPadMgr.validCtrlrsMask & 2) != 0;
}
void func_800D3210() {
diff --git a/src/code/fault.c b/src/code/fault.c
index b3270ea7c..469ef799d 100644
--- a/src/code/fault.c
+++ b/src/code/fault.c
@@ -250,7 +250,7 @@ void Fault_Sleep(u32 duration) {
void Fault_PadCallback(Input* input) {
// BUG: this function is not called correctly and thus will crash from reading a bad pointer at 0x800C7E4C
- func_800C7E08(input, 0);
+ PadMgr_RequestPadData(input, 0);
}
void Fault_UpdatePadImpl() {
@@ -270,7 +270,7 @@ u32 Fault_WaitForInputImpl() {
Fault_Sleep(0x10);
Fault_UpdatePadImpl();
- kDown = curInput->padPressed;
+ kDown = curInput->press.in.button;
if (kDown == 0x20) {
sFaultStructPtr->faultActive = !sFaultStructPtr->faultActive;
@@ -583,7 +583,7 @@ void Fault_DrawMemDump(u32 pc, u32 sp, u32 unk0, u32 unk1) {
count--;
Fault_Sleep(0x10);
Fault_UpdatePadImpl();
- if (!~(curInput->padPressed | ~L_TRIG)) {
+ if (!~(curInput->press.in.button | ~L_TRIG)) {
sFaultStructPtr->faultActive = false;
}
}
@@ -591,42 +591,42 @@ void Fault_DrawMemDump(u32 pc, u32 sp, u32 unk0, u32 unk1) {
do {
Fault_Sleep(0x10);
Fault_UpdatePadImpl();
- } while (curInput->padPressed == 0);
+ } while (curInput->press.in.button == 0);
- if (!~(curInput->padPressed | ~START_BUTTON)) {
+ if (!~(curInput->press.in.button | ~START_BUTTON)) {
return;
}
- if (!~(curInput->raw.pad | ~A_BUTTON)) {
+ if (!~(curInput->cur.in.button | ~A_BUTTON)) {
return;
}
off = 0x10;
- if (!~(curInput->raw.pad | ~Z_TRIG)) {
+ if (!~(curInput->cur.in.button | ~Z_TRIG)) {
off = 0x100;
}
- if (!~(curInput->raw.pad | ~B_BUTTON)) {
+ if (!~(curInput->cur.in.button | ~B_BUTTON)) {
off <<= 8;
}
- if (!~(curInput->raw.pad | ~U_JPAD)) {
+ if (!~(curInput->cur.in.button | ~U_JPAD)) {
addr -= off;
}
- if (!~(curInput->raw.pad | ~D_JPAD)) {
+ if (!~(curInput->cur.in.button | ~D_JPAD)) {
addr += off;
}
- if (!~(curInput->raw.pad | ~U_CBUTTONS)) {
+ if (!~(curInput->cur.in.button | ~U_CBUTTONS)) {
addr = pc;
}
- if (!~(curInput->raw.pad | ~D_CBUTTONS)) {
+ if (!~(curInput->cur.in.button | ~D_CBUTTONS)) {
addr = sp;
}
- if (!~(curInput->raw.pad | ~L_CBUTTONS)) {
+ if (!~(curInput->cur.in.button | ~L_CBUTTONS)) {
addr = unk0;
}
- if (!~(curInput->raw.pad | ~R_CBUTTONS)) {
+ if (!~(curInput->cur.in.button | ~R_CBUTTONS)) {
addr = unk1;
}
- if (!~(curInput->raw.pad | ~L_TRIG)) {
+ if (!~(curInput->cur.in.button | ~L_TRIG)) {
break;
}
}
diff --git a/src/code/graph.c b/src/code/graph.c
index 5e1d2563d..600c2287f 100644
--- a/src/code/graph.c
+++ b/src/code/graph.c
@@ -387,8 +387,8 @@ void Graph_Update(GraphicsContext* gfxCtx, GameState* gameState) {
}
sGraphUpdateTime = time;
- if (D_8012DBC0 && (!~(gameState->input[0].padPressed | ~Z_TRIG)) &&
- (!~(gameState->input[0].raw.pad | ~(L_TRIG | R_TRIG)))) {
+ if (D_8012DBC0 && (!~(gameState->input[0].press.in.button | ~Z_TRIG)) &&
+ (!~(gameState->input[0].cur.in.button | ~(L_TRIG | R_TRIG)))) {
gSaveContext.game_mode = 0;
SET_NEXT_GAMESTATE(gameState, func_80801E44, char[0x240]); // TODO : SelectContext
gameState->running = false;
diff --git a/src/code/main.c b/src/code/main.c
index 5e2b9a89e..8b797bbf9 100644
--- a/src/code/main.c
+++ b/src/code/main.c
@@ -1,6 +1,5 @@
#include <global.h>
#include <vt.h>
-#include <padmgr.h>
#include <sched.h>
u32 gScreenWidth = SCREEN_WIDTH;
diff --git a/src/code/padmgr.c b/src/code/padmgr.c
index ac345c86b..db3cd151f 100644
--- a/src/code/padmgr.c
+++ b/src/code/padmgr.c
@@ -4,11 +4,10 @@
#include <PR/os_cont.h>
#include <ultra64/controller.h>
-#include <padmgr.h>
s32 D_8012D280 = 1;
-OSMesgQueue* PadMgr_LockGetControllerQueue(PadMgr* padmgr) {
+OSMesgQueue* PadMgr_LockSerialMesgQueue(PadMgr* padmgr) {
OSMesgQueue* ctrlrqueue = NULL;
if (D_8012D280 > 2) {
@@ -28,7 +27,7 @@ OSMesgQueue* PadMgr_LockGetControllerQueue(PadMgr* padmgr) {
return ctrlrqueue;
}
-void PadMgr_UnlockReleaseControllerQueue(PadMgr* padmgr, OSMesgQueue* ctrlrqueue) {
+void PadMgr_UnlockSerialMesgQueue(PadMgr* padmgr, OSMesgQueue* ctrlrqueue) {
if (D_8012D280 > 2) {
// EUC-JP: ロック解除します | Unlock
osSyncPrintf("%2d %d serialMsgQロック解除します %08x %08x %08x\n", osGetThreadId(NULL),
@@ -44,193 +43,347 @@ void PadMgr_UnlockReleaseControllerQueue(PadMgr* padmgr, OSMesgQueue* ctrlrqueue
}
}
-void PadMgr_Lock2(PadMgr* padmgr) {
+void PadMgr_LockPadData(PadMgr* padmgr) {
osRecvMesg(&padmgr->queue2, NULL, OS_MESG_BLOCK);
}
-void PadMgr_Unlock2(PadMgr* padmgr) {
+void PadMgr_UnlockPadData(PadMgr* padmgr) {
osSendMesg(&padmgr->queue2, NULL, OS_MESG_BLOCK);
}
#ifdef NON_MATCHING
// regalloc and minor ordering differences
-void func_800C740C(PadMgr* padmgr) {
- static u32 D_8012D284 = 0;
+void PadMgr_RumbleControl(PadMgr* padmgr) {
+ static u32 errcnt = 0;
static u32 D_8016A4F0;
s32 temp;
- s32 var1;
+ s32 triedRumbleComm;
OSMesgQueue* ctrlrqueue;
- s32 var3;
+ s32 ctrlr;
s32 var4;
s32 i;
temp = 1;
- ctrlrqueue = PadMgr_LockGetControllerQueue(padmgr);
- var1 = 0;
+ ctrlrqueue = PadMgr_LockSerialMesgQueue(padmgr);
+ triedRumbleComm = 0;
for (i = 0; i < 4; i++) {
- if (padmgr->unk_2AA[i] != 0) {
+ if (padmgr->ctrlrIsConnected[i] != 0) {
if (padmgr->pad_status[i].status & 1) {
- if (padmgr->unk_2AE[i] == temp) {
- if (padmgr->unk_2B2[i] != 0) {
- if (padmgr->unk_2B6[i] < 3) {
+ if (padmgr->pakType[i] == temp) {
+ if (padmgr->rumbleEnable[i] != 0) {
+ if (padmgr->rumbleCounter[i] < 3) {
osSyncPrintf(VT_FGCOL(YELLOW));
osSyncPrintf("padmgr: %dコン: %s\n", i + 1, "振動パック ぶるぶるぶるぶる");
osSyncPrintf(VT_RST);
- if (osSetVibration(&padmgr->unk_controller[i], temp) != 0) {
- padmgr->unk_2AE[i] = 0;
+ if (osSetRumble(&padmgr->unk_controller[i], temp) != 0) {
+ padmgr->pakType[i] = 0;
osSyncPrintf(VT_FGCOL(YELLOW));
osSyncPrintf("padmgr: %dコン: %s\n", i + 1, "振動パックで通信エラーが発生しました");
osSyncPrintf(VT_RST);
} else {
- padmgr->unk_2B6[i] = 3;
+ padmgr->rumbleCounter[i] = 3;
}
- var1 = 1;
+ triedRumbleComm = 1;
}
} else {
- if (padmgr->unk_2B6[i] != 0) {
+ if (padmgr->rumbleCounter[i] != 0) {
osSyncPrintf(VT_FGCOL(YELLOW));
osSyncPrintf("padmgr: %dコン: %s\n", i + 1, "振動パック 停止");
osSyncPrintf(VT_RST);
- if (osSetVibration(&padmgr->unk_controller[i], 0) != 0) {
- padmgr->unk_2AE[i] = 0;
+ if (osSetRumble(&padmgr->unk_controller[i], 0) != 0) {
+ padmgr->pakType[i] = 0;
osSyncPrintf(VT_FGCOL(YELLOW));
osSyncPrintf("padmgr: %dコン: %s\n", i + 1, "振動パックで通信エラーが発生しました");
osSyncPrintf(VT_RST);
} else {
- padmgr->unk_2B6[i]--;
+ padmgr->rumbleCounter[i]--;
}
- var1 = 1;
+ triedRumbleComm = 1;
}
}
}
} else {
- if (padmgr->unk_2AE[i] != 0) {
- if (padmgr->unk_2AE[i] == 1) {
+ if (padmgr->pakType[i] != 0) {
+ if (padmgr->pakType[i] == 1) {
osSyncPrintf(VT_FGCOL(YELLOW));
osSyncPrintf("padmgr: %dコン: %s\n", i + 1, "振動パックが抜かれたようです");
osSyncPrintf(VT_RST);
- padmgr->unk_2AE[i] = 0;
+ padmgr->pakType[i] = 0;
} else {
osSyncPrintf(VT_FGCOL(YELLOW));
osSyncPrintf("padmgr: %dコン: %s\n", i + 1,
"振動パックではないコントローラパックが抜かれたようです");
osSyncPrintf(VT_RST);
- padmgr->unk_2AE[i] = 0;
+ padmgr->pakType[i] = 0;
}
}
}
}
}
- if (!var1) {
- var3 = D_8016A4F0 % 4;
+ if (!triedRumbleComm) {
+ ctrlr = D_8016A4F0 % 4;
- if ((padmgr->unk_2AA[var3] != 0) && (padmgr->pad_status[var3].status & 1) && (padmgr->unk_2AE[var3] != 1)) {
- var4 = osProbeVibrationPack(ctrlrqueue, &padmgr->unk_controller[var3], var3);
+ if ((padmgr->ctrlrIsConnected[ctrlr] != 0) && (padmgr->pad_status[ctrlr].status & 1) &&
+ (padmgr->pakType[ctrlr] != 1)) {
+ var4 = osProbeRumblePak(ctrlrqueue, &padmgr->unk_controller[ctrlr], ctrlr);
if (var4 == 0) {
- padmgr->unk_2AE[var3] = 1;
- osSetVibration(&padmgr->unk_controller[var3], 1);
- osSetVibration(&padmgr->unk_controller[var3], 0);
+ padmgr->pakType[ctrlr] = 1;
+ osSetRumble(&padmgr->unk_controller[ctrlr], 1);
+ osSetRumble(&padmgr->unk_controller[ctrlr], 0);
osSyncPrintf(VT_FGCOL(YELLOW));
- osSyncPrintf("padmgr: %dコン: %s\n", var3 + 1, "振動パックを認識しました");
+ osSyncPrintf("padmgr: %dコン: %s\n", ctrlr + 1, "振動パックを認識しました");
osSyncPrintf(VT_RST);
} else if (var4 == 11) {
- padmgr->unk_2AE[var3] = 2;
+ padmgr->pakType[ctrlr] = 2;
} else if (var4 == 4) {
- LOG_NUM("++errcnt", ++D_8012D284, "../padmgr.c", 282);
+ LOG_NUM("++errcnt", ++errcnt, "../padmgr.c", 282);
osSyncPrintf(VT_FGCOL(YELLOW));
- osSyncPrintf("padmgr: %dコン: %s\n", var3 + 1, "コントローラパックの通信エラー");
+ osSyncPrintf("padmgr: %dコン: %s\n", ctrlr + 1, "コントローラパックの通信エラー");
osSyncPrintf(VT_RST);
}
}
}
D_8016A4F0++;
- PadMgr_UnlockReleaseControllerQueue(padmgr, ctrlrqueue);
+ PadMgr_UnlockSerialMesgQueue(padmgr, ctrlrqueue);
}
#else
-u32 D_8012D284 = 0;
+u32 D_8012D284 = 0; // errcnt
u32 D_8016A4F0;
-#pragma GLOBAL_ASM("asm/non_matchings/code/padmgr/func_800C740C.s")
+#pragma GLOBAL_ASM("asm/non_matchings/code/padmgr/PadMgr_RumbleControl.s")
#endif
// func_800A2300 in 1.0
-void func_800C7818(PadMgr* padmgr) {
+void PadMgr_RumbleStop(PadMgr* padmgr) {
s32 i;
OSMesgQueue* ctrlrqueue;
- ctrlrqueue = PadMgr_LockGetControllerQueue(padmgr);
+ ctrlrqueue = PadMgr_LockSerialMesgQueue(padmgr);
for (i = 0; i < 4; i++) {
- if (osProbeVibrationPack(ctrlrqueue, &padmgr->unk_controller[i], i) == 0) {
- if ((gFaultStruct.msgId == 0) && (padmgr->unk_45D != 0)) {
+ if (osProbeRumblePak(ctrlrqueue, &padmgr->unk_controller[i], i) == 0) {
+ if ((gFaultStruct.msgId == 0) && (padmgr->rumbleOnFrames != 0)) {
osSyncPrintf(VT_FGCOL(YELLOW));
// EUC-JP: コン | 'Con'? , EUC-JP: 振動パック 停止 | Stop vibration pack
osSyncPrintf("padmgr: %dコン: %s\n", i + 1, "振動パック 停止");
osSyncPrintf(VT_RST);
}
- osSetVibration(&padmgr->unk_controller[i], 0);
+ osSetRumble(&padmgr->unk_controller[i], 0);
}
}
- PadMgr_UnlockReleaseControllerQueue(padmgr, ctrlrqueue);
+ PadMgr_UnlockSerialMesgQueue(padmgr, ctrlrqueue);
}
-void func_800C7928(PadMgr* padmgr) {
- padmgr->unk_45C = 3;
+void PadMgr_RumbleReset(PadMgr* padmgr) {
+ padmgr->rumbleOffFrames = 3;
}
-void func_800C7934(PadMgr* padmgr, u32 a1, u32 a2) {
- padmgr->unk_2B2[a1] = a2;
- padmgr->unk_45D = 0xF0;
+void PadMgr_RumbleSetSingle(PadMgr* padmgr, u32 ctrlr, u32 rumble) {
+ padmgr->rumbleEnable[ctrlr] = rumble;
+ padmgr->rumbleOnFrames = 0xF0;
}
-#ifdef NON_MATCHING
-// minor ordering difference
// 800A23CC in 1.0
-void func_800C7948(PadMgr* padmgr, u8* a1) {
- padmgr->unk_2B2[0] = a1[0];
- padmgr->unk_2B2[1] = a1[1];
- padmgr->unk_2B2[2] = a1[2];
- padmgr->unk_2B2[3] = a1[3];
+void PadMgr_RumbleSet(PadMgr* padmgr, u8* ctrlrRumbles) {
+ s32 i;
+ for (i = 0; i < 4; ++i) {
+ padmgr->rumbleEnable[i] = ctrlrRumbles[i];
+ }
+ padmgr->rumbleOnFrames = 0xF0;
+}
+
+#if 0
+void PadMgr_ProcessInputs(PadMgr* padmgr) {
+ /*
+ void *sp34;
+ s32 temp_s1;
+ s32 temp_v0_5;
+ u16 temp_a1;
+ u16 temp_v1_2;
+ u8 temp_v0;
+ void *temp_v0_2;
+ void *temp_v0_3;
+ void *temp_v0_4;
+ void *temp_v1;
+ void *phi_s0;
+ void *phi_s3;
+ s32 phi_s2;
+ s32 phi_s1;
+ */
+ Input* input;
+ PadState* padnow1; //name from debug string
+ s32 i;
- padmgr->unk_45D = 0xF0; // NON MATCHING - T0 and T9 are reordered for some reason
+ PadMgr_LockPadData(padmgr);
+ input = padmgr->inputs; //s0
+ padnow1 = padmgr->pads; //s3
+ for(i=0; i<padmgr->ncontrollers; ++i, ++input, ++padnow1){
+ input->prev.in = input->cur.in;
+ input->prev.status = input->cur.status;
+ temp_v0 = phi_s3->unk4;
+ switch(padnow1->errno){
+ case 0:
+ input->cur.in = padnow1->input;
+ input->cur.status = padnow1->status;
+ if (padmgr->ctrlrIsConnected[i] == 0) {
+ padmgr->ctrlrIsConnected[i] = 1;
+ osSyncPrintf(&D_80145AF0); //"\x1b[33m"
+ osSyncPrintf(&D_80145AF8, phi_s2 + 1, &D_80145B0C); //"padmgr: %dCon: %s\n" : "Recognized"
+ osSyncPrintf(&D_80145B1C); //"\x1b[m"
+ }
+ break;
+ case 4:
+ input->cur.in = input->prev.in;
+ input->cur.status = input->prev.status;
+ LogUtils_LogThreadId(&D_80145B20, 0x17c); //"../padmgr.c"
+ osSyncPrintf(&D_80145B2C, padmgr->ctrlrIsConnected[i]); //"this->ctrlrIsConnected[i] = %d\n"
+ osSyncPrintf(&D_80145B48); //"\x1b[33m"
+ osSyncPrintf(&D_80145B50, temp_s1, &D_80145B64); //"padmgr: %dCon: %s\n" : "Overrun error occurred"
+ osSyncPrintf(&D_80145B80); //"\x1b[m"
+ break;
+ case 8:
+ input->cur.in.button = 0;
+ input->cur.in.x = 0;
+ input->cur.in.y = 0;
+ temp_v0_2 = arg0 + phi_s2;
+ input->cur.errno = padnow1->errno;
+ if (temp_v0_2->ctrlrIsConnected != 0){
+ temp_v0_2->ctrlrIsConnected = 0;
+ temp_v0_2->pakType = 0;
+ temp_v0_2->rumbleCounter = 0xff;
+ osSyncPrintf(&D_80145B84); //"\x1b[33m"
+ osSyncPrintf(&D_80145B8C, phi_s2 + 1, &D_80145BA0); //"padmgr: %dCon: %s\n" : "Do not respond"
+ osSyncPrintf(&D_80145BB0); //"\x1b[m"
+ }
+ break;
+ default:
+ LogUtils_LogThreadId(&D_80145BB4, 0x18c); //"../padmgr.c"
+ osSyncPrintf(&D_80145BC0, padnow1->errno); //"padnow1->errno = %x\n"
+ Fault_AddHungupAndCrash(&D_80145BD8, 0x18d); //"../padmgr.c"
+ }
+ input->press.in.button = input->cur.in.button & (input->prev.in.button ^ input->cur.in.button);
+ input->rel.in.button = input->prev.in.button & (input->prev.in.button ^ input->cur.in.button);
+ func_800FCC6C(input);
+ input->press.in.x = (input->cur.in.x - input->prev.in.x) + input->press.in.x;
+ input->press.in.y = (input->cur.in.y - input->prev.in.y) + input->press.in.y;
+ }
+ PadMgr_UnlockPadData(arg0);
}
#else
-#pragma GLOBAL_ASM("asm/non_matchings/code/padmgr/func_800C7948.s")
+#pragma GLOBAL_ASM("asm/non_matchings/code/padmgr/PadMgr_ProcessInputs.s")
#endif
-#pragma GLOBAL_ASM("asm/non_matchings/code/padmgr/func_800C7974.s")
+void PadMgr_HandleRetraceMsg(PadMgr* padmgr) {
+ OSMesgQueue* queue; // s1
+ u32 i;
+ u32 mask;
-#pragma GLOBAL_ASM("asm/non_matchings/code/padmgr/func_800C7C14.s")
+ queue = PadMgr_LockSerialMesgQueue(padmgr);
+ osContStartReadData(queue);
+ if (padmgr->retraceCallback) {
+ padmgr->retraceCallback(padmgr, padmgr->retraceCallbackValue);
+ }
+ osRecvMesg(queue, NULL, OS_MESG_BLOCK);
+ osContGetReadData(&padmgr->pads[0]);
+ if (padmgr->preNMIShutdown) {
+ bzero(&padmgr->pads[0], 0x18);
+ }
+ PadMgr_ProcessInputs(padmgr);
+ func_80103210(queue);
+ osRecvMesg(queue, NULL, OS_MESG_BLOCK);
+ func_8010328C(padmgr);
+ PadMgr_UnlockSerialMesgQueue(padmgr, queue);
+
+ mask = 0;
+ for (i = 0; i - 4 != 0; ++i) {
+ if (padmgr->pad_status[i].errno == 0) {
+ if (padmgr->pad_status[i].type - 5 == 0) {
+ mask |= 1 << i;
+ } else {
+ LogUtils_LogThreadId("../padmgr.c", 0x1ca);
+ osSyncPrintf("this->pad_status[i].type = %x\n", padmgr->pad_status[i].type);
+ // EUC-JP: 知らない種類のコントローラが接続されています | An unknown type of controller is connected
+ osSyncPrintf("知らない種類のコントローラが接続されています\n");
+ }
+ }
+ }
+ padmgr->validCtrlrsMask = mask;
+
+ if (gFaultStruct.msgId) {
+ PadMgr_RumbleStop(padmgr);
+ } else if (padmgr->rumbleOffFrames > 0) {
+ --padmgr->rumbleOffFrames;
+ PadMgr_RumbleStop(padmgr);
+ } else if (padmgr->rumbleOnFrames == 0) {
+ PadMgr_RumbleStop(padmgr);
+ } else if (!padmgr->preNMIShutdown) {
+ PadMgr_RumbleControl(padmgr);
+ --padmgr->rumbleOnFrames;
+ }
+}
-void func_800C7DD0(PadMgr* padmgr) {
+void PadMgr_HandlePreNMI(PadMgr* padmgr) {
osSyncPrintf("padmgr_HandlePreNMI()\n");
- padmgr->unk_45E = 1;
- func_800C7928(padmgr);
+ padmgr->preNMIShutdown = 1;
+ PadMgr_RumbleReset(padmgr);
}
-#pragma GLOBAL_ASM("asm/non_matchings/code/padmgr/func_800C7E08.s")
-// void func_800C7E08(Input*, u32);
+#ifdef NON_MATCHING
+// Regalloc differences
+void PadMgr_RequestPadData(PadMgr* padmgr, Input* inputs, s32 mode) {
+ u32 i;
+ Input* pmInputs;
+ Input* newin;
+
+ PadMgr_LockPadData(padmgr);
+ pmInputs = padmgr->inputs;
+ newin = inputs;
+ for (i = 0; i < 4; ++i) {
+ if (mode) {
+ *newin = *pmInputs;
+ pmInputs->press.in.button = 0;
+ pmInputs->press.in.x = 0;
+ pmInputs->press.in.y = 0;
+ pmInputs->rel.in.button = 0;
+ } else {
+ // Correct instructions, wrong regalloc
+ newin->prev = newin->cur;
+ newin->cur = pmInputs->cur;
+ newin->press.in.button = newin->cur.in.button & (newin->prev.in.button ^ newin->cur.in.button);
+ newin->rel.in.button = newin->prev.in.button & (newin->prev.in.button ^ newin->cur.in.button);
+ func_800FCC6C(newin);
+ newin->press.in.x = (newin->cur.in.x - newin->prev.in.x) + newin->press.in.x;
+ newin->press.in.y = (newin->cur.in.y - newin->prev.in.y) + newin->press.in.y;
+ }
+ ++pmInputs;
+ ++newin;
+ }
+ PadMgr_UnlockPadData(padmgr);
+}
+#else
+#pragma GLOBAL_ASM("asm/non_matchings/code/padmgr/PadMgr_RequestPadData.s")
+#endif
// 800A2918 in 1.0
-void PadMgr_Run(PadMgr* padmgr) {
+void PadMgr_MainProc(PadMgr* padmgr) {
s16* mesg;
- s32 bVar2;
+ s32 exit;
mesg = NULL;
// EUC-JP: コントローラスレッド実行開始 | Start of controller thread execution
osSyncPrintf("コントローラスレッド実行開始\n");
- bVar2 = 0;
+ exit = 0;
- while (bVar2 == 0) {
+ while (!exit) {
if ((D_8012D280 > 2) && (padmgr->queue3.validCount == 0)) {
// EUC-JP: コントローラスレッドイベント待ち | Waiting for controller thread event
osSyncPrintf("コントローラスレッドイベント待ち %lld\n", OS_CYCLES_TO_USEC(osGetTime()));
@@ -245,7 +398,7 @@ void PadMgr_Run(PadMgr* padmgr) {
osSyncPrintf("padmgr_HandleRetraceMsg START %lld\n", OS_CYCLES_TO_USEC(osGetTime()));
}
- func_800C7C14(padmgr);
+ PadMgr_HandleRetraceMsg(padmgr);
if (D_8012D280 > 2) {
osSyncPrintf("padmgr_HandleRetraceMsg END %lld\n", OS_CYCLES_TO_USEC(osGetTime()));
@@ -253,10 +406,10 @@ void PadMgr_Run(PadMgr* padmgr) {
break;
case OS_SC_PRE_NMI_MSG:
- func_800C7DD0(padmgr);
+ PadMgr_HandlePreNMI(padmgr);
break;
case OS_SC_NMI_MSG:
- bVar2 = 1;
+ exit = 1;
break;
}
}
@@ -267,7 +420,7 @@ void PadMgr_Run(PadMgr* padmgr) {
}
// func_800A2A14 in 1.0
-void PadMgr_Init(PadMgr* padmgr, OSMesgQueue* ctrlrqueue, UNK_TYPE arg2, OSId id, OSPri priority, void* stack) {
+void PadMgr_Init(PadMgr* padmgr, OSMesgQueue* siIntMsgQ, UNK_TYPE arg2, OSId id, OSPri priority, void* stack) {
// EUC-JP: パッドマネージャ作成 | Create pad manager
osSyncPrintf("パッドマネージャ作成 padmgr_Create()\n");
bzero(padmgr, sizeof(PadMgr));
@@ -276,14 +429,14 @@ void PadMgr_Init(PadMgr* padmgr, OSMesgQueue* ctrlrqueue, UNK_TYPE arg2, OSId id
osCreateMesgQueue(&padmgr->queue3, padmgr->msgbuf3, 4);
IrqMgr_AddClient(padmgr->unk_78, &padmgr->unk_70, &padmgr->queue3);
osCreateMesgQueue(&padmgr->queue1, padmgr->msgbuf1, 1);
- PadMgr_UnlockReleaseControllerQueue(padmgr, ctrlrqueue);
+ PadMgr_UnlockSerialMesgQueue(padmgr, siIntMsgQ);
osCreateMesgQueue(&padmgr->queue2, padmgr->msgbuf2, 1);
- PadMgr_Unlock2(padmgr);
- func_800FCD40(ctrlrqueue, &padmgr->unk_2A8, padmgr);
+ PadMgr_UnlockPadData(padmgr);
+ func_800FCD40(siIntMsgQ, &padmgr->validCtrlrsMask, padmgr);
- padmgr->unk_2A9 = 4;
- func_80104D00(padmgr->unk_2A9);
+ padmgr->ncontrollers = 4;
+ func_80104D00(padmgr->ncontrollers);
- osCreateThread(&padmgr->thread, id, PadMgr_Run, padmgr, stack, priority);
+ osCreateThread(&padmgr->thread, id, PadMgr_MainProc, padmgr, stack, priority);
osStartThread(&padmgr->thread);
}
diff --git a/src/code/z_debug.c b/src/code/z_debug.c
index cb21e0125..fc663c3d2 100644
--- a/src/code/z_debug.c
+++ b/src/code/z_debug.c
@@ -114,11 +114,12 @@ void func_8006390C(Input* input) {
s32 i;
regGroup = (gGameInfo->regGroup * REG_PAGES + gGameInfo->regPage) * REG_PER_PAGE - REG_PER_PAGE;
- dpad = input->raw.pad & (U_JPAD | L_JPAD | R_JPAD | D_JPAD);
- if (!~(input->raw.pad | ~L_TRIG) || !~(input->raw.pad | ~R_TRIG) || !~(input->raw.pad | ~START_BUTTON)) {
+ dpad = input->cur.in.button & (U_JPAD | L_JPAD | R_JPAD | D_JPAD);
+ if (!~(input->cur.in.button | ~L_TRIG) || !~(input->cur.in.button | ~R_TRIG) ||
+ !~(input->cur.in.button | ~START_BUTTON)) {
input_combo = inputCombos;
for (i = 0; i < REG_GROUPS; i++) {
- if (~(~input_combo->push | input->raw.pad) || ~(~input_combo->held | input->padPressed)) {
+ if (~(~input_combo->push | input->cur.in.button) || ~(~input_combo->held | input->press.in.button)) {
input_combo++;
} else {
break;
@@ -154,16 +155,18 @@ void func_8006390C(Input* input) {
gGameInfo->dpadLast = dpad;
}
- increment = (dpad & R_JPAD)
- ? (!~(input->raw.pad | ~(A_BUTTON | B_BUTTON))
- ? 1000
- : !~(input->raw.pad | ~A_BUTTON) ? 100 : !~(input->raw.pad | ~B_BUTTON) ? 10 : 1)
- : (dpad & L_JPAD) ? (!~(input->raw.pad | ~(A_BUTTON | B_BUTTON))
- ? -1000
- : !~(input->raw.pad | ~A_BUTTON)
- ? -100
- : !~(input->raw.pad | ~B_BUTTON) ? -10 : -1)
- : 0;
+ increment =
+ (dpad & R_JPAD)
+ ? (!~(input->cur.in.button | ~(A_BUTTON | B_BUTTON))
+ ? 1000
+ : !~(input->cur.in.button | ~A_BUTTON) ? 100
+ : !~(input->cur.in.button | ~B_BUTTON) ? 10 : 1)
+ : (dpad & L_JPAD) ? (!~(input->cur.in.button | ~(A_BUTTON | B_BUTTON))
+ ? -1000
+ : !~(input->cur.in.button | ~A_BUTTON)
+ ? -100
+ : !~(input->cur.in.button | ~B_BUTTON) ? -10 : -1)
+ : 0;
gGameInfo->data[gGameInfo->regCur + regGroup] += increment;
if (dpad & U_JPAD) {
diff --git a/src/code/z_demo.c b/src/code/z_demo.c
index be6505dcd..32939bf77 100644
--- a/src/code/z_demo.c
+++ b/src/code/z_demo.c
@@ -99,14 +99,15 @@ void func_80064558(GlobalContext* globalCtx, CutsceneContext* csCtx) {
void func_800645A0(GlobalContext* globalCtx, CutsceneContext* csCtx) {
Input* pad1 = &globalCtx->state.input[0];
- if (!~(pad1->padPressed | ~L_JPAD) && (csCtx->state == CS_STATE_IDLE) && (gSaveContext.scene_setup_index >= 4)) {
+ if (!~(pad1->press.in.button | ~L_JPAD) && (csCtx->state == CS_STATE_IDLE) &&
+ (gSaveContext.scene_setup_index >= 4)) {
D_8015FCC8 = 0;
gSaveContext.cutscene_index = 0xFFFD;
gSaveContext.cutscene_trigger = 1;
}
- if (!~(pad1->padPressed | ~U_JPAD) && (csCtx->state == CS_STATE_IDLE) && (gSaveContext.scene_setup_index >= 4) &&
- (D_8011D394 == 0)) {
+ if (!~(pad1->press.in.button | ~U_JPAD) && (csCtx->state == CS_STATE_IDLE) &&
+ (gSaveContext.scene_setup_index >= 4) && (D_8011D394 == 0)) {
D_8015FCC8 = 1;
gSaveContext.cutscene_index = 0xFFFD;
gSaveContext.cutscene_trigger = 1;
@@ -443,15 +444,16 @@ void Cutscene_Command_Terminator(GlobalContext* globalCtx, CutsceneContext* csCt
if ((gSaveContext.game_mode != 0) && (gSaveContext.game_mode != 3) && (globalCtx->sceneNum != SCENE_SPOT00) &&
(csCtx->frames > 20) &&
- (!~(globalCtx->state.input[0].padPressed | ~A_BUTTON) || !~(globalCtx->state.input[0].padPressed | ~B_BUTTON) ||
- !~(globalCtx->state.input[0].padPressed | ~START_BUTTON)) &&
+ (!~(globalCtx->state.input[0].press.in.button | ~A_BUTTON) ||
+ !~(globalCtx->state.input[0].press.in.button | ~B_BUTTON) ||
+ !~(globalCtx->state.input[0].press.in.button | ~START_BUTTON)) &&
(gSaveContext.file_num != 0xFEDC) && (globalCtx->sceneLoadFlag == 0)) {
Audio_PlaySoundGeneral(NA_SE_SY_PIECE_OF_HEART, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8);
temp = 1;
}
if ((csCtx->frames == cmd->startFrame) || (temp != 0) ||
- ((csCtx->frames > 20) && (!~(globalCtx->state.input[0].padPressed | ~START_BUTTON)) &&
+ ((csCtx->frames > 20) && (!~(globalCtx->state.input[0].press.in.button | ~START_BUTTON)) &&
(gSaveContext.file_num != 0xFEDC))) {
csCtx->state = CS_STATE_UNSKIPPABLE_EXEC;
func_800F68BC(0);
@@ -1523,7 +1525,7 @@ void Cutscene_ProcessCommands(GlobalContext* globalCtx, CutsceneContext* csCtx,
return;
}
- if (!~(globalCtx->state.input[0].padPressed | ~R_JPAD)) {
+ if (!~(globalCtx->state.input[0].press.in.button | ~R_JPAD)) {
csCtx->state = CS_STATE_UNSKIPPABLE_INIT;
return;
}
diff --git a/src/code/z_parameter.c b/src/code/z_parameter.c
index 19e5915aa..10e285b8b 100644
--- a/src/code/z_parameter.c
+++ b/src/code/z_parameter.c
@@ -3982,13 +3982,13 @@ void Interface_Update(GlobalContext* globalCtx) {
u16 action;
Input* input = &globalCtx->state.input[2];
- if (!~(input->padPressed | ~L_JPAD)) {
+ if (!~(input->press.in.button | ~L_JPAD)) {
gSaveContext.language = 0;
osSyncPrintf("J_N=%x J_N=%x\n", gSaveContext.language, &gSaveContext.language);
- } else if (!~(input->padPressed | ~U_JPAD)) {
+ } else if (!~(input->press.in.button | ~U_JPAD)) {
gSaveContext.language = 1;
osSyncPrintf("J_N=%x J_N=%x\n", gSaveContext.language, &gSaveContext.language);
- } else if (!~(input->padPressed | ~R_JPAD)) {
+ } else if (!~(input->press.in.button | ~R_JPAD)) {
gSaveContext.language = 2;
osSyncPrintf("J_N=%x J_N=%x\n", gSaveContext.language, &gSaveContext.language);
}
diff --git a/src/code/z_sample.c b/src/code/z_sample.c
index ee7bf3caa..38add9d42 100644
--- a/src/code/z_sample.c
+++ b/src/code/z_sample.c
@@ -3,7 +3,7 @@
#include <PR/os_cont.h>
void Sample_Calc(SampleContext* this) {
- if (!~(this->state.input[0].padPressed | ~START_BUTTON)) {
+ if (!~(this->state.input[0].press.in.button | ~START_BUTTON)) {
SET_NEXT_GAMESTATE(&this->state, func_800BCA64, GlobalContext);
this->state.running = false;
}
diff --git a/src/libultra_code/osContStartReadData.c b/src/libultra_code/osContStartReadData.c
index 9bd0bfbd2..60e415028 100644
--- a/src/libultra_code/osContStartReadData.c
+++ b/src/libultra_code/osContStartReadData.c
@@ -26,9 +26,9 @@ void osContGetReadData(OSContPad* pad) {
slot = *slot_ptr;
pad->errno = (slot.hdr.status_hi_bytes_rec_lo & 0xc0) >> 4;
if (pad->errno == 0) {
- pad->button = slot.button;
- pad->stick_x = slot.rawStickX;
- pad->stick_y = slot.rawStickY;
+ pad->button = slot.input.button;
+ pad->stick_x = slot.input.x;
+ pad->stick_y = slot.input.y;
}
};
}
@@ -46,9 +46,9 @@ void __osPackReadData() {
slot.hdr.bytes_send = 1;
slot.hdr.status_hi_bytes_rec_lo = 4;
slot.hdr.command = 1;
- slot.button = 0xFFFF;
- slot.rawStickX = 0xFF;
- slot.rawStickY = 0xFF;
+ slot.input.button = 0xFFFF;
+ slot.input.x = 0xFF;
+ slot.input.y = 0xFF;
for (i = 0; i < _osCont_numControllers; i++) {
*slot_ptr++ = slot;
}
diff --git a/src/libultra_code/osMempakAddrCRC.c b/src/libultra_code/osMempakAddrCRC.c
new file mode 100644
index 000000000..4565ff4ee
--- /dev/null
+++ b/src/libultra_code/osMempakAddrCRC.c
@@ -0,0 +1,68 @@
+#include <ultra64.h>
+#include <global.h>
+
+#include <ultra64/controller.h>
+
+// Valid addr up to 0x7FF
+// It's the address of a block of 0x20 bytes in the mempak
+// So that means the whole mempak has a 16-bit address space
+u8 osMempakAddrCRC(u16 addr) {
+ u32 addr32 = addr;
+ u32 ret = 0;
+ u32 bit;
+ s32 i;
+
+ for (bit = 0x400; bit; bit /= 2) {
+ ret *= 2;
+ if (addr32 & bit) {
+ if (ret & 0x20) {
+ ret ^= 0x14;
+ } else {
+ ++ret;
+ }
+ } else {
+ if (ret & 0x20) {
+ ret ^= 0x15;
+ }
+ }
+ }
+ for (i = 0; i < 5; ++i) {
+ ret <<= 1;
+ if (ret & 0x20) {
+ ret ^= 0x15;
+ }
+ }
+ return ret & 0x1f;
+}
+
+u8 osMempakDataCRC(u8* data) {
+ s32 ret;
+ u32 bit;
+ u32 byte;
+
+ ret = 0;
+ for (byte = 0x20; byte; --byte, ++data) {
+ for (bit = 0x80; bit; bit /= 2) {
+ ret *= 2;
+ if ((*data & bit) != 0) {
+ if ((ret & 0x100) != 0) {
+ ret ^= 0x84;
+ } else {
+ ++ret;
+ }
+ } else {
+ if (ret & 0x100) {
+ ret ^= 0x85;
+ }
+ }
+ }
+ }
+ do {
+ ret *= 2;
+ if (ret & 0x100) {
+ ret ^= 0x85;
+ }
+ ++byte;
+ } while (byte < 8U);
+ return ret;
+}
diff --git a/src/libultra_code/osReadMempak.c b/src/libultra_code/osReadMempak.c
new file mode 100644
index 000000000..fd1b3b0e4
--- /dev/null
+++ b/src/libultra_code/osReadMempak.c
@@ -0,0 +1,57 @@
+#include <ultra64.h>
+#include <global.h>
+
+#include <ultra64/controller.h>
+
+s32 osReadMempak(OSMesgQueue* ctrlrqueue, s32 ctrlridx, u16 addr, PIF_mempak_data_t* data) {
+ s32 ret;
+ s32 i;
+ u8* bufptr;
+ s32 read_try_count = 2;
+
+ __osSiGetAccess();
+ do {
+ if ((_osCont_lastPollType != 2) || (ctrlridx != D_80134D20)) {
+ bufptr = &pifMempakBuf.bytes[0];
+ _osCont_lastPollType = 2;
+ D_80134D20 = ctrlridx;
+ // clang-format off
+ // NOLINTNEXTLINE
+ for (i = 0; i < ctrlridx; i++) *bufptr++ = 0;
+ // clang-format on
+ pifMempakBuf.status_control = 1;
+ ((PIF_header_t*)bufptr)->slot_type = 0xff;
+ ((PIF_header_t*)bufptr)->bytes_send = 3;
+ ((PIF_header_t*)bufptr)->status_hi_bytes_rec_lo = 0x21;
+ ((PIF_header_t*)bufptr)->command = 2; // read mempak; send byte 0
+ // Received bytes are 6-26 inclusive
+ bufptr[0x26] = 0xff; // last byte of receive
+ bufptr[0x27] = 0xfe; // End of commands
+ } else {
+ bufptr = &pifMempakBuf.bytes[ctrlridx];
+ }
+ bufptr[4] = addr >> 3; // send byte 1
+ bufptr[5] = (s8)(osMempakAddrCRC(addr) | (addr << 5)); // send byte 2
+ __osSiRawStartDma(1, &pifMempakBuf);
+ osRecvMesg(ctrlrqueue, 0, 1);
+ __osSiRawStartDma(0, &pifMempakBuf);
+ osRecvMesg(ctrlrqueue, 0, 1);
+ ret = (((PIF_header_t*)bufptr)->status_hi_bytes_rec_lo & 0xc0) >> 4;
+ if (!ret) {
+ if (bufptr[0x26] != osMempakDataCRC(bufptr + 6)) {
+ ret = func_80101910(ctrlrqueue, ctrlridx);
+ if (ret)
+ break;
+ ret = 4; // Retry
+ } else {
+ bcopy(bufptr + 6, data, 0x20);
+ }
+ } else {
+ ret = 1; // Error
+ }
+ if (ret != 4)
+ break;
+ } while (0 <= read_try_count--);
+ __osSiRelAccess();
+ return ret;
+}
diff --git a/src/libultra_code/osVibrationPack.c b/src/libultra_code/osRumblePak.c
index 033f04500..d2b47f2c6 100644
--- a/src/libultra_code/osVibrationPack.c
+++ b/src/libultra_code/osRumblePak.c
@@ -6,7 +6,7 @@
pif_data_buffer_t osPifBuffers[4];
// func_800CF990 in 1.0
-s32 osSetVibration(unk_controller_t* arg0, u32 vibrate) {
+s32 osSetRumble(unk_controller_t* arg0, u32 vibrate) {
s32 i;
s32 ret;
u8* buf;
@@ -22,7 +22,7 @@ s32 osSetVibration(unk_controller_t* arg0, u32 vibrate) {
((PIF_mempak_wr_t*)buf)->data[i + 2] = vibrate;
}
- _osCont_lastPollType = (u8)0xfe; // last controller poll type?
+ _osCont_lastPollType = 0xfe; // last controller poll type?
__osSiRawStartDma(OS_WRITE, &osPifBuffers[arg0->ctrlridx]);
osRecvMesg(arg0->ctrlrqueue, NULL, OS_MESG_BLOCK);
__osSiRawStartDma(OS_READ, &osPifBuffers[arg0->ctrlridx]);
@@ -51,8 +51,8 @@ void osSetUpMempakWrite(s32 ctrlridx, pif_data_buffer_t* buf) {
mempakwr.hdr.bytes_send = 0x23;
mempakwr.hdr.status_hi_bytes_rec_lo = 1;
mempakwr.hdr.command = 3; // write mempak
- mempakwr.data[0] = 0xC0;
- mempakwr.data[1] = (u8)(func_80106170(0x600) | 0xC000); // yes, this is correct
+ mempakwr.data[0] = 0x600 >> 3;
+ mempakwr.data[1] = (u8)(osMempakAddrCRC(0x600) | (0x600 << 5));
if (ctrlridx != 0) {
for (i = 0; i < ctrlridx; ++i) {
*buf_ptr++ = 0;
@@ -67,13 +67,13 @@ typedef struct {
u8 unk[0x20];
} unk_sp24_t;
-s32 osProbeVibrationPack(OSMesgQueue* ctrlrqueue, unk_controller_t* unk_controller, u32 ctrlridx) {
+s32 osProbeRumblePak(OSMesgQueue* ctrlrqueue, unk_controller_t* unk_controller, u32 ctrlridx) {
s32 ret;
unk_sp24_t sp24;
unk_controller->ctrlrqueue = ctrlrqueue;
unk_controller->ctrlridx = ctrlridx;
- unk_controller->bytes[0x65] = (u8)0xff;
+ unk_controller->bytes[0x65] = 0xff;
unk_controller->unk0 = 0;
ret = func_80104C80(unk_controller, 0xfe);
@@ -83,37 +83,37 @@ s32 osProbeVibrationPack(OSMesgQueue* ctrlrqueue, unk_controller_t* unk_controll
if (ret != 0) {
return ret;
}
- ret = func_80105F40(ctrlrqueue, ctrlridx, 0x400, &sp24);
+ ret = osReadMempak(ctrlrqueue, ctrlridx, 0x400, &sp24);
ret = ret;
if (ret == 2) {
- ret = 4; //"Controller pack communication error"
+ ret = 4; // "Controller pack communication error"
}
if (ret != 0) {
return ret;
}
if (sp24.unk[0x1F] == 0xfe) {
- return 0xb; // possibly controller pack? (Some other valid return value other than vibration pack)
+ return 0xb; // possibly controller pack? (Some other valid return value other than rumble pak)
}
ret = func_80104C80(unk_controller, 0x80);
if (ret == 2) {
- ret = 4; //"Controller pack communication error"
+ ret = 4; // "Controller pack communication error"
}
if (ret != 0) {
return ret;
}
- ret = func_80105F40(ctrlrqueue, ctrlridx, 0x400, &sp24);
+ ret = osReadMempak(ctrlrqueue, ctrlridx, 0x400, &sp24);
if (ret == 2) {
- ret = 4; //"Controller pack communication error"
+ ret = 4; // "Controller pack communication error"
}
if (ret != 0) {
return ret;
}
if (sp24.unk[0x1F] != 0x80) {
- return 0xb; // possibly controller pack? (Some other valid return value other than vibration pack)
+ return 0xb; // possibly controller pack? (Some other valid return value other than rumble pak)
}
if ((unk_controller->unk0 & 8) == 0) {
osSetUpMempakWrite(ctrlridx, &osPifBuffers[ctrlridx]);
}
unk_controller->unk0 = 8;
- return 0; //"Recognized vibration pack"
+ return 0; // "Recognized rumble pak"
}
diff --git a/src/overlays/actors/ovl_En_Ani/z_en_ani.c b/src/overlays/actors/ovl_En_Ani/z_en_ani.c
index 54f1a750a..901f23c06 100644
--- a/src/overlays/actors/ovl_En_Ani/z_en_ani.c
+++ b/src/overlays/actors/ovl_En_Ani/z_en_ani.c
@@ -47,15 +47,8 @@ const ActorInit En_Ani_InitVars = {
};
static ColliderCylinderInit cylinderInitData = {
- 0x0A, 0x00, 0x11, 0x39,
- 0x10, 0x01, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0x00000000,
- 0x00, 0x00, 0x00, 0x00,
- 0xFFCFFFFF,
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x01, 0x01, 0x00,
- 0x001E, 0x0028, 0x0000,
+ 0x0A, 0x00, 0x11, 0x39, 0x10, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00000000, 0x00, 0x00,
+ 0x00, 0x00, 0xFFCFFFFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x001E, 0x0028, 0x0000,
};
static InitChainEntry initChain[] = {
@@ -63,9 +56,7 @@ static InitChainEntry initChain[] = {
ICHAIN_F32(unk_F4, 850, ICHAIN_STOP),
};
-static Vec3f EnAniVec = {
- 800.0f, 500.0f, 0.0f
-};
+static Vec3f EnAniVec = { 800.0f, 500.0f, 0.0f };
UNK_PTR D_809B0F80[] = {
0x06000408,