Skip to content

Commit

Permalink
Match func_8007C4A4 & func_80095AE0 (#618)
Browse files Browse the repository at this point in the history
* Match funcs

* Add ub fix
  • Loading branch information
MegaMech authored Apr 21, 2024
1 parent d08be66 commit cda6a50
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 167 deletions.
62 changes: 0 additions & 62 deletions asm/non_matchings/code_80091750/func_80095AE0.s

This file was deleted.

47 changes: 0 additions & 47 deletions asm/non_matchings/update_objects/func_8007C4A4.s

This file was deleted.

84 changes: 49 additions & 35 deletions src/code_80091750.c
Original file line number Diff line number Diff line change
Expand Up @@ -2814,45 +2814,59 @@ Gfx *func_800959F8(Gfx *displayListHead, Vtx *arg1) {
return displayListHead;
}

#ifdef MIPS_TO_C
//generated by m2c commit eefca95b040d7ee0c617bc58f9ac6cd1cf7bce87 on Sep-01-2023
void func_80095AE0(Mtx *arg0, f32 arg1, f32 arg2, f32 arg3, f32 arg4) {
s32 sp14;
s32 sp10;
s32 spC;
s32 sp8;
Mtx *var_v1;
s32 var_v0;
typedef struct {
u16 i[4][4];
u16 f[4][4];
} Mtx_u;

typedef union {
Mtx_u u;
Mtx_t m;
long long int force_structure_alignment;
} Mtx2;

typedef union {
s16 s[2];
s32 w;
} TheWhyUnion;

// Why... Why... Why... This function is so bad it's not going in the header.
void func_80095AE0(Mtx2 *arg0, f32 arg1, f32 arg2, f32 arg3, f32 arg4) {
TheWhyUnion sp14;
TheWhyUnion sp10;
TheWhyUnion spC;
TheWhyUnion sp8;
s32 i;

var_v0 = 0;
var_v1 = arg0;
do {
var_v0 += 4;
var_v1->m[0][0] = 0;
var_v1->m[0][1] = 0;
var_v1->m[0][2] = 0;
var_v1->m[0][3] = 0;
var_v1 += 0x10;
} while (var_v0 != 0x10);
sp14 = (s32) (arg3 * 65536.0f);
sp10 = (s32) (arg4 * 65536.0f);
spC = (s32) (arg1 * 65536.0f);
sp8 = (s32) (arg2 * 65536.0f);
arg0->unk0 = (s16) sp14.unk0;
arg0->unk14 = 1;
arg0->unkA = (s16) sp10.unk0;
arg0->unk18 = (s16) spC.unk0;
arg0->unk1E = 1;
arg0->unk1A = (s16) sp8.unk0;
arg0->unk20 = (s16) sp14.unk2;
arg0->unk2A = (s16) sp10.unk2;
arg0->unk38 = (s16) spC.unk2;
arg0->unk3A = (s16) sp8.unk2;
}

#ifdef AVOID_UB
for (int row = 0; row < 4; row++) {
for (int col = 0; col < 4; col++) {
arg0->m[row][col] = 0;
}
}
#else
GLOBAL_ASM("asm/non_matchings/code_80091750/func_80095AE0.s")
for(i = 0; i < 16; i++) {\
arg0->m[0][i] = 0;
}
#endif

sp14.w = arg3 * 65536.0f;
sp10.w = arg4 * 65536.0f;
spC.w = arg1 * 65536.0f;
sp8.w = arg2 * 65536.0f;
arg0->u.i[0][0] = sp14.s[0];
arg0->u.i[1][1] = sp10.s[0];
arg0->u.i[2][2] = 1;
arg0->u.i[3][0] = spC.s[0];
arg0->u.i[3][1] = sp8.s[0];
arg0->u.i[3][3] = 1;
arg0->u.f[0][0] = sp14.s[1];
arg0->u.f[1][1] = sp10.s[1];
arg0->u.f[3][0] = spC.s[1];
arg0->u.f[3][1] = sp8.s[1];
}

Gfx *func_80095BD0(Gfx *displayListHead, u8 *arg1, f32 arg2, f32 arg3, u32 arg4, u32 arg5, f32 arg6, f32 arg7) {
Vtx *var_a1;
Mtx *sp28;
Expand Down
1 change: 0 additions & 1 deletion src/code_80091750.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,6 @@ Gfx *draw_flash_select_case(Gfx*, s32, s32, s32, s32, s32);
Gfx *draw_flash_select_case_slow(Gfx*, s32, s32, s32, s32);
Gfx *draw_flash_select_case_fast(Gfx*, s32, s32, s32, s32);
Gfx *func_800959F8(Gfx*, Vtx*);
void func_80095AE0(Mtx*, f32, f32, f32, f32);
Gfx *func_80095BD0(Gfx*, u8*, f32, f32, u32, u32, f32, f32);
Gfx *func_80095E10(Gfx*, s8, s32, s32, s32, s32, s32, s32, s32, s32, u8 *, u32, u32);
Gfx *func_800963F0(Gfx*, s8, s32, s32, f32, f32, s32, s32, s32, s32, s32, s32, u8 *, u32, u32);
Expand Down
31 changes: 9 additions & 22 deletions src/update_objects.c
Original file line number Diff line number Diff line change
Expand Up @@ -4186,32 +4186,19 @@ UNUSED void func_8007C49C(void) {

}

#ifdef NON_MATCHING
// https://decomp.me/scratch/IH8Vx
// No idea what the source of the diff is
void func_8007C4A4(s32 objectIndex) {
s32 temp_t8;
s32 var_t1;
u16 var_t9;

temp_t8 = gObjectList[objectIndex].direction_angle[1] * 0x24;
var_t1 = temp_t8 >> 0x10;
if (temp_t8 < 0) {
var_t1 = temp_t8 + 0xFFFF;
var_t1 >>= 0x10;
}
var_t1 &= 0xFFFF;
if (var_t1 < 0x13) {
set_object_flag_status_false(objectIndex, 0x80);
gObjectList[objectIndex].itemDisplay = var_t1;
}
else {
set_object_flag_status_true(objectIndex, 0x80);
gObjectList[objectIndex].itemDisplay = 0x24 - var_t1;
var_t9 = gObjectList[objectIndex].unk_0BE[1] * 0x24 / 0x10000;

if (var_t9 < 0x13) {
set_object_flag_unk_054_false(objectIndex, 0x80);
gObjectList[objectIndex].itemDisplay = var_t9;
} else {
set_object_flag_unk_054_true(objectIndex, 0x80);
gObjectList[objectIndex].itemDisplay = 0x24 - var_t9;
}
}
#else
GLOBAL_ASM("asm/non_matchings/update_objects/func_8007C4A4.s")
#endif

void func_8007C550(s32 objectIndex) {
gObjectList[objectIndex].direction_angle[1] = func_800417B4(gObjectList[objectIndex].direction_angle[1], atan2s(gObjectList[objectIndex].velocity[0], gObjectList[objectIndex].velocity[2]));
Expand Down

0 comments on commit cda6a50

Please sign in to comment.