From b923157c6781fbf9783b2554b1e5abbdc59f1449 Mon Sep 17 00:00:00 2001 From: MegaMech Date: Tue, 2 Jan 2024 15:45:46 -0700 Subject: [PATCH] Match func_8000BBD8 (#526) * Renames * match func --- .../code_80005FD0/func_8000BBD8.s | 114 ------------------ .../hud_renderer/func_8004F168.s | 16 +-- assets/include/minimap_icons.mk | 2 +- assets/minimap_icons.json | 2 +- src/code_80005FD0.c | 79 ++++++------ src/common_textures.h | 4 +- src/data/common_textures.inc.c | 8 +- src/hud_renderer.c | 85 +++++++------ 8 files changed, 96 insertions(+), 214 deletions(-) delete mode 100644 asm/non_matchings/code_80005FD0/func_8000BBD8.s diff --git a/asm/non_matchings/code_80005FD0/func_8000BBD8.s b/asm/non_matchings/code_80005FD0/func_8000BBD8.s deleted file mode 100644 index 71d7628c6..000000000 --- a/asm/non_matchings/code_80005FD0/func_8000BBD8.s +++ /dev/null @@ -1,114 +0,0 @@ -glabel func_8000BBD8 -/* 00C7D8 8000BBD8 27BDFFD8 */ addiu $sp, $sp, -0x28 -/* 00C7DC 8000BBDC AFA40028 */ sw $a0, 0x28($sp) -/* 00C7E0 8000BBE0 308EFFFF */ andi $t6, $a0, 0xffff -/* 00C7E4 8000BBE4 25C40001 */ addiu $a0, $t6, 1 -/* 00C7E8 8000BBE8 308DFFFF */ andi $t5, $a0, 0xffff -/* 00C7EC 8000BBEC 00067C00 */ sll $t7, $a2, 0x10 -/* 00C7F0 8000BBF0 000FC403 */ sra $t8, $t7, 0x10 -/* 00C7F4 8000BBF4 000E38C0 */ sll $a3, $t6, 3 -/* 00C7F8 8000BBF8 00187040 */ sll $t6, $t8, 1 -/* 00C7FC 8000BBFC 3C0F8016 */ lui $t7, %hi(gWaypointCountByPathIndex) # 0x8016 -/* 00C800 8000BC00 01EE7821 */ addu $t7, $t7, $t6 -/* 00C804 8000BC04 95EF45C8 */ lhu $t7, %lo(gWaypointCountByPathIndex)($t7) # 0x45c8($t7) -/* 00C808 8000BC08 AFA5002C */ sw $a1, 0x2c($sp) -/* 00C80C 8000BC0C 3C058016 */ lui $a1, %hi(D_80164560) # 0x8016 -/* 00C810 8000BC10 01AF001A */ div $zero, $t5, $t7 -/* 00C814 8000BC14 00181880 */ sll $v1, $t8, 2 -/* 00C818 8000BC18 00A32821 */ addu $a1, $a1, $v1 -/* 00C81C 8000BC1C 3C098016 */ lui $t1, %hi(D_80164570) # 0x8016 -/* 00C820 8000BC20 8CA54560 */ lw $a1, %lo(D_80164560)($a1) # 0x4560($a1) -/* 00C824 8000BC24 01234821 */ addu $t1, $t1, $v1 -/* 00C828 8000BC28 8D294570 */ lw $t1, %lo(D_80164570)($t1) # 0x4570($t1) -/* 00C82C 8000BC2C AFA60030 */ sw $a2, 0x30($sp) -/* 00C830 8000BC30 00A71021 */ addu $v0, $a1, $a3 -/* 00C834 8000BC34 84590000 */ lh $t9, ($v0) -/* 00C838 8000BC38 01A02025 */ move $a0, $t5 -/* 00C83C 8000BC3C 01274021 */ addu $t0, $t1, $a3 -/* 00C840 8000BC40 850C0004 */ lh $t4, 4($t0) -/* 00C844 8000BC44 44992000 */ mtc1 $t9, $f4 -/* 00C848 8000BC48 844A0004 */ lh $t2, 4($v0) -/* 00C84C 8000BC4C 448C5000 */ mtc1 $t4, $f10 -/* 00C850 8000BC50 468023A0 */ cvt.s.w $f14, $f4 -/* 00C854 8000BC54 03003025 */ move $a2, $t8 -/* 00C858 8000BC58 850B0000 */ lh $t3, ($t0) -/* 00C85C 8000BC5C 448A3000 */ mtc1 $t2, $f6 -/* 00C860 8000BC60 46805120 */ cvt.s.w $f4, $f10 -/* 00C864 8000BC64 448B4000 */ mtc1 $t3, $f8 -/* 00C868 8000BC68 46803420 */ cvt.s.w $f16, $f6 -/* 00C86C 8000BC6C E7A40008 */ swc1 $f4, 8($sp) -/* 00C870 8000BC70 468044A0 */ cvt.s.w $f18, $f8 -/* 00C874 8000BC74 15E00002 */ bnez $t7, .L8000BC80 -/* 00C878 8000BC78 00000000 */ nop -/* 00C87C 8000BC7C 0007000D */ break 7 -.L8000BC80: -/* 00C880 8000BC80 2401FFFF */ li $at, -1 -/* 00C884 8000BC84 15E10004 */ bne $t7, $at, .L8000BC98 -/* 00C888 8000BC88 3C018000 */ li $at, 0x80000000 # -0.000000 -/* 00C88C 8000BC8C 14810002 */ bne $a0, $at, .L8000BC98 -/* 00C890 8000BC90 00000000 */ nop -/* 00C894 8000BC94 0006000D */ break 6 -.L8000BC98: -/* 00C898 8000BC98 00002010 */ mfhi $a0 -/* 00C89C 8000BC9C 3098FFFF */ andi $t8, $a0, 0xffff -/* 00C8A0 8000BCA0 001838C0 */ sll $a3, $t8, 3 -/* 00C8A4 8000BCA4 00A71021 */ addu $v0, $a1, $a3 -/* 00C8A8 8000BCA8 84590000 */ lh $t9, ($v0) -/* 00C8AC 8000BCAC 01274021 */ addu $t0, $t1, $a3 -/* 00C8B0 8000BCB0 3C013F00 */ li $at, 0x3F000000 # 0.500000 -/* 00C8B4 8000BCB4 44993000 */ mtc1 $t9, $f6 -/* 00C8B8 8000BCB8 44811000 */ mtc1 $at, $f2 -/* 00C8BC 8000BCBC 03002025 */ move $a0, $t8 -/* 00C8C0 8000BCC0 46803220 */ cvt.s.w $f8, $f6 -/* 00C8C4 8000BCC4 E7A80014 */ swc1 $f8, 0x14($sp) -/* 00C8C8 8000BCC8 844A0004 */ lh $t2, 4($v0) -/* 00C8CC 8000BCCC 448A5000 */ mtc1 $t2, $f10 -/* 00C8D0 8000BCD0 00000000 */ nop -/* 00C8D4 8000BCD4 46805120 */ cvt.s.w $f4, $f10 -/* 00C8D8 8000BCD8 E7A40010 */ swc1 $f4, 0x10($sp) -/* 00C8DC 8000BCDC 850B0000 */ lh $t3, ($t0) -/* 00C8E0 8000BCE0 448B3000 */ mtc1 $t3, $f6 -/* 00C8E4 8000BCE4 00000000 */ nop -/* 00C8E8 8000BCE8 46803220 */ cvt.s.w $f8, $f6 -/* 00C8EC 8000BCEC 44813000 */ mtc1 $at, $f6 -/* 00C8F0 8000BCF0 3C013F80 */ li $at, 0x3F800000 # 1.000000 -/* 00C8F4 8000BCF4 E7A80004 */ swc1 $f8, 4($sp) -/* 00C8F8 8000BCF8 850C0004 */ lh $t4, 4($t0) -/* 00C8FC 8000BCFC C7A8002C */ lwc1 $f8, 0x2c($sp) -/* 00C900 8000BD00 448C5000 */ mtc1 $t4, $f10 -/* 00C904 8000BD04 00000000 */ nop -/* 00C908 8000BD08 46805120 */ cvt.s.w $f4, $f10 -/* 00C90C 8000BD0C 46024282 */ mul.s $f10, $f8, $f2 -/* 00C910 8000BD10 C7A80014 */ lwc1 $f8, 0x14($sp) -/* 00C914 8000BD14 E7A40000 */ swc1 $f4, ($sp) -/* 00C918 8000BD18 44812000 */ mtc1 $at, $f4 -/* 00C91C 8000BD1C 460A3001 */ sub.s $f0, $f6, $f10 -/* 00C920 8000BD20 3C018016 */ lui $at, %hi(D_80162FA0) # $at, 0x8016 -/* 00C924 8000BD24 46087180 */ add.s $f6, $f14, $f8 -/* 00C928 8000BD28 C7A80004 */ lwc1 $f8, 4($sp) -/* 00C92C 8000BD2C 46002301 */ sub.s $f12, $f4, $f0 -/* 00C930 8000BD30 46003282 */ mul.s $f10, $f6, $f0 -/* 00C934 8000BD34 46089180 */ add.s $f6, $f18, $f8 -/* 00C938 8000BD38 46025102 */ mul.s $f4, $f10, $f2 -/* 00C93C 8000BD3C 00000000 */ nop -/* 00C940 8000BD40 46066282 */ mul.s $f10, $f12, $f6 -/* 00C944 8000BD44 00000000 */ nop -/* 00C948 8000BD48 46025202 */ mul.s $f8, $f10, $f2 -/* 00C94C 8000BD4C C7AA0008 */ lwc1 $f10, 8($sp) -/* 00C950 8000BD50 46082180 */ add.s $f6, $f4, $f8 -/* 00C954 8000BD54 C7A40000 */ lwc1 $f4, ($sp) -/* 00C958 8000BD58 46045200 */ add.s $f8, $f10, $f4 -/* 00C95C 8000BD5C E4262FA0 */ swc1 $f6, %lo(D_80162FA0)($at) -/* 00C960 8000BD60 C7A40010 */ lwc1 $f4, 0x10($sp) -/* 00C964 8000BD64 3C018016 */ lui $at, %hi(D_80162FA0 + 8) -/* 00C968 8000BD68 46086182 */ mul.s $f6, $f12, $f8 -/* 00C96C 8000BD6C 46048200 */ add.s $f8, $f16, $f4 -/* 00C970 8000BD70 27BD0028 */ addiu $sp, $sp, 0x28 -/* 00C974 8000BD74 46023282 */ mul.s $f10, $f6, $f2 -/* 00C978 8000BD78 00000000 */ nop -/* 00C97C 8000BD7C 46004182 */ mul.s $f6, $f8, $f0 -/* 00C980 8000BD80 00000000 */ nop -/* 00C984 8000BD84 46023102 */ mul.s $f4, $f6, $f2 -/* 00C988 8000BD88 460A2200 */ add.s $f8, $f4, $f10 -/* 00C98C 8000BD8C 03E00008 */ jr $ra -/* 00C990 8000BD90 E4282FA8 */ swc1 $f8, %lo(D_80162FA0 + 8)($at) diff --git a/asm/non_matchings/hud_renderer/func_8004F168.s b/asm/non_matchings/hud_renderer/func_8004F168.s index a251daeb0..f52e1aefd 100644 --- a/asm/non_matchings/hud_renderer/func_8004F168.s +++ b/asm/non_matchings/hud_renderer/func_8004F168.s @@ -96,8 +96,8 @@ glabel func_8004F168 /* 04FED8 8004F2D8 30CCFFFF */ andi $t4, $a2, 0xffff /* 04FEDC 8004F2DC 01803025 */ move $a2, $t4 /* 04FEE0 8004F2E0 254ACCD8 */ addiu $t2, %lo(gMiniMapKartTextures) # addiu $t2, $t2, -0x3328 -/* 04FEE4 8004F2E4 3C190D00 */ lui $t9, %hi(D_0D005470) # $t9, 0xd00 -/* 04FEE8 8004F2E8 27395470 */ addiu $t9, %lo(D_0D005470) # addiu $t9, $t9, 0x5470 +/* 04FEE4 8004F2E4 3C190D00 */ lui $t9, %hi(common_vtx_player_minimap_icon) # $t9, 0xd00 +/* 04FEE8 8004F2E8 27395470 */ addiu $t9, %lo(common_vtx_player_minimap_icon) # addiu $t9, $t9, 0x5470 /* 04FEEC 8004F2EC 01AA7021 */ addu $t6, $t5, $t2 /* 04FEF0 8004F2F0 240C0008 */ li $t4, 8 /* 04FEF4 8004F2F4 240F0008 */ li $t7, 8 @@ -122,8 +122,8 @@ glabel func_8004F168 /* 04FF3C 8004F33C 01003025 */ move $a2, $t0 /* 04FF40 8004F340 25CECCD8 */ addiu $t6, %lo(gMiniMapKartTextures) # addiu $t6, $t6, -0x3328 /* 04FF44 8004F344 000D51C0 */ sll $t2, $t5, 7 -/* 04FF48 8004F348 3C0F0D00 */ lui $t7, %hi(D_0D005470) # $t7, 0xd00 -/* 04FF4C 8004F34C 25EF5470 */ addiu $t7, %lo(D_0D005470) # addiu $t7, $t7, 0x5470 +/* 04FF48 8004F348 3C0F0D00 */ lui $t7, %hi(common_vtx_player_minimap_icon) # $t7, 0xd00 +/* 04FF4C 8004F34C 25EF5470 */ addiu $t7, %lo(common_vtx_player_minimap_icon) # addiu $t7, $t7, 0x5470 /* 04FF50 8004F350 014EC821 */ addu $t9, $t2, $t6 /* 04FF54 8004F354 24080008 */ li $t0, 8 /* 04FF58 8004F358 24090008 */ li $t1, 8 @@ -146,9 +146,9 @@ glabel func_8004F168 /* 04FF98 8004F398 24070008 */ li $a3, 8 /* 04FF9C 8004F39C 24060008 */ li $a2, 8 /* 04FFA0 8004F3A0 15A00009 */ bnez $t5, .L8004F3C8 -/* 04FFA4 8004F3A4 3C0E0D03 */ lui $t6, %hi(gTextureMiniMapProgressDot) # $t6, 0xd03 -/* 04FFA8 8004F3A8 3C0A0D03 */ lui $t2, %hi(gTextureMiniMapProgressDot) # $t2, 0xd03 -/* 04FFAC 8004F3AC 254AD0D8 */ addiu $t2, %lo(gTextureMiniMapProgressDot) # addiu $t2, $t2, -0x2f28 +/* 04FFA4 8004F3A4 3C0E0D03 */ lui $t6, %hi(common_texture_minimap_progress_dot) # $t6, 0xd03 +/* 04FFA8 8004F3A8 3C0A0D03 */ lui $t2, %hi(common_texture_minimap_progress_dot) # $t2, 0xd03 +/* 04FFAC 8004F3AC 254AD0D8 */ addiu $t2, %lo(common_texture_minimap_progress_dot) # addiu $t2, $t2, -0x2f28 /* 04FFB0 8004F3B0 AFAA0010 */ sw $t2, 0x10($sp) /* 04FFB4 8004F3B4 24060008 */ li $a2, 8 /* 04FFB8 8004F3B8 0C013114 */ jal func_8004C450 @@ -156,7 +156,7 @@ glabel func_8004F168 /* 04FFC0 8004F3C0 10000005 */ b .L8004F3D8 /* 04FFC4 8004F3C4 8FBF002C */ lw $ra, 0x2c($sp) .L8004F3C8: -/* 04FFC8 8004F3C8 25CED0D8 */ addiu $t6, %lo(gTextureMiniMapProgressDot) # addiu $t6, $t6, -0x2f28 +/* 04FFC8 8004F3C8 25CED0D8 */ addiu $t6, %lo(common_texture_minimap_progress_dot) # addiu $t6, $t6, -0x2f28 /* 04FFCC 8004F3CC 0C0130D9 */ jal func_8004C364 /* 04FFD0 8004F3D0 AFAE0010 */ sw $t6, 0x10($sp) .L8004F3D4: diff --git a/assets/include/minimap_icons.mk b/assets/include/minimap_icons.mk index a56a15134..75d739c0b 100644 --- a/assets/include/minimap_icons.mk +++ b/assets/include/minimap_icons.mk @@ -10,7 +10,7 @@ $(MINIMAP_ICONS_DIR)/gTextureMiniMapKartDonkeyKong.png \ $(MINIMAP_ICONS_DIR)/gTextureMiniMapKartWario.png \ $(MINIMAP_ICONS_DIR)/gTextureMiniMapKartPeach.png \ $(MINIMAP_ICONS_DIR)/gTextureMiniMapKartBowser.png \ -$(MINIMAP_ICONS_DIR)/gTextureMiniMapProgressDot.png +$(MINIMAP_ICONS_DIR)/common_texture_minimap_progress_dot.png MINIMAP_ICONS_EXPORT_SENTINEL := $(MINIMAP_ICONS_DIR)/.export diff --git a/assets/minimap_icons.json b/assets/minimap_icons.json index cb9cafb79..aa105b692 100644 --- a/assets/minimap_icons.json +++ b/assets/minimap_icons.json @@ -8,5 +8,5 @@ "gTextureMiniMapKartWario": {"output_dir": "minimap_icons", "rom_offset": "0x132B50", "block_offset": "0x2CF58", "width": 8, "height": 8, "type": "rgba16"}, "gTextureMiniMapKartPeach": {"output_dir": "minimap_icons", "rom_offset": "0x132B50", "block_offset": "0x2CFD8", "width": 8, "height": 8, "type": "rgba16"}, "gTextureMiniMapKartBowser": {"output_dir": "minimap_icons", "rom_offset": "0x132B50", "block_offset": "0x2D058", "width": 8, "height": 8, "type": "rgba16"}, -"gTextureMiniMapProgressDot": {"output_dir": "minimap_icons", "rom_offset": "0x132B50", "block_offset": "0x2D0D8", "width": 8, "height": 8, "type": "rgba16"} +"common_texture_minimap_progress_dot": {"output_dir": "minimap_icons", "rom_offset": "0x132B50", "block_offset": "0x2D0D8", "width": 8, "height": 8, "type": "rgba16"} } \ No newline at end of file diff --git a/src/code_80005FD0.c b/src/code_80005FD0.c index ef0a66c21..bc3c09c58 100644 --- a/src/code_80005FD0.c +++ b/src/code_80005FD0.c @@ -2284,56 +2284,47 @@ void func_8000BA14(u16 waypointIndex, f32 arg1, f32 arg2, s16 pathIndex) { } } -#ifdef MIPS_TO_C -//generated by m2c commit 08138748803d75e73e4a94bb0c619a273754ee9c on Oct-12-2023 -extern f32 D_80162FA8; - void func_8000BBD8(u16 waypointIndex, f32 arg1, s16 pathIndex) { - f32 sp14; - f32 sp10; - f32 sp8; - f32 sp4; - f32 sp0; - TrackWaypoint *temp_a1; - TrackWaypoint *temp_t0; - TrackWaypoint *temp_t0_2; - TrackWaypoint *temp_t1; - TrackWaypoint *temp_v0; - TrackWaypoint *temp_v0_2; + TrackWaypoint* path1; + TrackWaypoint* path2; + f32 x1; + f32 z1; + f32 x3; + f32 z3; + f32 x2; + f32 z2; + f32 x4; + f32 z4; f32 temp_f0; f32 temp_f12; - f32 temp_f4; - f32 temp_f4_2; - f32 temp_f8; - f32 temp_f8_2; - s32 temp_t6; - s32 temp_t8; - temp_t6 = waypointIndex & 0xFFFF; - temp_a1 = D_80164560[pathIndex]; - temp_t1 = D_80164570[pathIndex]; - temp_v0 = &temp_a1[temp_t6]; - temp_t0 = &temp_t1[temp_t6]; - sp8 = (f32) temp_t0->posZ; - temp_t8 = ((s32) ((temp_t6 + 1) & 0xFFFF) % (s32) gWaypointCountByPathIndex[pathIndex]) & 0xFFFF; - temp_v0_2 = &temp_a1[temp_t8]; - temp_t0_2 = &temp_t1[temp_t8]; - temp_f8 = (f32) temp_v0_2->posX; - sp14 = temp_f8; - temp_f4 = (f32) temp_v0_2->posZ; - sp10 = temp_f4; - temp_f8_2 = (f32) temp_t0_2->posX; - sp4 = temp_f8_2; - temp_f4_2 = (f32) temp_t0_2->posZ; - sp0 = temp_f4_2; - temp_f0 = 0.5f - (arg1 * 0.5f); + path1 = &D_80164560[pathIndex][waypointIndex]; + path2 = &D_80164570[pathIndex][waypointIndex]; + + x1 = (f32) path1->posX; + z1 = (f32) path1->posZ; + + x2 = (f32) path2->posX; + z2 = (f32) path2->posZ; + + waypointIndex += 1; + waypointIndex = waypointIndex % gWaypointCountByPathIndex[pathIndex]; + + path1 = &D_80164560[pathIndex][waypointIndex]; + path2 = &D_80164570[pathIndex][waypointIndex]; + + x3 = (f32) path1->posX; + z3 = (f32) path1->posZ; + + x4 = (f32) path2->posX; + z4 = (f32) path2->posZ; + + + temp_f0 = 0.5f - (arg1 / 2.0f); temp_f12 = 1.0f - temp_f0; - *D_80162FA0 = (((f32) temp_v0->posX + temp_f8) * temp_f0 * 0.5f) + (temp_f12 * ((f32) temp_t0->posX + temp_f8_2) * 0.5f); - D_80162FA8 = (((f32) temp_v0->posZ + temp_f4) * temp_f0 * 0.5f) + (temp_f12 * (sp8 + temp_f4_2) * 0.5f); + D_80162FA0[0] = ((temp_f0 * ( x1 + x3)) / 2.0f) + ((temp_f12 * (x2 + x4)) / 2.0f); + D_80162FA0[2] = ((temp_f0 * ( z1 + z3)) / 2.0f) + ((temp_f12 * (z2 + z4)) / 2.0f); } -#else -GLOBAL_ASM("asm/non_matchings/code_80005FD0/func_8000BBD8.s") -#endif s16 func_8000BD94(f32 posX, f32 posY, f32 posZ, s32 pathIndex) { f32 x_dist; diff --git a/src/common_textures.h b/src/common_textures.h index 5115d47a3..ac71e92d2 100644 --- a/src/common_textures.h +++ b/src/common_textures.h @@ -87,7 +87,7 @@ extern Gfx D_toads_turnpike_0D0053C8[]; extern Gfx D_toads_turnpike_0D0053F0[]; extern Gfx D_toads_turnpike_0D005418[]; extern Vtx D_0D005430[]; -extern Vtx D_0D005470[]; +extern Vtx common_vtx_player_minimap_icon[]; extern Vtx D_0D0054B0[]; extern Vtx common_vtx_rectangle[]; extern Vtx D_0D0057B0[]; @@ -366,6 +366,6 @@ extern u8 D_0D02AC58[][1024]; extern u8 D_0D02BC58[][1024]; extern s8 gTextureMiniMapFinishLine[]; extern s8 gMiniMapKartTextures[][128]; -extern s8 gTextureMiniMapProgressDot[]; +extern s8 common_texture_minimap_progress_dot[]; #endif diff --git a/src/data/common_textures.inc.c b/src/data/common_textures.inc.c index 161c38033..d0a3e8649 100644 --- a/src/data/common_textures.inc.c +++ b/src/data/common_textures.inc.c @@ -741,7 +741,7 @@ Vtx D_0D005430[] = { {{{ -2, 1, 0}, 0, {0, 192}, {0xff, 0xff, 0xff, 0xff}}}, }; -Vtx D_0D005470[] = { +Vtx common_vtx_player_minimap_icon[] = { {{{ -4, -4, 0}, 0, {0, 0}, {0xff, 0xff, 0xff, 0xff}}}, {{{ 3, -4, 0}, 0, {448, 0}, {0xff, 0xff, 0xff, 0xff}}}, {{{ 3, 3, 0}, 0, {448, 448}, {0xff, 0xff, 0xff, 0xff}}}, @@ -1198,7 +1198,7 @@ Gfx common_rectangle_display[] = { }; Gfx D_0D006950[] = { - gsSPVertex(D_0D005470, 4, 0), + gsSPVertex(common_vtx_player_minimap_icon, 4, 0), gsSPDisplayList(common_rectangle_display), gsSPEndDisplayList(), }; @@ -3194,6 +3194,6 @@ s8 gMiniMapKartTextures[][128] = { }, }; -s8 gTextureMiniMapProgressDot[] = { - #include "assets/minimap_icons/gTextureMiniMapProgressDot.inc.c" +s8 common_texture_minimap_progress_dot[] = { + #include "assets/minimap_icons/common_texture_minimap_progress_dot.inc.c" }; diff --git a/src/hud_renderer.c b/src/hud_renderer.c index 4c686dc22..061177879 100644 --- a/src/hud_renderer.c +++ b/src/hud_renderer.c @@ -538,7 +538,7 @@ UNUSED void func_80046A68(Vec3f arg0, Vec3su arg1, f32 arg2, u8 *texture, Vtx *a } UNUSED void func_80046AD4(s32 arg0, s32 arg1, u16 arg2, f32 arg3, u8 *texture) { - func_800464D0(arg0, arg1, arg2, arg3, texture, D_0D005470, 8, 8, 8, 8); + func_800464D0(arg0, arg1, arg2, arg3, texture, common_vtx_player_minimap_icon, 8, 8, 8, 8); } UNUSED void func_80046B38(s32 arg0, s32 arg1, u16 arg2, f32 arg3, u8 *texture) { @@ -2329,30 +2329,35 @@ void func_8004F020(s32 arg0) { func_8004CAD0(var_f2, var_f0, gTextureMiniMapFinishLine); } -#ifdef MIPS_TO_C +#ifdef NON_MATCHING //generated by m2c commit beb457dabfc7a01ec6540a5404a6a05097a13602 on Dec-20-2023 -void func_8004F168(s32 arg0, s32 arg1, s32 arg2) { - Player *temp_v1; - s16 temp_a0; - s16 temp_a1; +/** + * characterId of 8 appears to be a type of null check or control flow alteration. +*/ +void func_8004F168(s32 arg0, s32 playerId, s32 characterId) { + Player *player = &gPlayerOne[playerId]; + s32 temp_a0; + s32 temp_a1; - temp_v1 = &gPlayerOne[arg1]; - if (temp_v1->type & 0x8000) { - temp_a0 = ((D_8018D2C0[arg0] + D_8018D2F0) - ((s16) D_8018D2B0 / 2)) + D_8018D2E0 + (s16) (s32) (temp_v1->pos[0] * D_8018D2A0); - temp_a1 = ((D_8018D2D8[arg0] + D_8018D2F8) - ((s16) D_8018D2B8 / 2)) + D_8018D2E8 + (s32) (temp_v1->pos[2] * D_8018D2A0); - if (arg2 != 8) { - if ((gGPCurrentRaceRankByPlayerId[arg1] == 0) && (gModeSelection != 3) && (gModeSelection != 1)) { - func_80046424((s32) temp_a0, (s32) temp_a1, (temp_v1->unk_02C[1] + 0x8000) & 0xFFFF, 1.0f, (u8 *) gMiniMapKartTextures[arg2], D_0D005470, 8, 8, 8, 8); - return; + if (gPlayerOne->type & PLAYER_EXISTS) { + temp_a0 = ((D_8018D2C0[arg0] + D_8018D2F0) - ((s16) D_8018D2B0 / 2)) + D_8018D2E0 + (s32) (player->pos[0] * D_8018D2A0); + temp_a1 = ((D_8018D2D8[arg0] + D_8018D2F8) - ((s16) D_8018D2B8 / 2)) + D_8018D2E8 + (s32) (player->pos[2] * D_8018D2A0); + if (characterId != 8) { + if ((gGPCurrentRaceRankByPlayerId[playerId] == 0) && (gModeSelection != BATTLE) && (gModeSelection != TIME_TRIALS)) { + func_80046424((s32) temp_a0, (s32) temp_a1, (player->unk_02C[1] + 0x8000) & 0xFFFF, 1.0f, (u8 *) gMiniMapKartTextures[characterId], common_vtx_player_minimap_icon, 8, 8, 8, 8); + // return; + } else { + func_800463B0((s32) temp_a0, (s32) temp_a1, (player->unk_02C[1] + 0x8000) & 0xFFFF, 1.0f, (u8 *) gMiniMapKartTextures[characterId], common_vtx_player_minimap_icon, 8, 8, 8, 8); + } + //return; + } else { + if (gGPCurrentRaceRankByPlayerId[playerId] == 0) { + func_8004C450((s32) temp_a0, (s32) temp_a1, 8, 8, (u8 *) common_texture_minimap_progress_dot); + //return; + } else { + func_8004C364((s32) temp_a0, (s32) temp_a1, 8, 8, (u8 *) common_texture_minimap_progress_dot); } - func_800463B0((s32) temp_a0, (s32) temp_a1, (temp_v1->unk_02C[1] + 0x8000) & 0xFFFF, 1.0f, (u8 *) gMiniMapKartTextures[arg2], D_0D005470, 8, 8, 8, 8); - return; } - if (gGPCurrentRaceRankByPlayerId[arg1] == 0) { - func_8004C450((s32) temp_a0, (s32) temp_a1, 8U, 8U, (u8 *) gTextureMiniMapProgressDot); - return; - } - func_8004C364((s32) temp_a0, (s32) temp_a1, 8U, 8U, (u8 *) gTextureMiniMapProgressDot); } } #else @@ -2361,43 +2366,43 @@ GLOBAL_ASM("asm/non_matchings/hud_renderer/func_8004F168.s") // WTF is up with the gPlayerOne access in this function? void func_8004F3E4(s32 arg0) { - s32 temp_a1; - s32 var_s1; Player *player; + s32 playerId; + s32 idx; switch (gModeSelection) { /* irregular */ case GRAND_PRIX: - for (var_s1 = D_8018D158 - 1; var_s1 >= 0; var_s1--) { - temp_a1 = gGPCurrentRacePlayerIdByRank[var_s1]; - if ((gPlayerOne + temp_a1)->type & 0x1000) { - func_8004F168(arg0, temp_a1, 8); + for (idx = D_8018D158 - 1; idx >= 0; idx--) { + playerId = gGPCurrentRacePlayerIdByRank[idx]; + if ((gPlayerOne + playerId)->type & PLAYER_CPU) { + func_8004F168(arg0, playerId, 8); } } - for (var_s1 = D_8018D158 - 1; var_s1 >= 0; var_s1--) { - temp_a1 = gGPCurrentRacePlayerIdByRank[var_s1]; - if (((gPlayerOne + temp_a1)->type & 0x1000) != 0x1000) { - func_8004F168(arg0, temp_a1, (gPlayerOne + temp_a1)->characterId); + for (idx = D_8018D158 - 1; idx >= 0; idx--) { + playerId = gGPCurrentRacePlayerIdByRank[idx]; + if (((gPlayerOne + playerId)->type & PLAYER_CPU) != PLAYER_CPU) { + func_8004F168(arg0, playerId, (gPlayerOne + playerId)->characterId); } } break; case TIME_TRIALS: - for (var_s1 = 0; var_s1 < 8; var_s1++) { - if (((gPlayerOne + var_s1)->type & 0x100) == 0x100) { - func_8004F168(arg0, var_s1, 8); + for (idx = 0; idx < 8; idx++) { + if (((gPlayerOne + idx)->type & PLAYER_INVISIBLE_OR_BOMB) == PLAYER_INVISIBLE_OR_BOMB) { + func_8004F168(arg0, idx, 8); } } func_8004F168(arg0, 0, gPlayerOne->characterId); break; case VERSUS: - for (var_s1 = gPlayerCountSelection1 - 1; var_s1 >=0; var_s1--) { - temp_a1 = gGPCurrentRacePlayerIdByRank[var_s1]; - func_8004F168(arg0, temp_a1, (gPlayerOne + temp_a1)->characterId); + for (idx = gPlayerCountSelection1 - 1; idx >=0; idx--) { + playerId = gGPCurrentRacePlayerIdByRank[idx]; + func_8004F168(arg0, playerId, (gPlayerOne + playerId)->characterId); } break; case BATTLE: - for (var_s1 = 0; var_s1 < gPlayerCountSelection1; var_s1++) { - if (!((gPlayerOne + var_s1)->type & 0x40)) { - func_8004F168(arg0, var_s1, (gPlayerOne + var_s1)->characterId); + for (idx = 0; idx < gPlayerCountSelection1; idx++) { + if (!((gPlayerOne + idx)->type & PLAYER_UNKNOWN_0x40)) { + func_8004F168(arg0, idx, (gPlayerOne + idx)->characterId); } } break;