Skip to content

Commit ae5b0ce

Browse files
emoosebelek666
andcommitted
bodyprog: match func_8006A1A4, dedupe s_func_8006DCE0_64 -> s_SubCharacter
Co-authored-by: belek666 <belek666@users.noreply.github.com>
1 parent 9e8299b commit ae5b0ce

2 files changed

Lines changed: 79 additions & 47 deletions

File tree

include/bodyprog/bodyprog.h

Lines changed: 10 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -350,25 +350,6 @@ typedef struct
350350
s16 field_36;
351351
} s_func_8006CC44_44;
352352

353-
typedef struct
354-
{
355-
s8 unk_0[22];
356-
s32 field_18;
357-
s32 field_1C;
358-
s32 field_20;
359-
s8 unk_24[164];
360-
s16 field_C8;
361-
s16 field_CA;
362-
s16 field_CC;
363-
s8 unk_CE[6];
364-
s16 field_D4;
365-
s16 field_D6;
366-
s16 field_D8;
367-
s16 field_DA;
368-
s16 field_DC;
369-
s16 field_DE;
370-
} s_func_8006DCE0_64; // Unknown size;
371-
372353
typedef struct
373354
{
374355
s32 field_0;
@@ -398,7 +379,7 @@ typedef struct
398379
s8 unk_18[4];
399380
s16 field_1C;
400381
s8 unk_1E[2];
401-
s_func_8006DCE0_64* field_20;
382+
s_SubCharacter* field_20;
402383
s16 field_24;
403384
s16 field_26;
404385
s32 field_28;
@@ -417,7 +398,7 @@ typedef struct
417398
s16 field_5E;
418399
s16 field_60;
419400
s8 unk_62[2];
420-
s_func_8006DCE0_64** field_64;
401+
s_SubCharacter** field_64;
421402
s32 field_68;
422403
s_func_8006DCE0_6C field_6C;
423404
s32 field_7C;
@@ -2425,6 +2406,10 @@ extern s16 D_800C4408;
24252406

24262407
extern s8 D_800C4414;
24272408

2409+
extern s_SubCharacter* D_800C4458;
2410+
2411+
extern s_SubCharacter** D_800C4474;
2412+
24282413
// emoose: Also works: `extern u16 D_800C4478[];`, `arg0->field_4 = D_800C4478[0];`.
24292414
// Didn't see any array accesses in Ghidra though, struct might be more likely.
24302415
extern s_800C4478 D_800C4478;
@@ -3564,7 +3549,7 @@ s32 func_80069FFC(s_800C4590* arg0, VECTOR3* arg1, s_SubCharacter* chara);
35643549

35653550
void func_8006A178(s_800C4590* arg0, s32 arg1, s32 arg2, s32 arg3, s32 arg4);
35663551

3567-
s32 func_8006A1A4(s32* arg0, s_SubCharacter* chara, s32 arg2);
3552+
s_SubCharacter** func_8006A1A4(s32* arg0, s_SubCharacter* chara, s32 arg2);
35683553

35693554
s32 func_8006A3B4(s32 arg0, VECTOR* arg1, s32 arg2);
35703555

@@ -3654,7 +3639,7 @@ bool func_8006DB3C(s_func_800700F8_2* arg0, VECTOR3* arg1, VECTOR3* arg2, s_SubC
36543639

36553640
bool func_8006DC18(s_func_800700F8_2* arg0, VECTOR3* vec1, VECTOR3* vec2);
36563641

3657-
bool func_8006DCE0(s_func_8006DCE0* arg0, s32 arg1, s16 arg2, VECTOR3* pos0, VECTOR3* pos1, s32 arg5, s32 arg6, s32 arg7, s32 arg8);
3642+
bool func_8006DCE0(s_func_8006DCE0* arg0, s32 arg1, s16 arg2, VECTOR3* pos0, VECTOR3* pos1, s32 arg5, s32 arg6, s_SubCharacter** arg7, s32 arg8);
36583643

36593644
bool func_8006DEB0(s_func_800700F8_2* arg0, s_func_8006DCE0* arg1);
36603645

@@ -3670,9 +3655,9 @@ void func_8006E78C(s_func_8006DCE0* arg0, s_IpdCollisionData_14* arg1, SVECTOR3*
36703655

36713656
void func_8006EB8C(s_func_8006DCE0* arg0, s_IpdCollisionData_18* arg1);
36723657

3673-
void func_8006EE0C(s_func_8006DCE0_6C* arg0, s32 arg1, s_func_8006DCE0_64* arg2);
3658+
void func_8006EE0C(s_func_8006DCE0_6C* arg0, s32 arg1, s_SubCharacter* arg2);
36743659

3675-
void func_8006EEB8(s_func_8006DCE0* arg0, s_func_8006DCE0_64* arg1);
3660+
void func_8006EEB8(s_func_8006DCE0* arg0, s_SubCharacter* arg1);
36763661

36773662
void func_8006F250(s_func_8006F250* arg0, s32 arg1, s32 arg2, s32 arg3, s32 arg4);
36783663

src/bodyprog/bodyprog_80055028.c

Lines changed: 69 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2905,7 +2905,54 @@ void func_8006A178(s_800C4590* arg0, s32 arg1, s32 arg2, s32 arg3, s32 arg4) //
29052905
arg0->field_C = arg4;
29062906
}
29072907

2908-
INCLUDE_ASM("asm/bodyprog/nonmatchings/bodyprog_80055028", func_8006A1A4); // 0x8006A1A4
2908+
s_SubCharacter** func_8006A1A4(s32* arg0, s_SubCharacter* chara, s32 arg2) // 0x8006A1A4
2909+
{
2910+
s_SubCharacter* otherChara;
2911+
2912+
if (chara != NULL &&
2913+
(chara->model_0.charaId_0 == 0 || chara->u_E1.s_0.field_E1_0 == 0 || (chara->u_E1.s_0.field_E1_0 == 1 && arg2 == 1)))
2914+
{
2915+
*arg0 = 0;
2916+
return &D_800C4458;
2917+
}
2918+
2919+
*arg0 = 0;
2920+
D_800C4474 = &D_800C4458;
2921+
2922+
for (otherChara = &g_SysWork.npcs_1A0[0]; otherChara < &g_SysWork.npcs_1A0[NPC_COUNT_MAX]; otherChara++)
2923+
{
2924+
if (otherChara->model_0.charaId_0 != 0)
2925+
{
2926+
if (otherChara->u_E1.s_0.field_E1_0 != 0 &&
2927+
(otherChara->u_E1.s_0.field_E1_0 != 1 || arg2 != 1) &&
2928+
otherChara != chara &&
2929+
(arg2 != 1 || chara == NULL || chara->u_E1.s_0.field_E1_0 != 4 || otherChara->u_E1.s_0.field_E1_0 >= chara->u_E1.s_0.field_E1_0))
2930+
{
2931+
*arg0 += 1;
2932+
*D_800C4474 = otherChara;
2933+
D_800C4474++;
2934+
otherChara->field_E0 = 0;
2935+
}
2936+
}
2937+
}
2938+
2939+
otherChara = &g_SysWork.player_4C.chara_0;
2940+
if (otherChara->model_0.charaId_0 != 0)
2941+
{
2942+
if (otherChara->u_E1.s_0.field_E1_0 != 0 &&
2943+
(otherChara->u_E1.s_0.field_E1_0 != 1 || arg2 != 1) &&
2944+
otherChara != chara &&
2945+
(arg2 != 1 || chara == NULL || chara->u_E1.s_0.field_E1_0 != 4 || otherChara->u_E1.s_0.field_E1_0 >= chara->u_E1.s_0.field_E1_0))
2946+
{
2947+
*arg0 += 1;
2948+
*D_800C4474 = otherChara;
2949+
D_800C4474++;
2950+
otherChara->field_E0 = 0;
2951+
}
2952+
}
2953+
2954+
return &D_800C4458;
2955+
}
29092956

29102957
s32 func_8006A3B4(s32 arg0, VECTOR* arg1, s32 arg2) // 0x8006A3B4
29112958
{
@@ -4805,10 +4852,10 @@ bool func_8006D90C(s_func_800700F8_2* arg0, VECTOR3* vec1, VECTOR3* vec2) // 0x8
48054852

48064853
bool func_8006DA08(s_func_800700F8_2* arg0, VECTOR3* vec1, VECTOR3* vec2, s_SubCharacter* chara) // 0x8006DA08
48074854
{
4808-
s32 sp28;
4809-
s32 temp_v0;
4810-
s32 scratchPrev;
4811-
s32 scratchAddr;
4855+
s32 sp28;
4856+
s_SubCharacter** temp_v0;
4857+
s32 scratchPrev;
4858+
s32 scratchAddr;
48124859

48134860
temp_v0 = func_8006A1A4(&sp28, chara, 0);
48144861

@@ -4850,10 +4897,10 @@ static inline void func_8006DB3C_Inline(s_func_800700F8_2* arg0, VECTOR3* arg1,
48504897

48514898
bool func_8006DB3C(s_func_800700F8_2* arg0, VECTOR3* arg1, VECTOR3* arg2, s_SubCharacter* chara) // 0x8006DB3C
48524899
{
4853-
s32 sp28;
4854-
s32 temp_s0;
4855-
s32 temp_v0;
4856-
s32 scratchAddr;
4900+
s32 sp28;
4901+
s32 temp_s0;
4902+
s_SubCharacter** temp_v0;
4903+
s32 scratchAddr;
48574904

48584905
temp_v0 = func_8006A1A4(&sp28, chara, 1);
48594906
arg0->field_0 = false;
@@ -4898,7 +4945,7 @@ bool func_8006DC18(s_func_800700F8_2* arg0, VECTOR3* vec1, VECTOR3* vec2) // 0x8
48984945
return arg0->field_0;
48994946
}
49004947

4901-
bool func_8006DCE0(s_func_8006DCE0* arg0, s32 arg1, s16 arg2, VECTOR3* pos0, VECTOR3* pos1, s32 arg5, s32 arg6, s32 arg7, s32 arg8)
4948+
bool func_8006DCE0(s_func_8006DCE0* arg0, s32 arg1, s16 arg2, VECTOR3* pos0, VECTOR3* pos1, s32 arg5, s32 arg6, s_SubCharacter** arg7, s32 arg8)
49024949
{
49034950
if (pos1->vx == 0 && pos1->vz == 0)
49044951
{
@@ -4959,7 +5006,7 @@ bool func_8006DEB0(s_func_800700F8_2* arg0, s_func_8006DCE0* arg1) // 0x8006DEB0
49595006
s32 sp10;
49605007
s32 temp_lo;
49615008
s_IpdCollisionData* temp_s1;
4962-
s_func_8006DCE0_64** var_s0_2;
5009+
s_SubCharacter** var_s0_2;
49635010
s_IpdCollisionData** temp_s5;
49645011
s_IpdCollisionData** var_s3;
49655012
s_func_8006DCE0_8C* var_s0;
@@ -5423,7 +5470,7 @@ void func_8006EB8C(s_func_8006DCE0* arg0, s_IpdCollisionData_18* arg1) // 0x8006
54235470
}
54245471
}
54255472

5426-
void func_8006EE0C(s_func_8006DCE0_6C* arg0, s32 arg1, s_func_8006DCE0_64* arg2) // 0x8006EE0C
5473+
void func_8006EE0C(s_func_8006DCE0_6C* arg0, s32 arg1, s_SubCharacter* arg2) // 0x8006EE0C
54275474
{
54285475
s32 var_a1;
54295476
s32 var_a3;
@@ -5434,25 +5481,25 @@ void func_8006EE0C(s_func_8006DCE0_6C* arg0, s32 arg1, s_func_8006DCE0_64* arg2)
54345481
if (arg1 == 1)
54355482
{
54365483
arg0->field_C = arg2->field_D4 >> 4;
5437-
var_a3 = arg2->field_DC;
5438-
var_a1 = arg2->field_DE;
5439-
var_v0 = arg2->field_1C + arg2->field_CA;
5484+
var_a3 = arg2->field_D8.field_4;
5485+
var_a1 = arg2->field_D8.field_6;
5486+
var_v0 = arg2->position_18.vy + arg2->field_CA;
54405487
}
54415488
else
54425489
{
54435490
arg0->field_C = arg2->field_D6 >> 4;
5444-
var_a3 = arg2->field_D8;
5445-
var_a1 = arg2->field_DA;
5446-
var_v0 = arg2->field_1C + arg2->field_CC;
5491+
var_a3 = arg2->field_D8.field_0;
5492+
var_a1 = arg2->field_D8.field_2;
5493+
var_v0 = arg2->position_18.vy + arg2->field_CC;
54475494
}
54485495

54495496
arg0->field_A = var_v0 >> 4;
5450-
arg0->field_0 = (arg2->field_18 + var_a3) >> 4;
5451-
arg0->field_4 = (arg2->field_20 + var_a1) >> 4;
5452-
arg0->field_8 = (arg2->field_1C + arg2->field_C8) >> 4;
5497+
arg0->field_0 = (arg2->position_18.vx + var_a3) >> 4;
5498+
arg0->field_4 = (arg2->position_18.vz + var_a1) >> 4;
5499+
arg0->field_8 = (arg2->position_18.vy + arg2->field_C8) >> 4;
54535500
}
54545501

5455-
void func_8006EEB8(s_func_8006DCE0* arg0, s_func_8006DCE0_64* arg1) // 0x8006EEB8
5502+
void func_8006EEB8(s_func_8006DCE0* arg0, s_SubCharacter* arg1) // 0x8006EEB8
54565503
{
54575504
VECTOR3 sp18;
54585505
s32 temp_t0;

0 commit comments

Comments
 (0)