From 78681aa5baf9ce42848f2a9719ad9edde86f2810 Mon Sep 17 00:00:00 2001 From: Tyler McGavran Date: Sun, 23 Jan 2022 00:46:07 -0500 Subject: [PATCH] Variety of changes (#147) * Update player struct with lap count and rank Also rename some arrays to better reflect what they are tracking * Add bounding box corner struct and surface type enum * Create a .h file and move stuff into it See https://github.com/DeadHamster35/Tarmac64/wiki/Surface-Types and https://github.com/micro500/mariokart64/wiki/Surface-Map for reference Signed-off-by: Taggerung --- asm/bss_MainSeg.s | 4 +- .../code_80005FD0/func_800088D8.s | 12 +- .../code_80005FD0/func_80008F38.s | 8 +- .../code_80005FD0/func_8000929C.s | 20 +- .../code_80005FD0/func_80009B60.s | 4 +- .../code_80005FD0/func_8000F628.s | 4 +- .../code_80005FD0/func_8001AC10.s | 8 +- .../code_800431B0/func_80050320.s | 8 +- .../code_800431B0/func_80050644.s | 16 +- .../code_800431B0/func_800508C0.s | 4 +- .../code_800431B0/func_80050E34.s | 4 +- .../code_80057C60/func_8005A14C.s | 4 +- .../code_8028DF00/func_8028F970.s | 8 +- .../staff_ghosts/func_80005B18.s | 8 +- include/common_structs.h | 83 +- include/functions.h | 1 - include/variables.h | 9 +- src/code_80005FD0.c | 40 +- src/code_80027D00.c | 1360 +++++++++-------- src/code_800393C0.c | 76 +- src/code_800431B0.c | 30 +- src/code_80057C60.c | 884 +++++------ src/code_80057C60.h | 240 +++ src/code_8028DF00.c | 50 +- src/code_80290C20.c | 17 +- src/math_util.c | 36 +- src/memory.c | 149 +- src/staff_ghosts.c | 14 +- 28 files changed, 1635 insertions(+), 1466 deletions(-) create mode 100644 src/code_80057C60.h diff --git a/asm/bss_MainSeg.s b/asm/bss_MainSeg.s index 9f38af727..cdd5cba35 100644 --- a/asm/bss_MainSeg.s +++ b/asm/bss_MainSeg.s @@ -172,7 +172,7 @@ glabel D_80164386 # List of s32's, seemingly indexed by player ID # Indicates the number of completed laps for that player -glabel lapCount +glabel gLapCountByPlayerId .skip 2 glabel D_80164392 @@ -238,7 +238,7 @@ glabel D_80164490 glabel D_80164498 .skip 16 -glabel D_801644A8 +glabel gLapCompletionPercentByPlayerId .skip 40 glabel gCourseCompletionPercentByPlayerId diff --git a/asm/non_matchings/code_80005FD0/func_800088D8.s b/asm/non_matchings/code_80005FD0/func_800088D8.s index 10f542585..594231386 100644 --- a/asm/non_matchings/code_80005FD0/func_800088D8.s +++ b/asm/non_matchings/code_80005FD0/func_800088D8.s @@ -91,10 +91,10 @@ glabel func_800088D8 /* 009624 80008A24 50200016 */ beql $at, $zero, .L80008A80 /* 009628 80008A28 84E40000 */ lh $a0, ($a3) /* 00962C 80008A2C 84E20000 */ lh $v0, ($a3) -/* 009630 80008A30 3C018016 */ lui $at, %hi(D_801644A8) +/* 009630 80008A30 3C018016 */ lui $at, %hi(gLapCompletionPercentByPlayerId) /* 009634 80008A34 00280821 */ addu $at, $at, $t0 /* 009638 80008A38 84E30010 */ lh $v1, 0x10($a3) -/* 00963C 80008A3C C42044A8 */ lwc1 $f0, %lo(D_801644A8)($at) +/* 00963C 80008A3C C42044A8 */ lwc1 $f0, %lo(gLapCompletionPercentByPlayerId)($at) /* 009640 80008A40 44822000 */ mtc1 $v0, $f4 /* 009644 80008A44 3C013F80 */ li $at, 0x3F800000 # 1.000000 /* 009648 80008A48 44814000 */ mtc1 $at, $f8 @@ -170,10 +170,10 @@ glabel func_800088D8 /* 00974C 80008B4C 10200015 */ beqz $at, .L80008BA4 /* 009750 80008B50 3C0F800E */ lui $t7, %hi(gCCSelection) /* 009754 80008B54 84E20000 */ lh $v0, ($a3) -/* 009758 80008B58 3C018016 */ lui $at, %hi(D_801644A8) +/* 009758 80008B58 3C018016 */ lui $at, %hi(gLapCompletionPercentByPlayerId) /* 00975C 80008B5C 00280821 */ addu $at, $at, $t0 /* 009760 80008B60 84E30010 */ lh $v1, 0x10($a3) -/* 009764 80008B64 C42044A8 */ lwc1 $f0, %lo(D_801644A8)($at) +/* 009764 80008B64 C42044A8 */ lwc1 $f0, %lo(gLapCompletionPercentByPlayerId)($at) /* 009768 80008B68 44829000 */ mtc1 $v0, $f18 /* 00976C 80008B6C 3C013F80 */ li $at, 0x3F800000 # 1.000000 /* 009770 80008B70 44814000 */ mtc1 $at, $f8 @@ -308,10 +308,10 @@ glabel func_800088D8 /* 00993C 80008D3C 0009C040 */ sll $t8, $t1, 1 /* 009940 80008D40 00F83021 */ addu $a2, $a3, $t8 /* 009944 80008D44 84C20000 */ lh $v0, ($a2) -/* 009948 80008D48 3C018016 */ lui $at, %hi(D_801644A8) +/* 009948 80008D48 3C018016 */ lui $at, %hi(gLapCompletionPercentByPlayerId) /* 00994C 80008D4C 00280821 */ addu $at, $at, $t0 /* 009950 80008D50 84C30010 */ lh $v1, 0x10($a2) -/* 009954 80008D54 C42044A8 */ lwc1 $f0, %lo(D_801644A8)($at) +/* 009954 80008D54 C42044A8 */ lwc1 $f0, %lo(gLapCompletionPercentByPlayerId)($at) /* 009958 80008D58 44825000 */ mtc1 $v0, $f10 /* 00995C 80008D5C 3C013F80 */ li $at, 0x3F800000 # 1.000000 /* 009960 80008D60 44814000 */ mtc1 $at, $f8 diff --git a/asm/non_matchings/code_80005FD0/func_80008F38.s b/asm/non_matchings/code_80005FD0/func_80008F38.s index 966d144cf..4fd648407 100644 --- a/asm/non_matchings/code_80005FD0/func_80008F38.s +++ b/asm/non_matchings/code_80005FD0/func_80008F38.s @@ -1,10 +1,10 @@ glabel func_80008F38 /* 009B38 80008F38 3C068016 */ lui $a2, %hi(D_801645C8) # $a2, 0x8016 /* 009B3C 80008F3C 00041080 */ sll $v0, $a0, 2 -/* 009B40 80008F40 3C038016 */ lui $v1, %hi(lapCount) # 0x8016 +/* 009B40 80008F40 3C038016 */ lui $v1, %hi(gLapCountByPlayerId) # 0x8016 /* 009B44 80008F44 24C645C8 */ addiu $a2, %lo(D_801645C8) # addiu $a2, $a2, 0x45c8 /* 009B48 80008F48 00621821 */ addu $v1, $v1, $v0 -/* 009B4C 80008F4C 8C634390 */ lw $v1, %lo(lapCount)($v1) # 0x4390($v1) +/* 009B4C 80008F4C 8C634390 */ lw $v1, %lo(gLapCountByPlayerId)($v1) # 0x4390($v1) /* 009B50 80008F50 94CE0000 */ lhu $t6, ($a2) /* 009B54 80008F54 00042840 */ sll $a1, $a0, 1 /* 009B58 80008F58 3C088016 */ lui $t0, %hi(D_80164438) # 0x8016 @@ -42,11 +42,11 @@ glabel func_80008F38 .L80008FD4: /* 009BD4 80008FD4 46103003 */ div.s $f0, $f6, $f16 /* 009BD8 80008FD8 44832000 */ mtc1 $v1, $f4 -/* 009BDC 80008FDC 3C018016 */ lui $at, %hi(D_801644A8) +/* 009BDC 80008FDC 3C018016 */ lui $at, %hi(gLapCompletionPercentByPlayerId) /* 009BE0 80008FE0 00220821 */ addu $at, $at, $v0 /* 009BE4 80008FE4 46802220 */ cvt.s.w $f8, $f4 /* 009BE8 80008FE8 46080280 */ add.s $f10, $f0, $f8 -/* 009BEC 80008FEC E42044A8 */ swc1 $f0, %lo(D_801644A8)($at) +/* 009BEC 80008FEC E42044A8 */ swc1 $f0, %lo(gLapCompletionPercentByPlayerId)($at) /* 009BF0 80008FF0 3C018016 */ lui $at, %hi(gCourseCompletionPercentByPlayerId) /* 009BF4 80008FF4 00220821 */ addu $at, $at, $v0 /* 009BF8 80008FF8 03E00008 */ jr $ra diff --git a/asm/non_matchings/code_80005FD0/func_8000929C.s b/asm/non_matchings/code_80005FD0/func_8000929C.s index fa66981cd..8a3662533 100644 --- a/asm/non_matchings/code_80005FD0/func_8000929C.s +++ b/asm/non_matchings/code_80005FD0/func_8000929C.s @@ -110,12 +110,12 @@ glabel func_8000929C .L8000943C: /* 00A03C 8000943C C426CFA8 */ lwc1 $f6, %lo(D_800ECFA8)($at) /* 00A040 80009440 00045080 */ sll $t2, $a0, 2 -/* 00A044 80009444 3C0B8016 */ lui $t3, %hi(lapCount) # 0x8016 +/* 00A044 80009444 3C0B8016 */ lui $t3, %hi(gLapCountByPlayerId) # 0x8016 /* 00A048 80009448 4606603C */ c.lt.s $f12, $f6 /* 00A04C 8000944C 016A5821 */ addu $t3, $t3, $t2 /* 00A050 80009450 45000028 */ bc1f .L800094F4 /* 00A054 80009454 00000000 */ nop -/* 00A058 80009458 8D6B4390 */ lw $t3, %lo(lapCount)($t3) # 0x4390($t3) +/* 00A058 80009458 8D6B4390 */ lw $t3, %lo(gLapCountByPlayerId)($t3) # 0x4390($t3) /* 00A05C 8000945C 29610002 */ slti $at, $t3, 2 /* 00A060 80009460 10200024 */ beqz $at, .L800094F4 /* 00A064 80009464 00000000 */ nop @@ -141,12 +141,12 @@ glabel func_8000929C .L800094B0: /* 00A0B0 800094B0 C42ACFAC */ lwc1 $f10, %lo(D_800ECFAC)($at) /* 00A0B4 800094B4 00046880 */ sll $t5, $a0, 2 -/* 00A0B8 800094B8 3C0E8016 */ lui $t6, %hi(lapCount) # 0x8016 +/* 00A0B8 800094B8 3C0E8016 */ lui $t6, %hi(gLapCountByPlayerId) # 0x8016 /* 00A0BC 800094BC 460C503C */ c.lt.s $f10, $f12 /* 00A0C0 800094C0 01CD7021 */ addu $t6, $t6, $t5 /* 00A0C4 800094C4 4500000B */ bc1f .L800094F4 /* 00A0C8 800094C8 00000000 */ nop -/* 00A0CC 800094CC 8DCE4390 */ lw $t6, %lo(lapCount)($t6) # 0x4390($t6) +/* 00A0CC 800094CC 8DCE4390 */ lw $t6, %lo(gLapCountByPlayerId)($t6) # 0x4390($t6) /* 00A0D0 800094D0 29C10002 */ slti $at, $t6, 2 /* 00A0D4 800094D4 10200007 */ beqz $at, .L800094F4 /* 00A0D8 800094D8 00000000 */ nop @@ -178,8 +178,8 @@ glabel func_8000929C /* 00A134 80009534 4500004B */ bc1f .L80009664 /* 00A138 80009538 00000000 */ nop /* 00A13C 8000953C 4604003C */ c.lt.s $f0, $f4 -/* 00A140 80009540 3C188016 */ lui $t8, %hi(lapCount) # $t8, 0x8016 -/* 00A144 80009544 27184390 */ addiu $t8, %lo(lapCount) # addiu $t8, $t8, 0x4390 +/* 00A140 80009540 3C188016 */ lui $t8, %hi(gLapCountByPlayerId) # $t8, 0x8016 +/* 00A144 80009544 27184390 */ addiu $t8, %lo(gLapCountByPlayerId) # addiu $t8, $t8, 0x4390 /* 00A148 80009548 00F81021 */ addu $v0, $a3, $t8 /* 00A14C 8000954C 45000045 */ bc1f .L80009664 /* 00A150 80009550 00000000 */ nop @@ -196,9 +196,9 @@ glabel func_8000929C /* 00A17C 8000957C 01876021 */ addu $t4, $t4, $a3 /* 00A180 80009580 8D8C4408 */ lw $t4, %lo(D_80164408)($t4) # 0x4408($t4) /* 00A184 80009584 24010007 */ li $at, 7 -/* 00A188 80009588 3C028016 */ lui $v0, %hi(lapCount) # $v0, 0x8016 +/* 00A188 80009588 3C028016 */ lui $v0, %hi(gLapCountByPlayerId) # $v0, 0x8016 /* 00A18C 8000958C 15810011 */ bne $t4, $at, .L800095D4 -/* 00A190 80009590 24424390 */ addiu $v0, %lo(lapCount) # addiu $v0, $v0, 0x4390 +/* 00A190 80009590 24424390 */ addiu $v0, %lo(gLapCountByPlayerId) # addiu $v0, $v0, 0x4390 /* 00A194 80009594 3C038016 */ lui $v1, %hi(D_801643B0) # $v1, 0x8016 /* 00A198 80009598 246343B0 */ addiu $v1, %lo(D_801643B0) # addiu $v1, $v1, 0x43b0 .L8000959C: @@ -265,8 +265,8 @@ glabel func_8000929C /* 00A280 80009680 4502000E */ bc1fl .L800096BC /* 00A284 80009684 C7AA0044 */ lwc1 $f10, 0x44($sp) /* 00A288 80009688 4608003C */ c.lt.s $f0, $f8 -/* 00A28C 8000968C 3C0A8016 */ lui $t2, %hi(lapCount) # $t2, 0x8016 -/* 00A290 80009690 254A4390 */ addiu $t2, %lo(lapCount) # addiu $t2, $t2, 0x4390 +/* 00A28C 8000968C 3C0A8016 */ lui $t2, %hi(gLapCountByPlayerId) # $t2, 0x8016 +/* 00A290 80009690 254A4390 */ addiu $t2, %lo(gLapCountByPlayerId) # addiu $t2, $t2, 0x4390 /* 00A294 80009694 00EA1021 */ addu $v0, $a3, $t2 /* 00A298 80009698 45020008 */ bc1fl .L800096BC /* 00A29C 8000969C C7AA0044 */ lwc1 $f10, 0x44($sp) diff --git a/asm/non_matchings/code_80005FD0/func_80009B60.s b/asm/non_matchings/code_80005FD0/func_80009B60.s index e236247a7..20091c952 100644 --- a/asm/non_matchings/code_80005FD0/func_80009B60.s +++ b/asm/non_matchings/code_80005FD0/func_80009B60.s @@ -58,10 +58,10 @@ glabel func_80009B60 /* 00A83C 80009C3C 3C018016 */ lui $at, %hi(gCourseCompletionPercentByPlayerId) /* 00A840 80009C40 00270821 */ addu $at, $at, $a3 /* 00A844 80009C44 E42044D0 */ swc1 $f0, %lo(gCourseCompletionPercentByPlayerId)($at) -/* 00A848 80009C48 3C018016 */ lui $at, %hi(D_801644A8) +/* 00A848 80009C48 3C018016 */ lui $at, %hi(gLapCompletionPercentByPlayerId) /* 00A84C 80009C4C 00270821 */ addu $at, $at, $a3 /* 00A850 80009C50 10000537 */ b .L8000B130 -/* 00A854 80009C54 E42044A8 */ swc1 $f0, %lo(D_801644A8)($at) +/* 00A854 80009C54 E42044A8 */ swc1 $f0, %lo(gLapCompletionPercentByPlayerId)($at) .L80009C58: /* 00A858 80009C58 00D81021 */ addu $v0, $a2, $t8 /* 00A85C 80009C5C A4400000 */ sh $zero, ($v0) diff --git a/asm/non_matchings/code_80005FD0/func_8000F628.s b/asm/non_matchings/code_80005FD0/func_8000F628.s index 3962b94cd..5d5ab908b 100644 --- a/asm/non_matchings/code_80005FD0/func_8000F628.s +++ b/asm/non_matchings/code_80005FD0/func_8000F628.s @@ -1,8 +1,8 @@ glabel func_8000F628 /* 010228 8000F628 27BDFEE0 */ addiu $sp, $sp, -0x120 /* 01022C 8000F62C 3C0E8016 */ lui $t6, %hi(D_80163210) # $t6, 0x8016 -/* 010230 8000F630 3C0F8016 */ lui $t7, %hi(lapCount) # $t7, 0x8016 -/* 010234 8000F634 25EF4390 */ addiu $t7, %lo(lapCount) # addiu $t7, $t7, 0x4390 +/* 010230 8000F630 3C0F8016 */ lui $t7, %hi(gLapCountByPlayerId) # $t7, 0x8016 +/* 010234 8000F634 25EF4390 */ addiu $t7, %lo(gLapCountByPlayerId) # addiu $t7, $t7, 0x4390 /* 010238 8000F638 25CE3210 */ addiu $t6, %lo(D_80163210) # addiu $t6, $t6, 0x3210 /* 01023C 8000F63C AFAE00D4 */ sw $t6, 0xd4($sp) /* 010240 8000F640 AFAF00D0 */ sw $t7, 0xd0($sp) diff --git a/asm/non_matchings/code_80005FD0/func_8001AC10.s b/asm/non_matchings/code_80005FD0/func_8001AC10.s index 4a62aef12..778154567 100644 --- a/asm/non_matchings/code_80005FD0/func_8001AC10.s +++ b/asm/non_matchings/code_80005FD0/func_8001AC10.s @@ -59,12 +59,12 @@ glabel L8001ACAC /* 01B8F0 8001ACF0 14200018 */ bnez $at, .L8001AD54 /* 01B8F4 8001ACF4 00000000 */ nop /* 01B8F8 8001ACF8 860B0006 */ lh $t3, 6($s0) -/* 01B8FC 8001ACFC 3C038016 */ lui $v1, %hi(lapCount) # 0x8016 +/* 01B8FC 8001ACFC 3C038016 */ lui $v1, %hi(gLapCountByPlayerId) # 0x8016 /* 01B900 8001AD00 00621821 */ addu $v1, $v1, $v0 /* 01B904 8001AD04 29610003 */ slti $at, $t3, 3 /* 01B908 8001AD08 10200012 */ beqz $at, .L8001AD54 /* 01B90C 8001AD0C 00000000 */ nop -/* 01B910 8001AD10 8C634390 */ lw $v1, %lo(lapCount)($v1) # 0x4390($v1) +/* 01B910 8001AD10 8C634390 */ lw $v1, %lo(gLapCountByPlayerId)($v1) # 0x4390($v1) /* 01B914 8001AD14 3C068016 */ lui $a2, %hi(gPlayerPositions) # $a2, 0x8016 /* 01B918 8001AD18 24C643B8 */ addiu $a2, %lo(gPlayerPositions) # addiu $a2, $a2, 0x43b8 /* 01B91C 8001AD1C 28610003 */ slti $at, $v1, 3 @@ -89,11 +89,11 @@ glabel L8001ACAC /* 01B960 8001AD60 86020004 */ lh $v0, 4($s0) glabel L8001AD64 /* 01B964 8001AD64 8FA20030 */ lw $v0, 0x30($sp) -/* 01B968 8001AD68 3C0E8016 */ lui $t6, %hi(lapCount) # 0x8016 +/* 01B968 8001AD68 3C0E8016 */ lui $t6, %hi(gLapCountByPlayerId) # 0x8016 /* 01B96C 8001AD6C 3C068016 */ lui $a2, %hi(gPlayerPositions) # $a2, 0x8016 /* 01B970 8001AD70 00027880 */ sll $t7, $v0, 2 /* 01B974 8001AD74 01CF7021 */ addu $t6, $t6, $t7 -/* 01B978 8001AD78 8DCE4390 */ lw $t6, %lo(lapCount)($t6) # 0x4390($t6) +/* 01B978 8001AD78 8DCE4390 */ lw $t6, %lo(gLapCountByPlayerId)($t6) # 0x4390($t6) /* 01B97C 8001AD7C 24C643B8 */ addiu $a2, %lo(gPlayerPositions) # addiu $a2, $a2, 0x43b8 /* 01B980 8001AD80 3C038016 */ lui $v1, %hi(D_80163478) # $v1, 0x8016 /* 01B984 8001AD84 19C0004B */ blez $t6, .L8001AEB4 diff --git a/asm/non_matchings/code_800431B0/func_80050320.s b/asm/non_matchings/code_800431B0/func_80050320.s index e486efa6f..47892ad97 100644 --- a/asm/non_matchings/code_800431B0/func_80050320.s +++ b/asm/non_matchings/code_800431B0/func_80050320.s @@ -17,13 +17,13 @@ glabel func_80050320 /* 050F5C 8005035C 3C128019 */ lui $s2, %hi(D_8018D050) # $s2, 0x8019 /* 050F60 80050360 3C178019 */ lui $s7, %hi(D_8018D3E0) # $s7, 0x8019 /* 050F64 80050364 3C15800E */ lui $s5, %hi(gPlayerOne) # $s5, 0x800e -/* 050F68 80050368 3C148016 */ lui $s4, %hi(lapCount) # $s4, 0x8016 +/* 050F68 80050368 3C148016 */ lui $s4, %hi(gLapCountByPlayerId) # $s4, 0x8016 /* 050F6C 8005036C 3C138019 */ lui $s3, %hi(D_8018D078) # $s3, 0x8019 /* 050F70 80050370 4480B000 */ mtc1 $zero, $f22 /* 050F74 80050374 4480A800 */ mtc1 $zero, $f21 /* 050F78 80050378 4480A000 */ mtc1 $zero, $f20 /* 050F7C 8005037C 2673D078 */ addiu $s3, %lo(D_8018D078) # addiu $s3, $s3, -0x2f88 -/* 050F80 80050380 26944390 */ addiu $s4, %lo(lapCount) # addiu $s4, $s4, 0x4390 +/* 050F80 80050380 26944390 */ addiu $s4, %lo(gLapCountByPlayerId) # addiu $s4, $s4, 0x4390 /* 050F84 80050384 26B5C4DC */ addiu $s5, %lo(gPlayerOne) # addiu $s5, $s5, -0x3b24 /* 050F88 80050388 26F7D3E0 */ addiu $s7, %lo(D_8018D3E0) # addiu $s7, $s7, -0x2c20 /* 050F8C 8005038C 2652D050 */ addiu $s2, %lo(D_8018D050) # addiu $s2, $s2, -0x2fb0 @@ -103,13 +103,13 @@ glabel func_80050320 .L800504A4: /* 0510A4 800504A4 3C128019 */ lui $s2, %hi(D_8018D050) # $s2, 0x8019 /* 0510A8 800504A8 3C15800E */ lui $s5, %hi(gPlayerOne) # $s5, 0x800e -/* 0510AC 800504AC 3C148016 */ lui $s4, %hi(lapCount) # $s4, 0x8016 +/* 0510AC 800504AC 3C148016 */ lui $s4, %hi(gLapCountByPlayerId) # $s4, 0x8016 /* 0510B0 800504B0 3C138019 */ lui $s3, %hi(D_8018D078) # $s3, 0x8019 /* 0510B4 800504B4 4480B000 */ mtc1 $zero, $f22 /* 0510B8 800504B8 4480A800 */ mtc1 $zero, $f21 /* 0510BC 800504BC 4480A000 */ mtc1 $zero, $f20 /* 0510C0 800504C0 2673D078 */ addiu $s3, %lo(D_8018D078) # addiu $s3, $s3, -0x2f88 -/* 0510C4 800504C4 26944390 */ addiu $s4, %lo(lapCount) # addiu $s4, $s4, 0x4390 +/* 0510C4 800504C4 26944390 */ addiu $s4, %lo(gLapCountByPlayerId) # addiu $s4, $s4, 0x4390 /* 0510C8 800504C8 26B5C4DC */ addiu $s5, %lo(gPlayerOne) # addiu $s5, $s5, -0x3b24 /* 0510CC 800504CC 2652D050 */ addiu $s2, %lo(D_8018D050) # addiu $s2, $s2, -0x2fb0 /* 0510D0 800504D0 00008025 */ move $s0, $zero diff --git a/asm/non_matchings/code_800431B0/func_80050644.s b/asm/non_matchings/code_800431B0/func_80050644.s index 73bd6158d..46f30f48e 100644 --- a/asm/non_matchings/code_800431B0/func_80050644.s +++ b/asm/non_matchings/code_800431B0/func_80050644.s @@ -1,9 +1,9 @@ glabel func_80050644 /* 051244 80050644 308EFFFF */ andi $t6, $a0, 0xffff /* 051248 80050648 000E4080 */ sll $t0, $t6, 2 -/* 05124C 8005064C 3C078016 */ lui $a3, %hi(lapCount) # 0x8016 +/* 05124C 8005064C 3C078016 */ lui $a3, %hi(gLapCountByPlayerId) # 0x8016 /* 051250 80050650 00E83821 */ addu $a3, $a3, $t0 -/* 051254 80050654 8CE74390 */ lw $a3, %lo(lapCount)($a3) # 0x4390($a3) +/* 051254 80050654 8CE74390 */ lw $a3, %lo(gLapCountByPlayerId)($a3) # 0x4390($a3) /* 051258 80050658 AFA40000 */ sw $a0, ($sp) /* 05125C 8005065C 00001825 */ move $v1, $zero /* 051260 80050660 28E10003 */ slti $at, $a3, 3 @@ -15,9 +15,9 @@ glabel func_80050644 /* 051278 80050678 15E1002A */ bne $t7, $at, .L80050724 /* 05127C 8005067C 00000000 */ nop /* 051280 80050680 04E0000A */ bltz $a3, .L800506AC -/* 051284 80050684 3C018016 */ lui $at, %hi(D_801644A8) +/* 051284 80050684 3C018016 */ lui $at, %hi(gLapCompletionPercentByPlayerId) /* 051288 80050688 00280821 */ addu $at, $at, $t0 -/* 05128C 8005068C C42444A8 */ lwc1 $f4, %lo(D_801644A8)($at) +/* 05128C 8005068C C42444A8 */ lwc1 $f4, %lo(gLapCompletionPercentByPlayerId)($at) /* 051290 80050690 3C014468 */ li $at, 0x44680000 # 928.000000 /* 051294 80050694 44813000 */ mtc1 $at, $f6 /* 051298 80050698 00000000 */ nop @@ -65,9 +65,9 @@ glabel func_80050644 .L80050724: /* 051324 80050724 04E0000A */ bltz $a3, .L80050750 -/* 051328 80050728 3C018016 */ lui $at, %hi(D_801644A8) +/* 051328 80050728 3C018016 */ lui $at, %hi(gLapCompletionPercentByPlayerId) /* 05132C 8005072C 00280821 */ addu $at, $at, $t0 -/* 051330 80050730 C43044A8 */ lwc1 $f16, %lo(D_801644A8)($at) +/* 051330 80050730 C43044A8 */ lwc1 $f16, %lo(gLapCompletionPercentByPlayerId)($at) /* 051334 80050734 3C014382 */ li $at, 0x43820000 # 260.000000 /* 051338 80050738 44819000 */ mtc1 $at, $f18 /* 05133C 8005073C 00000000 */ nop @@ -100,9 +100,9 @@ glabel func_80050644 /* 05139C 8005079C ACCB0000 */ sw $t3, ($a2) .L800507A0: -/* 0513A0 800507A0 3C018016 */ lui $at, %hi(D_801644A8) +/* 0513A0 800507A0 3C018016 */ lui $at, %hi(gLapCompletionPercentByPlayerId) /* 0513A4 800507A4 00280821 */ addu $at, $at, $t0 -/* 0513A8 800507A8 C42844A8 */ lwc1 $f8, %lo(D_801644A8)($at) +/* 0513A8 800507A8 C42844A8 */ lwc1 $f8, %lo(gLapCompletionPercentByPlayerId)($at) /* 0513AC 800507AC 3C014382 */ li $at, 0x43820000 # 260.000000 /* 0513B0 800507B0 44815000 */ mtc1 $at, $f10 /* 0513B4 800507B4 00000000 */ nop diff --git a/asm/non_matchings/code_800431B0/func_800508C0.s b/asm/non_matchings/code_800431B0/func_800508C0.s index 0437cab53..20ff168c0 100644 --- a/asm/non_matchings/code_800431B0/func_800508C0.s +++ b/asm/non_matchings/code_800431B0/func_800508C0.s @@ -20,9 +20,9 @@ glabel func_800508C0 /* 051500 80050900 0C014191 */ jal func_80050644 /* 051504 80050904 27A60050 */ addiu $a2, $sp, 0x50 /* 051508 80050908 00107880 */ sll $t7, $s0, 2 -/* 05150C 8005090C 3C038016 */ lui $v1, %hi(lapCount) # 0x8016 +/* 05150C 8005090C 3C038016 */ lui $v1, %hi(gLapCountByPlayerId) # 0x8016 /* 051510 80050910 006F1821 */ addu $v1, $v1, $t7 -/* 051514 80050914 8C634390 */ lw $v1, %lo(lapCount)($v1) # 0x4390($v1) +/* 051514 80050914 8C634390 */ lw $v1, %lo(gLapCountByPlayerId)($v1) # 0x4390($v1) /* 051518 80050918 AFA2004C */ sw $v0, 0x4c($sp) /* 05151C 8005091C 24010001 */ li $at, 1 /* 051520 80050920 18600037 */ blez $v1, .L80050A00 diff --git a/asm/non_matchings/code_800431B0/func_80050E34.s b/asm/non_matchings/code_800431B0/func_80050E34.s index 3a6d54946..853d2cd00 100644 --- a/asm/non_matchings/code_800431B0/func_80050E34.s +++ b/asm/non_matchings/code_800431B0/func_80050E34.s @@ -13,7 +13,7 @@ glabel func_80050E34 /* 051A60 80050E60 3C0E800E */ lui $t6, %hi(gPlayerCountSelection1) # $t6, 0x800e /* 051A64 80050E64 8DCEC538 */ lw $t6, %lo(gPlayerCountSelection1)($t6) /* 051A68 80050E68 AFB00024 */ sw $s0, 0x24($sp) -/* 051A6C 80050E6C 3C108016 */ lui $s0, %hi(lapCount) # 0x8016 +/* 051A6C 80050E6C 3C108016 */ lui $s0, %hi(gLapCountByPlayerId) # 0x8016 /* 051A70 80050E70 0004C080 */ sll $t8, $a0, 2 /* 051A74 80050E74 0004C940 */ sll $t9, $a0, 5 /* 051A78 80050E78 3C0D8019 */ lui $t5, %hi(D_8018CE24) # 0x8019 @@ -25,7 +25,7 @@ glabel func_80050E34 /* 051A90 80050E90 01B96821 */ addu $t5, $t5, $t9 /* 051A94 80050E94 24010001 */ li $at, 1 /* 051A98 80050E98 00803825 */ move $a3, $a0 -/* 051A9C 80050E9C 8E104390 */ lw $s0, %lo(lapCount)($s0) # 0x4390($s0) +/* 051A9C 80050E9C 8E104390 */ lw $s0, %lo(gLapCountByPlayerId)($s0) # 0x4390($s0) /* 051AA0 80050EA0 94510254 */ lhu $s1, 0x254($v0) /* 051AA4 80050EA4 15C10004 */ bne $t6, $at, .L80050EB8 /* 051AA8 80050EA8 8DADCE24 */ lw $t5, %lo(D_8018CE24)($t5) # -0x31dc($t5) diff --git a/asm/non_matchings/code_80057C60/func_8005A14C.s b/asm/non_matchings/code_80057C60/func_8005A14C.s index aa3f29607..b0d621f47 100644 --- a/asm/non_matchings/code_80057C60/func_8005A14C.s +++ b/asm/non_matchings/code_80057C60/func_8005A14C.s @@ -3,12 +3,12 @@ glabel func_8005A14C /* 05AD50 8005A150 01C47023 */ subu $t6, $t6, $a0 /* 05AD54 8005A154 000E7100 */ sll $t6, $t6, 4 /* 05AD58 8005A158 0004C880 */ sll $t9, $a0, 2 -/* 05AD5C 8005A15C 3C098016 */ lui $t1, %hi(lapCount) +/* 05AD5C 8005A15C 3C098016 */ lui $t1, %hi(gLapCountByPlayerId) /* 05AD60 8005A160 01C47023 */ subu $t6, $t6, $a0 /* 05AD64 8005A164 3C0F800E */ lui $t7, %hi(gPlayerOne) # $t7, 0x800e /* 05AD68 8005A168 01394821 */ addu $t1, $t1, $t9 /* 05AD6C 8005A16C 8DEFC4DC */ lw $t7, %lo(gPlayerOne)($t7) -/* 05AD70 8005A170 8D294390 */ lw $t1, %lo(lapCount)($t1) +/* 05AD70 8005A170 8D294390 */ lw $t1, %lo(gLapCountByPlayerId)($t1) /* 05AD74 8005A174 27BDFFD0 */ addiu $sp, $sp, -0x30 /* 05AD78 8005A178 000E7080 */ sll $t6, $t6, 2 /* 05AD7C 8005A17C 01C47023 */ subu $t6, $t6, $a0 diff --git a/asm/non_matchings/code_8028DF00/func_8028F970.s b/asm/non_matchings/code_8028DF00/func_8028F970.s index 828b03ebc..6fc1a99c1 100644 --- a/asm/non_matchings/code_8028DF00/func_8028F970.s +++ b/asm/non_matchings/code_8028DF00/func_8028F970.s @@ -125,8 +125,8 @@ glabel func_8028F970 /* 0F914C 8028FB3C 51A1001F */ beql $t5, $at, .L8028FBBC /* 0F9150 8028FB40 8FBF0024 */ lw $ra, 0x24($sp) /* 0F9154 8028FB44 8CA5C4BC */ lw $a1, %lo(gControllerOne)($a1) -/* 0F9158 8028FB48 3C028016 */ lui $v0, %hi(lapCount) # $v0, 0x8016 -/* 0F915C 8028FB4C 24424390 */ addiu $v0, %lo(lapCount) # addiu $v0, $v0, 0x4390 +/* 0F9158 8028FB48 3C028016 */ lui $v0, %hi(gLapCountByPlayerId) # $v0, 0x8016 +/* 0F915C 8028FB4C 24424390 */ addiu $v0, %lo(gLapCountByPlayerId) # addiu $v0, $v0, 0x4390 /* 0F9160 8028FB50 94A40006 */ lhu $a0, 6($a1) /* 0F9164 8028FB54 24030002 */ li $v1, 2 /* 0F9168 8028FB58 308E0800 */ andi $t6, $a0, 0x800 @@ -135,9 +135,9 @@ glabel func_8028F970 /* 0F9174 8028FB64 AC430000 */ sw $v1, ($v0) /* 0F9178 8028FB68 94A40006 */ lhu $a0, 6($a1) .L8028FB6C: -/* 0F917C 8028FB6C 3C028016 */ lui $v0, %hi(lapCount) # $v0, 0x8016 +/* 0F917C 8028FB6C 3C028016 */ lui $v0, %hi(gLapCountByPlayerId) # $v0, 0x8016 /* 0F9180 8028FB70 308F0100 */ andi $t7, $a0, 0x100 -/* 0F9184 8028FB74 24424390 */ addiu $v0, %lo(lapCount) # addiu $v0, $v0, 0x4390 +/* 0F9184 8028FB74 24424390 */ addiu $v0, %lo(gLapCountByPlayerId) # addiu $v0, $v0, 0x4390 /* 0F9188 8028FB78 11E00004 */ beqz $t7, .L8028FB8C /* 0F918C 8028FB7C 24030002 */ li $v1, 2 /* 0F9190 8028FB80 AC430000 */ sw $v1, ($v0) diff --git a/asm/non_matchings/staff_ghosts/func_80005B18.s b/asm/non_matchings/staff_ghosts/func_80005B18.s index 8a232dac8..7f99bed81 100644 --- a/asm/non_matchings/staff_ghosts/func_80005B18.s +++ b/asm/non_matchings/staff_ghosts/func_80005B18.s @@ -5,8 +5,8 @@ glabel func_80005B18 /* 006724 80005B24 24030001 */ li $v1, 1 /* 006728 80005B28 146400CC */ bne $v1, $a0, .L80005E5C /* 00672C 80005B2C AFBF0014 */ sw $ra, 0x14($sp) -/* 006730 80005B30 3C088016 */ lui $t0, %hi(lapCount) # $t0, 0x8016 -/* 006734 80005B34 25084390 */ addiu $t0, %lo(lapCount) # addiu $t0, $t0, 0x4390 +/* 006730 80005B30 3C088016 */ lui $t0, %hi(gLapCountByPlayerId) # $t0, 0x8016 +/* 006734 80005B34 25084390 */ addiu $t0, %lo(gLapCountByPlayerId) # addiu $t0, $t0, 0x4390 /* 006738 80005B38 8D020000 */ lw $v0, ($t0) /* 00673C 80005B3C 24060003 */ li $a2, 3 /* 006740 80005B40 3C058016 */ lui $a1, %hi(D_80162DDC) # $a1, 0x8016 @@ -194,8 +194,8 @@ glabel func_80005B18 /* 006A00 80005E00 00000000 */ nop /* 006A04 80005E04 0C0015F7 */ jal func_800057DC /* 006A08 80005E08 00000000 */ nop -/* 006A0C 80005E0C 3C088016 */ lui $t0, %hi(lapCount) # $t0, 0x8016 -/* 006A10 80005E10 25084390 */ addiu $t0, %lo(lapCount) # addiu $t0, $t0, 0x4390 +/* 006A0C 80005E0C 3C088016 */ lui $t0, %hi(gLapCountByPlayerId) # $t0, 0x8016 +/* 006A10 80005E10 25084390 */ addiu $t0, %lo(gLapCountByPlayerId) # addiu $t0, $t0, 0x4390 /* 006A14 80005E14 24060003 */ li $a2, 3 .L80005E18: /* 006A18 80005E18 3C198016 */ lui $t9, %hi(D_80162DD4+0x2) # $t9, 0x8016 diff --git a/include/common_structs.h b/include/common_structs.h index a13aa1aa1..fea0c5db0 100644 --- a/include/common_structs.h +++ b/include/common_structs.h @@ -52,6 +52,31 @@ typedef enum { /* 0x10 */ NUM_TIME_TRIAL_DATA } TIME_TRIAL_DATA_INDEX; +enum SURFACE_TYPE { + /* 0x00 */ AIRBORNE, + /* 0x01 */ PAVEMENT, // Luigi's Raceway, Toad's Turnpike, Koopa Troop beach shortcut tunnel, Mario Raceway, Royal Raceway, Rainbow Road, Block Fort, Double Deck, Skyscraper + /* 0x02 */ SAND_ONE, // Luigi's Raceway, Moo Moo Farm, Kalimiari Desert on course, Choco Mountain, Wario Stadium, DK Jungle on course, Yoshi Valley + /* 0x03 */ SAND_TWO, // Koopa Troopa Beach light color, Royal Raceway + /* 0x04 */ STONE_TWO, // Royal Raceway castle entrance, Bowser's Castle + /* 0x05 */ SNOW_ONE, // Frappe Snowland on course, Sherber Land tunnel + /* 0x06 */ STONE_ONE, // Royal Raceway castle bridges (even the wooden one), Banshee's Boardwalk, Big Donut + /* 0x07 */ SAND_FIVE, // Mario Raceway + /* 0x08 */ GRASS, // Luigi's Raceway, Mario Raceway, Royal Raceway, Bowser's Castle, DK Jungle, Yoshi Valley + /* 0x09 */ ICE, // Sherbert Land + /* 0x0A */ SAND_THREE, // Koop Troopa Beach dark color + /* 0x0B */ SNOW_TWO, // Frappe Snowland off course + /* 0x0C */ CLIFF, // Koopa Troopa Beach, Choco Mountain + /* 0x0D */ SAND_FOUR, // Kalimari Desert off course + /* 0x0E */ TRAIN_TRACK, // Kalimari Desert + /* 0x0F */ DIRT, // DK Jungle cave + /* 0x10 */ WOOD_TWO, // Bowser's Castle bridge 2, DK Jungle bridge + /* 0x11 */ WOOD_ONE, // Frappe Snowland bridge, Bowser's Castle bridge 1,3, Yoshi Valley bridge 2 + /* 0xFC */ BOOST_PAD_TWO = 0xFC, // DK Jungle + /* 0xFD */ OUT_OF_BOUNDS, // DK Jungle river island + /* 0xFE */ BOOST_PAD_ONE, // Royal Raceway + /* 0xFF */ RAMP // Koopa Troopa beach +}; + // This was added as a silly idea: // In the data to use "A, B, Z, R" instead of hex numbers. typedef enum { @@ -165,12 +190,33 @@ typedef struct { /* 0x46 */ s16 unk_046; } UnkPlayerStruct258; // size = 0x48 +typedef struct { + /* 0x00 */ f32 cornerX; + /* 0x04 */ f32 cornerY; + /* 0x08 */ f32 cornerZ; + // Type of surface the corner is above + /* 0x0C */ u8 surfaceType; + /* 0x0D */ u8 unk_0D; + // Don't know if "tile" is right the right term + // D_8015F580 is a pointer to an array of "tile" structs. This is an index to that array + /* 0x0E */ u16 tileIndex; + // cornerX/Y/Z place the corner "in the air" as it were, this member indicates the Y position of the corner's "on the ground" sibling + // On flat ground this value should be cornerY - gKartBoundingBoxTable[characterId] + /* 0x10 */ f32 cornerGroundY; + /* 0x14 */ s32 unk_14; +} kartBoundingBoxCorner; // size = 0x18 + +#define FRONT_LEFT_TYRE 0 +#define FRONT_RIGHT_TYRE 1 +#define BACK_LEFT_TYRE 2 +#define BACK_RIGHT_TYRE 3 + typedef struct { /* 0x0000 */ u16 unk_000; /* 0x0002 */ u16 unk_002; - /* 0x0004 */ s16 unk_004; // currentPosition + /* 0x0004 */ s16 currentRank; /* 0x0006 */ u16 unk_006; - /* 0x0008 */ s16 unk_008; // lapCount? + /* 0x0008 */ s16 lapCount; /* 0x000A */ char unk_00A[0x2]; /* 0x000C */ s32 unk_00C; /* 0x0010 */ s16 unk_010; @@ -269,38 +315,7 @@ typedef struct { /* 0x014C */ char unk_14C[0x4]; /* 0x0150 */ f32 unk_150[9]; /* 0x0174 */ f32 unk_174[9]; - /* 0x0198 */ f32 unk_198; - /* 0x019C */ f32 unk_19C; - /* 0x01A0 */ f32 unk_1A0; - /* 0x01A4 */ s8 frontLeftTyreSurface; - /* 0x01A5 */ s8 unk_1A5; - /* 0x01A6 */ s16 unk_1A6; - /* 0x01A8 */ f32 unk_1A8; - /* 0x01AC */ s32 unk_1AC; - /* 0x01B0 */ f32 unk_1B0; - /* 0x01B4 */ f32 unk_1B4; - /* 0x01B8 */ f32 unk_1B8; - /* 0x01BC */ s8 frontRightTyreSurface; - /* 0x01BD */ s8 unk_1BD; - /* 0x01BE */ s16 unk_1BE; - /* 0x01C0 */ f32 unk_1C0; - /* 0x01C4 */ s32 unk_1C4; - /* 0x01C8 */ f32 unk_1C8; - /* 0x01CC */ f32 unk_1CC; - /* 0x01D0 */ f32 unk_1D0; - /* 0x01D4 */ s8 backLeftTyreSurface; - /* 0x01D5 */ s8 unk_1D5; - /* 0x01D6 */ s16 unk_1D6; - /* 0x01D8 */ f32 unk_1D8; - /* 0x01DC */ s32 unk_1DC; - /* 0x01E0 */ f32 unk_1E0; - /* 0x01E4 */ f32 unk_1E4; - /* 0x01E8 */ f32 unk_1E8; - /* 0x01EC */ s8 backRightTyreSurface; - /* 0x01ED */ s8 unk_1ED; - /* 0x01EE */ s16 unk_1EE; - /* 0x01F0 */ f32 unk_1F0; - /* 0x01F4 */ s32 unk_1F4; + /* 0x0198 */ kartBoundingBoxCorner boundingBoxCorners[4]; /* 0x01F8 */ f32 unk_1F8; /* 0x01FC */ f32 unk_1FC; /* 0x0200 */ s32 unk_200; diff --git a/include/functions.h b/include/functions.h index b4db50000..52f164cac 100644 --- a/include/functions.h +++ b/include/functions.h @@ -13,7 +13,6 @@ f32 func_802AE1C0(f32 arg0, f32 arg1, f32 arg2); void func_802B6540(f32* arg0, f32 arg1, f32 arg2, f32 arg3, s16 arg4); void func_80295BF8(s32 arg0); void func_8005D6C0(Player* player); -void func_8006B87C(Player* player, s32 arg1); void func_8006B7E4(Player* player, s32 arg1); void func_8002D268(Player* player, s32 arg1, s8 arg2, s8 arg3); void func_8002934C(Player* player, s32 arg1, s8 arg2, s8 arg3); diff --git a/include/variables.h b/include/variables.h index 371417efc..84c2e88bc 100644 --- a/include/variables.h +++ b/include/variables.h @@ -5,6 +5,8 @@ #include "defines.h" #include "common_structs.h" +extern s32 gActiveScreenMode; // D_800DC52C + extern s32 gCCSelection; // D_800DC548 extern s8 gCharacterIdByGPOverallRank[8]; // D_8018D9D0 extern s8 gCharacterGridSelections[4]; // D_8018EDE4 @@ -43,6 +45,9 @@ extern f32 gKartFrictionTable[]; extern f32 gKartBoundingBoxTable[]; extern f32 gKartGravityTable[]; +extern f32 gLapCompletionPercentByPlayerId[8]; // D_801644A8 +extern s32 gLapCountByPlayerId[8]; // D_80164390 + extern s32 gMenuTimingCounter; // D_8018EE00 extern s32 gMenuSelection; // D_800E86A0 extern s32 gModeSelection; // D_800DC53C @@ -59,6 +64,7 @@ extern s32 gPlayerPositions[]; // D_801643B8 extern u8 gSaveDataSoundMode; // D_8018ED14 extern u8 gSaveDataSoundModeBackup; // D_8018ED8C +//extern u32 gScreenModeSelection; // D_800DC530 extern u32 gSegmentTable[16]; // D_80150258 extern OSMesgQueue gSIEventMesgQueue; // D_8014F0B8 extern u8 gSoundMode; // D_8018EDF2 @@ -86,7 +92,7 @@ extern Player* gPlayerOneCopy; extern SaveData D_8018EB90; -extern Mtx D_80183D60; +extern Mtx D_80183D60[]; extern struct_D_8018CE10 D_8018CE10[]; extern struct_D_802874D8 D_802874D8; @@ -103,7 +109,6 @@ extern Gfx D_0D0077A0[]; extern s32 D_800DC50C; extern u16 D_800DC51C; -extern s32 gActiveScreenMode; // D_800DC52C extern s32 D_800DC540; extern u16 D_800DC5FC; diff --git a/src/code_80005FD0.c b/src/code_80005FD0.c index f61023346..7789c2dad 100644 --- a/src/code_80005FD0.c +++ b/src/code_80005FD0.c @@ -1968,7 +1968,7 @@ extern ? D_80164376; extern s16 D_80164386; extern ? D_801643BA; extern ? D_80164450; -extern ? D_801644A8; +extern ? gLapCompletionPercentByPlayerId; extern ? D_80164538; extern u16 D_801645C8; extern ? gPlayers; @@ -2048,7 +2048,7 @@ extern ? gPlayers; phi_a1_2 = -temp_a2; } if (temp_t2 < 0x18) { - temp_f0 = *(&D_801644A8 + temp_t0); + temp_f0 = *(&gLapCompletionPercentByPlayerId + temp_t0); phi_a0 = (temp_a3->unk10 * temp_f0) + (temp_a3->unk0 * (1.0f - temp_f0)); } else { phi_a0 = temp_a3->unk0; @@ -2072,7 +2072,7 @@ extern ? gPlayers; phi_a1_4 = -phi_a1_3; } if (temp_t2 < 0x18) { - temp_f0_2 = *(&D_801644A8 + temp_t0); + temp_f0_2 = *(&gLapCompletionPercentByPlayerId + temp_t0); phi_a0_2 = (temp_a3->unk10 * temp_f0_2) + (temp_a3->unk0 * (1.0f - temp_f0_2)); } else { phi_a0_2 = temp_a3->unk0; @@ -2129,7 +2129,7 @@ extern ? gPlayers; } if (temp_t2 < 0x18) { temp_a2_2 = temp_a3 + (phi_t1 * 2); - temp_f0_3 = *(&D_801644A8 + temp_t0); + temp_f0_3 = *(&gLapCompletionPercentByPlayerId + temp_t0); phi_a0_5 = (temp_a2_2->unk10 * temp_f0_3) + (temp_a2_2->unk0 * (1.0f - temp_f0_3)); } else { phi_a0_5 = *(temp_a3 + (phi_t1 * 2)); @@ -2226,11 +2226,11 @@ GLOBAL_ASM("asm/non_matchings/code_80005FD0/func_80008E58.s") extern s16 D_80162FCE; extern ? D_80164438; extern ? D_80164450; -extern ? D_801644A8; +extern ? gLapCompletionPercentByPlayerId; extern ? gCourseCompletionPercentByPlayerId; extern ? D_801645B0; extern u16 D_801645C8; -extern ? lapCount; +extern ? gLapCountByPlayerId; void func_80008F38(s32 arg0) { f32 temp_f0; @@ -2245,7 +2245,7 @@ void func_80008F38(s32 arg0) { f32 phi_f16; temp_v0 = arg0 * 4; - temp_v1 = *(&lapCount + temp_v0); + temp_v1 = *(&gLapCountByPlayerId + temp_v0); temp_a1 = arg0 * 2; temp_t0 = *(&D_80164438 + temp_a1); temp_f6 = temp_t0; @@ -2261,7 +2261,7 @@ void func_80008F38(s32 arg0) { phi_f16 = temp_f16 + 4294967296.0f; } temp_f0 = phi_f6 / phi_f16; - *(&D_801644A8 + temp_v0) = temp_f0; + *(&gLapCompletionPercentByPlayerId + temp_v0) = temp_f0; *(&gCourseCompletionPercentByPlayerId + temp_v0) = temp_f0 + temp_v1; } #else @@ -2418,7 +2418,7 @@ extern s32 D_80164408; extern s32 D_8016440C; extern ? D_80164438; extern ? D_801645C8; -extern ? lapCount; +extern ? gLapCountByPlayerId; void func_8000929C(s32 arg0, void *arg1) { f32 sp4C; @@ -2505,7 +2505,7 @@ void func_8000929C(s32 arg0, void *arg1) { if (arg1->unk14 < 300.0f) { phi_v1 = 1; phi_t0 = 1; - } else if ((arg1->unk14 < D_800ECFA8) && (*(&lapCount + (phi_a0 * 4)) < 2) && (phi_a3_2 = phi_a0 * 4, (D_801634EC == 1))) { + } else if ((arg1->unk14 < D_800ECFA8) && (*(&gLapCountByPlayerId + (phi_a0 * 4)) < 2) && (phi_a3_2 = phi_a0 * 4, (D_801634EC == 1))) { phi_v1 = 1; phi_t0 = 1; } else { @@ -2517,7 +2517,7 @@ void func_8000929C(s32 arg0, void *arg1) { phi_v1 = 1; phi_t0 = 1; } else { - if ((D_800ECFAC < arg1->unk14) && (*(&lapCount + (phi_a0 * 4)) < 2) && (D_801634EC == 1)) { + if ((D_800ECFAC < arg1->unk14) && (*(&gLapCountByPlayerId + (phi_a0 * 4)) < 2) && (D_801634EC == 1)) { phi_v1 = 1; phi_t0 = 1; } @@ -2535,12 +2535,12 @@ block_25: if (phi_v1 != 0) { temp_f0_2 = D_8016344C; if (sp44 <= temp_f0_2) { - temp_v0_3 = phi_a3_2 + &lapCount; + temp_v0_3 = phi_a3_2 + &gLapCountByPlayerId; if (temp_f0_2 < sp38) { temp_t1 = *temp_v0_3 + 1; *temp_v0_3 = temp_t1; if ((gModeSelection == GRAND_PRIX) && (temp_t1 == 5)) { - phi_v0 = &lapCount; + phi_v0 = &gLapCountByPlayerId; if (*(&D_80164408 + phi_a3_2) == 7) { do { temp_v0_4 = phi_v0 + 0x10; @@ -2575,7 +2575,7 @@ block_25: if (phi_t0 != 0) { temp_f0_3 = D_8016344C; if (sp38 <= temp_f0_3) { - temp_v0_5 = phi_a3_2 + &lapCount; + temp_v0_5 = phi_a3_2 + &gLapCountByPlayerId; if (temp_f0_3 < sp44) { arg0 = phi_a0_2; *temp_v0_5 = *temp_v0_5 - 1; @@ -2844,7 +2844,7 @@ extern ? D_80163504; extern u16 D_80164430; extern ? D_80164438; extern ? D_80164450; -extern ? D_801644A8; +extern ? gLapCompletionPercentByPlayerId; extern ? D_801644D0; extern ? D_80164590; extern ? D_801645B0; @@ -2967,7 +2967,7 @@ void func_80009B60(s32 arg0) { if ((temp_v1->unk0 & 0x8000) == 0) { *(&D_80164450 + temp_a3) = -0x14; *(&gCourseCompletionPercentByPlayerId + temp_a3) = -1000.0f; - *(&D_801644A8 + temp_a3) = -1000.0f; + *(&gLapCompletionPercentByPlayerId + temp_a3) = -1000.0f; return; } temp_v0_2 = temp_a2 + &D_801633E0; @@ -6370,7 +6370,7 @@ extern s16 D_8016479E; extern ? D_801647A8; extern s8 D_8018EE08; extern ? gPlayers; -extern s32 lapCount; +extern s32 gLapCountByPlayerId; void func_8000F628(void) { void *sp104; @@ -6480,7 +6480,7 @@ void func_8000F628(void) { s16 phi_s1_5; spD4 = &D_80163210; - spD0 = &lapCount; + spD0 = &gLapCountByPlayerId; spB8 = &D_80163258; spBC = &D_80164408; spCC = &gCourseCompletionPercentByPlayerId; @@ -13374,7 +13374,7 @@ void func_8001AC10(s32 playerId, s32 *arg2) { case 0: /* switch 1 */ temp_s0->unk2 = -1; temp_v0 = playerId * 4; - if ((((playerId * 0x14) + 0x64) < *(&D_80164450 + temp_v0)) && (temp_s0->unk4 >= 0x259) && (temp_s0->unk6 < 3) && (temp_v1 = lapCount[playerId], ((temp_v1 < 3) != 0))) { + if ((((playerId * 0x14) + 0x64) < *(&D_80164450 + temp_v0)) && (temp_s0->unk4 >= 0x259) && (temp_s0->unk6 < 3) && (temp_v1 = gLapCountByPlayerId[playerId], ((temp_v1 < 3) != 0))) { func_8001AB74(playerId, temp_s0, func_8007AF78(temp_v1, (&gPlayerPositions + temp_v0)->unk2, &gPlayerPositions)); } else { func_8001ABE0(playerId, temp_s0); @@ -13383,7 +13383,7 @@ void func_8001AC10(s32 playerId, s32 *arg2) { block_194: break; case 1: /* switch 1 */ - if ((lapCount[playerId] > 0) && (temp_v1_2 = D_80163478, temp_a0 = *(&gPlayerPositions + (temp_v1_2 * 4)), ((temp_a0 < *(&gPlayerPositions + (playerId * 4))) != 0)) && (temp_a0 == 0)) { + if ((gLapCountByPlayerId[playerId] > 0) && (temp_v1_2 = D_80163478, temp_a0 = *(&gPlayerPositions + (temp_v1_2 * 4)), ((temp_a0 < *(&gPlayerPositions + (playerId * 4))) != 0)) && (temp_a0 == 0)) { temp_v0_2 = sp2C->unk254; if (temp_v0_2 != 4) { if (temp_v0_2 != 6) { diff --git a/src/code_80027D00.c b/src/code_80027D00.c index 4a4c89421..05ab03a8a 100644 --- a/src/code_80027D00.c +++ b/src/code_80027D00.c @@ -1038,20 +1038,17 @@ GLOBAL_ASM("asm/non_matchings/code_80027D00/func_8002934C.s") #endif #ifdef MIPS_TO_C -//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307 -? move_f32_towards(void *, f32, ?); // extern -? move_s16_towards(void *, s16, ?); // extern -s32 func_802ABD10(u16); // extern -? func_802AFA34(void *, void *, f32, f32, f32); // extern -? func_802B63B8(f32, f32 *, f32 *, f32 *); // extern -s32 func_802B7C40(f32); // extern -extern ? D_800DDBD4; -extern f64 D_800ED798; -extern f64 D_800ED7A0; -extern f64 D_800ED7A8; -extern f64 D_800ED7B0; +//generated by mips_to_c commit 792017ad9d422c2467bd42686f383a5c41f41c75 +s32 func_802ABD10(u16); /* extern */ +? func_802AFA34(Player *, kartBoundingBoxCorner *, f32, f32, f32); /* extern */ +? func_802B63B8(f32, f32 *, f32 *, f32 *); /* extern */ +? func_802B6540(f32, f32 *, ?, ?, ?, s32); /* extern */ +s32 func_802B7C40(f32); /* extern */ +? move_f32_towards(f32 *, f32, ?); /* extern */ +? move_s16_towards(s16 *, s16, ?); /* extern */ +static f32 D_800DDBD4[8] = { 0.75f, 0.75f, 0.75f, 0.75f, 0.75f, 0.75f, 0.75f, 0.75f }; -void func_80029B4C(void *arg0, ? arg1, f32 arg2, ? arg3) { +void func_80029B4C(Player *player, f32 arg1, f32 arg2, f32 arg3) { f32 sp94; f32 sp90; f32 sp8C; @@ -1088,118 +1085,118 @@ void func_80029B4C(void *arg0, ? arg1, f32 arg2, ? arg3) { s16 phi_a1; s32 phi_v1; - if ((arg0->unkBC & 0x40000000) == 0x40000000) { - phi_f12 = (*(&D_800DDBD4 + (arg0->unk254 * 4)) / 2.0f) * (arg0->unk224 * 1.5) * 18.0; + if ((player->unk_0BC & 0x40000000) == 0x40000000) { + phi_f12 = (f32) ((f64) (D_800DDBD4[player->characterId] / 2.0f) * ((f64) player->unk_224 * 1.5) * 18.0); } else { - phi_f12 = (*(&D_800DDBD4 + (arg0->unk254 * 4)) / 2.0f) * 18.0f; + phi_f12 = (D_800DDBD4[player->characterId] / 2.0f) * 18.0f; } sp48 = phi_f12; - func_802B6540(&sp5C, 0.0f, 1.0f, 0.0f, arg0->unk2E + arg0->unkC0); - temp_f0 = phi_f12; + func_802B6540(phi_f12, &sp5C, 0, 0x3F800000, 0, player->unk_02E + player->unk_0C0); + temp_f0 = (f64) sp48; temp_a0 = &sp8C; - temp_f2 = phi_f12 - 2.0f; - sp8C = temp_f0 - D_800ED798; + temp_f2 = sp48 - 2.0f; + sp8C = (f32) (temp_f0 - 3.6); sp38 = temp_f0; sp94 = temp_f2; sp40 = temp_f2; - sp90 = -arg0->unk70; - func_802B63B8(phi_f12, temp_a0, &sp5C); - sp80 = arg0->unk198; - sp84 = arg0->unk19C; - sp88 = arg0->unk1A0; - arg0->unk198 = sp8C + arg0->unk14; - arg0->unk19C = sp90 + arg0->unk18; - arg0->unk1A0 = sp94 + arg0->unk1C; - func_802AFA34(arg0, arg0 + 0x198, sp80, sp84, sp88); - temp_f14 = -phi_f12; - temp_f2_2 = temp_f14; + sp90 = -player->unk_070; + func_802B63B8(sp48, temp_a0, &sp5C); + sp80 = player->boundingBoxCorners[0].cornerX; + sp84 = player->boundingBoxCorners[0].cornerY; + sp88 = player->boundingBoxCorners[0].cornerZ; + player->boundingBoxCorners[0].cornerX = sp8C + player->posX; + player->boundingBoxCorners[0].cornerY = sp90 + player->posY; + player->boundingBoxCorners[0].cornerZ = sp94 + player->posZ; + func_802AFA34(player, player->boundingBoxCorners, sp80, sp84, sp88); + temp_f14 = -sp48; + temp_f2_2 = (f64) temp_f14; temp_a0_2 = &sp8C; - sp8C = temp_f2_2 + D_800ED7A0; + sp8C = (f32) (temp_f2_2 + 3.6); sp34 = temp_f14; sp28 = temp_f2_2; sp94 = sp40; - sp90 = -arg0->unk70; - func_802B63B8(phi_f12, (bitwise f32 *) temp_f14, temp_a0_2, &sp5C); - sp80 = arg0->unk1B0; - sp84 = arg0->unk1B4; - sp88 = arg0->unk1B8; - arg0->unk1B0 = sp8C + arg0->unk14; - arg0->unk1B4 = sp90 + arg0->unk18; - arg0->unk1B8 = sp94 + arg0->unk1C; - func_802AFA34(arg0, arg0 + 0x1B0, sp80, sp84, sp88); + sp90 = -player->unk_070; + func_802B63B8(sp48, (bitwise f32 *) temp_f14, temp_a0_2, &sp5C); + sp80 = player->boundingBoxCorners[1].cornerX; + sp84 = player->boundingBoxCorners[1].cornerY; + sp88 = player->boundingBoxCorners[1].cornerZ; + player->boundingBoxCorners[1].cornerX = sp8C + player->posX; + player->boundingBoxCorners[1].cornerY = sp90 + player->posY; + player->boundingBoxCorners[1].cornerZ = sp94 + player->posZ; + func_802AFA34(player, &player->boundingBoxCorners[1], sp80, sp84, sp88); temp_a0_3 = &sp8C; temp_f12 = sp34 + 4.0f; - sp8C = temp_f0 - D_800ED7A8; + sp8C = (f32) (sp38 - 2.6); sp94 = temp_f12; sp40 = temp_f12; - sp90 = -arg0->unk70; + sp90 = -player->unk_070; func_802B63B8(temp_f12, temp_a0_3, &sp5C); - sp80 = arg0->unk1C8; - sp84 = arg0->unk1CC; - sp88 = arg0->unk1D0; - arg0->unk1C8 = sp8C + arg0->unk14; - arg0->unk1CC = sp90 + arg0->unk18; - arg0->unk1D0 = sp94 + arg0->unk1C; - func_802AFA34(arg0, arg0 + 0x1C8, sp80, sp84, sp88); + sp80 = player->boundingBoxCorners[2].cornerX; + sp84 = player->boundingBoxCorners[2].cornerY; + sp88 = player->boundingBoxCorners[2].cornerZ; + player->boundingBoxCorners[2].cornerX = sp8C + player->posX; + player->boundingBoxCorners[2].cornerY = sp90 + player->posY; + player->boundingBoxCorners[2].cornerZ = sp94 + player->posZ; + func_802AFA34(player, &player->boundingBoxCorners[2], sp80, sp84, sp88); temp_a0_4 = &sp8C; - sp8C = temp_f2_2 + D_800ED7B0; + sp8C = (f32) (sp28 + 2.6); sp94 = sp40; - sp90 = -arg0->unk70; + sp90 = -player->unk_070; func_802B63B8((bitwise f32) temp_a0_4, &sp5C); - sp80 = arg0->unk1E0; - sp84 = arg0->unk1E4; - sp88 = arg0->unk1E8; - arg0->unk1E0 = sp8C + arg0->unk14; - arg0->unk1E4 = sp90 + arg0->unk18; - arg0->unk1E8 = sp94 + arg0->unk1C; - func_802AFA34(arg0, arg0 + 0x1E0, sp80, sp84, sp88); - if ((arg0->unkBC & 8) == 0) { - move_f32_towards(arg0 + 0x230, (arg0->unk1A8 + arg0->unk1D8) / 2.0f, 0x3F000000); - move_f32_towards(arg0 + 0x23C, (arg0->unk1C0 + arg0->unk1F0) / 2.0f, 0x3F000000); - move_f32_towards(arg0 + 0x1FC, (arg0->unk1A8 + arg0->unk1C0) / 2.0f, 0x3F000000); - move_f32_towards(arg0 + 0x1F8, (arg0->unk1D8 + arg0->unk1F0) / 2.0f, 0x3F000000); + sp80 = player->boundingBoxCorners[3].cornerX; + sp84 = player->boundingBoxCorners[3].cornerY; + sp88 = player->boundingBoxCorners[3].cornerZ; + player->boundingBoxCorners[3].cornerX = sp8C + player->posX; + player->boundingBoxCorners[3].cornerY = sp90 + player->posY; + player->boundingBoxCorners[3].cornerZ = sp94 + player->posZ; + func_802AFA34(player, &player->boundingBoxCorners[3], sp80, sp84, sp88); + if ((player->unk_0BC & 8) == 0) { + move_f32_towards(&player->unk_230, (player->boundingBoxCorners[0].cornerGroundY + player->boundingBoxCorners[2].cornerGroundY) / 2.0f, 0.5f); + move_f32_towards(&player->unk_23C, (player->boundingBoxCorners[1].cornerGroundY + player->boundingBoxCorners[3].cornerGroundY) / 2.0f, 0.5f); + move_f32_towards(&player->unk_1FC, (player->boundingBoxCorners[0].cornerGroundY + player->boundingBoxCorners[1].cornerGroundY) / 2.0f, 0.5f); + move_f32_towards(&player->unk_1F8, (player->boundingBoxCorners[2].cornerGroundY + player->boundingBoxCorners[3].cornerGroundY) / 2.0f, 0.5f); } - temp_f2_3 = ((*(&D_800DDBD4 + (arg0->unk254 * 4)) * 18.0f) + 1.0f) * arg0->unk224; + temp_f2_3 = ((D_800DDBD4[player->characterId] * 18.0f) + 1.0f) * player->unk_224; sp50 = temp_f2_3; - arg0->unk206 = -func_802B7C40((arg0->unk23C - arg0->unk230) / temp_f2_3); - if (((arg0->unkCA & 2) == 2) || (temp_t2 = arg0->unkBC & 8, phi_v0 = temp_t2, (temp_t2 != 0))) { - arg0->unk206 = 0; - phi_v0 = arg0->unkBC & 8; + player->unk_206 = (s16) -func_802B7C40((player->unk_23C - player->unk_230) / temp_f2_3); + if (((player->unk_0CA & 2) == 2) || (temp_t2 = player->unk_0BC & 8, phi_v0 = temp_t2, (temp_t2 != 0))) { + player->unk_206 = 0; + phi_v0 = player->unk_0BC & 8; } if (phi_v0 != 8) { - move_s16_towards(arg0 + 0xC4, func_802B7C40((arg0->unk1F8 - arg0->unk1FC) / temp_f2_3), 0x3F000000); + move_s16_towards(&player->unk_0C4, func_802B7C40((player->unk_1F8 - player->unk_1FC) / temp_f2_3), 0x3F000000); } else { - temp_f0_2 = arg0->unk24 - arg2; + temp_f0_2 = player->rotY - arg2; sp54 = temp_f0_2; temp_v0 = func_802B7C40(temp_f0_2 / temp_f2_3); - phi_a1 = temp_v0 * 0xA; + phi_a1 = (s16) (temp_v0 * 0xA); if (temp_f0_2 >= 0.0f) { - phi_a1 = temp_v0 / 4; + phi_a1 = (s16) (temp_v0 / 4); } - move_s16_towards(arg0 + 0xC4, phi_a1, 0x3F000000); + move_s16_towards(&player->unk_0C4, phi_a1, 0x3F000000); } - if (((arg0->unkBC & 8) == 8) && ((arg0->unkCA & 2) == 2)) { - arg0->unkC4 = arg0->unkD9C; + if (((player->unk_0BC & 8) == 8) && ((player->unk_0CA & 2) == 2)) { + player->unk_0C4 = (s16) (s32) player->unk_D9C; } - temp_t5 = func_802ABD10(arg0->unk11A) & 0xFF; + temp_t5 = func_802ABD10((u16) player->unk_11A) & 0xFF; temp_v1 = temp_t5 & 0xFFFF; - arg0->unkF8 = temp_t5; + player->unkF8 = temp_t5; phi_v1 = temp_v1; if (temp_v1 == 0xFE) { - temp_v0_2 = arg0->unkBC; + temp_v0_2 = player->unk_0BC; phi_v1 = temp_v1; if ((temp_v0_2 & 0x100000) != 0x100000) { phi_v1 = temp_v1; if ((temp_v0_2 & 8) != 8) { - arg0->unkC = arg0->unkC | 0x800000; + player->unk_00C |= 0x800000; phi_v1 = temp_t5 & 0xFFFF; } } } if (phi_v1 == 0xFC) { - temp_v0_3 = arg0->unkBC; + temp_v0_3 = player->unk_0BC; if (((temp_v0_3 & 4) != 4) && ((temp_v0_3 & 8) != 8)) { - arg0->unkC = arg0->unkC | 0x8000; + player->unk_00C |= 0x8000; } } } @@ -1208,17 +1205,15 @@ GLOBAL_ASM("asm/non_matchings/code_80027D00/func_80029B4C.s") #endif #ifdef MIPS_TO_C -//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307 -? move_s16_towards(void *, s16, ?); // extern -s32 func_802ABD10(u16); // extern -s32 func_802ABD7C(u16); // extern -f32 func_802ABE30(f32, f32, f32, u16); // extern -s32 func_802B7C40(f32); // extern -f32 sins(s32); // extern -f32 coss(s32); // extern -extern ? D_800DDBD4; +//generated by mips_to_c commit 792017ad9d422c2467bd42686f383a5c41f41c75 +s32 func_802ABD10(u16); /* extern */ +s32 func_802ABD7C(u16); /* extern */ +f32 func_802ABE30(f32, f32, f32, u16); /* extern */ +s32 func_802B7C40(f32); /* extern */ +? move_s16_towards(s16 *, s16, ?); /* extern */ +static f32 D_800DDBD4[8] = { 0.75f, 0.75f, 0.75f, 0.75f, 0.75f, 0.75f, 0.75f, 0.75f }; -void func_8002A194(void *arg0, f32 arg1, f32 arg2, f32 arg3) { +void func_8002A194(Player *player, f32 arg1, f32 arg2, f32 arg3) { s16 sp3A; f32 sp30; s32 sp28; @@ -1243,81 +1238,81 @@ void func_8002A194(void *arg0, f32 arg1, f32 arg2, f32 arg3) { f32 phi_f20; s16 phi_a1; - temp_v1 = -arg0->unk2E - arg0->unkC0; - if ((arg0->unkBC & 0x40000000) == 0x40000000) { - phi_f20 = (((*(&D_800DDBD4 + (arg0->unk254 * 4)) * 18.0f) / 2.0f) * (arg0->unk224 * 1.5)) - 1.0; + temp_v1 = -(s32) player->unk_02E - player->unk_0C0; + if ((player->unk_0BC & 0x40000000) == 0x40000000) { + phi_f20 = (f32) (((f64) ((D_800DDBD4[player->characterId] * 18.0f) / 2.0f) * ((f64) player->unk_224 * 1.5)) - 1.0); } else { - phi_f20 = (((*(&D_800DDBD4 + (arg0->unk254 * 4)) * 18.0f) / 2.0f) * arg0->unk224) - 1.0f; + phi_f20 = (((D_800DDBD4[player->characterId] * 18.0f) / 2.0f) * player->unk_224) - 1.0f; } temp_t7 = (temp_v1 + 0x2000) & 0xFFFF; sp28 = temp_t7; sp3A = temp_v1; - arg0->unk1A0 = (coss(temp_t7) * phi_f20) + arg3; - temp_f12 = (sins(sp28) * phi_f20) + arg1; - arg0->unk198 = temp_f12; - arg0->unk1A8 = func_802ABE30(temp_f12, arg2, arg0->unk1A0, arg0->unk11A); + player->boundingBoxCorners[0].cornerZ = (coss((u16) temp_t7) * phi_f20) + arg3; + temp_f12 = (sins((u16) sp28) * phi_f20) + arg1; + player->boundingBoxCorners[0].cornerX = temp_f12; + player->boundingBoxCorners[0].cornerGroundY = func_802ABE30(temp_f12, arg2, player->boundingBoxCorners[0].cornerZ, (u16) player->unk_11A); temp_t8 = (sp3A - 0x2000) & 0xFFFF; sp28 = temp_t8; - arg0->unk1B8 = (coss(temp_t8) * phi_f20) + arg3; - temp_f12_2 = (sins(sp28) * phi_f20) + arg1; - arg0->unk1B0 = temp_f12_2; - arg0->unk1C0 = func_802ABE30(temp_f12_2, arg2, arg0->unk1B8, arg0->unk11A); + player->boundingBoxCorners[1].cornerZ = (coss((u16) temp_t8) * phi_f20) + arg3; + temp_f12_2 = (sins((u16) sp28) * phi_f20) + arg1; + player->boundingBoxCorners[1].cornerX = temp_f12_2; + player->boundingBoxCorners[1].cornerGroundY = func_802ABE30(temp_f12_2, arg2, player->boundingBoxCorners[1].cornerZ, (u16) player->unk_11A); temp_t9 = (sp3A + 0x6000) & 0xFFFF; sp28 = temp_t9; - arg0->unk1D0 = (coss(temp_t9) * phi_f20) + arg3; - temp_f12_3 = (sins(sp28) * phi_f20) + arg1; - arg0->unk1C8 = temp_f12_3; - arg0->unk1D8 = func_802ABE30(temp_f12_3, arg2, arg0->unk1D0, arg0->unk11A); + player->boundingBoxCorners[2].cornerZ = (coss((u16) temp_t9) * phi_f20) + arg3; + temp_f12_3 = (sins((u16) sp28) * phi_f20) + arg1; + player->boundingBoxCorners[2].cornerX = temp_f12_3; + player->boundingBoxCorners[2].cornerGroundY = func_802ABE30(temp_f12_3, arg2, player->boundingBoxCorners[2].cornerZ, (u16) player->unk_11A); temp_t0 = (sp3A - 0x6000) & 0xFFFF; sp28 = temp_t0; - arg0->unk1E8 = (coss(temp_t0) * phi_f20) + arg3; - arg0->unk1E0 = (sins(sp28) * phi_f20) + arg1; - arg0->unk1F0 = func_802ABE30(arg0->unk1C8, arg2, arg0->unk1D0, arg0->unk11A); - if ((arg0->unkBC & 8) != 8) { - temp_f0 = arg0->unk1A8; - temp_f2 = arg0->unk1D8; - temp_f12_4 = arg0->unk1C0; - temp_f14 = arg0->unk1F0; - arg0->unk230 = (temp_f0 + temp_f2) / 2.0f; - arg0->unk23C = (temp_f12_4 + temp_f14) / 2.0f; - arg0->unk1FC = (temp_f0 + temp_f12_4) / 2.0f; - arg0->unk1F8 = (temp_f2 + temp_f14) / 2.0f; + player->boundingBoxCorners[3].cornerZ = (coss((u16) temp_t0) * phi_f20) + arg3; + player->boundingBoxCorners[3].cornerX = (sins((u16) sp28) * phi_f20) + arg1; + player->boundingBoxCorners[3].cornerGroundY = func_802ABE30(player->boundingBoxCorners[2].cornerX, arg2, player->boundingBoxCorners[2].cornerZ, (u16) player->unk_11A); + if ((player->unk_0BC & 8) != 8) { + temp_f0 = player->boundingBoxCorners[0].cornerGroundY; + temp_f2 = player->boundingBoxCorners[2].cornerGroundY; + temp_f12_4 = player->boundingBoxCorners[1].cornerGroundY; + temp_f14 = player->boundingBoxCorners[3].cornerGroundY; + player->unk_230 = (temp_f0 + temp_f2) / 2.0f; + player->unk_23C = (temp_f12_4 + temp_f14) / 2.0f; + player->unk_1FC = (temp_f0 + temp_f12_4) / 2.0f; + player->unk_1F8 = (temp_f2 + temp_f14) / 2.0f; } - temp_v1_2 = func_802ABD10(arg0->unk11A) & 0xFF; - arg0->unkF8 = temp_v1_2; - arg0->unk1EC = temp_v1_2; - arg0->unk1D4 = temp_v1_2; - arg0->unk1BC = temp_v1_2; - arg0->unk1A4 = temp_v1_2; - temp_f20 = (*(&D_800DDBD4 + (arg0->unk254 * 4)) * 18.0f) + 1.0f; - arg0->unk206 = -func_802B7C40((arg0->unk23C - arg0->unk230) / temp_f20); - if ((arg0->unkBC & 8) != 8) { - move_s16_towards(arg0 + 0xC4, func_802B7C40((arg0->unk1F8 - arg0->unk1FC) / temp_f20), 0x3F000000); + temp_v1_2 = func_802ABD10((u16) player->unk_11A) & 0xFF; + player->unkF8 = temp_v1_2; + player->boundingBoxCorners[3].surfaceType = (u8) temp_v1_2; + player->boundingBoxCorners[2].surfaceType = (u8) temp_v1_2; + player->boundingBoxCorners[1].surfaceType = (u8) temp_v1_2; + player->boundingBoxCorners[0].surfaceType = (u8) temp_v1_2; + temp_f20 = (D_800DDBD4[player->characterId] * 18.0f) + 1.0f; + player->unk_206 = (s16) -func_802B7C40((player->unk_23C - player->unk_230) / temp_f20); + if ((player->unk_0BC & 8) != 8) { + move_s16_towards(&player->unk_0C4, func_802B7C40((player->unk_1F8 - player->unk_1FC) / temp_f20), 0x3F000000); } else { - temp_f0_2 = arg0->unk24 - arg2; + temp_f0_2 = player->rotY - arg2; sp30 = temp_f0_2; temp_v0 = func_802B7C40(temp_f0_2 / temp_f20); - phi_a1 = temp_v0 * 0xA; + phi_a1 = (s16) (temp_v0 * 0xA); if (temp_f0_2 >= 0.0f) { - phi_a1 = (temp_v0 << 0x11) >> 0x10; + phi_a1 = (s16) (temp_v0 * 2); } - move_s16_towards(arg0 + 0xC4, phi_a1, 0x3F000000); + move_s16_towards(&player->unk_0C4, phi_a1, 0x3F000000); } - if (func_802ABD7C(arg0->unk11A) != 0) { - arg0->unk1F4 = arg0->unk1F4 | 1; + if (func_802ABD7C((u16) player->unk_11A) != 0) { + player->boundingBoxCorners[3].unk_14 |= 1; } else { - arg0->unk1F4 = arg0->unk1F4 & ~1; + player->boundingBoxCorners[3].unk_14 &= -2; } - if (arg0->unkF8 == 0xFE) { - temp_v0_2 = arg0->unkBC; + if (player->unkF8 == 0xFE) { + temp_v0_2 = player->unk_0BC; if (((temp_v0_2 & 0x100000) != 0x100000) && ((temp_v0_2 & 8) != 8)) { - arg0->unkC = arg0->unkC | 0x800000; + player->unk_00C |= 0x800000; } } - if (arg0->unkF8 == 0xFC) { - temp_v0_3 = arg0->unkBC; + if (player->unkF8 == 0xFC) { + temp_v0_3 = player->unk_0BC; if (((temp_v0_3 & 4) != 4) && ((temp_v0_3 & 8) != 8)) { - arg0->unkC = arg0->unkC | 0x8000; + player->unk_00C |= 0x8000; } } } @@ -3397,27 +3392,28 @@ GLOBAL_ASM("asm/non_matchings/code_80027D00/func_8002D268.s") #endif #ifdef MIPS_TO_C -//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307 -s32 get_player_index_for_player(); // extern +//generated by mips_to_c commit 792017ad9d422c2467bd42686f383a5c41f41c75 +f32 func_802AE1C0(f32, f32, Player *, f32); /* extern */ +s32 get_player_index_for_player(); /* extern */ -void func_8002E4C4(void *arg0) { +void func_8002E4C4(Player *player) { s32 sp1C; f32 temp_f12; f32 temp_f2; s32 temp_v0; - temp_v0 = get_player_index_for_player(); + temp_v0 = get_player_index_for_player(player); sp1C = temp_v0; - arg0->unkF0 = 0.0f; - arg0->unkF4 = 0.0f; - arg0->unkEC = 0.0f; - temp_f2 = func_802AE1C0(arg0->unk14, D_80164510[temp_v0] + 10.0f, arg0->unk1C) + arg0->unk70; - arg0->unk18 = temp_f2; + player->kartHopJerk = 0.0f; + player->kartHopAcceleration = 0.0f; + player->kartHopVelocity = 0.0f; + temp_f2 = func_802AE1C0(player->posX, D_80164510[temp_v0] + 10.0f, player, player->posZ) + player->unk_070; + player->posY = temp_f2; temp_f12 = D_80164510[sp1C]; - if (((temp_f2 - temp_f12) > 1200.0f) || ((arg0->unk18 - temp_f12) < -1200.0f)) { - arg0->unk18 = arg0->unk24; + if (((temp_f2 - temp_f12) > 1200.0f) || ((player->posY - temp_f12) < -1200.0f)) { + player->posY = player->rotY; } - arg0->unk38 = 0.0f; + player->unk_038 = 0.0f; } #else GLOBAL_ASM("asm/non_matchings/code_80027D00/func_8002E4C4.s") @@ -4116,11 +4112,8 @@ GLOBAL_ASM("asm/non_matchings/code_80027D00/func_8002F730.s") #endif #ifdef MIPS_TO_C -//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307 -extern ? D_800E2A90; -extern ? D_800E2AB0; - -void func_8002FCA8(void *arg0, s8 arg1) { +//generated by mips_to_c commit 792017ad9d422c2467bd42686f383a5c41f41c75 +void func_8002FCA8(Player *player, s8 arg1) { f32 temp_f2; s32 temp_lo; s32 temp_v0; @@ -4136,28 +4129,28 @@ void func_8002FCA8(void *arg0, s8 arg1) { f32 phi_f0_4; f32 phi_f0_5; - temp_v0 = arg0->unkBC; + temp_v0 = player->unk_0BC; phi_f0_2 = 0.0f; phi_f0_5 = 0.0f; if ((temp_v0 & 0x200) != 0x200) { - temp_v1 = arg0->unk1EC; - if (temp_v1 < 0xF) { - phi_f0_5 = 0.0f + *(*(&D_800E2A90 + (arg0->unk254 * 4)) + (temp_v1 * 4)); + temp_v1 = player->boundingBoxCorners[3].surfaceType; + if ((s32) temp_v1 < 0xF) { + phi_f0_5 = 0.0f + D_800E2A90[player->characterId][temp_v1]; } - temp_v1_2 = arg0->unk1D4; + temp_v1_2 = player->boundingBoxCorners[2].surfaceType; phi_f0_4 = phi_f0_5; - if (temp_v1_2 < 0xF) { - phi_f0_4 = phi_f0_5 + *(*(&D_800E2A90 + (arg0->unk254 * 4)) + (temp_v1_2 * 4)); + if ((s32) temp_v1_2 < 0xF) { + phi_f0_4 = phi_f0_5 + D_800E2A90[player->characterId][temp_v1_2]; } - temp_v1_3 = arg0->unk1BC; + temp_v1_3 = player->boundingBoxCorners[1].surfaceType; phi_f0_3 = phi_f0_4; - if (temp_v1_3 < 0xF) { - phi_f0_3 = phi_f0_4 + *(*(&D_800E2AB0 + (arg0->unk254 * 4)) + (temp_v1_3 * 4)); + if ((s32) temp_v1_3 < 0xF) { + phi_f0_3 = phi_f0_4 + D_800E2AB0[player->characterId][temp_v1_3]; } - temp_v1_4 = arg0->unk1A4; + temp_v1_4 = player->boundingBoxCorners[0].surfaceType; phi_f0_2 = phi_f0_3; - if (temp_v1_4 < 0xF) { - phi_f0_2 = phi_f0_3 + *(*(&D_800E2AB0 + (arg0->unk254 * 4)) + (temp_v1_4 * 4)); + if ((s32) temp_v1_4 < 0xF) { + phi_f0_2 = phi_f0_3 + D_800E2AB0[player->characterId][temp_v1_4]; } } phi_v1 = 0; @@ -4165,40 +4158,27 @@ void func_8002FCA8(void *arg0, s8 arg1) { if ((D_801652C0[arg1] & 4) != 0) { phi_v1 = 2; } - if ((arg0->unk9C >= 200.0f) && (phi_v1 == 2) && ((temp_lo = arg0->unkC0 / 0xB6, ((temp_lo < 0x10) == 0)) || (temp_lo < -0xF))) { - phi_f0 = phi_f0_2 + 1.0; + if ((player->unk_09C >= 200.0f) && (phi_v1 == 2) && ((temp_lo = (s32) player->unk_0C0 / 182, ((temp_lo < 0x10) == 0)) || (temp_lo < -0xF))) { + phi_f0 = (f32) ((f64) phi_f0_2 + 1.0); } - if (((temp_v0 & 0x200000) == 0x200000) && ((arg0->unk0 & 0x4000) != 0x4000)) { + if (((temp_v0 & 0x200000) == 0x200000) && ((player->unk_000 & 0x4000) != 0x4000)) { phi_f0 = -3.0f; } - temp_f2 = arg0->unk88; + temp_f2 = player->unk_088; if (temp_f2 >= 0.0f) { phi_f12 = temp_f2 * phi_f0; } else { phi_f12 = -temp_f2 * phi_f0; } - arg0->unk208 = temp_f2 - phi_f12; + player->unk_208 = temp_f2 - phi_f12; } #else GLOBAL_ASM("asm/non_matchings/code_80027D00/func_8002FCA8.s") #endif #ifdef MIPS_TO_C -//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307 -extern ? D_800E2E90; -extern f64 D_800ED8D8; -extern f64 D_800ED8E0; -extern f64 D_800ED8E8; -extern f64 D_800ED8F0; -extern f64 D_800ED8F8; -extern f64 D_800ED900; -extern f64 D_800ED908; -extern f64 D_800ED910; -extern f64 D_800ED918; -extern f64 D_800ED920; -extern f64 D_800ED928; - -void func_8002FE84(void *arg0, f32 arg1) { +//generated by mips_to_c commit 792017ad9d422c2467bd42686f383a5c41f41c75 +void func_8002FE84(Player *player, f32 arg1) { f32 temp_f0; f32 temp_f0_2; f32 temp_f0_3; @@ -4212,45 +4192,45 @@ void func_8002FE84(void *arg0, f32 arg1) { f32 phi_f0_2; f32 phi_f0_3; - temp_v0 = arg0->unkBC; + temp_v0 = player->unk_0BC; if ((temp_v0 & 0x4000) == 0x4000) { - temp_f0 = arg0->unk9C; - arg0->unk98 = ((temp_f0 * temp_f0) / 25.0f) * D_800ED8D8; + temp_f0 = player->unk_09C; + player->unk_098 = (f32) ((f64) ((temp_f0 * temp_f0) / 25.0f) * 1.1); return; } if ((temp_v0 & 8) == 8) { - temp_f0_2 = arg0->unk9C; - arg0->unk98 = ((temp_f0_2 * temp_f0_2) / 25.0f) * D_800ED8E0; + temp_f0_2 = player->unk_09C; + player->unk_098 = (f32) ((f64) ((temp_f0_2 * temp_f0_2) / 25.0f) * 1.1); return; } - arg0->unk98 = arg1; - temp_lo = arg0->unkC4 / 0xB6; - if ((temp_lo >= 0x12) || (temp_lo < -0x11)) { - phi_f0 = 0.0f + ((temp_lo * D_800ED8E8) / D_800ED8F0); + player->unk_098 = arg1; + temp_lo = (s32) player->unk_0C4 / 182; + if (((s32) (s16) temp_lo >= 0x12) || ((s32) (s16) temp_lo < -0x11)) { + phi_f0 = (f32) ((f64) 0.0f + (((f64) (s16) temp_lo * 0.0125) / 1.2)); } else { - phi_f0 = 0.0f + ((temp_lo * D_800ED8F8) / D_800ED900); + phi_f0 = (f32) ((f64) 0.0f + (((f64) (s16) temp_lo * 0.025) / 1.2)); } - temp_v0_2 = arg0->unk1EC; - arg0->unk98 = (1.0f - phi_f0) * arg1; + temp_v0_2 = player->boundingBoxCorners[3].surfaceType; + player->unk_098 = (1.0f - phi_f0) * arg1; phi_f0_3 = phi_f0; if (temp_v0_2 == 8) { - phi_f0_3 = phi_f0 + (*(*(&D_800E2E90 + (arg0->unk254 * 4)) + (temp_v0_2 * 4)) * D_800ED908); + phi_f0_3 = (f32) ((f64) phi_f0 + ((f64) D_800E2E90[player->characterId][temp_v0_2] * 0.7)); } - temp_v0_3 = arg0->unk1D4; + temp_v0_3 = player->boundingBoxCorners[2].surfaceType; phi_f0_2 = phi_f0_3; if (temp_v0_3 == 8) { - phi_f0_2 = phi_f0_3 + (*(*(&D_800E2E90 + (arg0->unk254 * 4)) + (temp_v0_3 * 4)) * D_800ED910); + phi_f0_2 = (f32) ((f64) phi_f0_3 + ((f64) D_800E2E90[player->characterId][temp_v0_3] * 0.7)); } - temp_lo_2 = arg0->unkC0 / 0xB6; + temp_lo_2 = (s32) player->unk_0C0 / 182; if (temp_lo_2 < 0) { - phi_f18 = phi_f0_2 + (-temp_lo_2 * D_800ED918); + phi_f18 = (f64) phi_f0_2 + ((f64) -temp_lo_2 * 0.004); } else { - phi_f18 = phi_f0_2 + (temp_lo_2 * D_800ED920); + phi_f18 = (f64) phi_f0_2 + ((f64) temp_lo_2 * 0.004); } - arg0->unk98 = arg1 * (1.0 + (phi_f18 * D_800ED928)); - if ((arg0->unkBC & 0x20) == 0x20) { - temp_f0_3 = arg0->unk9C + 180.0f; - arg0->unk98 = (temp_f0_3 * temp_f0_3) / 25.0f; + player->unk_098 = (f32) ((f64) arg1 * (1.0 + ((f64) (f32) phi_f18 * 0.7))); + if ((player->unk_0BC & 0x20) == 0x20) { + temp_f0_3 = player->unk_09C + 180.0f; + player->unk_098 = (temp_f0_3 * temp_f0_3) / 25.0f; } } #else @@ -4258,34 +4238,17 @@ GLOBAL_ASM("asm/non_matchings/code_80027D00/func_8002FE84.s") #endif #ifdef MIPS_TO_C -//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307 -? move_f32_towards(void *, f32, void *, f32, ?, void *); // extern -? func_8002FE84(f32, void *, f32); // extern -extern ? D_800E2E90; -extern ? D_800E2EB0; -extern f64 D_800ED930; -extern f64 D_800ED938; -extern f64 D_800ED940; -extern f64 D_800ED948; -extern f64 D_800ED950; -extern f64 D_800ED958; -extern f64 D_800ED960; -extern f64 D_800ED968; -extern f64 D_800ED970; -extern f64 D_800ED978; -extern f64 D_800ED980; -extern f64 D_800ED988; -extern f64 D_800ED990; -extern f64 D_800ED998; -extern f64 D_800ED9A0; -extern f64 D_800ED9A8; -extern f64 D_800ED9B0; -extern ? gKartTurnSpeedReductionTable0; -extern ? gKartTurnSpeedReductionTable1; +//generated by mips_to_c commit 792017ad9d422c2467bd42686f383a5c41f41c75 +? func_8002FE84(f32, Player *, f32); /* extern */ +? move_f32_towards(f32 *, f32, f32, Player *); /* extern */ -f32 func_80030150(void *arg0, s8 arg1) { +f32 func_80030150(Player *player, s8 arg1) { f32 sp24; f32 sp1C; + Player *temp_a0_2; + Player *temp_a0_3; + Player *temp_a3; + f32 *temp_a0; f32 temp_f0; f32 temp_f0_2; f32 temp_f0_3; @@ -4305,25 +4268,20 @@ f32 func_80030150(void *arg0, s8 arg1) { s32 temp_lo_3; s32 temp_t0; s32 temp_t5; - s32 temp_t8; u16 temp_v0_5; + u16 temp_v1; u8 temp_v0; u8 temp_v0_2; u8 temp_v0_3; u8 temp_v0_4; - void *temp_a0; - void *temp_a0_2; - void *temp_a0_3; - void *temp_a3; s32 phi_v0; f32 phi_f0; - void *phi_f12; - void *phi_a3; + Player *phi_a3; f32 phi_f0_2; s32 phi_v0_2; - void *phi_a3_2; + Player *phi_a3_2; f32 phi_f14; - void *phi_a3_3; + Player *phi_a3_3; f32 phi_f0_3; f32 phi_f2; f32 phi_f0_4; @@ -4339,208 +4297,205 @@ f32 func_80030150(void *arg0, s8 arg1) { f32 phi_f0_12; f64 phi_f6; - temp_a3 = arg0; - temp_f2 = (arg0->unk94 / 18.0f) * 216.0f; + temp_a3 = player; + temp_f2 = (player->unk_094 / 18.0f) * 216.0f; phi_a3 = temp_a3; phi_f0_2 = 0.0f; phi_f14 = 0.0f; - phi_f12 = arg0; phi_f0_6 = 0.0f; phi_f0_12 = 0.0f; if (temp_f2 >= 8.0f) { - temp_a1 = arg0->unkBC; + temp_a1 = player->unk_0BC; temp_t0 = temp_a1 & 0x200; temp_a2 = temp_a1 & 8; if (temp_t0 != 0x200) { - temp_v0 = arg0->unk1EC; - if (temp_v0 >= 0xF) { + temp_v0 = player->boundingBoxCorners[3].surfaceType; + if ((s32) temp_v0 >= 0xF) { } else { - phi_f0_12 = 0.0f + *(*(&D_800E2E90 + (temp_a3->unk254 * 4)) + (temp_v0 * 4)); + phi_f0_12 = 0.0f + D_800E2E90[temp_a3->characterId][temp_v0]; } - temp_v0_2 = temp_a3->unk1D4; + temp_v0_2 = temp_a3->boundingBoxCorners[2].surfaceType; phi_f0_10 = phi_f0_12; - if (temp_v0_2 < 0xF) { - phi_f0_10 = phi_f0_12 + *(*(&D_800E2E90 + (temp_a3->unk254 * 4)) + (temp_v0_2 * 4)); + if ((s32) temp_v0_2 < 0xF) { + phi_f0_10 = phi_f0_12 + *(*(D_800E2E90 + (temp_a3->characterId * 4)) + (temp_v0_2 * 4)); } - temp_v0_3 = temp_a3->unk1BC; + temp_v0_3 = temp_a3->boundingBoxCorners[1].surfaceType; phi_f0_8 = phi_f0_10; - if (temp_v0_3 < 0xF) { - phi_f0_8 = phi_f0_10 + *(*(&D_800E2EB0 + (temp_a3->unk254 * 4)) + (temp_v0_3 * 4)); + if ((s32) temp_v0_3 < 0xF) { + phi_f0_8 = phi_f0_10 + D_800E2EB0[temp_a3->characterId][temp_v0_3]; } - temp_v0_4 = temp_a3->unk1A4; + temp_v0_4 = temp_a3->boundingBoxCorners[0].surfaceType; phi_f0_6 = phi_f0_8; - if (temp_v0_4 < 0xF) { - phi_f0_6 = phi_f0_8 + *(*(&D_800E2E90 + (temp_a3->unk254 * 4)) + (temp_v0_4 * 4)); + if ((s32) temp_v0_4 < 0xF) { + phi_f0_6 = phi_f0_8 + *(*(D_800E2E90 + (temp_a3->characterId * 4)) + (temp_v0_4 * 4)); } } phi_f0_5 = phi_f0_6; - if ((temp_a2 != 8) && ((temp_a3->unkCA & 2) != 2)) { - temp_lo = temp_a3->unkC4 / 0xB6; + if ((temp_a2 != 8) && ((temp_a3->unk_0CA & 2) != 2)) { + temp_lo = (s32) temp_a3->unk_0C4 / 182; if (temp_f2 >= 20.0f) { - if ((temp_lo >= 0x12) || (temp_lo < -0x11)) { - phi_f0_11 = phi_f0_6 - ((temp_lo * D_800ED930) / 3.0); + if (((s32) (s16) temp_lo >= 0x12) || ((s32) (s16) temp_lo < -0x11)) { + phi_f0_11 = (f32) ((f64) phi_f0_6 - (((f64) (s16) temp_lo * 0.0126) / 3.0)); } else { - phi_f6 = phi_f0_6 - ((temp_lo * D_800ED938) / 3.0); + phi_f6 = (f64) phi_f0_6 - (((f64) (s16) temp_lo * 0.026) / 3.0); goto block_20; } } else { - temp_f0 = phi_f0_6 + D_800ED940; + temp_f0 = (f32) ((f64) phi_f0_6 + -0.2); phi_f0_11 = temp_f0; if ((temp_a1 & 0x40000000) == 0x40000000) { - phi_f6 = temp_f0 + D_800ED948; + phi_f6 = (f64) temp_f0 + -0.55; block_20: - phi_f0_11 = phi_f6; + phi_f0_11 = (f32) phi_f6; } } - if (((temp_a1 & 0x10) == 0x10) || (temp_a3->unk204 > 0)) { - temp_lo_3 = temp_a3->unkC0 / 0xB6; - phi_v0 = temp_lo_3; - if (temp_lo_3 < 0) { - phi_f0_9 = phi_f0_11 + (-temp_lo_3 * D_800ED950); - } else { - phi_f0_9 = phi_f0_11 + (temp_lo_3 * D_800ED958); - } - } else { - temp_lo_2 = temp_a3->unkC0 / 0xB6; - temp_t8 = temp_a3->unk254 * 4; + if (((temp_a1 & 0x10) == 0x10) || ((s32) temp_a3->unk_204 > 0)) { + temp_lo_2 = (s32) temp_a3->unk_0C0 / 182; phi_v0 = temp_lo_2; if (temp_lo_2 < 0) { - phi_f0_9 = phi_f0_11 + (-temp_lo_2 * (D_800ED960 + *(&gKartTurnSpeedReductionTable0 + temp_t8))); + phi_f0_9 = (f32) ((f64) phi_f0_11 + ((f64) -temp_lo_2 * 0.004)); } else { - phi_f0_9 = phi_f0_11 + (temp_lo_2 * (D_800ED968 + *(&gKartTurnSpeedReductionTable0 + temp_t8))); + phi_f0_9 = (f32) ((f64) phi_f0_11 + ((f64) temp_lo_2 * 0.004)); + } + } else { + temp_v1 = temp_a3->characterId; + temp_lo_3 = (s32) temp_a3->unk_0C0 / 182; + phi_v0 = temp_lo_3; + if (temp_lo_3 < 0) { + phi_f0_9 = (f32) ((f64) phi_f0_11 + ((f64) -temp_lo_3 * (0.01 + (f64) gKartTurnSpeedReductionTable0[temp_v1]))); + } else { + phi_f0_9 = (f32) ((f64) phi_f0_11 + ((f64) temp_lo_3 * (0.01 + (f64) gKartTurnSpeedReductionTable0[temp_v1]))); } } phi_f0_7 = phi_f0_9; - if (((temp_a1 & 0x20000000) == 0x20000000) && (temp_a3->unk228 < 0xA)) { + if (((temp_a1 & 0x20000000) == 0x20000000) && ((s32) temp_a3->unk_228 < 0xA)) { if (phi_v0 < 0) { - phi_f4_2 = phi_f0_9 + (-phi_v0 * D_800ED970); + phi_f4_2 = (f64) phi_f0_9 + ((f64) -phi_v0 * 0.008); } else { - phi_f4_2 = phi_f0_9 + (phi_v0 * D_800ED978); + phi_f4_2 = (f64) phi_f0_9 + ((f64) phi_v0 * 0.008); } - phi_f0_7 = phi_f4_2; + phi_f0_7 = (f32) phi_f4_2; } phi_f0_5 = phi_f0_7; if (temp_t0 == 0x200) { - phi_f0_5 = phi_f0_7 + -0.25; + phi_f0_5 = (f32) ((f64) phi_f0_7 + -0.25); } } - temp_v0_5 = temp_a3->unkDE; + temp_v0_5 = temp_a3->unk_0DE; phi_f0_4 = phi_f0_5; if ((temp_v0_5 & 1) == 1) { - phi_f4 = phi_f0_5 + D_800ED980; + phi_f4 = (f64) phi_f0_5 + 0.3; goto block_44; } if ((temp_v0_5 & 2) == 2) { - phi_f0_4 = phi_f0_5 + D_800ED988; + phi_f0_4 = (f32) ((f64) phi_f0_5 + 0.15); } temp_f2_2 = D_801652A0[arg1]; phi_f0 = phi_f0_4; - phi_f12 = NULL; - phi_f12 = NULL; - if (((temp_f2_2 - temp_a3->unk1D8) >= 3.5) || ((temp_f2_2 - temp_a3->unk1F0) >= 3.5)) { - phi_f4 = phi_f0_4 + D_800ED990; + if (((f64) (temp_f2_2 - temp_a3->boundingBoxCorners[2].cornerGroundY) >= 3.5) || ((f64) (temp_f2_2 - temp_a3->boundingBoxCorners[3].cornerGroundY) >= 3.5)) { + phi_f4 = (f64) phi_f0_4 + 0.05; block_44: - phi_f0 = phi_f4; + phi_f0 = (f32) phi_f4; } if (temp_a2 != 0) { - temp_f18 = temp_a3->unk8C * D_800ED998; + temp_f18 = (f64) temp_a3->unk_08C * 0.04; sp24 = phi_f0; - arg0 = temp_a3; - move_f32_towards(phi_f12, 0.0f, temp_a3 + 0xA0, temp_f18, 0x3E19999A, temp_a3); - phi_a3 = arg0; + player = temp_a3; + move_f32_towards(&temp_a3->unk_0A0, (f32) temp_f18, 0.15f, temp_a3); + phi_a3 = player; phi_f0_2 = phi_f0; } else { - arg0 = temp_a3; + player = temp_a3; sp24 = phi_f0; - move_f32_towards(phi_f12, 0.0f, temp_a3 + 0xA0, 0.0f, 0x3DCCCCCD, temp_a3); - phi_a3 = arg0; + move_f32_towards(&temp_a3->unk_0A0, 0.0f, 0.1f, temp_a3); + phi_a3 = player; phi_f0_2 = phi_f0; } } else { - temp_a3->unkA0 = 0.0f; - temp_a3->unkE8 = 0.0f; - if ((temp_a3->unkC4 / 0xB6) < 0) { - temp_f0_2 = 0.0f + D_800ED9A0; + temp_a3->unk_0A0 = 0.0f; + temp_a3->unk_0E8 = 0.0f; + if (((s32) temp_a3->unk_0C4 / 182) < 0) { + temp_f0_2 = (f32) ((f64) 0.0f + -0.85); phi_f0_2 = temp_f0_2; - if ((temp_a3->unkBC * 2) < 0) { - phi_f0_2 = temp_f0_2 + D_800ED9A8; + if ((temp_a3->unk_0BC * 2) < 0) { + phi_f0_2 = (f32) ((f64) temp_f0_2 + -0.55); } } } - temp_t5 = phi_a3->unk0 & 0x4000; + temp_t5 = phi_a3->unk_000 & 0x4000; phi_v0_2 = temp_t5; phi_a3_2 = phi_a3; phi_f14 = 0.0f; if (temp_t5 != 0x4000) { - if ((phi_a3->unkBC & 0x200000) == 0x200000) { - arg0 = phi_a3; + if ((phi_a3->unk_0BC & 0x200000) == 0x200000) { + player = phi_a3; sp24 = phi_f0_2; - move_f32_towards(phi_a3 + 0xE8, 380.0f, 0x3F000000, (bitwise f32) phi_a3); - phi_v0_2 = arg0->unk0 & 0x4000; - phi_a3_2 = arg0; + move_f32_towards(phi_a3 + 0xE8, 380.0f, 0.5f, phi_a3); + phi_v0_2 = player->unk_000 & 0x4000; + phi_a3_2 = player; } else { - arg0 = phi_a3; + player = phi_a3; sp24 = phi_f0_2; - move_f32_towards(phi_a3 + 0xE8, 0.0f, 0x3DCCCCCD, (bitwise f32) phi_a3); - phi_v0_2 = arg0->unk0 & 0x4000; - phi_a3_2 = arg0; + move_f32_towards(phi_a3 + 0xE8, 0.0f, 0.1f, phi_a3); + phi_v0_2 = player->unk_000 & 0x4000; + phi_a3_2 = player; } } phi_a3_3 = phi_a3_2; phi_f0_3 = phi_f0_2; if (phi_v0_2 == 0x4000) { - temp_a1_2 = phi_a3_2->unkBC; + temp_a1_2 = phi_a3_2->unk_0BC; temp_a0 = phi_a3_2 + 0xE8; if (((temp_a1_2 & 0x100) == 0x100) && ((temp_a1_2 & 0x10) != 0x10)) { - arg0 = phi_a3_2; + player = phi_a3_2; sp24 = phi_f0_2; - move_f32_towards(temp_a0, 580.0f, 0x3E4CCCCD, (bitwise f32) phi_a3_2); + move_f32_towards(temp_a0, 580.0f, 0.2f, phi_a3_2); } else { - arg0 = phi_a3_2; + player = phi_a3_2; sp24 = phi_f0_2; - move_f32_towards(temp_a0, phi_f14, 0x3C23D70A, (bitwise f32) phi_a3_2); + move_f32_towards(temp_a0, phi_f14, 0.01f, phi_a3_2); } - if ((arg0->unkBC & 0x200000) == 0x200000) { - arg0 = arg0; + if ((player->unk_0BC & 0x200000) == 0x200000) { + player = player; sp24 = sp24; - move_f32_towards(arg0 + 0xE4, 580.0f, 0x3C23D70A, (bitwise f32) arg0); + move_f32_towards(player + 0xE4, 580.0f, 0.01f, player); } else { - arg0 = arg0; + player = player; sp24 = sp24; - move_f32_towards(arg0 + 0xE4, 0.0f, 0x3C23D70A, (bitwise f32) arg0); + move_f32_towards(player + 0xE4, 0.0f, 0.01f, player); } - phi_a3_3 = arg0; + phi_a3_3 = player; phi_f0_3 = sp24; } - arg0 = phi_a3_3; - move_f32_towards(phi_a3_3 + 0x104, phi_f0_3, (bitwise void *) (*(&gKartTurnSpeedReductionTable1 + (phi_a3_3->unk254 * 4)) + D_800ED9B0), (bitwise f32) phi_a3_3); - temp_f0_3 = arg0->unk8C; - temp_f12 = arg0->unk80; - temp_f2_3 = (temp_f0_3 + arg0->unkE8 + temp_f12 + arg0->unkE4) - arg0->unkA0; + player = phi_a3_3; + move_f32_towards(&phi_a3_3->unk_104, phi_f0_3, (f32) ((f64) gKartTurnSpeedReductionTable1[phi_a3_3->characterId] + 0.05), phi_a3_3); + temp_f0_3 = player->unk_08C; + temp_f12 = player->boostPower; + temp_f2_3 = (temp_f0_3 + player->unk_0E8 + temp_f12 + player->unk_0E4) - player->unk_0A0; phi_f2 = temp_f2_3; if (temp_f2_3 < 0.0f) { phi_f2 = 0.0f; } - temp_v0_6 = arg0->unkCA; - if (((temp_v0_6 & 2) == 2) || ((temp_v0_6 & 8) == 8) || ((arg0->unk0 & 0x2000) == 0x2000)) { - return (1.0f - arg0->unk104) * phi_f2; + temp_v0_6 = player->unk_0CA; + if (((temp_v0_6 & 2) == 2) || ((temp_v0_6 & 8) == 8) || ((player->unk_000 & 0x2000) == 0x2000)) { + return (1.0f - player->unk_104) * phi_f2; } - temp_a1_3 = arg0->unkBC; - if (((temp_a1_3 & 0x80) == 0x80) || ((temp_a1_3 & 0x40) == 0x40) || ((temp_a1_3 & 0x1000000) == 0x1000000) || ((temp_a1_3 & 0x2000000) == 0x2000000)) { - return (1.0f - arg0->unk104) * phi_f2; + temp_a1_3 = player->unk_0BC; + if (((temp_a1_3 & 0x80) == 0x80) || ((temp_a1_3 & 0x40) == 0x40) || ((temp_a1_3 & 0x01000000) == 0x01000000) || ((temp_a1_3 & 0x02000000) == 0x02000000)) { + return (1.0f - player->unk_104) * phi_f2; } - if (((temp_a1_3 & 0x2000) == 0x2000) || ((temp_a1_3 & 0x100000) == 0x100000) || (temp_a0_2 = arg0, ((temp_a1_3 & 4) == 4))) { + if (((temp_a1_3 & 0x2000) == 0x2000) || ((temp_a1_3 & 0x100000) == 0x100000) || (temp_a0_2 = player, ((temp_a1_3 & 4) == 4))) { temp_f4 = temp_f12 + temp_f0_3; - temp_a0_3 = arg0; - arg0 = arg0; + temp_a0_3 = player; + player = player; func_8002FE84(temp_f12, temp_a0_3, temp_f4); - return arg0->unk80 + arg0->unk8C; + return player->boostPower + player->unk_08C; } - arg0 = arg0; + player = player; sp1C = phi_f2; func_8002FE84(temp_f12, temp_a0_2, phi_f2); - return (1.0f - arg0->unk104) * phi_f2; + return (1.0f - player->unk_104) * phi_f2; } #else GLOBAL_ASM("asm/non_matchings/code_80027D00/func_80030150.s") @@ -5374,13 +5329,10 @@ GLOBAL_ASM("asm/non_matchings/code_80027D00/func_8003221C.s") #endif #ifdef MIPS_TO_C -//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307 -? func_80031F48(f32, f32, f32); // extern -extern ? D_800E3210; -extern f64 D_800EDB00; -extern f64 D_800EDB08; +//generated by mips_to_c commit 792017ad9d422c2467bd42686f383a5c41f41c75 +? func_80031F48(f32, f32, f32); /* extern */ -void func_800323E4(void *arg0) { +void func_800323E4(Player *player) { s32 sp24; f32 sp1C; f32 temp_f0; @@ -5393,75 +5345,75 @@ void func_800323E4(void *arg0) { f32 phi_f2_2; phi_f2_2 = 0.0f; - if (arg0 == gPlayerOne) { + if (player == gPlayerOne) { sp24 = 0; } phi_v1 = sp24; - if (arg0 == gPlayerTwo) { + if (player == gPlayerTwo) { phi_v1 = 1; } - if (arg0 == gPlayerThree) { + if (player == gPlayerThree) { phi_v1 = 2; } - if (arg0 == gPlayerFour) { + if (player == gPlayerFour) { phi_v1 = 3; } - if (arg0 == gPlayerFive) { + if (player == gPlayerFive) { phi_v1 = 4; } - if (arg0 == gPlayerSix) { + if (player == gPlayerSix) { phi_v1 = 5; } - if (arg0 == gPlayerSeven) { + if (player == gPlayerSeven) { phi_v1 = 6; } - if (arg0 == gPlayerEight) { + if (player == gPlayerEight) { phi_v1 = 7; } - temp_t5 = arg0->unkBC | 1; - arg0->unkBC = temp_t5; + temp_t5 = player->unk_0BC | 1; + player->unk_0BC = temp_t5; if ((temp_t5 & 0x20) == 0x20) { func_80031F48(0.0f, 1.0f); - arg0->unk20C = 0.0f; + player->unk_20C = 0.0f; return; } - temp_v0 = arg0->unk1EC; - if (temp_v0 < 0xF) { - phi_f2_2 = 0.0f + *(*(&D_800E3210 + (arg0->unk254 * 4)) + (temp_v0 * 4)); + temp_v0 = player->boundingBoxCorners[3].surfaceType; + if ((s32) temp_v0 < 0xF) { + phi_f2_2 = 0.0f + D_800E3210[player->characterId][temp_v0]; } - temp_v0_2 = arg0->unk1D4; + temp_v0_2 = player->boundingBoxCorners[2].surfaceType; phi_f2 = phi_f2_2; - if (temp_v0_2 < 0xF) { - phi_f2 = phi_f2_2 + *(*(&D_800E3210 + (arg0->unk254 * 4)) + (temp_v0_2 * 4)); + if ((s32) temp_v0_2 < 0xF) { + phi_f2 = phi_f2_2 + D_800E3210[player->characterId][temp_v0_2]; } - if ((arg0->unk22C - arg0->unk94) <= 0.0f) { - arg0->unk20C = 0.0f; + if ((player->unk_22C - player->unk_094) <= 0.0f) { + player->unk_20C = 0.0f; } else { - arg0->unk20C = arg0->unk20C + D_800EDB00; - if (arg0->unk20C >= 2.0f) { - arg0->unk20C = 2.0f; + player->unk_20C = (f32) ((f64) player->unk_20C + 0.02); + if (player->unk_20C >= 2.0f) { + player->unk_20C = 2.0f; } } phi_f12 = 2.0f; if (D_80165520[phi_v1] == 1) { - if (arg0->unk20C >= 2.0f) { + if (player->unk_20C >= 2.0f) { func_80031F48(2.0f, (1.0f - phi_f2) * 5.0f); return; } func_80031F48(2.0f, (1.0f - phi_f2) * 3.0f); return; } - if (((arg0->unk94 / 18.0f) * 216.0f) <= 20.0f) { + if (((player->unk_094 / 18.0f) * 216.0f) <= 20.0f) { sp1C = phi_f2; func_80031F48(2.0f, (1.0f - phi_f2) * 4.0f); phi_f12 = 2.0f; } temp_f0 = 1.0f - phi_f2; - if (phi_f12 <= arg0->unk20C) { - func_80031F48(phi_f12, (bitwise f32) arg0, temp_f0 * 2.5); + if (phi_f12 <= player->unk_20C) { + func_80031F48(phi_f12, (bitwise f32) player, (f32) ((f64) temp_f0 * 2.5)); return; } - func_80031F48(phi_f12, (bitwise f32) arg0, temp_f0 * D_800EDB08); + func_80031F48(phi_f12, (bitwise f32) player, (f32) ((f64) temp_f0 * 1.2)); } #else GLOBAL_ASM("asm/non_matchings/code_80027D00/func_800323E4.s") @@ -6070,53 +6022,173 @@ GLOBAL_ASM("asm/non_matchings/code_80027D00/func_80033A40.s") #endif #ifdef MIPS_TO_C -//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307 -? func_8002A8A4(f32, f32, void *, s8); // extern -? func_8002BD58(void *, s32); // extern -? func_80033884(void *, s32 *, s32 *, s32, s32, s32, s32); // extern -? func_80033A40(void *, s32 *, s32 *, s32, s32, s32, f32); // extern -? func_80036CB4(void *); // extern -s32 func_80038534(void *); // extern -extern ? D_800E3410; -extern ? D_800E3610; -extern s32 D_800E3DF8; -extern f64 D_800EDCE8; -extern f64 D_800EDCF0; -extern f32 D_800EDCF8; -extern f32 D_800EDCFC; -extern f32 D_800EDD00; -extern f32 D_800EDD04; -extern f32 D_800EDD08; -extern f32 D_800EDD0C; -extern f32 D_800EDD10; -extern f32 D_800EDD14; -extern f32 D_800EDD18; -extern f32 D_800EDD1C; -extern f32 D_800EDD20; -extern f32 D_800EDD24; -extern f32 D_800EDD28; -extern f32 D_800EDD2C; -extern f32 D_800EDD30; -extern f32 D_800EDD34; -extern f32 D_800EDD38; -extern f32 D_800EDD3C; -extern f32 D_800EDD40; -extern f32 D_800EDD44; -extern f32 D_800EDD48; -extern f32 D_800EDD4C; -extern f32 D_800EDD50; -extern f32 D_800EDD54; -extern f32 D_800EDD58; -extern f32 D_800EDD5C; -extern f64 D_800EDD60; -extern f64 D_800EDD68; -extern f64 D_800EDD70; -extern f64 D_800EDD78; -extern f64 D_800EDD80; -extern ? gKartHandlingTable; -extern ? gKartTable800E3650; +//generated by mips_to_c commit 792017ad9d422c2467bd42686f383a5c41f41c75 +? func_8002A8A4(f32, f32, Player *, s8); /* extern */ +? func_8002BD58(Player *, s32); /* extern */ +? func_80033884(Player *, s32 *, s32 *, s32, s32, s32, s32); /* extern */ +? func_80033A40(Player *, s32 *, s32 *, s32, s32, s32, f32); /* extern */ +? func_80036CB4(Player *); /* extern */ +s32 func_80038534(struct Controller *); /* extern */ +static s32 D_800E3DF8[0x9C] = { + 0, + 0x3F000000, + 0x3F000000, + 0x3F000000, + 0x3F000000, + 0x3F000000, + 0x3F000000, + 0x3F19999A, + 0x3F19999A, + 0x3F19999A, + 0x3F19999A, + 0x3F19999A, + 0x3F333333, + 0x3F333333, + 0x3F333333, + 0x3F333333, + 0x3F333333, + 0x3F333333, + 0x3F333333, + 0x3F333333, + 0x3F333333, + 0x3F333333, + 0x3F333333, + 0x3F333333, + 0x3F19999A, + 0x3F19999A, + 0x3F19999A, + 0x3F19999A, + 0x3F19999A, + 0x3F19999A, + 0x3F19999A, + 0x3F19999A, + 0x3F19999A, + 0x3F19999A, + 0x3F19999A, + 0x3F19999A, + 0x3F000000, + 0x3F000000, + 0x3F000000, + 0x3F000000, + 0x3F19999A, + 0x3F19999A, + 0x3F19999A, + 0x3F19999A, + 0x3F19999A, + 0x3F19999A, + 0x3F19999A, + 0x3F19999A, + 0x3F19999A, + 0x3F19999A, + 0x3F333333, + 0x3F333333, + 0x3F333333, + 0x3F333333, + 0x3F333333, + 0x3F333333, + 0x3F19999A, + 0x3F19999A, + 0x3F19999A, + 0x3F19999A, + 0x3F333333, + 0x3F333333, + 0x3F333333, + 0x3F333333, + 0x3F333333, + 0x3F333333, + 0x3F333333, + 0x3F333333, + 0x3F333333, + 0x3F333333, + 0x3F333333, + 0x3F333333, + 0x3F333333, + 0x3F333333, + 0x3F333333, + 0x3F333333, + 0x3F333333, + 0x3F333333, + 0x3F333333, + 0x3F333333, + 0x3F333333, + 0x3F333333, + 0x3F333333, + 0x3F333333, + 0x3F333333, + 0x3F333333, + 0x3F333333, + 0x3F333333, + 0x3F333333, + 0x3F333333, + 0x3F333333, + 0x3F333333, + 0x3F333333, + 0x3F333333, + 0x3F333333, + 0x3F333333, + 0x3F333333, + 0x3F333333, + 0x3F333333, + 0x3F333333, + 0x3F333333, + 0x3F333333, + 0x3F333333, + 0x3F333333, + 0x3F333333, + 0x3F333333, + 0x3F333333, + 0x3F333333, + 0x3F4CCCCD, + 0x3F4CCCCD, + 0x3F4CCCCD, + 0x3F4CCCCD, + 0x3F4CCCCD, + 0x3F4CCCCD, + 0x3F4CCCCD, + 0x3F4CCCCD, + 0x3F4CCCCD, + 0x3F4CCCCD, + 0x3F4CCCCD, + 0x3F4CCCCD, + 0x3F4CCCCD, + 0x3F4CCCCD, + 0x3F4CCCCD, + 0x3F4CCCCD, + 0x3F4CCCCD, + 0x3F4CCCCD, + 0x3F4CCCCD, + 0x3F4CCCCD, + 0x3F4CCCCD, + 0x3F4CCCCD, + 0x3F4CCCCD, + 0x3F4CCCCD, + 0x3F4CCCCD, + 0x3F4CCCCD, + 0x3F4CCCCD, + 0x3F4CCCCD, + 0x3F4CCCCD, + 0x3F4CCCCD, + 0x3F4CCCCD, + 0x3F4CCCCD, + 0x3F4CCCCD, + 0x3F4CCCCD, + 0x3F4CCCCD, + 0x3F4CCCCD, + 0x3F4CCCCD, + 0x3F4CCCCD, + 0x3F4CCCCD, + 0x3F4CCCCD, + 0x3F4CCCCD, + 0x3F4CCCCD, + 0x3F4CCCCD, + 0x3F4CCCCD, + 0x3F4CCCCD, + 0x3F4CCCCD, + 0x3F4CCCCD, + 0x3F4CCCCD, +}; /* const */ -void func_80033AE0(void *arg0, void *arg1, s8 arg2) { +void func_80033AE0(Player *player, struct Controller *arg1, s8 arg2) { s32 sp2E4; s32 sp2E0; s32 sp2D0; @@ -6133,12 +6205,10 @@ void func_80033AE0(void *arg0, void *arg1, s8 arg2) { f32 temp_f0; f32 temp_f0_2; f32 temp_f0_3; + f32 temp_f0_4; f32 temp_f0_5; + f32 temp_f0_6; f32 temp_f0_7; - f32 temp_f0_8; - f32 temp_f0_9; - f64 temp_f0_4; - f64 temp_f0_6; s16 temp_v1_3; s16 temp_v1_6; s32 *temp_t7; @@ -6167,7 +6237,6 @@ void func_80033AE0(void *arg0, void *arg1, s8 arg2) { s32 temp_t3; s32 temp_t3_2; s32 temp_t4; - s32 temp_t4_2; s32 temp_t5; s32 temp_t5_2; s32 temp_t7_2; @@ -6182,6 +6251,7 @@ void func_80033AE0(void *arg0, void *arg1, s8 arg2) { s32 temp_v1_7; s32 temp_v1_8; u16 temp_v0_6; + u16 temp_v1_9; u8 temp_v0_4; u8 temp_v0_5; u8 temp_v0_8; @@ -6214,75 +6284,75 @@ void func_80033AE0(void *arg0, void *arg1, s8 arg2) { f32 phi_f12_2; sp2C0 = 0.0f; - phi_t7 = &D_800E3DF8; + phi_t7 = D_800E3DF8; phi_t6 = &sp44; do { temp_t7 = phi_t7 + 0xC; temp_t6 = phi_t6 + 0xC; - temp_t6->unk-C = *phi_t7; - temp_t6->unk-8 = temp_t7->unk-8; - temp_t6->unk-4 = temp_t7->unk-4; + temp_t6->unk-C = (s32) *phi_t7; + temp_t6->unk-8 = (s32) temp_t7->unk-8; + temp_t6->unk-4 = (s32) temp_t7->unk-4; phi_t7 = temp_t7; phi_t6 = temp_t6; - } while (temp_t7 != (&D_800E3DF8 + 0x270)); - temp_v1 = arg0->unkBC; - if ((((temp_v1 & 2) != 2) && (((temp_lo = arg0->unkC0 / 0xB6, ((temp_lo < 7) != 0)) && (temp_lo >= -6)) || ((arg1->unk4 & 0x10) != 0x10))) || (((arg0->unk94 / 18.0f) * 216.0f) <= 20.0f) || ((temp_v1 & 0x8000) == 0x8000)) { + } while (temp_t7 != (D_800E3DF8 + 0x270)); + temp_v1 = player->unk_0BC; + if ((((temp_v1 & 2) != 2) && (((temp_lo = (s32) player->unk_0C0 / 182, ((temp_lo < 7) != 0)) && (temp_lo >= -6)) || ((arg1->button & 0x10) != 0x10))) || (((player->unk_094 / 18.0f) * 216.0f) <= 20.0f) || ((temp_v1 & 0x8000) == 0x8000)) { sp2BC = 0.0f; - func_80036CB4(arg0); + func_80036CB4(player); } - temp_lo_2 = arg0->unkC0 / 0xB6; + temp_lo_2 = (s32) player->unk_0C0 / 182; if (temp_lo_2 < -5) { - arg0->unk44 = arg0->unk44 | 4; - arg0->unk44 = arg0->unk44 & 0xFFFD; + player->unk_044 |= 4; + player->unk_044 &= 0xFFFD; temp_v0 = &D_801652C0[arg2]; - *temp_v0 = *temp_v0 + 1; + *temp_v0 += 1; phi_s1 = arg2 * 4; } else if (temp_lo_2 >= 6) { - arg0->unk44 = arg0->unk44 | 2; - arg0->unk44 = arg0->unk44 & 0xFFFB; + player->unk_044 |= 2; + player->unk_044 &= 0xFFFB; temp_v0_2 = &D_801652C0[arg2]; - *temp_v0_2 = *temp_v0_2 + 1; + *temp_v0_2 += 1; phi_s1 = arg2 * 4; } else { - arg0->unk44 = arg0->unk44 & 0xFFF9; + player->unk_044 &= 0xFFF9; D_801652C0[arg2] = 0; phi_s1 = arg2 * 4; } - temp_v1_2 = arg0->unkBC; + temp_v1_2 = player->unk_0BC; if (((temp_v1_2 & 2) == 2) || ((temp_v1_2 & 0x10) == 0x10)) { - arg0->unk44 = arg0->unk44 & 0xFFF9; + player->unk_044 &= 0xFFF9; } sp2BC = 0.0f; - sp2E4 = arg0->unk7C; + sp2E4 = player->unk_07C; temp_v0_3 = func_80038534(arg1); - temp_v1_3 = arg0->unk44; + temp_v1_3 = player->unk_044; phi_t1 = temp_v0_3; phi_f2_4 = 0.0f; if (((temp_v1_3 & 1) == 1) || ((temp_v1_3 & 8) == 8)) { phi_t1 = -temp_v0_3; } temp_t3 = (phi_t1 << 0x10) & 0xFFFF0000; - arg0->unk7C = temp_t3; + player->unk_07C = temp_t3; temp_t5 = sp2E4 - temp_t3; sp2D0 = temp_t5; temp_t9 = temp_t5 >> 0x10; sp2D0 = temp_t9; - arg0->unkFA = temp_t9; - if (((sp2D0 >= 0x5A) || (sp2D0 < -0x59)) && ((arg0->unk44 & 0x4000) == 0)) { - temp_v1_4 = arg0->unkBC; - if (((temp_v1_4 & 0x10) == 0) && (gCCSelection == CC_150) && (gModeSelection != BATTLE) && ((temp_v1_4 & 8) == 0) && (((arg0->unk94 / 18.0f) * 216.0f) >= 40.0f) && (arg0->unk204 == 0)) { - arg0->unkC = arg0->unkC | 0x80; + player->unk_0FA = (s16) temp_t9; + if (((sp2D0 >= 0x5A) || (sp2D0 < -0x59)) && ((player->unk_044 & 0x4000) == 0)) { + temp_v1_4 = player->unk_0BC; + if (((temp_v1_4 & 0x10) == 0) && (gCCSelection == 2) && (gModeSelection != 3) && ((temp_v1_4 & 8) == 0) && (((player->unk_094 / 18.0f) * 216.0f) >= 40.0f) && (player->unk_204 == 0)) { + player->unk_00C |= 0x80; } } - temp_v0_4 = arg0->unk1EC; - temp_v1_5 = arg0->unkBC; - if (temp_v0_4 < 0xF) { - phi_f2_4 = 0.0f + *(*(&D_800E3610 + (arg0->unk254 * 4)) + (temp_v0_4 * 4)); + temp_v0_4 = player->boundingBoxCorners[3].surfaceType; + temp_v1_5 = player->unk_0BC; + if ((s32) temp_v0_4 < 0xF) { + phi_f2_4 = 0.0f + D_800E3610[player->characterId][temp_v0_4]; } - temp_v0_5 = arg0->unk1D4; + temp_v0_5 = player->boundingBoxCorners[2].surfaceType; phi_f2 = phi_f2_4; - if (temp_v0_5 < 0xF) { - phi_f2 = phi_f2_4 + *(*(&D_800E3610 + (arg0->unk254 * 4)) + (temp_v0_5 * 4)); + if ((s32) temp_v0_5 < 0xF) { + phi_f2 = phi_f2_4 + D_800E3610[player->characterId][temp_v0_5]; } if ((temp_v1_5 & 0x20) == 0x20) { phi_t0_2 = 0xA; @@ -6294,32 +6364,32 @@ void func_80033AE0(void *arg0, void *arg1, s8 arg2) { phi_a0 = 3; } phi_v1_2 = 8; - if (((arg0->unk94 / 18.0f) * 216.0f) >= 15.0f) { - temp_v1_6 = arg0->unk44; + if (((player->unk_094 / 18.0f) * 216.0f) >= 15.0f) { + temp_v1_6 = player->unk_044; if ((temp_v1_6 & 2) == 2) { if ((sp2D0 < 0x24) && (sp2D0 >= 0)) { - temp_f8 = (*(&gKartTable800E3650 + (arg0->unk254 * 4)) + 1.0f) * ((phi_a0 + 0xF) * (1.0f + phi_f2)); + temp_f8 = (s32) ((gKartTable800E3650[player->characterId] + 1.0f) * ((f32) (phi_a0 + 0xF) * (1.0f + phi_f2))); sp2C8 = temp_f8; sp2CC = temp_f8; } else { temp_f0 = 1.0f + phi_f2; - sp2C8 = (phi_a0 + 5) * temp_f0; - sp2CC = (phi_a0 + 9) * temp_f0; + sp2C8 = (s32) ((f32) (phi_a0 + 5) * temp_f0); + sp2CC = (s32) ((f32) (phi_a0 + 9) * temp_f0); } } else if ((temp_v1_6 & 4) == 4) { if ((sp2D0 >= -0x23) && (sp2D0 <= 0)) { - temp_f6 = (*(&gKartTable800E3650 + (arg0->unk254 * 4)) + 1.0f) * ((phi_a0 + 0xF) * (1.0f + phi_f2)); + temp_f6 = (s32) ((gKartTable800E3650[player->characterId] + 1.0f) * ((f32) (phi_a0 + 0xF) * (1.0f + phi_f2))); sp2C8 = temp_f6; sp2CC = temp_f6; } else { temp_f0_2 = 1.0f + phi_f2; - sp2C8 = (phi_a0 + 5) * temp_f0_2; - sp2CC = (phi_a0 + 9) * temp_f0_2; + sp2C8 = (s32) ((f32) (phi_a0 + 5) * temp_f0_2); + sp2CC = (s32) ((f32) (phi_a0 + 9) * temp_f0_2); } } else { temp_f0_3 = 1.0f + phi_f2; - sp2C8 = (phi_a0 + 3) * temp_f0_3; - sp2CC = (phi_a0 + 6) * temp_f0_3; + sp2C8 = (s32) ((f32) (phi_a0 + 3) * temp_f0_3); + sp2CC = (s32) ((f32) (phi_a0 + 6) * temp_f0_3); } phi_t0_2 = sp2CC; phi_v1_2 = sp2C8; @@ -6328,162 +6398,160 @@ void func_80033AE0(void *arg0, void *arg1, s8 arg2) { sp2CC = 8; } } - temp_v0_6 = arg0->unkDE; + temp_v0_6 = player->unk_0DE; phi_t0_3 = phi_t0_2; phi_v1_3 = phi_v1_2; if ((temp_v0_6 & 1) == 1) { - phi_t0 = phi_t0_2 * 1.5; - phi_v1 = phi_v1_2 * 1.5; + phi_t0 = (s32) ((f64) phi_t0_2 * 1.5); + phi_v1 = (s32) ((f64) phi_v1_2 * 1.5); } else { if ((temp_v0_6 & 2) == 2) { - temp_f0_4 = D_800EDCE8; - phi_t0_3 = phi_t0_2 * temp_f0_4; - phi_v1_3 = phi_v1_2 * temp_f0_4; + phi_t0_3 = (s32) ((f64) phi_t0_2 * 1.2); + phi_v1_3 = (s32) ((f64) phi_v1_2 * 1.2); } - temp_f0_5 = *(D_801652A0 + phi_s1); + temp_f0_4 = *(D_801652A0 + phi_s1); phi_t0 = phi_t0_3; phi_v1 = phi_v1_3; - if (((temp_f0_5 - arg0->unk1D8) >= 3.5) || ((temp_f0_5 - arg0->unk1F0) >= 3.5)) { - temp_f0_6 = D_800EDCF0; - phi_t0 = phi_t0_3 * temp_f0_6; - phi_v1 = phi_v1_3 * temp_f0_6; + if (((f64) (temp_f0_4 - player->boundingBoxCorners[2].cornerGroundY) >= 3.5) || ((f64) (temp_f0_4 - player->boundingBoxCorners[3].cornerGroundY) >= 3.5)) { + phi_t0 = (s32) ((f64) phi_t0_3 * 1.05); + phi_v1 = (s32) ((f64) phi_v1_3 * 1.05); } } sp2E0 = phi_t1; sp2CC = phi_t0; sp2C8 = phi_v1; - func_80033884(arg0, &sp2D0, &sp2E4, arg0->unk7C, 0x5A, 0x78000 / phi_v1, 0x1C2); - func_80033884(arg0, &sp2D0, &sp2E4, arg0->unk7C, 0x59, 0x76000 / sp2C8, 0x1B8); - func_80033884(arg0, &sp2D0, &sp2E4, arg0->unk7C, 0x58, 0x74000 / sp2C8, 0x1AE); - func_80033884(arg0, &sp2D0, &sp2E4, arg0->unk7C, 0x57, 0x72000 / sp2C8, 0x1A4); - func_80033884(arg0, &sp2D0, &sp2E4, arg0->unk7C, 0x56, 0x70000 / sp2C8, 0x19A); - func_80033884(arg0, &sp2D0, &sp2E4, arg0->unk7C, 0x55, 0x58000 / sp2C8, 0x190); - func_80033884(arg0, &sp2D0, &sp2E4, arg0->unk7C, 0x54, 0x56000 / sp2C8, 0x18B); - func_80033884(arg0, &sp2D0, &sp2E4, arg0->unk7C, 0x53, 0x50000 / sp2C8, 0x186); - func_80033884(arg0, &sp2D0, &sp2E4, arg0->unk7C, 0x52, 0x4F000 / sp2C8, 0x186); - func_80033884(arg0, &sp2D0, &sp2E4, arg0->unk7C, 0x51, 0x4E000 / sp2C8, 0x17C); - func_80033884(arg0, &sp2D0, &sp2E4, arg0->unk7C, 0x50, 0x4D000 / sp2C8, 0x172); + func_80033884(player, &sp2D0, &sp2E4, player->unk_07C, 0x5A, 0x78000 / phi_v1, 0x1C2); + func_80033884(player, &sp2D0, &sp2E4, player->unk_07C, 0x59, 0x76000 / sp2C8, 0x1B8); + func_80033884(player, &sp2D0, &sp2E4, player->unk_07C, 0x58, 0x74000 / sp2C8, 0x1AE); + func_80033884(player, &sp2D0, &sp2E4, player->unk_07C, 0x57, 0x72000 / sp2C8, 0x1A4); + func_80033884(player, &sp2D0, &sp2E4, player->unk_07C, 0x56, 0x70000 / sp2C8, 0x19A); + func_80033884(player, &sp2D0, &sp2E4, player->unk_07C, 0x55, 0x58000 / sp2C8, 0x190); + func_80033884(player, &sp2D0, &sp2E4, player->unk_07C, 0x54, 0x56000 / sp2C8, 0x18B); + func_80033884(player, &sp2D0, &sp2E4, player->unk_07C, 0x53, 0x50000 / sp2C8, 0x186); + func_80033884(player, &sp2D0, &sp2E4, player->unk_07C, 0x52, 0x4F000 / sp2C8, 0x186); + func_80033884(player, &sp2D0, &sp2E4, player->unk_07C, 0x51, 0x4E000 / sp2C8, 0x17C); + func_80033884(player, &sp2D0, &sp2E4, player->unk_07C, 0x50, 0x4D000 / sp2C8, 0x172); temp_lo_3 = 0x4C000 / sp2C8; sp40 = temp_lo_3; - func_80033884(arg0, &sp2D0, &sp2E4, arg0->unk7C, 0x4F, temp_lo_3, 0x168); - func_80033884(arg0, &sp2D0, &sp2E4, arg0->unk7C, 0x4E, temp_lo_3, 0x168); - func_80033884(arg0, &sp2D0, &sp2E4, arg0->unk7C, 0x4D, 0x4B000 / sp2C8, 0x15E); - func_80033884(arg0, &sp2D0, &sp2E4, arg0->unk7C, 0x4C, 0x4A000 / sp2C8, 0x154); + func_80033884(player, &sp2D0, &sp2E4, player->unk_07C, 0x4F, temp_lo_3, 0x168); + func_80033884(player, &sp2D0, &sp2E4, player->unk_07C, 0x4E, sp40, 0x168); + func_80033884(player, &sp2D0, &sp2E4, player->unk_07C, 0x4D, 0x4B000 / sp2C8, 0x15E); + func_80033884(player, &sp2D0, &sp2E4, player->unk_07C, 0x4C, 0x4A000 / sp2C8, 0x154); temp_lo_4 = 0x49000 / sp2C8; sp40 = temp_lo_4; - func_80033884(arg0, &sp2D0, &sp2E4, arg0->unk7C, 0x4B, temp_lo_4, 0x14A); - func_80033884(arg0, &sp2D0, &sp2E4, arg0->unk7C, 0x4A, sp40, 0x14A); - func_80033884(arg0, &sp2D0, &sp2E4, arg0->unk7C, 0x49, sp40, 0x14A); - func_80033884(arg0, &sp2D0, &sp2E4, arg0->unk7C, 0x48, 0x48000 / sp2C8, 0x140); + func_80033884(player, &sp2D0, &sp2E4, player->unk_07C, 0x4B, temp_lo_4, 0x14A); + func_80033884(player, &sp2D0, &sp2E4, player->unk_07C, 0x4A, sp40, 0x14A); + func_80033884(player, &sp2D0, &sp2E4, player->unk_07C, 0x49, sp40, 0x14A); + func_80033884(player, &sp2D0, &sp2E4, player->unk_07C, 0x48, 0x48000 / sp2C8, 0x140); temp_lo_5 = 0x47000 / sp2C8; sp40 = temp_lo_5; - func_80033884(arg0, &sp2D0, &sp2E4, arg0->unk7C, 0x47, temp_lo_5, 0x13B); - func_80033884(arg0, &sp2D0, &sp2E4, arg0->unk7C, 0x46, temp_lo_5, 0x13B); + func_80033884(player, &sp2D0, &sp2E4, player->unk_07C, 0x47, temp_lo_5, 0x13B); + func_80033884(player, &sp2D0, &sp2E4, player->unk_07C, 0x46, sp40, 0x13B); temp_lo_6 = 0x46000 / sp2C8; sp40 = temp_lo_6; - func_80033884(arg0, &sp2D0, &sp2E4, arg0->unk7C, 0x45, temp_lo_6, 0x131); - func_80033884(arg0, &sp2D0, &sp2E4, arg0->unk7C, 0x44, sp40, 0x131); + func_80033884(player, &sp2D0, &sp2E4, player->unk_07C, 0x45, temp_lo_6, 0x131); + func_80033884(player, &sp2D0, &sp2E4, player->unk_07C, 0x44, sp40, 0x131); temp_lo_7 = 0x45000 / sp2C8; sp3C = temp_lo_7; - func_80033884(arg0, &sp2D0, &sp2E4, arg0->unk7C, 0x43, temp_lo_7, 0x118); - func_80033884(arg0, &sp2D0, &sp2E4, arg0->unk7C, 0x42, sp40, 0x10E); - func_80033884(arg0, &sp2D0, &sp2E4, arg0->unk7C, 0x41, sp3C, 0x10E); - func_80033884(arg0, &sp2D0, &sp2E4, arg0->unk7C, 0x40, 0x44000 / sp2C8, 0x104); + func_80033884(player, &sp2D0, &sp2E4, player->unk_07C, 0x43, temp_lo_7, 0x118); + func_80033884(player, &sp2D0, &sp2E4, player->unk_07C, 0x42, sp40, 0x10E); + func_80033884(player, &sp2D0, &sp2E4, player->unk_07C, 0x41, sp3C, 0x10E); + func_80033884(player, &sp2D0, &sp2E4, player->unk_07C, 0x40, 0x44000 / sp2C8, 0x104); temp_lo_8 = 0x43000 / sp2C8; sp40 = temp_lo_8; - func_80033884(arg0, &sp2D0, &sp2E4, arg0->unk7C, 0x3F, temp_lo_8, 0xFA); - func_80033884(arg0, &sp2D0, &sp2E4, arg0->unk7C, 0x3E, sp40, 0xFA); - func_80033884(arg0, &sp2D0, &sp2E4, arg0->unk7C, 0x3D, sp40, 0xFA); - func_80033884(arg0, &sp2D0, &sp2E4, arg0->unk7C, 0x3C, 0x3D000 / sp2C8, 0xF5); - func_80033884(arg0, &sp2D0, &sp2E4, arg0->unk7C, 0x3B, 0x3C000 / sp2C8, 0xF5); - func_80033884(arg0, &sp2D0, &sp2E4, arg0->unk7C, 0x3A, 0x3B000 / sp2C8, 0xF5); - func_80033884(arg0, &sp2D0, &sp2E4, arg0->unk7C, 0x39, 0x3A000 / sp2C8, 0xF5); + func_80033884(player, &sp2D0, &sp2E4, player->unk_07C, 0x3F, temp_lo_8, 0xFA); + func_80033884(player, &sp2D0, &sp2E4, player->unk_07C, 0x3E, sp40, 0xFA); + func_80033884(player, &sp2D0, &sp2E4, player->unk_07C, 0x3D, sp40, 0xFA); + func_80033884(player, &sp2D0, &sp2E4, player->unk_07C, 0x3C, 0x3D000 / sp2C8, 0xF5); + func_80033884(player, &sp2D0, &sp2E4, player->unk_07C, 0x3B, 0x3C000 / sp2C8, 0xF5); + func_80033884(player, &sp2D0, &sp2E4, player->unk_07C, 0x3A, 0x3B000 / sp2C8, 0xF5); + func_80033884(player, &sp2D0, &sp2E4, player->unk_07C, 0x39, 0x3A000 / sp2C8, 0xF5); temp_lo_9 = 0x38000 / sp2C8; sp40 = temp_lo_9; - func_80033884(arg0, &sp2D0, &sp2E4, arg0->unk7C, 0x38, temp_lo_9, 0xF5); - func_80033884(arg0, &sp2D0, &sp2E4, arg0->unk7C, 0x37, sp40, 0xE6); - func_80033884(arg0, &sp2D0, &sp2E4, arg0->unk7C, 0x36, sp40, 0xE6); - func_80033884(arg0, &sp2D0, &sp2E4, arg0->unk7C, 0x35, sp40, 0xE6); - func_80033884(arg0, &sp2D0, &sp2E4, arg0->unk7C, 0x34, sp40, 0xE6); - func_80033884(arg0, &sp2D0, &sp2E4, arg0->unk7C, 0x33, sp40, 0xE6); + func_80033884(player, &sp2D0, &sp2E4, player->unk_07C, 0x38, temp_lo_9, 0xF5); + func_80033884(player, &sp2D0, &sp2E4, player->unk_07C, 0x37, sp40, 0xE6); + func_80033884(player, &sp2D0, &sp2E4, player->unk_07C, 0x36, sp40, 0xE6); + func_80033884(player, &sp2D0, &sp2E4, player->unk_07C, 0x35, sp40, 0xE6); + func_80033884(player, &sp2D0, &sp2E4, player->unk_07C, 0x34, sp40, 0xE6); + func_80033884(player, &sp2D0, &sp2E4, player->unk_07C, 0x33, sp40, 0xE6); temp_lo_10 = 0x32000 / sp2C8; sp40 = temp_lo_10; - func_80033884(arg0, &sp2D0, &sp2E4, arg0->unk7C, 0x32, temp_lo_10, 0xDC); - func_80033884(arg0, &sp2D0, &sp2E4, arg0->unk7C, 0x31, sp40, 0xDC); - func_80033884(arg0, &sp2D0, &sp2E4, arg0->unk7C, 0x30, sp40, 0xDC); - func_80033884(arg0, &sp2D0, &sp2E4, arg0->unk7C, 0x2F, sp40, 0xDC); - func_80033884(arg0, &sp2D0, &sp2E4, arg0->unk7C, 0x2E, sp40, 0xDC); - func_80033884(arg0, &sp2D0, &sp2E4, arg0->unk7C, 0x2D, 0x30000 / sp2C8, 0x6E); + func_80033884(player, &sp2D0, &sp2E4, player->unk_07C, 0x32, temp_lo_10, 0xDC); + func_80033884(player, &sp2D0, &sp2E4, player->unk_07C, 0x31, sp40, 0xDC); + func_80033884(player, &sp2D0, &sp2E4, player->unk_07C, 0x30, sp40, 0xDC); + func_80033884(player, &sp2D0, &sp2E4, player->unk_07C, 0x2F, sp40, 0xDC); + func_80033884(player, &sp2D0, &sp2E4, player->unk_07C, 0x2E, sp40, 0xDC); + func_80033884(player, &sp2D0, &sp2E4, player->unk_07C, 0x2D, 0x30000 / sp2C8, 0x6E); temp_lo_11 = 0x2E000 / sp2C8; sp40 = temp_lo_11; - func_80033884(arg0, &sp2D0, &sp2E4, arg0->unk7C, 0x2C, temp_lo_11, 0x6E); - func_80033884(arg0, &sp2D0, &sp2E4, arg0->unk7C, 0x2B, sp40, 0x6E); - func_80033884(arg0, &sp2D0, &sp2E4, arg0->unk7C, 0x2A, sp40, 0x6E); - func_80033884(arg0, &sp2D0, &sp2E4, arg0->unk7C, 0x29, sp40, 0x6E); - func_80033884(arg0, &sp2D0, &sp2E4, arg0->unk7C, 0x28, sp40, 0x6E); - func_80033884(arg0, &sp2D0, &sp2E4, arg0->unk7C, 0x27, 0x2C000 / sp2C8, 0x6E); + func_80033884(player, &sp2D0, &sp2E4, player->unk_07C, 0x2C, temp_lo_11, 0x6E); + func_80033884(player, &sp2D0, &sp2E4, player->unk_07C, 0x2B, sp40, 0x6E); + func_80033884(player, &sp2D0, &sp2E4, player->unk_07C, 0x2A, sp40, 0x6E); + func_80033884(player, &sp2D0, &sp2E4, player->unk_07C, 0x29, sp40, 0x6E); + func_80033884(player, &sp2D0, &sp2E4, player->unk_07C, 0x28, sp40, 0x6E); + func_80033884(player, &sp2D0, &sp2E4, player->unk_07C, 0x27, 0x2C000 / sp2C8, 0x6E); temp_lo_12 = 0x28000 / sp2C8; sp40 = temp_lo_12; - func_80033884(arg0, &sp2D0, &sp2E4, arg0->unk7C, 0x26, temp_lo_12, 0x6E); - func_80033884(arg0, &sp2D0, &sp2E4, arg0->unk7C, 0x25, temp_lo_12, 0x6E); + func_80033884(player, &sp2D0, &sp2E4, player->unk_07C, 0x26, temp_lo_12, 0x6E); + func_80033884(player, &sp2D0, &sp2E4, player->unk_07C, 0x25, sp40, 0x6E); temp_lo_13 = 0x24000 / sp2C8; sp40 = temp_lo_13; - func_80033884(arg0, &sp2D0, &sp2E4, arg0->unk7C, 0x24, temp_lo_13, 0x6E); - func_80033884(arg0, &sp2D0, &sp2E4, arg0->unk7C, 0x23, temp_lo_13, 0x6E); - func_80033884(arg0, &sp2D0, &sp2E4, arg0->unk7C, 0x22, 0x22000 / sp2C8, 0x6E); + func_80033884(player, &sp2D0, &sp2E4, player->unk_07C, 0x24, temp_lo_13, 0x6E); + func_80033884(player, &sp2D0, &sp2E4, player->unk_07C, 0x23, sp40, 0x6E); + func_80033884(player, &sp2D0, &sp2E4, player->unk_07C, 0x22, 0x22000 / sp2C8, 0x6E); temp_lo_14 = 0x20000 / sp2C8; sp40 = temp_lo_14; - func_80033884(arg0, &sp2D0, &sp2E4, arg0->unk7C, 0x20, temp_lo_14, 0x64); - func_80033884(arg0, &sp2D0, &sp2E4, arg0->unk7C, 0x1F, temp_lo_14, 0x64); - func_80033A40(arg0, &sp2D0, &sp2E4, arg0->unk7C, 0x1E, 0x1F000 / sp2CC, D_800EDCF8); - func_80033A40(arg0, &sp2D0, &sp2E4, arg0->unk7C, 0x1D, 0x1E000 / sp2CC, D_800EDCFC); - func_80033A40(arg0, &sp2D0, &sp2E4, arg0->unk7C, 0x1C, 0x1D000 / sp2CC, D_800EDD00); - func_80033A40(arg0, &sp2D0, &sp2E4, arg0->unk7C, 0x1B, 0x1C000 / sp2CC, D_800EDD04); - func_80033A40(arg0, &sp2D0, &sp2E4, arg0->unk7C, 0x1A, 0x1B000 / sp2CC, D_800EDD08); - func_80033A40(arg0, &sp2D0, &sp2E4, arg0->unk7C, 0x19, 0x1A000 / sp2CC, 1.0f); - func_80033A40(arg0, &sp2D0, &sp2E4, arg0->unk7C, 0x18, 0x19000 / sp2CC, 1.0f); - func_80033A40(arg0, &sp2D0, &sp2E4, arg0->unk7C, 0x17, 0x18000 / sp2CC, 1.0f); - func_80033A40(arg0, &sp2D0, &sp2E4, arg0->unk7C, 0x16, 0x17000 / sp2CC, 1.0f); - func_80033A40(arg0, &sp2D0, &sp2E4, arg0->unk7C, 0x15, 0x16000 / sp2CC, 1.0f); - func_80033A40(arg0, &sp2D0, &sp2E4, arg0->unk7C, 0x14, 0x15000 / sp2CC, D_800EDD0C); - func_80033A40(arg0, &sp2D0, &sp2E4, arg0->unk7C, 0x13, 0x14000 / sp2CC, D_800EDD10); - func_80033A40(arg0, &sp2D0, &sp2E4, arg0->unk7C, 0x12, 0x13000 / sp2CC, D_800EDD14); - func_80033A40(arg0, &sp2D0, &sp2E4, arg0->unk7C, 0x11, 0x12000 / sp2CC, D_800EDD18); - func_80033A40(arg0, &sp2D0, &sp2E4, arg0->unk7C, 0x10, 0x11000 / sp2CC, D_800EDD1C); - func_80033A40(arg0, &sp2D0, &sp2E4, arg0->unk7C, 0xF, 0x10000 / sp2CC, D_800EDD20); - func_80033A40(arg0, &sp2D0, &sp2E4, arg0->unk7C, 0xE, 0xF000 / sp2CC, D_800EDD24); + func_80033884(player, &sp2D0, &sp2E4, player->unk_07C, 0x20, temp_lo_14, 0x64); + func_80033884(player, &sp2D0, &sp2E4, player->unk_07C, 0x1F, sp40, 0x64); + func_80033A40(player, &sp2D0, &sp2E4, player->unk_07C, 0x1E, 0x1F000 / sp2CC, 0.9f); + func_80033A40(player, &sp2D0, &sp2E4, player->unk_07C, 0x1D, 0x1E000 / sp2CC, 0.9f); + func_80033A40(player, &sp2D0, &sp2E4, player->unk_07C, 0x1C, 0x1D000 / sp2CC, 0.9f); + func_80033A40(player, &sp2D0, &sp2E4, player->unk_07C, 0x1B, 0x1C000 / sp2CC, 0.9f); + func_80033A40(player, &sp2D0, &sp2E4, player->unk_07C, 0x1A, 0x1B000 / sp2CC, 0.9f); + func_80033A40(player, &sp2D0, &sp2E4, player->unk_07C, 0x19, 0x1A000 / sp2CC, 1.0f); + func_80033A40(player, &sp2D0, &sp2E4, player->unk_07C, 0x18, 0x19000 / sp2CC, 1.0f); + func_80033A40(player, &sp2D0, &sp2E4, player->unk_07C, 0x17, 0x18000 / sp2CC, 1.0f); + func_80033A40(player, &sp2D0, &sp2E4, player->unk_07C, 0x16, 0x17000 / sp2CC, 1.0f); + func_80033A40(player, &sp2D0, &sp2E4, player->unk_07C, 0x15, 0x16000 / sp2CC, 1.0f); + func_80033A40(player, &sp2D0, &sp2E4, player->unk_07C, 0x14, 0x15000 / sp2CC, 1.05f); + func_80033A40(player, &sp2D0, &sp2E4, player->unk_07C, 0x13, 0x14000 / sp2CC, 1.05f); + func_80033A40(player, &sp2D0, &sp2E4, player->unk_07C, 0x12, 0x13000 / sp2CC, 1.05f); + func_80033A40(player, &sp2D0, &sp2E4, player->unk_07C, 0x11, 0x12000 / sp2CC, 1.05f); + func_80033A40(player, &sp2D0, &sp2E4, player->unk_07C, 0x10, 0x11000 / sp2CC, 1.05f); + func_80033A40(player, &sp2D0, &sp2E4, player->unk_07C, 0xF, 0x10000 / sp2CC, 1.2f); + func_80033A40(player, &sp2D0, &sp2E4, player->unk_07C, 0xE, 0xF000 / sp2CC, 1.2f); temp_lo_15 = 0xE000 / sp2CC; sp40 = temp_lo_15; - func_80033A40(arg0, &sp2D0, &sp2E4, arg0->unk7C, 0xD, temp_lo_15, D_800EDD28); + func_80033A40(player, &sp2D0, &sp2E4, player->unk_07C, 0xD, temp_lo_15, 1.2f); temp_lo_16 = 0xD000 / sp2CC; sp3C = temp_lo_16; - func_80033A40(arg0, &sp2D0, &sp2E4, arg0->unk7C, 0xC, temp_lo_16, D_800EDD2C); + func_80033A40(player, &sp2D0, &sp2E4, player->unk_07C, 0xC, temp_lo_16, 1.2f); temp_lo_17 = 0xC000 / sp2CC; sp38 = temp_lo_17; - func_80033A40(arg0, &sp2D0, &sp2E4, arg0->unk7C, 0xB, temp_lo_17, D_800EDD30); - func_80033A40(arg0, &sp2D0, &sp2E4, arg0->unk7C, 0xA, sp40, D_800EDD34); - func_80033A40(arg0, &sp2D0, &sp2E4, arg0->unk7C, 9, sp3C, D_800EDD38); - func_80033A40(arg0, &sp2D0, &sp2E4, arg0->unk7C, 8, sp38, D_800EDD3C); - func_80033A40(arg0, &sp2D0, &sp2E4, arg0->unk7C, 7, 0xB000 / sp2CC, D_800EDD40); - func_80033A40(arg0, &sp2D0, &sp2E4, arg0->unk7C, 6, 0xA000 / sp2CC, D_800EDD44); - func_80033A40(arg0, &sp2D0, &sp2E4, arg0->unk7C, 5, 0x9000 / sp2CC, D_800EDD48); - func_80033A40(arg0, &sp2D0, &sp2E4, arg0->unk7C, 4, 0x8000 / sp2CC, D_800EDD4C); - func_80033A40(arg0, &sp2D0, &sp2E4, arg0->unk7C, 3, 0x7000 / sp2CC, D_800EDD50); - func_80033A40(arg0, &sp2D0, &sp2E4, arg0->unk7C, 2, 0x6000 / sp2CC, D_800EDD54); - func_80033A40(arg0, &sp2D0, &sp2E4, arg0->unk7C, 1, 0x5000 / sp2CC, D_800EDD58); - func_80033A40(arg0, &sp2D0, &sp2E4, arg0->unk7C, 0, 0 / sp2CC, D_800EDD5C); - temp_v1_7 = arg0->unkBC; + func_80033A40(player, &sp2D0, &sp2E4, player->unk_07C, 0xB, temp_lo_17, 1.2f); + func_80033A40(player, &sp2D0, &sp2E4, player->unk_07C, 0xA, sp40, 1.6f); + func_80033A40(player, &sp2D0, &sp2E4, player->unk_07C, 9, sp3C, 1.6f); + func_80033A40(player, &sp2D0, &sp2E4, player->unk_07C, 8, sp38, 1.6f); + func_80033A40(player, &sp2D0, &sp2E4, player->unk_07C, 7, 0xB000 / sp2CC, 1.6f); + func_80033A40(player, &sp2D0, &sp2E4, player->unk_07C, 6, 0xA000 / sp2CC, 1.6f); + func_80033A40(player, &sp2D0, &sp2E4, player->unk_07C, 5, 0x9000 / sp2CC, 1.9f); + func_80033A40(player, &sp2D0, &sp2E4, player->unk_07C, 4, 0x8000 / sp2CC, 1.9f); + func_80033A40(player, &sp2D0, &sp2E4, player->unk_07C, 3, 0x7000 / sp2CC, 1.9f); + func_80033A40(player, &sp2D0, &sp2E4, player->unk_07C, 2, 0x6000 / sp2CC, 1.9f); + func_80033A40(player, &sp2D0, &sp2E4, player->unk_07C, 1, 0x5000 / sp2CC, 1.9f); + func_80033A40(player, &sp2D0, &sp2E4, player->unk_07C, 0, 0 / sp2CC, 1.9f); + temp_v1_7 = player->unk_0BC; temp_v0_7 = temp_v1_7 & 0x10; if (temp_v0_7 == 0x10) { - phi_f2_2 = (sp2E4 >> 0x10) / 8; - phi_f0_5 = (arg0->unk94 / 18.0f) * 216.0f; + phi_f2_2 = (f32) ((s32) (sp2E4 >> 0x10) / 8); + phi_f0_5 = (player->unk_094 / 18.0f) * 216.0f; } else { - temp_f0_7 = (arg0->unk94 / 18.0f) * 216.0f; - phi_f0_5 = temp_f0_7; - if (temp_f0_7 <= 25.0f) { - phi_f2_2 = (sp2E4 >> 0x10) / 0xC; + temp_f0_5 = (player->unk_094 / 18.0f) * 216.0f; + phi_f0_5 = temp_f0_5; + if (temp_f0_5 <= 25.0f) { + phi_f2_2 = (f32) ((s32) (sp2E4 >> 0x10) / 12); } else { - phi_f2_2 = (sp2E4 >> 0x10) / (8.0f + (arg0->unk9C / 50.0f)); + phi_f2_2 = (f32) (sp2E4 >> 0x10) / (8.0f + (player->unk_09C / 50.0f)); } } phi_f2_5 = phi_f2_2; @@ -6491,127 +6559,127 @@ void func_80033AE0(void *arg0, void *arg1, s8 arg2) { phi_f2_5 = -phi_f2_2; } if ((temp_v1_7 & 0x20) == 0x20) { - phi_f2_3 = (sp + (phi_f0_5 * 4))->unk6C * 1.5f * phi_f2_5; + phi_f2_3 = (sp + ((s16) (s32) phi_f0_5 * 4))->unk6C * 1.5f * phi_f2_5; } else if (temp_v0_7 == 0x10) { - phi_f2_3 = (sp + (phi_f0_5 * 4))->unk44 * phi_f2_5; + phi_f2_3 = (sp + ((s16) (s32) phi_f0_5 * 4))->unk44 * phi_f2_5; } else { - phi_f2_3 = (sp + (phi_f0_5 * 4))->unk44 * 1.5f * phi_f2_5; + phi_f2_3 = (sp + ((s16) (s32) phi_f0_5 * 4))->unk44 * 1.5f * phi_f2_5; } - arg0->unk7C = sp2E4; - if (arg0->unk10C != 0) { + player->unk_07C = sp2E4; + if (player->unk_10C != 0) { sp2C4 = phi_f2_3; - func_8002BD58(arg0, 0x10); + func_8002BD58(player, 0x10); } - temp_v0_8 = arg0->unk1EC; - arg0->unkBC = arg0->unkBC & 0xDFFFFFFF; - if (temp_v0_8 >= 0xF) { + temp_v0_8 = player->boundingBoxCorners[3].surfaceType; + player->unk_0BC &= 0xDFFFFFFF; + if ((s32) temp_v0_8 >= 0xF) { phi_f12_2 = sp2C0; } else { - phi_f12_2 = 0.0f + *(*(&D_800E3410 + (arg0->unk254 * 4)) + (temp_v0_8 * 4)); + phi_f12_2 = 0.0f + D_800E3410[player->characterId][temp_v0_8]; } - temp_v0_9 = arg0->unk1D4; + temp_v0_9 = player->boundingBoxCorners[2].surfaceType; phi_f12 = phi_f12_2; - if (temp_v0_9 < 0xF) { - phi_f12 = phi_f12_2 + *(*(&D_800E3410 + (arg0->unk254 * 4)) + (temp_v0_9 * 4)); + if ((s32) temp_v0_9 < 0xF) { + phi_f12 = phi_f12_2 + D_800E3410[player->characterId][temp_v0_9]; } - temp_v1_8 = arg0->unkBC; + temp_v1_8 = player->unk_0BC; temp_v0_10 = temp_v1_8 & 2; if ((temp_v0_10 != 2) && ((temp_v1_8 & 0x10) != 0x10)) { if ((temp_v1_8 & 0x20) == 0x20) { - arg0->unk78 = ((arg0->unk7C >> 0x10) * 5) * phi_f2_3; + player->unk_078 = (s16) (s32) ((f32) (((s32) player->unk_07C >> 0x10) * 5) * phi_f2_3); } else { if ((temp_v1_8 & 1) != 1) { - temp_t3_2 = arg0->unk7C >> 0x10; - temp_t4 = arg0->unk254 * 4; + temp_v1_9 = player->characterId; + temp_t3_2 = (s32) player->unk_07C >> 0x10; if ((temp_t3_2 >= 0x2D) || (temp_t3_2 < -0x2C)) { - arg0->unk78 = (*(&gKartHandlingTable + temp_t4) + D_800EDD60) * (temp_t3_2 * (phi_f2_3 + (phi_f2_3 * phi_f12))); + player->unk_078 = (s16) (s32) (((f64) gKartHandlingTable[temp_v1_9] + 0.15) * (f64) ((f32) temp_t3_2 * (phi_f2_3 + (phi_f2_3 * phi_f12)))); } else { - arg0->unk78 = *(&gKartHandlingTable + temp_t4) * (temp_t3_2 * (phi_f2_3 + (phi_f2_3 * phi_f12))); + player->unk_078 = (s16) (s32) (gKartHandlingTable[temp_v1_9] * ((f32) temp_t3_2 * (phi_f2_3 + (phi_f2_3 * phi_f12)))); } } else { - temp_f0_8 = (arg0->unk94 / 18.0f) * 216.0f; - phi_f0 = temp_f0_8; - if ((temp_f0_8 >= 0.0f) && (temp_f0_8 < 8.0f)) { - arg0->unk78 = (arg0->unk7C >> 0x10) * (phi_f2_3 + (phi_f2_3 * phi_f12)); - phi_f0 = (arg0->unk94 / 18.0f) * 216.0f; + temp_f0_6 = (player->unk_094 / 18.0f) * 216.0f; + phi_f0 = temp_f0_6; + if ((temp_f0_6 >= 0.0f) && (temp_f0_6 < 8.0f)) { + player->unk_078 = (s16) (s32) ((f32) ((s32) player->unk_07C >> 0x10) * (phi_f2_3 + (phi_f2_3 * phi_f12))); + phi_f0 = (player->unk_094 / 18.0f) * 216.0f; } phi_f0_2 = phi_f0; if ((phi_f0 >= 8.0f) && (phi_f0 < 65.0f)) { - arg0->unk78 = (arg0->unk7C >> 0x10) * (phi_f2_3 + 1.5 + (phi_f2_3 * phi_f12)); - phi_f0_2 = (arg0->unk94 / 18.0f) * 216.0f; + player->unk_078 = (s16) (s32) ((f64) ((s32) player->unk_07C >> 0x10) * ((f64) phi_f2_3 + 1.5 + (f64) (phi_f2_3 * phi_f12))); + phi_f0_2 = (player->unk_094 / 18.0f) * 216.0f; } if (phi_f0_2 >= 65.0f) { - arg0->unk78 = (arg0->unk7C >> 0x10) * (phi_f2_3 + D_800EDD68 + (phi_f2_3 * phi_f12)); + player->unk_078 = (s16) (s32) ((f64) ((s32) player->unk_07C >> 0x10) * ((f64) phi_f2_3 + 1.6 + (f64) (phi_f2_3 * phi_f12))); } } - arg0->unk228 = 0; - if (arg0->unk22A < 2) { - arg0->unk22A = 0; + player->unk_228 = 0; + if ((s32) player->unk_22A < 2) { + player->unk_22A = 0; } } } else if (((temp_v1_8 & 8) != 8) && (temp_v0_10 != 2)) { - if ((arg0->unkC0 / 0xB6) > 0) { - temp_t5_2 = arg0->unk7C >> 0x10; - phi_s1_2 = (((temp_t5_2 * 0xD) + 0x2B1) / 0x6A) + 0x28; + if (((s32) player->unk_0C0 / 182) > 0) { + temp_t5_2 = (s32) player->unk_07C >> 0x10; + phi_s1_2 = (s16) (((s32) ((temp_t5_2 * 0xD) + 0x2B1) / 106) + 0x28); if (temp_t5_2 < -0x27) { temp_t2 = temp_v1_8 | 0x20000000; - arg0->unkBC = temp_t2; + player->unk_0BC = temp_t2; if (temp_t5_2 < -0x31) { - arg0->unkBC = temp_t2 | 0x20000000; + player->unk_0BC = temp_t2 | 0x20000000; } } sp2C4 = phi_f2_3; sp2C0 = phi_f12; - func_8002A8A4(phi_f12, 0.0f, arg0, arg2); + func_8002A8A4(phi_f12, 0.0f, player, arg2); } else { - temp_t7_2 = arg0->unk7C >> 0x10; - phi_s1_2 = (((temp_t7_2 * 0xD) + 0x2B1) / 0x6A) - 0x35; + temp_t7_2 = (s32) player->unk_07C >> 0x10; + phi_s1_2 = (s16) (((s32) ((temp_t7_2 * 0xD) + 0x2B1) / 106) - 0x35); if (temp_t7_2 >= 0x28) { - temp_t4_2 = temp_v1_8 | 0x20000000; - arg0->unkBC = temp_t4_2; + temp_t4 = temp_v1_8 | 0x20000000; + player->unk_0BC = temp_t4; if (temp_t7_2 < -0x31) { - arg0->unkBC = temp_t4_2 | 0x20000000; + player->unk_0BC = temp_t4 | 0x20000000; } } sp2C4 = phi_f2_3; sp2C0 = phi_f12; - func_8002A8A4(phi_f12, 0.0f, arg0, arg2); + func_8002A8A4(phi_f12, 0.0f, player, arg2); } - temp_f0_9 = (arg0->unk94 / 18.0f) * 216.0f; - phi_f0_3 = temp_f0_9; - if ((temp_f0_9 >= 0.0f) && (temp_f0_9 < 8.0f)) { - arg0->unk78 = phi_s1_2 * (sp2C4 + 2.0f + (sp2C4 * sp2C0)); - phi_f0_3 = (arg0->unk94 / 18.0f) * 216.0f; + temp_f0_7 = (player->unk_094 / 18.0f) * 216.0f; + phi_f0_3 = temp_f0_7; + if ((temp_f0_7 >= 0.0f) && (temp_f0_7 < 8.0f)) { + player->unk_078 = (s16) (s32) ((f32) phi_s1_2 * (sp2C4 + 2.0f + (sp2C4 * sp2C0))); + phi_f0_3 = (player->unk_094 / 18.0f) * 216.0f; } phi_f0_4 = phi_f0_3; if ((phi_f0_3 >= 8.0f) && (phi_f0_3 < 65.0f)) { - arg0->unk78 = phi_s1_2 * (sp2C4 + 3.0f + (sp2C4 * sp2C0)); - phi_f0_4 = (arg0->unk94 / 18.0f) * 216.0f; + player->unk_078 = (s16) (s32) ((f32) phi_s1_2 * (sp2C4 + 3.0f + (sp2C4 * sp2C0))); + phi_f0_4 = (player->unk_094 / 18.0f) * 216.0f; } if (phi_f0_4 >= 65.0f) { - arg0->unk78 = phi_s1_2 * (sp2C4 + 3.5 + (sp2C4 * sp2C0)); + player->unk_078 = (s16) (s32) ((f64) phi_s1_2 * ((f64) sp2C4 + 3.5 + (f64) (sp2C4 * sp2C0))); } - if ((arg0->unkBC & 0x20000000) == 0x20000000) { - arg0->unk78 = arg0->unk78 * D_800EDD70; + if ((player->unk_0BC & 0x20000000) == 0x20000000) { + player->unk_078 = (s16) (s32) ((f64) player->unk_078 * 0.9); } else { - phi_t4 = arg0->unk78 * D_800EDD78; + phi_t4 = (s16) (s32) ((f64) player->unk_078 * 0.65); goto block_125; } } else { - phi_s1_3 = arg0->unk7C >> 0x10; + phi_s1_3 = (s16) ((s32) player->unk_07C >> 0x10); if (sp2E0 == 0) { phi_s1_3 = 0; } - if (((arg0->unk94 / 18.0f) * 216.0f) <= 5.0f) { - arg0->unk78 = phi_s1_3 * (phi_f2_3 + 6.0f); + if (((player->unk_094 / 18.0f) * 216.0f) <= 5.0f) { + player->unk_078 = (s16) (s32) ((f32) phi_s1_3 * (phi_f2_3 + 6.0f)); } else { - phi_t4 = phi_s1_3 * (phi_f2_3 + 1.5f); + phi_t4 = (s16) (s32) ((f32) phi_s1_3 * (phi_f2_3 + 1.5f)); block_125: - arg0->unk78 = phi_t4; + player->unk_078 = phi_t4; } } - if (gModeSelection == BATTLE) { - arg0->unk78 = arg0->unk78 * D_800EDD80; + if (gModeSelection == 3) { + player->unk_078 = (s16) (s32) ((f64) player->unk_078 * 1.7); } } #else diff --git a/src/code_800393C0.c b/src/code_800393C0.c index f9eb32f02..2ec0714bc 100644 --- a/src/code_800393C0.c +++ b/src/code_800393C0.c @@ -79,7 +79,7 @@ void spawn_player(Player *player, s8 playerIndex, f32 arg2, f32 arg3, f32 arg4, player->unk_07C = 0; player->unk_07A = 0; player->unk_006 = 0; - player->unk_008 = -1; + player->lapCount = -1; player->unk_08C = 0.0f; player->unk_090 = 0.0f; player->unk_094 = 0.0f; @@ -233,44 +233,54 @@ void spawn_player(Player *player, s8 playerIndex, f32 arg2, f32 arg3, f32 arg4, D_801654C0[playerIndex] = 0; D_80165340 = 0; - player->frontLeftTyreSurface = 0; - player->frontRightTyreSurface = 0; - player->backLeftTyreSurface = 0; - player->backRightTyreSurface = 0; - player->unk_1A5 = 0; - player->unk_1BD = 0; - player->unk_1D5 = 0; - player->unk_1ED = 0; - player->unk_1A6 = 0; - player->unk_1BE = 0; - player->unk_1D6 = 0; - player->unk_1EE = 0; - player->unk_1C4 = 0; - player->unk_1AC = 0; - player->unk_1DC = 0; - player->unk_1F4 = 0; + player->boundingBoxCorners[FRONT_LEFT_TYRE].surfaceType = 0; + player->boundingBoxCorners[FRONT_RIGHT_TYRE].surfaceType = 0; + player->boundingBoxCorners[BACK_LEFT_TYRE].surfaceType = 0; + player->boundingBoxCorners[BACK_RIGHT_TYRE].surfaceType = 0; + + player->boundingBoxCorners[FRONT_LEFT_TYRE].unk_0D = 0; + player->boundingBoxCorners[FRONT_RIGHT_TYRE].unk_0D = 0; + player->boundingBoxCorners[BACK_LEFT_TYRE].unk_0D = 0; + player->boundingBoxCorners[BACK_RIGHT_TYRE].unk_0D = 0; + + player->boundingBoxCorners[FRONT_LEFT_TYRE].tileIndex = 0; + player->boundingBoxCorners[FRONT_RIGHT_TYRE].tileIndex = 0; + player->boundingBoxCorners[BACK_LEFT_TYRE].tileIndex = 0; + player->boundingBoxCorners[BACK_RIGHT_TYRE].tileIndex = 0; + + player->boundingBoxCorners[FRONT_RIGHT_TYRE].unk_14 = 0; + player->boundingBoxCorners[FRONT_LEFT_TYRE].unk_14 = 0; + player->boundingBoxCorners[BACK_LEFT_TYRE].unk_14 = 0; + player->boundingBoxCorners[BACK_RIGHT_TYRE].unk_14 = 0; + player->unk_110 = 0; player->unk_112 = 0; player->unk_114 = 0; player->unk_116 = 0; player->unk_118 = 0; player->unk_11A = 0; - player->unk_198 = 0.0f; - player->unk_19C = 0.0f; - player->unk_1A0 = 0.0f; - player->unk_1B0 = 0.0f; - player->unk_1B4 = 0.0f; - player->unk_1B8 = 0.0f; - player->unk_1C8 = 0.0f; - player->unk_1CC = 0.0f; - player->unk_1D0 = 0.0f; - player->unk_1E0 = 0.0f; - player->unk_1E4 = 0.0f; - player->unk_1E8 = 0.0f; - player->unk_1A8 = 0.0f; - player->unk_1C0 = 0.0f; - player->unk_1D8 = 0.0f; - player->unk_1F0 = 0.0f; + + player->boundingBoxCorners[FRONT_LEFT_TYRE].cornerX = 0.0f; + player->boundingBoxCorners[FRONT_LEFT_TYRE].cornerY = 0.0f; + player->boundingBoxCorners[FRONT_LEFT_TYRE].cornerZ = 0.0f; + + player->boundingBoxCorners[FRONT_RIGHT_TYRE].cornerX = 0.0f; + player->boundingBoxCorners[FRONT_RIGHT_TYRE].cornerY = 0.0f; + player->boundingBoxCorners[FRONT_RIGHT_TYRE].cornerZ = 0.0f; + + player->boundingBoxCorners[BACK_LEFT_TYRE].cornerX = 0.0f; + player->boundingBoxCorners[BACK_LEFT_TYRE].cornerY = 0.0f; + player->boundingBoxCorners[BACK_LEFT_TYRE].cornerZ = 0.0f; + + player->boundingBoxCorners[BACK_RIGHT_TYRE].cornerX = 0.0f; + player->boundingBoxCorners[BACK_RIGHT_TYRE].cornerY = 0.0f; + player->boundingBoxCorners[BACK_RIGHT_TYRE].cornerZ = 0.0f; + + player->boundingBoxCorners[FRONT_LEFT_TYRE].cornerGroundY = 0.0f; + player->boundingBoxCorners[FRONT_RIGHT_TYRE].cornerGroundY = 0.0f; + player->boundingBoxCorners[BACK_LEFT_TYRE].cornerGroundY = 0.0f; + player->boundingBoxCorners[BACK_RIGHT_TYRE].cornerGroundY = 0.0f; + player->unk_11C = 0.0f; player->unk_120 = 0.0f; player->unk_124 = 0.0f; diff --git a/src/code_800431B0.c b/src/code_800431B0.c index 1ddc06de9..94aafa6ef 100644 --- a/src/code_800431B0.c +++ b/src/code_800431B0.c @@ -5928,7 +5928,7 @@ void func_80050320(void) { phi_a0 = 1; } temp_v1 = gGPCurrentRaceRanks[phi_s0]; - temp_a1 = lapCount[*((phi_s0 * 2) + &D_80164360)]; + temp_a1 = gLapCountByPlayerId[*((phi_s0 * 2) + &D_80164360)]; if (temp_v1 == gPlayerOne->characterId) { func_8004FDB4(*temp_t0, temp_f14, phi_a0, temp_a1, phi_s0, temp_a1, temp_v1, 0xFF, 1, phi_a0, 0); } else { @@ -5953,7 +5953,7 @@ void func_80050320(void) { phi_a0_2 = 1; } temp_v0 = *((phi_s0_2 * 2) + &D_80164360); - temp_a1_2 = lapCount[temp_v0]; + temp_a1_2 = gLapCountByPlayerId[temp_v0]; temp_v1_2 = gPlayerOne[temp_v0].characterId; if (temp_v0 == 0) { func_8004FDB4(*temp_t0_2, temp_f14_2, phi_a0_2, temp_a1_2, phi_s0_2, temp_a1_2, temp_v1_2, 0xFF, 1, phi_a0_2, 1); @@ -5978,8 +5978,8 @@ GLOBAL_ASM("asm/non_matchings/code_800431B0/func_80050320.s") #ifdef MIPS_TO_C //generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307 -extern ? D_801644A8; -extern ? lapCount; +extern ? gLapCompletionPercentByPlayerId; +extern ? gLapCountByPlayerId; ? func_80050644(s32 arg0, s32 *arg1, s32 *arg2) { s32 temp_a3; @@ -5990,13 +5990,13 @@ extern ? lapCount; temp_t6 = arg0 & 0xFFFF; temp_t0 = temp_t6 * 4; - temp_a3 = *(&lapCount + temp_t0); + temp_a3 = *(&gLapCountByPlayerId + temp_t0); phi_v0 = 0; phi_v0_2 = 0; if (temp_a3 < 3) { if (gPlayerCountSelection1 == 1) { if (temp_a3 >= 0) { - phi_v0 = *(&D_801644A8 + temp_t0) * 928.0f; + phi_v0 = *(&gLapCompletionPercentByPlayerId + temp_t0) * 928.0f; } if (phi_v0 < 0x104) { *arg1 = phi_v0; @@ -6018,7 +6018,7 @@ extern ? lapCount; return 4; } if (temp_a3 >= 0) { - phi_v0_2 = *(&D_801644A8 + temp_t0) * 260.0f; + phi_v0_2 = *(&gLapCompletionPercentByPlayerId + temp_t0) * 260.0f; } *arg1 = phi_v0_2; *arg2 = 0; @@ -6029,7 +6029,7 @@ extern ? lapCount; *arg2 = (gPlayerPositions[temp_t6] * 0x14) + 0x20; return 0; } - *arg1 = *(&D_801644A8 + temp_t0) * 260.0f; + *arg1 = *(&gLapCompletionPercentByPlayerId + temp_t0) * 260.0f; *arg2 = 0; return 0; } @@ -6100,7 +6100,7 @@ void func_800508C0(void) { } else { phi_s0 = D_80164360; } - temp_v1 = lapCount[phi_s0]; + temp_v1 = gLapCountByPlayerId[phi_s0]; sp4C = func_80050644(phi_s0 & 0xFFFF, &sp54, &sp50); if (temp_v1 > 0) { if (temp_v1 == 1) { @@ -6128,10 +6128,10 @@ void func_800508C0(void) { phi_s0_3 = sp42; phi_s1_2 = sp40; phi_s2_2 = sp3E; - if ((lapCount[phi_s0] >= 0) && (lapCount[phi_s0] < 3)) { - if (lapCount[phi_s0] != 0) { - if (lapCount[phi_s0] != 1) { - if (lapCount[phi_s0] != 2) { + if ((gLapCountByPlayerId[phi_s0] >= 0) && (gLapCountByPlayerId[phi_s0] < 3)) { + if (gLapCountByPlayerId[phi_s0] != 0) { + if (gLapCountByPlayerId[phi_s0] != 1) { + if (gLapCountByPlayerId[phi_s0] != 2) { } else { phi_s1_2 = 0; @@ -6208,7 +6208,7 @@ extern s32 D_8018D3E4; extern s32 D_8018D3E8; extern s32 D_8018D3EC; extern void *gDisplayListHead; -extern ? lapCount; +extern ? gLapCountByPlayerId; void func_80050E34(s32 arg0, s32 arg1) { s32 spD4; @@ -6261,7 +6261,7 @@ void func_80050E34(s32 arg0, s32 arg1) { temp_v0 = &gPlayerOne[arg0]; spAC = temp_v0; - temp_s0 = *(&lapCount + (arg0 * 4)); + temp_s0 = *(&gLapCountByPlayerId + (arg0 * 4)); temp_s1 = temp_v0->characterId; temp_t5 = *(&D_8018CE24 + (arg0 << 5)); if (gPlayerCountSelection1 == 1) { diff --git a/src/code_80057C60.c b/src/code_80057C60.c index 687aae3be..f7fa59963 100644 --- a/src/code_80057C60.c +++ b/src/code_80057C60.c @@ -2,11 +2,12 @@ #include #include #include -#include -#include +#include #include #include +#include "code_80057C60.h" #include "code_80040E50.h" +#include "math_util.h" void func_8001C3C4(s32); void func_80041D34(void); @@ -34,45 +35,6 @@ void func_800532A4(s32); void func_80054BE8(s32); void func_80055F48(s32); void func_80056160(s32); -void func_80059360(void); -void func_80059560(s32); -void func_80059820(s32); -void func_8005995C(void); -void func_80059D00(void); -void func_8005A14C(s32); -void func_8005A380(void); -void func_8005A3C0(void); -void func_8005A71C(void); -void func_8005A74C(void); -void func_8005A99C(void); -void func_8005AA34(void); -void func_8005B914(void); -void func_8005C360(f32); -void func_8005C728(void); -void func_8005CB60(s32, s32); -void func_8005D0FC(s32); -void func_8005D1F4(s32); -void func_80062B18(f32*, f32*, f32*, f32, f32, f32, u16, u16); -void func_80066998(Player*, s8, s16, s8); -void func_80067964(Player*, s8, s32, s8, s32); -void func_80067D3C(Player*, s8, s32, s32, f32, s32); -void func_8006801C(Player*, s8, s32, s32, f32, s32); -void func_80068310(Player*, s8, s32, s8, s32); -void func_80068724(Player*, s8, s32, s8, s32); -void func_80068AA4(Player*, s8, s32, s8, s32); -void func_80068DA0(Player*, s8, s32, s8, s32); -void func_8006A280(Player*, s8, s16, s8); -void func_800658A0(Player*, s8, s16, s8); -void func_8006B9CC(Player*, s8); -void func_8006AFD0(Player*, s16, s8, s8); -void func_8006C6AC(Player*, s16, s8, s8); -void func_8006C9B8(Player*, s16, s8, s8); -void func_8006CEC0(Player*, s16, s8, s8); -void func_8006D194(Player*, s8, s8); -void func_8006D474(Player*, s8, s8); -void func_8006DC54(Player*, s8, s8); -void func_8006DD3C(Player*, s8, s8); -void func_8006E420(Player*, s8, s8); void func_800744CC(void); void func_80077640(void); void func_80078C70(s32); @@ -89,118 +51,11 @@ void func_8008C1E0(s32*, s32*); void func_8008C204(void); void func_802A3730(struct UnkStruct_800DC5EC*); -f32 coss(u16); -f32 sins(u16); - -extern Mtx *D_80183D60; -extern Vp D_802B8880; -extern Gfx *gDisplayListHead; -extern struct GfxPool *gGfxPool; -extern s32 gPlayerCountSelection1; -extern s16 gCurrentCourseId; - -extern struct UnkStruct_800DC5EC *D_800DC5EC; -extern struct UnkStruct_800DC5EC *D_800DC5F0; -extern struct UnkStruct_800DC5EC *D_800DC5F4; -extern struct UnkStruct_800DC5EC *D_800DC5F8; -extern s32 D_8018D21C; -extern u16 gPlayerBalloonStatus[8][3]; // 0x8018D5F0 -extern s16 gPlayerBalloonCount[]; - -extern Player* gPlayerOneCopy; -extern u16 D_800DC5FC; -extern f64 D_800EE648; -extern f64 D_800EE650; -extern f64 D_800EE658; -extern f64 D_800EE660; -extern f64 D_800EE668; -extern f64 D_800EE670; -extern f64 D_800EE678; -extern f32 D_800EE680; -extern f32 D_800EE684; -extern f32 D_800EE688; -extern f32 D_800EE68C; -extern f64 D_800EE690; -extern f64 D_800EE698; -extern f64 D_800EE6A0; -extern f64 D_800EE6A8; -extern f64 D_800EE6B0; -extern f64 D_800EE6B8; -extern f64 D_800EE6C0; -extern f64 D_800EE6D8; -extern f64 D_800EE6E0; -extern f64 D_800EE6E8; -extern f64 D_800EE700; -extern f64 D_800EE708; -extern f64 D_800EE710; -extern f64 D_800EE718; -extern f64 D_800EE720; -extern f64 D_800EE728; -extern f64 D_800EE730; -extern f64 D_800EE738; -extern f64 D_800EE740; -extern f64 D_800EE748; -extern f64 D_800EE750; -extern f64 D_800EE758; -extern f64 D_800EE760; -extern f64 D_800EE768; -extern f64 D_800EE770; -extern f64 D_800EE778; -extern f32 D_800EE780; -extern f64 D_800EE788; -extern f64 D_800EE790; -extern f64 D_800EE798; -extern f64 D_800EE7A0; -extern f64 D_800EE7A8; -extern f32 D_800EE7B0; -extern f64 D_800EE7B8; -extern f32 D_800EE948; -extern f32 D_800EE94C; -extern s32 lapCount; -extern s32 D_80164394; -extern s32 D_80164398; -extern s32 D_8016439C; -extern s32 gPlayerPositions; -extern f32 D_801652A0[]; -extern s32 D_801655C0; -extern s32 D_801655F0; -extern s32 D_80165678; -extern s8 D_801657AE; -extern s8 D_801657D8; -extern s8 D_801657E8; -extern s8 D_8018CAE0; -extern s32 D_8018D120; -extern s32 D_8018D170; -extern s32 D_8018D178; -extern s32 D_8018D188; -extern s32 D_8018D190; -extern s32 D_8018D1A0; -extern s32 D_8018D1B4; -extern s32 D_8018D1D4; -extern s32 D_8018D1CC; -extern s32 D_8018D1FC; -extern s32 D_8018D204; -extern s32 D_8018D2A4; -extern s32 D_8018D2BC; -extern s32 D_8018D480; -extern s32 D_8018D484; -extern s32 gActiveScreenMode; -extern s32 gModeSelection; -extern s32 gPlayerCountSelection1; -extern Player* gPlayerEight; -extern Player* gPlayerFive; -extern Player* gPlayerFour; -extern Player* gPlayerOne; -extern Player* gPlayerSeven; -extern Player* gPlayerSix; -extern Player* gPlayerThree; -extern Player* gPlayerTwo; - // UI Code? void func_80057C60(void) { - gSPViewport(gDisplayListHead++, VIRTUAL_TO_PHYSICAL(&D_802B8880)); + gSPViewport(gDisplayListHead++, VIRTUAL_TO_PHYSICAL(D_802B8880)); gDPSetScissor(gDisplayListHead++, G_SC_NON_INTERLACE, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT); - gSPMatrix(gDisplayListHead++, VIRTUAL_TO_PHYSICAL(&D_80183D60), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION); + gSPMatrix(gDisplayListHead++, VIRTUAL_TO_PHYSICAL(D_80183D60), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION); } void func_80057CE4(void) { @@ -294,10 +149,6 @@ void func_80057FC4(u32 arg0) { } extern s32 D_8018D22C; -void func_800581C8(); -void func_800582CC(); -void func_80058394(); -void func_8005845C(); void func_80058090(u32 arg0) { UNUSED Gfx *temp_v1; @@ -354,7 +205,6 @@ void func_80058090(u32 arg0) { } void func_8005217C(s32); -void func_800588F4(s32 arg0); extern s32 D_800DC50C; extern u16 D_800DC51C; void func_800581C8(void) { @@ -412,11 +262,6 @@ void func_8005845C(void) { func_800588F4(3); } -void func_80058640(); /* extern */ -void func_800586FC(); /* extern */ -void func_800587A4(); /* extern */ -void func_8005884C(); /* extern */ - void func_80058538(u32 arg0) { UNUSED Gfx *temp_v1; @@ -460,8 +305,6 @@ void func_80058538(u32 arg0) { } } -void func_80058B58(); - void func_80058640(void) { gDPSetTexturePersp(gDisplayListHead++, G_TP_PERSP); gSPMatrix(gDisplayListHead++, VIRTUAL_TO_PHYSICAL(&gGfxPool->mtxPool[1]), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION); @@ -515,7 +358,6 @@ void func_80055C38(s32); void func_80055E68(s32); void func_80056188(s32); void func_80056AC0(s32); -extern s32 gModeSelection; extern s16 D_80165730; extern s8 D_8018EDF3; extern s8 D_80165898; @@ -643,16 +485,6 @@ void func_80058BF4(void) { gSPDisplayList(gDisplayListHead++, &D_0D0076F8); } -void func_80058F48(void); -void func_80059358(void); -void func_800593F0(void); -void func_800594F0(void); -void func_80059528(void); -void func_800596A8(void); -void func_80059710(void); -void func_80059750(void); -void func_800597B8(void); - void func_80058C20(u32 arg0) { D_8018D21C = arg0; @@ -721,15 +553,6 @@ void func_80058C20(u32 arg0) { } } -void func_800593F8(void); -void func_80058F78(void); -void func_800594F8(void); -void func_80059530(void); -void func_800596D8(void); -void func_80059718(void); -void func_80059780(void); -void func_800597E8(void); - void func_80058DB4(u32 arg0) { D_8018D21C = arg0; @@ -896,8 +719,6 @@ extern s8 D_80165801; extern s32 D_8018D188; extern s32 D_8018D2BC; -extern s32 gScreenModeSelection; - void func_800591B4(void) { if ((D_801657B0 == 0) && (D_800DC5B8 != 0)) { @@ -1484,7 +1305,7 @@ void func_8005A070(void) { extern f32 D_800EE1E0; extern ? D_80165C18; extern ? D_8018CE24; -extern ? lapCount; +extern ? gLapCountByPlayerId; void func_8005A14C(s32 arg0) { s32 sp2C; @@ -1498,7 +1319,7 @@ void func_8005A14C(s32 arg0) { void *phi_s0; temp_t0 = &gPlayerOne[arg0]; - sp28 = *(&lapCount + (arg0 * 4)); + sp28 = *(&gLapCountByPlayerId + (arg0 * 4)); temp_a3 = *(&D_8018CE24 + (arg0 << 5)); if ((temp_t0->unk_000 & 0x8000) != 0) { if ((temp_t0->unk_0BC & 0x204C0) != 0) { @@ -2481,7 +2302,7 @@ void func_8005B914(void) { func_8005AA94(0x82); goto block_76; case 0x80: /* switch 1 */ - if (gPlayerPositions < 4) { + if (gPlayerPositions[0] < 4) { func_8005AA6C(0x8C); } else { func_8005AA6C(0x82); @@ -3169,7 +2990,7 @@ void func_8005D0FC(s32 arg0) { if (gModeSelection != BATTLE) { switch (arg0) { /* irregular */ case 0: - func_8005CB60(arg0, lapCount); + func_8005CB60(arg0, gLapCountByPlayerId[0]); break; case 1: func_8005CB60(arg0, D_80164394); @@ -3189,7 +3010,7 @@ void func_8005D18C(void) { D_801657D8 = 1; D_8018D2BC = 0; D_8018D2A4 = 0; - if (gPlayerPositions >= 4) { + if (gPlayerPositions[0] >= 4) { D_8018D1FC = 1; D_8018D2A4 = 1; D_8018D2BC = 1; @@ -3500,57 +3321,56 @@ GLOBAL_ASM("asm/non_matchings/code_80057C60/func_8005D82C.s") #endif #ifdef MIPS_TO_C -//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307 -? func_8005D794(void *, void *, f32, f32, ?32, s32, s32); // extern -? func_8005D7D8(void *, ?, ?); // extern -? func_8005D800(void *, ?, ?); // extern +//generated by mips_to_c commit 792017ad9d422c2467bd42686f383a5c41f41c75 +? func_8005D794(Player *, f32, f32, f32, f32, s32, s32); /* extern */ +? func_8005D7D8(Player *, ?, ?); /* extern */ +? func_8005D800(Player *, ?, ?); /* extern */ -void func_8005D898(void *arg0, s16 arg1, ? arg2, ? arg3) { +void func_8005D898(Player *player, s32 arg1, s8 arg2, s32 arg3) { + Player *temp_s1; + Player *temp_s1_2; s32 temp_lo; - void *temp_s1; - void *temp_s1_2; void *temp_s2; void *temp_s2_2; - void *phi_s1; + Player *phi_s1; s32 phi_v0; s32 phi_v0_2; void *phi_s2; - if (arg0->unkC0 >= 0) { - temp_s2 = arg0 + (arg1 * 0x48); + if ((s32) player->unk_0C0 >= 0) { + temp_s2 = player + ((s16) arg1 * 0x48); temp_s1 = temp_s2 + 0x528; - func_8005D794(temp_s1, arg0->unk1C8, arg0->unk1D8 + 2.0f, arg0->unk1D0, arg0->unk1D4, 1); + func_8005D794(temp_s1, player->boundingBoxCorners[2].cornerX, player->boundingBoxCorners[2].cornerGroundY + 2.0f, player->boundingBoxCorners[2].cornerZ, (bitwise f32) player->boundingBoxCorners[2].surfaceType, 1); phi_s1 = temp_s1; phi_s2 = temp_s2; } else { - temp_s2_2 = arg0 + (arg1 * 0x48); + temp_s2_2 = player + ((s16) arg1 * 0x48); temp_s1_2 = temp_s2_2 + 0x528; - func_8005D794(arg0, temp_s1_2, arg0->unk1E0, arg0->unk1F0 + 2.0f, arg0->unk1E8, arg0->unk1EC, 0); + func_8005D794(player, (bitwise f32) temp_s1_2, player->boundingBoxCorners[3].cornerX, player->boundingBoxCorners[3].cornerGroundY + 2.0f, player->boundingBoxCorners[3].cornerZ, (s32) player->boundingBoxCorners[3].surfaceType, 0); phi_s1 = temp_s1_2; phi_s2 = temp_s2_2; } - temp_lo = arg0->unkC0 / 0xB6; + temp_lo = (s32) player->unk_0C0 / 182; if ((temp_lo >= 7) || (temp_lo < -6)) { func_8005D7D8(phi_s1, 1, 0x3EB33333); - if (arg0->unk22A == 0) { + if (player->unk_22A == 0) { func_8005D800(phi_s1, 0xFFFFFF, 0x70); } - phi_v0 = arg0->unk22A; - if (arg0->unk22A == 1) { + phi_v0 = (s32) player->unk_22A; + if (player->unk_22A == 1) { func_8005D800(phi_s1, 0xFFFF00, 0x70); - phi_v0 = arg0->unk22A; + phi_v0 = (s32) player->unk_22A; } phi_v0_2 = phi_v0; if (phi_v0 >= 2) { func_8005D800(phi_s1, 0xFF9600, 0x70); - phi_v0_2 = arg0->unk22A; + phi_v0_2 = (s32) player->unk_22A; } if (phi_v0_2 >= 2) { phi_s2->unk568 = 2; return; } - phi_s2->unk568 = phi_v0_2; - // Duplicate return node #14. Try simplifying control flow for better match + phi_s2->unk568 = (s16) phi_v0_2; } } #else @@ -3588,16 +3408,17 @@ GLOBAL_ASM("asm/non_matchings/code_80057C60/func_8005DAD8.s") #endif #ifdef MIPS_TO_C -//generated by mips_to_c commit bd0364fa19633bd6201f8007e2d0a7ed87825909 -? func_8005D794(f32, f32, void *, void *, f32, f32, f32, s32, s32); /* extern */ +//generated by mips_to_c commit 792017ad9d422c2467bd42686f383a5c41f41c75 +? func_8005D794(f32, f32, Player *, void *, f32, f32, f32, s32, s32); /* extern */ ? func_8005D7D8(void *, ?, ?); /* extern */ ? func_8005D800(void *, ?, ?); /* extern */ ? func_8005D82C(void *, ?, ?); /* extern */ ? func_8005DAD8(void *, ?, ?, ?); /* extern */ +s16 random_int(u16); /* extern */ +static u16 D_800E483E; /* unable to generate initializer; const */ s16 gCurrentCourseId; /* unable to generate initializer */ -u16 D_800E483E; /* unable to generate initializer; const */ -void func_8005DAF4(void *arg0, s16 arg1, s32 arg2, s32 arg3) { +void func_8005DAF4(Player *player, s32 arg1, s8 arg2, s32 arg3) { s32 sp48; s32 sp44; f32 sp40; @@ -3668,37 +3489,39 @@ void func_8005DAF4(void *arg0, s16 arg1, s32 arg2, s32 arg3) { s16 phi_v1_8; s16 phi_v1_9; s16 phi_v1_10; + s16 phi_t0; s16 phi_v0; void *phi_s2; sp48 = 0xFF; temp_v0 = random_int(D_800E483E); + phi_t0 = (s16) arg1; phi_t1 = 0xFF; if ((temp_v0 == 0) || (temp_v0 == 4)) { sp44 = 1; - sp3C = arg0->unk1D8 + 2.0f; - sp40 = arg0->unk1C8; - sp38 = arg0->unk1D0; - phi_t1 = arg0->unk1D4; + sp3C = player->boundingBoxCorners[2].cornerGroundY + 2.0f; + sp40 = player->boundingBoxCorners[2].cornerX; + sp38 = player->boundingBoxCorners[2].cornerZ; + phi_t1 = (s32) player->boundingBoxCorners[2].surfaceType; } phi_f12 = sp3C; phi_f14 = sp38; phi_f2 = sp40; phi_t3 = sp44; if ((temp_v0 == 2) || (temp_v0 == 6)) { - phi_t1 = arg0->unk1EC; - phi_f12 = arg0->unk1F0 + 2.0f; - phi_f14 = arg0->unk1E8; - phi_f2 = arg0->unk1E0; + phi_t1 = (s32) player->boundingBoxCorners[3].surfaceType; + phi_f12 = player->boundingBoxCorners[3].cornerGroundY + 2.0f; + phi_f14 = player->boundingBoxCorners[3].cornerZ; + phi_f2 = player->boundingBoxCorners[3].cornerX; phi_t3 = 0; } switch (phi_t1) { case 2: - if ((arg1 == 0) && ((temp_v0_2 = arg0 + (arg2 * 0x48), (temp_v0_2->unk546 > 0)) || (temp_v0_2->unk544 == 0))) { - if (((arg0->unk94 / 18.0f) * 216.0f) >= 10.0f) { - temp_s2 = arg0 + (arg1 * 0x48); + if (((s16) arg1 == 0) && ((temp_v0_2 = player + (arg2 * 0x48), ((s32) temp_v0_2->unk546 > 0)) || (temp_v0_2->unk544 == 0))) { + if (((player->unk_094 / 18.0f) * 216.0f) >= 10.0f) { + temp_s2 = player + ((s16) arg1 * 0x48); temp_s0 = temp_s2 + 0x528; - func_8005D794(phi_f12, phi_f14, arg0, temp_s0, phi_f2, phi_f12, phi_f14, phi_t1, phi_t3); + func_8005D794(phi_f12, phi_f14, player, temp_s0, phi_f2, phi_f12, phi_f14, phi_t1, phi_t3); func_8005D7D8(temp_s0, 2, 0x3EEB851F); temp_v1 = gCurrentCourseId; phi_v1 = temp_v1; @@ -3730,13 +3553,13 @@ void func_8005DAF4(void *arg0, s16 arg1, s32 arg2, s32 arg3) { if (phi_v1_5 == 0x12) { func_8005DAD8(temp_s0, 0xB, 0, 0x80); } - phi_v0 = random_int(0x10); + phi_v0 = random_int(0x10U); goto block_105; } - } else if (((arg0 + (arg2 * 0x48))->unk546 > 0) && (((arg0->unk94 / 18.0f) * 216.0f) >= 10.0f)) { - temp_s2_2 = arg0 + (arg1 * 0x48); + } else if (((s32) (player + (arg2 * 0x48))->unk546 > 0) && (((player->unk_094 / 18.0f) * 216.0f) >= 10.0f)) { + temp_s2_2 = player + ((s16) arg1 * 0x48); temp_s0_2 = temp_s2_2 + 0x528; - func_8005D794(phi_f12, phi_f14, arg0, temp_s0_2, phi_f2, phi_f12, phi_f14, phi_t1, phi_t3); + func_8005D794(phi_f12, phi_f14, player, temp_s0_2, phi_f2, phi_f12, phi_f14, phi_t1, phi_t3); func_8005D7D8(temp_s0_2, 2, 0x3EEB851F); temp_v1_2 = gCurrentCourseId; phi_v1_6 = temp_v1_2; @@ -3768,188 +3591,184 @@ void func_8005DAF4(void *arg0, s16 arg1, s32 arg2, s32 arg3) { if (phi_v1_10 == 0x12) { func_8005DAD8(temp_s0_2, 0xB, 0, 0x80); } - phi_v0 = random_int(0x10); + phi_v0 = random_int(0x10U); block_105: phi_s2->unk562 = phi_v0; } default: return; case 8: - if ((arg1 == 0) && ((temp_v0_3 = arg0 + (arg2 * 0x48), (temp_v0_3->unk546 > 0)) || (temp_v0_3->unk544 == 0))) { - if (((arg0->unk94 / 18.0f) * 216.0f) >= 10.0f) { - temp_s2_3 = arg0 + (arg1 * 0x48); + if (((s16) arg1 == 0) && ((temp_v0_3 = player + (arg2 * 0x48), ((s32) temp_v0_3->unk546 > 0)) || (temp_v0_3->unk544 == 0))) { + if (((player->unk_094 / 18.0f) * 216.0f) >= 10.0f) { + temp_s2_3 = player + ((s16) arg1 * 0x48); temp_s0_3 = temp_s2_3 + 0x528; - func_8005D794(phi_f12, phi_f14, arg0, temp_s0_3, phi_f2, phi_f12, phi_f14, phi_t1, phi_t3); + func_8005D794(phi_f12, phi_f14, player, temp_s0_3, phi_f2, phi_f12, phi_f14, phi_t1, phi_t3); func_8005D7D8(temp_s0_3, 3, 0x3F800000); func_8005D800(temp_s0_3, 0xFFFFFF, 0xFF); - temp_v1_3 = arg1 * 8; - temp_s2_3->unk560 = temp_s2_3->unk560 - temp_v1_3; - temp_s2_3->unk562 = temp_s2_3->unk562 - temp_v1_3; - temp_s2_3->unk564 = temp_s2_3->unk564 - temp_v1_3; + temp_v1_3 = (s16) arg1 * 8; + temp_s2_3->unk560 = (s16) (temp_s2_3->unk560 - temp_v1_3); + temp_s2_3->unk562 = (s16) (temp_s2_3->unk562 - temp_v1_3); + temp_s2_3->unk564 = (s16) (temp_s2_3->unk564 - temp_v1_3); + phi_t0 = (s16) arg1; } - } else if (((arg0 + (arg2 * 0x48))->unk546 > 0) && (((arg0->unk94 / 18.0f) * 216.0f) >= 10.0f)) { - temp_s2_4 = arg0 + (arg1 * 0x48); + } else if (((s32) (player + (arg2 * 0x48))->unk546 > 0) && (((player->unk_094 / 18.0f) * 216.0f) >= 10.0f)) { + temp_s2_4 = player + ((s16) arg1 * 0x48); temp_s0_4 = temp_s2_4 + 0x528; - func_8005D794(phi_f12, phi_f14, arg0, temp_s0_4, phi_f2, phi_f12, phi_f14, phi_t1, phi_t3); + func_8005D794(phi_f12, phi_f14, player, temp_s0_4, phi_f2, phi_f12, phi_f14, phi_t1, phi_t3); func_8005D7D8(temp_s0_4, 3, 0x3F800000); func_8005D800(temp_s0_4, 0xFFFFFF, 0xFF); - temp_v1_4 = arg1 * 8; - temp_s2_4->unk560 = temp_s2_4->unk560 - temp_v1_4; - temp_s2_4->unk562 = temp_s2_4->unk562 - temp_v1_4; - temp_s2_4->unk564 = temp_s2_4->unk564 - temp_v1_4; + temp_v1_4 = (s16) arg1 * 8; + temp_s2_4->unk560 = (s16) (temp_s2_4->unk560 - temp_v1_4); + temp_s2_4->unk562 = (s16) (temp_s2_4->unk562 - temp_v1_4); + temp_s2_4->unk564 = (s16) (temp_s2_4->unk564 - temp_v1_4); + phi_t0 = (s16) arg1; } - temp_s2_5 = arg0 + (arg1 * 0x48); - temp_s2_5->unk52C = temp_s2_5->unk52C - 1.5; + temp_s2_5 = player + (phi_t0 * 0x48); + temp_s2_5->unk52C = (f32) ((f64) temp_s2_5->unk52C - 1.5); return; case 7: - if ((arg1 == 0) && ((temp_v0_4 = arg0 + (arg2 * 0x48), (temp_v0_4->unk546 > 0)) || (temp_v0_4->unk544 == 0))) { - if (((arg0->unk94 / 18.0f) * 216.0f) >= 10.0f) { - temp_s2_6 = arg0 + (arg1 * 0x48); + if (((s16) arg1 == 0) && ((temp_v0_4 = player + (arg2 * 0x48), ((s32) temp_v0_4->unk546 > 0)) || (temp_v0_4->unk544 == 0))) { + if (((player->unk_094 / 18.0f) * 216.0f) >= 10.0f) { + temp_s2_6 = player + ((s16) arg1 * 0x48); temp_s0_5 = temp_s2_6 + 0x528; - func_8005D794(phi_f12, phi_f14, arg0, temp_s0_5, phi_f2, phi_f12, phi_f14, phi_t1, phi_t3); + func_8005D794(phi_f12, phi_f14, player, temp_s0_5, phi_f2, phi_f12, phi_f14, phi_t1, phi_t3); func_8005D7D8(temp_s0_5, 2, 0x3EEB851F); func_8005DAD8(temp_s0_5, 2, 1, 0xA8); - phi_v0 = random_int(0x10); + phi_v0 = random_int(0x10U); phi_s2 = temp_s2_6; goto block_105; } - } else if (((arg0 + (arg2 * 0x48))->unk546 > 0) && (((arg0->unk94 / 18.0f) * 216.0f) >= 10.0f)) { - temp_s2_7 = arg0 + (arg1 * 0x48); + } else if (((s32) (player + (arg2 * 0x48))->unk546 > 0) && (((player->unk_094 / 18.0f) * 216.0f) >= 10.0f)) { + temp_s2_7 = player + ((s16) arg1 * 0x48); temp_s0_6 = temp_s2_7 + 0x528; - func_8005D794(phi_f12, phi_f14, arg0, temp_s0_6, phi_f2, phi_f12, phi_f14, phi_t1, phi_t3); + func_8005D794(phi_f12, phi_f14, player, temp_s0_6, phi_f2, phi_f12, phi_f14, phi_t1, phi_t3); func_8005D7D8(temp_s0_6, 2, 0x3EEB851F); func_8005DAD8(temp_s0_6, 2, 1, 0xA8); - phi_v0 = random_int(0x10); + phi_v0 = random_int(0x10U); phi_s2 = temp_s2_7; goto block_105; } - /* Duplicate return node #106. Try simplifying control flow for better match */ - return; + break; case 3: - if ((arg1 == 0) && ((temp_v0_5 = arg0 + (arg2 * 0x48), (temp_v0_5->unk546 > 0)) || (temp_v0_5->unk544 == 0))) { - if (((arg0->unk94 / 18.0f) * 216.0f) >= 10.0f) { - temp_s2_8 = arg0 + (arg1 * 0x48); + if (((s16) arg1 == 0) && ((temp_v0_5 = player + (arg2 * 0x48), ((s32) temp_v0_5->unk546 > 0)) || (temp_v0_5->unk544 == 0))) { + if (((player->unk_094 / 18.0f) * 216.0f) >= 10.0f) { + temp_s2_8 = player + ((s16) arg1 * 0x48); temp_s0_7 = temp_s2_8 + 0x528; - func_8005D794(phi_f12, phi_f14, arg0, temp_s0_7, phi_f2, phi_f12, phi_f14, phi_t1, phi_t3); + func_8005D794(phi_f12, phi_f14, player, temp_s0_7, phi_f2, phi_f12, phi_f14, phi_t1, phi_t3); func_8005D7D8(temp_s0_7, 2, 0x3EEB851F); func_8005DAD8(temp_s0_7, 3, 1, 0xA8); - phi_v0 = random_int(0x10); + phi_v0 = random_int(0x10U); phi_s2 = temp_s2_8; goto block_105; } - } else if (((arg0 + (arg2 * 0x48))->unk546 > 0) && (((arg0->unk94 / 18.0f) * 216.0f) >= 10.0f)) { - temp_s2_9 = arg0 + (arg1 * 0x48); + } else if (((s32) (player + (arg2 * 0x48))->unk546 > 0) && (((player->unk_094 / 18.0f) * 216.0f) >= 10.0f)) { + temp_s2_9 = player + ((s16) arg1 * 0x48); temp_s0_8 = temp_s2_9 + 0x528; - func_8005D794(phi_f12, phi_f14, arg0, temp_s0_8, phi_f2, phi_f12, phi_f14, phi_t1, phi_t3); + func_8005D794(phi_f12, phi_f14, player, temp_s0_8, phi_f2, phi_f12, phi_f14, phi_t1, phi_t3); func_8005D7D8(temp_s0_8, 2, 0x3EEB851F); func_8005DAD8(temp_s0_8, 3, 1, 0xA8); - phi_v0 = random_int(0x10); + phi_v0 = random_int(0x10U); phi_s2 = temp_s2_9; goto block_105; } - /* Duplicate return node #106. Try simplifying control flow for better match */ - return; + break; case 10: - if ((arg1 == 0) && ((temp_v0_6 = arg0 + (arg2 * 0x48), (temp_v0_6->unk546 > 0)) || (temp_v0_6->unk544 == 0))) { - if (((arg0->unk94 / 18.0f) * 216.0f) >= 10.0f) { - temp_s2_10 = arg0 + (arg1 * 0x48); + if (((s16) arg1 == 0) && ((temp_v0_6 = player + (arg2 * 0x48), ((s32) temp_v0_6->unk546 > 0)) || (temp_v0_6->unk544 == 0))) { + if (((player->unk_094 / 18.0f) * 216.0f) >= 10.0f) { + temp_s2_10 = player + ((s16) arg1 * 0x48); temp_s0_9 = temp_s2_10 + 0x528; - func_8005D794(phi_f12, phi_f14, arg0, temp_s0_9, phi_f2, phi_f12, phi_f14, phi_t1, phi_t3); + func_8005D794(phi_f12, phi_f14, player, temp_s0_9, phi_f2, phi_f12, phi_f14, phi_t1, phi_t3); func_8005D7D8(temp_s0_9, 2, 0x3EEB851F); func_8005DAD8(temp_s0_9, 4, 1, 0xA8); - phi_v0 = random_int(0x10); + phi_v0 = random_int(0x10U); phi_s2 = temp_s2_10; goto block_105; } - } else if (((arg0 + (arg2 * 0x48))->unk546 > 0) && (((arg0->unk94 / 18.0f) * 216.0f) >= 10.0f)) { - temp_s2_11 = arg0 + (arg1 * 0x48); + } else if (((s32) (player + (arg2 * 0x48))->unk546 > 0) && (((player->unk_094 / 18.0f) * 216.0f) >= 10.0f)) { + temp_s2_11 = player + ((s16) arg1 * 0x48); temp_s0_10 = temp_s2_11 + 0x528; - func_8005D794(phi_f12, phi_f14, arg0, temp_s0_10, phi_f2, phi_f12, phi_f14, phi_t1, phi_t3); + func_8005D794(phi_f12, phi_f14, player, temp_s0_10, phi_f2, phi_f12, phi_f14, phi_t1, phi_t3); func_8005D7D8(temp_s0_10, 2, 0x3EEB851F); func_8005DAD8(temp_s0_10, 4, 1, 0xA8); - phi_v0 = random_int(0x10); + phi_v0 = random_int(0x10U); phi_s2 = temp_s2_11; goto block_105; } - /* Duplicate return node #106. Try simplifying control flow for better match */ - return; + break; case 13: - if ((arg1 == 0) && ((temp_v0_7 = arg0 + (arg2 * 0x48), (temp_v0_7->unk546 > 0)) || (temp_v0_7->unk544 == 0))) { - if (((arg0->unk94 / 18.0f) * 216.0f) >= 10.0f) { - temp_s2_12 = arg0 + (arg1 * 0x48); + if (((s16) arg1 == 0) && ((temp_v0_7 = player + (arg2 * 0x48), ((s32) temp_v0_7->unk546 > 0)) || (temp_v0_7->unk544 == 0))) { + if (((player->unk_094 / 18.0f) * 216.0f) >= 10.0f) { + temp_s2_12 = player + ((s16) arg1 * 0x48); temp_s0_11 = temp_s2_12 + 0x528; - func_8005D794(phi_f12, phi_f14, arg0, temp_s0_11, phi_f2, phi_f12, phi_f14, phi_t1, phi_t3); + func_8005D794(phi_f12, phi_f14, player, temp_s0_11, phi_f2, phi_f12, phi_f14, phi_t1, phi_t3); func_8005D7D8(temp_s0_11, 2, 0x3EEB851F); func_8005DAD8(temp_s0_11, 5, 1, 0xA8); - phi_v0 = random_int(0x10); + phi_v0 = random_int(0x10U); phi_s2 = temp_s2_12; goto block_105; } - } else if (((arg0 + (arg2 * 0x48))->unk546 > 0) && (((arg0->unk94 / 18.0f) * 216.0f) >= 10.0f)) { - temp_s2_13 = arg0 + (arg1 * 0x48); + } else if (((s32) (player + (arg2 * 0x48))->unk546 > 0) && (((player->unk_094 / 18.0f) * 216.0f) >= 10.0f)) { + temp_s2_13 = player + ((s16) arg1 * 0x48); temp_s0_12 = temp_s2_13 + 0x528; - func_8005D794(phi_f12, phi_f14, arg0, temp_s0_12, phi_f2, phi_f12, phi_f14, phi_t1, phi_t3); + func_8005D794(phi_f12, phi_f14, player, temp_s0_12, phi_f2, phi_f12, phi_f14, phi_t1, phi_t3); func_8005D7D8(temp_s0_12, 2, 0x3EEB851F); func_8005D82C(temp_s0_12, 0xFFA54F, 0xAF); func_8005DAD8(temp_s0_12, 5, 1, 0xA8); - phi_v0 = random_int(0x10); + phi_v0 = random_int(0x10U); phi_s2 = temp_s2_13; goto block_105; } - /* Duplicate return node #106. Try simplifying control flow for better match */ - return; + break; case 5: case 11: - if ((arg1 == 0) && ((temp_v0_8 = arg0 + (arg2 * 0x48), (temp_v0_8->unk546 > 0)) || (temp_v0_8->unk544 == 0))) { - if (((arg0->unk94 / 18.0f) * 216.0f) >= 10.0f) { - temp_s2_14 = arg0 + (arg1 * 0x48); + if (((s16) arg1 == 0) && ((temp_v0_8 = player + (arg2 * 0x48), ((s32) temp_v0_8->unk546 > 0)) || (temp_v0_8->unk544 == 0))) { + if (((player->unk_094 / 18.0f) * 216.0f) >= 10.0f) { + temp_s2_14 = player + ((s16) arg1 * 0x48); temp_s0_13 = temp_s2_14 + 0x528; - func_8005D794(phi_f12, phi_f14, arg0, temp_s0_13, phi_f2, phi_f12, phi_f14, phi_t1, phi_t3); + func_8005D794(phi_f12, phi_f14, player, temp_s0_13, phi_f2, phi_f12, phi_f14, phi_t1, phi_t3); func_8005D7D8(temp_s0_13, 2, 0x3EEB851F); func_8005DAD8(temp_s0_13, 6, 1, 0xA8); - phi_v0 = random_int(0x10); + phi_v0 = random_int(0x10U); phi_s2 = temp_s2_14; goto block_105; } - } else if (((arg0 + (arg2 * 0x48))->unk546 > 0) && (((arg0->unk94 / 18.0f) * 216.0f) >= 10.0f)) { - temp_s2_15 = arg0 + (arg1 * 0x48); + } else if (((s32) (player + (arg2 * 0x48))->unk546 > 0) && (((player->unk_094 / 18.0f) * 216.0f) >= 10.0f)) { + temp_s2_15 = player + ((s16) arg1 * 0x48); temp_s0_14 = temp_s2_15 + 0x528; - func_8005D794(phi_f12, phi_f14, arg0, temp_s0_14, phi_f2, phi_f12, phi_f14, phi_t1, phi_t3); + func_8005D794(phi_f12, phi_f14, player, temp_s0_14, phi_f2, phi_f12, phi_f14, phi_t1, phi_t3); func_8005D7D8(temp_s0_14, 2, 0x3EEB851F); func_8005DAD8(temp_s0_14, 6, 1, 0xA8); - phi_v0 = random_int(0x10); + phi_v0 = random_int(0x10U); phi_s2 = temp_s2_15; goto block_105; } - /* Duplicate return node #106. Try simplifying control flow for better match */ - return; + break; case 1: case 4: case 6: - if ((arg1 == 0) && ((temp_v0_9 = arg0 + (arg2 * 0x48), (temp_v0_9->unk546 > 0)) || (temp_v0_9->unk544 == 0))) { - temp_f0 = arg0->unk94; - if (((((temp_f0 / 18.0f) * 216.0f) >= 30.0f) && ((temp_lo = arg0->unkC0 / 182, ((temp_lo < 0x15) == 0)) || (temp_lo < -0x14))) || ((arg0->unk22C - temp_f0) >= 0.04)) { - temp_s2_16 = arg0 + (arg1 * 0x48); + if (((s16) arg1 == 0) && ((temp_v0_9 = player + (arg2 * 0x48), ((s32) temp_v0_9->unk546 > 0)) || (temp_v0_9->unk544 == 0))) { + temp_f0 = player->unk_094; + if (((((temp_f0 / 18.0f) * 216.0f) >= 30.0f) && ((temp_lo = (s32) player->unk_0C0 / 182, ((temp_lo < 0x15) == 0)) || (temp_lo < -0x14))) || ((f64) (player->unk_22C - temp_f0) >= 0.04)) { + temp_s2_16 = player + ((s16) arg1 * 0x48); temp_s0_15 = temp_s2_16 + 0x528; - func_8005D794(phi_f12, phi_f14, arg0, temp_s0_15, phi_f2, phi_f12, phi_f14, phi_t1, phi_t3); + func_8005D794(phi_f12, phi_f14, player, temp_s0_15, phi_f2, phi_f12, phi_f14, phi_t1, phi_t3); func_8005D7D8(temp_s0_15, 2, 0x3EEB851F); func_8005DAD8(temp_s0_15, 0, 0, 0x80); - phi_v0 = random_int(0x10); + phi_v0 = random_int(0x10U); phi_s2 = temp_s2_16; goto block_105; } - } else if (((arg0 + (arg2 * 0x48))->unk546 > 0) && (((temp_f0_2 = arg0->unk94, (((temp_f0_2 / 18.0f) * 216.0f) >= 30.0f)) && ((temp_lo_2 = arg0->unkC0 / 182, ((temp_lo_2 < 0x15) == 0)) || (temp_lo_2 < -0x14))) || ((arg0->unk22C - temp_f0_2) >= 0.04))) { - temp_s2_17 = arg0 + (arg1 * 0x48); + } else if (((s32) (player + (arg2 * 0x48))->unk546 > 0) && (((temp_f0_2 = player->unk_094, (((temp_f0_2 / 18.0f) * 216.0f) >= 30.0f)) && ((temp_lo_2 = (s32) player->unk_0C0 / 182, ((temp_lo_2 < 0x15) == 0)) || (temp_lo_2 < -0x14))) || ((f64) (player->unk_22C - temp_f0_2) >= 0.04))) { + temp_s2_17 = player + ((s16) arg1 * 0x48); temp_s0_16 = temp_s2_17 + 0x528; - func_8005D794(phi_f12, phi_f14, arg0, temp_s0_16, phi_f2, phi_f12, phi_f14, phi_t1, phi_t3); + func_8005D794(phi_f12, phi_f14, player, temp_s0_16, phi_f2, phi_f12, phi_f14, phi_t1, phi_t3); func_8005D7D8(temp_s0_16, 2, 0x3EEB851F); func_8005DAD8(temp_s0_16, 0, 0, 0x80); - phi_v0 = random_int(0x10); + phi_v0 = random_int(0x10U); phi_s2 = temp_s2_17; goto block_105; } - /* Duplicate return node #106. Try simplifying control flow for better match */ - return; + break; } } #else @@ -3957,13 +3776,14 @@ GLOBAL_ASM("asm/non_matchings/code_80057C60/func_8005DAF4.s") #endif #ifdef MIPS_TO_C -//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307 -? func_8005D794(f32, f32, void *, void *, f32, f32, f32, s32, s32); // extern -? func_8005D7D8(void *, ?, ?); // extern -? func_8005D800(void *, ?, ?); // extern -extern u16 D_800E4842; +//generated by mips_to_c commit 792017ad9d422c2467bd42686f383a5c41f41c75 +? func_8005D794(f32, f32, Player *, void *, f32, f32, f32, s32, s32); /* extern */ +? func_8005D7D8(void *, ?, ?); /* extern */ +? func_8005D800(void *, ?, ?); /* extern */ +s32 random_int(u16); /* extern */ +static u16 D_800E4842; /* unable to generate initializer; const */ -void func_8005EA94(void *arg0, s16 arg1, s32 arg2, s8 arg3) { +void func_8005EA94(Player *player, s16 arg1, s32 arg2, s8 arg3) { s32 sp48; s32 sp44; f32 sp40; @@ -3986,12 +3806,12 @@ void func_8005EA94(void *arg0, s16 arg1, s32 arg2, s8 arg3) { temp_v0 = random_int(D_800E4842); phi_t0 = 0xFF; if ((temp_v0 == 0) || (temp_v0 == 8)) { - temp_f0 = arg0->unk1D8; - if ((D_801652A0[arg3] - temp_f0) >= 3.5) { + temp_f0 = player->boundingBoxCorners[2].cornerGroundY; + if ((f64) (D_801652A0[arg3] - temp_f0) >= 3.5) { sp44 = 1; - sp40 = arg0->unk1C8; + sp40 = player->boundingBoxCorners[2].cornerX; sp3C = temp_f0 + 2.0f; - sp38 = arg0->unk1D0; + sp38 = player->boundingBoxCorners[2].cornerZ; phi_t0 = 0; } } @@ -4000,36 +3820,31 @@ void func_8005EA94(void *arg0, s16 arg1, s32 arg2, s8 arg3) { phi_f2 = sp40; phi_t1 = sp44; if ((temp_v0 == 2) || (temp_v0 == 6)) { - temp_f0_2 = arg0->unk1F0; - if ((D_801652A0[arg3] - temp_f0_2) >= 3.5) { + temp_f0_2 = player->boundingBoxCorners[3].cornerGroundY; + if ((f64) (D_801652A0[arg3] - temp_f0_2) >= 3.5) { phi_t0 = 0; phi_f12 = temp_f0_2 + 2.0f; - phi_f14 = arg0->unk1E8; - phi_f2 = arg0->unk1E0; + phi_f14 = player->boundingBoxCorners[3].cornerZ; + phi_f2 = player->boundingBoxCorners[3].cornerX; phi_t1 = 0; } } if (phi_t0 == 0) { - if ((arg1 == 0) && ((temp_v0_2 = arg0 + (arg2 * 0x48), (temp_v0_2->unk546 > 0)) || (temp_v0_2->unk544 == 0))) { - if (((arg0->unk94 / 18.0f) * 216.0f) >= 10.0f) { - temp_a1 = arg0 + (arg1 * 0x48) + 0x528; + if ((arg1 == 0) && ((temp_v0_2 = player + (arg2 * 0x48), ((s32) temp_v0_2->unk546 > 0)) || (temp_v0_2->unk544 == 0))) { + if (((player->unk_094 / 18.0f) * 216.0f) >= 10.0f) { + temp_a1 = player + (arg1 * 0x48) + 0x528; sp34 = temp_a1; - func_8005D794(phi_f12, phi_f14, arg0, temp_a1, phi_f2, phi_f12, phi_f14, phi_t0, phi_t1); + func_8005D794(phi_f12, phi_f14, player, temp_a1, phi_f2, phi_f12, phi_f14, phi_t0, phi_t1); func_8005D7D8(sp34, 9, 0x3F4CCCCD); func_8005D800(sp34, 0xFFFFFF, 0xAF); - return; } - // Duplicate return node #17. Try simplifying control flow for better match - return; - } - if (((arg0 + (arg2 * 0x48))->unk546 > 0) && (((arg0->unk94 / 18.0f) * 216.0f) >= 10.0f)) { - temp_a1_2 = arg0 + (arg1 * 0x48) + 0x528; + } else if (((s32) (player + (arg2 * 0x48))->unk546 > 0) && (((player->unk_094 / 18.0f) * 216.0f) >= 10.0f)) { + temp_a1_2 = player + (arg1 * 0x48) + 0x528; sp34 = temp_a1_2; - func_8005D794(phi_f12, phi_f14, arg0, temp_a1_2, phi_f2, phi_f12, phi_f14, phi_t0, phi_t1); + func_8005D794(phi_f12, phi_f14, player, temp_a1_2, phi_f2, phi_f12, phi_f14, phi_t0, phi_t1); func_8005D7D8(sp34, 9, 0x3F4CCCCD); func_8005D800(sp34, 0xFFFFFF, 0xAF); } - // Duplicate return node #17. Try simplifying control flow for better match } } #else @@ -4037,15 +3852,16 @@ GLOBAL_ASM("asm/non_matchings/code_80057C60/func_8005EA94.s") #endif #ifdef MIPS_TO_C -//generated by mips_to_c commit bd0364fa19633bd6201f8007e2d0a7ed87825909 -? func_8005D794(f32, void *, void *, f32, f32, f32, s32, s32); /* extern */ +//generated by mips_to_c commit 792017ad9d422c2467bd42686f383a5c41f41c75 +? func_8005D794(f32, Player *, void *, f32, f32, f32, s32, s32); /* extern */ ? func_8005D7D8(void *, ?, ?); /* extern */ ? func_8005D800(void *, ?, ?); /* extern */ ? func_8005DAD8(void *, ?, ?, ?); /* extern */ +s16 random_int(u16); /* extern */ +static u16 D_800E4846; /* unable to generate initializer; const */ s16 gCurrentCourseId; /* unable to generate initializer */ -u16 D_800E4846; /* unable to generate initializer; const */ -void func_8005ED48(void *arg0, s16 arg1, s32 arg2, s32 arg3) { +void func_8005ED48(Player *player, s16 arg1, s32 arg2, s32 arg3) { s32 sp48; s32 sp44; f32 sp40; @@ -4120,28 +3936,28 @@ void func_8005ED48(void *arg0, s16 arg1, s32 arg2, s32 arg3) { phi_t2 = 0xFF; if ((temp_v0 == 2) || (temp_v0 == 4)) { sp44 = 1; - sp3C = arg0->unk1D8 + 2.0f; - sp40 = arg0->unk1C8; - sp38 = arg0->unk1D0; - phi_t2 = arg0->unk1D4; + sp3C = player->boundingBoxCorners[2].cornerGroundY + 2.0f; + sp40 = player->boundingBoxCorners[2].cornerX; + sp38 = player->boundingBoxCorners[2].cornerZ; + phi_t2 = (s32) player->boundingBoxCorners[2].surfaceType; } phi_f12 = sp38; phi_f0 = sp40; phi_f2 = sp3C; phi_t3 = sp44; if ((temp_v0 == 0) || (temp_v0 == 6)) { - phi_t2 = arg0->unk1EC; - phi_f12 = arg0->unk1E8; - phi_f0 = arg0->unk1E0; - phi_f2 = arg0->unk1F0 + 2.0f; + phi_t2 = (s32) player->boundingBoxCorners[3].surfaceType; + phi_f12 = player->boundingBoxCorners[3].cornerZ; + phi_f0 = player->boundingBoxCorners[3].cornerX; + phi_f2 = player->boundingBoxCorners[3].cornerGroundY + 2.0f; phi_t3 = 0; } switch (phi_t2) { case 2: - if ((arg1 == 0) && ((temp_v0_2 = arg0 + (arg2 * 0x48), (temp_v0_2->unk546 > 0)) || (temp_v0_2->unk544 == 0))) { - temp_s2 = arg0 + (arg1 * 0x48); + if ((arg1 == 0) && ((temp_v0_2 = player + (arg2 * 0x48), ((s32) temp_v0_2->unk546 > 0)) || (temp_v0_2->unk544 == 0))) { + temp_s2 = player + (arg1 * 0x48); temp_s0 = temp_s2 + 0x528; - func_8005D794(phi_f12, arg0, temp_s0, phi_f0, phi_f2, phi_f12, phi_t2, phi_t3); + func_8005D794(phi_f12, player, temp_s0, phi_f0, phi_f2, phi_f12, phi_t2, phi_t3); func_8005D7D8(temp_s0, 5, 0x3EEB851F); temp_v1 = gCurrentCourseId; phi_v1 = temp_v1; @@ -4173,13 +3989,13 @@ void func_8005ED48(void *arg0, s16 arg1, s32 arg2, s32 arg3) { if (phi_v1_5 == 0x12) { func_8005DAD8(temp_s0, 0xB, 0, 0x80); } - phi_v0 = random_int(0x10); + phi_v0 = random_int(0x10U); goto block_83; } - if ((arg0 + (arg2 * 0x48))->unk546 > 0) { - temp_s2_2 = arg0 + (arg1 * 0x48); + if ((s32) (player + (arg2 * 0x48))->unk546 > 0) { + temp_s2_2 = player + (arg1 * 0x48); temp_s0_2 = temp_s2_2 + 0x528; - func_8005D794(phi_f12, arg0, temp_s0_2, phi_f0, phi_f2, phi_f12, phi_t2, phi_t3); + func_8005D794(phi_f12, player, temp_s0_2, phi_f0, phi_f2, phi_f12, phi_t2, phi_t3); func_8005D7D8(temp_s0_2, 5, 0x3EEB851F); temp_v1_2 = gCurrentCourseId; phi_v1_6 = temp_v1_2; @@ -4211,178 +4027,172 @@ void func_8005ED48(void *arg0, s16 arg1, s32 arg2, s32 arg3) { if (phi_v1_10 == 0x12) { func_8005DAD8(temp_s0_2, 0xB, 0, 0x80); } - phi_v0 = random_int(0x10); + phi_v0 = random_int(0x10U); block_83: phi_s2->unk562 = phi_v0; } default: return; case 8: - if ((arg1 == 0) && ((temp_v0_3 = arg0 + (arg2 * 0x48), (temp_v0_3->unk546 > 0)) || (temp_v0_3->unk544 == 0))) { - temp_s2_3 = arg0 + (arg1 * 0x48); + if ((arg1 == 0) && ((temp_v0_3 = player + (arg2 * 0x48), ((s32) temp_v0_3->unk546 > 0)) || (temp_v0_3->unk544 == 0))) { + temp_s2_3 = player + (arg1 * 0x48); temp_s0_3 = temp_s2_3 + 0x528; - func_8005D794(phi_f12, arg0, temp_s0_3, phi_f0, phi_f2, phi_f12, phi_t2, phi_t3); + func_8005D794(phi_f12, player, temp_s0_3, phi_f0, phi_f2, phi_f12, phi_t2, phi_t3); func_8005D7D8(temp_s0_3, 5, 0x3DCCCCCD); func_8005D800(temp_s0_3, 0xFFFFFF, 0xFF); temp_v1_3 = arg1 * 8; - temp_s2_3->unk560 = temp_s2_3->unk560 - temp_v1_3; - temp_s2_3->unk562 = temp_s2_3->unk562 - temp_v1_3; - temp_s2_3->unk564 = temp_s2_3->unk564 - temp_v1_3; - } else if ((arg0 + (arg2 * 0x48))->unk546 > 0) { - temp_s2_4 = arg0 + (arg1 * 0x48); + temp_s2_3->unk560 = (s16) (temp_s2_3->unk560 - temp_v1_3); + temp_s2_3->unk562 = (s16) (temp_s2_3->unk562 - temp_v1_3); + temp_s2_3->unk564 = (s16) (temp_s2_3->unk564 - temp_v1_3); + } else if ((s32) (player + (arg2 * 0x48))->unk546 > 0) { + temp_s2_4 = player + (arg1 * 0x48); temp_s0_4 = temp_s2_4 + 0x528; - func_8005D794(phi_f12, arg0, temp_s0_4, phi_f0, phi_f2, phi_f12, phi_t2, phi_t3); + func_8005D794(phi_f12, player, temp_s0_4, phi_f0, phi_f2, phi_f12, phi_t2, phi_t3); func_8005D7D8(temp_s0_4, 5, 0x3DCCCCCD); func_8005D800(temp_s0_4, 0xFFFFFF, 0xFF); temp_v1_4 = arg1 * 8; - temp_s2_4->unk560 = temp_s2_4->unk560 - temp_v1_4; - temp_s2_4->unk562 = temp_s2_4->unk562 - temp_v1_4; - temp_s2_4->unk564 = temp_s2_4->unk564 - temp_v1_4; + temp_s2_4->unk560 = (s16) (temp_s2_4->unk560 - temp_v1_4); + temp_s2_4->unk562 = (s16) (temp_s2_4->unk562 - temp_v1_4); + temp_s2_4->unk564 = (s16) (temp_s2_4->unk564 - temp_v1_4); } - temp_s2_5 = arg0 + (arg1 * 0x48); - temp_s2_5->unk52C = temp_s2_5->unk52C - 1.5; + temp_s2_5 = player + (arg1 * 0x48); + temp_s2_5->unk52C = (f32) ((f64) temp_s2_5->unk52C - 1.5); return; case 7: - if ((arg1 == 0) && ((temp_v0_4 = arg0 + (arg2 * 0x48), (temp_v0_4->unk546 > 0)) || (temp_v0_4->unk544 == 0))) { - temp_s2_6 = arg0 + (arg1 * 0x48); + if ((arg1 == 0) && ((temp_v0_4 = player + (arg2 * 0x48), ((s32) temp_v0_4->unk546 > 0)) || (temp_v0_4->unk544 == 0))) { + temp_s2_6 = player + (arg1 * 0x48); temp_s0_5 = temp_s2_6 + 0x528; - func_8005D794(phi_f12, arg0, temp_s0_5, phi_f0, phi_f2, phi_f12, phi_t2, phi_t3); + func_8005D794(phi_f12, player, temp_s0_5, phi_f0, phi_f2, phi_f12, phi_t2, phi_t3); func_8005D7D8(temp_s0_5, 5, 0x3EEB851F); func_8005DAD8(temp_s0_5, 2, 1, 0xA8); - phi_v0 = random_int(0x10); + phi_v0 = random_int(0x10U); phi_s2 = temp_s2_6; goto block_83; } - if ((arg0 + (arg2 * 0x48))->unk546 > 0) { - temp_s2_7 = arg0 + (arg1 * 0x48); + if ((s32) (player + (arg2 * 0x48))->unk546 > 0) { + temp_s2_7 = player + (arg1 * 0x48); temp_s0_6 = temp_s2_7 + 0x528; - func_8005D794(phi_f12, arg0, temp_s0_6, phi_f0, phi_f2, phi_f12, phi_t2, phi_t3); + func_8005D794(phi_f12, player, temp_s0_6, phi_f0, phi_f2, phi_f12, phi_t2, phi_t3); func_8005D7D8(temp_s0_6, 5, 0x3EEB851F); func_8005DAD8(temp_s0_6, 2, 1, 0xA8); - phi_v0 = random_int(0x10); + phi_v0 = random_int(0x10U); phi_s2 = temp_s2_7; goto block_83; } - /* Duplicate return node #84. Try simplifying control flow for better match */ - return; + break; case 3: - if ((arg1 == 0) && ((temp_v0_5 = arg0 + (arg2 * 0x48), (temp_v0_5->unk546 > 0)) || (temp_v0_5->unk544 == 0))) { - temp_s2_8 = arg0 + (arg1 * 0x48); + if ((arg1 == 0) && ((temp_v0_5 = player + (arg2 * 0x48), ((s32) temp_v0_5->unk546 > 0)) || (temp_v0_5->unk544 == 0))) { + temp_s2_8 = player + (arg1 * 0x48); temp_s0_7 = temp_s2_8 + 0x528; - func_8005D794(phi_f12, arg0, temp_s0_7, phi_f0, phi_f2, phi_f12, phi_t2, phi_t3); + func_8005D794(phi_f12, player, temp_s0_7, phi_f0, phi_f2, phi_f12, phi_t2, phi_t3); func_8005D7D8(temp_s0_7, 5, 0x3EEB851F); func_8005DAD8(temp_s0_7, 3, 1, 0xA8); - phi_v0 = random_int(0x10); + phi_v0 = random_int(0x10U); phi_s2 = temp_s2_8; goto block_83; } - if ((arg0 + (arg2 * 0x48))->unk546 > 0) { - temp_s2_9 = arg0 + (arg1 * 0x48); + if ((s32) (player + (arg2 * 0x48))->unk546 > 0) { + temp_s2_9 = player + (arg1 * 0x48); temp_s0_8 = temp_s2_9 + 0x528; - func_8005D794(phi_f12, arg0, temp_s0_8, phi_f0, phi_f2, phi_f12, phi_t2, phi_t3); + func_8005D794(phi_f12, player, temp_s0_8, phi_f0, phi_f2, phi_f12, phi_t2, phi_t3); func_8005D7D8(temp_s0_8, 5, 0x3EEB851F); func_8005DAD8(temp_s0_8, 3, 1, 0xA8); - phi_v0 = random_int(0x10); + phi_v0 = random_int(0x10U); phi_s2 = temp_s2_9; goto block_83; } - /* Duplicate return node #84. Try simplifying control flow for better match */ - return; + break; case 10: - if ((arg1 == 0) && ((temp_v0_6 = arg0 + (arg2 * 0x48), (temp_v0_6->unk546 > 0)) || (temp_v0_6->unk544 == 0))) { - temp_s2_10 = arg0 + (arg1 * 0x48); + if ((arg1 == 0) && ((temp_v0_6 = player + (arg2 * 0x48), ((s32) temp_v0_6->unk546 > 0)) || (temp_v0_6->unk544 == 0))) { + temp_s2_10 = player + (arg1 * 0x48); temp_s0_9 = temp_s2_10 + 0x528; - func_8005D794(phi_f12, arg0, temp_s0_9, phi_f0, phi_f2, phi_f12, phi_t2, phi_t3); + func_8005D794(phi_f12, player, temp_s0_9, phi_f0, phi_f2, phi_f12, phi_t2, phi_t3); func_8005D7D8(temp_s0_9, 5, 0x3EEB851F); func_8005DAD8(temp_s0_9, 4, 1, 0xA8); - phi_v0 = random_int(0x10); + phi_v0 = random_int(0x10U); phi_s2 = temp_s2_10; goto block_83; } - if ((arg0 + (arg2 * 0x48))->unk546 > 0) { - temp_s2_11 = arg0 + (arg1 * 0x48); + if ((s32) (player + (arg2 * 0x48))->unk546 > 0) { + temp_s2_11 = player + (arg1 * 0x48); temp_s0_10 = temp_s2_11 + 0x528; - func_8005D794(phi_f12, arg0, temp_s0_10, phi_f0, phi_f2, phi_f12, phi_t2, phi_t3); + func_8005D794(phi_f12, player, temp_s0_10, phi_f0, phi_f2, phi_f12, phi_t2, phi_t3); func_8005D7D8(temp_s0_10, 5, 0x3EEB851F); func_8005DAD8(temp_s0_10, 4, 1, 0xA8); - phi_v0 = random_int(0x10); + phi_v0 = random_int(0x10U); phi_s2 = temp_s2_11; goto block_83; } - /* Duplicate return node #84. Try simplifying control flow for better match */ - return; + break; case 13: - if ((arg1 == 0) && ((temp_v0_7 = arg0 + (arg2 * 0x48), (temp_v0_7->unk546 > 0)) || (temp_v0_7->unk544 == 0))) { - temp_s2_12 = arg0 + (arg1 * 0x48); + if ((arg1 == 0) && ((temp_v0_7 = player + (arg2 * 0x48), ((s32) temp_v0_7->unk546 > 0)) || (temp_v0_7->unk544 == 0))) { + temp_s2_12 = player + (arg1 * 0x48); temp_s0_11 = temp_s2_12 + 0x528; - func_8005D794(phi_f12, arg0, temp_s0_11, phi_f0, phi_f2, phi_f12, phi_t2, phi_t3); + func_8005D794(phi_f12, player, temp_s0_11, phi_f0, phi_f2, phi_f12, phi_t2, phi_t3); func_8005D7D8(temp_s0_11, 5, 0x3EEB851F); func_8005DAD8(temp_s0_11, 5, 1, 0xA8); - phi_v0 = random_int(0x10); + phi_v0 = random_int(0x10U); phi_s2 = temp_s2_12; goto block_83; } - if ((arg0 + (arg2 * 0x48))->unk546 > 0) { - temp_s2_13 = arg0 + (arg1 * 0x48); + if ((s32) (player + (arg2 * 0x48))->unk546 > 0) { + temp_s2_13 = player + (arg1 * 0x48); temp_s0_12 = temp_s2_13 + 0x528; - func_8005D794(phi_f12, arg0, temp_s0_12, phi_f0, phi_f2, phi_f12, phi_t2, phi_t3); + func_8005D794(phi_f12, player, temp_s0_12, phi_f0, phi_f2, phi_f12, phi_t2, phi_t3); func_8005D7D8(temp_s0_12, 5, 0x3EEB851F); func_8005DAD8(temp_s0_12, 5, 1, 0xA8); - phi_v0 = random_int(0x10); + phi_v0 = random_int(0x10U); phi_s2 = temp_s2_13; goto block_83; } - /* Duplicate return node #84. Try simplifying control flow for better match */ - return; + break; case 5: case 11: - if ((arg1 == 0) && ((temp_v0_8 = arg0 + (arg2 * 0x48), (temp_v0_8->unk546 > 0)) || (temp_v0_8->unk544 == 0))) { - temp_s2_14 = arg0 + (arg1 * 0x48); + if ((arg1 == 0) && ((temp_v0_8 = player + (arg2 * 0x48), ((s32) temp_v0_8->unk546 > 0)) || (temp_v0_8->unk544 == 0))) { + temp_s2_14 = player + (arg1 * 0x48); temp_s0_13 = temp_s2_14 + 0x528; - func_8005D794(phi_f12, arg0, temp_s0_13, phi_f0, phi_f2, phi_f12, phi_t2, phi_t3); + func_8005D794(phi_f12, player, temp_s0_13, phi_f0, phi_f2, phi_f12, phi_t2, phi_t3); func_8005D7D8(temp_s0_13, 5, 0x3EEB851F); func_8005DAD8(temp_s0_13, 6, 1, 0xA8); - phi_v0 = random_int(0x10); + phi_v0 = random_int(0x10U); phi_s2 = temp_s2_14; goto block_83; } - if ((arg0 + (arg2 * 0x48))->unk546 > 0) { - temp_s2_15 = arg0 + (arg1 * 0x48); + if ((s32) (player + (arg2 * 0x48))->unk546 > 0) { + temp_s2_15 = player + (arg1 * 0x48); temp_s0_14 = temp_s2_15 + 0x528; - func_8005D794(phi_f12, arg0, temp_s0_14, phi_f0, phi_f2, phi_f12, phi_t2, phi_t3); + func_8005D794(phi_f12, player, temp_s0_14, phi_f0, phi_f2, phi_f12, phi_t2, phi_t3); func_8005D7D8(temp_s0_14, 5, 0x3EEB851F); func_8005DAD8(temp_s0_14, 6, 1, 0xA8); - phi_v0 = random_int(0x10); + phi_v0 = random_int(0x10U); phi_s2 = temp_s2_15; goto block_83; } - /* Duplicate return node #84. Try simplifying control flow for better match */ - return; + break; case 1: case 4: case 6: - if ((arg1 == 0) && ((temp_v0_9 = arg0 + (arg2 * 0x48), (temp_v0_9->unk546 > 0)) || (temp_v0_9->unk544 == 0))) { - temp_s2_16 = arg0 + (arg1 * 0x48); + if ((arg1 == 0) && ((temp_v0_9 = player + (arg2 * 0x48), ((s32) temp_v0_9->unk546 > 0)) || (temp_v0_9->unk544 == 0))) { + temp_s2_16 = player + (arg1 * 0x48); temp_s0_15 = temp_s2_16 + 0x528; - func_8005D794(phi_f12, arg0, temp_s0_15, phi_f0, phi_f2, phi_f12, phi_t2, phi_t3); + func_8005D794(phi_f12, player, temp_s0_15, phi_f0, phi_f2, phi_f12, phi_t2, phi_t3); func_8005D7D8(temp_s0_15, 5, 0x3EEB851F); func_8005DAD8(temp_s0_15, 0, 0, 0x80); - phi_v0 = random_int(0x10); + phi_v0 = random_int(0x10U); phi_s2 = temp_s2_16; goto block_83; } - if ((arg0 + (arg2 * 0x48))->unk546 > 0) { - temp_s2_17 = arg0 + (arg1 * 0x48); + if ((s32) (player + (arg2 * 0x48))->unk546 > 0) { + temp_s2_17 = player + (arg1 * 0x48); temp_s0_16 = temp_s2_17 + 0x528; - func_8005D794(phi_f12, arg0, temp_s0_16, phi_f0, phi_f2, phi_f12, phi_t2, phi_t3); + func_8005D794(phi_f12, player, temp_s0_16, phi_f0, phi_f2, phi_f12, phi_t2, phi_t3); func_8005D7D8(temp_s0_16, 5, 0x3EEB851F); func_8005DAD8(temp_s0_16, 0, 0, 0x80); - phi_v0 = random_int(0x10); + phi_v0 = random_int(0x10U); phi_s2 = temp_s2_17; goto block_83; } - /* Duplicate return node #84. Try simplifying control flow for better match */ - return; + break; } } #else @@ -4390,15 +4200,15 @@ GLOBAL_ASM("asm/non_matchings/code_80057C60/func_8005ED48.s") #endif #ifdef MIPS_TO_C -//generated by mips_to_c commit bd0364fa19633bd6201f8007e2d0a7ed87825909 -? func_8005D794(f32, void *, void *, f32, f32, f32, s32, s32); /* extern */ +//generated by mips_to_c commit 792017ad9d422c2467bd42686f383a5c41f41c75 +? func_8005D794(f32, Player *, void *, f32, f32, f32, s32, s32); /* extern */ ? func_8005D7D8(void *, ?, ?); /* extern */ ? func_8005D800(void *, ?, ?); /* extern */ ? func_8005DAD8(void *, ?, ?, ?); /* extern */ s16 random_int(?); /* extern */ s16 gCurrentCourseId; /* unable to generate initializer */ -void func_8005F90C(void *arg0, s16 arg1, s32 arg2, s32 arg3) { +void func_8005F90C(Player *player, s16 arg1, s32 arg2, s32 arg3) { s16 temp_v1; s16 temp_v1_2; s32 temp_t2; @@ -4463,24 +4273,24 @@ void func_8005F90C(void *arg0, s16 arg1, s32 arg2, s32 arg3) { void *phi_s2; phi_t1 = 0; - if ((arg0->unkBC & 0x80) == 0x80) { - phi_v0 = arg0->unk1D4; - phi_f12 = arg0->unk1C; - phi_f0 = arg0->unk14; - phi_f2 = arg0->unk18 - arg0->unk70; + if ((player->unk_0BC & 0x80) == 0x80) { + phi_v0 = (s32) player->boundingBoxCorners[2].surfaceType; + phi_f12 = player->posZ; + phi_f0 = player->posX; + phi_f2 = player->posY - player->unk_070; phi_t1 = 1; } else { - phi_v0 = arg0->unk1EC; - phi_f12 = arg0->unk1C; - phi_f0 = arg0->unk14; - phi_f2 = arg0->unk18 - arg0->unk70; + phi_v0 = (s32) player->boundingBoxCorners[3].surfaceType; + phi_f12 = player->posZ; + phi_f0 = player->posX; + phi_f2 = player->posY - player->unk_070; } switch (phi_v0) { case 2: - if ((arg1 == 0) && ((temp_v0 = arg0 + (arg2 * 0x48), (temp_v0->unk546 > 0)) || (temp_v0->unk544 == 0))) { - temp_s2 = arg0 + (arg1 * 0x48); + if ((arg1 == 0) && ((temp_v0 = player + (arg2 * 0x48), ((s32) temp_v0->unk546 > 0)) || (temp_v0->unk544 == 0))) { + temp_s2 = player + (arg1 * 0x48); temp_s0 = temp_s2 + 0x528; - func_8005D794(phi_f12, arg0, temp_s0, phi_f0, phi_f2, phi_f12, phi_v0, phi_t1); + func_8005D794(phi_f12, player, temp_s0, phi_f0, phi_f2, phi_f12, phi_v0, phi_t1); func_8005D7D8(temp_s0, 4, 0x3EEB851F); temp_v1 = gCurrentCourseId; phi_v1 = temp_v1; @@ -4515,10 +4325,10 @@ void func_8005F90C(void *arg0, s16 arg1, s32 arg2, s32 arg3) { phi_v0_2 = random_int(0x10); goto block_80; } - if ((arg0 + (arg2 * 0x48))->unk546 > 0) { - temp_s2_2 = arg0 + (arg1 * 0x48); + if ((s32) (player + (arg2 * 0x48))->unk546 > 0) { + temp_s2_2 = player + (arg1 * 0x48); temp_s0_2 = temp_s2_2 + 0x528; - func_8005D794(phi_f12, arg0, temp_s0_2, phi_f0, phi_f2, phi_f12, phi_v0, phi_t1); + func_8005D794(phi_f12, player, temp_s0_2, phi_f0, phi_f2, phi_f12, phi_v0, phi_t1); func_8005D7D8(temp_s0_2, 4, 0x3EEB851F); temp_v1_2 = gCurrentCourseId; phi_v1_6 = temp_v1_2; @@ -4557,171 +4367,165 @@ block_80: default: return; case 8: - if ((arg1 == 0) && ((temp_v0_2 = arg0 + (arg2 * 0x48), (temp_v0_2->unk546 > 0)) || (temp_v0_2->unk544 == 0))) { - temp_s2_3 = arg0 + (arg1 * 0x48); + if ((arg1 == 0) && ((temp_v0_2 = player + (arg2 * 0x48), ((s32) temp_v0_2->unk546 > 0)) || (temp_v0_2->unk544 == 0))) { + temp_s2_3 = player + (arg1 * 0x48); temp_s0_3 = temp_s2_3 + 0x528; - func_8005D794(phi_f12, arg0, temp_s0_3, phi_f0, phi_f2, phi_f12, phi_v0, phi_t1); + func_8005D794(phi_f12, player, temp_s0_3, phi_f0, phi_f2, phi_f12, phi_v0, phi_t1); func_8005D7D8(temp_s0_3, 4, 0x3DCCCCCD); func_8005D800(temp_s0_3, 0xFFFFFF, 0xFF); temp_t6 = arg1 * 8; - temp_s2_3->unk560 = temp_s2_3->unk560 - temp_t6; - temp_s2_3->unk562 = temp_s2_3->unk562 - temp_t6; - temp_s2_3->unk564 = temp_s2_3->unk564 - temp_t6; - } else if ((arg0 + (arg2 * 0x48))->unk546 > 0) { - temp_s2_4 = arg0 + (arg1 * 0x48); + temp_s2_3->unk560 = (s16) (temp_s2_3->unk560 - temp_t6); + temp_s2_3->unk562 = (s16) (temp_s2_3->unk562 - temp_t6); + temp_s2_3->unk564 = (s16) (temp_s2_3->unk564 - temp_t6); + } else if ((s32) (player + (arg2 * 0x48))->unk546 > 0) { + temp_s2_4 = player + (arg1 * 0x48); temp_s0_4 = temp_s2_4 + 0x528; - func_8005D794(phi_f12, arg0, temp_s0_4, phi_f0, phi_f2, phi_f12, phi_v0, phi_t1); + func_8005D794(phi_f12, player, temp_s0_4, phi_f0, phi_f2, phi_f12, phi_v0, phi_t1); func_8005D7D8(temp_s0_4, 4, 0x3DCCCCCD); func_8005D800(temp_s0_4, 0xFFFFFF, 0xFF); temp_t2 = arg1 * 8; - temp_s2_4->unk560 = temp_s2_4->unk560 - temp_t2; - temp_s2_4->unk562 = temp_s2_4->unk562 - temp_t2; - temp_s2_4->unk564 = temp_s2_4->unk564 - temp_t2; + temp_s2_4->unk560 = (s16) (temp_s2_4->unk560 - temp_t2); + temp_s2_4->unk562 = (s16) (temp_s2_4->unk562 - temp_t2); + temp_s2_4->unk564 = (s16) (temp_s2_4->unk564 - temp_t2); } - temp_s2_5 = arg0 + (arg1 * 0x48); - temp_s2_5->unk52C = temp_s2_5->unk52C - 1.5; + temp_s2_5 = player + (arg1 * 0x48); + temp_s2_5->unk52C = (f32) ((f64) temp_s2_5->unk52C - 1.5); return; case 7: - if ((arg1 == 0) && ((temp_v0_3 = arg0 + (arg2 * 0x48), (temp_v0_3->unk546 > 0)) || (temp_v0_3->unk544 == 0))) { - temp_s2_6 = arg0 + (arg1 * 0x48); + if ((arg1 == 0) && ((temp_v0_3 = player + (arg2 * 0x48), ((s32) temp_v0_3->unk546 > 0)) || (temp_v0_3->unk544 == 0))) { + temp_s2_6 = player + (arg1 * 0x48); temp_s0_5 = temp_s2_6 + 0x528; - func_8005D794(phi_f12, arg0, temp_s0_5, phi_f0, phi_f2, phi_f12, phi_v0, phi_t1); + func_8005D794(phi_f12, player, temp_s0_5, phi_f0, phi_f2, phi_f12, phi_v0, phi_t1); func_8005D7D8(temp_s0_5, 4, 0x3EEB851F); func_8005DAD8(temp_s0_5, 2, 1, 0xA8); phi_v0_2 = random_int(0x10); phi_s2 = temp_s2_6; goto block_80; } - if ((arg0 + (arg2 * 0x48))->unk546 > 0) { - temp_s2_7 = arg0 + (arg1 * 0x48); + if ((s32) (player + (arg2 * 0x48))->unk546 > 0) { + temp_s2_7 = player + (arg1 * 0x48); temp_s0_6 = temp_s2_7 + 0x528; - func_8005D794(phi_f12, arg0, temp_s0_6, phi_f0, phi_f2, phi_f12, phi_v0, phi_t1); + func_8005D794(phi_f12, player, temp_s0_6, phi_f0, phi_f2, phi_f12, phi_v0, phi_t1); func_8005D7D8(temp_s0_6, 4, 0x3EEB851F); func_8005DAD8(temp_s0_6, 2, 1, 0xA8); phi_v0_2 = random_int(0x10); phi_s2 = temp_s2_7; goto block_80; } - /* Duplicate return node #81. Try simplifying control flow for better match */ - return; + break; case 3: - if ((arg1 == 0) && ((temp_v0_4 = arg0 + (arg2 * 0x48), (temp_v0_4->unk546 > 0)) || (temp_v0_4->unk544 == 0))) { - temp_s2_8 = arg0 + (arg1 * 0x48); + if ((arg1 == 0) && ((temp_v0_4 = player + (arg2 * 0x48), ((s32) temp_v0_4->unk546 > 0)) || (temp_v0_4->unk544 == 0))) { + temp_s2_8 = player + (arg1 * 0x48); temp_s0_7 = temp_s2_8 + 0x528; - func_8005D794(phi_f12, arg0, temp_s0_7, phi_f0, phi_f2, phi_f12, phi_v0, phi_t1); + func_8005D794(phi_f12, player, temp_s0_7, phi_f0, phi_f2, phi_f12, phi_v0, phi_t1); func_8005D7D8(temp_s0_7, 4, 0x3EEB851F); func_8005DAD8(temp_s0_7, 3, 1, 0xA8); phi_v0_2 = random_int(0x10); phi_s2 = temp_s2_8; goto block_80; } - if ((arg0 + (arg2 * 0x48))->unk546 > 0) { - temp_s2_9 = arg0 + (arg1 * 0x48); + if ((s32) (player + (arg2 * 0x48))->unk546 > 0) { + temp_s2_9 = player + (arg1 * 0x48); temp_s0_8 = temp_s2_9 + 0x528; - func_8005D794(phi_f12, arg0, temp_s0_8, phi_f0, phi_f2, phi_f12, phi_v0, phi_t1); + func_8005D794(phi_f12, player, temp_s0_8, phi_f0, phi_f2, phi_f12, phi_v0, phi_t1); func_8005D7D8(temp_s0_8, 4, 0x3EEB851F); func_8005DAD8(temp_s0_8, 3, 1, 0xA8); phi_v0_2 = random_int(0x10); phi_s2 = temp_s2_9; goto block_80; } - /* Duplicate return node #81. Try simplifying control flow for better match */ - return; + break; case 10: - if ((arg1 == 0) && ((temp_v0_5 = arg0 + (arg2 * 0x48), (temp_v0_5->unk546 > 0)) || (temp_v0_5->unk544 == 0))) { - temp_s2_10 = arg0 + (arg1 * 0x48); + if ((arg1 == 0) && ((temp_v0_5 = player + (arg2 * 0x48), ((s32) temp_v0_5->unk546 > 0)) || (temp_v0_5->unk544 == 0))) { + temp_s2_10 = player + (arg1 * 0x48); temp_s0_9 = temp_s2_10 + 0x528; - func_8005D794(phi_f12, arg0, temp_s0_9, phi_f0, phi_f2, phi_f12, phi_v0, phi_t1); + func_8005D794(phi_f12, player, temp_s0_9, phi_f0, phi_f2, phi_f12, phi_v0, phi_t1); func_8005D7D8(temp_s0_9, 4, 0x3EEB851F); func_8005DAD8(temp_s0_9, 4, 1, 0xA8); phi_v0_2 = random_int(0x10); phi_s2 = temp_s2_10; goto block_80; } - if ((arg0 + (arg2 * 0x48))->unk546 > 0) { - temp_s2_11 = arg0 + (arg1 * 0x48); + if ((s32) (player + (arg2 * 0x48))->unk546 > 0) { + temp_s2_11 = player + (arg1 * 0x48); temp_s0_10 = temp_s2_11 + 0x528; - func_8005D794(phi_f12, arg0, temp_s0_10, phi_f0, phi_f2, phi_f12, phi_v0, phi_t1); + func_8005D794(phi_f12, player, temp_s0_10, phi_f0, phi_f2, phi_f12, phi_v0, phi_t1); func_8005D7D8(temp_s0_10, 4, 0x3EEB851F); func_8005DAD8(temp_s0_10, 4, 1, 0xA8); phi_v0_2 = random_int(0x10); phi_s2 = temp_s2_11; goto block_80; } - /* Duplicate return node #81. Try simplifying control flow for better match */ - return; + break; case 13: - if ((arg1 == 0) && ((temp_v0_6 = arg0 + (arg2 * 0x48), (temp_v0_6->unk546 > 0)) || (temp_v0_6->unk544 == 0))) { - temp_s2_12 = arg0 + (arg1 * 0x48); + if ((arg1 == 0) && ((temp_v0_6 = player + (arg2 * 0x48), ((s32) temp_v0_6->unk546 > 0)) || (temp_v0_6->unk544 == 0))) { + temp_s2_12 = player + (arg1 * 0x48); temp_s0_11 = temp_s2_12 + 0x528; - func_8005D794(phi_f12, arg0, temp_s0_11, phi_f0, phi_f2, phi_f12, phi_v0, phi_t1); + func_8005D794(phi_f12, player, temp_s0_11, phi_f0, phi_f2, phi_f12, phi_v0, phi_t1); func_8005D7D8(temp_s0_11, 4, 0x3EEB851F); func_8005DAD8(temp_s0_11, 5, 1, 0xA8); phi_v0_2 = random_int(0x10); phi_s2 = temp_s2_12; goto block_80; } - if ((arg0 + (arg2 * 0x48))->unk546 > 0) { - temp_s2_13 = arg0 + (arg1 * 0x48); + if ((s32) (player + (arg2 * 0x48))->unk546 > 0) { + temp_s2_13 = player + (arg1 * 0x48); temp_s0_12 = temp_s2_13 + 0x528; - func_8005D794(phi_f12, arg0, temp_s0_12, phi_f0, phi_f2, phi_f12, phi_v0, phi_t1); + func_8005D794(phi_f12, player, temp_s0_12, phi_f0, phi_f2, phi_f12, phi_v0, phi_t1); func_8005D7D8(temp_s0_12, 4, 0x3EEB851F); func_8005DAD8(temp_s0_12, 5, 1, 0xA8); phi_v0_2 = random_int(0x10); phi_s2 = temp_s2_13; goto block_80; } - /* Duplicate return node #81. Try simplifying control flow for better match */ - return; + break; case 5: case 11: - if ((arg1 == 0) && ((temp_v0_7 = arg0 + (arg2 * 0x48), (temp_v0_7->unk546 > 0)) || (temp_v0_7->unk544 == 0))) { - temp_s2_14 = arg0 + (arg1 * 0x48); + if ((arg1 == 0) && ((temp_v0_7 = player + (arg2 * 0x48), ((s32) temp_v0_7->unk546 > 0)) || (temp_v0_7->unk544 == 0))) { + temp_s2_14 = player + (arg1 * 0x48); temp_s0_13 = temp_s2_14 + 0x528; - func_8005D794(phi_f12, arg0, temp_s0_13, phi_f0, phi_f2, phi_f12, phi_v0, phi_t1); + func_8005D794(phi_f12, player, temp_s0_13, phi_f0, phi_f2, phi_f12, phi_v0, phi_t1); func_8005D7D8(temp_s0_13, 4, 0x3EEB851F); func_8005DAD8(temp_s0_13, 6, 1, 0xA8); phi_v0_2 = random_int(0x10); phi_s2 = temp_s2_14; goto block_80; } - if ((arg0 + (arg2 * 0x48))->unk546 > 0) { - temp_s2_15 = arg0 + (arg1 * 0x48); + if ((s32) (player + (arg2 * 0x48))->unk546 > 0) { + temp_s2_15 = player + (arg1 * 0x48); temp_s0_14 = temp_s2_15 + 0x528; - func_8005D794(phi_f12, arg0, temp_s0_14, phi_f0, phi_f2, phi_f12, phi_v0, phi_t1); + func_8005D794(phi_f12, player, temp_s0_14, phi_f0, phi_f2, phi_f12, phi_v0, phi_t1); func_8005D7D8(temp_s0_14, 4, 0x3EEB851F); func_8005DAD8(temp_s0_14, 6, 1, 0xA8); phi_v0_2 = random_int(0x10); phi_s2 = temp_s2_15; goto block_80; } - /* Duplicate return node #81. Try simplifying control flow for better match */ - return; + break; case 1: case 4: case 6: - if ((arg1 == 0) && ((temp_v0_8 = arg0 + (arg2 * 0x48), (temp_v0_8->unk546 > 0)) || (temp_v0_8->unk544 == 0))) { - temp_s2_16 = arg0 + (arg1 * 0x48); + if ((arg1 == 0) && ((temp_v0_8 = player + (arg2 * 0x48), ((s32) temp_v0_8->unk546 > 0)) || (temp_v0_8->unk544 == 0))) { + temp_s2_16 = player + (arg1 * 0x48); temp_s0_15 = temp_s2_16 + 0x528; - func_8005D794(phi_f12, arg0, temp_s0_15, phi_f0, phi_f2, phi_f12, phi_v0, phi_t1); + func_8005D794(phi_f12, player, temp_s0_15, phi_f0, phi_f2, phi_f12, phi_v0, phi_t1); func_8005D7D8(temp_s0_15, 4, 0x3EEB851F); func_8005DAD8(temp_s0_15, 0, 0, 0x80); phi_v0_2 = random_int(0x10); phi_s2 = temp_s2_16; goto block_80; } - if ((arg0 + (arg2 * 0x48))->unk546 > 0) { - temp_s2_17 = arg0 + (arg1 * 0x48); + if ((s32) (player + (arg2 * 0x48))->unk546 > 0) { + temp_s2_17 = player + (arg1 * 0x48); temp_s0_16 = temp_s2_17 + 0x528; - func_8005D794(phi_f12, arg0, temp_s0_16, phi_f0, phi_f2, phi_f12, phi_v0, phi_t1); + func_8005D794(phi_f12, player, temp_s0_16, phi_f0, phi_f2, phi_f12, phi_v0, phi_t1); func_8005D7D8(temp_s0_16, 4, 0x3EEB851F); func_8005DAD8(temp_s0_16, 0, 0, 0x80); phi_v0_2 = random_int(0x10); phi_s2 = temp_s2_17; goto block_80; } - /* Duplicate return node #81. Try simplifying control flow for better match */ - return; + break; } } #else @@ -6086,11 +5890,11 @@ void func_80063268(Player* arg0, s16 arg1, UNUSED s8 arg2, UNUSED s8 arg3) { void func_80063408(Player* arg0, s16 arg1, UNUSED s8 arg2, UNUSED s8 arg3) { if (arg0->unk_258[10 + arg1].unk_010 == 1) { - arg0->unk_258[10 + arg1].unk_008 = (arg0->unk_258[10 + arg1].unk_01E * -7) * coss(arg0->unk_258[10 + arg1].unk_020) + arg0->unk_1D0; - arg0->unk_258[10 + arg1].unk_000 = (arg0->unk_258[10 + arg1].unk_01E * -7) * sins(arg0->unk_258[10 + arg1].unk_020) + arg0->unk_1C8; + arg0->unk_258[10 + arg1].unk_008 = arg0->boundingBoxCorners[2].cornerZ + (arg0->unk_258[10 + arg1].unk_01E * -7) * coss(arg0->unk_258[10 + arg1].unk_020); + arg0->unk_258[10 + arg1].unk_000 = arg0->boundingBoxCorners[2].cornerX + (arg0->unk_258[10 + arg1].unk_01E * -7) * sins(arg0->unk_258[10 + arg1].unk_020); } else { - arg0->unk_258[10 + arg1].unk_008 = (arg0->unk_258[10 + arg1].unk_01E * -7) * coss(arg0->unk_258[10 + arg1].unk_020) + arg0->unk_1E8; - arg0->unk_258[10 + arg1].unk_000 = (arg0->unk_258[10 + arg1].unk_01E * -7) * sins(arg0->unk_258[10 + arg1].unk_020) + arg0->unk_1E0; + arg0->unk_258[10 + arg1].unk_008 = arg0->boundingBoxCorners[3].cornerZ + (arg0->unk_258[10 + arg1].unk_01E * -7) * coss(arg0->unk_258[10 + arg1].unk_020); + arg0->unk_258[10 + arg1].unk_000 = arg0->boundingBoxCorners[3].cornerX + (arg0->unk_258[10 + arg1].unk_01E * -7) * sins(arg0->unk_258[10 + arg1].unk_020); } ++arg0->unk_258[10 + arg1].unk_01E; @@ -6125,19 +5929,19 @@ void func_800635D4(Player* arg0, s16 arg1, UNUSED s8 arg2, UNUSED s8 arg3) { if (arg0->unk_258[10 + arg1].unk_010 == 1) { if ((arg0->unk_0BC * 2) < 0) { func_80062B18(&sp44, &sp40, &sp3C, -2.0f, 0.0f, (-arg0->unk_258[10 + arg1].unk_01E * (arg0->unk_094 / 18.0f) * 216.0f) / 16, -arg0->unk_258[10 + arg1].unk_020, 2 * -arg0->unk_206); - arg0->unk_258[10 + arg1].unk_000 = arg0->unk_1C8 + sp44; - arg0->unk_258[10 + arg1].unk_008 = arg0->unk_1D0 + sp3C; + arg0->unk_258[10 + arg1].unk_000 = arg0->boundingBoxCorners[2].cornerX + sp44; + arg0->unk_258[10 + arg1].unk_008 = arg0->boundingBoxCorners[2].cornerZ + sp3C; } else { - arg0->unk_258[10 + arg1].unk_008 = ((-arg0->unk_258[10 + arg1].unk_01E * (arg0->unk_094 / 18.0f) * 216.0f) / 16) * coss(arg0->unk_258[10 + arg1].unk_020) + arg0->unk_1D0; - arg0->unk_258[10 + arg1].unk_000 = ((-arg0->unk_258[10 + arg1].unk_01E * (arg0->unk_094 / 18.0f) * 216.0f) / 16) * sins(arg0->unk_258[10 + arg1].unk_020) + arg0->unk_1C8; + arg0->unk_258[10 + arg1].unk_008 = arg0->boundingBoxCorners[2].cornerZ + ((-arg0->unk_258[10 + arg1].unk_01E * (arg0->unk_094 / 18.0f) * 216.0f) / 16) * coss(arg0->unk_258[10 + arg1].unk_020); + arg0->unk_258[10 + arg1].unk_000 = arg0->boundingBoxCorners[2].cornerX + ((-arg0->unk_258[10 + arg1].unk_01E * (arg0->unk_094 / 18.0f) * 216.0f) / 16) * sins(arg0->unk_258[10 + arg1].unk_020); } } else if ((arg0->unk_0BC * 2) < 0) { func_80062B18(&sp44, &sp40, &sp3C, 2.0f, 0.0f, (-arg0->unk_258[10 + arg1].unk_01E * (arg0->unk_094 / 18.0f) * 216.0f) / 16, - arg0->unk_258[10 + arg1].unk_020, 2 * -arg0->unk_206); - arg0->unk_258[10 + arg1].unk_000 = arg0->unk_1E0 + sp44; - arg0->unk_258[10 + arg1].unk_008 = arg0->unk_1E8 + sp3C; + arg0->unk_258[10 + arg1].unk_000 = arg0->boundingBoxCorners[3].cornerX + sp44; + arg0->unk_258[10 + arg1].unk_008 = arg0->boundingBoxCorners[3].cornerZ + sp3C; } else { - arg0->unk_258[10 + arg1].unk_008 = ((-arg0->unk_258[10 + arg1].unk_01E * (arg0->unk_094 / 18.0f) * 216.0f) / 16) * coss(arg0->unk_258[10 + arg1].unk_020) + arg0->unk_1E8; - arg0->unk_258[10 + arg1].unk_000 = ((-arg0->unk_258[10 + arg1].unk_01E * (arg0->unk_094 / 18.0f) * 216.0f) / 16) * sins(arg0->unk_258[10 + arg1].unk_020) + arg0->unk_1E0; + arg0->unk_258[10 + arg1].unk_008 = arg0->boundingBoxCorners[3].cornerZ + ((-arg0->unk_258[10 + arg1].unk_01E * (arg0->unk_094 / 18.0f) * 216.0f) / 16) * coss(arg0->unk_258[10 + arg1].unk_020); + arg0->unk_258[10 + arg1].unk_000 = arg0->boundingBoxCorners[3].cornerX + ((-arg0->unk_258[10 + arg1].unk_01E * (arg0->unk_094 / 18.0f) * 216.0f) / 16) * sins(arg0->unk_258[10 + arg1].unk_020); } ++arg0->unk_258[10 + arg1].unk_01E; @@ -6173,11 +5977,11 @@ void func_800635D4(Player* arg0, s16 arg1, UNUSED s8 arg2, UNUSED s8 arg3) { void func_800639DC(Player* arg0, s16 arg1, UNUSED s8 arg2, UNUSED s8 arg3) { if (arg0->unk_258[10 + arg1].unk_010 == 1) { - arg0->unk_258[10 + arg1].unk_008 = (D_800EE680 * arg0->unk_258[10 + arg1].unk_01E) * coss(arg0->unk_258[10 + arg1].unk_020) + arg0->unk_1D0; - arg0->unk_258[10 + arg1].unk_000 = (D_800EE684 * arg0->unk_258[10 + arg1].unk_01E) * sins(arg0->unk_258[10 + arg1].unk_020) + arg0->unk_1C8; + arg0->unk_258[10 + arg1].unk_008 = arg0->boundingBoxCorners[2].cornerZ + (D_800EE680 * arg0->unk_258[10 + arg1].unk_01E) * coss(arg0->unk_258[10 + arg1].unk_020); + arg0->unk_258[10 + arg1].unk_000 = arg0->boundingBoxCorners[2].cornerX + (D_800EE684 * arg0->unk_258[10 + arg1].unk_01E) * sins(arg0->unk_258[10 + arg1].unk_020); } else { - arg0->unk_258[10 + arg1].unk_008 = (D_800EE688 * arg0->unk_258[10 + arg1].unk_01E) * coss(arg0->unk_258[10 + arg1].unk_020) + arg0->unk_1E8; - arg0->unk_258[10 + arg1].unk_000 = (D_800EE68C * arg0->unk_258[10 + arg1].unk_01E) * sins(arg0->unk_258[10 + arg1].unk_020) + arg0->unk_1E0; + arg0->unk_258[10 + arg1].unk_008 = arg0->boundingBoxCorners[3].cornerZ + (D_800EE688 * arg0->unk_258[10 + arg1].unk_01E) * coss(arg0->unk_258[10 + arg1].unk_020); + arg0->unk_258[10 + arg1].unk_000 = arg0->boundingBoxCorners[3].cornerX + (D_800EE68C * arg0->unk_258[10 + arg1].unk_01E) * sins(arg0->unk_258[10 + arg1].unk_020); } ++arg0->unk_258[10 + arg1].unk_01E; arg0->unk_258[10 + arg1].unk_004 += D_800EE690; @@ -6208,11 +6012,11 @@ void func_800639DC(Player* arg0, s16 arg1, UNUSED s8 arg2, UNUSED s8 arg3) { void func_80063BD4(Player* arg0, s16 arg1, UNUSED s8 arg2, UNUSED s8 arg3) { if (arg0->unk_258[10 + arg1].unk_010 == 1) { - arg0->unk_258[10 + arg1].unk_008 = (-2 * arg0->unk_258[10 + arg1].unk_01E * coss(arg0->unk_258[10 + arg1].unk_020) + arg0->unk_1D0); - arg0->unk_258[10 + arg1].unk_000 = (-2 * arg0->unk_258[10 + arg1].unk_01E * sins(arg0->unk_258[10 + arg1].unk_020) + arg0->unk_1C8); + arg0->unk_258[10 + arg1].unk_008 = arg0->boundingBoxCorners[2].cornerZ + (-2 * arg0->unk_258[10 + arg1].unk_01E * coss(arg0->unk_258[10 + arg1].unk_020)); + arg0->unk_258[10 + arg1].unk_000 = arg0->boundingBoxCorners[2].cornerX + (-2 * arg0->unk_258[10 + arg1].unk_01E * sins(arg0->unk_258[10 + arg1].unk_020)); } else { - arg0->unk_258[10 + arg1].unk_008 = (-2 * arg0->unk_258[10 + arg1].unk_01E * coss(arg0->unk_258[10 + arg1].unk_020) + arg0->unk_1E8); - arg0->unk_258[10 + arg1].unk_000 = (-2 * arg0->unk_258[10 + arg1].unk_01E * sins(arg0->unk_258[10 + arg1].unk_020) + arg0->unk_1E0); + arg0->unk_258[10 + arg1].unk_008 = arg0->boundingBoxCorners[3].cornerZ + (-2 * arg0->unk_258[10 + arg1].unk_01E * coss(arg0->unk_258[10 + arg1].unk_020)); + arg0->unk_258[10 + arg1].unk_000 = arg0->boundingBoxCorners[3].cornerX + (-2 * arg0->unk_258[10 + arg1].unk_01E * sins(arg0->unk_258[10 + arg1].unk_020)); } ++arg0->unk_258[10 + arg1].unk_01E; @@ -6229,11 +6033,11 @@ void func_80063BD4(Player* arg0, s16 arg1, UNUSED s8 arg2, UNUSED s8 arg3) { void func_80063D58(Player* arg0, s16 arg1, UNUSED s8 arg2, UNUSED s8 arg3) { if (arg0->unk_258[10 + arg1].unk_010 == 1) { - arg0->unk_258[10 + arg1].unk_008 = ((-arg0->unk_258[10 + arg1].unk_01E * (arg0->unk_094 / 18.0f) * 216.0f) / 20.0f) * coss(arg0->unk_258[10 + arg1].unk_020) + arg0->unk_1D0; - arg0->unk_258[10 + arg1].unk_000 = ((-arg0->unk_258[10 + arg1].unk_01E * (arg0->unk_094 / 18.0f) * 216.0f) / 20.0f) * sins(arg0->unk_258[10 + arg1].unk_020) + arg0->unk_1C8; + arg0->unk_258[10 + arg1].unk_008 = arg0->boundingBoxCorners[2].cornerZ + ((-arg0->unk_258[10 + arg1].unk_01E * (arg0->unk_094 / 18.0f) * 216.0f) / 20.0f) * coss(arg0->unk_258[10 + arg1].unk_020); + arg0->unk_258[10 + arg1].unk_000 = arg0->boundingBoxCorners[2].cornerX + ((-arg0->unk_258[10 + arg1].unk_01E * (arg0->unk_094 / 18.0f) * 216.0f) / 20.0f) * sins(arg0->unk_258[10 + arg1].unk_020); } else { - arg0->unk_258[10 + arg1].unk_008 = ((-arg0->unk_258[10 + arg1].unk_01E * (arg0->unk_094 / 18.0f) * 216.0f) / 20.0f) * coss(arg0->unk_258[10 + arg1].unk_020) + arg0->unk_1E8; - arg0->unk_258[10 + arg1].unk_000 = ((-arg0->unk_258[10 + arg1].unk_01E * (arg0->unk_094 / 18.0f) * 216.0f) / 20.0f) * sins(arg0->unk_258[10 + arg1].unk_020) + arg0->unk_1E0; + arg0->unk_258[10 + arg1].unk_008 = arg0->boundingBoxCorners[3].cornerZ + ((-arg0->unk_258[10 + arg1].unk_01E * (arg0->unk_094 / 18.0f) * 216.0f) / 20.0f) * coss(arg0->unk_258[10 + arg1].unk_020); + arg0->unk_258[10 + arg1].unk_000 = arg0->boundingBoxCorners[3].cornerX + ((-arg0->unk_258[10 + arg1].unk_01E * (arg0->unk_094 / 18.0f) * 216.0f) / 20.0f) * sins(arg0->unk_258[10 + arg1].unk_020); } ++arg0->unk_258[10 + arg1].unk_01E; @@ -10601,7 +10405,7 @@ void func_8006B7E4(Player *player, s32 arg1) { GLOBAL_ASM("asm/non_matchings/code_80057C60/func_8006B7E4.s") #endif -void func_8006B87C(UNUSED s32 arg0, s8 playerIndex) { +void func_8006B87C(UNUSED Player *player, s8 playerIndex) { gPlayerBalloonStatus[playerIndex][0] = BALLOON_STATUS_GONE; gPlayerBalloonStatus[playerIndex][1] = BALLOON_STATUS_GONE; gPlayerBalloonStatus[playerIndex][2] = BALLOON_STATUS_GONE; diff --git a/src/code_80057C60.h b/src/code_80057C60.h new file mode 100644 index 000000000..ca126ab67 --- /dev/null +++ b/src/code_80057C60.h @@ -0,0 +1,240 @@ +#ifndef CODE_80057C60_H +#define CODE_80057C60_H + +#include "common_structs.h" + +void func_80057C60(); +void func_80057CE4(); +void func_80057DD0(); +void func_80057FC4(u32); + +void func_80058090(u32); +void func_800581C8(); +void func_800582CC(); +void func_80058394(); +void func_8005845C(); +void func_80058538(u32); +void func_80058640(); +void func_800586FC(); +void func_800587A4(); +void func_8005884C(); +void func_800588F4(s32); +void func_80058B58(); +void func_80058BF4(); +void func_80058C20(u32); +void func_80058DB4(u32); +void func_80058F48(); +void func_80058F78(); + +void func_80059024(); +void func_8005902C(); +void func_800590D4(); +void func_800591B4(); +void func_80059358(); +void func_80059360(); +void func_800593F0(); +void func_800593F8(); +void func_80059488(s32); +void func_800594F0(); +void func_800594F8(); +void func_80059528(); +void func_80059530(); +void func_80059560(s32); +void func_800596A8(); +void func_800596D8(); +void func_80059710(); +void func_80059718(); +void func_80059750(); +void func_80059780(); +void func_800597B8(); +void func_800597E8(); +void func_80059820(s32); +void func_800598D4(s32); +void func_8005994C(); +void func_8005995C(); +void func_80059A88(s32); +void func_80059D00(); + +void func_8005A070(); +void func_8005A14C(s32); +void func_8005A380(); +void func_8005A3C0(); +void func_8005A71C(); +void func_8005A74C(); +void func_8005A99C(); +void func_8005AA34(); +void func_8005AA4C(); +void func_8005AA6C(s32); +void func_8005AA80(); +void func_8005AA94(s32); +void func_8005AAF0(); +void func_8005AB20(); + +void func_8005B914(); + +void func_8005C360(f32); +void func_8005C6B4(s8, s16*, s16*, s16*); +void func_8005C728(); +void func_8005CB60(s32, s32); + +void func_8005D0FC(s32); +void func_8005D18C(); +void func_8005D1F4(s32); + +void func_80062B18(f32*, f32*, f32*, f32, f32, f32, u16, u16); +void func_80062F98(Player*, s16, s8, s8); + +void func_800630C0(Player*, s16, s8, s8); +void func_800631A8(Player*, s16, s8, s8); +void func_80063268(Player*, s16, s8, s8); +void func_80063408(Player*, s16, s8, s8); +void func_800635D4(Player*, s16, s8, s8); +void func_800639DC(Player*, s16, s8, s8); +void func_80063BD4(Player*, s16, s8, s8); +void func_80063D58(Player*, s16, s8, s8); + +void func_800643A8(Player*, s16, s8, s8); +void func_800647C8(Player*, s16, s8, s8); +void func_800648E4(Player*, s16, s8, s8); +void func_80064988(Player*, s16, s8, s8); +void func_800649F4(Player*, s16, s8, s8); +void func_80064B30(Player*, s16, s8, s8); +void func_80064C74(Player*, s16, s8, s8); +void func_80064DEC(Player*, s16, s8, s8); +void func_80064EA4(Player*, s16, s8, s8); +void func_80064F88(Player*, s16, s8, s8); + +void func_80065030(Player*, s16, s8, s8); +void func_800650FC(Player*, s16, s8, s8); +void func_800651F4(Player*, s16, s8, s8); +void func_800658A0(Player*, s8, s16, s8); + +void func_80066998(Player*, s8, s16, s8); + +void func_80067964(Player*, s8, s32, s8, s32); +void func_80067D3C(Player*, s8, s32, s32, f32, s32); + +void func_8006801C(Player*, s8, s32, s32, f32, s32); +void func_80068310(Player*, s8, s32, s8, s32); +void func_80068724(Player*, s8, s32, s8, s32); +void func_80068AA4(Player*, s8, s32, s8, s32); +void func_80068DA0(Player*, s8, s32, s8, s32); + +void func_8006A280(Player*, s8, s16, s8); +void func_8006AFD0(Player*, s16, s8, s8); + +void func_8006B87C(Player*, s8); +void func_8006B974(s32, s8, s8); +void func_8006B9CC(Player*, s8); +void func_8006BA94(Player*, s8, s8); + +void func_8006C6AC(Player*, s16, s8, s8); +void func_8006C9B8(Player*, s16, s8, s8); +void func_8006CEC0(Player*, s16, s8, s8); + +void func_8006D194(Player*, s8, s8); +void func_8006D474(Player*, s8, s8); +void func_8006DC54(Player*, s8, s8); +void func_8006DD3C(Player*, s8, s8); + +void func_8006E058(); +void func_8006E420(Player*, s8, s8); +void func_8006E5AC(Player*, s8, s8); +void func_8006E634(Player*, s8, s8); +void func_8006E6BC(Player*, s8, s8); +void func_8006E744(Player*, s8, s8); +void func_8006E7CC(Player*, s8, s8); +void func_8006E848(Player*, s8, s8); +void func_8006E8C4(Player*, s8, s8); +void func_8006E940(Player*, s8, s8); + +extern u16 gPlayerBalloonStatus[8][3]; // D_8018D5F0 +extern s16 gPlayerBalloonCount[]; // D_8018D8C0 +extern u32 gScreenModeSelection; // D_800DC530 + +extern struct UnkStruct_800DC5EC *D_800DC5EC; +extern struct UnkStruct_800DC5EC *D_800DC5F0; +extern struct UnkStruct_800DC5EC *D_800DC5F4; +extern struct UnkStruct_800DC5EC *D_800DC5F8; + +extern u16 D_800DC5FC; + +extern f64 D_800EE648; +extern f64 D_800EE650; +extern f64 D_800EE658; +extern f64 D_800EE660; +extern f64 D_800EE668; +extern f64 D_800EE670; +extern f64 D_800EE678; +extern f32 D_800EE680; +extern f32 D_800EE684; +extern f32 D_800EE688; +extern f32 D_800EE68C; +extern f64 D_800EE690; +extern f64 D_800EE698; +extern f64 D_800EE6A0; +extern f64 D_800EE6A8; +extern f64 D_800EE6B0; +extern f64 D_800EE6B8; +extern f64 D_800EE6C0; +extern f64 D_800EE6D8; +extern f64 D_800EE6E0; +extern f64 D_800EE6E8; +extern f64 D_800EE700; +extern f64 D_800EE708; +extern f64 D_800EE710; +extern f64 D_800EE718; +extern f64 D_800EE720; +extern f64 D_800EE728; +extern f64 D_800EE730; +extern f64 D_800EE738; +extern f64 D_800EE740; +extern f64 D_800EE748; +extern f64 D_800EE750; +extern f64 D_800EE758; +extern f64 D_800EE760; +extern f64 D_800EE768; +extern f64 D_800EE770; +extern f64 D_800EE778; +extern f32 D_800EE780; +extern f64 D_800EE788; +extern f64 D_800EE790; +extern f64 D_800EE798; +extern f64 D_800EE7A0; +extern f64 D_800EE7A8; +extern f32 D_800EE7B0; +extern f64 D_800EE7B8; +extern f32 D_800EE948; +extern f32 D_800EE94C; + +extern s32 D_80164394; +extern s32 D_80164398; +extern s32 D_8016439C; +extern f32 D_801652A0[]; +extern s32 D_801655C0; +extern s32 D_801655F0; +extern s32 D_80165678; +extern s8 D_801657AE; +extern s8 D_801657D8; +extern s8 D_801657E8; + +extern s8 D_8018CAE0; + +extern s32 D_8018D120; +extern s32 D_8018D170; +extern s32 D_8018D178; +extern s32 D_8018D188; +extern s32 D_8018D190; +extern s32 D_8018D1A0; +extern s32 D_8018D1B4; +extern s32 D_8018D1D4; +extern s32 D_8018D1CC; +extern s32 D_8018D1FC; +extern s32 D_8018D204; +extern s32 D_8018D21C; +extern s32 D_8018D2A4; +extern s32 D_8018D2BC; +extern s32 D_8018D480; +extern s32 D_8018D484; + +#endif diff --git a/src/code_8028DF00.c b/src/code_8028DF00.c index 86d8c4caa..d2f4abb33 100644 --- a/src/code_8028DF00.c +++ b/src/code_8028DF00.c @@ -45,7 +45,7 @@ extern s32 D_800DC544; extern Player gPlayers[]; extern Player *gPlayerTwo; extern Player *gPlayerOne; -extern s32 lapCount[]; +extern s32 gLapCountByPlayerId[]; extern s32 D_80150120; extern s32 gModeSelection; extern s32 gPlayerCountSelection1; @@ -206,7 +206,7 @@ void update_player_battle_status(void) { extern f32 gTimePlayerLastTouchedFinishLine[]; extern u16 D_801645B0[]; extern u16 D_801645C8[]; -extern f32 D_801644A8[]; +extern f32 gLapCompletionPercentByPlayerId[]; void func_8028E298(void) { f32 temp_v0; @@ -220,8 +220,8 @@ void func_8028E298(void) { } temp_a2 = D_801645B0[i]; - temp_v0 = ((2 - gPlayers[i].unk_008) * D_801645C8[temp_a2]); - temp_v0 += D_801645C8[temp_a2] * (1.0f - D_801644A8[i]); + temp_v0 = ((2 - gPlayers[i].lapCount) * D_801645C8[temp_a2]); + temp_v0 += D_801645C8[temp_a2] * (1.0f - gLapCompletionPercentByPlayerId[i]); temp_v0 /= 15.0f; gTimePlayerLastTouchedFinishLine[i] = gCourseTimer + temp_v0; @@ -612,16 +612,16 @@ void func_8028EF28(void) { continue; } - if (lapCount[i] < gPlayers[i].unk_008) { - gPlayers[i].unk_008--; - } else if (lapCount[i] > gPlayers[i].unk_008) { - gPlayers[i].unk_008++; + if (gLapCountByPlayerId[i] < gPlayers[i].lapCount) { + gPlayers[i].lapCount--; + } else if (gLapCountByPlayerId[i] > gPlayers[i].lapCount) { + gPlayers[i].lapCount++; if ((gPlayers[i].unk_000 & PLAYER_HUMAN) != 0) { - if (gPlayers[i].unk_008 == 3) { + if (gPlayers[i].lapCount == 3) { func_8028EEF0(i); - currentPosition = gPlayers[i].unk_004; + currentPosition = gPlayers[i].currentRank; gPlayers[i].unk_000 |= PLAYER_CPU; if (currentPosition < 4) { @@ -702,7 +702,7 @@ void func_8028EF28(void) { } - } else if (gPlayers[i].unk_008 == 2) { + } else if (gPlayers[i].lapCount == 2) { if ((gPlayers[i].unk_000 & 0x100) != 0) { return; } @@ -711,7 +711,7 @@ void func_8028EF28(void) { func_800CA49C((u8)i); } } - } else if (gPlayers[i].unk_008 == 3) { + } else if (gPlayers[i].lapCount == 3) { func_8028EEF0(i); if (gModeSelection == TIME_TRIALS) { func_80005AE8(ply); @@ -741,7 +741,7 @@ void update_race_position_data(void) { ((gPlayers[i].unk_000 & PLAYER_CINEMATIC_MODE) == 0) && ((gPlayers[i].unk_000 & PLAYER_INVISIBLE_OR_BOMB) == 0)) { position = gPlayerPositions[i]; - gPlayers[i].unk_004 = position; + gPlayers[i].currentRank = position; gPlayerPositionLUT[position] = i; } } @@ -992,23 +992,23 @@ block_20: if ((gEnableDebugMode != 0) && (gModeSelection != BATTLE)) { temp_a1 = gControllerOne; if ((temp_a1->buttonPressed & 0x800) != 0) { - lapCount->unk0 = 2; + gLapCountByPlayerId->unk0 = 2; } phi_a0 = temp_a1->buttonPressed; if ((temp_a1->buttonPressed & 0x100) != 0) { - lapCount->unk0 = 2; - lapCount->unk4 = 2; + gLapCountByPlayerId->unk0 = 2; + gLapCountByPlayerId->unk4 = 2; phi_a0 = temp_a1->buttonPressed; } if ((phi_a0 & 0x400) != 0) { - lapCount->unk0 = 2; - lapCount->unk4 = 2; - lapCount->unk8 = 2; - lapCount->unkC = 2; - lapCount->unk10 = 2; - lapCount->unk14 = 2; - lapCount->unk18 = 2; - lapCount->unk1C = 2; + gLapCountByPlayerId->unk0 = 2; + gLapCountByPlayerId->unk4 = 2; + gLapCountByPlayerId->unk8 = 2; + gLapCountByPlayerId->unkC = 2; + gLapCountByPlayerId->unk10 = 2; + gLapCountByPlayerId->unk14 = 2; + gLapCountByPlayerId->unk18 = 2; + gLapCountByPlayerId->unk1C = 2; } } // Duplicate return node #29. Try simplifying control flow for better match @@ -1162,7 +1162,7 @@ void func_8028FCBC(void) { if (((gPlayerOne->unk_000 & PLAYER_CINEMATIC_MODE) != 0) && ((gPlayerTwo->unk_000 & PLAYER_CINEMATIC_MODE) != 0)) { - if (gPlayerOne->unk_004 < gPlayerTwo->unk_004) { + if (gPlayerOne->currentRank < gPlayerTwo->currentRank) { gPlayerWinningIndex = 1; } else { gPlayerWinningIndex = 0; diff --git a/src/code_80290C20.c b/src/code_80290C20.c index fd51a4102..5203a890c 100644 --- a/src/code_80290C20.c +++ b/src/code_80290C20.c @@ -2184,14 +2184,15 @@ GLOBAL_ASM("asm/non_matchings/code_80290C20/func_80295A38.s") void func_80295BF8(s32 playerIndex) { Player* player = &gPlayers[playerIndex]; func_802AAAAC(&player->unk_110); - player->unk_1BD = 0; - player->unk_1A5 = 0; - player->unk_1ED = 0; - player->unk_1D5 = 0; - player->unk_1BE = 0x1388; - player->unk_1A6 = 0x1388; - player->unk_1EE = 0x1388; - player->unk_1D6 = 0x1388; + player->boundingBoxCorners[FRONT_RIGHT_TYRE].unk_0D = 0.0f; + player->boundingBoxCorners[FRONT_LEFT_TYRE].unk_0D = 0.0f; + player->boundingBoxCorners[BACK_RIGHT_TYRE].unk_0D = 0.0f; + player->boundingBoxCorners[BACK_LEFT_TYRE].unk_0D = 0.0f; + + player->boundingBoxCorners[FRONT_RIGHT_TYRE].tileIndex = 0x1388; + player->boundingBoxCorners[FRONT_LEFT_TYRE].tileIndex = 0x1388; + player->boundingBoxCorners[BACK_RIGHT_TYRE].tileIndex = 0x1388; + player->boundingBoxCorners[BACK_LEFT_TYRE].tileIndex = 0x1388; } diff --git a/src/math_util.c b/src/math_util.c index ca61defc7..8bdea2ee6 100644 --- a/src/math_util.c +++ b/src/math_util.c @@ -1975,10 +1975,8 @@ GLOBAL_ASM("asm/non_matchings/math_util/func_802B8414.s") #endif #ifdef MIPS_TO_C -//generated by mips_to_c commit bd0364fa19633bd6201f8007e2d0a7ed87825909 -//This function did not have a glabel in the original assembly, as such it may -//be unused/unnamed -void func_802B8614(void *arg0) { +//generated by mips_to_c commit 792017ad9d422c2467bd42686f383a5c41f41c75 +UNUSED void func_802B8614(Player *player) { f64 sp78; f64 sp70; f64 sp68; @@ -1997,16 +1995,16 @@ void func_802B8614(void *arg0) { f64 temp_f4; f64 temp_f6; - temp_f6 = arg0->unk1B0; + temp_f6 = (f64) player->boundingBoxCorners[1].cornerX; sp78 = temp_f6; - sp70 = arg0->unk1C0; - sp68 = arg0->unk1B8; - temp_f30 = arg0->unk198; - sp58 = arg0->unk1A8; - sp50 = arg0->unk1A0; - sp48 = arg0->unk1E0; - sp40 = arg0->unk1F0; - temp_f4 = arg0->unk1E8; + sp70 = (f64) player->boundingBoxCorners[1].cornerGroundY; + sp68 = (f64) player->boundingBoxCorners[1].cornerZ; + temp_f30 = (f64) player->boundingBoxCorners[0].cornerX; + sp58 = (f64) player->boundingBoxCorners[0].cornerGroundY; + sp50 = (f64) player->boundingBoxCorners[0].cornerZ; + sp48 = (f64) player->boundingBoxCorners[3].cornerX; + sp40 = (f64) player->boundingBoxCorners[3].cornerGroundY; + temp_f4 = (f64) player->boundingBoxCorners[3].cornerZ; temp_f2 = sp58 - sp70; sp38 = temp_f4; temp_f12 = temp_f4 - sp50; @@ -2015,14 +2013,14 @@ void func_802B8614(void *arg0) { temp_f18 = sp48 - temp_f30; temp_f20 = temp_f30 - temp_f6; if (0.0 == 0.0) { - arg0->unk58 = 0.0f; - arg0->unk60 = 0.0f; - arg0->unk5C = 1.0f; + player->unk_058 = 0.0f; + player->unk_060 = 0.0f; + player->unk_05C = 1.0f; return; } - arg0->unk58 = ((temp_f2 * temp_f12) - (temp_f14 * temp_f16)) / 0.0; - arg0->unk5C = ((temp_f14 * temp_f18) - (temp_f20 * temp_f12)) / 0.0; - arg0->unk60 = ((temp_f20 * temp_f16) - (temp_f2 * temp_f18)) / 0.0; + player->unk_058 = (f32) ((f64) (f32) ((temp_f2 * temp_f12) - (temp_f14 * temp_f16)) / 0.0); + player->unk_05C = (f32) ((f64) (f32) ((temp_f14 * temp_f18) - (temp_f20 * temp_f12)) / 0.0); + player->unk_060 = (f32) ((f64) (f32) ((temp_f20 * temp_f16) - (temp_f2 * temp_f18)) / 0.0); } #else GLOBAL_ASM("asm/non_matchings/math_util/func_802B8614.s") diff --git a/src/memory.c b/src/memory.c index 76a77629b..bb9aefec2 100644 --- a/src/memory.c +++ b/src/memory.c @@ -4438,16 +4438,21 @@ GLOBAL_ASM("asm/non_matchings/memory/func_802AF9F0.s") #endif #ifdef MIPS_TO_C -//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307 -f32 func_802ABE30(f32, f32, f32, u16); // extern -s32 func_802AC760(s16 *, f32, f32, f32, f32, s32, f32, f32, f32); // extern -s32 func_802ACBA4(s16 *, f32, f32, f32, f32, s32, f32, f32, f32); // extern -s32 func_802AD278(s16 *, f32, f32, f32, f32, s32, f32, f32, f32); // extern -? func_802AF9F0(f32, ? *, ?32, void *); // extern +//generated by mips_to_c commit 792017ad9d422c2467bd42686f383a5c41f41c75 +f32 func_802ABE30(f32, f32, f32, u16); /* extern */ +s32 func_802AC760(s16 *, f32, f32, f32, f32, s32, f32, f32, f32); /* extern */ +s32 func_802ACBA4(s16 *, f32, f32, f32, f32, s32, f32, f32, f32); /* extern */ +s32 func_802AD278(s16 *, f32, f32, f32, f32, s32, f32, f32, f32); /* extern */ +? func_802AF9F0(f32, ? *, ?32, kartBoundingBoxCorner *); /* extern */ extern ? D_8014F110; +extern s32 D_8015F580; extern s32 D_8015F584; +extern s16 D_8015F6E8; +extern s16 D_8015F6EA; +extern s16 D_8015F6F0; +extern s16 D_8015F6F2; -? func_802AFA34(void *arg0, void *arg1, f32 arg2, f32 arg3, f32 arg4) { +s32 func_802AFA34(Player *player, kartBoundingBoxCorner *corner, f32 cornerX, f32 cornerY, f32 cornerZ) { ? sp128; ? sp11C; ? sp110; @@ -4498,17 +4503,17 @@ extern s32 D_8015F584; sp104 = 0x447A0000; sp108 = 0x447A0000; sp10C = 0x447A0000; - temp_f20 = arg0->unk70; + temp_f20 = player->unk_070; spFE = 0x1388; sp100 = 0x1388; sp102 = 0x1388; spF8 = 0; spFA = 0; spFC = 0; - temp_v0 = arg1->unkD; - temp_f22 = arg1->unk0; - temp_f24 = arg1->unk4; - temp_f26 = arg1->unk8; + temp_v0 = corner->unk_0D; + temp_f22 = corner->cornerX; + temp_f24 = corner->cornerY; + temp_f26 = corner->cornerZ; if (temp_v0 != 0) { phi_s7 = &spF8; if (temp_v0 != 0x20) { @@ -4518,26 +4523,38 @@ extern s32 D_8015F584; if (temp_v0 != 0x80) { goto block_21; } - if ((func_802AD278(&spF8, temp_f20, temp_f22, temp_f24, temp_f26, arg1->unkE, arg2, arg3, arg4) == 1) && (temp_f0 = func_802ABE30(temp_f22, temp_f24, temp_f26, arg1->unkE), temp_f2 = arg0->unk18, !(temp_f2 < temp_f0)) && !((2.0f * temp_f20) < (temp_f2 - temp_f0))) { - arg1->unk10 = temp_f0; - func_802AF9F0(temp_f0, &sp11C, sp108, arg1); - return 1; + if (func_802AD278(&spF8, temp_f20, temp_f22, temp_f24, temp_f26, (s32) corner->tileIndex, cornerX, cornerY, cornerZ) == 1) { + temp_f0 = func_802ABE30(temp_f22, temp_f24, temp_f26, corner->tileIndex); + temp_f2 = player->posY; + if (!(temp_f2 < temp_f0) && !((2.0f * temp_f20) < (temp_f2 - temp_f0))) { + corner->cornerGroundY = temp_f0; + func_802AF9F0(temp_f0, &sp11C, sp108, corner); + return 1; + } } phi_f30 = 2.0f; goto block_22; } - if ((func_802AC760(&spF8, temp_f20, temp_f22, temp_f24, temp_f26, arg1->unkE, arg2, arg3, arg4) == 1) && (temp_f0_2 = func_802ABE30(temp_f22, temp_f24, temp_f26, arg1->unkE), temp_f2_2 = arg0->unk18, !(temp_f2_2 < temp_f0_2)) && !((2.0f * temp_f20) < (temp_f2_2 - temp_f0_2))) { - arg1->unk10 = temp_f0_2; - func_802AF9F0(temp_f0_2, &sp128, sp10C, arg1); - return 1; + if (func_802AC760(&spF8, temp_f20, temp_f22, temp_f24, temp_f26, (s32) corner->tileIndex, cornerX, cornerY, cornerZ) == 1) { + temp_f0_2 = func_802ABE30(temp_f22, temp_f24, temp_f26, corner->tileIndex); + temp_f2_2 = player->posY; + if (!(temp_f2_2 < temp_f0_2) && !((2.0f * temp_f20) < (temp_f2_2 - temp_f0_2))) { + corner->cornerGroundY = temp_f0_2; + func_802AF9F0(temp_f0_2, &sp128, sp10C, corner); + return 1; + } } phi_f30 = 2.0f; goto block_22; } - if ((func_802ACBA4(&spF8, temp_f20, temp_f22, temp_f24, temp_f26, arg1->unkE, arg2, arg3, arg4) == 1) && (temp_f0_3 = func_802ABE30(temp_f22, temp_f24, temp_f26, arg1->unkE), temp_f2_3 = arg0->unk18, !(temp_f2_3 < temp_f0_3)) && !((2.0f * temp_f20) < (temp_f2_3 - temp_f0_3))) { - arg1->unk10 = temp_f0_3; - func_802AF9F0(temp_f0_3, &sp110, sp104, arg1); - return 1; + if (func_802ACBA4(&spF8, temp_f20, temp_f22, temp_f24, temp_f26, (s32) corner->tileIndex, cornerX, cornerY, cornerZ) == 1) { + temp_f0_3 = func_802ABE30(temp_f22, temp_f24, temp_f26, corner->tileIndex); + temp_f2_3 = player->posY; + if (!(temp_f2_3 < temp_f0_3) && !((2.0f * temp_f20) < (temp_f2_3 - temp_f0_3))) { + corner->cornerGroundY = temp_f0_3; + func_802AF9F0(temp_f0_3, &sp110, sp104, corner); + return 1; + } } phi_f30 = 2.0f; goto block_22; @@ -4548,23 +4565,23 @@ block_21: block_22: temp_v0_2 = D_8015F6EA; temp_v1 = D_8015F6F2; - temp_f10 = (temp_f22 - temp_v0_2) / ((D_8015F6E8 - temp_v0_2) / 0x20); - temp_f16 = (temp_f26 - temp_v1) / ((D_8015F6F0 - temp_v1) / 0x20); - if (temp_f10 < 0) { + temp_f10 = (s32) ((temp_f22 - (f32) temp_v0_2) / (f32) ((s32) (D_8015F6E8 - temp_v0_2) / 32)); + temp_f16 = (s32) ((temp_f26 - (f32) temp_v1) / (f32) ((s32) (D_8015F6F0 - temp_v1) / 32)); + if ((s32) (s16) temp_f10 < 0) { goto block_57; } - if (temp_f16 < 0) { + if ((s32) (s16) temp_f16 < 0) { goto block_57; } - if (temp_f10 >= 0x20) { + if ((s32) (s16) temp_f10 >= 0x20) { goto block_57; } - if (temp_f16 >= 0x20) { + if ((s32) (s16) temp_f16 >= 0x20) { goto block_57; } - temp_v1_2 = ((temp_f10 + (temp_f16 << 5)) * 4) + &D_8014F110; + temp_v1_2 = ((s16) ((s16) temp_f10 + ((s16) temp_f16 << 5)) * 4) + &D_8014F110; temp_v0_3 = temp_v1_2->unk2; - sp8C = temp_v0_3; + sp8C = (s32) temp_v0_3; if (temp_v0_3 == 0) { goto block_57; } @@ -4577,41 +4594,53 @@ loop_34: temp_v0_4 = D_8015F580 + temp_s4; temp_v1_3 = temp_v0_4->unk0; if ((temp_v1_3 & 0x4000) != 0) { - if ((arg1->unkE != temp_s0) && (func_802AC760(phi_s7, temp_f20, temp_f22, temp_f24, temp_f26, temp_s0, arg2, arg3, arg4) == 1) && (temp_f0_4 = func_802ABE30(temp_f22, temp_f24, temp_f26, temp_s0 & 0xFFFF), temp_f2_4 = arg0->unk18, !(temp_f2_4 < temp_f0_4)) && !((phi_f30 * temp_f20) < (temp_f2_4 - temp_f0_4))) { - spD4 = temp_f0_4; - func_802AF9F0(temp_f0_4, &sp128, sp10C, arg1); - arg1->unk10 = temp_f0_4; - arg1->unkD = 0x40; - arg1->unkE = temp_s0; - arg1->unkC = (D_8015F580 + temp_s4)->unk2; - if ((*(D_8015F580 + temp_s4) & 0x1000) != 0) { - arg1->unk14 = 1; + if ((corner->tileIndex != temp_s0) && (func_802AC760(phi_s7, temp_f20, temp_f22, temp_f24, temp_f26, (s32) temp_s0, cornerX, cornerY, cornerZ) == 1)) { + temp_f0_4 = func_802ABE30(temp_f22, temp_f24, temp_f26, temp_s0 & 0xFFFF); + temp_f2_4 = player->posY; + if (!(temp_f2_4 < temp_f0_4) && !((phi_f30 * temp_f20) < (temp_f2_4 - temp_f0_4))) { + spD4 = temp_f0_4; + func_802AF9F0(temp_f0_4, &sp128, sp10C, corner); + corner->cornerGroundY = spD4; + corner->unk_0D = 0x40; + corner->tileIndex = temp_s0; + corner->surfaceType = (u8) (D_8015F580 + temp_s4)->unk2; + if ((*(D_8015F580 + temp_s4) & 0x1000) != 0) { + corner->unk_14 = 1; + return 1; + } + corner->unk_14 = 0; return 1; } - arg1->unk14 = 0; - return 1; } goto block_55; } if ((temp_v1_3 & 0x8000) != 0) { - if ((temp_v0_4->unk20 != 0.0f) && (arg1->unkE != temp_s0) && (func_802AD278(phi_s7, temp_f20, temp_f22, temp_f24, temp_f26, temp_s0, arg2, arg3, arg4) == 1) && (temp_f0_5 = func_802ABE30(temp_f22, temp_f24, temp_f26, temp_s0 & 0xFFFF), temp_f2_5 = arg0->unk18, !(temp_f2_5 < temp_f0_5)) && !((phi_f30 * temp_f20) < (temp_f2_5 - temp_f0_5))) { - arg1->unk10 = temp_f0_5; - func_802AF9F0(temp_f0_5, &sp11C, sp108, arg1); - arg1->unk10 = func_802ABE30(temp_f22, temp_f24, temp_f26, temp_s0 & 0xFFFF); - arg1->unkD = 0x80; - arg1->unkE = temp_s0; - arg1->unkC = (D_8015F580 + temp_s4)->unk2; - return 1; + if ((temp_v0_4->unk20 != 0.0f) && (corner->tileIndex != temp_s0) && (func_802AD278(phi_s7, temp_f20, temp_f22, temp_f24, temp_f26, (s32) temp_s0, cornerX, cornerY, cornerZ) == 1)) { + temp_f0_5 = func_802ABE30(temp_f22, temp_f24, temp_f26, temp_s0 & 0xFFFF); + temp_f2_5 = player->posY; + if (!(temp_f2_5 < temp_f0_5) && !((phi_f30 * temp_f20) < (temp_f2_5 - temp_f0_5))) { + corner->cornerGroundY = temp_f0_5; + func_802AF9F0(temp_f0_5, &sp11C, sp108, corner); + corner->cornerGroundY = func_802ABE30(temp_f22, temp_f24, temp_f26, temp_s0 & 0xFFFF); + corner->unk_0D = 0x80; + corner->tileIndex = temp_s0; + corner->surfaceType = (u8) (D_8015F580 + temp_s4)->unk2; + return 1; + } } goto block_55; } - if ((temp_v0_4->unk20 != 0.0f) && (arg1->unkE != temp_s0) && (func_802ACBA4(phi_s7, temp_f20, temp_f22, temp_f24, temp_f26, temp_s0, arg2, arg3, arg4) == 1) && (temp_f0_6 = func_802ABE30(temp_f22, temp_f24, temp_f26, temp_s0 & 0xFFFF), temp_f2_6 = arg0->unk18, !(temp_f2_6 < temp_f0_6)) && !((phi_f30 * temp_f20) < (temp_f2_6 - temp_f0_6))) { - arg1->unk10 = temp_f0_6; - func_802AF9F0(temp_f0_6, &sp110, sp104, arg1); - arg1->unkD = 0x20; - arg1->unkE = temp_s0; - arg1->unkC = (D_8015F580 + temp_s4)->unk2; - return 1; + if ((temp_v0_4->unk20 != 0.0f) && (corner->tileIndex != temp_s0) && (func_802ACBA4(phi_s7, temp_f20, temp_f22, temp_f24, temp_f26, (s32) temp_s0, cornerX, cornerY, cornerZ) == 1)) { + temp_f0_6 = func_802ABE30(temp_f22, temp_f24, temp_f26, temp_s0 & 0xFFFF); + temp_f2_6 = player->posY; + if (!(temp_f2_6 < temp_f0_6) && !((phi_f30 * temp_f20) < (temp_f2_6 - temp_f0_6))) { + corner->cornerGroundY = temp_f0_6; + func_802AF9F0(temp_f0_6, &sp110, sp104, corner); + corner->unk_0D = 0x20; + corner->tileIndex = temp_s0; + corner->surfaceType = (u8) (D_8015F580 + temp_s4)->unk2; + return 1; + } } block_55: temp_t6 = (phi_s2 + 1) & 0xFFFF; @@ -4623,8 +4652,8 @@ block_55: goto loop_34; } block_56: - arg1->unk10 = temp_f24; - arg1->unkC = 0; + corner->cornerGroundY = temp_f24; + corner->surfaceType = 0; block_57: return 0; } diff --git a/src/staff_ghosts.c b/src/staff_ghosts.c index 55c828ad3..ee276d892 100644 --- a/src/staff_ghosts.c +++ b/src/staff_ghosts.c @@ -67,7 +67,7 @@ extern s16 gCurrentCourseId; extern s32 gModeSelection; extern s32 gActiveScreenMode; extern u16 D_8015F890; -extern s32 lapCount[]; +extern s32 gLapCountByPlayerId[]; extern s32 D_8018CA78; extern Player *gPlayerOne; @@ -489,9 +489,9 @@ void func_80005B18(void) { u16 *phi_a3; if (gModeSelection == TIME_TRIALS) { - temp_v0 = lapCount[0]; + temp_v0 = gLapCountByPlayerId[0]; //phi_a3 = &D_80162DD4; - if ((lapCount[0] == 3) && (D_80162DDC == 0) && D_80162DF8 != 1) { + if ((gLapCountByPlayerId[0] == 3) && (D_80162DDC == 0) && D_80162DF8 != 1) { //if (D_80162DF8 != 1) { if (D_80162DD4 == 1) { @@ -507,7 +507,7 @@ void func_80005B18(void) { func_80005AE8(gPlayerThree); } else { - if (lapCount[4] != 3) { + if (gLapCountByPlayerId[4] != 3) { D_80162DD0 = D_80162DCC; func_800052A4(); // gModeSelection, &D_80162DDC, 3, &D_80162DD4); D_80162DDC = 1; @@ -534,7 +534,7 @@ void func_80005B18(void) { return; } - if ((lapCount[0] == 3) && (D_80162DDC == 0) && (D_80162DF8 == 1)) { + if ((gLapCountByPlayerId[0] == 3) && (D_80162DDC == 0) && (D_80162DF8 == 1)) { D_80162D80 = (void *) ((D_80162DC8 << 0xF) + 0x3000 + &D_802BFB80); D_80162D84 = D_80162D86; D_80162DDC = 1; @@ -549,10 +549,10 @@ void func_80005B18(void) { D_80162DEC = 100; } if ((gModeSelection == TIME_TRIALS) && (gActiveScreenMode == 0)) { - if ((D_80162DD4 == 0) && (lapCount[4] != 3)) { + if ((D_80162DD4 == 0) && (gLapCountByPlayerId[4] != 3)) { func_800057DC(); //gModeSelection, &D_80162DDC, 3, &D_80162DD4); } - if ((D_80162DD6 == 0) && (3 != lapCount[8])) { + if ((D_80162DD6 == 0) && (3 != gLapCountByPlayerId[8])) { func_8000561C(); } if (( gPlayerOne->unk_000 & PLAYER_CINEMATIC_MODE) == 0) {