func_80237750

This commit is contained in:
Seeky 2023-08-24 19:17:10 +01:00
parent cd8b3b1a3e
commit c0fbeaf20e
2 changed files with 86 additions and 12 deletions

View File

@ -25,17 +25,21 @@ typedef struct
/* 0x0000 */ u32 flags;
/* 0x0004 */ u8 unknown_0x4[0x44 - 0x4];
/* 0x0044 */ bool enableRumble[4]; // index controller id, controller vibrates when true
/* 0x0000 */ bool rumblePrev[4]; // rumble enable flags from previous frame
/* 0x0000 */ Vec2 pointingPos[4]; // wii remote pointer positions
/* 0x0048 */ bool rumblePrev[4]; // rumble enable flags from previous frame
/* 0x004C */ Vec2 pointingPos[4]; // wii remote pointer positions
// controller input states, major index controller id, minor index age (latest is 0)
/* 0x0000 */ KPADStatus statuses[4][WPAD_STATUS_COUNT];
/* 0x0000 */ s32 kpadReadRet[4]; // last return from KPADRead for each controller
/* 0x0000 */ KPADStatus pastStatuses[4][60];
/* 0x0000 */ u32 unknown_0x9d3c[4];
/* 0x0000 */ s32 unknown_0x9d4c[4];
/* 0x0000 */ u8 unknown_0x9d5c[0x9d60 - 0x9d5c];
/* 0x0000 */ s64 unknown_0x9d60[4];
/* 0x0000 */ u8 unknown_0x9d80[0x9dc8 - 0x9d80];
/* 0x006C */ KPADStatus statuses[4][WPAD_STATUS_COUNT];
/* 0x216C */ s32 kpadReadRet[4]; // last return from KPADRead for each controller
/* 0x217C */ KPADStatus pastStatuses[4][60];
/* 0x9D3C */ u32 unknown_0x9d3c[4];
/* 0x9D4C */ s32 unknown_0x9d4c[4];
/* 0x9D5C */ u8 unknown_0x9d5c[0x9d60 - 0x9d5c];
/* 0x9D60 */ s64 unknown_0x9d60[4];
/* 0x9D80 */ f32 unknown_0x9d80[15];
/* 0x9DBC */ f32 unkknown_0x9dbc;
/* 0x9DC0 */ u8 unknown_0x9dc0;
/* 0x9DC1 */ u8 unknown_0x9dc1;
/* 0x9DC2 */ u8 unknown_0x9dc2[0x9dc8 - 0x9dc2];
} WpadWork;
SIZE_ASSERT(WpadWork, 0x9dc8)

View File

@ -4,6 +4,7 @@
#include <spm/wpadmgr.h>
#include <wii/kpad.h>
#include <wii/wpad.h>
#include <msl/math.h>
#include <msl/string.h>
// .rodata
@ -143,7 +144,76 @@ void func_80237710(s32 controller)
wp->unknown_0x9d60[controller] = gp->time;
}
asm bool func_80237750()
bool func_80237750()
{
#include "asm/80237750.s"
s32 q;
s32 i;
s32 count;
f32 x;
if (wp->unknown_0x9dc1 != 0 && wp->unknown_0x9d80[0] <= wp->unknown_0x9d80[1])
wp->unknown_0x9dc1 = 0;
if (wp->unkknown_0x9dbc > 0.0f)
{
wp->unkknown_0x9dbc -= 0.2f;
return 1;
}
if (wp->unknown_0x9dc1 != 0)
return 0;
for (i = 0; i < 14; i++)
{
if (wp->unknown_0x9d80[i] < wp->unknown_0x9d80[i+1])
break;
}
if (i == 0 || i >= 14)
return 0;
q = i;
count = 0;
for (;i < 14; i++)
{
if (wp->unknown_0x9d80[i] >= wp->unknown_0x9d80[i+1])
break;
if (fabsf(wp->unknown_0x9d80[i] - wp->unknown_0x9d80[i+1]) <= 0.01f)
{
if (++count > 1)
break;
}
else
{
count = 0;
}
}
if (i >= 14)
return 0;
if (wp->unknown_0x9d80[i] > wp->unknown_0x9d80[0])
return 0;
if (wp->unknown_0x9d80[i] - wp->unknown_0x9d80[q] < 0.1f)
return 0;
x = wp->unknown_0x9d80[0] - wp->unknown_0x9d80[q];
if (x < 1.0f)
return 0;
wp->unkknown_0x9dbc = x / q;
if (wp->unkknown_0x9dbc < 0.75f)
{
wp->unkknown_0x9dbc = 0.0f;
return 0;
}
if (wp->unkknown_0x9dbc > 3.0f)
wp->unkknown_0x9dbc *= 1.25f;
wp->unknown_0x9dc1 = 1;
return 1;
}