Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/melee/mp/forward.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ typedef struct mp_UnkStruct3 mp_UnkStruct3;
typedef struct mp_UnkStruct4 mp_UnkStruct4;
typedef struct mp_UnkStruct5 mp_UnkStruct5;
typedef struct mp_UnkStruct6 mp_UnkStruct6;
typedef struct mp_UnkStruct7 mp_UnkStruct7;
typedef struct mpisland mpisland;

typedef void (*mpLib_Callback)(s32, s32, CollData*, s32, s32, f32);
Expand Down
142 changes: 137 additions & 5 deletions src/melee/mp/mplib.c
Original file line number Diff line number Diff line change
@@ -1,14 +1,27 @@
#include "mp/forward.h"

#include "mplib.h"

#include "mp/types.h"

#include <dolphin/mtx/types.h>
#include <baselib/tev.h>
#include <baselib/texp.h>

/* 4D64B0 */ static int mpLib_804D64B0;
/* 4D64B4 */ static int mpLib_804D64B4;
/* 4D64B8 */ static int mpLib_804D64B8;
/* 4D64BC */ static mp_UnkStruct2* mpLib_804D64BC;
/* 4D64C0 */ static int mpLib_804D64C0;
/* 4D64C4 */ static mp_UnkStruct7* mpLib_804D64C4;
/* 4D64C8 */ static s32 mpLib_804D64C8;
/* 4D64CC */ static s32 mpLib_804D64CC;
/* 4D64D0 */ static s32 mpLib_804D64D0;
/* 4D64D4 */ static s32 mpLib_804D64D4;
/* 4D64D8 */ static s32 mpLib_804D64D8;
/* 4D64DC */ static s32 mpLib_804D64DC;
/* 4D64E0 */ static s32 mpLib_804D64E0;
/* 4D64E4 */ static s32 mpLib_804D64E4;

int mpLib_8004D164(void)
{
Expand Down Expand Up @@ -348,13 +361,113 @@ int mpLib_800588C8(void)
return mpLib_804D64B0;
}

/// #mpLib_800588D0
void mpLib_800588D0(f32 left, f32 bottom, f32 right, f32 top)
{
mp_UnkStruct7* curr = mpLib_804D64C4;

while (curr != NULL) {
s32 flags = curr->x8;

if ((flags & 0x10000) && !(flags & 0x40000)) {
if (flags & 0x400) {
curr->x8 = flags & 0xFFFFEFFF;
} else if ((left > curr->x18) || (right < curr->x10) ||
(bottom > curr->x1C) || (top < curr->x14))
{
curr->x8 |= 0x1000;
} else {
curr->x8 = flags & 0xFFFFEFFF;
}
} else {
curr->x8 |= 0x1000;
}

curr = curr->next;
}

mpLib_804D64B0 = 1;
}

void mpLib_80058970(f32 arg0, f32 arg1, f32 arg2, f32 arg3)
{
f32 right;
f32 left;
f32 bottom;
f32 var_f5;

left = arg2;
bottom = arg3;
if (arg0 > left) {
right = arg0;
} else {
right = left;
left = arg0;
}
if (arg1 > bottom) {
var_f5 = arg1;
} else {
var_f5 = bottom;
bottom = arg1;
}
mpLib_800588D0(left, bottom, right, var_f5);
}

void mpLib_800589D0(f32 arg0, f32 arg1, f32 arg2, f32 arg3, f32 arg4, f32 arg5,
f32 arg6, f32 arg7)
{
f32 right;
f32 left;
f32 bottom;
f32 top;

left = arg2;
bottom = arg3;
if (arg0 > left) {
right = arg0;
} else {
right = left;
left = arg0;
}
if (arg1 > bottom) {
top = arg1;
} else {
top = bottom;
bottom = arg1;
}
if (right < arg4) {
right = arg4;
} else if (left > arg4) {
left = arg4;
}
if (top < arg5) {
top = arg5;
} else if (bottom > arg5) {
bottom = arg5;
}
if (right < arg6) {
right = arg6;
} else if (left > arg6) {
left = arg6;
}
if (top < arg7) {
top = arg7;
} else if (bottom > arg7) {
bottom = arg7;
}
mpLib_800588D0(left, bottom, right, top);
}

/// #mpLib_80058970
void mpLib_80058AA0(void)
{
mp_UnkStruct7* curr = mpLib_804D64C4;

/// #mpLib_800589D0
while (curr != NULL) {
curr->x8 = curr->x8 & 0xFFFFEFFF;
curr = curr->next;
}

/// #mpLib_80058AA0
mpLib_804D64B0 = 0;
}

/// #mpLib_80058ACC

Expand All @@ -372,6 +485,25 @@ int mpLib_800588C8(void)

/// #mpLib_8005A220

/// #mpLib_8005A2DC
void mpLib_8005A2DC(void)
{
f32 temp_f1;

mpLib_800590F4();
temp_f1 = mpLib_80059E60();
if (mpLib_804D64D0 == 0) {
mpLib_804D64D0 = 1;
// Should the following be...
//
// "]ap coll unddr=%d upper=%d left=%d right=%d bbox-%d"
//
// instead? It looks like a clear typo on upper=$d, as suggested by the
// number of arguments.
OSReport("]ap coll unddr=%d upper=$d left=%d rhght=%d bbox-%d",
mpLib_804D64D4, mpLib_804D64D8, mpLib_804D64DC,
mpLib_804D64E0, mpLib_804D64E4);
}
HSD_StateInvalidate(-1);
}

/// #mpLib_8005A340
7 changes: 4 additions & 3 deletions src/melee/mp/mplib.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,15 +131,16 @@
/* 0588C8 */ int mpLib_800588C8(void);
/* 0588D0 */ void mpLib_800588D0(float left, float bottom, float right,
float top);
/* 058970 */ UNK_RET mpLib_80058970(UNK_PARAMS);
/* 0589D0 */ UNK_RET mpLib_800589D0(UNK_PARAMS);
/* 058970 */ void mpLib_80058970(f32 arg8, f32 arg9, f32 argA, f32 argB);
/* 0589D0 */ void mpLib_800589D0(f32 arg8, f32 arg9, f32 argA, f32 argB,
f32 argC, f32 argD, f32 argE, f32 argF);
/* 058AA0 */ void mpLib_80058AA0(void);
/* 058ACC */ UNK_RET mpLib_80058ACC(UNK_PARAMS);
/* 058B5C */ UNK_RET mpLib_80058B5C(UNK_PARAMS);
/* 0590F4 */ UNK_RET mpLib_800590F4(UNK_PARAMS);
/* 059404 */ UNK_RET mpLib_80059404(UNK_PARAMS);
/* 059554 */ UNK_RET mpLib_80059554(UNK_PARAMS);
/* 059E60 */ UNK_RET mpLib_80059E60(UNK_PARAMS);
/* 059E60 */ float mpLib_80059E60(UNK_PARAMS);
/* 059FE0 */ UNK_RET mpLib_80059FE0(UNK_PARAMS);
/* 05A220 */ UNK_RET mpLib_8005A220(UNK_PARAMS);
/* 05A2DC */ UNK_RET mpLib_8005A2DC(UNK_PARAMS);
Expand Down
11 changes: 11 additions & 0 deletions src/melee/mp/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,15 @@ struct mp_UnkStruct6 {
/* +4 */ short* x4;
};

struct mp_UnkStruct7 {
/* +0 */ struct mp_UnkStruct7* next;
/* +4 */ s32 x4;
/* +8 */ s32 x8;
/* +C */ u8 xC[0x10 - 0xC];
/* +10 */ float x10;
/* +14 */ float x14;
/* +18 */ float x18;
/* +1C */ float x1C;
};

#endif