mirror of
https://github.com/zeldaret/oot.git
synced 2025-07-05 07:24:34 +00:00
Decompile code_800D2E30 and use struct in code_800A9F30 (#80)
* Match func_800AA000 * Match z_camera/func_800437F0 * Decompile code_800D2E30, use struct in 800A9F30 * Format * Remove 'U' from literals * Remove bss, cleanup z_camera * Review changes, rename temp * Move externs to variables.h
This commit is contained in:
parent
21750d5aee
commit
eefbe9afe1
12 changed files with 197 additions and 424 deletions
|
@ -1,12 +1,11 @@
|
|||
#include <ultra64.h>
|
||||
#include <global.h>
|
||||
|
||||
extern u8 D_80160FD0[];
|
||||
extern PadMgr gPadMgr;
|
||||
UnkRumbleStruct D_80160FD0;
|
||||
|
||||
void func_800A9F30(s32 a, s32 b) {
|
||||
void func_800A9F30(PadMgr* a, s32 b) {
|
||||
func_800D2E30(&D_80160FD0);
|
||||
PadMgr_RumbleSet(a, &D_80160FD0);
|
||||
PadMgr_RumbleSet(a, D_80160FD0.rumbleEnable);
|
||||
}
|
||||
|
||||
void func_800A9F6C(f32 a, u8 b, u8 c, u8 d) {
|
||||
|
@ -21,20 +20,43 @@ void func_800A9F6C(f32 a, u8 b, u8 c, u8 d) {
|
|||
if ((temp1 < 1000) && (b != 0) && (d != 0)) {
|
||||
temp2 = b - (temp1 * 255) / 1000;
|
||||
if (temp2 > 0) {
|
||||
D_801610DA = temp2;
|
||||
D_80160FD0[0x10B] = c;
|
||||
D_80160FD0[0x10C] = d;
|
||||
D_80160FD0.unk_10A = temp2;
|
||||
D_80160FD0.unk_10B = c;
|
||||
D_80160FD0.unk_10C = d;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_800A9F30/func_800AA000.s")
|
||||
// this function is very similar to the one above but has a loop in it I can't figure out
|
||||
void func_800AA000(float a, u8 b, u8 c, u8 d) {
|
||||
s32 temp1;
|
||||
s32 temp2;
|
||||
s32 i;
|
||||
if (1000000.0f < a) {
|
||||
temp1 = 1000;
|
||||
} else {
|
||||
temp1 = sqrtf(a);
|
||||
}
|
||||
|
||||
if (temp1 < 1000 && b != 0 && d != 0) {
|
||||
temp2 = b - (temp1 * 255) / 1000;
|
||||
|
||||
for (i = 0; i < 0x40; i++) {
|
||||
if (D_80160FD0.unk_04[i] == 0) {
|
||||
if (temp2 > 0) {
|
||||
D_80160FD0.unk_04[i] = temp2;
|
||||
D_80160FD0.unk_44[i] = c;
|
||||
D_80160FD0.unk_84[i] = d;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void func_800AA0B4(void) {
|
||||
func_800D3140(&D_80160FD0);
|
||||
|
||||
gPadMgr.retraceCallback = func_800A9F30;
|
||||
gPadMgr.retraceCallback = (void*)func_800A9F30;
|
||||
gPadMgr.retraceCallbackValue = 0;
|
||||
|
||||
if (0) {} // Necessary to match
|
||||
|
@ -52,17 +74,17 @@ void func_800AA0F0(void) {
|
|||
}
|
||||
|
||||
u32 func_800AA148(void) {
|
||||
return ((gPadMgr.pakType[0] ^ 1) == 0);
|
||||
return gPadMgr.pakType[0] == 1;
|
||||
}
|
||||
|
||||
void func_800AA15C(void) {
|
||||
D_801610D4 = 2;
|
||||
D_80160FD0.unk_104 = 2;
|
||||
}
|
||||
|
||||
void func_800AA16C(void) {
|
||||
D_801610D4 = 0;
|
||||
D_80160FD0.unk_104 = 0;
|
||||
}
|
||||
|
||||
void func_800AA178(u32 a) {
|
||||
D_801610D5 = !!a;
|
||||
D_80160FD0.unk_105 = !!a;
|
||||
}
|
||||
|
|
124
src/code/code_800D2E30.c
Normal file
124
src/code/code_800D2E30.c
Normal file
|
@ -0,0 +1,124 @@
|
|||
#include <ultra64.h>
|
||||
#include <global.h>
|
||||
|
||||
void func_800D2E30(UnkRumbleStruct* arg0) {
|
||||
s32 i;
|
||||
s32 unk_a3;
|
||||
s32 index = -1;
|
||||
UnkRumbleStruct* new_var;
|
||||
|
||||
for (i = 0; i < 4; i++) {
|
||||
arg0->rumbleEnable[i] = 0;
|
||||
}
|
||||
|
||||
if (arg0->unk_105 == 0) {
|
||||
new_var = arg0;
|
||||
if (D_8012DBB0 != 0) {
|
||||
for (i = 0; i < 4; i++) {
|
||||
gPadMgr.pakType[i] = 0;
|
||||
}
|
||||
}
|
||||
D_8012DBB0 = new_var->unk_105;
|
||||
return;
|
||||
}
|
||||
D_8012DBB0 = arg0->unk_105;
|
||||
|
||||
if (arg0->unk_104 == 2) {
|
||||
for (i = 0; i < 4; ++i) {
|
||||
gPadMgr.pakType[i] = 0;
|
||||
}
|
||||
|
||||
for (i = 0; i < 0x40; i++) {
|
||||
arg0->unk_C4[i] = 0;
|
||||
arg0->unk_84[i] = 0;
|
||||
arg0->unk_44[i] = 0;
|
||||
arg0->unk_04[i] = 0;
|
||||
}
|
||||
arg0->unk_106 = arg0->unk_108 = arg0->unk_10A = arg0->unk_10B = arg0->unk_10C = arg0->unk_10D = 0;
|
||||
arg0->unk_104 = 1;
|
||||
}
|
||||
if (arg0->unk_104 != 0) {
|
||||
for (i = 0; i < 0x40; i++) {
|
||||
|
||||
if (arg0->unk_04[i] != 0) {
|
||||
if (arg0->unk_44[i] > 0) {
|
||||
arg0->unk_44[i]--;
|
||||
} else {
|
||||
unk_a3 = arg0->unk_04[i] - arg0->unk_84[i];
|
||||
if (unk_a3 > 0) {
|
||||
arg0->unk_04[i] = unk_a3;
|
||||
} else {
|
||||
arg0->unk_04[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
unk_a3 = arg0->unk_C4[i] + arg0->unk_04[i];
|
||||
arg0->unk_C4[i] = unk_a3;
|
||||
if (index == -1) {
|
||||
index = i;
|
||||
arg0->rumbleEnable[0] = (unk_a3 >= 0x100);
|
||||
} else {
|
||||
|
||||
if (arg0->unk_04[index] < arg0->unk_04[i]) {
|
||||
index = i;
|
||||
arg0->rumbleEnable[0] = (unk_a3 >= 0x100);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (arg0->unk_10A != 0) {
|
||||
if (arg0->unk_10B > 0) {
|
||||
arg0->unk_10B--;
|
||||
} else {
|
||||
unk_a3 = arg0->unk_10A - arg0->unk_10C;
|
||||
if (unk_a3 > 0) {
|
||||
arg0->unk_10A = unk_a3;
|
||||
} else {
|
||||
arg0->unk_10A = 0;
|
||||
}
|
||||
}
|
||||
unk_a3 = arg0->unk_10D + arg0->unk_10A;
|
||||
arg0->unk_10D = unk_a3;
|
||||
arg0->rumbleEnable[0] = (unk_a3 >= 0x100);
|
||||
}
|
||||
if (arg0->unk_10A != 0) {
|
||||
unk_a3 = arg0->unk_10A;
|
||||
} else {
|
||||
if (index == -1) {
|
||||
unk_a3 = 0;
|
||||
} else {
|
||||
unk_a3 = arg0->unk_04[index];
|
||||
}
|
||||
}
|
||||
if (unk_a3 == 0) {
|
||||
if ((++arg0->unk_108) >= 6) {
|
||||
arg0->unk_106 = 0;
|
||||
arg0->unk_108 = 5;
|
||||
}
|
||||
} else {
|
||||
arg0->unk_108 = 0;
|
||||
if ((++arg0->unk_106) >= 0x1C21) {
|
||||
arg0->unk_104 = 0;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (i = 0; i < 0x40; i++) {
|
||||
arg0->unk_C4[i] = 0;
|
||||
arg0->unk_84[i] = 0;
|
||||
arg0->unk_44[i] = 0;
|
||||
arg0->unk_04[i] = 0;
|
||||
}
|
||||
|
||||
arg0->unk_106 = arg0->unk_108 = arg0->unk_10A = arg0->unk_10B = arg0->unk_10C = arg0->unk_10D = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void func_800D3140(UnkRumbleStruct* arg0) {
|
||||
bzero(arg0, sizeof(UnkRumbleStruct));
|
||||
arg0->unk_104 = 2;
|
||||
arg0->unk_105 = 1;
|
||||
}
|
||||
|
||||
void func_800D3178(UnkRumbleStruct* arg0) {
|
||||
bzero(arg0, sizeof(UnkRumbleStruct));
|
||||
}
|
|
@ -22,9 +22,20 @@ typedef struct {
|
|||
Vec3s pos;
|
||||
} SplineData; // originally called SplinedatZ
|
||||
|
||||
// 47 lines
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800437F0.s")
|
||||
// had an attempt at this but didn't get very close
|
||||
f32 func_800437F0(f32 arg0, f32 arg1) {
|
||||
f32 percent = 0.4f;
|
||||
f32 ret = fabsf(arg1);
|
||||
|
||||
if (arg0 < ret) {
|
||||
ret = 1;
|
||||
} else if (ret < (f32)arg0 * (1 - percent)) { //! float cast needed to match
|
||||
ret = (SQ(arg1) * (1 - percent)) / SQ((1 - percent) * arg0);
|
||||
} else {
|
||||
ret = 1 - (0.4f * SQ(arg0 - ret)) / SQ(0.4f * arg0);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
f32 func_8004389C(f32 a, f32 b, f32 c, f32 d) {
|
||||
f32 temp1 = a - b;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue