Match m446dll/cursor.c

This commit is contained in:
CreateSource 2024-05-24 12:01:49 -04:00
parent 6e273405bc
commit 52015bfa2c
6 changed files with 256 additions and 26 deletions

View file

@ -220,15 +220,15 @@ lbl_1_rodata_250 = .rodata:0x00000250; // type:object size:0x4 scope:local data:
lbl_1_rodata_254 = .rodata:0x00000254; // type:object size:0x4 scope:local data:float
lbl_1_rodata_258 = .rodata:0x00000258; // type:object size:0x4 scope:local data:float
lbl_1_rodata_260 = .rodata:0x00000260; // type:object size:0x8 scope:local data:double
lbl_1_rodata_268 = .rodata:0x00000268; // type:object size:0x8 data:double
lbl_1_rodata_270 = .rodata:0x00000270; // type:object size:0x4 data:float
lbl_1_rodata_278 = .rodata:0x00000278; // type:object size:0x8 data:double
lbl_1_rodata_280 = .rodata:0x00000280; // type:object size:0x4 data:float
lbl_1_rodata_284 = .rodata:0x00000284; // type:object size:0x4 data:float
lbl_1_rodata_288 = .rodata:0x00000288; // type:object size:0x4 data:float
lbl_1_rodata_290 = .rodata:0x00000290; // type:object size:0x8 data:double
lbl_1_rodata_298 = .rodata:0x00000298; // type:object size:0x4 data:float
lbl_1_rodata_29C = .rodata:0x0000029C; // type:object size:0x4 data:float
lbl_1_rodata_268 = .rodata:0x00000268; // type:object size:0x8 scope:local data:double
lbl_1_rodata_270 = .rodata:0x00000270; // type:object size:0x4 scope:local data:float
lbl_1_rodata_278 = .rodata:0x00000278; // type:object size:0x8 scope:local data:double
lbl_1_rodata_280 = .rodata:0x00000280; // type:object size:0x4 scope:local data:float
lbl_1_rodata_284 = .rodata:0x00000284; // type:object size:0x4 scope:local data:float
lbl_1_rodata_288 = .rodata:0x00000288; // type:object size:0x4 scope:local data:float
lbl_1_rodata_290 = .rodata:0x00000290; // type:object size:0x8 scope:local data:double
lbl_1_rodata_298 = .rodata:0x00000298; // type:object size:0x4 scope:local data:float
lbl_1_rodata_29C = .rodata:0x0000029C; // type:object size:0x4 scope:local data:float
lbl_1_rodata_2A0 = .rodata:0x000002A0; // type:object size:0x4 data:float
lbl_1_rodata_2A4 = .rodata:0x000002A4; // type:object size:0x4 data:float
lbl_1_rodata_2A8 = .rodata:0x000002A8; // type:object size:0x4 data:float
@ -275,7 +275,7 @@ lbl_1_data_37C = .data:0x0000037C; // type:object size:0x1E scope:local data:str
lbl_1_data_39A = .data:0x0000039A; // type:object size:0x1E scope:local data:string
lbl_1_data_3B8 = .data:0x000003B8; // type:object size:0x10 scope:local data:string
lbl_1_data_3C8 = .data:0x000003C8; // type:object size:0x24
lbl_1_data_3EC = .data:0x000003EC; // type:object size:0x24
lbl_1_data_3EC = .data:0x000003EC; // type:object size:0x24 scope:local data:string
lbl_1_data_410 = .data:0x00000410; // type:object size:0x14
lbl_1_data_424 = .data:0x00000424; // type:object size:0x3C
lbl_1_data_460 = .data:0x00000460; // type:object size:0x54 data:byte
@ -303,5 +303,5 @@ lbl_1_bss_70 = .bss:0x00000070; // type:object size:0xC data:4byte
lbl_1_bss_7C = .bss:0x0000007C; // type:object size:0x4 data:float
lbl_1_bss_80 = .bss:0x00000080; // type:object size:0xC data:float
lbl_1_bss_8C = .bss:0x0000008C; // type:object size:0xC data:float
lbl_1_bss_98 = .bss:0x00000098; // type:object size:0x8 data:4byte
lbl_1_bss_98 = .bss:0x00000098; // type:object size:0x4 data:4byte
lbl_1_bss_A0 = .bss:0x000000A0; // type:object size:0x4 data:4byte

View file

@ -1194,7 +1194,7 @@ config.libs = [
Object(Matching, "REL/m446Dll/table.c"),
Object(Matching, "REL/m446Dll/player.c"),
Object(Matching, "REL/m446Dll/camera.c"),
Object(NonMatching, "REL/m446Dll/cursor.c"),
Object(Matching, "REL/m446Dll/cursor.c"),
Object(NonMatching, "REL/m446Dll/stage.c"),
},
),

View file

@ -91,10 +91,16 @@ typedef struct _unkStruct7 {
s8 field00_bit2 : 1;
s8 field00_bit3 : 1;
};
char unk1[0x1F];
s32 unk4;
s32 unk8;
s16 unkC[9];
Vec unk20;
char unk24[0x18];
Vec unk2C;
Vec unk38;
f32 unk44;
u8 unk48;
f32 unk4C;
f32 unk50;
} unkStruct7;
typedef struct _unkStruct8 {
@ -137,7 +143,6 @@ typedef struct _unkStruct8 {
f32 unkC0;
f32 unkC4;
s32 unkC8;
char unkCC[0x4];
} unkStruct8;
typedef void (*m446Func)(s32);
@ -147,6 +152,8 @@ typedef void (*m446Func8)(unkStruct8*);
////// BSS //////
// cursor.c
extern unkStruct3* lbl_1_bss_98;
// camera.c
extern Vec lbl_1_bss_8C;
extern Vec lbl_1_bss_80;
extern f32 lbl_1_bss_7C;
@ -193,6 +200,10 @@ extern m446Func4 lbl_1_data_150[3];
extern s32 lbl_1_data_228[9];
extern s32 lbl_1_data_24C[9][4];
extern m446Func8 lbl_1_data_2DC[5];
// camera.c
extern Vec lbl_1_data_370;
// cursor.c
extern s32 lbl_1_data_3C8[9];
////// PROTOTYPES //////
// main.c
@ -304,4 +315,16 @@ extern void fn_1_6EC4(Vec*);
extern void fn_1_6EE8(f32);
extern void fn_1_6EF8(Vec*, Vec*, f32*, s32);
extern s32 fn_1_708C(void);
extern void fn_1_709C(void);
extern void fn_1_709C(void);
// cursor.c
extern s32 fn_1_72E0(void);
extern void fn_1_72F8(void);
extern void fn_1_7350(void);
extern unkStruct7* fn_1_74F4(s32);
extern void fn_1_76E8(unkStruct7*);
extern void fn_1_77C8(unkStruct7*, u8);
extern void fn_1_7884(unkStruct7*);
extern void fn_1_7908(unkStruct7*, Vec*, s32);
extern void fn_1_799C(unkStruct7*);
extern void fn_1_7A38(unkStruct7*);
extern void fn_1_7AB4(unkStruct7*);

217
src/REL/m446Dll/cursor.c Normal file
View file

@ -0,0 +1,217 @@
#include "REL/m446Dll.h"
#include "math.h"
#include "game/hsfman.h"
#include "game/hsfmotion.h"
// bss
unkStruct3* lbl_1_bss_98;
// data
s32 lbl_1_data_3C8[9] = {
0x4D0012, 0x4D0013, 0x4D0014,
0x4D0015, 0x4D0016, 0x4D0017,
0x4D0018, 0x4D0019, 0x4D001A
};
s32 fn_1_72E0(void) {
lbl_1_bss_98 = NULL;
return 1;
}
void fn_1_72F8(void) {
unkStruct3* var_r31;
unkStruct7* var_r30;
var_r31 = lbl_1_bss_98;
if (var_r31) {
do {
var_r30 = var_r31->unk0;
fn_1_76E8(var_r30);
var_r31 = var_r31->unk8;
} while (var_r31);
}
}
void fn_1_7350(void) {
f32 temp_f31;
unkStruct3* var_r30;
unkStruct7* temp_r31;
var_r30 = lbl_1_bss_98;
if (var_r30) {
do {
temp_r31 = var_r30->unk0;
if (temp_r31->field00_bit1 != 0) {
temp_f31 = sin((M_PI * (90.0f * temp_r31->unk4C)) / 180.0);
temp_f31 *= temp_f31;
temp_r31->unk20.x = (temp_r31->unk2C.x + (temp_f31 * (temp_r31->unk38.x - temp_r31->unk2C.x)));
temp_r31->unk20.y = (temp_r31->unk2C.y + (temp_f31 * (temp_r31->unk38.y - temp_r31->unk2C.y)));
temp_r31->unk20.z = (temp_r31->unk2C.z + (temp_f31 * (temp_r31->unk38.z - temp_r31->unk2C.z)));
temp_r31->unk4C += temp_r31->unk50;
if (temp_r31->unk4C >= 1.0f) {
temp_r31->unk20.x = temp_r31->unk38.x;
temp_r31->unk20.y = temp_r31->unk38.y;
temp_r31->unk20.z = temp_r31->unk38.z;
temp_r31->field00_bit1 = 0;
}
}
if ((temp_r31->unk8 == 0) && (temp_r31->field00_bit3 != 0) && (Hu3DMotionEndCheck(temp_r31->unkC[1]) != 0)) {
fn_1_7884(temp_r31);
}
fn_1_7AB4(temp_r31);
var_r30 = var_r30->unk8;
} while (var_r30);
}
}
unkStruct7* fn_1_74F4(s32 arg0) {
s32 var_r30;
unkStruct7* var_r31;
unkStruct3* var_r29;
var_r31 = HuMemDirectMallocNum(HEAP_SYSTEM, 0x54, 0x10000000);
if (!var_r31) {
return NULL;
}
var_r31->unk4 = 0;
var_r31->unk20.x = 0.0f;
var_r31->unk20.y = 72.0f;
var_r31->unk20.z = 0.0f;
var_r31->unk44 = 1.0f;
var_r31->field00_bit1 = 0;
var_r31->field00_bit2 = 0;
var_r31->field00_bit3 = 0;
var_r31->unk8 = arg0;
var_r31->unk48 = 0;
var_r31->unkC[0] = Hu3DModelCreateFile(0x4D0009);
Hu3DModelLayerSet(var_r31->unkC[0], 6);
if (var_r31->unk8 == 0) {
for (var_r30 = 0; var_r30 < 9; var_r30++) {
var_r31->unkC[var_r30 + 1] = Hu3DModelCreateFile(lbl_1_data_3C8[var_r30]);
Hu3DModelLayerSet(var_r31->unkC[var_r30 + 1], 7);
}
}
fn_1_77C8(var_r31, 0);
var_r29 = fn_1_1DF4(var_r31);
if (!var_r29) {
OSReport("[!] m446CursorCreate ERROR...\n");
HuMemDirectFree(var_r31);
return NULL;
}
if (lbl_1_bss_98) {
fn_1_1EC8(lbl_1_bss_98, var_r29);
} else {
lbl_1_bss_98 = var_r29;
}
return var_r31;
}
void fn_1_76E8(unkStruct7* arg0) {
s32 var_r29;
unkStruct3* var_r31;
var_r31 = lbl_1_bss_98;
if (var_r31) {
do {
if (arg0 == var_r31->unk0) {
if (var_r31 == lbl_1_bss_98) {
lbl_1_bss_98 = var_r31->unk8;
}
fn_1_1F04(var_r31);
fn_1_1E5C(var_r31);
Hu3DModelKill(arg0->unkC[0]);
if (arg0->unk8 == 0) {
for (var_r29 = 0; var_r29 < 9; var_r29++) {
Hu3DModelKill(arg0->unkC[var_r29 + 1]);
}
}
HuMemDirectFree(arg0);
return;
}
var_r31 = var_r31->unk8;
} while (var_r31);
}
}
void fn_1_77C8(unkStruct7* arg0, u8 arg1) {
s32 var_r30;
arg0->field00_bit0 = 1;
arg0->unk48 = arg1;
Hu3DModelAttrReset(arg0->unkC[0], 1);
if (arg0->unk8 == 0) {
for (var_r30 = 0; var_r30 < 9; var_r30++) {
if (var_r30 == arg1) {
Hu3DModelAttrReset(arg0->unkC[var_r30 + 1], 1);
} else {
Hu3DModelAttrSet(arg0->unkC[var_r30 + 1], 1);
}
}
}
}
void fn_1_7884(unkStruct7* arg0) {
s32 var_r30;
arg0->field00_bit0 = 0;
Hu3DModelAttrSet(arg0->unkC[0], 1);
if (arg0->unk8 == 0) {
for (var_r30 = 0; var_r30 < 9; var_r30++) {
Hu3DModelAttrSet(arg0->unkC[var_r30 + 1], 1);
}
}
}
void fn_1_7908(unkStruct7* arg0, Vec* arg1, s32 arg2) {
arg0->unk38 = *arg1;
arg0->unk2C = arg0->unk20;
arg0->unk4C = 0.0f;
arg0->unk50 = (1.0f / arg2);
arg0->field00_bit1 = 1;
}
void fn_1_799C(unkStruct7* arg0) {
s32 var_r30;
if (arg0->unk8 == 0) {
for (var_r30 = 0; var_r30 < 9; var_r30++) {
Hu3DModelAttrReset(arg0->unkC[var_r30 + 1], 0x40000002);
Hu3DMotionTimeSet(arg0->unkC[var_r30 + 1], 0.0f);
}
}
arg0->field00_bit3 = 1;
}
void fn_1_7A38(unkStruct7* arg0) {
s32 var_r31;
if (arg0->unk8 == 0) {
for (var_r31 = 0; var_r31 < 9; var_r31++) {
Hu3DModelAttrSet(arg0->unkC[var_r31 + 1], 0x40000002);
}
}
arg0->field00_bit3 = 0;
}
void fn_1_7AB4(unkStruct7* arg0) {
f32 var_f31;
s32 temp_r29;
s32 var_r30;
Hu3DModelPosSet(arg0->unkC[0], arg0->unk20.x, arg0->unk20.y, arg0->unk20.z);
Hu3DModelScaleSet(arg0->unkC[0], arg0->unk44, arg0->unk44, arg0->unk44);
if (arg0->unk8 == 0) {
for (var_r30 = 0; var_r30 < 9; var_r30++) {
temp_r29 = var_r30 + 1;
Hu3DModelPosSet(arg0->unkC[temp_r29], arg0->unk20.x, 0.1f + arg0->unk20.y, arg0->unk20.z);
Hu3DModelScaleSet(arg0->unkC[temp_r29], arg0->unk44, arg0->unk44, arg0->unk44);
if (arg0->field00_bit2 != 0) {
var_f31 = 180.0f;
} else {
var_f31 = 0.0f;
}
Hu3DModelRotSet(arg0->unkC[temp_r29], 0.0f, var_f31, 0.0f);
}
}
}

View file

@ -10,10 +10,6 @@
#include "game/frand.h"
#include "game/minigame_seq.h"
// cursor.c
extern s32 fn_1_72E0(void);
extern void fn_1_72F8(void);
extern void fn_1_7350(void);
// stage.c
extern s32 fn_1_7BF0(void);
extern void fn_1_7C08(void);

View file

@ -5,12 +5,6 @@
// bss
unkStruct3* lbl_1_bss_28;
// cursor.c
extern unkStruct7 *fn_1_74F4(s32);
extern void fn_1_76E8(unkStruct7*);
extern void fn_1_77C8(void*, u8);
extern void fn_1_7884(unkStruct7*);
s32 fn_1_3924(void) {
lbl_1_bss_28 = NULL;
return 1;