diff --git a/Makefile b/Makefile index 1c40caaf8d..849e379246 100644 --- a/Makefile +++ b/Makefile @@ -244,7 +244,7 @@ include $(MAKEFILE_SPLIT) # These are files that need to be encoded into EUC-JP in order for the ROM to match # We filter them out from the regular C_FILES since we don't need nor want the # UTF-8 versions getting compiled -EUC_JP_FILES := src/ending/credits.c src/code_80005FD0.c src/menu_items.c +EUC_JP_FILES := src/ending/credits.c src/cpu_vehicles_camera_path.c src/menu_items.c C_FILES := $(filter-out %.inc.c,$(filter-out $(EUC_JP_FILES),$(foreach dir,$(SRC_DIRS),$(wildcard $(dir)/*.c)))) S_FILES := $(foreach dir,$(ASM_DIRS),$(wildcard $(dir)/*.s)) # Include source files in courses/course_name/files.c but exclude .inc.c files. diff --git a/asm/non_matchings/code_80005FD0/kart_ai_use_item_strategy.s b/asm/non_matchings/cpu_vehicles_camera_path/cpu_use_item_strategy.s similarity index 96% rename from asm/non_matchings/code_80005FD0/kart_ai_use_item_strategy.s rename to asm/non_matchings/cpu_vehicles_camera_path/cpu_use_item_strategy.s index 6e1f08c5ac..e7def57c8f 100644 --- a/asm/non_matchings/code_80005FD0/kart_ai_use_item_strategy.s +++ b/asm/non_matchings/cpu_vehicles_camera_path/cpu_use_item_strategy.s @@ -21,7 +21,7 @@ glabel jpt_800ED4A0 .section .text -glabel kart_ai_use_item_strategy +glabel cpu_use_item_strategy /* 01B810 8001AC10 000478C0 */ sll $t7, $a0, 3 /* 01B814 8001AC14 01E47823 */ subu $t7, $t7, $a0 /* 01B818 8001AC18 000F7900 */ sll $t7, $t7, 4 @@ -46,8 +46,8 @@ glabel kart_ai_use_item_strategy /* 01B864 8001AC64 510C0480 */ beql $t0, $t4, .L8001BE68 /* 01B868 8001AC68 8FBF0024 */ lw $ra, 0x24($sp) /* 01B86C 8001AC6C 972E0000 */ lhu $t6, ($t9) -/* 01B870 8001AC70 3C0B8016 */ lui $t3, %hi(D_801642D8) # $t3, 0x8016 -/* 01B874 8001AC74 256B42D8 */ addiu $t3, %lo(D_801642D8) # addiu $t3, $t3, 0x42d8 +/* 01B870 8001AC70 3C0B8016 */ lui $t3, %hi(cpu_ItemStrategy) # $t3, 0x8016 +/* 01B874 8001AC74 256B42D8 */ addiu $t3, %lo(cpu_ItemStrategy) # addiu $t3, $t3, 0x42d8 /* 01B878 8001AC78 31CF0800 */ andi $t7, $t6, 0x800 /* 01B87C 8001AC7C 15E00479 */ bnez $t7, .L8001BE64 /* 01B880 8001AC80 0004C900 */ sll $t9, $a0, 4 @@ -65,12 +65,12 @@ glabel L8001ACAC /* 01B8AC 8001ACAC 2405FFFF */ li $a1, -1 /* 01B8B0 8001ACB0 A6050002 */ sh $a1, 2($s0) /* 01B8B4 8001ACB4 8FAD0030 */ lw $t5, 0x30($sp) -/* 01B8B8 8001ACB8 3C0E8016 */ lui $t6, %hi(D_80164450) # 0x8016 +/* 01B8B8 8001ACB8 3C0E8016 */ lui $t6, %hi(gNumPathPointsTraversed) # 0x8016 /* 01B8BC 8001ACBC 8FA40030 */ lw $a0, 0x30($sp) /* 01B8C0 8001ACC0 000D1080 */ sll $v0, $t5, 2 /* 01B8C4 8001ACC4 01C27021 */ addu $t6, $t6, $v0 /* 01B8C8 8001ACC8 000D7880 */ sll $t7, $t5, 2 -/* 01B8CC 8001ACCC 8DCE4450 */ lw $t6, %lo(D_80164450)($t6) # 0x4450($t6) +/* 01B8CC 8001ACCC 8DCE4450 */ lw $t6, %lo(gNumPathPointsTraversed)($t6) # 0x4450($t6) /* 01B8D0 8001ACD0 01ED7821 */ addu $t7, $t7, $t5 /* 01B8D4 8001ACD4 000F7880 */ sll $t7, $t7, 2 /* 01B8D8 8001ACD8 25F80064 */ addiu $t8, $t7, 0x64 @@ -96,11 +96,11 @@ glabel L8001ACAC /* 01B928 8001AD28 00032400 */ sll $a0, $v1, 0x10 /* 01B92C 8001AD2C 00046403 */ sra $t4, $a0, 0x10 /* 01B930 8001AD30 01802025 */ move $a0, $t4 -/* 01B934 8001AD34 0C01EBDE */ jal kart_ai_gen_random_item +/* 01B934 8001AD34 0C01EBDE */ jal cpu_gen_random_item /* 01B938 8001AD38 85A50002 */ lh $a1, 2($t5) /* 01B93C 8001AD3C 8FA40030 */ lw $a0, 0x30($sp) /* 01B940 8001AD40 02002825 */ move $a1, $s0 -/* 01B944 8001AD44 0C006ADD */ jal kart_ai_decisions_branch_item +/* 01B944 8001AD44 0C006ADD */ jal cpu_decisions_branch_item /* 01B948 8001AD48 00403025 */ move $a2, $v0 /* 01B94C 8001AD4C 10000003 */ b .L8001AD5C /* 01B950 8001AD50 00000000 */ nop @@ -118,10 +118,10 @@ glabel L8001AD64 /* 01B974 8001AD74 01CF7021 */ addu $t6, $t6, $t7 /* 01B978 8001AD78 8DCE4390 */ lw $t6, %lo(gLapCountByPlayerId)($t6) # 0x4390($t6) /* 01B97C 8001AD7C 24C643B8 */ addiu $a2, %lo(gGPCurrentRaceRankByPlayerId) # addiu $a2, $a2, 0x43b8 -/* 01B980 8001AD80 3C038016 */ lui $v1, %hi(D_80163478) # $v1, 0x8016 +/* 01B980 8001AD80 3C038016 */ lui $v1, %hi(gBestRankedHumanPlayer) # $v1, 0x8016 /* 01B984 8001AD84 19C0004B */ blez $t6, .L8001AEB4 /* 01B988 8001AD88 00000000 */ nop -/* 01B98C 8001AD8C 84633478 */ lh $v1, %lo(D_80163478)($v1) +/* 01B98C 8001AD8C 84633478 */ lh $v1, %lo(gBestRankedHumanPlayer)($v1) /* 01B990 8001AD90 00CF5821 */ addu $t3, $a2, $t7 /* 01B994 8001AD94 8D6C0000 */ lw $t4, ($t3) /* 01B998 8001AD98 0003C080 */ sll $t8, $v1, 2 @@ -134,27 +134,27 @@ glabel L8001AD64 /* 01B9B4 8001ADB4 8FAD002C */ lw $t5, 0x2c($sp) /* 01B9B8 8001ADB8 95A20254 */ lhu $v0, 0x254($t5) /* 01B9BC 8001ADBC 24010004 */ li $at, 4 -/* 01B9C0 8001ADC0 3C088016 */ lui $t0, %hi(gNearestWaypointByPlayerId) # $t0, 0x8016 +/* 01B9C0 8001ADC0 3C088016 */ lui $t0, %hi(gNearestPathPointByPlayerId) # $t0, 0x8016 /* 01B9C4 8001ADC4 10410006 */ beq $v0, $at, .L8001ADE0 -/* 01B9C8 8001ADC8 25084438 */ addiu $t0, %lo(gNearestWaypointByPlayerId) # addiu $t0, $t0, 0x4438 +/* 01B9C8 8001ADC8 25084438 */ addiu $t0, %lo(gNearestPathPointByPlayerId) # addiu $t0, $t0, 0x4438 /* 01B9CC 8001ADCC 24060006 */ li $a2, 6 /* 01B9D0 8001ADD0 10460014 */ beq $v0, $a2, .L8001AE24 -/* 01B9D4 8001ADD4 3C088016 */ lui $t0, %hi(gNearestWaypointByPlayerId) # 0x8016 +/* 01B9D4 8001ADD4 3C088016 */ lui $t0, %hi(gNearestPathPointByPlayerId) # 0x8016 /* 01B9D8 8001ADD8 10000024 */ b .L8001AE6C -/* 01B9DC 8001ADDC 3C088016 */ lui $t0, %hi(gNearestWaypointByPlayerId) # $t0, 0x8016 +/* 01B9DC 8001ADDC 3C088016 */ lui $t0, %hi(gNearestPathPointByPlayerId) # $t0, 0x8016 .L8001ADE0: /* 01B9E0 8001ADE0 8FAF0030 */ lw $t7, 0x30($sp) /* 01B9E4 8001ADE4 0003C840 */ sll $t9, $v1, 1 -/* 01B9E8 8001ADE8 3C0C8016 */ lui $t4, %hi(D_80164430) # $t4, 0x8016 +/* 01B9E8 8001ADE8 3C0C8016 */ lui $t4, %hi(gSelectedPathCount) # $t4, 0x8016 /* 01B9EC 8001ADEC 000F7040 */ sll $t6, $t7, 1 -/* 01B9F0 8001ADF0 958C4430 */ lhu $t4, %lo(D_80164430)($t4) +/* 01B9F0 8001ADF0 958C4430 */ lhu $t4, %lo(gSelectedPathCount)($t4) /* 01B9F4 8001ADF4 010EC021 */ addu $t8, $t0, $t6 /* 01B9F8 8001ADF8 01195821 */ addu $t3, $t0, $t9 /* 01B9FC 8001ADFC 95650000 */ lhu $a1, ($t3) /* 01BA00 8001AE00 97040000 */ lhu $a0, ($t8) /* 01BA04 8001AE04 24060028 */ li $a2, 40 /* 01BA08 8001AE08 24070002 */ li $a3, 2 -/* 01BA0C 8001AE0C 0C001EFE */ jal func_80007BF8 +/* 01BA0C 8001AE0C 0C001EFE */ jal is_path_point_in_range /* 01BA10 8001AE10 AFAC0010 */ sw $t4, 0x10($sp) /* 01BA14 8001AE14 18400045 */ blez $v0, .L8001AF2C /* 01BA18 8001AE18 240D0022 */ li $t5, 34 @@ -162,18 +162,18 @@ glabel L8001AD64 /* 01BA20 8001AE20 A60D0000 */ sh $t5, ($s0) .L8001AE24: /* 01BA24 8001AE24 8FAF0030 */ lw $t7, 0x30($sp) -/* 01BA28 8001AE28 25084438 */ addiu $t0, %lo(gNearestWaypointByPlayerId) # addiu $t0, $t0, 0x4438 +/* 01BA28 8001AE28 25084438 */ addiu $t0, %lo(gNearestPathPointByPlayerId) # addiu $t0, $t0, 0x4438 /* 01BA2C 8001AE2C 0003C840 */ sll $t9, $v1, 1 -/* 01BA30 8001AE30 3C0C8016 */ lui $t4, %hi(D_80164430) # $t4, 0x8016 +/* 01BA30 8001AE30 3C0C8016 */ lui $t4, %hi(gSelectedPathCount) # $t4, 0x8016 /* 01BA34 8001AE34 000F7040 */ sll $t6, $t7, 1 -/* 01BA38 8001AE38 958C4430 */ lhu $t4, %lo(D_80164430)($t4) +/* 01BA38 8001AE38 958C4430 */ lhu $t4, %lo(gSelectedPathCount)($t4) /* 01BA3C 8001AE3C 010EC021 */ addu $t8, $t0, $t6 /* 01BA40 8001AE40 01195821 */ addu $t3, $t0, $t9 /* 01BA44 8001AE44 95650000 */ lhu $a1, ($t3) /* 01BA48 8001AE48 97040000 */ lhu $a0, ($t8) /* 01BA4C 8001AE4C 24060004 */ li $a2, 4 /* 01BA50 8001AE50 24070002 */ li $a3, 2 -/* 01BA54 8001AE54 0C001EFE */ jal func_80007BF8 +/* 01BA54 8001AE54 0C001EFE */ jal is_path_point_in_range /* 01BA58 8001AE58 AFAC0010 */ sw $t4, 0x10($sp) /* 01BA5C 8001AE5C 18400033 */ blez $v0, .L8001AF2C /* 01BA60 8001AE60 240D0022 */ li $t5, 34 @@ -181,18 +181,18 @@ glabel L8001AD64 /* 01BA68 8001AE68 A60D0000 */ sh $t5, ($s0) .L8001AE6C: /* 01BA6C 8001AE6C 8FAF0030 */ lw $t7, 0x30($sp) -/* 01BA70 8001AE70 25084438 */ addiu $t0, $t0, %lo(gNearestWaypointByPlayerId) # 0x4438 +/* 01BA70 8001AE70 25084438 */ addiu $t0, $t0, %lo(gNearestPathPointByPlayerId) # 0x4438 /* 01BA74 8001AE74 0003C840 */ sll $t9, $v1, 1 -/* 01BA78 8001AE78 3C0C8016 */ lui $t4, %hi(D_80164430) # $t4, 0x8016 +/* 01BA78 8001AE78 3C0C8016 */ lui $t4, %hi(gSelectedPathCount) # $t4, 0x8016 /* 01BA7C 8001AE7C 000F7040 */ sll $t6, $t7, 1 -/* 01BA80 8001AE80 958C4430 */ lhu $t4, %lo(D_80164430)($t4) +/* 01BA80 8001AE80 958C4430 */ lhu $t4, %lo(gSelectedPathCount)($t4) /* 01BA84 8001AE84 010EC021 */ addu $t8, $t0, $t6 /* 01BA88 8001AE88 01195821 */ addu $t3, $t0, $t9 /* 01BA8C 8001AE8C 95650000 */ lhu $a1, ($t3) /* 01BA90 8001AE90 97040000 */ lhu $a0, ($t8) /* 01BA94 8001AE94 2406000A */ li $a2, 10 /* 01BA98 8001AE98 24070002 */ li $a3, 2 -/* 01BA9C 8001AE9C 0C001EFE */ jal func_80007BF8 +/* 01BA9C 8001AE9C 0C001EFE */ jal is_path_point_in_range /* 01BAA0 8001AEA0 AFAC0010 */ sw $t4, 0x10($sp) /* 01BAA4 8001AEA4 18400021 */ blez $v0, .L8001AF2C /* 01BAA8 8001AEA8 240D0022 */ li $t5, 34 @@ -359,7 +359,7 @@ glabel L8001B0EC /* 01BD00 8001B100 0460006C */ bltz $v1, .L8001B2B4 /* 01BD04 8001B104 28610064 */ slti $at, $v1, 0x64 /* 01BD08 8001B108 1020006A */ beqz $at, .L8001B2B4 -/* 01BD0C 8001B10C 3C088016 */ lui $t0, %hi(gNearestWaypointByPlayerId) # $t0, 0x8016 +/* 01BD0C 8001B10C 3C088016 */ lui $t0, %hi(gNearestPathPointByPlayerId) # $t0, 0x8016 /* 01BD10 8001B110 0003C8C0 */ sll $t9, $v1, 3 /* 01BD14 8001B114 0323C823 */ subu $t9, $t9, $v1 /* 01BD18 8001B118 3C0B8016 */ lui $t3, %hi(gActorList) # $t3, 0x8016 @@ -381,9 +381,9 @@ glabel L8001B0EC /* 01BD58 8001B158 A6000004 */ sh $zero, 4($s0) /* 01BD5C 8001B15C 272B0001 */ addiu $t3, $t9, 1 /* 01BD60 8001B160 A60B0006 */ sh $t3, 6($s0) -/* 01BD64 8001B164 3C068016 */ lui $a2, %hi(D_80163478) # $a2, 0x8016 -/* 01BD68 8001B168 84C63478 */ lh $a2, %lo(D_80163478)($a2) -/* 01BD6C 8001B16C 25084438 */ addiu $t0, %lo(gNearestWaypointByPlayerId) # addiu $t0, $t0, 0x4438 +/* 01BD64 8001B164 3C068016 */ lui $a2, %hi(gBestRankedHumanPlayer) # $a2, 0x8016 +/* 01BD68 8001B168 84C63478 */ lh $a2, %lo(gBestRankedHumanPlayer)($a2) +/* 01BD6C 8001B16C 25084438 */ addiu $t0, %lo(gNearestPathPointByPlayerId) # addiu $t0, $t0, 0x4438 /* 01BD70 8001B170 3C098016 */ lui $t1, %hi(gPathIndexByPlayerId) # $t1, 0x8016 /* 01BD74 8001B174 00067840 */ sll $t7, $a2, 1 /* 01BD78 8001B178 010F7021 */ addu $t6, $t0, $t7 @@ -393,16 +393,16 @@ glabel L8001B0EC /* 01BD88 8001B188 95B90000 */ lhu $t9, ($t5) /* 01BD8C 8001B18C 270C001E */ addiu $t4, $t8, 0x1e /* 01BD90 8001B190 01E03025 */ move $a2, $t7 -/* 01BD94 8001B194 3C0F8016 */ lui $t7, %hi(gWaypointCountByPathIndex) # 0x8016 +/* 01BD94 8001B194 3C0F8016 */ lui $t7, %hi(gPathCountByPathIndex) # 0x8016 /* 01BD98 8001B198 00195840 */ sll $t3, $t9, 1 /* 01BD9C 8001B19C 01EB7821 */ addu $t7, $t7, $t3 -/* 01BDA0 8001B1A0 95EF45C8 */ lhu $t7, %lo(gWaypointCountByPathIndex)($t7) # 0x45c8($t7) +/* 01BDA0 8001B1A0 95EF45C8 */ lhu $t7, %lo(gPathCountByPathIndex)($t7) # 0x45c8($t7) /* 01BDA4 8001B1A4 952D0000 */ lhu $t5, ($t1) -/* 01BDA8 8001B1A8 3C0B8016 */ lui $t3, %hi(D_80164550) # 0x8016 +/* 01BDA8 8001B1A8 3C0B8016 */ lui $t3, %hi(gTrackPaths) # 0x8016 /* 01BDAC 8001B1AC 018F001A */ div $zero, $t4, $t7 /* 01BDB0 8001B1B0 000DC880 */ sll $t9, $t5, 2 /* 01BDB4 8001B1B4 01795821 */ addu $t3, $t3, $t9 -/* 01BDB8 8001B1B8 8D6B4550 */ lw $t3, %lo(D_80164550)($t3) # 0x4550($t3) +/* 01BDB8 8001B1B8 8D6B4550 */ lw $t3, %lo(gTrackPaths)($t3) # 0x4550($t3) /* 01BDBC 8001B1BC 00007010 */ mfhi $t6 /* 01BDC0 8001B1C0 000EC0C0 */ sll $t8, $t6, 3 /* 01BDC4 8001B1C4 030B1021 */ addu $v0, $t8, $t3 @@ -782,7 +782,7 @@ glabel L8001B6AC /* 01C330 8001B730 100001C0 */ b .L8001BE34 /* 01C334 8001B734 86020004 */ lh $v0, 4($s0) glabel L8001B738 -/* 01C338 8001B738 0C006AFB */ jal func_8001ABEC +/* 01C338 8001B738 0C006AFB */ jal clear_expired_strategies /* 01C33C 8001B73C 02002025 */ move $a0, $s0 /* 01C340 8001B740 860D0002 */ lh $t5, 2($s0) /* 01C344 8001B744 3C0F8016 */ lui $t7, %hi(gActorList) # $t7, 0x8016 @@ -986,7 +986,7 @@ glabel L8001B9D0 /* 01C600 8001BA00 24790001 */ addiu $t9, $v1, 1 /* 01C604 8001BA04 54480005 */ bnel $v0, $t0, .L8001BA1C /* 01C608 8001BA08 24790001 */ addiu $t9, $v1, 1 -/* 01C60C 8001BA0C 0C0AC192 */ jal func_802B0648 +/* 01C60C 8001BA0C 0C0AC192 */ jal drop_banana_in_banana_bunch /* 01C610 8001BA10 00E02025 */ move $a0, $a3 /* 01C614 8001BA14 86030008 */ lh $v1, 8($s0) /* 01C618 8001BA18 24790001 */ addiu $t9, $v1, 1 diff --git a/asm/non_matchings/code_80005FD0/func_800088D8.s b/asm/non_matchings/cpu_vehicles_camera_path/func_800088D8.s similarity index 95% rename from asm/non_matchings/code_80005FD0/func_800088D8.s rename to asm/non_matchings/cpu_vehicles_camera_path/func_800088D8.s index efa8f6b18c..c8f69b77b1 100644 --- a/asm/non_matchings/code_80005FD0/func_800088D8.s +++ b/asm/non_matchings/cpu_vehicles_camera_path/func_800088D8.s @@ -69,14 +69,14 @@ glabel func_800088D8 /* 0095D0 800089D0 03193821 */ addu $a3, $t8, $t9 /* 0095D4 800089D4 3C0E800E */ lui $t6, %hi(gDemoMode) /* 0095D8 800089D8 95CEC51C */ lhu $t6, %lo(gDemoMode)($t6) -/* 0095DC 800089DC 3C048016 */ lui $a0, %hi(D_80164450) # $a0, 0x8016 -/* 0095E0 800089E0 24844450 */ addiu $a0, %lo(D_80164450) # addiu $a0, $a0, 0x4450 +/* 0095DC 800089DC 3C048016 */ lui $a0, %hi(gNumPathPointsTraversed) # $a0, 0x8016 +/* 0095E0 800089E0 24844450 */ addiu $a0, %lo(gNumPathPointsTraversed) # addiu $a0, $a0, 0x4450 /* 0095E4 800089E4 146E003A */ bne $v1, $t6, .L80008AD0 /* 0095E8 800089E8 0088C021 */ addu $t8, $a0, $t0 /* 0095EC 800089EC 3C188016 */ lui $t8, %hi(D_80164378 + 0xE) # $t8, 0x8016 /* 0095F0 800089F0 87184386 */ lh $t8, %lo(D_80164378 + 0xE)($t8) -/* 0095F4 800089F4 3C048016 */ lui $a0, %hi(D_80164450) # $a0, 0x8016 -/* 0095F8 800089F8 24844450 */ addiu $a0, %lo(D_80164450) # addiu $a0, $a0, 0x4450 +/* 0095F4 800089F4 3C048016 */ lui $a0, %hi(gNumPathPointsTraversed) # $a0, 0x8016 +/* 0095F8 800089F8 24844450 */ addiu $a0, %lo(gNumPathPointsTraversed) # addiu $a0, $a0, 0x4450 /* 0095FC 800089FC 0018C880 */ sll $t9, $t8, 2 /* 009600 80008A00 00887821 */ addu $t7, $a0, $t0 /* 009604 80008A04 00997021 */ addu $t6, $a0, $t9 @@ -134,14 +134,14 @@ glabel func_800088D8 /* 0096C8 80008AC8 100000BB */ b .L80008DB8 /* 0096CC 80008ACC 24020001 */ li $v0, 1 .L80008AD0: -/* 0096D0 80008AD0 3C0F8016 */ lui $t7, %hi(gWaypointCountByPathIndex) # $t7, 0x8016 -/* 0096D4 80008AD4 95EF45C8 */ lhu $t7, %lo(gWaypointCountByPathIndex)($t7) +/* 0096D0 80008AD0 3C0F8016 */ lui $t7, %hi(gPathCountByPathIndex) # $t7, 0x8016 +/* 0096D4 80008AD4 95EF45C8 */ lhu $t7, %lo(gPathCountByPathIndex)($t7) /* 0096D8 80008AD8 87020002 */ lh $v0, 2($t8) /* 0096DC 80008ADC 24010003 */ li $at, 3 /* 0096E0 80008AE0 000FC040 */ sll $t8, $t7, 1 /* 0096E4 80008AE4 0301001A */ div $zero, $t8, $at -/* 0096E8 80008AE8 3C0B8016 */ lui $t3, %hi(D_80163478) # $t3, 0x8016 -/* 0096EC 80008AEC 856B3478 */ lh $t3, %lo(D_80163478)($t3) +/* 0096E8 80008AE8 3C0B8016 */ lui $t3, %hi(gBestRankedHumanPlayer) # $t3, 0x8016 +/* 0096EC 80008AEC 856B3478 */ lh $t3, %lo(gBestRankedHumanPlayer)($t3) /* 0096F0 80008AF0 3C0D8016 */ lui $t5, %hi(gGPCurrentRaceRankByPlayerId + 0x2) # 0x8016 /* 0096F4 80008AF4 000BC880 */ sll $t9, $t3, 2 /* 0096F8 80008AF8 00997021 */ addu $t6, $a0, $t9 @@ -220,8 +220,8 @@ glabel func_800088D8 .L80008C08: /* 009808 80008C08 3C098016 */ lui $t1, %hi(D_80163344) # $t1, 0x8016 /* 00980C 80008C0C 85293344 */ lh $t1, %lo(D_80163344)($t1) -/* 009810 80008C10 3C048016 */ lui $a0, %hi(D_80164450) # $a0, 0x8016 -/* 009814 80008C14 24844450 */ addiu $a0, %lo(D_80164450) # addiu $a0, $a0, 0x4450 +/* 009810 80008C10 3C048016 */ lui $a0, %hi(gNumPathPointsTraversed) # $a0, 0x8016 +/* 009814 80008C14 24844450 */ addiu $a0, %lo(gNumPathPointsTraversed) # addiu $a0, $a0, 0x4450 /* 009818 80008C18 00097080 */ sll $t6, $t1, 2 /* 00981C 80008C1C 0088C821 */ addu $t9, $a0, $t0 /* 009820 80008C20 008E7821 */ addu $t7, $a0, $t6 diff --git a/asm/non_matchings/code_80005FD0/func_8000B140.s b/asm/non_matchings/cpu_vehicles_camera_path/func_8000B140.s similarity index 95% rename from asm/non_matchings/code_80005FD0/func_8000B140.s rename to asm/non_matchings/cpu_vehicles_camera_path/func_8000B140.s index 9089758eb4..f25d13ba2c 100644 --- a/asm/non_matchings/code_80005FD0/func_8000B140.s +++ b/asm/non_matchings/cpu_vehicles_camera_path/func_8000B140.s @@ -41,8 +41,8 @@ glabel func_8000B140 /* 00BDA8 8000B1A8 10410187 */ beq $v0, $at, .L8000B7C8 /* 00BDAC 8000B1AC 2406FFFF */ li $a2, -1 /* 00BDB0 8000B1B0 10C20185 */ beq $a2, $v0, .L8000B7C8 -/* 00BDB4 8000B1B4 3C0B8016 */ lui $t3, %hi(D_80163068) # $t3, 0x8016 -/* 00BDB8 8000B1B8 256B3068 */ addiu $t3, %lo(D_80163068) # addiu $t3, $t3, 0x3068 +/* 00BDB4 8000B1B4 3C0B8016 */ lui $t3, %hi(gTrackPositionFactor) # $t3, 0x8016 +/* 00BDB8 8000B1B8 256B3068 */ addiu $t3, %lo(gTrackPositionFactor) # addiu $t3, $t3, 0x3068 /* 00BDBC 8000B1BC 00047880 */ sll $t7, $a0, 2 /* 00BDC0 8000B1C0 016FC021 */ addu $t8, $t3, $t7 /* 00BDC4 8000B1C4 3C01BF80 */ li $at, 0xBF800000 # -1.000000 @@ -76,9 +76,9 @@ glabel func_8000B140 /* 00BE34 8000B234 3C014358 */ li $at, 0x43580000 # 216.000000 /* 00BE38 8000B238 44815000 */ mtc1 $at, $f10 /* 00BE3C 8000B23C 46062203 */ div.s $f8, $f4, $f6 -/* 00BE40 8000B240 3C098016 */ lui $t1, %hi(gNearestWaypointByPlayerId) # 0x8016 +/* 00BE40 8000B240 3C098016 */ lui $t1, %hi(gNearestPathPointByPlayerId) # 0x8016 /* 00BE44 8000B244 012D4821 */ addu $t1, $t1, $t5 -/* 00BE48 8000B248 85294438 */ lh $t1, %lo(gNearestWaypointByPlayerId)($t1) # 0x4438($t1) +/* 00BE48 8000B248 85294438 */ lh $t1, %lo(gNearestPathPointByPlayerId)($t1) # 0x4438($t1) /* 00BE4C 8000B24C 240303E8 */ li $v1, 1000 /* 00BE50 8000B250 27A5009C */ addiu $a1, $sp, 0x9c /* 00BE54 8000B254 27A200B0 */ addiu $v0, $sp, 0xb0 @@ -134,31 +134,31 @@ glabel func_8000B140 /* 00BF10 8000B310 44815000 */ mtc1 $at, $f10 /* 00BF14 8000B314 46062203 */ div.s $f8, $f4, $f6 /* 00BF18 8000B318 00087040 */ sll $t6, $t0, 1 -/* 00BF1C 8000B31C 3C038016 */ lui $v1, %hi(gNearestWaypointByPlayerId) # 0x8016 +/* 00BF1C 8000B31C 3C038016 */ lui $v1, %hi(gNearestPathPointByPlayerId) # 0x8016 /* 00BF20 8000B320 006E1821 */ addu $v1, $v1, $t6 /* 00BF24 8000B324 4614B081 */ sub.s $f2, $f22, $f20 -/* 00BF28 8000B328 84634438 */ lh $v1, %lo(gNearestWaypointByPlayerId)($v1) # 0x4438($v1) +/* 00BF28 8000B328 84634438 */ lh $v1, %lo(gNearestPathPointByPlayerId)($v1) # 0x4438($v1) /* 00BF2C 8000B32C 3125FFFF */ andi $a1, $t1, 0xffff /* 00BF30 8000B330 00003025 */ move $a2, $zero /* 00BF34 8000B334 24070014 */ li $a3, 20 -/* 00BF38 8000B338 3C0C8016 */ lui $t4, %hi(D_80164430) # $t4, 0x8016 +/* 00BF38 8000B338 3C0C8016 */ lui $t4, %hi(gSelectedPathCount) # $t4, 0x8016 /* 00BF3C 8000B33C 3064FFFF */ andi $a0, $v1, 0xffff /* 00BF40 8000B340 460A4002 */ mul.s $f0, $f8, $f10 /* 00BF44 8000B344 4602003C */ c.lt.s $f0, $f2 /* 00BF48 8000B348 00000000 */ nop /* 00BF4C 8000B34C 45020028 */ bc1fl .L8000B3F0 /* 00BF50 8000B350 29410002 */ slti $at, $t2, 2 -/* 00BF54 8000B354 958C4430 */ lhu $t4, %lo(D_80164430)($t4) +/* 00BF54 8000B354 958C4430 */ lhu $t4, %lo(gSelectedPathCount)($t4) /* 00BF58 8000B358 A7A300E4 */ sh $v1, 0xe4($sp) /* 00BF5C 8000B35C AFA800FC */ sw $t0, 0xfc($sp) /* 00BF60 8000B360 A7A900E6 */ sh $t1, 0xe6($sp) /* 00BF64 8000B364 AFAA00F0 */ sw $t2, 0xf0($sp) /* 00BF68 8000B368 E7A000DC */ swc1 $f0, 0xdc($sp) /* 00BF6C 8000B36C E7A20060 */ swc1 $f2, 0x60($sp) -/* 00BF70 8000B370 0C001EFE */ jal func_80007BF8 +/* 00BF70 8000B370 0C001EFE */ jal is_path_point_in_range /* 00BF74 8000B374 AFAC0010 */ sw $t4, 0x10($sp) -/* 00BF78 8000B378 3C0B8016 */ lui $t3, %hi(D_80163068) # $t3, 0x8016 -/* 00BF7C 8000B37C 256B3068 */ addiu $t3, %lo(D_80163068) # addiu $t3, $t3, 0x3068 +/* 00BF78 8000B378 3C0B8016 */ lui $t3, %hi(gTrackPositionFactor) # $t3, 0x8016 +/* 00BF7C 8000B37C 256B3068 */ addiu $t3, %lo(gTrackPositionFactor) # addiu $t3, $t3, 0x3068 /* 00BF80 8000B380 87A300E4 */ lh $v1, 0xe4($sp) /* 00BF84 8000B384 8FA800FC */ lw $t0, 0xfc($sp) /* 00BF88 8000B388 87A900E6 */ lh $t1, 0xe6($sp) @@ -179,8 +179,8 @@ glabel func_8000B140 /* 00BFC4 8000B3C4 10000006 */ b .L8000B3E0 /* 00BFC8 8000B3C8 A4C50000 */ sh $a1, ($a2) .L8000B3CC: -/* 00BFCC 8000B3CC 3C0E8016 */ lui $t6, %hi(D_80164430) # $t6, 0x8016 -/* 00BFD0 8000B3D0 95CE4430 */ lhu $t6, %lo(D_80164430)($t6) +/* 00BFCC 8000B3CC 3C0E8016 */ lui $t6, %hi(gSelectedPathCount) # $t6, 0x8016 +/* 00BFD0 8000B3D0 95CE4430 */ lhu $t6, %lo(gSelectedPathCount)($t6) /* 00BFD4 8000B3D4 006E6021 */ addu $t4, $v1, $t6 /* 00BFD8 8000B3D8 01896823 */ subu $t5, $t4, $t1 /* 00BFDC 8000B3DC A4CD0000 */ sh $t5, ($a2) diff --git a/asm/non_matchings/code_80005FD0/func_80017054.s b/asm/non_matchings/cpu_vehicles_camera_path/func_80017054.s similarity index 93% rename from asm/non_matchings/code_80005FD0/func_80017054.s rename to asm/non_matchings/cpu_vehicles_camera_path/func_80017054.s index de71136a5a..4c1306c77a 100644 --- a/asm/non_matchings/code_80005FD0/func_80017054.s +++ b/asm/non_matchings/cpu_vehicles_camera_path/func_80017054.s @@ -37,17 +37,17 @@ glabel func_80017054 /* 017CAC 800170AC AFA700C4 */ sw $a3, 0xc4($sp) /* 017CB0 800170B0 848200AE */ lh $v0, 0xae($a0) /* 017CB4 800170B4 01C01825 */ move $v1, $t6 -/* 017CB8 800170B8 3C0F8016 */ lui $t7, %hi(gNearestWaypointByCameraId) # $t7, 0x8016 +/* 017CB8 800170B8 3C0F8016 */ lui $t7, %hi(gNearestPathPointByCameraId) # $t7, 0x8016 /* 017CBC 800170BC E5240000 */ swc1 $f4, ($t1) -/* 017CC0 800170C0 3C0C8016 */ lui $t4, %hi(gWaypointCountByPathIndex) # 0x8016 +/* 017CC0 800170C0 3C0C8016 */ lui $t4, %hi(gPathCountByPathIndex) # 0x8016 /* 017CC4 800170C4 3C018016 */ lui $at, %hi(D_80163238) # $at, 0x8016 -/* 017CC8 800170C8 25EF4668 */ addiu $t7, %lo(gNearestWaypointByCameraId) # addiu $t7, $t7, 0x4668 +/* 017CC8 800170C8 25EF4668 */ addiu $t7, %lo(gNearestPathPointByCameraId) # addiu $t7, $t7, 0x4668 /* 017CCC 800170CC 00077040 */ sll $t6, $a3, 1 /* 017CD0 800170D0 000AC840 */ sll $t9, $t2, 1 /* 017CD4 800170D4 01996021 */ addu $t4, $t4, $t9 /* 017CD8 800170D8 01CF4021 */ addu $t0, $t6, $t7 /* 017CDC 800170DC AC223238 */ sw $v0, %lo(D_80163238)($at) -/* 017CE0 800170E0 958C45C8 */ lhu $t4, %lo(gWaypointCountByPathIndex)($t4) # 0x45c8($t4) +/* 017CE0 800170E0 958C45C8 */ lhu $t4, %lo(gPathCountByPathIndex)($t4) # 0x45c8($t4) /* 017CE4 800170E4 85070000 */ lh $a3, ($t0) /* 017CE8 800170E8 00808025 */ move $s0, $a0 /* 017CEC 800170EC AFAC0058 */ sw $t4, 0x58($sp) @@ -134,10 +134,10 @@ glabel func_80017054 /* 017E1C 8001721C 8C650000 */ lw $a1, ($v1) /* 017E20 80017220 AFA30044 */ sw $v1, 0x44($sp) /* 017E24 80017224 3044FFFF */ andi $a0, $v0, 0xffff -/* 017E28 80017228 0C002EF6 */ jal func_8000BBD8 +/* 017E28 80017228 0C002EF6 */ jal set_track_offset_position /* 017E2C 8001722C AFA6003C */ sw $a2, 0x3c($sp) -/* 017E30 80017230 3C038016 */ lui $v1, %hi(D_80162FA0) # $v1, 0x8016 -/* 017E34 80017234 24632FA0 */ addiu $v1, %lo(D_80162FA0) # addiu $v1, $v1, 0x2fa0 +/* 017E30 80017230 3C038016 */ lui $v1, %hi(gOffsetPosition) # $v1, 0x8016 +/* 017E34 80017234 24632FA0 */ addiu $v1, %lo(gOffsetPosition) # addiu $v1, $v1, 0x2fa0 /* 017E38 80017238 C4660000 */ lwc1 $f6, ($v1) /* 017E3C 8001723C 3C013FE0 */ li $at, 0x3FE00000 # 1.750000 /* 017E40 80017240 44810800 */ mtc1 $at, $f1 @@ -154,10 +154,10 @@ glabel func_80017054 /* 017E6C 8001726C E7A4008C */ swc1 $f4, 0x8c($sp) /* 017E70 80017270 46205120 */ cvt.s.d $f4, $f10 /* 017E74 80017274 E7A40084 */ swc1 $f4, 0x84($sp) -/* 017E78 80017278 0C002EF6 */ jal func_8000BBD8 +/* 017E78 80017278 0C002EF6 */ jal set_track_offset_position /* 017E7C 8001727C 8F050000 */ lw $a1, ($t8) -/* 017E80 80017280 3C038016 */ lui $v1, %hi(D_80162FA0) # $v1, 0x8016 -/* 017E84 80017284 24632FA0 */ addiu $v1, %lo(D_80162FA0) # addiu $v1, $v1, 0x2fa0 +/* 017E80 80017280 3C038016 */ lui $v1, %hi(gOffsetPosition) # $v1, 0x8016 +/* 017E84 80017284 24632FA0 */ addiu $v1, %lo(gOffsetPosition) # addiu $v1, $v1, 0x2fa0 /* 017E88 80017288 C46A0000 */ lwc1 $f10, ($v1) /* 017E8C 8001728C C7A6008C */ lwc1 $f6, 0x8c($sp) /* 017E90 80017290 3C013FE0 */ li $at, 0x3FE00000 # 1.750000 @@ -201,9 +201,9 @@ glabel func_80017054 /* 017F20 80017320 8FAC005C */ lw $t4, 0x5c($sp) /* 017F24 80017324 000D7403 */ sra $t6, $t5, 0x10 /* 017F28 80017328 01C01025 */ move $v0, $t6 -/* 017F2C 8001732C 3C0E8016 */ lui $t6, %hi(D_80164550) # $t6, 0x8016 +/* 017F2C 8001732C 3C0E8016 */ lui $t6, %hi(gTrackPaths) # $t6, 0x8016 /* 017F30 80017330 00004810 */ mfhi $t1 -/* 017F34 80017334 25CE4550 */ addiu $t6, %lo(D_80164550) # addiu $t6, $t6, 0x4550 +/* 017F34 80017334 25CE4550 */ addiu $t6, %lo(gTrackPaths) # addiu $t6, $t6, 0x4550 /* 017F38 80017338 000C6880 */ sll $t5, $t4, 2 /* 017F3C 8001733C 0009C400 */ sll $t8, $t1, 0x10 /* 017F40 80017340 01AE5021 */ addu $t2, $t5, $t6 @@ -270,10 +270,10 @@ glabel func_80017054 /* 01801C 8001741C 8F050000 */ lw $a1, ($t8) /* 018020 80017420 AFAA002C */ sw $t2, 0x2c($sp) /* 018024 80017424 A7AF006C */ sh $t7, 0x6c($sp) -/* 018028 80017428 0C002EF6 */ jal func_8000BBD8 +/* 018028 80017428 0C002EF6 */ jal set_track_offset_position /* 01802C 8001742C A7A2006E */ sh $v0, 0x6e($sp) -/* 018030 80017430 3C038016 */ lui $v1, %hi(D_80162FA0) # $v1, 0x8016 -/* 018034 80017434 24632FA0 */ addiu $v1, %lo(D_80162FA0) # addiu $v1, $v1, 0x2fa0 +/* 018030 80017430 3C038016 */ lui $v1, %hi(gOffsetPosition) # $v1, 0x8016 +/* 018034 80017434 24632FA0 */ addiu $v1, %lo(gOffsetPosition) # addiu $v1, $v1, 0x2fa0 /* 018038 80017438 C4660000 */ lwc1 $f6, ($v1) /* 01803C 8001743C 3C013FE0 */ li $at, 0x3FE00000 # 1.750000 /* 018040 80017440 44810800 */ mtc1 $at, $f1 @@ -290,10 +290,10 @@ glabel func_80017054 /* 01806C 8001746C 462053A0 */ cvt.s.d $f14, $f10 /* 018070 80017470 46204420 */ cvt.s.d $f16, $f8 /* 018074 80017474 E7AE0098 */ swc1 $f14, 0x98($sp) -/* 018078 80017478 0C002EF6 */ jal func_8000BBD8 +/* 018078 80017478 0C002EF6 */ jal set_track_offset_position /* 01807C 8001747C E7B00090 */ swc1 $f16, 0x90($sp) -/* 018080 80017480 3C038016 */ lui $v1, %hi(D_80162FA0) # $v1, 0x8016 -/* 018084 80017484 24632FA0 */ addiu $v1, %lo(D_80162FA0) # addiu $v1, $v1, 0x2fa0 +/* 018080 80017480 3C038016 */ lui $v1, %hi(gOffsetPosition) # $v1, 0x8016 +/* 018084 80017484 24632FA0 */ addiu $v1, %lo(gOffsetPosition) # addiu $v1, $v1, 0x2fa0 /* 018088 80017488 C4640000 */ lwc1 $f4, ($v1) /* 01808C 8001748C 3C013FE0 */ li $at, 0x3FE00000 # 1.750000 /* 018090 80017490 44810800 */ mtc1 $at, $f1 diff --git a/asm/non_matchings/code_80005FD0/func_80019FB4.s b/asm/non_matchings/cpu_vehicles_camera_path/func_80019FB4.s similarity index 100% rename from asm/non_matchings/code_80005FD0/func_80019FB4.s rename to asm/non_matchings/cpu_vehicles_camera_path/func_80019FB4.s diff --git a/asm/non_matchings/code_80005FD0/func_80009B60.s b/asm/non_matchings/cpu_vehicles_camera_path/update_player.s similarity index 79% rename from asm/non_matchings/code_80005FD0/func_80009B60.s rename to asm/non_matchings/cpu_vehicles_camera_path/update_player.s index 87bb293601..2a23871fb0 100644 --- a/asm/non_matchings/code_80005FD0/func_80009B60.s +++ b/asm/non_matchings/cpu_vehicles_camera_path/update_player.s @@ -23,14 +23,14 @@ glabel D_800ECFC8 .section .text -glabel func_80009B60 +glabel update_player /* 00A760 80009B60 3C0E800E */ lui $t6, %hi(gCurrentCourseId) /* 00A764 80009B64 85CEC5A0 */ lh $t6, %lo(gCurrentCourseId)($t6) -/* 00A768 80009B68 3C01800E */ lui $at, %hi(gKartAICourseMaximumSeparation) +/* 00A768 80009B68 3C01800E */ lui $at, %hi(cpu_CourseMaximumSeparation) /* 00A76C 80009B6C 3C0A8016 */ lui $t2, %hi(D_80163100) # $t2, 0x8016 /* 00A770 80009B70 000E7880 */ sll $t7, $t6, 2 /* 00A774 80009B74 002F0821 */ addu $at, $at, $t7 -/* 00A778 80009B78 C424CA4C */ lwc1 $f4, %lo(gKartAICourseMaximumSeparation)($at) +/* 00A778 80009B78 C424CA4C */ lwc1 $f4, %lo(cpu_CourseMaximumSeparation)($at) /* 00A77C 80009B7C 27BDFF30 */ addiu $sp, $sp, -0xd0 /* 00A780 80009B80 254A3100 */ addiu $t2, %lo(D_80163100) # addiu $t2, $t2, 0x3100 /* 00A784 80009B84 4600218D */ trunc.w.s $f6, $f4 @@ -42,8 +42,8 @@ glabel func_80009B60 /* 00A79C 80009B9C 07220565 */ bltzl $t9, .L8000B134 /* 00A7A0 80009BA0 8FBF0014 */ lw $ra, 0x14($sp) /* 00A7A4 80009BA4 8C4B0000 */ lw $t3, ($v0) -/* 00A7A8 80009BA8 3C088016 */ lui $t0, %hi(D_80163378) # $t0, 0x8016 -/* 00A7AC 80009BAC 25083378 */ addiu $t0, %lo(D_80163378) # addiu $t0, $t0, 0x3378 +/* 00A7A8 80009BA8 3C088016 */ lui $t0, %hi(gIncrementUpdatePlayer) # $t0, 0x8016 +/* 00A7AC 80009BAC 25083378 */ addiu $t0, %lo(gIncrementUpdatePlayer) # addiu $t0, $t0, 0x3378 /* 00A7B0 80009BB0 256C0001 */ addiu $t4, $t3, 1 /* 00A7B4 80009BB4 1480000B */ bnez $a0, .L80009BE4 /* 00A7B8 80009BB8 AC4C0000 */ sw $t4, ($v0) @@ -76,10 +76,10 @@ glabel func_80009B60 /* 00A820 80009C20 00053040 */ sll $a2, $a1, 1 /* 00A824 80009C24 3C01C47A */ li $at, 0xC47A0000 # -1000.000000 /* 00A828 80009C28 44810000 */ mtc1 $at, $f0 -/* 00A82C 80009C2C 3C018016 */ lui $at, %hi(D_80164450) # 0x8016 +/* 00A82C 80009C2C 3C018016 */ lui $at, %hi(gNumPathPointsTraversed) # 0x8016 /* 00A830 80009C30 00270821 */ addu $at, $at, $a3 /* 00A834 80009C34 240FFFEC */ li $t7, -20 -/* 00A838 80009C38 AC2F4450 */ sw $t7, %lo(D_80164450)($at) # 0x4450($at) +/* 00A838 80009C38 AC2F4450 */ sw $t7, %lo(gNumPathPointsTraversed)($at) # 0x4450($at) /* 00A83C 80009C3C 3C018016 */ lui $at, %hi(gCourseCompletionPercentByPlayerId) /* 00A840 80009C40 00270821 */ addu $at, $at, $a3 /* 00A844 80009C44 E42044D0 */ swc1 $f0, %lo(gCourseCompletionPercentByPlayerId)($at) @@ -146,16 +146,16 @@ glabel func_80009B60 /* 00A924 80009D24 17200502 */ bnez $t9, .L8000B130 /* 00A928 80009D28 304A0008 */ andi $t2, $v0, 8 /* 00A92C 80009D2C 15400500 */ bnez $t2, .L8000B130 -/* 00A930 80009D30 3C028016 */ lui $v0, %hi(D_80163448) # $v0, 0x8016 +/* 00A930 80009D30 3C028016 */ lui $v0, %hi(gPlayerPathIndex) # $v0, 0x8016 /* 00A934 80009D34 3C0B8016 */ lui $t3, %hi(gPathIndexByPlayerId) # 0x8016 /* 00A938 80009D38 01665821 */ addu $t3, $t3, $a2 /* 00A93C 80009D3C 956445B0 */ lhu $a0, %lo(gPathIndexByPlayerId)($t3) # 0x45b0($t3) -/* 00A940 80009D40 24423448 */ addiu $v0, %lo(D_80163448) # addiu $v0, $v0, 0x3448 +/* 00A940 80009D40 24423448 */ addiu $v0, %lo(gPlayerPathIndex) # addiu $v0, $v0, 0x3448 /* 00A944 80009D44 AFA30040 */ sw $v1, 0x40($sp) /* 00A948 80009D48 AFA500D0 */ sw $a1, 0xd0($sp) /* 00A94C 80009D4C AFA60034 */ sw $a2, 0x34($sp) /* 00A950 80009D50 AFA70038 */ sw $a3, 0x38($sp) -/* 00A954 80009D54 0C002370 */ jal func_80008DC0 +/* 00A954 80009D54 0C002370 */ jal set_current_path /* 00A958 80009D58 AC440000 */ sw $a0, ($v0) /* 00A95C 80009D5C 3C02800E */ lui $v0, %hi(gCurrentCourseId) /* 00A960 80009D60 8442C5A0 */ lh $v0, %lo(gCurrentCourseId)($v0) @@ -171,7 +171,7 @@ glabel func_80009B60 /* 00A988 80009D88 1000001A */ b .L80009DF4 /* 00A98C 80009D8C 8FA50040 */ lw $a1, 0x40($sp) .L80009D90: -/* 00A990 80009D90 0C004B70 */ jal func_80012DC0 +/* 00A990 80009D90 0C004B70 */ jal handle_trains_interactions /* 00A994 80009D94 8FA50040 */ lw $a1, 0x40($sp) /* 00A998 80009D98 8FAC00D0 */ lw $t4, 0xd0($sp) /* 00A99C 80009D9C 55800015 */ bnel $t4, $zero, .L80009DF4 @@ -181,21 +181,21 @@ glabel func_80009B60 /* 00A9AC 80009DAC 10000011 */ b .L80009DF4 /* 00A9B0 80009DB0 8FA50040 */ lw $a1, 0x40($sp) .L80009DB4: -/* 00A9B4 80009DB4 0C004E15 */ jal func_80013854 +/* 00A9B4 80009DB4 0C004E15 */ jal handle_paddleBoats_interactions /* 00A9B8 80009DB8 8FA40040 */ lw $a0, 0x40($sp) /* 00A9BC 80009DBC 1000000D */ b .L80009DF4 /* 00A9C0 80009DC0 8FA50040 */ lw $a1, 0x40($sp) .L80009DC4: -/* 00A9C4 80009DC4 0C005231 */ jal func_800148C4 +/* 00A9C4 80009DC4 0C005231 */ jal handle_box_trucks_interactions /* 00A9C8 80009DC8 8FA50040 */ lw $a1, 0x40($sp) /* 00A9CC 80009DCC 8FA400D0 */ lw $a0, 0xd0($sp) -/* 00A9D0 80009DD0 0C005286 */ jal func_80014A18 +/* 00A9D0 80009DD0 0C005286 */ jal handle_school_buses_interactions /* 00A9D4 80009DD4 8FA50040 */ lw $a1, 0x40($sp) /* 00A9D8 80009DD8 8FA400D0 */ lw $a0, 0xd0($sp) -/* 00A9DC 80009DDC 0C0052DB */ jal func_80014B6C +/* 00A9DC 80009DDC 0C0052DB */ jal handle_tanker_trucks_interactions /* 00A9E0 80009DE0 8FA50040 */ lw $a1, 0x40($sp) /* 00A9E4 80009DE4 8FA400D0 */ lw $a0, 0xd0($sp) -/* 00A9E8 80009DE8 0C005330 */ jal func_80014CC0 +/* 00A9E8 80009DE8 0C005330 */ jal handle_cars_interactions /* 00A9EC 80009DEC 8FA50040 */ lw $a1, 0x40($sp) /* 00A9F0 80009DF0 8FA50040 */ lw $a1, 0x40($sp) .L80009DF4: @@ -212,7 +212,7 @@ glabel func_80009B60 /* 00AA1C 80009E1C ACB800BC */ sw $t8, 0xbc($a1) /* 00AA20 80009E20 A4AA0044 */ sh $t2, 0x44($a1) .L80009E24: -/* 00AA24 80009E24 0C0024A7 */ jal func_8000929C +/* 00AA24 80009E24 0C0024A7 */ jal update_player_path_completion /* 00AA28 80009E28 8FA400D0 */ lw $a0, 0xd0($sp) /* 00AA2C 80009E2C 3C0B800E */ lui $t3, %hi(gCurrentCourseId) /* 00AA30 80009E30 856BC5A0 */ lh $t3, %lo(gCurrentCourseId)($t3) @@ -234,12 +234,12 @@ glabel func_80009B60 .L80009E6C: /* 00AA6C 80009E6C 8FAF0040 */ lw $t7, 0x40($sp) .L80009E70: -/* 00AA70 80009E70 3C0A8016 */ lui $t2, %hi(D_801630E2) # $t2, 0x8016 +/* 00AA70 80009E70 3C0A8016 */ lui $t2, %hi(gIsPlayerNewPathPoint) # $t2, 0x8016 /* 00AA74 80009E74 95F80000 */ lhu $t8, ($t7) /* 00AA78 80009E78 33191000 */ andi $t9, $t8, 0x1000 /* 00AA7C 80009E7C 532004AD */ beql $t9, $zero, .L8000B134 /* 00AA80 80009E80 8FBF0014 */ lw $ra, 0x14($sp) -/* 00AA84 80009E84 854A30E2 */ lh $t2, %lo(D_801630E2)($t2) +/* 00AA84 80009E84 854A30E2 */ lh $t2, %lo(gIsPlayerNewPathPoint)($t2) /* 00AA88 80009E88 24010001 */ li $at, 1 /* 00AA8C 80009E8C 15410007 */ bne $t2, $at, .L80009EAC /* 00AA90 80009E90 3C0B800E */ lui $t3, %hi(gCurrentCourseId) @@ -247,21 +247,21 @@ glabel func_80009B60 /* 00AA98 80009E98 24010014 */ li $at, 20 /* 00AA9C 80009E9C 11610003 */ beq $t3, $at, .L80009EAC /* 00AAA0 80009EA0 00000000 */ nop -/* 00AAA4 80009EA4 0C00478E */ jal kart_ai_behaviour +/* 00AAA4 80009EA4 0C00478E */ jal cpu_behaviour /* 00AAA8 80009EA8 8FA400D0 */ lw $a0, 0xd0($sp) .L80009EAC: -/* 00AAAC 80009EAC 3C0E8016 */ lui $t6, %hi(D_80163378) # $t6, 0x8016 -/* 00AAB0 80009EB0 8DCE3378 */ lw $t6, %lo(D_80163378)($t6) +/* 00AAAC 80009EAC 3C0E8016 */ lui $t6, %hi(gIncrementUpdatePlayer) # $t6, 0x8016 +/* 00AAB0 80009EB0 8DCE3378 */ lw $t6, %lo(gIncrementUpdatePlayer)($t6) /* 00AAB4 80009EB4 8FAC00D0 */ lw $t4, 0xd0($sp) /* 00AAB8 80009EB8 31CF0001 */ andi $t7, $t6, 1 /* 00AABC 80009EBC 318D0001 */ andi $t5, $t4, 1 /* 00AAC0 80009EC0 11ED0003 */ beq $t7, $t5, .L80009ED0 /* 00AAC4 80009EC4 AFAD0030 */ sw $t5, 0x30($sp) -/* 00AAC8 80009EC8 0C006B04 */ jal kart_ai_use_item_strategy +/* 00AAC8 80009EC8 0C006B04 */ jal cpu_use_item_strategy /* 00AACC 80009ECC 01802025 */ move $a0, $t4 .L80009ED0: /* 00AAD0 80009ED0 8FA400D0 */ lw $a0, 0xd0($sp) -/* 00AAD4 80009ED4 0C00267B */ jal func_800099EC +/* 00AAD4 80009ED4 0C00267B */ jal update_player_timer_sound /* 00AAD8 80009ED8 8FA50040 */ lw $a1, 0x40($sp) /* 00AADC 80009EDC 3C02800E */ lui $v0, %hi(gModeSelection) /* 00AAE0 80009EE0 8C42C53C */ lw $v0, %lo(gModeSelection)($v0) @@ -317,42 +317,42 @@ glabel func_80009B60 /* 00AB94 80009F94 8FAA00D0 */ lw $t2, 0xd0($sp) /* 00AB98 80009F98 44808000 */ mtc1 $zero, $f16 /* 00AB9C 80009F9C 000A5900 */ sll $t3, $t2, 4 -/* 00ABA0 80009FA0 3C018016 */ lui $at, %hi(D_801634F8 + 4) +/* 00ABA0 80009FA0 3C018016 */ lui $at, %hi(gPlayerTrackPositionFactorInstruction + 4) /* 00ABA4 80009FA4 002B0821 */ addu $at, $at, $t3 -/* 00ABA8 80009FA8 E43034FC */ swc1 $f16, %lo(D_801634F8 + 4)($at) +/* 00ABA8 80009FA8 E43034FC */ swc1 $f16, %lo(gPlayerTrackPositionFactorInstruction + 4)($at) .L80009FAC: /* 00ABAC 80009FAC 8FAE00D0 */ lw $t6, 0xd0($sp) /* 00ABB0 80009FB0 44809000 */ mtc1 $zero, $f18 -/* 00ABB4 80009FB4 3C018016 */ lui $at, %hi(D_801634F8 + 12) +/* 00ABB4 80009FB4 3C018016 */ lui $at, %hi(gPlayerTrackPositionFactorInstruction + 12) /* 00ABB8 80009FB8 000E7900 */ sll $t7, $t6, 4 /* 00ABBC 80009FBC 002F0821 */ addu $at, $at, $t7 -/* 00ABC0 80009FC0 E4323504 */ swc1 $f18, %lo(D_801634F8 + 12)($at) +/* 00ABC0 80009FC0 E4323504 */ swc1 $f18, %lo(gPlayerTrackPositionFactorInstruction + 12)($at) .L80009FC4: -/* 00ABC4 80009FC4 3C028016 */ lui $v0, %hi(D_80163448) # $v0, 0x8016 -/* 00ABC8 80009FC8 8C423448 */ lw $v0, %lo(D_80163448)($v0) -/* 00ABCC 80009FCC 3C0A8016 */ lui $t2, %hi(D_80164510) # $t2, 0x8016 -/* 00ABD0 80009FD0 254A4510 */ addiu $t2, %lo(D_80164510) # addiu $t2, $t2, 0x4510 +/* 00ABC4 80009FC4 3C028016 */ lui $v0, %hi(gPlayerPathIndex) # $v0, 0x8016 +/* 00ABC8 80009FC8 8C423448 */ lw $v0, %lo(gPlayerPathIndex)($v0) +/* 00ABCC 80009FCC 3C0A8016 */ lui $t2, %hi(gPlayerPathY) # $t2, 0x8016 +/* 00ABD0 80009FD0 254A4510 */ addiu $t2, %lo(gPlayerPathY) # addiu $t2, $t2, 0x4510 /* 00ABD4 80009FD4 1840000A */ blez $v0, .L8000A000 -/* 00ABD8 80009FD8 3C0B8016 */ lui $t3, %hi(gNearestWaypointByPlayerId) # $t3, 0x8016 +/* 00ABD8 80009FD8 3C0B8016 */ lui $t3, %hi(gNearestPathPointByPlayerId) # $t3, 0x8016 /* 00ABDC 80009FDC 8FAD00D0 */ lw $t5, 0xd0($sp) -/* 00ABE0 80009FE0 3C188016 */ lui $t8, %hi(D_801634F8) # $t8, 0x8016 +/* 00ABE0 80009FE0 3C188016 */ lui $t8, %hi(gPlayerTrackPositionFactorInstruction) # $t8, 0x8016 /* 00ABE4 80009FE4 44802000 */ mtc1 $zero, $f4 /* 00ABE8 80009FE8 44803000 */ mtc1 $zero, $f6 -/* 00ABEC 80009FEC 271834F8 */ addiu $t8, %lo(D_801634F8) # addiu $t8, $t8, 0x34f8 +/* 00ABEC 80009FEC 271834F8 */ addiu $t8, %lo(gPlayerTrackPositionFactorInstruction) # addiu $t8, $t8, 0x34f8 /* 00ABF0 80009FF0 000D6100 */ sll $t4, $t5, 4 /* 00ABF4 80009FF4 01981821 */ addu $v1, $t4, $t8 /* 00ABF8 80009FF8 E4640004 */ swc1 $f4, 4($v1) /* 00ABFC 80009FFC E466000C */ swc1 $f6, 0xc($v1) .L8000A000: -/* 00AC00 8000A000 256B4438 */ addiu $t3, %lo(gNearestWaypointByPlayerId) # addiu $t3, $t3, 0x4438 +/* 00AC00 8000A000 256B4438 */ addiu $t3, %lo(gNearestPathPointByPlayerId) # addiu $t3, $t3, 0x4438 /* 00AC04 8000A004 010B7021 */ addu $t6, $t0, $t3 /* 00AC08 8000A008 8FB90038 */ lw $t9, 0x38($sp) /* 00AC0C 8000A00C AFAE0024 */ sw $t6, 0x24($sp) /* 00AC10 8000A010 00027880 */ sll $t7, $v0, 2 -/* 00AC14 8000A014 3C0D8016 */ lui $t5, %hi(D_80164550) # 0x8016 +/* 00AC14 8000A014 3C0D8016 */ lui $t5, %hi(gTrackPaths) # 0x8016 /* 00AC18 8000A018 95D80000 */ lhu $t8, ($t6) /* 00AC1C 8000A01C 01AF6821 */ addu $t5, $t5, $t7 -/* 00AC20 8000A020 8DAD4550 */ lw $t5, %lo(D_80164550)($t5) # 0x4550($t5) +/* 00AC20 8000A020 8DAD4550 */ lw $t5, %lo(gTrackPaths)($t5) # 0x4550($t5) /* 00AC24 8000A024 032A3021 */ addu $a2, $t9, $t2 /* 00AC28 8000A028 0018C8C0 */ sll $t9, $t8, 3 /* 00AC2C 8000A02C 01B95021 */ addu $t2, $t5, $t9 @@ -410,18 +410,18 @@ glabel func_80009B60 /* 00ACEC 8000A0EC 00602025 */ move $a0, $v1 .L8000A0F0: /* 00ACF0 8000A0F0 44803000 */ mtc1 $zero, $f6 -/* 00ACF4 8000A0F4 3C018016 */ lui $at, %hi(D_801634F8 + 4) +/* 00ACF4 8000A0F4 3C018016 */ lui $at, %hi(gPlayerTrackPositionFactorInstruction + 4) /* 00ACF8 8000A0F8 00390821 */ addu $at, $at, $t9 /* 00ACFC 8000A0FC 1000000D */ b .L8000A134 -/* 00AD00 8000A100 E42634FC */ swc1 $f6, %lo(D_801634F8 + 4)($at) +/* 00AD00 8000A100 E42634FC */ swc1 $f6, %lo(gPlayerTrackPositionFactorInstruction + 4)($at) .L8000A104: -/* 00AD04 8000A104 0C005243 */ jal func_8001490C +/* 00AD04 8000A104 0C005243 */ jal update_player_track_position_factor_from_box_trucks /* 00AD08 8000A108 AFA5002C */ sw $a1, 0x2c($sp) -/* 00AD0C 8000A10C 0C005298 */ jal func_80014A60 +/* 00AD0C 8000A10C 0C005298 */ jal update_player_track_position_factor_from_buses /* 00AD10 8000A110 8FA400D0 */ lw $a0, 0xd0($sp) -/* 00AD14 8000A114 0C0052ED */ jal func_80014BB4 +/* 00AD14 8000A114 0C0052ED */ jal update_player_track_position_factor_from_tanker_truck /* 00AD18 8000A118 8FA400D0 */ lw $a0, 0xd0($sp) -/* 00AD1C 8000A11C 0C005342 */ jal func_80014D08 +/* 00AD1C 8000A11C 0C005342 */ jal update_player_track_position_factor_from_cars /* 00AD20 8000A120 8FA400D0 */ lw $a0, 0xd0($sp) /* 00AD24 8000A124 8FA5002C */ lw $a1, 0x2c($sp) /* 00AD28 8000A128 24090001 */ li $t1, 1 @@ -436,23 +436,23 @@ glabel func_80009B60 /* 00AD48 8000A148 A42030E8 */ sh $zero, %lo(D_801630E8)($at) # 0x30e8($at) /* 00AD4C 8000A14C 8D4B00BC */ lw $t3, 0xbc($t2) /* 00AD50 8000A150 2401FFEF */ li $at, -17 -/* 00AD54 8000A154 3C0F8016 */ lui $t7, %hi(D_80163378) # $t7, 0x8016 +/* 00AD54 8000A154 3C0F8016 */ lui $t7, %hi(gIncrementUpdatePlayer) # $t7, 0x8016 /* 00AD58 8000A158 01617024 */ and $t6, $t3, $at /* 00AD5C 8000A15C AD4E00BC */ sw $t6, 0xbc($t2) -/* 00AD60 8000A160 8DEF3378 */ lw $t7, %lo(D_80163378)($t7) +/* 00AD60 8000A160 8DEF3378 */ lw $t7, %lo(gIncrementUpdatePlayer)($t7) /* 00AD64 8000A164 8FB80030 */ lw $t8, 0x30($sp) /* 00AD68 8000A168 3C028019 */ lui $v0, %hi(gPlayerCount) # $v0, 0x8019 /* 00AD6C 8000A16C 31EC0001 */ andi $t4, $t7, 1 /* 00AD70 8000A170 1198000C */ beq $t4, $t8, .L8000A1A4 /* 00AD74 8000A174 01402025 */ move $a0, $t2 -/* 00AD78 8000A178 0C00DA03 */ jal func_8003680C +/* 00AD78 8000A178 0C00DA03 */ jal apply_cpu_turn /* 00AD7C 8000A17C 00002825 */ move $a1, $zero /* 00AD80 8000A180 8FAD0038 */ lw $t5, 0x38($sp) -/* 00AD84 8000A184 3C058016 */ lui $a1, %hi(D_80163210) # 0x8016 +/* 00AD84 8000A184 3C058016 */ lui $a1, %hi(gPreviousCpuTargetSpeed) # 0x8016 /* 00AD88 8000A188 8FA400D0 */ lw $a0, 0xd0($sp) /* 00AD8C 8000A18C 00AD2821 */ addu $a1, $a1, $t5 -/* 00AD90 8000A190 8CA53210 */ lw $a1, %lo(D_80163210)($a1) # 0x3210($a1) -/* 00AD94 8000A194 0C002109 */ jal func_80008424 +/* 00AD90 8000A190 8CA53210 */ lw $a1, %lo(gPreviousCpuTargetSpeed)($a1) # 0x3210($a1) +/* 00AD94 8000A194 0C002109 */ jal regulate_cpu_speed /* 00AD98 8000A198 8FA60040 */ lw $a2, 0x40($sp) /* 00AD9C 8000A19C 100003E5 */ b .L8000B134 /* 00ADA0 8000A1A0 8FBF0014 */ lw $ra, 0x14($sp) @@ -472,8 +472,8 @@ glabel func_80009B60 /* 00ADD4 8000A1D4 01EE7821 */ addu $t7, $t7, $t6 /* 00ADD8 8000A1D8 8DEF43B8 */ lw $t7, %lo(gGPCurrentRaceRankByPlayerId)($t7) /* 00ADDC 8000A1DC 956B334C */ lhu $t3, %lo(D_8016334C)($t3) # 0x334c($t3) -/* 00ADE0 8000A1E0 3C0C8016 */ lui $t4, %hi(D_80163210) # $t4, 0x8016 -/* 00ADE4 8000A1E4 258C3210 */ addiu $t4, %lo(D_80163210) # addiu $t4, $t4, 0x3210 +/* 00ADE0 8000A1E0 3C0C8016 */ lui $t4, %hi(gPreviousCpuTargetSpeed) # $t4, 0x8016 +/* 00ADE4 8000A1E4 258C3210 */ addiu $t4, %lo(gPreviousCpuTargetSpeed) # addiu $t4, $t4, 0x3210 /* 00ADE8 8000A1E8 016F082A */ slt $at, $t3, $t7 /* 00ADEC 8000A1EC 10200005 */ beqz $at, .L8000A204 /* 00ADF0 8000A1F0 3C01800F */ lui $at, %hi(D_800ECFB4) # $at, 0x800f @@ -491,8 +491,8 @@ glabel func_80009B60 /* 00AE1C 8000A21C 8F39C548 */ lw $t9, %lo(gCCSelection)($t9) /* 00AE20 8000A220 8FAC00D0 */ lw $t4, 0xd0($sp) /* 00AE24 8000A224 000A6900 */ sll $t5, $t2, 4 -/* 00AE28 8000A228 3C0A8016 */ lui $t2, %hi(D_801634F8) # $t2, 0x8016 -/* 00AE2C 8000A22C 254A34F8 */ addiu $t2, %lo(D_801634F8) # addiu $t2, $t2, 0x34f8 +/* 00AE28 8000A228 3C0A8016 */ lui $t2, %hi(gPlayerTrackPositionFactorInstruction) # $t2, 0x8016 +/* 00AE2C 8000A22C 254A34F8 */ addiu $t2, %lo(gPlayerTrackPositionFactorInstruction) # addiu $t2, $t2, 0x34f8 /* 00AE30 8000A230 3C0E0D01 */ lui $t6, %hi(D_0D0096B8) # $t6, 0xd01 /* 00AE34 8000A234 00195880 */ sll $t3, $t9, 2 /* 00AE38 8000A238 000CC100 */ sll $t8, $t4, 4 @@ -503,21 +503,21 @@ glabel func_80009B60 /* 00AE4C 8000A24C 0C026455 */ jal segmented_to_virtual_dupe_2 /* 00AE50 8000A250 AFA30030 */ sw $v1, 0x30($sp) /* 00AE54 8000A254 8FB90038 */ lw $t9, 0x38($sp) -/* 00AE58 8000A258 3C0D8016 */ lui $t5, %hi(D_80163210) # $t5, 0x8016 +/* 00AE58 8000A258 3C0D8016 */ lui $t5, %hi(gPreviousCpuTargetSpeed) # $t5, 0x8016 /* 00AE5C 8000A25C 3C01BF00 */ li $at, 0xBF000000 # -0.500000 /* 00AE60 8000A260 8FA30030 */ lw $v1, 0x30($sp) /* 00AE64 8000A264 C44A0000 */ lwc1 $f10, ($v0) /* 00AE68 8000A268 44818000 */ mtc1 $at, $f16 -/* 00AE6C 8000A26C 25AD3210 */ addiu $t5, %lo(D_80163210) # addiu $t5, $t5, 0x3210 +/* 00AE6C 8000A26C 25AD3210 */ addiu $t5, %lo(gPreviousCpuTargetSpeed) # addiu $t5, $t5, 0x3210 /* 00AE70 8000A270 032D4021 */ addu $t0, $t9, $t5 /* 00AE74 8000A274 E50A0000 */ swc1 $f10, ($t0) /* 00AE78 8000A278 1000002C */ b .L8000A32C /* 00AE7C 8000A27C E4700004 */ swc1 $f16, 4($v1) .L8000A280: -/* 00AE80 8000A280 3C0F8016 */ lui $t7, %hi(sSomeNearestWaypoint) # $t7, 0x8016 -/* 00AE84 8000A284 85EF2FCE */ lh $t7, %lo(sSomeNearestWaypoint)($t7) -/* 00AE88 8000A288 3C0B8016 */ lui $t3, %hi(D_801645E0) # $t3, 0x8016 -/* 00AE8C 8000A28C 8D6B45E0 */ lw $t3, %lo(D_801645E0)($t3) +/* 00AE80 8000A280 3C0F8016 */ lui $t7, %hi(sSomeNearestPathPoint) # $t7, 0x8016 +/* 00AE84 8000A284 85EF2FCE */ lh $t7, %lo(sSomeNearestPathPoint)($t7) +/* 00AE88 8000A288 3C0B8016 */ lui $t3, %hi(gCurrentTrackConsecutiveCurveCountsPath) # $t3, 0x8016 +/* 00AE8C 8000A28C 8D6B45E0 */ lw $t3, %lo(gCurrentTrackConsecutiveCurveCountsPath)($t3) /* 00AE90 8000A290 000F7040 */ sll $t6, $t7, 1 /* 00AE94 8000A294 016E6021 */ addu $t4, $t3, $t6 /* 00AE98 8000A298 85980000 */ lh $t8, ($t4) @@ -526,17 +526,17 @@ glabel func_80009B60 /* 00AEA4 8000A2A4 3C0D800E */ lui $t5, %hi(gCCSelection) /* 00AEA8 8000A2A8 8DADC548 */ lw $t5, %lo(gCCSelection)($t5) /* 00AEAC 8000A2AC 854AC5A0 */ lh $t2, %lo(gCurrentCourseId)($t2) -/* 00AEB0 8000A2B0 3C0E0D01 */ lui $t6, %hi(D_0D009418) # $t6, 0xd01 +/* 00AEB0 8000A2B0 3C0E0D01 */ lui $t6, %hi(cpu_CurveTargetSpeed) # $t6, 0xd01 /* 00AEB4 8000A2B4 000D7880 */ sll $t7, $t5, 2 /* 00AEB8 8000A2B8 000AC900 */ sll $t9, $t2, 4 /* 00AEBC 8000A2BC 032F5821 */ addu $t3, $t9, $t7 -/* 00AEC0 8000A2C0 25CE9418 */ addiu $t6, %lo(D_0D009418) # addiu $t6, $t6, -0x6be8 +/* 00AEC0 8000A2C0 25CE9418 */ addiu $t6, %lo(cpu_CurveTargetSpeed) # addiu $t6, $t6, -0x6be8 /* 00AEC4 8000A2C4 0C026455 */ jal segmented_to_virtual_dupe_2 /* 00AEC8 8000A2C8 016E2021 */ addu $a0, $t3, $t6 /* 00AECC 8000A2CC 8FAC0038 */ lw $t4, 0x38($sp) -/* 00AED0 8000A2D0 3C188016 */ lui $t8, %hi(D_80163210) # $t8, 0x8016 +/* 00AED0 8000A2D0 3C188016 */ lui $t8, %hi(gPreviousCpuTargetSpeed) # $t8, 0x8016 /* 00AED4 8000A2D4 C4520000 */ lwc1 $f18, ($v0) -/* 00AED8 8000A2D8 27183210 */ addiu $t8, %lo(D_80163210) # addiu $t8, $t8, 0x3210 +/* 00AED8 8000A2D8 27183210 */ addiu $t8, %lo(gPreviousCpuTargetSpeed) # addiu $t8, $t8, 0x3210 /* 00AEDC 8000A2DC 01984021 */ addu $t0, $t4, $t8 /* 00AEE0 8000A2E0 10000012 */ b .L8000A32C /* 00AEE4 8000A2E4 E5120000 */ swc1 $f18, ($t0) @@ -545,32 +545,32 @@ glabel func_80009B60 /* 00AEEC 8000A2EC 3C19800E */ lui $t9, %hi(gCCSelection) /* 00AEF0 8000A2F0 8F39C548 */ lw $t9, %lo(gCCSelection)($t9) /* 00AEF4 8000A2F4 854AC5A0 */ lh $t2, %lo(gCurrentCourseId)($t2) -/* 00AEF8 8000A2F8 3C0E0D01 */ lui $t6, %hi(D_0D009568) # $t6, 0xd01 +/* 00AEF8 8000A2F8 3C0E0D01 */ lui $t6, %hi(cpu_NormalTargetSpeed) # $t6, 0xd01 /* 00AEFC 8000A2FC 00197880 */ sll $t7, $t9, 2 /* 00AF00 8000A300 000A6900 */ sll $t5, $t2, 4 /* 00AF04 8000A304 01AF5821 */ addu $t3, $t5, $t7 -/* 00AF08 8000A308 25CE9568 */ addiu $t6, %lo(D_0D009568) # addiu $t6, $t6, -0x6a98 +/* 00AF08 8000A308 25CE9568 */ addiu $t6, %lo(cpu_NormalTargetSpeed) # addiu $t6, $t6, -0x6a98 /* 00AF0C 8000A30C 0C026455 */ jal segmented_to_virtual_dupe_2 /* 00AF10 8000A310 016E2021 */ addu $a0, $t3, $t6 /* 00AF14 8000A314 8FAC0038 */ lw $t4, 0x38($sp) /* 00AF18 8000A318 C4440000 */ lwc1 $f4, ($v0) -/* 00AF1C 8000A31C 3C188016 */ lui $t8, %hi(D_80163210) # $t8, 0x8016 -/* 00AF20 8000A320 27183210 */ addiu $t8, %lo(D_80163210) # addiu $t8, $t8, 0x3210 +/* 00AF1C 8000A31C 3C188016 */ lui $t8, %hi(gPreviousCpuTargetSpeed) # $t8, 0x8016 +/* 00AF20 8000A320 27183210 */ addiu $t8, %lo(gPreviousCpuTargetSpeed) # addiu $t8, $t8, 0x3210 /* 00AF24 8000A324 01984021 */ addu $t0, $t4, $t8 /* 00AF28 8000A328 E5040000 */ swc1 $f4, ($t0) .L8000A32C: /* 00AF2C 8000A32C 8FA400D0 */ lw $a0, 0xd0($sp) /* 00AF30 8000A330 0C004C77 */ jal check_ai_crossing_distance /* 00AF34 8000A334 AFA8003C */ sw $t0, 0x3c($sp) -/* 00AF38 8000A338 0C0034EE */ jal func_8000D3B8 +/* 00AF38 8000A338 0C0034EE */ jal cpu_track_position_factor /* 00AF3C 8000A33C 8FA400D0 */ lw $a0, 0xd0($sp) -/* 00AF40 8000A340 3C058016 */ lui $a1, %hi(D_801630E0) # $a1, 0x8016 -/* 00AF44 8000A344 94A530E0 */ lhu $a1, %lo(D_801630E0)($a1) -/* 00AF48 8000A348 0C00350E */ jal func_8000D438 +/* 00AF40 8000A340 3C058016 */ lui $a1, %hi(gCurrentNearestPathPoint) # $a1, 0x8016 +/* 00AF44 8000A344 94A530E0 */ lhu $a1, %lo(gCurrentNearestPathPoint)($a1) +/* 00AF48 8000A348 0C00350E */ jal determine_ideal_cpu_position_offset /* 00AF4C 8000A34C 8FA400D0 */ lw $a0, 0xd0($sp) /* 00AF50 8000A350 8FA60040 */ lw $a2, 0x40($sp) -/* 00AF54 8000A354 3C078016 */ lui $a3, %hi(D_80162FA0) # $a3, 0x8016 -/* 00AF58 8000A358 24E72FA0 */ addiu $a3, %lo(D_80162FA0) # addiu $a3, $a3, 0x2fa0 +/* 00AF54 8000A354 3C078016 */ lui $a3, %hi(gOffsetPosition) # $a3, 0x8016 +/* 00AF58 8000A358 24E72FA0 */ addiu $a3, %lo(gOffsetPosition) # addiu $a3, $a3, 0x2fa0 /* 00AF5C 8000A35C 8CC200BC */ lw $v0, 0xbc($a2) /* 00AF60 8000A360 C4E80000 */ lwc1 $f8, ($a3) /* 00AF64 8000A364 C4EA0008 */ lwc1 $f10, 8($a3) @@ -590,17 +590,17 @@ glabel func_80009B60 /* 00AF9C 8000A39C 3C0145C8 */ li $at, 0x45C80000 # 6400.000000 /* 00AFA0 8000A3A0 44819000 */ mtc1 $at, $f18 /* 00AFA4 8000A3A4 46021182 */ mul.s $f6, $f2, $f2 -/* 00AFA8 8000A3A8 3C0B8016 */ lui $t3, %hi(D_801630E0) # 0x8016 -/* 00AFAC 8000A3AC 3C0C8016 */ lui $t4, %hi(D_80164430) # $t4, 0x8016 -/* 00AFB0 8000A3B0 3C198016 */ lui $t9, %hi(D_80163448) # 0x8016 -/* 00AFB4 8000A3B4 3C0F8016 */ lui $t7, %hi(D_80164590) # 0x8016 +/* 00AFA8 8000A3A8 3C0B8016 */ lui $t3, %hi(gCurrentNearestPathPoint) # 0x8016 +/* 00AFAC 8000A3AC 3C0C8016 */ lui $t4, %hi(gSelectedPathCount) # $t4, 0x8016 +/* 00AFB0 8000A3B0 3C198016 */ lui $t9, %hi(gPlayerPathIndex) # 0x8016 +/* 00AFB4 8000A3B4 3C0F8016 */ lui $t7, %hi(gPathExpectedRotation) # 0x8016 /* 00AFB8 8000A3B8 46062200 */ add.s $f8, $f4, $f6 /* 00AFBC 8000A3BC 4608903C */ c.lt.s $f18, $f8 /* 00AFC0 8000A3C0 00000000 */ nop /* 00AFC4 8000A3C4 45000039 */ bc1f .L8000A4AC /* 00AFC8 8000A3C8 00000000 */ nop -/* 00AFCC 8000A3CC 3C0F8016 */ lui $t7, %hi(D_80163448) # $t7, 0x8016 -/* 00AFD0 8000A3D0 8DEF3448 */ lw $t7, %lo(D_80163448)($t7) +/* 00AFCC 8000A3CC 3C0F8016 */ lui $t7, %hi(gPlayerPathIndex) # $t7, 0x8016 +/* 00AFD0 8000A3D0 8DEF3448 */ lw $t7, %lo(gPlayerPathIndex)($t7) /* 00AFD4 8000A3D4 8FA400D0 */ lw $a0, 0xd0($sp) /* 00AFD8 8000A3D8 55E0002B */ bnel $t7, $zero, .L8000A488 /* 00AFDC 8000A3DC 8FA60040 */ lw $a2, 0x40($sp) @@ -608,16 +608,16 @@ glabel func_80009B60 /* 00AFE4 8000A3E4 AFA8003C */ sw $t0, 0x3c($sp) /* 00AFE8 8000A3E8 8FAB0034 */ lw $t3, 0x34($sp) /* 00AFEC 8000A3EC 3C0E8016 */ lui $t6, %hi(D_80162FF8) # 0x8016 -/* 00AFF0 8000A3F0 3C078016 */ lui $a3, %hi(D_80162FA0) # $a3, 0x8016 +/* 00AFF0 8000A3F0 3C078016 */ lui $a3, %hi(gOffsetPosition) # $a3, 0x8016 /* 00AFF4 8000A3F4 01CB7021 */ addu $t6, $t6, $t3 /* 00AFF8 8000A3F8 85CE2FF8 */ lh $t6, %lo(D_80162FF8)($t6) # 0x2ff8($t6) -/* 00AFFC 8000A3FC 24E72FA0 */ addiu $a3, %lo(D_80162FA0) # addiu $a3, $a3, 0x2fa0 +/* 00AFFC 8000A3FC 24E72FA0 */ addiu $a3, %lo(gOffsetPosition) # addiu $a3, $a3, 0x2fa0 /* 00B000 8000A400 8FA8003C */ lw $t0, 0x3c($sp) /* 00B004 8000A404 19C0001F */ blez $t6, .L8000A484 -/* 00B008 8000A408 3C048016 */ lui $a0, %hi(D_801630E0) # $a0, 0x8016 -/* 00B00C 8000A40C 948430E0 */ lhu $a0, %lo(D_801630E0)($a0) -/* 00B010 8000A410 3C188016 */ lui $t8, %hi(D_80164430) # $t8, 0x8016 -/* 00B014 8000A414 97184430 */ lhu $t8, %lo(D_80164430)($t8) +/* 00B008 8000A408 3C048016 */ lui $a0, %hi(gCurrentNearestPathPoint) # $a0, 0x8016 +/* 00B00C 8000A40C 948430E0 */ lhu $a0, %lo(gCurrentNearestPathPoint)($a0) +/* 00B010 8000A410 3C188016 */ lui $t8, %hi(gSelectedPathCount) # $t8, 0x8016 +/* 00B014 8000A414 97184430 */ lhu $t8, %lo(gSelectedPathCount)($t8) /* 00B018 8000A418 24840005 */ addiu $a0, $a0, 5 /* 00B01C 8000A41C 308CFFFF */ andi $t4, $a0, 0xffff /* 00B020 8000A420 0198001A */ div $zero, $t4, $t8 @@ -637,15 +637,15 @@ glabel func_80009B60 /* 00B050 8000A450 00002010 */ mfhi $a0 /* 00B054 8000A454 3C058016 */ lui $a1, %hi(D_80163090) # 0x8016 /* 00B058 8000A458 308AFFFF */ andi $t2, $a0, 0xffff -/* 00B05C 8000A45C 3C068016 */ lui $a2, %hi(D_80163448 + 2) # $a2, 0x8016 +/* 00B05C 8000A45C 3C068016 */ lui $a2, %hi(gPlayerPathIndex + 2) # $a2, 0x8016 /* 00B060 8000A460 00B92821 */ addu $a1, $a1, $t9 /* 00B064 8000A464 01402025 */ move $a0, $t2 /* 00B068 8000A468 8CA53090 */ lw $a1, %lo(D_80163090)($a1) # 0x3090($a1) -/* 00B06C 8000A46C 84C6344A */ lh $a2, %lo(D_80163448 + 2)($a2) -/* 00B070 8000A470 0C002EF6 */ jal func_8000BBD8 +/* 00B06C 8000A46C 84C6344A */ lh $a2, %lo(gPlayerPathIndex + 2)($a2) +/* 00B070 8000A470 0C002EF6 */ jal set_track_offset_position /* 00B074 8000A474 AFA8003C */ sw $t0, 0x3c($sp) -/* 00B078 8000A478 3C078016 */ lui $a3, %hi(D_80162FA0) # $a3, 0x8016 -/* 00B07C 8000A47C 24E72FA0 */ addiu $a3, %lo(D_80162FA0) # addiu $a3, $a3, 0x2fa0 +/* 00B078 8000A478 3C078016 */ lui $a3, %hi(gOffsetPosition) # $a3, 0x8016 +/* 00B07C 8000A47C 24E72FA0 */ addiu $a3, %lo(gOffsetPosition) # addiu $a3, $a3, 0x2fa0 /* 00B080 8000A480 8FA8003C */ lw $t0, 0x3c($sp) .L8000A484: /* 00B084 8000A484 8FA60040 */ lw $a2, 0x40($sp) @@ -660,14 +660,14 @@ glabel func_80009B60 /* 00B0A4 8000A4A4 10000017 */ b .L8000A504 /* 00B0A8 8000A4A8 A4CD002E */ sh $t5, 0x2e($a2) .L8000A4AC: -/* 00B0AC 8000A4AC 956B30E0 */ lhu $t3, %lo(D_801630E0)($t3) # 0x30e0($t3) -/* 00B0B0 8000A4B0 958C4430 */ lhu $t4, %lo(D_80164430)($t4) -/* 00B0B4 8000A4B4 8F393448 */ lw $t9, %lo(D_80163448)($t9) # 0x3448($t9) +/* 00B0AC 8000A4AC 956B30E0 */ lhu $t3, %lo(gCurrentNearestPathPoint)($t3) # 0x30e0($t3) +/* 00B0B0 8000A4B0 958C4430 */ lhu $t4, %lo(gSelectedPathCount)($t4) +/* 00B0B4 8000A4B4 8F393448 */ lw $t9, %lo(gPlayerPathIndex)($t9) # 0x3448($t9) /* 00B0B8 8000A4B8 256E0004 */ addiu $t6, $t3, 4 /* 00B0BC 8000A4BC 01CC001A */ div $zero, $t6, $t4 /* 00B0C0 8000A4C0 00196880 */ sll $t5, $t9, 2 /* 00B0C4 8000A4C4 01ED7821 */ addu $t7, $t7, $t5 -/* 00B0C8 8000A4C8 8DEF4590 */ lw $t7, %lo(D_80164590)($t7) # 0x4590($t7) +/* 00B0C8 8000A4C8 8DEF4590 */ lw $t7, %lo(gPathExpectedRotation)($t7) # 0x4590($t7) /* 00B0CC 8000A4CC 0000C010 */ mfhi $t8 /* 00B0D0 8000A4D0 00185040 */ sll $t2, $t8, 1 /* 00B0D4 8000A4D4 15800002 */ bnez $t4, .L8000A4E0 @@ -688,12 +688,12 @@ glabel func_80009B60 /* 00B104 8000A504 00C02025 */ move $a0, $a2 .L8000A508: /* 00B108 8000A508 00002825 */ move $a1, $zero -/* 00B10C 8000A50C 0C00DA03 */ jal func_8003680C +/* 00B10C 8000A50C 0C00DA03 */ jal apply_cpu_turn /* 00B110 8000A510 AFA8003C */ sw $t0, 0x3c($sp) /* 00B114 8000A514 8FA8003C */ lw $t0, 0x3c($sp) /* 00B118 8000A518 8FA400D0 */ lw $a0, 0xd0($sp) /* 00B11C 8000A51C 8FA60040 */ lw $a2, 0x40($sp) -/* 00B120 8000A520 0C002109 */ jal func_80008424 +/* 00B120 8000A520 0C002109 */ jal regulate_cpu_speed /* 00B124 8000A524 8D050000 */ lw $a1, ($t0) /* 00B128 8000A528 10000302 */ b .L8000B134 /* 00B12C 8000A52C 8FBF0014 */ lw $ra, 0x14($sp) @@ -721,19 +721,19 @@ glabel func_80009B60 /* 00B178 8000A578 0C0AD489 */ jal get_angle_between_two_vectors /* 00B17C 8000A57C 25C50014 */ addiu $a1, $t6, 0x14 /* 00B180 8000A580 8FAC0034 */ lw $t4, 0x34($sp) -/* 00B184 8000A584 3C188016 */ lui $t8, %hi(D_80163300) # $t8, 0x8016 -/* 00B188 8000A588 27183300 */ addiu $t8, %lo(D_80163300) # addiu $t8, $t8, 0x3300 +/* 00B184 8000A584 3C188016 */ lui $t8, %hi(sPlayerAngle) # $t8, 0x8016 +/* 00B188 8000A588 27183300 */ addiu $t8, %lo(sPlayerAngle) # addiu $t8, $t8, 0x3300 /* 00B18C 8000A58C 0002C823 */ negu $t9, $v0 /* 00B190 8000A590 01981821 */ addu $v1, $t4, $t8 /* 00B194 8000A594 A4790000 */ sh $t9, ($v1) -/* 00B198 8000A598 3C0F8016 */ lui $t7, %hi(sSomeNearestWaypoint) # $t7, 0x8016 -/* 00B19C 8000A59C 85EF2FCE */ lh $t7, %lo(sSomeNearestWaypoint)($t7) -/* 00B1A0 8000A5A0 3C0D8016 */ lui $t5, %hi(D_80164430) # $t5, 0x8016 -/* 00B1A4 8000A5A4 95AD4430 */ lhu $t5, %lo(D_80164430)($t5) +/* 00B198 8000A598 3C0F8016 */ lui $t7, %hi(sSomeNearestPathPoint) # $t7, 0x8016 +/* 00B19C 8000A59C 85EF2FCE */ lh $t7, %lo(sSomeNearestPathPoint)($t7) +/* 00B1A0 8000A5A0 3C0D8016 */ lui $t5, %hi(gSelectedPathCount) # $t5, 0x8016 +/* 00B1A4 8000A5A4 95AD4430 */ lhu $t5, %lo(gSelectedPathCount)($t5) /* 00B1A8 8000A5A8 25EA0002 */ addiu $t2, $t7, 2 -/* 00B1AC 8000A5AC 3C0C8016 */ lui $t4, %hi(D_801631DC) # $t4, 0x8016 +/* 00B1AC 8000A5AC 3C0C8016 */ lui $t4, %hi(gCurrentPathPointExpectedRotationPath) # $t4, 0x8016 /* 00B1B0 8000A5B0 014D001A */ div $zero, $t2, $t5 -/* 00B1B4 8000A5B4 8D8C31DC */ lw $t4, %lo(D_801631DC)($t4) +/* 00B1B4 8000A5B4 8D8C31DC */ lw $t4, %lo(gCurrentPathPointExpectedRotationPath)($t4) /* 00B1B8 8000A5B8 00005810 */ mfhi $t3 /* 00B1BC 8000A5BC 000B7040 */ sll $t6, $t3, 1 /* 00B1C0 8000A5C0 018EC021 */ addu $t8, $t4, $t6 @@ -870,43 +870,43 @@ glabel func_80009B60 /* 00B390 8000A790 01416824 */ and $t5, $t2, $at /* 00B394 8000A794 ADED00BC */ sw $t5, 0xbc($t7) .L8000A798: -/* 00B398 8000A798 3C0B8016 */ lui $t3, %hi(D_80163378) # $t3, 0x8016 -/* 00B39C 8000A79C 8D6B3378 */ lw $t3, %lo(D_80163378)($t3) +/* 00B398 8000A798 3C0B8016 */ lui $t3, %hi(gIncrementUpdatePlayer) # $t3, 0x8016 +/* 00B39C 8000A79C 8D6B3378 */ lw $t3, %lo(gIncrementUpdatePlayer)($t3) /* 00B3A0 8000A7A0 8FB80030 */ lw $t8, 0x30($sp) /* 00B3A4 8000A7A4 8FA400D0 */ lw $a0, 0xd0($sp) /* 00B3A8 8000A7A8 316C0001 */ andi $t4, $t3, 1 /* 00B3AC 8000A7AC 11980010 */ beq $t4, $t8, .L8000A7F0 /* 00B3B0 8000A7B0 8FAA0040 */ lw $t2, 0x40($sp) /* 00B3B4 8000A7B4 8FB90034 */ lw $t9, 0x34($sp) -/* 00B3B8 8000A7B8 3C058016 */ lui $a1, %hi(D_80163050) # 0x8016 +/* 00B3B8 8000A7B8 3C058016 */ lui $a1, %hi(gPreviousAngleSteering) # 0x8016 /* 00B3BC 8000A7BC 8FA40040 */ lw $a0, 0x40($sp) /* 00B3C0 8000A7C0 00B92821 */ addu $a1, $a1, $t9 -/* 00B3C4 8000A7C4 0C00DA03 */ jal func_8003680C -/* 00B3C8 8000A7C8 84A53050 */ lh $a1, %lo(D_80163050)($a1) # 0x3050($a1) +/* 00B3C4 8000A7C4 0C00DA03 */ jal apply_cpu_turn +/* 00B3C8 8000A7C8 84A53050 */ lh $a1, %lo(gPreviousAngleSteering)($a1) # 0x3050($a1) /* 00B3CC 8000A7CC 8FAE0038 */ lw $t6, 0x38($sp) -/* 00B3D0 8000A7D0 3C058016 */ lui $a1, %hi(D_80163210) # 0x8016 +/* 00B3D0 8000A7D0 3C058016 */ lui $a1, %hi(gPreviousCpuTargetSpeed) # 0x8016 /* 00B3D4 8000A7D4 8FA400D0 */ lw $a0, 0xd0($sp) /* 00B3D8 8000A7D8 00AE2821 */ addu $a1, $a1, $t6 -/* 00B3DC 8000A7DC 8CA53210 */ lw $a1, %lo(D_80163210)($a1) # 0x3210($a1) -/* 00B3E0 8000A7E0 0C002109 */ jal func_80008424 +/* 00B3DC 8000A7DC 8CA53210 */ lw $a1, %lo(gPreviousCpuTargetSpeed)($a1) # 0x3210($a1) +/* 00B3E0 8000A7E0 0C002109 */ jal regulate_cpu_speed /* 00B3E4 8000A7E4 8FA60040 */ lw $a2, 0x40($sp) /* 00B3E8 8000A7E8 10000252 */ b .L8000B134 /* 00B3EC 8000A7EC 8FBF0014 */ lw $ra, 0x14($sp) .L8000A7F0: -/* 00B3F0 8000A7F0 3C058016 */ lui $a1, %hi(sSomeNearestWaypoint) # $a1, 0x8016 +/* 00B3F0 8000A7F0 3C058016 */ lui $a1, %hi(sSomeNearestPathPoint) # $a1, 0x8016 /* 00B3F4 8000A7F4 254D0014 */ addiu $t5, $t2, 0x14 /* 00B3F8 8000A7F8 AFAD001C */ sw $t5, 0x1c($sp) -/* 00B3FC 8000A7FC 0C002DF9 */ jal func_8000B7E4 -/* 00B400 8000A800 94A52FCE */ lhu $a1, %lo(sSomeNearestWaypoint)($a1) +/* 00B3FC 8000A7FC 0C002DF9 */ jal are_in_curve +/* 00B400 8000A800 94A52FCE */ lhu $a1, %lo(sSomeNearestPathPoint)($a1) /* 00B404 8000A804 8FAF0038 */ lw $t7, 0x38($sp) -/* 00B408 8000A808 3C0B8016 */ lui $t3, %hi(D_801630B8) # $t3, 0x8016 -/* 00B40C 8000A80C 256B30B8 */ addiu $t3, %lo(D_801630B8) # addiu $t3, $t3, 0x30b8 +/* 00B408 8000A808 3C0B8016 */ lui $t3, %hi(gIsPlayerInCurve) # $t3, 0x8016 +/* 00B40C 8000A80C 256B30B8 */ addiu $t3, %lo(gIsPlayerInCurve) # addiu $t3, $t3, 0x30b8 /* 00B410 8000A810 01EB1821 */ addu $v1, $t7, $t3 /* 00B414 8000A814 AC620000 */ sw $v0, ($v1) -/* 00B418 8000A818 3C058016 */ lui $a1, %hi(sSomeNearestWaypoint) # $a1, 0x8016 -/* 00B41C 8000A81C 94A52FCE */ lhu $a1, %lo(sSomeNearestWaypoint)($a1) +/* 00B418 8000A818 3C058016 */ lui $a1, %hi(sSomeNearestPathPoint) # $a1, 0x8016 +/* 00B41C 8000A81C 94A52FCE */ lhu $a1, %lo(sSomeNearestPathPoint)($a1) /* 00B420 8000A820 AFA30028 */ sw $v1, 0x28($sp) -/* 00B424 8000A824 0C00350E */ jal func_8000D438 +/* 00B424 8000A824 0C00350E */ jal determine_ideal_cpu_position_offset /* 00B428 8000A828 8FA400D0 */ lw $a0, 0xd0($sp) /* 00B42C 8000A82C 3C02800E */ lui $v0, %hi(gCurrentCourseId) /* 00B430 8000A830 8442C5A0 */ lh $v0, %lo(gCurrentCourseId)($v0) @@ -914,17 +914,17 @@ glabel func_80009B60 /* 00B438 8000A838 8FA90038 */ lw $t1, 0x38($sp) /* 00B43C 8000A83C 10410099 */ beq $v0, $at, .L8000AAA4 /* 00B440 8000A840 00000000 */ nop -/* 00B444 8000A844 3C058016 */ lui $a1, %hi(D_80164450) # 0x8016 +/* 00B444 8000A844 3C058016 */ lui $a1, %hi(gNumPathPointsTraversed) # 0x8016 /* 00B448 8000A848 00A92821 */ addu $a1, $a1, $t1 -/* 00B44C 8000A84C 8CA54450 */ lw $a1, %lo(D_80164450)($a1) # 0x4450($a1) -/* 00B450 8000A850 3C198016 */ lui $t9, %hi(D_801634F8) # $t9, 0x8016 -/* 00B454 8000A854 273934F8 */ addiu $t9, %lo(D_801634F8) # addiu $t9, $t9, 0x34f8 +/* 00B44C 8000A84C 8CA54450 */ lw $a1, %lo(gNumPathPointsTraversed)($a1) # 0x4450($a1) +/* 00B450 8000A850 3C198016 */ lui $t9, %hi(gPlayerTrackPositionFactorInstruction) # $t9, 0x8016 +/* 00B454 8000A854 273934F8 */ addiu $t9, %lo(gPlayerTrackPositionFactorInstruction) # addiu $t9, $t9, 0x34f8 /* 00B458 8000A858 28A1000B */ slti $at, $a1, 0xb /* 00B45C 8000A85C 10200045 */ beqz $at, .L8000A974 /* 00B460 8000A860 00000000 */ nop /* 00B464 8000A864 8FAC00D0 */ lw $t4, 0xd0($sp) -/* 00B468 8000A868 3C048016 */ lui $a0, %hi(D_801630E0) # $a0, 0x8016 -/* 00B46C 8000A86C 948430E0 */ lhu $a0, %lo(D_801630E0)($a0) +/* 00B468 8000A868 3C048016 */ lui $a0, %hi(gCurrentNearestPathPoint) # $a0, 0x8016 +/* 00B46C 8000A86C 948430E0 */ lhu $a0, %lo(gCurrentNearestPathPoint)($a0) /* 00B470 8000A870 000CC100 */ sll $t8, $t4, 4 /* 00B474 8000A874 18A0001F */ blez $a1, .L8000A8F4 /* 00B478 8000A878 03191821 */ addu $v1, $t8, $t9 @@ -933,8 +933,8 @@ glabel func_80009B60 /* 00B484 8000A884 24840008 */ addiu $a0, $a0, 8 /* 00B488 8000A888 24840014 */ addiu $a0, $a0, 0x14 /* 00B48C 8000A88C 308EFFFF */ andi $t6, $a0, 0xffff -/* 00B490 8000A890 3C0A8016 */ lui $t2, %hi(D_80164430) # $t2, 0x8016 -/* 00B494 8000A894 954A4430 */ lhu $t2, %lo(D_80164430)($t2) +/* 00B490 8000A890 3C0A8016 */ lui $t2, %hi(gSelectedPathCount) # $t2, 0x8016 +/* 00B494 8000A894 954A4430 */ lhu $t2, %lo(gSelectedPathCount)($t2) /* 00B498 8000A898 01C02025 */ move $a0, $t6 /* 00B49C 8000A89C 24050000 */ li $a1, 0 /* 00B4A0 8000A8A0 01CA001A */ div $zero, $t6, $t2 @@ -953,7 +953,7 @@ glabel func_80009B60 /* 00B4CC 8000A8CC 308DFFFF */ andi $t5, $a0, 0xffff /* 00B4D0 8000A8D0 01A02025 */ move $a0, $t5 /* 00B4D4 8000A8D4 00003025 */ move $a2, $zero -/* 00B4D8 8000A8D8 0C002EF6 */ jal func_8000BBD8 +/* 00B4D8 8000A8D8 0C002EF6 */ jal set_track_offset_position /* 00B4DC 8000A8DC AFA30030 */ sw $v1, 0x30($sp) /* 00B4E0 8000A8E0 8FA30030 */ lw $v1, 0x30($sp) /* 00B4E4 8000A8E4 44805000 */ mtc1 $zero, $f10 @@ -964,10 +964,10 @@ glabel func_80009B60 /* 00B4F4 8000A8F4 24840008 */ addiu $a0, $a0, 8 .L8000A8F8: /* 00B4F8 8000A8F8 308FFFFF */ andi $t7, $a0, 0xffff -/* 00B4FC 8000A8FC 3C0B8016 */ lui $t3, %hi(D_80164430) # $t3, 0x8016 -/* 00B500 8000A900 956B4430 */ lhu $t3, %lo(D_80164430)($t3) +/* 00B4FC 8000A8FC 3C0B8016 */ lui $t3, %hi(gSelectedPathCount) # $t3, 0x8016 +/* 00B500 8000A900 956B4430 */ lhu $t3, %lo(gSelectedPathCount)($t3) /* 00B504 8000A904 01E02025 */ move $a0, $t7 -/* 00B508 8000A908 3C188016 */ lui $t8, %hi(D_80163068) # $t8, 0x8016 +/* 00B508 8000A908 3C188016 */ lui $t8, %hi(gTrackPositionFactor) # $t8, 0x8016 /* 00B50C 8000A90C 01EB001A */ div $zero, $t7, $t3 /* 00B510 8000A910 15600002 */ bnez $t3, .L8000A91C /* 00B514 8000A914 00000000 */ nop @@ -981,15 +981,15 @@ glabel func_80009B60 /* 00B530 8000A930 0006000D */ break 6 .L8000A934: /* 00B534 8000A934 00002010 */ mfhi $a0 -/* 00B538 8000A938 27183068 */ addiu $t8, %lo(D_80163068) # addiu $t8, $t8, 0x3068 +/* 00B538 8000A938 27183068 */ addiu $t8, %lo(gTrackPositionFactor) # addiu $t8, $t8, 0x3068 /* 00B53C 8000A93C 308CFFFF */ andi $t4, $a0, 0xffff /* 00B540 8000A940 01384021 */ addu $t0, $t1, $t8 -/* 00B544 8000A944 3C068016 */ lui $a2, %hi(D_80163448 + 2) # $a2, 0x8016 +/* 00B544 8000A944 3C068016 */ lui $a2, %hi(gPlayerPathIndex + 2) # $a2, 0x8016 /* 00B548 8000A948 01802025 */ move $a0, $t4 -/* 00B54C 8000A94C 84C6344A */ lh $a2, %lo(D_80163448 + 2)($a2) +/* 00B54C 8000A94C 84C6344A */ lh $a2, %lo(gPlayerPathIndex + 2)($a2) /* 00B550 8000A950 8D050000 */ lw $a1, ($t0) /* 00B554 8000A954 AFA80020 */ sw $t0, 0x20($sp) -/* 00B558 8000A958 0C002EF6 */ jal func_8000BBD8 +/* 00B558 8000A958 0C002EF6 */ jal set_track_offset_position /* 00B55C 8000A95C AFA30030 */ sw $v1, 0x30($sp) /* 00B560 8000A960 8FA80020 */ lw $t0, 0x20($sp) /* 00B564 8000A964 8FA30030 */ lw $v1, 0x30($sp) @@ -1005,12 +1005,12 @@ glabel func_80009B60 /* 00B588 8000A988 3C0A8016 */ lui $t2, %hi(D_80162FF8) # 0x8016 /* 00B58C 8000A98C 014E5021 */ addu $t2, $t2, $t6 /* 00B590 8000A990 854A2FF8 */ lh $t2, %lo(D_80162FF8)($t2) # 0x2ff8($t2) -/* 00B594 8000A994 3C0F8016 */ lui $t7, %hi(D_80164430) # $t7, 0x8016 +/* 00B594 8000A994 3C0F8016 */ lui $t7, %hi(gSelectedPathCount) # $t7, 0x8016 /* 00B598 8000A998 15400019 */ bnez $t2, .L8000AA00 /* 00B59C 8000A99C 00000000 */ nop -/* 00B5A0 8000A9A0 3C048016 */ lui $a0, %hi(D_801630E0) # $a0, 0x8016 -/* 00B5A4 8000A9A4 948430E0 */ lhu $a0, %lo(D_801630E0)($a0) -/* 00B5A8 8000A9A8 95EF4430 */ lhu $t7, %lo(D_80164430)($t7) +/* 00B5A0 8000A9A0 3C048016 */ lui $a0, %hi(gCurrentNearestPathPoint) # $a0, 0x8016 +/* 00B5A4 8000A9A4 948430E0 */ lhu $a0, %lo(gCurrentNearestPathPoint)($a0) +/* 00B5A8 8000A9A8 95EF4430 */ lhu $t7, %lo(gSelectedPathCount)($t7) /* 00B5AC 8000A9AC 3C05BF33 */ lui $a1, (0xBF333333 >> 16) # lui $a1, 0xbf33 /* 00B5B0 8000A9B0 24840007 */ addiu $a0, $a0, 7 /* 00B5B4 8000A9B4 308DFFFF */ andi $t5, $a0, 0xffff @@ -1029,14 +1029,14 @@ glabel func_80009B60 .L8000A9E4: /* 00B5E4 8000A9E4 00002010 */ mfhi $a0 /* 00B5E8 8000A9E8 308BFFFF */ andi $t3, $a0, 0xffff -/* 00B5EC 8000A9EC 3C068016 */ lui $a2, %hi(D_80163448 + 2) # $a2, 0x8016 +/* 00B5EC 8000A9EC 3C068016 */ lui $a2, %hi(gPlayerPathIndex + 2) # $a2, 0x8016 /* 00B5F0 8000A9F0 01602025 */ move $a0, $t3 -/* 00B5F4 8000A9F4 84C6344A */ lh $a2, %lo(D_80163448 + 2)($a2) -/* 00B5F8 8000A9F8 0C002EF6 */ jal func_8000BBD8 +/* 00B5F4 8000A9F4 84C6344A */ lh $a2, %lo(gPlayerPathIndex + 2)($a2) +/* 00B5F8 8000A9F8 0C002EF6 */ jal set_track_offset_position /* 00B5FC 8000A9FC 34A53333 */ ori $a1, (0xBF333333 & 0xFFFF) # ori $a1, $a1, 0x3333 .L8000AA00: -/* 00B600 8000AA00 3C0C8016 */ lui $t4, %hi(D_80163448) # $t4, 0x8016 -/* 00B604 8000AA04 8D8C3448 */ lw $t4, %lo(D_80163448)($t4) +/* 00B600 8000AA00 3C0C8016 */ lui $t4, %hi(gPlayerPathIndex) # $t4, 0x8016 +/* 00B604 8000AA04 8D8C3448 */ lw $t4, %lo(gPlayerPathIndex)($t4) /* 00B608 8000AA08 3C198016 */ lui $t9, %hi(D_80162FF8) # $t9, 0x8016 /* 00B60C 8000AA0C 27392FF8 */ addiu $t9, %lo(D_80162FF8) # addiu $t9, $t9, 0x2ff8 /* 00B610 8000AA10 15800024 */ bnez $t4, .L8000AAA4 @@ -1046,14 +1046,14 @@ glabel func_80009B60 /* 00B620 8000AA20 0C002C50 */ jal func_8000B140 /* 00B624 8000AA24 8FA400D0 */ lw $a0, 0xd0($sp) /* 00B628 8000AA28 8FAA003C */ lw $t2, 0x3c($sp) -/* 00B62C 8000AA2C 3C0B8016 */ lui $t3, %hi(D_80164430) # $t3, 0x8016 +/* 00B62C 8000AA2C 3C0B8016 */ lui $t3, %hi(gSelectedPathCount) # $t3, 0x8016 /* 00B630 8000AA30 8FB80038 */ lw $t8, 0x38($sp) /* 00B634 8000AA34 854D0000 */ lh $t5, ($t2) /* 00B638 8000AA38 19A0001A */ blez $t5, .L8000AAA4 /* 00B63C 8000AA3C 00000000 */ nop -/* 00B640 8000AA40 3C048016 */ lui $a0, %hi(D_801630E0) # $a0, 0x8016 -/* 00B644 8000AA44 948430E0 */ lhu $a0, %lo(D_801630E0)($a0) -/* 00B648 8000AA48 956B4430 */ lhu $t3, %lo(D_80164430)($t3) +/* 00B640 8000AA40 3C048016 */ lui $a0, %hi(gCurrentNearestPathPoint) # $a0, 0x8016 +/* 00B644 8000AA44 948430E0 */ lhu $a0, %lo(gCurrentNearestPathPoint)($a0) +/* 00B648 8000AA48 956B4430 */ lhu $t3, %lo(gSelectedPathCount)($t3) /* 00B64C 8000AA4C 3C058016 */ lui $a1, %hi(D_80163090) # 0x8016 /* 00B650 8000AA50 24840005 */ addiu $a0, $a0, 5 /* 00B654 8000AA54 308FFFFF */ andi $t7, $a0, 0xffff @@ -1073,17 +1073,17 @@ glabel func_80009B60 /* 00B684 8000AA84 00002010 */ mfhi $a0 /* 00B688 8000AA88 308CFFFF */ andi $t4, $a0, 0xffff /* 00B68C 8000AA8C 00B82821 */ addu $a1, $a1, $t8 -/* 00B690 8000AA90 3C068016 */ lui $a2, %hi(D_80163448 + 2) # $a2, 0x8016 +/* 00B690 8000AA90 3C068016 */ lui $a2, %hi(gPlayerPathIndex + 2) # $a2, 0x8016 /* 00B694 8000AA94 01802025 */ move $a0, $t4 -/* 00B698 8000AA98 84C6344A */ lh $a2, %lo(D_80163448 + 2)($a2) -/* 00B69C 8000AA9C 0C002EF6 */ jal func_8000BBD8 +/* 00B698 8000AA98 84C6344A */ lh $a2, %lo(gPlayerPathIndex + 2)($a2) +/* 00B69C 8000AA9C 0C002EF6 */ jal set_track_offset_position /* 00B6A0 8000AAA0 8CA53090 */ lw $a1, %lo(D_80163090)($a1) # 0x3090($a1) .L8000AAA4: /* 00B6A4 8000AAA4 3C0E800E */ lui $t6, %hi(gCurrentCourseId) /* 00B6A8 8000AAA8 85CEC5A0 */ lh $t6, %lo(gCurrentCourseId)($t6) /* 00B6AC 8000AAAC 8FA90038 */ lw $t1, 0x38($sp) -/* 00B6B0 8000AAB0 3C198016 */ lui $t9, %hi(D_80163068) # $t9, 0x8016 -/* 00B6B4 8000AAB4 27393068 */ addiu $t9, %lo(D_80163068) # addiu $t9, $t9, 0x3068 +/* 00B6B0 8000AAB0 3C198016 */ lui $t9, %hi(gTrackPositionFactor) # $t9, 0x8016 +/* 00B6B4 8000AAB4 27393068 */ addiu $t9, %lo(gTrackPositionFactor) # addiu $t9, $t9, 0x3068 /* 00B6B8 8000AAB8 24010014 */ li $at, 20 /* 00B6BC 8000AABC 15C10038 */ bne $t6, $at, .L8000ABA0 /* 00B6C0 8000AAC0 01394021 */ addu $t0, $t1, $t9 @@ -1092,8 +1092,8 @@ glabel func_80009B60 /* 00B6CC 8000AACC 24010003 */ li $at, 3 /* 00B6D0 8000AAD0 004A1021 */ addu $v0, $v0, $t2 /* 00B6D4 8000AAD4 84423410 */ lh $v0, %lo(D_80163410)($v0) # 0x3410($v0) -/* 00B6D8 8000AAD8 3C078016 */ lui $a3, %hi(D_80162FA0) # $a3, 0x8016 -/* 00B6DC 8000AADC 24E72FA0 */ addiu $a3, %lo(D_80162FA0) # addiu $a3, $a3, 0x2fa0 +/* 00B6D8 8000AAD8 3C078016 */ lui $a3, %hi(gOffsetPosition) # $a3, 0x8016 +/* 00B6DC 8000AADC 24E72FA0 */ addiu $a3, %lo(gOffsetPosition) # addiu $a3, $a3, 0x2fa0 /* 00B6E0 8000AAE0 10410005 */ beq $v0, $at, .L8000AAF8 /* 00B6E4 8000AAE4 24010004 */ li $at, 4 /* 00B6E8 8000AAE8 1041000C */ beq $v0, $at, .L8000AB1C @@ -1112,21 +1112,21 @@ glabel func_80009B60 /* 00B718 8000AB18 E4E60008 */ swc1 $f6, 8($a3) .L8000AB1C: /* 00B71C 8000AB1C 8FAC0034 */ lw $t4, 0x34($sp) -/* 00B720 8000AB20 3C188016 */ lui $t8, %hi(gWaypointCountByPathIndex) # 0x8016 +/* 00B720 8000AB20 3C188016 */ lui $t8, %hi(gPathCountByPathIndex) # 0x8016 /* 00B724 8000AB24 95AF0000 */ lhu $t7, ($t5) /* 00B728 8000AB28 030CC021 */ addu $t8, $t8, $t4 -/* 00B72C 8000AB2C 971845C8 */ lhu $t8, %lo(gWaypointCountByPathIndex)($t8) # 0x45c8($t8) +/* 00B72C 8000AB2C 971845C8 */ lhu $t8, %lo(gPathCountByPathIndex)($t8) # 0x45c8($t8) /* 00B730 8000AB30 25EB000A */ addiu $t3, $t7, 0xa -/* 00B734 8000AB34 3C0A8016 */ lui $t2, %hi(D_80164550) # 0x8016 +/* 00B734 8000AB34 3C0A8016 */ lui $t2, %hi(gTrackPaths) # 0x8016 /* 00B738 8000AB38 0178001A */ div $zero, $t3, $t8 /* 00B73C 8000AB3C 01495021 */ addu $t2, $t2, $t1 -/* 00B740 8000AB40 8D4A4550 */ lw $t2, %lo(D_80164550)($t2) # 0x4550($t2) +/* 00B740 8000AB40 8D4A4550 */ lw $t2, %lo(gTrackPaths)($t2) # 0x4550($t2) /* 00B744 8000AB44 0000C810 */ mfhi $t9 /* 00B748 8000AB48 001970C0 */ sll $t6, $t9, 3 /* 00B74C 8000AB4C 01CA1021 */ addu $v0, $t6, $t2 /* 00B750 8000AB50 844D0000 */ lh $t5, ($v0) -/* 00B754 8000AB54 3C078016 */ lui $a3, %hi(D_80162FA0) # $a3, 0x8016 -/* 00B758 8000AB58 24E72FA0 */ addiu $a3, %lo(D_80162FA0) # addiu $a3, $a3, 0x2fa0 +/* 00B754 8000AB54 3C078016 */ lui $a3, %hi(gOffsetPosition) # $a3, 0x8016 +/* 00B758 8000AB58 24E72FA0 */ addiu $a3, %lo(gOffsetPosition) # addiu $a3, $a3, 0x2fa0 /* 00B75C 8000AB5C 448D9000 */ mtc1 $t5, $f18 /* 00B760 8000AB60 17000002 */ bnez $t8, .L8000AB6C /* 00B764 8000AB64 00000000 */ nop @@ -1147,18 +1147,18 @@ glabel func_80009B60 /* 00B798 8000AB98 46805420 */ cvt.s.w $f16, $f10 /* 00B79C 8000AB9C E4F00008 */ swc1 $f16, 8($a3) .L8000ABA0: -/* 00B7A0 8000ABA0 3C0C8016 */ lui $t4, %hi(D_80163178) # $t4, 0x8016 -/* 00B7A4 8000ABA4 3C078016 */ lui $a3, %hi(D_80162FA0) # 0x8016 -/* 00B7A8 8000ABA8 258C3178 */ addiu $t4, %lo(D_80163178) # addiu $t4, $t4, 0x3178 -/* 00B7AC 8000ABAC 24E52FA0 */ addiu $a1, $a3, %lo(D_80162FA0) # 0x2fa0 +/* 00B7A0 8000ABA0 3C0C8016 */ lui $t4, %hi(gPreviousPlayerAiOffsetX) # $t4, 0x8016 +/* 00B7A4 8000ABA4 3C078016 */ lui $a3, %hi(gOffsetPosition) # 0x8016 +/* 00B7A8 8000ABA8 258C3178 */ addiu $t4, %lo(gPreviousPlayerAiOffsetX) # addiu $t4, $t4, 0x3178 +/* 00B7AC 8000ABAC 24E52FA0 */ addiu $a1, $a3, %lo(gOffsetPosition) # 0x2fa0 /* 00B7B0 8000ABB0 012C1021 */ addu $v0, $t1, $t4 /* 00B7B4 8000ABB4 C4460000 */ lwc1 $f6, ($v0) /* 00B7B8 8000ABB8 C4A40000 */ lwc1 $f4, ($a1) /* 00B7BC 8000ABBC 3C013F00 */ li $at, 0x3F000000 # 0.500000 /* 00B7C0 8000ABC0 44810000 */ mtc1 $at, $f0 /* 00B7C4 8000ABC4 46062480 */ add.s $f18, $f4, $f6 -/* 00B7C8 8000ABC8 3C0B8016 */ lui $t3, %hi(D_801631A0) # $t3, 0x8016 -/* 00B7CC 8000ABCC 256B31A0 */ addiu $t3, %lo(D_801631A0) # addiu $t3, $t3, 0x31a0 +/* 00B7C8 8000ABC8 3C0B8016 */ lui $t3, %hi(gPreviousPlayerAiOffsetZ) # $t3, 0x8016 +/* 00B7CC 8000ABCC 256B31A0 */ addiu $t3, %lo(gPreviousPlayerAiOffsetZ) # addiu $t3, $t3, 0x31a0 /* 00B7D0 8000ABD0 012B1821 */ addu $v1, $t1, $t3 /* 00B7D4 8000ABD4 46009202 */ mul.s $f8, $f18, $f0 /* 00B7D8 8000ABD8 C4AA0008 */ lwc1 $f10, 8($a1) @@ -1195,7 +1195,7 @@ glabel func_80009B60 /* 00B854 8000AC54 4600218D */ trunc.w.s $f6, $f4 /* 00B858 8000AC58 44055000 */ mfc1 $a1, $f10 /* 00B85C 8000AC5C 3C0B800E */ lui $t3, %hi(gCurrentCourseId) -/* 00B860 8000AC60 3C03800E */ lui $v1, %hi(gKartAISteeringSensitivity) +/* 00B860 8000AC60 3C03800E */ lui $v1, %hi(cpu_SteeringSensitivity) /* 00B864 8000AC64 00057C00 */ sll $t7, $a1, 0x10 /* 00B868 8000AC68 44023000 */ mfc1 $v0, $f6 /* 00B86C 8000AC6C 000F6403 */ sra $t4, $t7, 0x10 @@ -1209,12 +1209,12 @@ glabel func_80009B60 /* 00B888 8000AC88 000A6C03 */ sra $t5, $t2, 0x10 /* 00B88C 8000AC8C 00CD082A */ slt $at, $a2, $t5 /* 00B890 8000AC90 10200004 */ beqz $at, .L8000ACA4 -/* 00B894 8000AC94 3C188016 */ lui $t8, %hi(D_801631D8) # $t8, 0x8016 +/* 00B894 8000AC94 3C188016 */ lui $t8, %hi(gCurrentTrackSectionTypesPath) # $t8, 0x8016 /* 00B898 8000AC98 00023400 */ sll $a2, $v0, 0x10 /* 00B89C 8000AC9C 00067C03 */ sra $t7, $a2, 0x10 /* 00B8A0 8000ACA0 01E03025 */ move $a2, $t7 .L8000ACA4: -/* 00B8A4 8000ACA4 8F1831D8 */ lw $t8, %lo(D_801631D8)($t8) +/* 00B8A4 8000ACA4 8F1831D8 */ lw $t8, %lo(gCurrentTrackSectionTypesPath)($t8) /* 00B8A8 8000ACA8 8FB90034 */ lw $t9, 0x34($sp) /* 00B8AC 8000ACAC 856BC5A0 */ lh $t3, %lo(gCurrentCourseId)($t3) /* 00B8B0 8000ACB0 24010002 */ li $at, 2 @@ -1223,7 +1223,7 @@ glabel func_80009B60 /* 00B8BC 8000ACBC 000B6040 */ sll $t4, $t3, 1 /* 00B8C0 8000ACC0 006C1821 */ addu $v1, $v1, $t4 /* 00B8C4 8000ACC4 10410006 */ beq $v0, $at, .L8000ACE0 -/* 00B8C8 8000ACC8 8463CA20 */ lh $v1, %lo(gKartAISteeringSensitivity)($v1) +/* 00B8C8 8000ACC8 8463CA20 */ lh $v1, %lo(cpu_SteeringSensitivity)($v1) /* 00B8CC 8000ACCC 24010003 */ li $at, 3 /* 00B8D0 8000ACD0 50410014 */ beql $v0, $at, .L8000AD24 /* 00B8D4 8000ACD4 3C013F00 */ lui $at, 0x3f00 @@ -1267,10 +1267,10 @@ glabel func_80009B60 .L8000AD5C: /* 00B95C 8000AD5C 8FAA0034 */ lw $t2, 0x34($sp) .L8000AD60: -/* 00B960 8000AD60 3C0D8016 */ lui $t5, %hi(gKartAIBehaviourState) # 0x8016 +/* 00B960 8000AD60 3C0D8016 */ lui $t5, %hi(cpu_BehaviourState) # 0x8016 /* 00B964 8000AD64 24010002 */ li $at, 2 /* 00B968 8000AD68 01AA6821 */ addu $t5, $t5, $t2 -/* 00B96C 8000AD6C 95AD32E8 */ lhu $t5, %lo(gKartAIBehaviourState)($t5) # 0x32e8($t5) +/* 00B96C 8000AD6C 95AD32E8 */ lhu $t5, %lo(cpu_BehaviourState)($t5) # 0x32e8($t5) /* 00B970 8000AD70 15A10013 */ bne $t5, $at, .L8000ADC0 /* 00B974 8000AD74 3C01800F */ lui $at, %hi(D_800ECFB8) # $at, 0x800f /* 00B978 8000AD78 C424CFB8 */ lwc1 $f4, %lo(D_800ECFB8)($at) @@ -1309,8 +1309,8 @@ glabel func_80009B60 /* 00B9F0 8000ADF0 24050035 */ li $a1, 53 /* 00B9F4 8000ADF4 00C30019 */ multu $a2, $v1 /* 00B9F8 8000ADF8 8FAE0034 */ lw $t6, 0x34($sp) -/* 00B9FC 8000ADFC 3C0A8016 */ lui $t2, %hi(D_80163050) # $t2, 0x8016 -/* 00BA00 8000AE00 254A3050 */ addiu $t2, %lo(D_80163050) # addiu $t2, $t2, 0x3050 +/* 00B9FC 8000ADFC 3C0A8016 */ lui $t2, %hi(gPreviousAngleSteering) # $t2, 0x8016 +/* 00BA00 8000AE00 254A3050 */ addiu $t2, %lo(gPreviousAngleSteering) # addiu $t2, $t2, 0x3050 /* 00BA04 8000AE04 01CA1021 */ addu $v0, $t6, $t2 /* 00BA08 8000AE08 844D0000 */ lh $t5, ($v0) /* 00BA0C 8000AE0C 3C014000 */ li $at, 0x40000000 # 2.000000 @@ -1331,13 +1331,13 @@ glabel func_80009B60 /* 00BA48 8000AE48 000C2C03 */ sra $a1, $t4, 0x10 .L8000AE4C: /* 00BA4C 8000AE4C 8FB90034 */ lw $t9, 0x34($sp) -/* 00BA50 8000AE50 3C0E8016 */ lui $t6, %hi(D_80163050) # $t6, 0x8016 -/* 00BA54 8000AE54 25CE3050 */ addiu $t6, %lo(D_80163050) # addiu $t6, $t6, 0x3050 +/* 00BA50 8000AE50 3C0E8016 */ lui $t6, %hi(gPreviousAngleSteering) # $t6, 0x8016 +/* 00BA54 8000AE54 25CE3050 */ addiu $t6, %lo(gPreviousAngleSteering) # addiu $t6, $t6, 0x3050 /* 00BA58 8000AE58 10000025 */ b .L8000AEF0 /* 00BA5C 8000AE5C 032E1021 */ addu $v0, $t9, $t6 .L8000AE60: -/* 00BA60 8000AE60 3C0D8016 */ lui $t5, %hi(D_80163050) # $t5, 0x8016 -/* 00BA64 8000AE64 25AD3050 */ addiu $t5, %lo(D_80163050) # addiu $t5, $t5, 0x3050 +/* 00BA60 8000AE60 3C0D8016 */ lui $t5, %hi(gPreviousAngleSteering) # $t5, 0x8016 +/* 00BA64 8000AE64 25AD3050 */ addiu $t5, %lo(gPreviousAngleSteering) # addiu $t5, $t5, 0x3050 /* 00BA68 8000AE68 10000021 */ b .L8000AEF0 /* 00BA6C 8000AE6C 014D1021 */ addu $v0, $t2, $t5 /* 00BA70 8000AE70 3C011000 */ lui $at, (0x1000000C >> 16) # lui $at, 0x1000 @@ -1347,16 +1347,16 @@ glabel func_80009B60 /* 00BA7C 8000AE7C 11E00007 */ beqz $t7, .L8000AE9C /* 00BA80 8000AE80 00000000 */ nop /* 00BA84 8000AE84 8FAB0034 */ lw $t3, 0x34($sp) -/* 00BA88 8000AE88 3C0C8016 */ lui $t4, %hi(D_80163050) # $t4, 0x8016 -/* 00BA8C 8000AE8C 258C3050 */ addiu $t4, %lo(D_80163050) # addiu $t4, $t4, 0x3050 +/* 00BA88 8000AE88 3C0C8016 */ lui $t4, %hi(gPreviousAngleSteering) # $t4, 0x8016 +/* 00BA8C 8000AE8C 258C3050 */ addiu $t4, %lo(gPreviousAngleSteering) # addiu $t4, $t4, 0x3050 /* 00BA90 8000AE90 00002825 */ move $a1, $zero /* 00BA94 8000AE94 10000016 */ b .L8000AEF0 /* 00BA98 8000AE98 016C1021 */ addu $v0, $t3, $t4 .L8000AE9C: /* 00BA9C 8000AE9C 00C30019 */ multu $a2, $v1 /* 00BAA0 8000AEA0 8FB80034 */ lw $t8, 0x34($sp) -/* 00BAA4 8000AEA4 3C198016 */ lui $t9, %hi(D_80163050) # $t9, 0x8016 -/* 00BAA8 8000AEA8 27393050 */ addiu $t9, %lo(D_80163050) # addiu $t9, $t9, 0x3050 +/* 00BAA4 8000AEA4 3C198016 */ lui $t9, %hi(gPreviousAngleSteering) # $t9, 0x8016 +/* 00BAA8 8000AEA8 27393050 */ addiu $t9, %lo(gPreviousAngleSteering) # addiu $t9, $t9, 0x3050 /* 00BAAC 8000AEAC 03191021 */ addu $v0, $t8, $t9 /* 00BAB0 8000AEB0 844E0000 */ lh $t6, ($v0) /* 00BAB4 8000AEB4 3C014000 */ li $at, 0x40000000 # 2.000000 @@ -1378,7 +1378,7 @@ glabel func_80009B60 /* 00BAF0 8000AEF0 00E02025 */ move $a0, $a3 /* 00BAF4 8000AEF4 AFA2003C */ sw $v0, 0x3c($sp) /* 00BAF8 8000AEF8 A7A50094 */ sh $a1, 0x94($sp) -/* 00BAFC 8000AEFC 0C00DA03 */ jal func_8003680C +/* 00BAFC 8000AEFC 0C00DA03 */ jal apply_cpu_turn /* 00BB00 8000AF00 AFA80020 */ sw $t0, 0x20($sp) /* 00BB04 8000AF04 8FA2003C */ lw $v0, 0x3c($sp) /* 00BB08 8000AF08 87A50094 */ lh $a1, 0x94($sp) @@ -1406,18 +1406,18 @@ glabel func_80009B60 /* 00BB5C 8000AF5C 3C0C800E */ lui $t4, %hi(gCCSelection) /* 00BB60 8000AF60 8D8CC548 */ lw $t4, %lo(gCCSelection)($t4) /* 00BB64 8000AF64 85EFC5A0 */ lh $t7, %lo(gCurrentCourseId)($t7) -/* 00BB68 8000AF68 3C0E0D01 */ lui $t6, %hi(D_0D009418) # $t6, 0xd01 +/* 00BB68 8000AF68 3C0E0D01 */ lui $t6, %hi(cpu_CurveTargetSpeed) # $t6, 0xd01 /* 00BB6C 8000AF6C 000CC080 */ sll $t8, $t4, 2 /* 00BB70 8000AF70 000F5900 */ sll $t3, $t7, 4 /* 00BB74 8000AF74 0178C821 */ addu $t9, $t3, $t8 -/* 00BB78 8000AF78 25CE9418 */ addiu $t6, %lo(D_0D009418) # addiu $t6, $t6, -0x6be8 +/* 00BB78 8000AF78 25CE9418 */ addiu $t6, %lo(cpu_CurveTargetSpeed) # addiu $t6, $t6, -0x6be8 /* 00BB7C 8000AF7C 032E2021 */ addu $a0, $t9, $t6 /* 00BB80 8000AF80 0C026455 */ jal segmented_to_virtual_dupe_2 /* 00BB84 8000AF84 AFA80020 */ sw $t0, 0x20($sp) /* 00BB88 8000AF88 8FAA0038 */ lw $t2, 0x38($sp) -/* 00BB8C 8000AF8C 3C0D8016 */ lui $t5, %hi(D_80163028) # $t5, 0x8016 +/* 00BB8C 8000AF8C 3C0D8016 */ lui $t5, %hi(cpu_TargetSpeed) # $t5, 0x8016 /* 00BB90 8000AF90 C4440000 */ lwc1 $f4, ($v0) -/* 00BB94 8000AF94 25AD3028 */ addiu $t5, %lo(D_80163028) # addiu $t5, $t5, 0x3028 +/* 00BB94 8000AF94 25AD3028 */ addiu $t5, %lo(cpu_TargetSpeed) # addiu $t5, $t5, 0x3028 /* 00BB98 8000AF98 014D1821 */ addu $v1, $t2, $t5 /* 00BB9C 8000AF9C 8FA80020 */ lw $t0, 0x20($sp) /* 00BBA0 8000AFA0 10000014 */ b .L8000AFF4 @@ -1427,18 +1427,18 @@ glabel func_80009B60 /* 00BBAC 8000AFAC 3C0B800E */ lui $t3, %hi(gCCSelection) /* 00BBB0 8000AFB0 8D6BC548 */ lw $t3, %lo(gCCSelection)($t3) /* 00BBB4 8000AFB4 85EFC5A0 */ lh $t7, %lo(gCurrentCourseId)($t7) -/* 00BBB8 8000AFB8 3C0E0D01 */ lui $t6, %hi(D_0D009568) # $t6, 0xd01 +/* 00BBB8 8000AFB8 3C0E0D01 */ lui $t6, %hi(cpu_NormalTargetSpeed) # $t6, 0xd01 /* 00BBBC 8000AFBC 000BC080 */ sll $t8, $t3, 2 /* 00BBC0 8000AFC0 000F6100 */ sll $t4, $t7, 4 /* 00BBC4 8000AFC4 0198C821 */ addu $t9, $t4, $t8 -/* 00BBC8 8000AFC8 25CE9568 */ addiu $t6, %lo(D_0D009568) # addiu $t6, $t6, -0x6a98 +/* 00BBC8 8000AFC8 25CE9568 */ addiu $t6, %lo(cpu_NormalTargetSpeed) # addiu $t6, $t6, -0x6a98 /* 00BBCC 8000AFCC 032E2021 */ addu $a0, $t9, $t6 /* 00BBD0 8000AFD0 0C026455 */ jal segmented_to_virtual_dupe_2 /* 00BBD4 8000AFD4 AFA80020 */ sw $t0, 0x20($sp) /* 00BBD8 8000AFD8 8FAA0038 */ lw $t2, 0x38($sp) /* 00BBDC 8000AFDC C44A0000 */ lwc1 $f10, ($v0) -/* 00BBE0 8000AFE0 3C0D8016 */ lui $t5, %hi(D_80163028) # $t5, 0x8016 -/* 00BBE4 8000AFE4 25AD3028 */ addiu $t5, %lo(D_80163028) # addiu $t5, $t5, 0x3028 +/* 00BBE0 8000AFE0 3C0D8016 */ lui $t5, %hi(cpu_TargetSpeed) # $t5, 0x8016 +/* 00BBE4 8000AFE4 25AD3028 */ addiu $t5, %lo(cpu_TargetSpeed) # addiu $t5, $t5, 0x3028 /* 00BBE8 8000AFE8 014D1821 */ addu $v1, $t2, $t5 /* 00BBEC 8000AFEC 8FA80020 */ lw $t0, 0x20($sp) /* 00BBF0 8000AFF0 E46A0000 */ swc1 $f10, ($v1) @@ -1446,10 +1446,10 @@ glabel func_80009B60 /* 00BBF4 8000AFF4 3C01800F */ lui $at, %hi(D_800ECFC0) # $at, 0x800f /* 00BBF8 8000AFF8 C430CFC0 */ lwc1 $f16, %lo(D_800ECFC0)($at) /* 00BBFC 8000AFFC C5000000 */ lwc1 $f0, ($t0) -/* 00BC00 8000B000 3C0E0D01 */ lui $t6, %hi(D_0D009808) # $t6, 0xd01 +/* 00BC00 8000B000 3C0E0D01 */ lui $t6, %hi(cpu_OffTrackTargetSpeed) # $t6, 0xd01 /* 00BC04 8000B004 3C01800F */ lui $at, %hi(D_800ECFC4) # $at, 0x800f /* 00BC08 8000B008 4600803C */ c.lt.s $f16, $f0 -/* 00BC0C 8000B00C 25CE9808 */ addiu $t6, %lo(D_0D009808) # addiu $t6, $t6, -0x67f8 +/* 00BC0C 8000B00C 25CE9808 */ addiu $t6, %lo(cpu_OffTrackTargetSpeed) # addiu $t6, $t6, -0x67f8 /* 00BC10 8000B010 3C0F800E */ lui $t7, %hi(gCurrentCourseId) /* 00BC14 8000B014 3C0C800E */ lui $t4, %hi(gCCSelection) /* 00BC18 8000B018 45010006 */ bc1t .L8000B034 @@ -1507,8 +1507,8 @@ glabel func_80009B60 .L8000B0D8: /* 00BCD8 8000B0D8 C46A0000 */ lwc1 $f10, ($v1) /* 00BCDC 8000B0DC 8FAA0040 */ lw $t2, 0x40($sp) -/* 00BCE0 8000B0E0 3C028016 */ lui $v0, %hi(D_8016320C) # $v0, 0x8016 -/* 00BCE4 8000B0E4 2442320C */ addiu $v0, %lo(D_8016320C) # addiu $v0, $v0, 0x320c +/* 00BCE0 8000B0E0 3C028016 */ lui $v0, %hi(gCurrentCpuTargetSpeed) # $v0, 0x8016 +/* 00BCE4 8000B0E4 2442320C */ addiu $v0, %lo(gCurrentCpuTargetSpeed) # addiu $v0, $v0, 0x320c /* 00BCE8 8000B0E8 E44A0000 */ swc1 $f10, ($v0) /* 00BCEC 8000B0EC 8D4D00BC */ lw $t5, 0xbc($t2) /* 00BCF0 8000B0F0 3C01FFDF */ lui $at, (0xFFDFFFFF >> 16) # lui $at, 0xffdf @@ -1517,15 +1517,15 @@ glabel func_80009B60 /* 00BCFC 8000B0FC AD4C00BC */ sw $t4, 0xbc($t2) /* 00BD00 8000B100 8FAF0038 */ lw $t7, 0x38($sp) /* 00BD04 8000B104 C4500000 */ lwc1 $f16, ($v0) -/* 00BD08 8000B108 3C018016 */ lui $at, %hi(D_80163210) +/* 00BD08 8000B108 3C018016 */ lui $at, %hi(gPreviousCpuTargetSpeed) /* 00BD0C 8000B10C 002F0821 */ addu $at, $at, $t7 /* 00BD10 8000B110 8FA400D0 */ lw $a0, 0xd0($sp) /* 00BD14 8000B114 0C004C77 */ jal check_ai_crossing_distance -/* 00BD18 8000B118 E4303210 */ swc1 $f16, %lo(D_80163210)($at) -/* 00BD1C 8000B11C 3C058016 */ lui $a1, %hi(D_8016320C) # $a1, 0x8016 -/* 00BD20 8000B120 8CA5320C */ lw $a1, %lo(D_8016320C)($a1) +/* 00BD18 8000B118 E4303210 */ swc1 $f16, %lo(gPreviousCpuTargetSpeed)($at) +/* 00BD1C 8000B11C 3C058016 */ lui $a1, %hi(gCurrentCpuTargetSpeed) # $a1, 0x8016 +/* 00BD20 8000B120 8CA5320C */ lw $a1, %lo(gCurrentCpuTargetSpeed)($a1) /* 00BD24 8000B124 8FA400D0 */ lw $a0, 0xd0($sp) -/* 00BD28 8000B128 0C002109 */ jal func_80008424 +/* 00BD28 8000B128 0C002109 */ jal regulate_cpu_speed /* 00BD2C 8000B12C 8FA60040 */ lw $a2, 0x40($sp) .L8000B130: /* 00BD30 8000B130 8FBF0014 */ lw $ra, 0x14($sp) diff --git a/asm/non_matchings/code_80005FD0/func_8000929C.s b/asm/non_matchings/cpu_vehicles_camera_path/update_player_path_completion.s similarity index 76% rename from asm/non_matchings/code_80005FD0/func_8000929C.s rename to asm/non_matchings/cpu_vehicles_camera_path/update_player_path_completion.s index f31cb788f7..ed334533a5 100644 --- a/asm/non_matchings/code_80005FD0/func_8000929C.s +++ b/asm/non_matchings/cpu_vehicles_camera_path/update_player_path_completion.s @@ -8,23 +8,23 @@ glabel D_800ECFAC .section .text -glabel func_8000929C +glabel update_player_path_completion /* 009E9C 8000929C 27BDFFB0 */ addiu $sp, $sp, -0x50 /* 009EA0 800092A0 AFBF0024 */ sw $ra, 0x24($sp) /* 009EA4 800092A4 C4A0001C */ lwc1 $f0, 0x1c($a1) /* 009EA8 800092A8 C4AC0014 */ lwc1 $f12, 0x14($a1) /* 009EAC 800092AC C4AE0018 */ lwc1 $f14, 0x18($a1) /* 009EB0 800092B0 3C0E8016 */ lui $t6, %hi(D_80163240) # $t6, 0x8016 -/* 009EB4 800092B4 3C018016 */ lui $at, %hi(D_801630E2) # $at, 0x8016 +/* 009EB4 800092B4 3C018016 */ lui $at, %hi(gIsPlayerNewPathPoint) # $at, 0x8016 /* 009EB8 800092B8 25CE3240 */ addiu $t6, %lo(D_80163240) # addiu $t6, $t6, 0x3240 /* 009EBC 800092BC 00041040 */ sll $v0, $a0, 1 -/* 009EC0 800092C0 A42030E2 */ sh $zero, %lo(D_801630E2)($at) +/* 009EC0 800092C0 A42030E2 */ sh $zero, %lo(gIsPlayerNewPathPoint)($at) /* 009EC4 800092C4 004E1821 */ addu $v1, $v0, $t6 /* 009EC8 800092C8 A4600000 */ sh $zero, ($v1) -/* 009ECC 800092CC 3C0F8016 */ lui $t7, %hi(gNearestWaypointByPlayerId) # $t7, 0x8016 -/* 009ED0 800092D0 3C188016 */ lui $t8, %hi(D_80163448) # $t8, 0x8016 -/* 009ED4 800092D4 8F183448 */ lw $t8, %lo(D_80163448)($t8) -/* 009ED8 800092D8 25EF4438 */ addiu $t7, %lo(gNearestWaypointByPlayerId) # addiu $t7, $t7, 0x4438 +/* 009ECC 800092CC 3C0F8016 */ lui $t7, %hi(gNearestPathPointByPlayerId) # $t7, 0x8016 +/* 009ED0 800092D0 3C188016 */ lui $t8, %hi(gPlayerPathIndex) # $t8, 0x8016 +/* 009ED4 800092D4 8F183448 */ lw $t8, %lo(gPlayerPathIndex)($t8) +/* 009ED8 800092D8 25EF4438 */ addiu $t7, %lo(gNearestPathPointByPlayerId) # addiu $t7, $t7, 0x4438 /* 009EDC 800092DC 004F4021 */ addu $t0, $v0, $t7 /* 009EE0 800092E0 44060000 */ mfc1 $a2, $f0 /* 009EE4 800092E4 85070000 */ lh $a3, ($t0) @@ -36,15 +36,15 @@ glabel func_8000929C /* 009EFC 800092FC AFA50010 */ sw $a1, 0x10($sp) /* 009F00 80009300 E7A00044 */ swc1 $f0, 0x44($sp) /* 009F04 80009304 E7AC004C */ swc1 $f12, 0x4c($sp) -/* 009F08 80009308 0C003349 */ jal func_8000CD24 +/* 009F08 80009308 0C003349 */ jal update_player_path /* 009F0C 8000930C AFB80018 */ sw $t8, 0x18($sp) -/* 009F10 80009310 3C058016 */ lui $a1, %hi(sSomeNearestWaypoint) # $a1, 0x8016 -/* 009F14 80009314 24A52FCE */ addiu $a1, %lo(sSomeNearestWaypoint) # addiu $a1, $a1, 0x2fce +/* 009F10 80009310 3C058016 */ lui $a1, %hi(sSomeNearestPathPoint) # $a1, 0x8016 +/* 009F14 80009314 24A52FCE */ addiu $a1, %lo(sSomeNearestPathPoint) # addiu $a1, $a1, 0x2fce /* 009F18 80009318 A4A20000 */ sh $v0, ($a1) /* 009F1C 8000931C 84A70000 */ lh $a3, ($a1) /* 009F20 80009320 8FA80030 */ lw $t0, 0x30($sp) -/* 009F24 80009324 3C018016 */ lui $at, %hi(D_801630E0) # $at, 0x8016 -/* 009F28 80009328 A42730E0 */ sh $a3, %lo(D_801630E0)($at) +/* 009F24 80009324 3C018016 */ lui $at, %hi(gCurrentNearestPathPoint) # $at, 0x8016 +/* 009F28 80009328 A42730E0 */ sh $a3, %lo(gCurrentNearestPathPoint)($at) /* 009F2C 8000932C 95190000 */ lhu $t9, ($t0) /* 009F30 80009330 8FA40050 */ lw $a0, 0x50($sp) /* 009F34 80009334 C7AC004C */ lwc1 $f12, 0x4c($sp) @@ -52,13 +52,13 @@ glabel func_8000929C /* 009F3C 8000933C 00E01825 */ move $v1, $a3 /* 009F40 80009340 A5030000 */ sh $v1, ($t0) /* 009F44 80009344 24090001 */ li $t1, 1 -/* 009F48 80009348 3C018016 */ lui $at, %hi(D_801630E2) # $at, 0x8016 -/* 009F4C 8000934C A42930E2 */ sh $t1, %lo(D_801630E2)($at) +/* 009F48 80009348 3C018016 */ lui $at, %hi(gIsPlayerNewPathPoint) # $at, 0x8016 +/* 009F4C 8000934C A42930E2 */ sh $t1, %lo(gIsPlayerNewPathPoint)($at) /* 009F50 80009350 AFA40050 */ sw $a0, 0x50($sp) -/* 009F54 80009354 0C0023CE */ jal func_80008F38 +/* 009F54 80009354 0C0023CE */ jal update_player_completion /* 009F58 80009358 E7AC004C */ swc1 $f12, 0x4c($sp) -/* 009F5C 8000935C 3C078016 */ lui $a3, %hi(sSomeNearestWaypoint) # $a3, 0x8016 -/* 009F60 80009360 84E72FCE */ lh $a3, %lo(sSomeNearestWaypoint)($a3) +/* 009F5C 8000935C 3C078016 */ lui $a3, %hi(sSomeNearestPathPoint) # $a3, 0x8016 +/* 009F60 80009360 84E72FCE */ lh $a3, %lo(sSomeNearestPathPoint)($a3) /* 009F64 80009364 8FA40050 */ lw $a0, 0x50($sp) /* 009F68 80009368 C7AC004C */ lwc1 $f12, 0x4c($sp) .L8000936C: @@ -67,20 +67,20 @@ glabel func_8000929C /* 009F74 80009374 24010014 */ li $at, 20 /* 009F78 80009378 30E5FFFF */ andi $a1, $a3, 0xffff /* 009F7C 8000937C 14410005 */ bne $v0, $at, .L80009394 -/* 009F80 80009380 3C068016 */ lui $a2, %hi(D_80163448) # $a2, 0x8016 -/* 009F84 80009384 0C002E57 */ jal func_8000B95C -/* 009F88 80009388 8CC63448 */ lw $a2, %lo(D_80163448)($a2) +/* 009F80 80009380 3C068016 */ lui $a2, %hi(gPlayerPathIndex) # $a2, 0x8016 +/* 009F84 80009384 0C002E57 */ jal update_player_position_factor +/* 009F88 80009388 8CC63448 */ lw $a2, %lo(gPlayerPathIndex)($a2) /* 009F8C 8000938C 10000111 */ b .L800097D4 /* 009F90 80009390 8FBF0024 */ lw $ra, 0x24($sp) .L80009394: /* 009F94 80009394 28E10014 */ slti $at, $a3, 0x14 /* 009F98 80009398 1420000B */ bnez $at, .L800093C8 -/* 009F9C 8000939C 3C0A8016 */ lui $t2, %hi(D_80163448) # $t2, 0x8016 -/* 009FA0 800093A0 8D4A3448 */ lw $t2, %lo(D_80163448)($t2) -/* 009FA4 800093A4 3C0C8016 */ lui $t4, %hi(gWaypointCountByPathIndex) # 0x8016 +/* 009F9C 8000939C 3C0A8016 */ lui $t2, %hi(gPlayerPathIndex) # $t2, 0x8016 +/* 009FA0 800093A0 8D4A3448 */ lw $t2, %lo(gPlayerPathIndex)($t2) +/* 009FA4 800093A4 3C0C8016 */ lui $t4, %hi(gPathCountByPathIndex) # 0x8016 /* 009FA8 800093A8 000A5840 */ sll $t3, $t2, 1 /* 009FAC 800093AC 018B6021 */ addu $t4, $t4, $t3 -/* 009FB0 800093B0 958C45C8 */ lhu $t4, %lo(gWaypointCountByPathIndex)($t4) # 0x45c8($t4) +/* 009FB0 800093B0 958C45C8 */ lhu $t4, %lo(gPathCountByPathIndex)($t4) # 0x45c8($t4) /* 009FB4 800093B4 258DFFEC */ addiu $t5, $t4, -0x14 /* 009FB8 800093B8 01A7082A */ slt $at, $t5, $a3 /* 009FBC 800093BC 14200002 */ bnez $at, .L800093C8 @@ -174,13 +174,13 @@ glabel func_8000929C /* 00A100 80009500 24080001 */ li $t0, 1 /* 00A104 80009504 00043880 */ sll $a3, $a0, 2 .L80009508: -/* 00A108 80009508 3C018016 */ lui $at, %hi(D_80163450) +/* 00A108 80009508 3C018016 */ lui $at, %hi(gPreviousPlayerZ) /* 00A10C 8000950C 00270821 */ addu $at, $at, $a3 -/* 00A110 80009510 C4303450 */ lwc1 $f16, %lo(D_80163450)($at) -/* 00A114 80009514 3C018016 */ lui $at, %hi(D_8016344C) # $at, 0x8016 +/* 00A110 80009510 C4303450 */ lwc1 $f16, %lo(gPreviousPlayerZ)($at) +/* 00A114 80009514 3C018016 */ lui $at, %hi(gPathStartZ) # $at, 0x8016 /* 00A118 80009518 10600052 */ beqz $v1, .L80009664 /* 00A11C 8000951C E7B00038 */ swc1 $f16, 0x38($sp) -/* 00A120 80009520 C420344C */ lwc1 $f0, %lo(D_8016344C)($at) +/* 00A120 80009520 C420344C */ lwc1 $f0, %lo(gPathStartZ)($at) /* 00A124 80009524 C7B20044 */ lwc1 $f18, 0x44($sp) /* 00A128 80009528 C7A40038 */ lwc1 $f4, 0x38($sp) /* 00A12C 8000952C 4600903E */ c.le.s $f18, $f0 @@ -202,9 +202,9 @@ glabel func_8000929C /* 00A16C 8000956C 5540001A */ bnel $t2, $zero, .L800095D8 /* 00A170 80009570 8FAD002C */ lw $t5, 0x2c($sp) /* 00A174 80009574 15210017 */ bne $t1, $at, .L800095D4 -/* 00A178 80009578 3C0C8016 */ lui $t4, %hi(D_80164408) # 0x8016 +/* 00A178 80009578 3C0C8016 */ lui $t4, %hi(gGPCurrentRaceRankByPlayerIdDup) # 0x8016 /* 00A17C 8000957C 01876021 */ addu $t4, $t4, $a3 -/* 00A180 80009580 8D8C4408 */ lw $t4, %lo(D_80164408)($t4) # 0x4408($t4) +/* 00A180 80009580 8D8C4408 */ lw $t4, %lo(gGPCurrentRaceRankByPlayerIdDup)($t4) # 0x4408($t4) /* 00A184 80009584 24010007 */ li $at, 7 /* 00A188 80009588 3C028016 */ lui $v0, %hi(gLapCountByPlayerId) # $v0, 0x8016 /* 00A18C 8000958C 15810011 */ bne $t4, $at, .L800095D4 @@ -233,20 +233,20 @@ glabel func_8000929C /* 00A1DC 800095DC A5AC0000 */ sh $t4, ($t5) /* 00A1E0 800095E0 A7A80034 */ sh $t0, 0x34($sp) /* 00A1E4 800095E4 AFA70030 */ sw $a3, 0x30($sp) -/* 00A1E8 800095E8 0C0023CE */ jal func_80008F38 +/* 00A1E8 800095E8 0C0023CE */ jal update_player_completion /* 00A1EC 800095EC AFA40050 */ sw $a0, 0x50($sp) -/* 00A1F0 800095F0 0C0046B9 */ jal reset_kart_ai_behaviour +/* 00A1F0 800095F0 0C0046B9 */ jal reset_cpu_behaviour /* 00A1F4 800095F4 8FA40050 */ lw $a0, 0x50($sp) /* 00A1F8 800095F8 8FA40050 */ lw $a0, 0x50($sp) /* 00A1FC 800095FC 3C0F8016 */ lui $t7, %hi(D_8016348C) # $t7, 0x8016 /* 00A200 80009600 85EF348C */ lh $t7, %lo(D_8016348C)($t7) -/* 00A204 80009604 3C018016 */ lui $at, %hi(D_801642D8 + 0x6) # 0x8016 +/* 00A204 80009604 3C018016 */ lui $at, %hi(cpu_ItemStrategy + 0x6) # 0x8016 /* 00A208 80009608 00047100 */ sll $t6, $a0, 4 /* 00A20C 8000960C 002E0821 */ addu $at, $at, $t6 /* 00A210 80009610 8FA70030 */ lw $a3, 0x30($sp) /* 00A214 80009614 87A80034 */ lh $t0, 0x34($sp) /* 00A218 80009618 15E00012 */ bnez $t7, .L80009664 -/* 00A21C 8000961C A42042DE */ sh $zero, %lo(D_801642D8 + 0x6)($at) # 0x42de($at) +/* 00A21C 8000961C A42042DE */ sh $zero, %lo(cpu_ItemStrategy + 0x6)($at) # 0x42de($at) /* 00A220 80009620 8FB80054 */ lw $t8, 0x54($sp) /* 00A224 80009624 8FA50038 */ lw $a1, 0x38($sp) /* 00A228 80009628 8FA60044 */ lw $a2, 0x44($sp) @@ -266,8 +266,8 @@ glabel func_8000929C /* 00A260 80009660 87A80034 */ lh $t0, 0x34($sp) .L80009664: /* 00A264 80009664 11000014 */ beqz $t0, .L800096B8 -/* 00A268 80009668 3C018016 */ lui $at, %hi(D_8016344C) # $at, 0x8016 -/* 00A26C 8000966C C420344C */ lwc1 $f0, %lo(D_8016344C)($at) +/* 00A268 80009668 3C018016 */ lui $at, %hi(gPathStartZ) # $at, 0x8016 +/* 00A26C 8000966C C420344C */ lwc1 $f0, %lo(gPathStartZ)($at) /* 00A270 80009670 C7A60038 */ lwc1 $f6, 0x38($sp) /* 00A274 80009674 C7A80044 */ lwc1 $f8, 0x44($sp) /* 00A278 80009678 4600303E */ c.le.s $f6, $f0 @@ -283,26 +283,26 @@ glabel func_8000929C /* 00A2A0 800096A0 8C4B0000 */ lw $t3, ($v0) /* 00A2A4 800096A4 AFA40050 */ sw $a0, 0x50($sp) /* 00A2A8 800096A8 256CFFFF */ addiu $t4, $t3, -1 -/* 00A2AC 800096AC 0C0023CE */ jal func_80008F38 +/* 00A2AC 800096AC 0C0023CE */ jal update_player_completion /* 00A2B0 800096B0 AC4C0000 */ sw $t4, ($v0) /* 00A2B4 800096B4 8FA40050 */ lw $a0, 0x50($sp) .L800096B8: /* 00A2B8 800096B8 C7AA0044 */ lwc1 $f10, 0x44($sp) .L800096BC: /* 00A2BC 800096BC 00046880 */ sll $t5, $a0, 2 -/* 00A2C0 800096C0 3C018016 */ lui $at, %hi(D_80163450) +/* 00A2C0 800096C0 3C018016 */ lui $at, %hi(gPreviousPlayerZ) /* 00A2C4 800096C4 3C0E800E */ lui $t6, %hi(gCurrentCourseId) /* 00A2C8 800096C8 85CEC5A0 */ lh $t6, %lo(gCurrentCourseId)($t6) /* 00A2CC 800096CC 002D0821 */ addu $at, $at, $t5 -/* 00A2D0 800096D0 E42A3450 */ swc1 $f10, %lo(D_80163450)($at) +/* 00A2D0 800096D0 E42A3450 */ swc1 $f10, %lo(gPreviousPlayerZ)($at) /* 00A2D4 800096D4 24010004 */ li $at, 4 /* 00A2D8 800096D8 15C10013 */ bne $t6, $at, .L80009728 -/* 00A2DC 800096DC 3C0F8016 */ lui $t7, %hi(D_801630E2) # $t7, 0x8016 -/* 00A2E0 800096E0 85EF30E2 */ lh $t7, %lo(D_801630E2)($t7) +/* 00A2DC 800096DC 3C0F8016 */ lui $t7, %hi(gIsPlayerNewPathPoint) # $t7, 0x8016 +/* 00A2E0 800096E0 85EF30E2 */ lh $t7, %lo(gIsPlayerNewPathPoint)($t7) /* 00A2E4 800096E4 24010001 */ li $at, 1 /* 00A2E8 800096E8 55E10010 */ bnel $t7, $at, .L8000972C /* 00A2EC 800096EC 8FAA0054 */ lw $t2, 0x54($sp) -/* 00A2F0 800096F0 0C002400 */ jal func_80009000 +/* 00A2F0 800096F0 0C002400 */ jal yoshi_valley_cpu_path /* 00A2F4 800096F4 AFA40050 */ sw $a0, 0x50($sp) /* 00A2F8 800096F8 8FB80054 */ lw $t8, 0x54($sp) /* 00A2FC 800096FC 8FA40050 */ lw $a0, 0x50($sp) @@ -314,56 +314,56 @@ glabel func_8000929C /* 00A314 80009714 51200005 */ beql $t1, $zero, .L8000972C /* 00A318 80009718 8FAA0054 */ lw $t2, 0x54($sp) .L8000971C: -/* 00A31C 8000971C 0C00243C */ jal func_800090F0 +/* 00A31C 8000971C 0C00243C */ jal update_cpu_path_completion /* 00A320 80009720 AFA40050 */ sw $a0, 0x50($sp) /* 00A324 80009724 8FA40050 */ lw $a0, 0x50($sp) .L80009728: /* 00A328 80009728 8FAA0054 */ lw $t2, 0x54($sp) .L8000972C: -/* 00A32C 8000972C 3C068016 */ lui $a2, %hi(D_80163448) # 0x8016 -/* 00A330 80009730 3C038016 */ lui $v1, %hi(sSomeNearestWaypoint) # 0x8016 +/* 00A32C 8000972C 3C068016 */ lui $a2, %hi(gPlayerPathIndex) # 0x8016 +/* 00A330 80009730 3C038016 */ lui $v1, %hi(sSomeNearestPathPoint) # 0x8016 /* 00A334 80009734 95420000 */ lhu $v0, ($t2) /* 00A338 80009738 304B4000 */ andi $t3, $v0, 0x4000 /* 00A33C 8000973C 11600020 */ beqz $t3, .L800097C0 /* 00A340 80009740 304C1000 */ andi $t4, $v0, 0x1000 /* 00A344 80009744 1580001E */ bnez $t4, .L800097C0 /* 00A348 80009748 01402825 */ move $a1, $t2 -/* 00A34C 8000974C 0C001974 */ jal func_800065D0 +/* 00A34C 8000974C 0C001974 */ jal detect_wrong_player_direction /* 00A350 80009750 AFA40050 */ sw $a0, 0x50($sp) /* 00A354 80009754 3C0D800E */ lui $t5, %hi(gModeSelection) /* 00A358 80009758 8DADC53C */ lw $t5, %lo(gModeSelection)($t5) /* 00A35C 8000975C 8FA40050 */ lw $a0, 0x50($sp) -/* 00A360 80009760 3C068016 */ lui $a2, %hi(D_80163448) # $a2, 0x8016 +/* 00A360 80009760 3C068016 */ lui $a2, %hi(gPlayerPathIndex) # $a2, 0x8016 /* 00A364 80009764 15A00013 */ bnez $t5, .L800097B4 -/* 00A368 80009768 3C038016 */ lui $v1, %hi(sSomeNearestWaypoint) # $v1, 0x8016 +/* 00A368 80009768 3C038016 */ lui $v1, %hi(sSomeNearestPathPoint) # $v1, 0x8016 /* 00A36C 8000976C 3C0E8019 */ lui $t6, %hi(gPlayerCount) # $t6, 0x8019 /* 00A370 80009770 81CEEDF3 */ lb $t6, %lo(gPlayerCount)($t6) /* 00A374 80009774 24010002 */ li $at, 2 /* 00A378 80009778 15C1000E */ bne $t6, $at, .L800097B4 /* 00A37C 8000977C 00000000 */ nop /* 00A380 80009780 1480000C */ bnez $a0, .L800097B4 -/* 00A384 80009784 3C0F8016 */ lui $t7, %hi(D_80164408) # $t7, 0x8016 -/* 00A388 80009788 3C188016 */ lui $t8, %hi(D_80164408 + 0x4) # $t8, 0x8016 -/* 00A38C 8000978C 8F18440C */ lw $t8, %lo(D_80164408 + 0x4)($t8) -/* 00A390 80009790 8DEF4408 */ lw $t7, %lo(D_80164408)($t7) +/* 00A384 80009784 3C0F8016 */ lui $t7, %hi(gGPCurrentRaceRankByPlayerIdDup) # $t7, 0x8016 +/* 00A388 80009788 3C188016 */ lui $t8, %hi(gGPCurrentRaceRankByPlayerIdDup + 0x4) # $t8, 0x8016 +/* 00A38C 8000978C 8F18440C */ lw $t8, %lo(gGPCurrentRaceRankByPlayerIdDup + 0x4)($t8) +/* 00A390 80009790 8DEF4408 */ lw $t7, %lo(gGPCurrentRaceRankByPlayerIdDup)($t7) /* 00A394 80009794 24190001 */ li $t9, 1 /* 00A398 80009798 01F8082A */ slt $at, $t7, $t8 /* 00A39C 8000979C 10200003 */ beqz $at, .L800097AC -/* 00A3A0 800097A0 3C018016 */ lui $at, %hi(D_80163478) # $at, 0x8016 +/* 00A3A0 800097A0 3C018016 */ lui $at, %hi(gBestRankedHumanPlayer) # $at, 0x8016 /* 00A3A4 800097A4 10000003 */ b .L800097B4 -/* 00A3A8 800097A8 A4203478 */ sh $zero, %lo(D_80163478)($at) +/* 00A3A8 800097A8 A4203478 */ sh $zero, %lo(gBestRankedHumanPlayer)($at) .L800097AC: -/* 00A3AC 800097AC 3C018016 */ lui $at, %hi(D_80163478) # $at, 0x8016 -/* 00A3B0 800097B0 A4393478 */ sh $t9, %lo(D_80163478)($at) +/* 00A3AC 800097AC 3C018016 */ lui $at, %hi(gBestRankedHumanPlayer) # $at, 0x8016 +/* 00A3B0 800097B0 A4393478 */ sh $t9, %lo(gBestRankedHumanPlayer)($at) .L800097B4: -/* 00A3B4 800097B4 8CC63448 */ lw $a2, %lo(D_80163448)($a2) +/* 00A3B4 800097B4 8CC63448 */ lw $a2, %lo(gPlayerPathIndex)($a2) /* 00A3B8 800097B8 10000003 */ b .L800097C8 -/* 00A3BC 800097BC 84632FCE */ lh $v1, %lo(sSomeNearestWaypoint)($v1) +/* 00A3BC 800097BC 84632FCE */ lh $v1, %lo(sSomeNearestPathPoint)($v1) .L800097C0: -/* 00A3C0 800097C0 8CC63448 */ lw $a2, %lo(D_80163448)($a2) # 0x3448($a2) -/* 00A3C4 800097C4 84632FCE */ lh $v1, %lo(sSomeNearestWaypoint)($v1) +/* 00A3C0 800097C0 8CC63448 */ lw $a2, %lo(gPlayerPathIndex)($a2) # 0x3448($a2) +/* 00A3C4 800097C4 84632FCE */ lh $v1, %lo(sSomeNearestPathPoint)($v1) .L800097C8: -/* 00A3C8 800097C8 0C002E57 */ jal func_8000B95C +/* 00A3C8 800097C8 0C002E57 */ jal update_player_position_factor /* 00A3CC 800097CC 3065FFFF */ andi $a1, $v1, 0xffff /* 00A3D0 800097D0 8FBF0024 */ lw $ra, 0x24($sp) .L800097D4: diff --git a/asm/non_matchings/render_objects/func_8004F168.s b/asm/non_matchings/render_objects/draw_minimap_character.s similarity index 99% rename from asm/non_matchings/render_objects/func_8004F168.s rename to asm/non_matchings/render_objects/draw_minimap_character.s index 4a745ecdac..f8ffe103cc 100644 --- a/asm/non_matchings/render_objects/func_8004F168.s +++ b/asm/non_matchings/render_objects/draw_minimap_character.s @@ -1,4 +1,4 @@ -glabel func_8004F168 +glabel draw_minimap_character /* 04FD68 8004F168 000570C0 */ sll $t6, $a1, 3 /* 04FD6C 8004F16C 01C57023 */ subu $t6, $t6, $a1 /* 04FD70 8004F170 000E7100 */ sll $t6, $t6, 4 diff --git a/courses/banshee_boardwalk/course_data.c b/courses/banshee_boardwalk/course_data.c index c45ed9d6ae..072d429cbd 100644 --- a/courses/banshee_boardwalk/course_data.c +++ b/courses/banshee_boardwalk/course_data.c @@ -3,7 +3,7 @@ #include #include #include -#include +#include #include #include @@ -2549,7 +2549,7 @@ Gfx d_course_banshee_boardwalk_dl_4480[] = { }; // 0x4578 Spawn location -TrackWaypoint d_course_banshee_boardwalk_unknown_waypoints[] = { +TrackPathPoint d_course_banshee_boardwalk_unknown_path[] = { { 5, 0, -65, 0 }, { 5, 0, -90, 0 }, { 4, 0, -203, 0 }, { 5, 0, -501, 0 }, { -13, 0, -575, 0 }, { -54, 0, -598, 0 }, { -244, 0, -605, 0 }, { -634, 0, -602, 0 }, { -688, 0, -629, 0 }, { -704, 0, -697, 0 }, { -702, 0, -895, 0 }, { -702, 0, -1095, 0 }, @@ -2572,7 +2572,7 @@ TrackWaypoint d_course_banshee_boardwalk_unknown_waypoints[] = { { 5, 0, 100, 0 }, { 7, 0, -28, 0 }, { -32768, 0, 0, 0 }, }; -TrackWaypoint d_course_banshee_boardwalk_track_waypoints[] = { +TrackPathPoint d_course_banshee_boardwalk_track_path[] = { { 5, 12, -77, 1 }, { 4, 12, -97, 1 }, { 4, 12, -117, 1 }, { 4, 12, -137, 1 }, { 4, 12, -157, 1 }, { 4, 12, -177, 1 }, diff --git a/courses/banshee_boardwalk/course_data.h b/courses/banshee_boardwalk/course_data.h index 40b4c42c6f..d92c44a74c 100644 --- a/courses/banshee_boardwalk/course_data.h +++ b/courses/banshee_boardwalk/course_data.h @@ -4,7 +4,7 @@ #include #include #include -#include +#include #include extern Gfx d_course_banshee_boardwalk_dl_0[]; @@ -112,8 +112,8 @@ extern Gfx d_course_banshee_boardwalk_dl_42D0[]; extern Gfx d_course_banshee_boardwalk_dl_43A8[]; extern Gfx d_course_banshee_boardwalk_dl_4428[]; extern Gfx d_course_banshee_boardwalk_dl_4480[]; -extern TrackWaypoint d_course_banshee_boardwalk_unknown_waypoints[]; -extern TrackWaypoint d_course_banshee_boardwalk_track_waypoints[]; +extern TrackPathPoint d_course_banshee_boardwalk_unknown_path[]; +extern TrackPathPoint d_course_banshee_boardwalk_track_path[]; extern u8 d_course_banshee_boardwalk_boo_tlut[]; extern Vtx d_course_banshee_boardwalk_cheep_cheep1[]; extern Vtx d_course_banshee_boardwalk_cheep_cheep2[]; diff --git a/courses/bowsers_castle/course_data.c b/courses/bowsers_castle/course_data.c index 23f1db65f7..9dbacf544d 100644 --- a/courses/bowsers_castle/course_data.c +++ b/courses/bowsers_castle/course_data.c @@ -3,7 +3,7 @@ #include #include #include -#include +#include #include #include @@ -2283,7 +2283,7 @@ Gfx d_course_bowsers_castle_dl_4EA8[] = { }; // 0x4F90 -TrackWaypoint d_course_bowsers_castle_unknown_waypoints[] = { +TrackPathPoint d_course_bowsers_castle_unknown_path[] = { { 2, 0, -172, 0 }, { 2, 0, -197, 0 }, { -2, 0, -691, 0 }, { -1, 0, -1087, 0 }, { 4, 0, -1519, 0 }, { 88, 0, -1645, 0 }, { 228, 0, -1743, 0 }, { 571, 0, -1749, 0 }, { 999, 0, -1749, 0 }, { 1201, 0, -1747, 0 }, { 1262, 0, -1759, 0 }, { 1274, 0, -1797, 0 }, { 1277, 0, -2193, 0 }, { 1272, 0, -2487, 0 }, { 1281, 0, -2631, 0 }, @@ -2301,7 +2301,7 @@ TrackWaypoint d_course_bowsers_castle_unknown_waypoints[] = { { 3, 0, -144, 0 }, { -32768, 0, 0, 0 }, }; -TrackWaypoint d_course_bowsers_castle_track_waypoints[] = { +TrackPathPoint d_course_bowsers_castle_track_path[] = { { 2, 0, -184, 1 }, { 1, 0, -204, 2 }, { 1, 0, -224, 2 }, diff --git a/courses/bowsers_castle/course_data.h b/courses/bowsers_castle/course_data.h index aadfe865f1..232cc32952 100644 --- a/courses/bowsers_castle/course_data.h +++ b/courses/bowsers_castle/course_data.h @@ -4,7 +4,7 @@ #include #include #include -#include +#include #include extern Gfx d_course_bowsers_castle_dl_0[]; @@ -115,8 +115,8 @@ extern Gfx d_course_bowsers_castle_dl_4A98[]; extern Gfx d_course_bowsers_castle_dl_4C00[]; extern Gfx d_course_bowsers_castle_dl_4CE8[]; extern Gfx d_course_bowsers_castle_dl_4EA8[]; -extern TrackWaypoint d_course_bowsers_castle_unknown_waypoints[]; -extern TrackWaypoint d_course_bowsers_castle_track_waypoints[]; +extern TrackPathPoint d_course_bowsers_castle_unknown_path[]; +extern TrackPathPoint d_course_bowsers_castle_track_path[]; extern u8 d_course_bowsers_castle_thwomp_side[]; extern u8 d_course_bowsers_castle_thwomp_tlut[]; extern u8 d_course_bowsers_castle_thwomp_faces[][1024]; diff --git a/courses/choco_mountain/course_data.c b/courses/choco_mountain/course_data.c index 623432ffed..143dcc308b 100644 --- a/courses/choco_mountain/course_data.c +++ b/courses/choco_mountain/course_data.c @@ -2,7 +2,7 @@ #include #include #include -#include +#include #include #include @@ -2680,7 +2680,7 @@ Gfx d_course_choco_mountain_dl_43C8[] = { gsSPEndDisplayList(), }; -TrackWaypoint d_course_choco_mountain_unknown_waypoints[] = { +TrackPathPoint d_course_choco_mountain_unknown_path[] = { { -7, 0, -699, 0 }, { -6, 0, -712, 0 }, { 8, 0, -903, 0 }, { 26, 0, -1074, 0 }, { 46, 0, -1140, 0 }, { 80, 0, -1185, 0 }, { 134, 0, -1225, 0 }, { 343, 0, -1316, 0 }, { 408, 0, -1334, 0 }, { 462, 0, -1329, 0 }, { 534, 0, -1295, 0 }, { 566, 0, -1269, 0 }, { 633, 0, -1202, 0 }, { 671, 0, -1170, 0 }, { 726, 0, -1144, 0 }, @@ -2705,7 +2705,7 @@ TrackWaypoint d_course_choco_mountain_unknown_waypoints[] = { { 0, 0, 63, 0 }, { 6, 0, -132, 0 }, { 5, 0, -378, 0 }, { -5, 0, -630, 0 }, { -32768, 0, 0, 0 }, }; -TrackWaypoint d_course_choco_mountain_track_waypoints[] = { +TrackPathPoint d_course_choco_mountain_track_path[] = { { -6, 40, -705, 1 }, { -5, 39, -725, 1 }, { -3, 37, -745, 1 }, { -2, 34, -765, 1 }, { 0, 32, -785, 1 }, { 0, 30, -805, 1 }, { 2, 27, -825, 1 }, { 3, 25, -845, 2 }, { 5, 23, -865, 2 }, diff --git a/courses/choco_mountain/course_data.h b/courses/choco_mountain/course_data.h index 7584ada967..40099dd511 100644 --- a/courses/choco_mountain/course_data.h +++ b/courses/choco_mountain/course_data.h @@ -4,7 +4,7 @@ #include #include #include -#include +#include #include extern Gfx d_course_choco_mountain_dl_0[]; @@ -103,8 +103,8 @@ extern Gfx d_course_choco_mountain_dl_4138[]; extern Gfx d_course_choco_mountain_dl_41F8[]; extern Gfx d_course_choco_mountain_dl_42C8[]; extern Gfx d_course_choco_mountain_dl_43C8[]; -extern TrackWaypoint d_course_choco_mountain_unknown_waypoints[]; -extern TrackWaypoint d_course_choco_mountain_track_waypoints[]; +extern TrackPathPoint d_course_choco_mountain_unknown_path[]; +extern TrackPathPoint d_course_choco_mountain_track_path[]; extern Lights1 d_course_choco_mountain_light; extern Vtx d_course_choco_mountain_6005AF8[]; extern u8 d_course_choco_mountain_wall_texture[]; diff --git a/courses/dks_jungle_parkway/course_data.c b/courses/dks_jungle_parkway/course_data.c index 0f3af0275a..d61314befc 100644 --- a/courses/dks_jungle_parkway/course_data.c +++ b/courses/dks_jungle_parkway/course_data.c @@ -3,7 +3,7 @@ #include #include #include -#include +#include #include #include @@ -3971,7 +3971,7 @@ Gfx d_course_dks_jungle_parkway_dl_7108[] = { }; // 0x71F0 -TrackWaypoint d_course_dks_jungle_parkway_unknown_waypoints[] = { +TrackPathPoint d_course_dks_jungle_parkway_unknown_path[] = { { 2, 0, 12, 0 }, { 5, 0, -5, 0 }, { 0, 0, -211, 0 }, { 0, 0, -455, 0 }, { 9, 0, -522, 0 }, { 39, 0, -585, 0 }, { 91, 0, -634, 0 }, { 149, 0, -678, 0 }, { 428, 0, -840, 0 }, { 730, 0, -1014, 0 }, { 884, 0, -1081, 0 }, { 1118, 0, -1142, 0 }, @@ -4000,7 +4000,7 @@ TrackWaypoint d_course_dks_jungle_parkway_unknown_waypoints[] = { { 3, 0, 45, 0 }, { -32768, 0, 0, 0 }, }; -TrackWaypoint d_course_dks_jungle_parkway_ferry_waypoints[] = { +TrackPathPoint d_course_dks_jungle_parkway_ferry_path[] = { { 1237, 0, -1373, 0 }, { 1206, 0, -1365, 0 }, { 877, 0, -1272, 0 }, { 614, 0, -1152, 0 }, { 254, 0, -959, 0 }, { -44, 0, -852, 0 }, { -217, 0, -814, 0 }, { -350, 0, -801, 0 }, { -431, 0, -842, 0 }, { -442, 0, -942, 0 }, { -395, 0, -1039, 0 }, { -314, 0, -1154, 0 }, { -125, 0, -1307, 0 }, { 95, 0, -1466, 0 }, { 316, 0, -1570, 0 }, @@ -4010,7 +4010,7 @@ TrackWaypoint d_course_dks_jungle_parkway_ferry_waypoints[] = { { 1293, 0, -1375, 0 }, { -32768, 0, 0, 0 }, }; -TrackWaypoint d_course_dks_jungle_parkway_track_waypoints[] = { +TrackPathPoint d_course_dks_jungle_parkway_track_path[] = { { 3, 0, 3, 1 }, { 4, 0, -16, 1 }, { 3, 0, -36, 1 }, diff --git a/courses/dks_jungle_parkway/course_data.h b/courses/dks_jungle_parkway/course_data.h index e8d37ddc81..f45b38a9dd 100644 --- a/courses/dks_jungle_parkway/course_data.h +++ b/courses/dks_jungle_parkway/course_data.h @@ -4,7 +4,7 @@ #include #include #include -#include +#include #include extern Gfx d_course_dks_jungle_parkway_dl_0[]; @@ -112,9 +112,9 @@ extern Gfx d_course_dks_jungle_parkway_dl_6F10[]; extern Gfx d_course_dks_jungle_parkway_dl_7008[]; extern Gfx d_course_dks_jungle_parkway_dl_7080[]; extern Gfx d_course_dks_jungle_parkway_dl_7108[]; -extern TrackWaypoint d_course_dks_jungle_parkway_unknown_waypoints[]; -extern TrackWaypoint d_course_dks_jungle_parkway_ferry_waypoints[]; -extern TrackWaypoint d_course_dks_jungle_parkway_track_waypoints[]; +extern TrackPathPoint d_course_dks_jungle_parkway_unknown_path[]; +extern TrackPathPoint d_course_dks_jungle_parkway_ferry_path[]; +extern TrackPathPoint d_course_dks_jungle_parkway_track_path[]; extern Vtx d_course_dks_jungle_parkway_paddle_boat_model1[]; extern Vtx d_course_dks_jungle_parkway_paddle_boat_model2[]; extern Vtx d_course_dks_jungle_parkway_paddle_boat_model3[]; diff --git a/courses/frappe_snowland/course_data.c b/courses/frappe_snowland/course_data.c index 9a6042fa48..56777b2bb0 100644 --- a/courses/frappe_snowland/course_data.c +++ b/courses/frappe_snowland/course_data.c @@ -3,7 +3,7 @@ #include #include #include -#include +#include #include #include @@ -1428,7 +1428,7 @@ Gfx d_course_frappe_snowland_dl_33E0[] = { gsSPDisplayList(d_course_frappe_snowland_packed_dl_5B58), gsSPEndDisplayList(), }; -TrackWaypoint d_course_frappe_snowland_unknown_waypoints[] = { +TrackPathPoint d_course_frappe_snowland_unknown_path[] = { { -4, 0, -259, 0 }, { -4, 0, -282, 0 }, { -10, 0, -526, 0 }, { 41, 0, -658, 0 }, { 150, 0, -769, 0 }, { 358, 0, -831, 0 }, { 572, 0, -881, 0 }, { 719, 0, -982, 0 }, { 801, 0, -1109, 0 }, { 838, 0, -1262, 0 }, { 820, 0, -1435, 0 }, { 749, 0, -1568, 0 }, { 674, 0, -1676, 0 }, { 621, 0, -1863, 0 }, { 603, 0, -2054, 0 }, @@ -1446,7 +1446,7 @@ TrackWaypoint d_course_frappe_snowland_unknown_waypoints[] = { { 0, 0, 155, 0 }, { -3, 0, -133, 0 }, { -32768, 0, 0, 0 }, }; -TrackWaypoint d_course_frappe_snowland_track_waypoints[] = { +TrackPathPoint d_course_frappe_snowland_track_path[] = { { -4, 0, -270, 1 }, { -4, 0, -290, 1 }, { -4, 0, -310, 2 }, diff --git a/courses/frappe_snowland/course_data.h b/courses/frappe_snowland/course_data.h index a74e5b5e9d..61983a4a64 100644 --- a/courses/frappe_snowland/course_data.h +++ b/courses/frappe_snowland/course_data.h @@ -4,7 +4,7 @@ #include #include #include -#include +#include #include extern Gfx d_course_frappe_snowland_dl_0[]; @@ -75,8 +75,8 @@ extern Gfx d_course_frappe_snowland_dl_3198[]; extern Gfx d_course_frappe_snowland_dl_3270[]; extern Gfx d_course_frappe_snowland_dl_3328[]; extern Gfx d_course_frappe_snowland_dl_33E0[]; -extern TrackWaypoint d_course_frappe_snowland_unknown_waypoints[]; -extern TrackWaypoint d_course_frappe_snowland_track_waypoints[]; +extern TrackPathPoint d_course_frappe_snowland_unknown_path[]; +extern TrackPathPoint d_course_frappe_snowland_track_path[]; extern u8 d_course_frappe_snowland_snowman_tlut[]; extern u8 d_course_frappe_snowland_snowman_head[]; extern u8 d_course_frappe_snowland_snowman_body[]; diff --git a/courses/kalimari_desert/course_data.c b/courses/kalimari_desert/course_data.c index da1363c79a..d44e49b5cb 100644 --- a/courses/kalimari_desert/course_data.c +++ b/courses/kalimari_desert/course_data.c @@ -3,7 +3,7 @@ #include #include #include -#include +#include #include #include @@ -2988,7 +2988,7 @@ Gfx d_course_kalimari_desert_dl_6940[] = { }; // 0x6AC8 -TrackWaypoint d_course_kalimari_desert_unknown_waypoints[] = { +TrackPathPoint d_course_kalimari_desert_unknown_path[] = { { 1, 0, 503, 0 }, { 1, 0, 485, 0 }, { 1, 0, 325, 0 }, { 3, 0, -247, 0 }, { -47, 0, -559, 0 }, { -176, 0, -821, 0 }, { -379, 0, -996, 0 }, { -620, 0, -1082, 0 }, { -878, 0, -1095, 0 }, { -1133, 0, -1037, 0 }, { -1342, 0, -907, 0 }, { -1513, 0, -691, 0 }, { -1610, 0, -448, 0 }, { -1642, 0, -133, 0 }, { -1642, 0, 18, 0 }, @@ -3002,7 +3002,7 @@ TrackWaypoint d_course_kalimari_desert_unknown_waypoints[] = { { -32768, 0, 0, 0 }, }; -TrackWaypoint d_course_kalimari_desert_train_waypoints[] = { +TrackPathPoint d_course_kalimari_desert_train_path[] = { { -741, 0, 2114, 0 }, { -741, 0, 2130, 0 }, { -741, 0, 2364, 0 }, { -744, 0, 2840, 0 }, { -749, 0, 2906, 0 }, { -758, 0, 2962, 0 }, { -769, 0, 3017, 0 }, { -784, 0, 3085, 0 }, { -801, 0, 3138, 0 }, { -818, 0, 3184, 0 }, { -838, 0, 3229, 0 }, { -864, 0, 3281, 0 }, { -891, 0, 3325, 0 }, { -917, 0, 3364, 0 }, { -951, 0, 3404, 0 }, @@ -3021,7 +3021,7 @@ TrackWaypoint d_course_kalimari_desert_train_waypoints[] = { { -32768, 0, 0, 0 }, }; -TrackWaypoint d_course_kalimari_desert_track_waypoints[] = { +TrackPathPoint d_course_kalimari_desert_track_path[] = { { 1, 0, 494, 1 }, { 1, 0, 473, 2 }, { 1, 0, 453, 2 }, { 1, 1, 433, 2 }, { 1, 1, 413, 2 }, { 1, 1, 393, 2 }, { 1, 1, 373, 2 }, { 1, 1, 353, 2 }, { 1, 1, 333, 2 }, { 1, 2, 313, 2 }, { 1, 3, 293, 2 }, { 1, 3, 273, 2 }, diff --git a/courses/kalimari_desert/course_data.h b/courses/kalimari_desert/course_data.h index 9e98b98665..7f45824d50 100644 --- a/courses/kalimari_desert/course_data.h +++ b/courses/kalimari_desert/course_data.h @@ -4,7 +4,7 @@ #include #include #include -#include +#include #include extern Gfx d_course_kalimari_desert_dl_0[]; @@ -87,9 +87,9 @@ extern Gfx d_course_kalimari_desert_dl_65B0[]; extern Gfx d_course_kalimari_desert_dl_66F0[]; extern Gfx d_course_kalimari_desert_dl_6838[]; extern Gfx d_course_kalimari_desert_dl_6940[]; -extern TrackWaypoint d_course_kalimari_desert_unknown_waypoints[]; -extern TrackWaypoint d_course_kalimari_desert_train_waypoints[]; -extern TrackWaypoint d_course_kalimari_desert_track_waypoints[]; +extern TrackPathPoint d_course_kalimari_desert_unknown_path[]; +extern TrackPathPoint d_course_kalimari_desert_train_path[]; +extern TrackPathPoint d_course_kalimari_desert_track_path[]; extern u8 d_course_kalimari_desert_tree_tlut[]; extern Vtx d_course_kalimari_desert_cactus_model1[]; extern Vtx d_course_kalimari_desert_cactus_model2[]; diff --git a/courses/koopa_troopa_beach/course_data.c b/courses/koopa_troopa_beach/course_data.c index 6de181a4d1..c89581af93 100644 --- a/courses/koopa_troopa_beach/course_data.c +++ b/courses/koopa_troopa_beach/course_data.c @@ -3,7 +3,7 @@ #include #include #include -#include +#include #include #include #include @@ -6474,7 +6474,7 @@ Gfx d_course_koopa_troopa_beach_dl_AD40[] = { }; // 0xADE0 path -TrackWaypoint d_course_koopa_troopa_beach_unknown_waypoints[] = { +TrackPathPoint d_course_koopa_troopa_beach_unknown_path[] = { { -34, 0, 103, 0 }, { -34, 0, 60, 0 }, { -38, 0, -184, 0 }, { -30, 0, -304, 0 }, { 36, 0, -422, 0 }, { 137, 0, -566, 0 }, { 147, 0, -645, 0 }, { 103, 0, -761, 0 }, { -12, 0, -837, 0 }, { -139, 0, -1031, 0 }, { -230, 0, -1258, 0 }, { -343, 0, -1414, 0 }, { -465, 0, -1429, 0 }, { -629, 0, -1397, 0 }, { -853, 0, -1326, 0 }, @@ -6490,7 +6490,7 @@ TrackWaypoint d_course_koopa_troopa_beach_unknown_waypoints[] = { { -32, 0, 136, 0 }, { -32768, 0, 0, 0 }, }; -TrackWaypoint d_course_koopa_troopa_beach_unknown_waypoints1[] = { +TrackPathPoint d_course_koopa_troopa_beach_unknown_path1[] = { { -27, 0, 101, 7 }, { -31, 0, 76, 7 }, { -27, 0, -187, 7 }, { -24, 0, -305, 7 }, { 26, 0, -415, 7 }, { 119, 0, -564, 7 }, { 133, 0, -646, 7 }, { 94, 0, -742, 7 }, { 8, 0, -853, 7 }, { -150, 0, -934, 7 }, { -310, 0, -919, 7 }, { -471, 0, -887, 7 }, @@ -6508,7 +6508,7 @@ TrackWaypoint d_course_koopa_troopa_beach_unknown_waypoints1[] = { { -24, 0, 409, 7 }, { -28, 0, 128, 7 }, { -32768, 0, 0, 0 }, }; -TrackWaypoint d_course_koopa_troopa_beach_track_waypoints[] = { +TrackPathPoint d_course_koopa_troopa_beach_track_path[] = { { -34, 1, 81, 1 }, { -34, 1, 61, 1 }, { -34, 1, 41, 1 }, { -34, 1, 21, 2 }, { -34, 1, 1, 2 }, { -35, 1, -18, 2 }, { -35, 1, -38, 2 }, { -35, 1, -58, 2 }, { -36, 1, -78, 2 }, @@ -6714,7 +6714,7 @@ TrackWaypoint d_course_koopa_troopa_beach_track_waypoints[] = { { -33, 1, 121, 1 }, { -33, 1, 101, 1 }, { -32768, -32768, -32768, 0 }, }; -TrackWaypoint d_course_koopa_troopa_beach_track_waypoints_2[] = { +TrackPathPoint d_course_koopa_troopa_beach_track_path_2[] = { { -29, 1, 88, 1 }, { -29, 1, 68, 1 }, { -29, 1, 48, 1 }, diff --git a/courses/koopa_troopa_beach/course_data.h b/courses/koopa_troopa_beach/course_data.h index fa6c27bf0c..f205ab0440 100644 --- a/courses/koopa_troopa_beach/course_data.h +++ b/courses/koopa_troopa_beach/course_data.h @@ -4,7 +4,7 @@ #include #include #include -#include +#include #include #include "animation.h" @@ -306,10 +306,10 @@ extern Gfx d_course_koopa_troopa_beach_dl_AB88[]; extern Gfx d_course_koopa_troopa_beach_dl_AC10[]; extern Gfx d_course_koopa_troopa_beach_dl_AC68[]; extern Gfx d_course_koopa_troopa_beach_dl_AD40[]; -extern TrackWaypoint d_course_koopa_troopa_beach_unknown_waypoints[]; -extern TrackWaypoint d_course_koopa_troopa_beach_unknown_waypoints1[]; -extern TrackWaypoint d_course_koopa_troopa_beach_track_waypoints[]; -extern TrackWaypoint d_course_koopa_troopa_beach_track_waypoints_2[]; +extern TrackPathPoint d_course_koopa_troopa_beach_unknown_path[]; +extern TrackPathPoint d_course_koopa_troopa_beach_unknown_path1[]; +extern TrackPathPoint d_course_koopa_troopa_beach_track_path[]; +extern TrackPathPoint d_course_koopa_troopa_beach_track_path_2[]; extern u8 d_course_koopa_troopa_beach_crab_tlut[]; extern u8 d_course_koopa_troopa_beach_crab_frames[][4096]; extern u32 d_course_koopa_troopa_beach_unk_data1[]; diff --git a/courses/luigi_raceway/course_data.c b/courses/luigi_raceway/course_data.c index 45fb148526..89c360fb7e 100644 --- a/courses/luigi_raceway/course_data.c +++ b/courses/luigi_raceway/course_data.c @@ -3,7 +3,7 @@ #include #include #include -#include +#include #include #include @@ -4693,7 +4693,7 @@ Gfx d_course_luigi_raceway_dl_A320[] = { }; // 0xA540 -TrackWaypoint d_course_luigi_raceway_unknown_waypoints[] = { +TrackPathPoint d_course_luigi_raceway_unknown_path[] = { { -139, 0, -202, 0 }, { -139, 0, -218, 0 }, { -139, 0, -297, 0 }, { -139, 0, -2247, 0 }, { -138, 0, -2474, 0 }, { -170, 0, -2745, 0 }, { -249, 0, -2930, 0 }, { -373, 0, -3095, 0 }, { -550, 0, -3226, 0 }, { -787, 0, -3310, 0 }, { -1022, 0, -3321, 0 }, { -1236, 0, -3258, 0 }, @@ -4710,7 +4710,7 @@ TrackWaypoint d_course_luigi_raceway_unknown_waypoints[] = { }; // 0xA6D0 -TrackWaypoint d_course_luigi_raceway_track_waypoints[] = { +TrackPathPoint d_course_luigi_raceway_track_path[] = { { -139, -50, -210, 1 }, { -139, -50, -230, 2 }, { -139, -50, -250, 2 }, { -139, -50, -270, 2 }, { -139, -50, -290, 2 }, { -139, -50, -310, 2 }, { -139, -50, -330, 2 }, { -139, -50, -350, 2 }, { -139, -50, -370, 2 }, { -139, -50, -390, 2 }, { -139, -50, -410, 2 }, { -139, -50, -430, 2 }, diff --git a/courses/luigi_raceway/course_data.h b/courses/luigi_raceway/course_data.h index 1b0694238e..47224ce871 100644 --- a/courses/luigi_raceway/course_data.h +++ b/courses/luigi_raceway/course_data.h @@ -4,7 +4,7 @@ #include #include #include -#include +#include #include extern Gfx d_course_luigi_raceway_dl_0[]; @@ -127,8 +127,8 @@ extern Gfx d_course_luigi_raceway_dl_9E58[]; extern Gfx d_course_luigi_raceway_dl_A028[]; extern Gfx d_course_luigi_raceway_dl_A178[]; extern Gfx d_course_luigi_raceway_dl_A320[]; -extern TrackWaypoint d_course_luigi_raceway_unknown_waypoints[]; -extern TrackWaypoint d_course_luigi_raceway_track_waypoints[]; +extern TrackPathPoint d_course_luigi_raceway_unknown_path[]; +extern TrackPathPoint d_course_luigi_raceway_track_path[]; extern Vtx d_course_luigi_raceway_basket_model_lod2[]; extern Vtx d_course_luigi_raceway_unknown_model1[]; extern Vtx d_course_luigi_raceway_unknown_model2[]; diff --git a/courses/mario_raceway/course_data.c b/courses/mario_raceway/course_data.c index 096cd54e1a..371f350236 100644 --- a/courses/mario_raceway/course_data.c +++ b/courses/mario_raceway/course_data.c @@ -4,7 +4,7 @@ #include #include #include -#include +#include #include #include "course_displaylists.inc.h" @@ -3093,7 +3093,7 @@ Gfx d_course_mario_raceway_dl_5228[] = { gsSPEndDisplayList(), }; -TrackWaypoint d_course_mario_raceway_unknown_waypoints[] = { +TrackPathPoint d_course_mario_raceway_unknown_path[] = { { 0, 0, -224, 0 }, { 0, 0, -241, 0 }, { 0, 0, -612, 0 }, { 16, 0, -690, 0 }, { 62, 0, -756, 0 }, { 128, 0, -798, 0 }, { 494, 0, -944, 0 }, { 637, 0, -997, 0 }, { 708, 0, -1007, 0 }, { 776, 0, -992, 0 }, { 836, 0, -949, 0 }, { 883, 0, -890, 0 }, { 902, 0, -796, 0 }, { 878, 0, -706, 0 }, { 812, 0, -584, 0 }, @@ -3111,7 +3111,7 @@ TrackWaypoint d_course_mario_raceway_unknown_waypoints[] = { { 1, 0, 255, 0 }, { 0, 0, -180, 0 }, { -32768, 0, 0, 0 }, }; -TrackWaypoint d_course_mario_raceway_track_waypoints[] = { +TrackPathPoint d_course_mario_raceway_track_path[] = { { 0, 0, -232, 1 }, { 0, 0, -252, 1 }, { 0, 0, -272, 1 }, { 0, 0, -292, 1 }, { 0, 0, -312, 1 }, { 0, 0, -332, 1 }, { 0, 0, -352, 1 }, { 0, 0, -372, 1 }, { 0, 0, -392, 1 }, { 0, 0, -412, 1 }, { 0, 0, -432, 1 }, { 0, 0, -452, 1 }, diff --git a/courses/mario_raceway/course_data.h b/courses/mario_raceway/course_data.h index bdc5a137d9..5ef289a71e 100644 --- a/courses/mario_raceway/course_data.h +++ b/courses/mario_raceway/course_data.h @@ -4,7 +4,7 @@ #include #include #include -#include +#include #include extern Gfx d_course_mario_raceway_dl_0[]; @@ -76,8 +76,8 @@ extern Gfx d_course_mario_raceway_dl_4ED0[]; extern Gfx d_course_mario_raceway_dl_4FF0[]; extern Gfx d_course_mario_raceway_dl_5150[]; extern Gfx d_course_mario_raceway_dl_5228[]; -extern TrackWaypoint d_course_mario_raceway_unknown_waypoints[]; -extern TrackWaypoint d_course_mario_raceway_track_waypoints[]; +extern TrackPathPoint d_course_mario_raceway_unknown_path[]; +extern TrackPathPoint d_course_mario_raceway_track_path[]; extern u8 d_course_mario_raceway_piranha_plant_tlut[]; extern Vtx d_course_mario_raceway_piranha_plant_model[]; extern Gfx d_course_mario_raceway_dl_piranha_plant[]; diff --git a/courses/moo_moo_farm/course_data.c b/courses/moo_moo_farm/course_data.c index fc11d99ae5..f08ffb028e 100644 --- a/courses/moo_moo_farm/course_data.c +++ b/courses/moo_moo_farm/course_data.c @@ -3,7 +3,7 @@ #include #include #include -#include +#include #include #include @@ -8424,7 +8424,7 @@ Gfx d_course_moo_moo_farm_dl_EA18[] = { }; // 0xEC80 -TrackWaypoint d_course_moo_moo_farm_unknown_waypoints[] = { +TrackPathPoint d_course_moo_moo_farm_unknown_path[] = { { 11, 0, 46, 0 }, { 9, 0, 21, 0 }, { 5, 0, -307, 0 }, { -19, 0, -698, 0 }, { -28, 0, -1122, 0 }, { -11, 0, -1281, 0 }, { -17, 0, -1480, 0 }, { 35, 0, -1705, 0 }, { 221, 0, -1918, 0 }, { 413, 0, -2044, 0 }, { 628, 0, -2130, 0 }, { 851, 0, -2141, 0 }, { 1056, 0, -2065, 0 }, { 1200, 0, -1919, 0 }, { 1336, 0, -1771, 0 }, @@ -8436,7 +8436,7 @@ TrackWaypoint d_course_moo_moo_farm_unknown_waypoints[] = { { 27, 0, 423, 0 }, { 6, 0, 185, 0 }, { 6, 0, 78, 0 }, { 1737, 0, -186, 0 }, { -32768, 0, 0, 0 }, }; -TrackWaypoint d_course_moo_moo_farm_track_waypoints[] = { +TrackPathPoint d_course_moo_moo_farm_track_path[] = { { 10, 18, 33, 1 }, { 9, 17, 13, 2 }, { 8, 17, -6, 2 }, { 8, 16, -26, 2 }, { 8, 15, -46, 2 }, { 7, 14, -66, 2 }, { 7, 14, -86, 2 }, { 7, 14, -106, 2 }, { 7, 14, -126, 2 }, diff --git a/courses/moo_moo_farm/course_data.h b/courses/moo_moo_farm/course_data.h index 8ff50ec2d7..dada2dc9a2 100644 --- a/courses/moo_moo_farm/course_data.h +++ b/courses/moo_moo_farm/course_data.h @@ -4,7 +4,7 @@ #include #include #include -#include +#include #include extern Gfx d_course_moo_moo_farm_dl_0[]; @@ -104,8 +104,8 @@ extern Gfx d_course_moo_moo_farm_dl_E1D8[]; extern Gfx d_course_moo_moo_farm_dl_E4B0[]; extern Gfx d_course_moo_moo_farm_dl_E708[]; extern Gfx d_course_moo_moo_farm_dl_EA18[]; -extern TrackWaypoint d_course_moo_moo_farm_unknown_waypoints[]; -extern TrackWaypoint d_course_moo_moo_farm_track_waypoints[]; +extern TrackPathPoint d_course_moo_moo_farm_unknown_path[]; +extern TrackPathPoint d_course_moo_moo_farm_track_path[]; extern u8 d_course_moo_moo_farm_mole_tlut[]; extern u8 d_course_moo_moo_farm_mole_frames[][2048]; extern u8 d_course_moo_moo_farm_mole_dirt[]; diff --git a/courses/rainbow_road/course_data.c b/courses/rainbow_road/course_data.c index a1d68895c0..6019f87927 100644 --- a/courses/rainbow_road/course_data.c +++ b/courses/rainbow_road/course_data.c @@ -3,7 +3,7 @@ #include #include #include -#include +#include #include #include #include @@ -813,7 +813,7 @@ Gfx d_course_rainbow_road_dl_1948[] = { gsSPEndDisplayList(), }; -TrackWaypoint d_course_rainbow_road_unknown_waypoints[] = { +TrackPathPoint d_course_rainbow_road_unknown_path[] = { { 6, 0, 3, 0 }, { 6, 0, -25, 0 }, { 0, 0, -514, 0 }, { 1, 0, -1537, 0 }, { -3, 0, -2579, 0 }, { -3, 0, -3696, 0 }, { 1, 0, -4448, 0 }, { 30, 0, -4782, 0 }, { 113, 0, -5064, 0 }, { 331, 0, -5290, 0 }, { 610, 0, -5390, 0 }, { 915, 0, -5345, 0 }, @@ -842,7 +842,7 @@ TrackWaypoint d_course_rainbow_road_unknown_waypoints[] = { { -32768, 0, 0, 0 }, }; -TrackWaypoint d_course_rainbow_road_track_waypoints[] = { +TrackPathPoint d_course_rainbow_road_track_path[] = { { 6, 1510, -11, 1 }, { 5, 1509, -31, 2 }, { 5, 1509, -51, 2 }, { 5, 1508, -71, 2 }, { 5, 1507, -91, 2 }, { 4, 1506, -111, 2 }, { 4, 1505, -131, 2 }, { 4, 1504, -151, 2 }, { 4, 1504, -171, 2 }, diff --git a/courses/rainbow_road/course_data.h b/courses/rainbow_road/course_data.h index c7ff57584c..20a914dd94 100644 --- a/courses/rainbow_road/course_data.h +++ b/courses/rainbow_road/course_data.h @@ -4,7 +4,7 @@ #include #include #include -#include +#include #include #include "animation.h" @@ -58,8 +58,8 @@ extern Gfx d_course_rainbow_road_dl_17D0[]; extern Gfx d_course_rainbow_road_dl_1878[]; extern Gfx d_course_rainbow_road_dl_18D0[]; extern Gfx d_course_rainbow_road_dl_1948[]; -extern TrackWaypoint d_course_rainbow_road_unknown_waypoints[]; -extern TrackWaypoint d_course_rainbow_road_track_waypoints[]; +extern TrackPathPoint d_course_rainbow_road_unknown_path[]; +extern TrackPathPoint d_course_rainbow_road_track_path[]; extern u8 d_course_rainbow_road_neon_mushroom_tlut_list[][512]; extern u8 d_course_rainbow_road_neon_mario_tlut_list[][512]; extern u8 d_course_rainbow_road_neon_boo_tlut_list[][512]; diff --git a/courses/royal_raceway/course_data.c b/courses/royal_raceway/course_data.c index 6ed835ffd0..53e2c925c2 100644 --- a/courses/royal_raceway/course_data.c +++ b/courses/royal_raceway/course_data.c @@ -3,7 +3,7 @@ #include #include #include -#include +#include #include #include @@ -4902,7 +4902,7 @@ Gfx d_course_royal_raceway_dl_B508[] = { }; // 0xB5B8 -TrackWaypoint d_course_royal_raceway_unknown_waypoints[] = { +TrackPathPoint d_course_royal_raceway_unknown_path[] = { { -63, 0, -321, 0 }, { -61, 0, -341, 0 }, { -60, 0, -591, 0 }, { -64, 0, -1334, 0 }, { -64, 0, -1761, 0 }, { -80, 0, -1851, 0 }, { -155, 0, -1949, 0 }, { -339, 0, -2075, 0 }, { -694, 0, -2315, 0 }, { -874, 0, -2417, 0 }, { -998, 0, -2434, 0 }, { -1134, 0, -2399, 0 }, @@ -4925,7 +4925,7 @@ TrackWaypoint d_course_royal_raceway_unknown_waypoints[] = { { -62, 0, -296, 0 }, { -32768, 0, 0, 0 }, }; -TrackWaypoint d_course_royal_raceway_track_waypoints[] = { +TrackPathPoint d_course_royal_raceway_track_path[] = { { -62, 0, -331, 1 }, { -61, 0, -350, 2 }, { -61, 0, -371, 2 }, { -60, 0, -391, 2 }, { -60, 0, -411, 2 }, { -60, 0, -431, 2 }, { -60, 0, -451, 2 }, { -60, 0, -471, 2 }, { -60, 0, -491, 2 }, diff --git a/courses/royal_raceway/course_data.h b/courses/royal_raceway/course_data.h index 3f73254244..68a78be34e 100644 --- a/courses/royal_raceway/course_data.h +++ b/courses/royal_raceway/course_data.h @@ -4,7 +4,7 @@ #include #include #include -#include +#include #include extern Gfx d_course_royal_raceway_dl_0[]; @@ -139,8 +139,8 @@ extern Gfx d_course_royal_raceway_dl_B230[]; extern Gfx d_course_royal_raceway_dl_B2E0[]; extern Gfx d_course_royal_raceway_dl_B3E8[]; extern Gfx d_course_royal_raceway_dl_B508[]; -extern TrackWaypoint d_course_royal_raceway_unknown_waypoints[]; -extern TrackWaypoint d_course_royal_raceway_track_waypoints[]; +extern TrackPathPoint d_course_royal_raceway_unknown_path[]; +extern TrackPathPoint d_course_royal_raceway_track_path[]; extern Vtx d_course_royal_raceway_tree_model[]; extern Gfx d_course_royal_raceway_dl_tree[]; extern Vtx d_royal_raceway_peaches_castle_tree_model[]; diff --git a/courses/sherbet_land/course_data.c b/courses/sherbet_land/course_data.c index a72089ac07..bfba0c64c6 100644 --- a/courses/sherbet_land/course_data.c +++ b/courses/sherbet_land/course_data.c @@ -3,7 +3,7 @@ #include #include #include -#include +#include #include #include #include @@ -2838,7 +2838,7 @@ Gfx d_course_sherbet_land_dl_4B20[] = { }; // unk 0x4BF8 -TrackWaypoint d_course_sherbet_land_unknown_waypoints[] = { +TrackPathPoint d_course_sherbet_land_unknown_path[] = { { -10, 0, 10, 0 }, { -10, 0, -8, 0 }, { -18, 0, -213, 0 }, { 52, 0, -308, 0 }, { 217, 0, -455, 0 }, { 436, 0, -587, 0 }, { 487, 0, -649, 0 }, { 465, 0, -722, 0 }, { 308, 0, -890, 0 }, { 132, 0, -1099, 0 }, { 37, 0, -1319, 0 }, { 31, 0, -1396, 0 }, @@ -2857,7 +2857,7 @@ TrackWaypoint d_course_sherbet_land_unknown_waypoints[] = { { -2058, 0, 1043, 0 }, { -32768, 0, 0, 0 }, }; -TrackWaypoint d_course_sherbet_land_track_waypoints[] = { +TrackPathPoint d_course_sherbet_land_track_path[] = { { -10, 0, 1, 1 }, { -10, 0, -19, 1 }, { -11, 0, -38, 1 }, { -12, 0, -58, 1 }, { -12, 0, -78, 1 }, { -13, 0, -98, 1 }, { -14, 0, -118, 1 }, { -14, 0, -139, 1 }, { -13, 0, -159, 1 }, diff --git a/courses/sherbet_land/course_data.h b/courses/sherbet_land/course_data.h index 51c8f0e350..8fefcca1e9 100644 --- a/courses/sherbet_land/course_data.h +++ b/courses/sherbet_land/course_data.h @@ -4,7 +4,7 @@ #include #include #include -#include +#include #include #include "animation.h" @@ -152,8 +152,8 @@ extern Gfx d_course_sherbet_land_dl_4930[]; extern Gfx d_course_sherbet_land_dl_4A20[]; extern Gfx d_course_sherbet_land_dl_4A98[]; extern Gfx d_course_sherbet_land_dl_4B20[]; -extern TrackWaypoint d_course_sherbet_land_unknown_waypoints[]; -extern TrackWaypoint d_course_sherbet_land_track_waypoints[]; +extern TrackPathPoint d_course_sherbet_land_unknown_path[]; +extern TrackPathPoint d_course_sherbet_land_track_path[]; extern Vtx d_course_sherbet_land_model1[]; extern Vtx d_course_sherbet_land_model2[]; extern Vtx d_course_sherbet_land_model3[]; diff --git a/courses/toads_turnpike/course_data.c b/courses/toads_turnpike/course_data.c index ef11cb18f7..e371c4bb24 100644 --- a/courses/toads_turnpike/course_data.c +++ b/courses/toads_turnpike/course_data.c @@ -3,7 +3,7 @@ #include #include #include -#include +#include #include #include @@ -1659,7 +1659,7 @@ Gfx d_course_toads_turnpike_dl_3AD8[] = { }; // 0x3B80 -TrackWaypoint d_course_toads_turnpike_unknown_waypoints[] = { +TrackPathPoint d_course_toads_turnpike_unknown_path[] = { { 100, 0, 26, 0 }, { 100, 0, 7, 0 }, { 102, 0, -299, 0 }, { 88, 0, -601, 0 }, { 76, 0, -897, 0 }, { 78, 0, -1946, 0 }, { 64, 0, -2260, 0 }, { 5, 0, -2490, 0 }, { -116, 0, -2706, 0 }, { -279, 0, -2886, 0 }, { -481, 0, -3017, 0 }, { -706, 0, -3099, 0 }, @@ -1676,7 +1676,7 @@ TrackWaypoint d_course_toads_turnpike_unknown_waypoints[] = { { 98, 0, 50, 0 }, { -32768, 0, 0, 0 }, }; -TrackWaypoint d_course_toads_turnpike_track_waypoints[] = { +TrackPathPoint d_course_toads_turnpike_track_path[] = { { 100, 0, 16, 1 }, { 100, 0, -3, 1 }, { 100, 0, -23, 1 }, diff --git a/courses/toads_turnpike/course_data.h b/courses/toads_turnpike/course_data.h index 2fd62526ce..d86b4fd68e 100644 --- a/courses/toads_turnpike/course_data.h +++ b/courses/toads_turnpike/course_data.h @@ -4,7 +4,7 @@ #include #include #include -#include +#include #include extern Gfx d_course_toads_turnpike_dl_0[]; @@ -89,8 +89,8 @@ extern Gfx d_course_toads_turnpike_dl_37F0[]; extern Gfx d_course_toads_turnpike_dl_3910[]; extern Gfx d_course_toads_turnpike_dl_39C8[]; extern Gfx d_course_toads_turnpike_dl_3AD8[]; -extern TrackWaypoint d_course_toads_turnpike_unknown_waypoints[]; -extern TrackWaypoint d_course_toads_turnpike_track_waypoints[]; +extern TrackPathPoint d_course_toads_turnpike_unknown_path[]; +extern TrackPathPoint d_course_toads_turnpike_track_path[]; extern u8 d_course_toads_turnpike_unk_windshield1[]; extern u8 d_course_toads_turnpike_unk_windshield2[]; extern u8 d_course_toads_turnpike_truck_box1[]; diff --git a/courses/wario_stadium/course_data.c b/courses/wario_stadium/course_data.c index 33767216a4..b72503024a 100644 --- a/courses/wario_stadium/course_data.c +++ b/courses/wario_stadium/course_data.c @@ -3,7 +3,7 @@ #include #include #include -#include +#include #include #include @@ -2256,7 +2256,7 @@ Gfx d_course_wario_stadium_dl_5588[] = { }; // 0x56A0 -TrackWaypoint d_course_wario_stadium_unknown_waypoints[] = { +TrackPathPoint d_course_wario_stadium_unknown_path[] = { { 16, 0, 7, 0 }, { 11, 0, -25, 0 }, { 8, 0, -227, 0 }, { 6, 0, -674, 0 }, { -3, 0, -1560, 0 }, { -121, 0, -1883, 0 }, { -430, 0, -2100, 0 }, { -790, 0, -2160, 0 }, { -1487, 0, -2155, 0 }, { -2171, 0, -2139, 0 }, { -2522, 0, -2014, 0 }, { -2757, 0, -1691, 0 }, @@ -2279,7 +2279,7 @@ TrackWaypoint d_course_wario_stadium_unknown_waypoints[] = { { -32768, 0, 0, 0 }, }; -TrackWaypoint d_course_wario_stadium_track_waypoints[] = { +TrackPathPoint d_course_wario_stadium_track_path[] = { { 13, 0, -9, 1 }, { 11, 0, -28, 1 }, { 11, 0, -48, 1 }, { 10, 0, -68, 1 }, { 10, 0, -88, 1 }, { 9, 0, -108, 1 }, { 9, 0, -128, 1 }, { 9, 0, -148, 1 }, { 8, 0, -168, 1 }, diff --git a/courses/wario_stadium/course_data.h b/courses/wario_stadium/course_data.h index 1fc5d7515f..1ef5a79cf7 100644 --- a/courses/wario_stadium/course_data.h +++ b/courses/wario_stadium/course_data.h @@ -4,7 +4,7 @@ #include #include #include -#include +#include #include extern Gfx d_course_wario_stadium_dl_0[]; @@ -115,8 +115,8 @@ extern Gfx d_course_wario_stadium_dl_5338[]; extern Gfx d_course_wario_stadium_dl_5460[]; extern Gfx d_course_wario_stadium_dl_54E8[]; extern Gfx d_course_wario_stadium_dl_5588[]; -extern TrackWaypoint d_course_wario_stadium_unknown_waypoints[]; -extern TrackWaypoint d_course_wario_stadium_track_waypoints[]; +extern TrackPathPoint d_course_wario_stadium_unknown_path[]; +extern TrackPathPoint d_course_wario_stadium_track_path[]; extern Vtx d_course_wario_stadium_sign_head_model1[]; extern Vtx d_course_wario_stadium_sign_head_model2[]; extern Vtx d_course_wario_stadium_sign_head_model3[]; diff --git a/courses/yoshi_valley/course_data.c b/courses/yoshi_valley/course_data.c index 6526c89956..aa70323fe8 100644 --- a/courses/yoshi_valley/course_data.c +++ b/courses/yoshi_valley/course_data.c @@ -3,7 +3,7 @@ #include #include #include -#include +#include #include #include #include @@ -5644,7 +5644,7 @@ Gfx d_course_yoshi_valley_dl_D540[] = { }; // 0xD780 -TrackWaypoint d_course_yoshi_valley_unknown_waypoints[] = { +TrackPathPoint d_course_yoshi_valley_unknown_path[] = { { -3, 0, -4, 0 }, { -3, 0, -20, 0 }, { -3, 0, -261, 0 }, { -18, 0, -642, 0 }, { -62, 0, -955, 0 }, { -155, 0, -1297, 0 }, { -232, 0, -1502, 0 }, { -317, 0, -1596, 0 }, { -432, 0, -1625, 0 }, { -554, 0, -1619, 0 }, { -765, 0, -1542, 0 }, { -1069, 0, -1409, 0 }, @@ -5666,7 +5666,7 @@ TrackWaypoint d_course_yoshi_valley_unknown_waypoints[] = { { -32768, 0, 0, 0 }, }; -TrackWaypoint d_course_yoshi_valley_unknown_waypoints_2[] = { +TrackPathPoint d_course_yoshi_valley_unknown_path_2[] = { { -6, 0, -5, 1 }, { -6, 0, -21, 1 }, { -5, 0, -434, 1 }, { -37, 0, -841, 1 }, { -150, 0, -1267, 1 }, { -228, 0, -1498, 1 }, { -328, 0, -1603, 1 }, { -439, 0, -1627, 1 }, { -548, 0, -1621, 1 }, { -759, 0, -1544, 1 }, { -1078, 0, -1402, 1 }, { -1207, 0, -1400, 1 }, @@ -5688,7 +5688,7 @@ TrackWaypoint d_course_yoshi_valley_unknown_waypoints_2[] = { { -2, 0, 33, 1 }, { -32768, 0, 0, 0 }, }; -TrackWaypoint d_course_yoshi_valley_unknown_waypoints_3[] = { +TrackPathPoint d_course_yoshi_valley_unknown_path_3[] = { { -3, 0, -3, 4 }, { -3, 0, -19, 4 }, { 0, 0, -268, 4 }, { -21, 0, -638, 4 }, { -66, 0, -952, 4 }, { -162, 0, -1297, 4 }, { -232, 0, -1502, 4 }, { -318, 0, -1594, 4 }, { -434, 0, -1624, 4 }, { -562, 0, -1612, 4 }, { -768, 0, -1547, 4 }, { -1081, 0, -1412, 4 }, @@ -5712,7 +5712,7 @@ TrackWaypoint d_course_yoshi_valley_unknown_waypoints_3[] = { { -6, 0, 21, 4 }, { -32768, 0, 0, 0 }, }; -TrackWaypoint d_course_yoshi_valley_unknown_waypoints_4[] = { +TrackPathPoint d_course_yoshi_valley_unknown_path_4[] = { { -2, 0, -1, 7 }, { 0, 0, -18, 7 }, { -2, 0, -268, 7 }, { -21, 0, -653, 7 }, { -70, 0, -965, 7 }, { -162, 0, -1303, 7 }, { -235, 0, -1506, 7 }, { -324, 0, -1596, 7 }, { -438, 0, -1624, 7 }, { -571, 0, -1611, 7 }, { -773, 0, -1533, 7 }, { -1077, 0, -1399, 7 }, @@ -5737,7 +5737,7 @@ TrackWaypoint d_course_yoshi_valley_unknown_waypoints_4[] = { { -32768, 0, 0, 0 }, }; -TrackWaypoint d_course_yoshi_valley_track_waypoints[] = { +TrackPathPoint d_course_yoshi_valley_track_path[] = { { -3, 180, -12, 1 }, { -3, 180, -32, 2 }, { -3, 180, -52, 2 }, { -2, 180, -72, 2 }, { -3, 180, -92, 2 }, { -3, 180, -112, 2 }, { -3, 180, -132, 2 }, { -3, 180, -152, 2 }, { -3, 180, -172, 2 }, @@ -5966,7 +5966,7 @@ TrackWaypoint d_course_yoshi_valley_track_waypoints[] = { { -4, 180, 18, 1 }, { -3, 180, -1, 1 }, { -32768, -32768, -32768, 0 }, }; -TrackWaypoint d_course_yoshi_valley_track_waypoints_2[] = { +TrackPathPoint d_course_yoshi_valley_track_path_2[] = { { -6, 180, -13, 1 }, { -5, 180, -33, 2 }, { -5, 180, -53, 2 }, @@ -6636,7 +6636,7 @@ TrackWaypoint d_course_yoshi_valley_track_waypoints_2[] = { { -32768, -32768, -32768, 0 }, }; -TrackWaypoint d_course_yoshi_valley_track_waypoints_3[] = { +TrackPathPoint d_course_yoshi_valley_track_path_3[] = { { -3, 180, -11, 1 }, { -2, 180, -31, 2 }, { -2, 180, -51, 2 }, @@ -7318,7 +7318,7 @@ TrackWaypoint d_course_yoshi_valley_track_waypoints_3[] = { { -32768, -32768, -32768, 0 }, }; -TrackWaypoint d_course_yoshi_valley_track_waypoints_4[] = { +TrackPathPoint d_course_yoshi_valley_track_path_4[] = { { -1, 180, -9, 1 }, { 0, 180, -29, 2 }, { 0, 180, -49, 2 }, diff --git a/courses/yoshi_valley/course_data.h b/courses/yoshi_valley/course_data.h index 2497ceee67..f37906b3be 100644 --- a/courses/yoshi_valley/course_data.h +++ b/courses/yoshi_valley/course_data.h @@ -4,7 +4,7 @@ #include #include #include -#include +#include #include #include "animation.h" @@ -133,14 +133,14 @@ extern Gfx d_course_yoshi_valley_dl_D018[]; extern Gfx d_course_yoshi_valley_dl_D1E8[]; extern Gfx d_course_yoshi_valley_dl_D3D0[]; extern Gfx d_course_yoshi_valley_dl_D540[]; -extern TrackWaypoint d_course_yoshi_valley_unknown_waypoints[]; -extern TrackWaypoint d_course_yoshi_valley_unknown_waypoints_2[]; -extern TrackWaypoint d_course_yoshi_valley_unknown_waypoints_3[]; -extern TrackWaypoint d_course_yoshi_valley_unknown_waypoints_4[]; -extern TrackWaypoint d_course_yoshi_valley_track_waypoints[]; -extern TrackWaypoint d_course_yoshi_valley_track_waypoints_2[]; -extern TrackWaypoint d_course_yoshi_valley_track_waypoints_3[]; -extern TrackWaypoint d_course_yoshi_valley_track_waypoints_4[]; +extern TrackPathPoint d_course_yoshi_valley_unknown_path[]; +extern TrackPathPoint d_course_yoshi_valley_unknown_path_2[]; +extern TrackPathPoint d_course_yoshi_valley_unknown_path_3[]; +extern TrackPathPoint d_course_yoshi_valley_unknown_path_4[]; +extern TrackPathPoint d_course_yoshi_valley_track_path[]; +extern TrackPathPoint d_course_yoshi_valley_track_path_2[]; +extern TrackPathPoint d_course_yoshi_valley_track_path_3[]; +extern TrackPathPoint d_course_yoshi_valley_track_path_4[]; extern Lights1 d_course_yoshi_valley_unknown_light1; extern Lights1 d_course_yoshi_valley_unknown_light2; extern Lights1 d_course_yoshi_valley_unknown_light3; diff --git a/docs/basics/controlflow.md b/docs/basics/controlflow.md index 01af022b3a..6bf6ddcf0f 100644 --- a/docs/basics/controlflow.md +++ b/docs/basics/controlflow.md @@ -3,54 +3,60 @@ [TOC] # Paradigm + The developers wrote mk64 using a state-driven paradigm. Gamestate, gamemode, course, actors, structs, and more decide which branches code should follow. As an example, a condition can check the current course to load that courses resources or run logic based on that. # Threading + After boot, the game begins by setting up its four threads; [idle](@ref thread1_idle), [video](@ref thread3_video), [audio](@ref thread4_audio), and the [game loop](@ref thread5_game_loop). The [idle thread](@ref thread1_idle) allows the cpu to sleep. Without it, if at any time execution of all threads were paused, the cpu would never be able to continue. The idle thread is active if all the other threads are paused. As such, the [idle thread](@ref thread1_idle) runs the following loop: `while(true);` (it runs in a perpetual loop of nothing; sleep). In mips assembly it looks like this: + ``` .L800005B8: b .L800005B8 -nop +nop ``` + b stands for branch which acts akin to a goto. In this case, branch to the label `.L800005B8`. This creates an infinite loop. Whenever the cpu branches it always runs the next instruction as well which is called a delay slot. This means the cpu will continuously branch then run `nop` or `no operation` with no method of escaping the loop (except for when another thread has a higher priority which means the cpu switches to that thread and stops running the idle thread). N64 threads are ran based on priority running whichever thread holds the most of it. Threads can also pause and wait for events. Note that the N64 is not multi-threaded by modern standards as the other threads contain specific purposes which slightly differs from the concept of splitting a single program into multiple processes for efficiency. # Overall Control Flow + order of initialisation of thread: boot: -* init_threads:
- * [idle](@ref thread1_idle), [video](@ref thread3_video), [audio](@ref thread4_audio), [game loop](@ref thread5_game_loop)
-* [game loop](@ref thread5_game_loop):
- * [audio](@ref thread4_audio)
- * [jumpTo a specific menu or race based on a gameState flag.](@ref update_gamestate)
- * [profiler](@ref profiler_log_thread5_time)
- * [config_gfx_pool](@ref config_gfx_pool)
- * [read_controllers](@ref read_controllers)
- * [game_state_handler](@ref game_state_handler)
- * [endDL/vsync](@ref display_and_vsync)
- * [game_state_handler](@ref game_state_handler):
- * switch([gGamestate](@ref gGamestate))
- * [menus](@ref update_menus) -> switch([menu](@ref gMenuSelection)) { // do menu stuff }
- * [race_logic_loop](@ref race_logic_loop) -> spaghetti
- * [podium_ceremony](@ref podium_ceremony_loop)
- * [credits](@ref credits_loop)
-* [video](@ref thread3_video):
+ +- init_threads:
+ - [idle](@ref thread1_idle), [video](@ref thread3_video), [audio](@ref thread4_audio), [game loop](@ref thread5_game_loop)
+- [game loop](@ref thread5_game_loop):
+ - [audio](@ref thread4_audio)
+ - [jumpTo a specific menu or race based on a gameState flag.](@ref update_gamestate)
+ - [profiler](@ref profiler_log_thread5_time)
+ - [config_gfx_pool](@ref config_gfx_pool)
+ - [read_controllers](@ref read_controllers)
+ - [game_state_handler](@ref game_state_handler)
+ - [endDL/vsync](@ref display_and_vsync)
+ - [game_state_handler](@ref game_state_handler):
+ - switch([gGamestate](@ref gGamestate))
+ - [menus](@ref update_menus) -> switch([menu](@ref gMenuSelection)) { // do menu stuff }
+ - [race_logic_loop](@ref race_logic_loop) -> spaghetti
+ - [podium_ceremony](@ref podium_ceremony_loop)
+ - [credits](@ref credits_loop)
+- [video](@ref thread3_video):
handles interaction between video/audio threads. handles vblanking and some elements pertaining to framebuffer most of all, handles which step of rendering a frame the cpu is in. Checks when new to start new sp tasks - If mk64 is in a menu state it will branch off to the menu code, running relevant bits of code based on more flags such as which particular menu the user is in. This will loop until the state changes to a different one such as race mode. If mk64 is in a race state, then race related code is ran and it spaghetti's off into a wide series of branches. This may include concepts such as `isLinedUp, isRacing, isRaceFinished, gotoNextCourse, isHuman, and isAI`. This relatively primitive design could be defined as a state machine from an abstract point of view. This would differ from an OOP design that uses objects and hierarchy. You will become very familiar with this design principle as you explore the code-base. During any step of the game loop, a switch can be setup to check a flag then run code relevant to the situation. For instance, a flag can check whether a race is in-progress or complete. If in-progress set the player to human controlled. If complete, set player to AI controlled. # Segments + mk64 code is split into three sections for now. |Segment|desc| |---|---| @@ -63,13 +69,15 @@ Racing segment loads after selecting a grand prix. Note that it is always reload # Code Breakdown ## Menus -|file|desc| -|---|---| -|[menus](@ref menus.c)| Menu related code | -|[save](@ref save.c)| Save related | -|[startup_logo](@ref data/startup_logo.c)|Startup logo| + +| file | desc | +| ---------------------------------------- | ----------------- | +| [menus](@ref menus.c) | Menu related code | +| [save](@ref save.c) | Save related | +| [startup_logo](@ref data/startup_logo.c) | Startup logo | ## Players + Player related code resides in |file|desc| |---|---| @@ -77,14 +85,16 @@ Player related code resides in |[camera](@ref camera.c)| Player cameras | ## Actors + Actor related code resides in |file|desc| |---|---| |[actors](@ref actors.c)|Variety of [actors](actorsmenu.html), see link for specifics.| |[actors_extended](@ref actors_extended.c)|Shells and bananas| -|[code_80005FD0](@ref code_80005FD0.c)| Vehicles; trains, cars, trucks, boats | +|[cpu_vehicles_camera_path](@ref cpu_vehicles_camera_path.c)| Vehicles; trains, cars, trucks, boats | ## Objects + Object related code resides in |file|desc| |---|---| @@ -95,6 +105,7 @@ Object related code resides in Documentation of the specifics still in-progress. See [actors](actorsmenu.html) for more information. ## Courses + Course related code resides in |file|desc| |---|---| @@ -103,36 +114,41 @@ Course related code resides in |[common_textures](@ref common_textures.c)|Content accessible to every course such as items and portraits| ### Course Folder + [course folder link][@ref courses] |file|desc| |---|---| |courses/course_name/course_data.c|Course data| -|courses/course_name/course_vertices.inc.c|Course vertices (this + _displaylists.inc.c makes the course geography)| +|courses/course_name/course_vertices.inc.c|Course vertices (this + \_displaylists.inc.c makes the course geography)| |courses/course_name/course_displaylists.inc.c|Course displaylists (these get compressed during compile)| |courses/course_name/course_offsets.c|Textures used in the course| ## UI & Other 2D Screen data -|file|desc| -|---|---| -|[render_objects](@ref render_objects.c)|ItemWindows| + +| file | desc | +| --------------------------------------- | ----------- | +| [render_objects](@ref render_objects.c) | ItemWindows | ## Engine -|file|desc| -|---|---| -|[collision](@ref collision.c)| | -|[code_80005FD0](@ref code_80005FD0.c)| Pathing code | + +| file | desc | +| ----------------------------------------------------------- | ------------ | +| [collision](@ref collision.c) | | +| [cpu_vehicles_camera_path](@ref cpu_vehicles_camera_path.c) | Pathing code | ## Math + Math related code resides in |file|desc| |---|---| |[math_util](@ref math_util.c)| | -|[math_util_2](@ref math_util_2.c)| | +|[math_util_2](@ref math_util_2.c)| | ## Ending -|file|desc| -|---|---| -|[ceremony_and_credits](@ref ceremony_and_credits.c)|Camera rails for podium ceremony and credits| -|[podium_ceremony_actors](@ref podium_ceremony_actors.c)|Fireworks and balloons for podium ceremony| -|[ceremony_data](@ref ceremony_data.c)|Trophies and podium models. Paths.| -|[credits](@ref credits.c)|Credits text and UI positions| + +| file | desc | +| ------------------------------------------------------- | -------------------------------------------- | +| [ceremony_and_credits](@ref ceremony_and_credits.c) | Camera rails for podium ceremony and credits | +| [podium_ceremony_actors](@ref podium_ceremony_actors.c) | Fireworks and balloons for podium ceremony | +| [ceremony_data](@ref ceremony_data.c) | Trophies and podium models. Paths. | +| [credits](@ref credits.c) | Credits text and UI positions | diff --git a/enhancements/flycam.patch b/enhancements/flycam.patch index 64384d1cac..fd81c47f67 100644 --- a/enhancements/flycam.patch +++ b/enhancements/flycam.patch @@ -158,9 +158,9 @@ index 0000000..5569838 + // Don't use `bool = !bool` here as the game code can swap these on you. + // Which will confuse the code. This forces it to always be correct + if (isFlycam) { -+ player->type |= PLAYER_KART_AI; ++ player->type |= PLAYER_CPU; + } else { -+ player->type &= PLAYER_KART_AI; ++ player->type &= PLAYER_CPU; + } + + gIsHUDVisible = !isFlycam; diff --git a/include/bomb_kart.h b/include/bomb_kart.h index 31550bbf64..3431b31b3d 100644 --- a/include/bomb_kart.h +++ b/include/bomb_kart.h @@ -17,7 +17,7 @@ #define BOMB_STATE_UNKNOWN 5 typedef struct { - /* 0x00 */ u16 waypointIndex; + /* 0x00 */ u16 pathPointIndex; /* 0x02 */ u16 startingState; /* 0x04 */ f32 unk_04; // Used to set the value of unk_3C in BombKart /* 0x08 */ f32 startingXPos; @@ -42,8 +42,8 @@ typedef struct { /* 0x24 */ Vec3f wheel3Pos; /* 0x30 */ Vec3f wheel4Pos; /* 0x3C */ f32 unk_3C; - /* 0x40 */ u16 someRot; // seems like an angle of some variety, can't figure out its purpose - /* 0x42 */ u16 waypointIndex; // probably the waypoint that the bomb circles + /* 0x40 */ u16 someRot; // seems like an angle of some variety, can't figure out its purpose + /* 0x42 */ u16 pathPointIndex; // probably the pathPoint that the bomb circles /* 0x44 */ u16 state; /* 0x46 */ u16 bounceTimer; // timer? state? height? /* 0x48 */ u16 circleTimer; // timer? state? Somehow controls how it circles around diff --git a/include/common_structs.h b/include/common_structs.h index a6d9fbc556..08231357f3 100644 --- a/include/common_structs.h +++ b/include/common_structs.h @@ -27,10 +27,10 @@ typedef enum { A = 0x80, B = 0x40, Z = 0x20, R = 0x10 } GhostController; /*** types.h ***/ typedef struct { - /* 0x0 */ s16 waypointStart; - /* 0x2 */ s16 waypointEnd; + /* 0x0 */ s16 pathPointStart; + /* 0x2 */ s16 pathPointEnd; /* 0x4 */ s32 type; -} KartAIBehaviour; // size = 0x8 +} CPUBehaviour; // size = 0x8 enum SpTaskState { SPTASK_STATE_NOT_STARTED, @@ -281,7 +281,7 @@ typedef struct { /* 0x0088 */ f32 unk_088; /* 0x008C */ f32 unk_08C; /* 0x0090 */ f32 unk_090; - /* 0x0094 */ f32 unk_094; + /* 0x0094 */ f32 speed; /* 0x0098 */ f32 unk_098; /* 0x009C */ f32 currentSpeed; /* 0x00A0 */ f32 unk_0A0; @@ -336,12 +336,12 @@ typedef struct { /* 0x0214 */ f32 topSpeed; /* 0x0218 */ f32 unk_218; /* 0x021C */ f32 unk_21C; - /* 0x0220 */ s16 nearestWaypointId; // ?? + /* 0x0220 */ s16 nearestPathPointId; // ?? /* 0x0222 */ s16 unk_222; /* 0x0224 */ f32 size; /* 0x0228 */ s16 unk_228; /* 0x022A */ s16 unk_22A; - /* 0x022C */ f32 unk_22C; + /* 0x022C */ f32 previousSpeed; /* 0x0230 */ f32 unk_230; /* 0x0234 */ s16 unk_234; /* 0x0236 */ s16 unk_236; diff --git a/include/course.h b/include/course.h index ff99e59333..4d5aacc287 100644 --- a/include/course.h +++ b/include/course.h @@ -4,7 +4,7 @@ #include #include #include -#include "waypoints.h" +#include "path.h" /** * @file Include for course gfx.inc.c. @@ -18,10 +18,10 @@ typedef struct { } TrackSections; struct _struct_gCoursePathSizes_0x10 { - /* 0x00 */ u16 unk0; - /* 0x02 */ u16 unk2; - /* 0x04 */ u16 unk4; - /* 0x06 */ u16 unk6; + /* 0x00 */ u16 firstPath; + /* 0x02 */ u16 secondPath; + /* 0x04 */ u16 thirdPath; + /* 0x06 */ u16 fourthPath; /* 0x08 */ u16 unk8; /* 0x0A */ char padA[6]; }; // size 0x10 @@ -83,20 +83,20 @@ typedef enum { extern s16 gCurrentCourseId; extern s16* D_800DCBB4[]; #define GET_COURSE_800DCBB4(n) D_800DCBB4[gCurrentCourseId][n] -extern f32 gKartAICourseMaximumSeparation[]; -#define GET_COURSE_AIMaximumSeparation gKartAICourseMaximumSeparation[gCurrentCourseId] +extern f32 cpu_CourseMaximumSeparation[]; +#define GET_COURSE_AIMaximumSeparation cpu_CourseMaximumSeparation[gCurrentCourseId] extern struct _struct_gCoursePathSizes_0x10 gCoursePathSizes[]; #define GET_COURSE_PathSizes gCoursePathSizes[gCurrentCourseId] -extern s16 gKartAISteeringSensitivity[]; -#define GET_COURSE_AISteeringSensitivity gKartAISteeringSensitivity[gCurrentCourseId] -extern f32 gKartAICourseMinimumSeparation[]; -#define GET_COURSE_AIMinimumSeparation gKartAICourseMinimumSeparation[gCurrentCourseId] -extern TrackWaypoint* gCoursePathTable[][4]; +extern s16 cpu_SteeringSensitivity[]; +#define GET_COURSE_AISteeringSensitivity cpu_SteeringSensitivity[gCurrentCourseId] +extern f32 cpu_CourseMinimumSeparation[]; +#define GET_COURSE_AIMinimumSeparation cpu_CourseMinimumSeparation[gCurrentCourseId] +extern TrackPathPoint* gCoursePathTable[][4]; #define GET_COURSE_PathTable(p) segmented_to_virtual_dupe_2(gCoursePathTable[gCurrentCourseId][p]) -extern TrackWaypoint* gCoursePathTable2[][4]; +extern TrackPathPoint* gCoursePathTable2[][4]; #define GET_COURSE_PathTable2(p) segmented_to_virtual_dupe_2(gCoursePathTable2[gCurrentCourseId][p]) -extern KartAIBehaviour* gKartAIBehaviourLUT[]; -#define GET_COURSE_AIBehaviour segmented_to_virtual_dupe_2(gKartAIBehaviourLUT[i]) +extern CPUBehaviour* cpu_BehaviourLUT[]; +#define GET_COURSE_AIBehaviour segmented_to_virtual_dupe_2(cpu_BehaviourLUT[i]) extern char* gCourseNames[]; #define GET_COURSE_Name gCourseNames[gCurrentCourseId] extern char* gCourseNamesDup[]; @@ -108,9 +108,12 @@ extern f32 gCourseFarPersp; extern f32 gCourseNearPersp; #define gCourseNearPersp gCourseNearPersp #define GET_COURSE_D_0D0096B8(cc) *(f32*) segmented_to_virtual_dupe_2(&D_0D0096B8[gCurrentCourseId][cc]) -#define GET_COURSE_D_0D009808(cc) *(f32*) segmented_to_virtual_dupe_2(&D_0D009808[gCurrentCourseId][cc]) -#define GET_COURSE_D_0D009418(cc) *(f32*) segmented_to_virtual_dupe_2(&D_0D009418[gCurrentCourseId][cc]) -#define GET_COURSE_D_0D009568(cc) *(f32*) segmented_to_virtual_dupe_2(&D_0D009568[gCurrentCourseId][cc]) +#define GET_COURSE_cpu_OffTrackTargetSpeed(cc) \ + *(f32*) segmented_to_virtual_dupe_2(&cpu_OffTrackTargetSpeed[gCurrentCourseId][cc]) +#define GET_COURSE_cpu_CurveTargetSpeed(cc) \ + *(f32*) segmented_to_virtual_dupe_2(&cpu_CurveTargetSpeed[gCurrentCourseId][cc]) +#define GET_COURSE_cpu_NormalTargetSpeed(cc) \ + *(f32*) segmented_to_virtual_dupe_2(&cpu_NormalTargetSpeed[gCurrentCourseId][cc]) #else #define gCurrentCourseId #define GET_COURSE_800DCBB4(n) @@ -127,9 +130,9 @@ extern f32 gCourseNearPersp; #define gCourseFarPersp #define gCourseNearPersp #define GET_COURSE_D_0D0096B8(cc) -#define GET_COURSE_D_0D009808(cc) -#define GET_COURSE_D_0D009418(cc) -#define GET_COURSE_D_0D009568(cc) +#define GET_COURSE_cpu_OffTrackTargetSpeed(cc) +#define GET_COURSE_cpu_CurveTargetSpeed(cc) +#define GET_COURSE_cpu_NormalTargetSpeed(cc) #endif #endif // COURSE_H diff --git a/include/defines.h b/include/defines.h index ec8bb4f438..ab7ba46871 100644 --- a/include/defines.h +++ b/include/defines.h @@ -74,13 +74,13 @@ #define PLAYER_STAGING (1 << 9) // 0x0200 #define PLAYER_UNKNOWN (1 << 10) // 0x0400 // unused ? #define PLAYER_CINEMATIC_MODE (1 << 11) // 0x0800 // Also used to track eliminations in Battle mode. -#define PLAYER_KART_AI (1 << 12) // 0x1000 +#define PLAYER_CPU (1 << 12) // 0x1000 #define PLAYER_START_SEQUENCE (1 << 13) // 0x2000 #define PLAYER_HUMAN (1 << 14) // 0x4000 #define PLAYER_EXISTS (1 << 15) // 0x8000 // Compiles to -0x1000 in diff.py -#define PLAYER_HUMAN_AND_KART_AI PLAYER_EXISTS | PLAYER_HUMAN | PLAYER_KART_AI | PLAYER_START_SEQUENCE +#define PLAYER_HUMAN_AND_CPU PLAYER_EXISTS | PLAYER_HUMAN | PLAYER_CPU | PLAYER_START_SEQUENCE #define ZERO_PLAYERS_SELECTED 0 #define ONE_PLAYERS_SELECTED 1 @@ -273,13 +273,13 @@ enum ITEMS { /* 0x0F */ ITEM_SUPER_MUSHROOM }; -enum KART_AI_BEHAVIOURS { +enum CPU_BEHAVIOURS { BEHAVIOUR_NONE = 0, BEHAVIOUR_1, BEHAVIOUR_HOP, - BEHAVIOUR_3, - BEHAVIOUR_4, - BEHAVIOUR_5, + BEHAVIOUR_DRIVE_CENTER, + BEHAVIOUR_DRIVE_LEFT, + BEHAVIOUR_DRIVE_OUTER, BEHAVIOUR_NORMAL_SPEED, BEHAVIOUR_FAST_SPEED, BEHAVIOUR_SLOW_SPEED, @@ -290,6 +290,8 @@ enum KART_AI_BEHAVIOURS { enum DIRECTION { NORTH, EAST, SOUTH, WEST }; +enum PLACE { FIRST_PLACE, SECOND_PLACE, THIRD_PLACE, FOURTH_PLACE }; + /** * @brief Balloon status */ @@ -321,14 +323,27 @@ enum DIRECTION { NORTH, EAST, SOUTH, WEST }; * @brief effect of player's * for effects */ -#define BOOST_RAMP_WOOD_EFFECT 0x4 // being boosted by a ramp -#define STAR_EFFECT 0x200 // being a star -#define BOOST_EFFECT 0x2000 // being boosted by trigger a mushroom -#define BOOST_RAMP_ASPHALT_EFFECT 0x100000 // being boosted by a boost pad -#define HIT_BY_ITEM_EFFECT 0x2000000 // being hit by an item -#define HIT_EFFECT 0x4000000 // hitting an object -#define LIGHTNING_EFFECT 0x40000000 // being hit by lightning -#define BOO_EFFECT 0x80000000 // being a boo +#define UNKNOWN_EFFECT_0x1 0x1 // +#define BOOST_RAMP_WOOD_EFFECT 0x4 // being boosted by a ramp +#define UNKNOWN_EFFECT_0x10 0x10 // +#define UNKNOWN_EFFECT_0x40 0x40 // +#define UNKNOWN_EFFECT_0x80 0x80 // +#define UNKNOWN_EFFECT_0xC 0xC // +#define UNKNOWN_EFFECT_0x10 0x10 // +#define UNKNOWN_EFFECT_0x100 0x100 // +#define UNKNOWN_EFFECT_0x1000 0x1000 // +#define STAR_EFFECT 0x200 // being a star +#define BOOST_EFFECT 0x2000 // being boosted by trigger a mushroom +#define UNKNOWN_EFFECT_0x10000 0x10000 // +#define BOOST_RAMP_ASPHALT_EFFECT 0x100000 // being boosted by a boost pad +#define UNKNOWN_EFFECT_0x200000 0x200000 // +#define REVERSE_EFFECT 0x400000 // being in reverse of the course +#define UNKNOWN_EFFECT_0x1000000 0x1000000 // +#define HIT_BY_ITEM_EFFECT 0x2000000 // being hit by an item +#define HIT_EFFECT 0x4000000 // hitting an object +#define UNKNOWN_EFFECT_0x10000000 0x10000000 // +#define LIGHTNING_EFFECT 0x40000000 // being hit by lightning +#define BOO_EFFECT 0x80000000 // being a boo /** * @brief shell state diff --git a/include/path.h b/include/path.h new file mode 100644 index 0000000000..b76473bd5b --- /dev/null +++ b/include/path.h @@ -0,0 +1,98 @@ +#ifndef PATH_H +#define PATH_H + +#include + +typedef struct { + /* 0x00 */ s16 posX; + /* 0x02 */ s16 posY; + /* 0x04 */ s16 posZ; + /* 0x06 */ u16 trackSectionId; +} TrackPathPoint; // size = 0x08 + +enum { + RIGHT_LEANING_CURVE = 0, + LEFT_LEANING_CURVE = 1, + RIGHT_CURVE = 2, // strong curve + LEFT_CURVE = 3, // strong curve + STRAIGHT = 4 +}; + +/** + * These are per-path arrays that contain some information relating to path + * The arrays in gTrackPaths contain X/Y/Z and track segment information + * The arrays in gTrackLeftPaths and gCurrentTrackRightPath track some other X/Y/Z, but the track segment is always 0 + *(so, untracked/unused) Its unclear how these arrays relate to each other + **/ +extern TrackPathPoint* gTrackPaths[]; +extern TrackPathPoint* gTrackLeftPaths[]; +extern TrackPathPoint* gTrackRightPaths[]; + +/** + * Don't know what exactly these are, but like gTrackPaths, gTrackLeftPaths, and gCurrentTrackRightPath + * they track something about the path on a per-path basis + **/ +// PathPoint types? +extern s16* gTrackSectionTypes[]; +// Based on analyse_angle_path this may be angles between path +// gPathExpectedRotation[i] = atan2(pathPoint_i, pathPoint_i+1)? +extern s16* gPathExpectedRotation[]; +// No idea. Adjacency list? +extern s16* gTrackConsecutiveCurveCounts[]; + +/** + * Certain parts of the pathPoint logic will copy some path/player specific data to a temporary variable. + * For example: gCurrentTrackPath is always a value from gTrackPaths. Depending on which path + * a given player is on, the specific value may change + **/ +// Shadows values from gNearestPathPointByPlayerId +extern s16 sSomeNearestPathPoint; +// Shadows values from gPathIndexByPlayerId +extern s32 gPlayerPathIndex; +// Shadows values from gTrackLeftPaths +extern TrackPathPoint* gCurrentTrackLeftPath; +// Shadows values from gCurrentTrackRightPath +extern TrackPathPoint* gCurrentTrackRightPath; +// Shadows values from gTrackSectionTypes +extern s16* gCurrentTrackSectionTypesPath; +// Shadows values from gPathExpectedRotation +extern s16* gCurrentPathPointExpectedRotationPath; +// Shadowd values from gPathCountByPathIndex +extern u16 gSelectedPathCount; +// Shadows values from gTrackPaths +extern TrackPathPoint* gCurrentTrackPath; +// Shadows values from gTrackConsecutiveCurveCounts +extern s16* gCurrentTrackConsecutiveCurveCountsPath; + +extern u16 gNearestPathPointByPlayerId[]; // D_80164438 +// Total path passed by playerId? +extern s32 gNumPathPointsTraversed[]; +extern u16 gPathIndexByPlayerId[]; // D_801645B0 +extern u16 gPathCountByPathIndex[]; // D_801645C8 +// These values are only used when the camera is in "cinematic" mode +extern s16 gNearestPathPointByCameraId[]; // D_80164668 + +/** + * Stuff that may not be directly related to path, but are only referenced in cpu_vehicles_camera_path. + * So they are at least pathPoint adjacent. + **/ + +// Tracks something on a per-player basis, no idea what though +extern f32 gTrackPositionFactor[]; +// Track segment by playerId, although it curiously does NOT track values for human players +// So, in 2 Player Grand Prix, the first 2 entries are always 0 +extern u16 gPlayersTrackSectionId[]; +// Seems to be a per-path overcount of the pathPoint count +extern s32 D_80163368[]; +// Seemingly the Z position of the 1st pathPoint in the 0th path? +extern f32 gPathStartZ; +// These seem to track whether a player has entered or exited the "unknown" zone in yoshi's valley +// See yoshi_valley_cpu_path and update_cpu_path_completion +// Is 1 when a player is in the "unknown" zone in yoshi's valley +extern s16 cpu_enteringPathIntersection[]; +// Is 1 when a player leaves the "unknown" zone in yoshi's valley +extern s16 cpu_exitingPathIntersection[]; +// Tracks whether a given player is in the "unknown" zone of yoshi's valley +extern s16 bInMultiPathSection[]; + +#endif diff --git a/include/vehicles.h b/include/vehicles.h index b24717fe4d..5590390bcb 100644 --- a/include/vehicles.h +++ b/include/vehicles.h @@ -40,7 +40,7 @@ typedef struct { /* 0x02 */ s16 compilerPadding; /* 0x04 */ Vec3f position; /* 0x10 */ Vec3f velocity; - /* 0x1C */ u16 waypointIndex; + /* 0x1C */ u16 pathPointIndex; /* 0x1E */ s16 actorIndex; /* 0x20 */ s32 unused; // Not read or written. Could be padding? } TrainCarStuff; // size = 0x24; @@ -56,19 +56,19 @@ typedef struct { } TrainStuff; // size = 0x10C typedef struct { - /* 0x00 */ s16 isActive; // The paddle wheel boat only shows up if the number of players is < 3 - /* 0x02 */ // s16 compilerPadding; - /* 0x04 */ Vec3f position; // - /* 0x10 */ Vec3f velocity; // - /* 0x1C */ u16 waypointIndex; // - /* 0x1E */ s16 actorIndex; // - /* 0x20 */ f32 speed; // - /* 0x24 */ s16 rotY; // Only Y rotation is tracked in this struct - /* 0x26 */ // s16 compilerPadding2; - /** - * Bit field that tracks whether a given human player is within a certain distance of the boat - * Probably audio related - **/ + /* 0x00 */ s16 isActive; // The paddle wheel boat only shows up if the number of players is < 3 + /* 0x02 */ // s16 compilerPadding; + /* 0x04 */ Vec3f position; // + /* 0x10 */ Vec3f velocity; // + /* 0x1C */ u16 pathPointIndex; // + /* 0x1E */ s16 actorIndex; // + /* 0x20 */ f32 speed; // + /* 0x24 */ s16 rotY; // Only Y rotation is tracked in this struct + /* 0x26 */ // s16 compilerPadding2; + /** + * Bit field that tracks whether a given human player is within a certain distance of the boat + * Probably audio related + **/ /* 0x28 */ s32 someFlags; } PaddleBoatStuff; // size = 0x2C @@ -77,7 +77,7 @@ typedef struct { /* 0x02 */ // s16 compilerPadding; /* 0x04 */ Vec3f position; /* 0x10 */ Vec3f velocity; - /* 0x1C */ u16 waypointIndex; + /* 0x1C */ u16 pathPointIndex; /* 0x1E */ s16 actorIndex; /* 0x20 */ f32 speed; // /* 0x24 */ f32 someMultiplierTheSequel; // diff --git a/include/waypoints.h b/include/waypoints.h deleted file mode 100644 index 2583e8a110..0000000000 --- a/include/waypoints.h +++ /dev/null @@ -1,90 +0,0 @@ -#ifndef WAYPOINTS_H -#define WAYPOINTS_H - -#include - -typedef struct { - /* 0x00 */ s16 posX; - /* 0x02 */ s16 posY; - /* 0x04 */ s16 posZ; - /* 0x06 */ u16 trackSectionId; -} TrackWaypoint; // size = 0x08 - -/** - * These are per-path arrays that contain some information relating to waypoints - * The arrays in D_80164550 contain X/Y/Z and track segment information - * The arrays in D_80164560 and D_80164570 track some other X/Y/Z, but the track segment is always 0 (so, - *untracked/unused) Its unclear how these arrays relate to each other - **/ -extern TrackWaypoint* D_80164550[]; -extern TrackWaypoint* D_80164560[]; -extern TrackWaypoint* D_80164570[]; - -/** - * Don't know what exactly these are, but like D_80164550, D_80164560, and D_80164570 - * they track something about the waypoints on a per-path basis - **/ -// Waypoint types? -extern s16* D_80164580[]; -// Based on func_80010DBC this may be angles between waypoints -// D_80164590[i] = atan2(waypoint_i, waypoint_i+1)? -extern s16* D_80164590[]; -// No idea. Adjacency list? -extern s16* D_801645A0[]; - -/** - * Certain parts of the waypoint logic will copy some path/player specific data to a temporary variable. - * For example: D_80164490 is always a value from D_80164550. Depending on which path - * a given player is on, the specific value may change - **/ -// Shadows values from gNearestWaypointByPlayerId -extern s16 sSomeNearestWaypoint; -// Shadows values from gPathIndexByPlayerId -extern s32 D_80163448; -// Shadows values from D_80164560 -extern TrackWaypoint* D_801631D0; -// Shadows values from D_80164570 -extern TrackWaypoint* D_801631D4; -// Shadows values from D_80164580 -extern s16* D_801631D8; -// Shadows values from D_80164590 -extern s16* D_801631DC; -// Shadowd values from gWaypointCountByPathIndex -extern u16 D_80164430; -// Shadows values from D_80164550 -extern TrackWaypoint* D_80164490; -// Shadows values from D_801645A0 -extern s16* D_801645E0; - -extern u16 gNearestWaypointByPlayerId[]; // D_80164438 -// Total waypoints passed by playerId? -extern s32 D_80164450[]; -extern u16 gPathIndexByPlayerId[]; // D_801645B0 -extern u16 gWaypointCountByPathIndex[]; // D_801645C8 -// These values are only used when the camera is in "cinematic" mode -extern s16 gNearestWaypointByCameraId[]; // D_80164668 - -/** - * Stuff that may not be directly related to waypoints, but are only referenced in code_80005FD0. - * So they are at least waypoint adjacent. - **/ - -// Tracks something on a per-player basis, no idea what though -extern f32 D_80163068[]; -// Track segment by playerId, although it curiously does NOT track values for human players -// So, in 2 Player Grand Prix, the first 2 entries are always 0 -extern u16 D_80163318[]; -// Seems to be a per-path overcount of the waypoint count -extern s32 D_80163368[]; -// Seemingly the Z position of the 1st waypoint in the 0th path? -extern f32 D_8016344C; -// These seem to track whether a player has entered or exited the "unknown" zone in yoshi's valley -// See func_80009000 and func_800090F0 -// Is 1 when a player is in the "unknown" zone in yoshi's valley -extern s16 D_80163490[]; -// Is 1 when a player leaves the "unknown" zone in yoshi's valley -extern s16 D_801634A8[]; -// Tracks whether a given player is in the "unknown" zone of yoshi's valley -extern s16 D_801644F8[]; - -#endif diff --git a/mk64.ld b/mk64.ld index 6d8d61eddc..be43fbfcd3 100644 --- a/mk64.ld +++ b/mk64.ld @@ -52,7 +52,7 @@ SECTIONS BUILD_DIR/src/animation.o(.text*); BUILD_DIR/src/staff_ghosts.o(.text*); BUILD_DIR/asm/unused_overflow_check.o(.text); - BUILD_DIR/src/code_80005FD0.jp.o(.text*); + BUILD_DIR/src/cpu_vehicles_camera_path.jp.o(.text*); BUILD_DIR/src/camera.o(.text*); BUILD_DIR/src/render_player.o(.text*); BUILD_DIR/src/kart_dma.o(.text*); @@ -269,7 +269,7 @@ SECTIONS BUILD_DIR/src/main.o(.rodata*); BUILD_DIR/src/animation.o(.rodata*); BUILD_DIR/src/code_800029B0.o(.rodata*); - BUILD_DIR/src/code_80005FD0.jp.o(.rodata*); + BUILD_DIR/src/cpu_vehicles_camera_path.jp.o(.rodata*); BUILD_DIR/src/camera.o(.rodata*); BUILD_DIR/src/render_player.o(.rodata*); BUILD_DIR/src/player_controller.o(.rodata*); @@ -328,7 +328,7 @@ SECTIONS BUILD_DIR/src/crash_screen.o(.bss*); BUILD_DIR/src/animation.o(.bss*); BUILD_DIR/src/staff_ghosts.o(.bss*); - BUILD_DIR/src/code_80005FD0.jp.o(.bss*); + BUILD_DIR/src/cpu_vehicles_camera_path.jp.o(.bss*); BUILD_DIR/src/camera.o(.bss*); BUILD_DIR/src/render_player.o(.bss*); BUILD_DIR/src/spawn_players.o(.bss*); diff --git a/models/tracks/banshee_boardwalk.zip b/models/tracks/banshee_boardwalk.zip new file mode 100644 index 0000000000..abf3fed424 Binary files /dev/null and b/models/tracks/banshee_boardwalk.zip differ diff --git a/safe_gcc.mk b/safe_gcc.mk index a856659cf2..0f5bb135c2 100644 --- a/safe_gcc.mk +++ b/safe_gcc.mk @@ -11,7 +11,7 @@ SAFE_C_FILES := \ build/us/src/code_800029B0.o \ build/us/src/animation.o \ build/us/src/player_controller.o \ - build/us/src/code_80005FD0.o \ + build/us/src/cpu_vehicles_camera_path.o \ build/us/src/profiler.o \ build/us/src/render_player.o \ build/us/src/code_80086E70.o \ diff --git a/src/actors/banana/update.inc.c b/src/actors/banana/update.inc.c index eb808aed1a..d3bbc65639 100644 --- a/src/actors/banana/update.inc.c +++ b/src/actors/banana/update.inc.c @@ -58,7 +58,7 @@ void update_actor_banana(struct BananaActor* banana) { } if ((controller->buttonDepressed & Z_TRIG) != 0) { controller->buttonDepressed &= ~Z_TRIG; - banana->state = 1; + banana->state = DROPPED_BANANA; banana->unk_04 = 0x00B4; player->soundEffects &= ~HOLD_BANANA_SOUND_EFFECT; func_800C9060(player - gPlayerOne, SOUND_ARG_LOAD(0x19, 0x00, 0x80, 0x12)); @@ -66,10 +66,10 @@ void update_actor_banana(struct BananaActor* banana) { if ((pad3 > 30.0f) && (controller->rawStickX < 10) && (controller->rawStickX >= -9)) { pad3 = pad3 - ((f32) 30); pad3 = (pad3 / 20.0f) + 0.5f; - if (player->unk_094 < 2.0f) { + if (player->speed < 2.0f) { temp_f0 = 4.0f; } else { - temp_f0 = (player->unk_094 * 0.75f) + 3.5f + pad3; + temp_f0 = (player->speed * 0.75f) + 3.5f + pad3; } vec3f_set(someVelocity, 0, pad3, temp_f0); func_802B64C4(someVelocity, player->rotation[1] + player->unk_0C0); diff --git a/src/actors/blue_and_red_shells/update.inc.c b/src/actors/blue_and_red_shells/update.inc.c index a6eb2f2698..c479ef3bd3 100644 --- a/src/actors/blue_and_red_shells/update.inc.c +++ b/src/actors/blue_and_red_shells/update.inc.c @@ -1,13 +1,13 @@ #include -#include +#include #include #include #include #include void func_802B3B44(struct ShellActor* shell) { - u16 currentWaypoint; - u16 nextWaypoint; + u16 currentPathPoint; + u16 nextPathPoint; f32 temp_f0; f32 temp_f0_2; f32 temp_f0_3; @@ -28,14 +28,14 @@ void func_802B3B44(struct ShellActor* shell) { f32 temp_f26; Vec3f origPos; - currentWaypoint = shell->pathIndex; - temp_f2 = D_80164490[currentWaypoint].posX; - temp_f12 = D_80164490[currentWaypoint].posY; - temp_f28 = D_80164490[currentWaypoint].posZ; - nextWaypoint = currentWaypoint + 1; + currentPathPoint = shell->pathIndex; + temp_f2 = gCurrentTrackPath[currentPathPoint].posX; + temp_f12 = gCurrentTrackPath[currentPathPoint].posY; + temp_f28 = gCurrentTrackPath[currentPathPoint].posZ; + nextPathPoint = currentPathPoint + 1; - if (nextWaypoint >= D_80164430) { - nextWaypoint -= D_80164430; + if (nextPathPoint >= gSelectedPathCount) { + nextPathPoint -= gSelectedPathCount; } temp_f20 = temp_f2 - shell->pos[0]; @@ -43,9 +43,9 @@ void func_802B3B44(struct ShellActor* shell) { temp_f24 = temp_f28 - shell->pos[2]; temp_f0 = (temp_f20 * temp_f20) + (temp_f22 * temp_f22) + (temp_f24 * temp_f24); if (temp_f0 > 400.0f) { - temp_f18_3 = D_80164490[nextWaypoint].posX; - temp_f16_3 = D_80164490[nextWaypoint].posY; - temp_f26 = D_80164490[nextWaypoint].posZ; + temp_f18_3 = gCurrentTrackPath[nextPathPoint].posX; + temp_f16_3 = gCurrentTrackPath[nextPathPoint].posY; + temp_f26 = gCurrentTrackPath[nextPathPoint].posZ; temp_f12_0 = temp_f18_3 - shell->pos[0]; temp_f12_1 = temp_f16_3 - shell->pos[1]; @@ -53,7 +53,7 @@ void func_802B3B44(struct ShellActor* shell) { temp_f0_3 = (temp_f12_0 * temp_f12_0) + (temp_f12_1 * temp_f12_1) + (temp_f12_2 * temp_f12_2); if (temp_f0_3 < temp_f0) { - shell->pathIndex = nextWaypoint; + shell->pathIndex = nextPathPoint; } else { temp_f0_2 = sqrtf(temp_f0) * 4.0f; temp_f20 /= temp_f0_2; @@ -94,11 +94,11 @@ void func_802B3B44(struct ShellActor* shell) { shell->pos[0] = temp_f2; shell->pos[1] = shell->boundingBoxSize + temp_f12; shell->pos[2] = temp_f28; - shell->pathIndex = nextWaypoint; + shell->pathIndex = nextPathPoint; } else { - temp_f18_3 = D_80164490[nextWaypoint].posX; - temp_f16_3 = D_80164490[nextWaypoint].posY; - temp_f26 = D_80164490[nextWaypoint].posZ; + temp_f18_3 = gCurrentTrackPath[nextPathPoint].posX; + temp_f16_3 = gCurrentTrackPath[nextPathPoint].posY; + temp_f26 = gCurrentTrackPath[nextPathPoint].posZ; shell->pos[0] = (temp_f2 + temp_f18_3) * 0.5f; shell->pos[1] = ((temp_f12 + temp_f16_3) * 0.5f) + shell->boundingBoxSize; @@ -317,8 +317,8 @@ void update_actor_red_blue_shell(struct ShellActor* shell) { if (shell->state == MOVING_SHELL) { shell->someTimer = 0x001E; height = 8.0f; - if (player->unk_094 > 8.0f) { - height = player->unk_094 * 1.2f; + if (player->speed > 8.0f) { + height = player->speed * 1.2f; } somePosVel[0] = 0.0f; somePosVel[1] = 0.0f; @@ -346,9 +346,9 @@ void update_actor_red_blue_shell(struct ShellActor* shell) { shell->targetPlayer = gPlayerPositionLUT[0]; shell->state = BLUE_SHELL_LOCK_ON; shell->shellId = 1000.0f; - temp_v0 = gNearestWaypointByPlayerId[player - gPlayerOne] + 8; - if ((s32) D_80164430 < temp_v0) { - temp_v0 -= D_80164430; + temp_v0 = gNearestPathPointByPlayerId[player - gPlayerOne] + 8; + if ((s32) gSelectedPathCount < temp_v0) { + temp_v0 -= gSelectedPathCount; } shell->pathIndex = temp_v0; } else if (gModeSelection == BATTLE) { @@ -367,17 +367,17 @@ void update_actor_red_blue_shell(struct ShellActor* shell) { if (player->currentRank == 0) { shell->state = TRIPLE_GREEN_SHELL; shell->someTimer = 0x0258; - temp_v0 = gNearestWaypointByPlayerId[player - gPlayerOne] + 8; - if ((s32) D_80164430 < temp_v0) { - temp_v0 -= D_80164430; + temp_v0 = gNearestPathPointByPlayerId[player - gPlayerOne] + 8; + if ((s32) gSelectedPathCount < temp_v0) { + temp_v0 -= gSelectedPathCount; } shell->pathIndex = temp_v0; } else if (player->currentRank >= 5) { shell->state = GREEN_SHELL_HIT_A_RACER; shell->shellId = 1000.0f; - temp_v0 = gNearestWaypointByPlayerId[player - gPlayerOne] + 8; - if ((s32) D_80164430 < temp_v0) { - temp_v0 -= D_80164430; + temp_v0 = gNearestPathPointByPlayerId[player - gPlayerOne] + 8; + if ((s32) gSelectedPathCount < temp_v0) { + temp_v0 -= gSelectedPathCount; } shell->pathIndex = temp_v0; shell->targetPlayer = gPlayerPositionLUT[player->currentRank - 1]; diff --git a/src/actors/green_shell/update.inc.c b/src/actors/green_shell/update.inc.c index 1578958446..8dd5e277d8 100644 --- a/src/actors/green_shell/update.inc.c +++ b/src/actors/green_shell/update.inc.c @@ -60,8 +60,8 @@ void update_actor_green_shell(struct ShellActor* shell) { controller->buttonDepressed &= ~Z_TRIG; if (controller->rawStickY < -0x2D) { var_f2 = 8.0f; - if (player->unk_094 > 8.0f) { - var_f2 = player->unk_094 * 1.2f; + if (player->speed > 8.0f) { + var_f2 = player->speed * 1.2f; } somePosVel[0] = 0.0f; somePosVel[1] = 0.0f; @@ -112,8 +112,8 @@ void update_actor_green_shell(struct ShellActor* shell) { } if (shell->state == 2) { var_f2 = 8.0f; - if (player->unk_094 > 8.0f) { - var_f2 = player->unk_094 * 1.2f; + if (player->speed > 8.0f) { + var_f2 = player->speed * 1.2f; } somePosVel[0] = 0.0f; somePosVel[1] = 0.0f; diff --git a/src/actors/kiwano_fruit/update.inc.c b/src/actors/kiwano_fruit/update.inc.c index a4e6b029da..2917a9908f 100644 --- a/src/actors/kiwano_fruit/update.inc.c +++ b/src/actors/kiwano_fruit/update.inc.c @@ -1,7 +1,7 @@ #include #include #include -#include +#include /** * @brief Updates the kiwano fruit actor. @@ -15,10 +15,10 @@ void update_actor_kiwano_fruit(struct KiwanoFruit* fruit) { f32 temp_f16; f32 temp_f14; f32 temp_f12; - s32 nearestWaypoint; + s32 nearestPathPoint; player = &gPlayers[fruit->targetPlayer]; - if (((player->type & PLAYER_KART_AI) != 0) || (player->collision.unk34 == 0)) { + if (((player->type & PLAYER_CPU) != 0) || (player->collision.unk34 == 0)) { fruit->state = 0; return; } @@ -30,10 +30,10 @@ void update_actor_kiwano_fruit(struct KiwanoFruit* fruit) { fruit->state = 1; fruit->velocity[0] = 80.0f; case 1: - nearestWaypoint = gNearestWaypointByPlayerId[(u16) (player - gPlayerOne)]; - temp_f2 = player->pos[0] - D_80164490[nearestWaypoint].posX; - temp_f16 = player->pos[1] - D_80164490[nearestWaypoint].posY; - temp_f14 = player->pos[2] - D_80164490[nearestWaypoint].posZ; + nearestPathPoint = gNearestPathPointByPlayerId[(u16) (player - gPlayerOne)]; + temp_f2 = player->pos[0] - gCurrentTrackPath[nearestPathPoint].posX; + temp_f16 = player->pos[1] - gCurrentTrackPath[nearestPathPoint].posY; + temp_f14 = player->pos[2] - gCurrentTrackPath[nearestPathPoint].posZ; temp_f12 = fruit->velocity[0] / sqrtf((temp_f2 * temp_f2) + (temp_f16 * temp_f16) + (temp_f14 * temp_f14)); temp_f2 *= temp_f12; temp_f16 *= temp_f12; diff --git a/src/audio/external.c b/src/audio/external.c index 64e63705a3..f65c2d2b97 100644 --- a/src/audio/external.c +++ b/src/audio/external.c @@ -12,7 +12,7 @@ #include "audio/data.h" #include "audio/port_eu.h" #include "code_800029B0.h" -#include "code_80005FD0.h" +#include "cpu_vehicles_camera_path.h" #include "menu_items.h" s8 D_8018EF10; @@ -1868,7 +1868,7 @@ void func_800C6108(u8 playerId) { D_800E9E64[playerId] = (player->unk_098 / D_800E9F7C[playerId].unk_34) + D_800E9F7C[playerId].unk_28; if (D_800E9EC4) {} // ? } - if (player->unk_094 > 4.75f) { + if (player->speed > 4.75f) { if (D_800E9EB4[playerId] < (D_800E9F7C[playerId].unk_18 + 0.4f)) { D_800E9DE4[playerId] += 0.005f; } @@ -1880,7 +1880,7 @@ void func_800C6108(u8 playerId) { } else { D_800E9E54[playerId] = (f32) -player->unk_0C0; } - if ((player->effects & 0x10) == 0x10) { + if ((player->effects & UNKNOWN_EFFECT_0x10) == UNKNOWN_EFFECT_0x10) { D_800E9EB4[playerId] = D_800E9E64[playerId] + D_800E9DE4[playerId]; } else { D_800E9EB4[playerId] = D_800E9E64[playerId] + D_800E9DE4[playerId] - (D_800E9E54[playerId] / 12000.0f); @@ -1927,7 +1927,7 @@ D_800E9F7C[playerId].unk_38 = (D_800E9F7C[playerId].unk_0C / 1.5f) + 0.4f; void func_800C64A0(u8 playerId) { switch (D_800E9E74[playerId]) { case 3: - D_800E9EF4[playerId] = (gPlayers[playerId].unk_094 / 5.0f) + 0.2f; + D_800E9EF4[playerId] = (gPlayers[playerId].speed / 5.0f) + 0.2f; break; case 1: case 13: @@ -1950,7 +1950,7 @@ void func_800C64A0(u8 playerId) { case 29: case 30: case 31: - D_800E9EF4[playerId] = (gPlayers[playerId].unk_094 / 5.0f) + 0.2f; + D_800E9EF4[playerId] = (gPlayers[playerId].speed / 5.0f) + 0.2f; break; default: D_800E9EF4[playerId] = 1.0f; @@ -1978,7 +1978,7 @@ void func_800C64A0(u8 playerId) { void func_800C6758(u8 playerId) { switch (D_800E9E74[playerId]) { /* irregular */ case 3: - D_800E9F14[playerId] = (gPlayers[playerId].unk_094 / 9.0f) + 0.6f; + D_800E9F14[playerId] = (gPlayers[playerId].speed / 9.0f) + 0.6f; break; case 2: case 13: @@ -2150,7 +2150,8 @@ void func_800C683C(u8 cameraId) { void func_800C70A8(u8 playerId) { if (D_800EA0EC[playerId] == 0) { D_800E9E74[playerId] = 0; - if ((D_800E9E54[playerId] > 3500.0f) || ((gPlayers[playerId].effects & 0x10) == 0x10)) { + if ((D_800E9E54[playerId] > 3500.0f) || + ((gPlayers[playerId].effects & UNKNOWN_EFFECT_0x10) == UNKNOWN_EFFECT_0x10)) { D_800E9E74[playerId] = 1; switch (gPlayers[playerId].tyres[AUDIO_LEFT_TYRE].surfaceType) { case DIRT: /* switch 1 */ @@ -2182,7 +2183,7 @@ void func_800C70A8(u8 playerId) { break; } } - if ((gPlayers[playerId].effects & 0x10) == 0x10) { + if ((gPlayers[playerId].effects & UNKNOWN_EFFECT_0x10) == UNKNOWN_EFFECT_0x10) { D_800E9E74[playerId] = 2; switch (gPlayers[playerId].tyres[AUDIO_LEFT_TYRE].surfaceType) { /* switch 2 */ case DIRT: /* switch 2 */ @@ -2334,7 +2335,7 @@ void func_800C70A8(u8 playerId) { D_800E9E74[playerId] = 0x0000001B; break; } - if (((gPlayers[playerId].unk_094 < 0.5f) || ((gPlayers[playerId].effects & 8) == 8)) && + if (((gPlayers[playerId].speed < 0.5f) || ((gPlayers[playerId].effects & 8) == 8)) && (D_800E9E74[playerId] != 0x0000001C)) { D_800E9E74[playerId] = 0; } diff --git a/src/camera.c b/src/camera.c index 8cc8b8e45d..4fb9bf656d 100644 --- a/src/camera.c +++ b/src/camera.c @@ -9,11 +9,11 @@ #include "code_800029B0.h" #include "math_util.h" #include "racing/memory.h" -#include "waypoints.h" +#include "path.h" #include "render_player.h" #include "collision.h" #include "code_80057C60.h" -#include "code_80005FD0.h" +#include "cpu_vehicles_camera_path.h" #include "main.h" #include "spawn_players.h" @@ -221,9 +221,9 @@ void func_8001CA78(UNUSED Player* player, Camera* camera, Vec3f arg2, f32* arg3, f32 temp_f18; f32 temp_f16; UNUSED s32 pad; - TrackWaypoint* temp_s2; + TrackPathPoint* temp_s2; - temp_s2 = &D_80164550[0][gWaypointCountByPathIndex[0] - 10]; + temp_s2 = &gTrackPaths[0][gPathCountByPathIndex[0] - 10]; sp68[0] = camera->unk_30[0]; sp68[1] = camera->unk_30[1]; sp68[2] = camera->unk_30[2]; @@ -362,7 +362,7 @@ void func_8001CCEC(Player* player, Camera* camera, Vec3f arg2, f32* arg3, f32* a arg2[0] = camera->lookAt[0]; arg2[1] = camera->lookAt[1]; arg2[2] = camera->lookAt[2]; - if ((player->effects & 0x01000000) == 0x01000000) { + if ((player->effects & UNKNOWN_EFFECT_0x1000000) == UNKNOWN_EFFECT_0x1000000) { sp84[2] /= 3.0f; } calculate_orientation_matrix(sp9C, 0, 1, 0, arg7); @@ -375,7 +375,7 @@ void func_8001CCEC(Player* player, Camera* camera, Vec3f arg2, f32* arg3, f32* a arg2[0] += (x - camera->lookAt[0]) * D_80164A78[index]; arg2[2] += ((z - camera->lookAt[2]) * D_80164A78[index]); - if ((((player->unk_094 / 18) * 216) <= 5.0f) && ((player->effects & 2) == 2)) { + if ((((player->speed / 18) * 216) <= 5.0f) && ((player->effects & 2) == 2)) { arg2[1] += ((y - camera->lookAt[1]) * 0.02); } else { arg2[1] += ((y - camera->lookAt[1]) * 0.5); @@ -383,7 +383,7 @@ void func_8001CCEC(Player* player, Camera* camera, Vec3f arg2, f32* arg3, f32* a mtxf_translate_vec3f_mat3(sp90, sp9C); x = player->pos[0] + sp90[0]; z = player->pos[2] + sp90[2]; - if ((player->effects & 0x01000000) != 0x01000000) { + if ((player->effects & UNKNOWN_EFFECT_0x1000000) != UNKNOWN_EFFECT_0x1000000) { var_f0 = player->pos[1] + sp90[1]; // permute y = var_f0; @@ -394,7 +394,7 @@ void func_8001CCEC(Player* player, Camera* camera, Vec3f arg2, f32* arg3, f32* a *arg3 = camera->pos[0] + ((x - camera->pos[0]) * D_80164A78[index]); *arg5 = camera->pos[2] + ((z - camera->pos[2]) * D_80164A78[index]); - if ((((player->unk_094 / 18) * 216) <= 5.0f) && ((player->effects & 2) == 2)) { + if ((((player->speed / 18) * 216) <= 5.0f) && ((player->effects & 2) == 2)) { *arg4 = camera->pos[1] + (((y - camera->pos[1]) * 0.01)); } else { *arg4 = camera->pos[1] + (((y - camera->pos[1]) * 0.15)); @@ -582,7 +582,7 @@ void func_8001D944(Player* player, Camera* camera, Vec3f arg2, f32* arg3, f32* a arg2[0] = camera->lookAt[0]; arg2[1] = camera->lookAt[1]; arg2[2] = camera->lookAt[2]; - if ((player->effects & 0x01000000) == 0x01000000) { + if ((player->effects & UNKNOWN_EFFECT_0x1000000) == UNKNOWN_EFFECT_0x1000000) { sp84[2] /= 3.0f; } calculate_orientation_matrix(sp9C, 0, 1, 0, arg7); @@ -595,7 +595,7 @@ void func_8001D944(Player* player, Camera* camera, Vec3f arg2, f32* arg3, f32* a arg2[0] += (x - camera->lookAt[0]) * D_80164A78[index]; arg2[2] += ((z - camera->lookAt[2]) * D_80164A78[index]); - if ((((player->unk_094 / 18) * 216) <= 5.0f) && ((player->effects & 2) == 2)) { + if ((((player->speed / 18) * 216) <= 5.0f) && ((player->effects & 2) == 2)) { arg2[1] += ((y - camera->lookAt[1]) * 0.02); } else { arg2[1] += ((y - camera->lookAt[1]) * 0.5); @@ -603,7 +603,7 @@ void func_8001D944(Player* player, Camera* camera, Vec3f arg2, f32* arg3, f32* a mtxf_translate_vec3f_mat3(sp90, sp9C); x = player->pos[0] + sp90[0]; z = player->pos[2] + sp90[2]; - if ((player->effects & 0x01000000) != 0x01000000) { + if ((player->effects & UNKNOWN_EFFECT_0x1000000) != UNKNOWN_EFFECT_0x1000000) { var_f0 = player->pos[1] + sp90[1]; // permute y = var_f0; @@ -614,7 +614,7 @@ void func_8001D944(Player* player, Camera* camera, Vec3f arg2, f32* arg3, f32* a *arg3 = camera->pos[0] + ((x - camera->pos[0]) * D_80164A78[index]); *arg5 = camera->pos[2] + ((z - camera->pos[2]) * D_80164A78[index]); - if ((((player->unk_094 / 18) * 216) <= 5.0f) && ((player->effects & 2) == 2)) { + if ((((player->speed / 18) * 216) <= 5.0f) && ((player->effects & 2) == 2)) { *arg4 = camera->pos[1] + (((y - camera->pos[1]) * 0.01)); } else { *arg4 = camera->pos[1] + (((y - camera->pos[1]) * 0.15)); @@ -704,7 +704,7 @@ void func_8001E45C(Camera* camera, Player* player, s8 arg2) { UNUSED s16 pad6; s16 temp; - if ((player->effects & 0x10) == 0x10) { + if ((player->effects & UNKNOWN_EFFECT_0x10) == UNKNOWN_EFFECT_0x10) { var_a3 = 100; if (player->unk_078 == 0) { camera->unk_B0 = 0; @@ -826,7 +826,7 @@ void func_8001EA0C(Camera* camera, Player* player, s8 arg2) { UNUSED s16 pad6; s16 temp; - if ((player->effects & 0x10) == 0x10) { + if ((player->effects & UNKNOWN_EFFECT_0x10) == UNKNOWN_EFFECT_0x10) { var_a3 = 100; if (player->unk_078 == 0) { camera->unk_B0 = 0; diff --git a/src/code_800029B0.c b/src/code_800029B0.c index 027fdf76db..4b2e60b757 100644 --- a/src/code_800029B0.c +++ b/src/code_800029B0.c @@ -4,7 +4,7 @@ #include "code_800029B0.h" #include "memory.h" -#include "waypoints.h" +#include "path.h" #include "actors.h" #include "actor_types.h" #include "math_util.h" @@ -24,7 +24,7 @@ #include "menus.h" #include "data/other_textures.h" -extern s32 D_802BA038; +extern s32 gDemoTimer; extern s16 D_802BA048; #if !ENABLE_CUSTOM_COURSE_ENGINE s16 gCurrentCourseId = 0; @@ -208,7 +208,7 @@ void setup_race(void) { gNumSpawnedShells = 0; D_800DC5B8 = 0; D_80152308 = 0; - D_802BA038 = -1; + gDemoTimer = -1; D_802BA048 = 0; func_802A74BC(); set_perspective_and_aspect_ratio(); @@ -216,15 +216,14 @@ void setup_race(void) { init_actors_and_load_textures(); if (gModeSelection != BATTLE) { - D_8015F8D0[1] = (f32) (D_80164490->posY - 15); - ; - D_8015F8D0[2] = D_80164490->posZ; + D_8015F8D0[1] = (f32) (gCurrentTrackPath->posY - 15); + D_8015F8D0[2] = gCurrentTrackPath->posZ; if (gCurrentCourseId == COURSE_TOADS_TURNPIKE) { - D_8015F8D0[0] = (gIsMirrorMode != 0) ? D_80164490->posX + 138.0f : D_80164490->posX - 138.0f; + D_8015F8D0[0] = (gIsMirrorMode != 0) ? gCurrentTrackPath->posX + 138.0f : gCurrentTrackPath->posX - 138.0f; } else if (gCurrentCourseId == COURSE_WARIO_STADIUM) { - D_8015F8D0[0] = (gIsMirrorMode != 0) ? D_80164490->posX + 12.0f : D_80164490->posX - 12.0f; + D_8015F8D0[0] = (gIsMirrorMode != 0) ? gCurrentTrackPath->posX + 12.0f : gCurrentTrackPath->posX - 12.0f; } else { - D_8015F8D0[0] = D_80164490->posX; + D_8015F8D0[0] = gCurrentTrackPath->posX; } } if (!gDemoMode) { diff --git a/src/code_80005FD0.c b/src/code_80005FD0.c deleted file mode 100644 index dacae1a0dd..0000000000 --- a/src/code_80005FD0.c +++ /dev/null @@ -1,7750 +0,0 @@ -#include -#include -#include - -#include "code_80005FD0.h" -#include "math_util.h" -#include "code_800029B0.h" -#include "racing/memory.h" -#include "waypoints.h" -#include "camera.h" -#include "actors.h" -#include "actors_extended.h" -#include "render_player.h" -#include "player_controller.h" -#include "update_objects.h" -#include "collision.h" -#include -#include "vehicles.h" -#include "render_objects.h" -#include "code_80057C60.h" -#include "bomb_kart.h" -#include "courses/all_course_data.h" -#include -#include -#include "main.h" -#include "menus.h" -#include "menu_items.h" -#include "audio/external.h" -#include "ending/podium_ceremony_actors.h" -#include "spawn_players.h" -#include "sounds.h" -#include "data/path_spawn_metadata.h" - -s32 unk_code_80005FD0_pad[24]; -Collision D_80162E70; -s16 D_80162EB0; // Possibly a float. -s16 D_80162EB2; // possibly [3] - -KartAIBehaviour* gCoursesKartAIBehaviour[NUM_COURSES - 1]; - -// more padding? -s32 D_80162F08[2]; - -s16 D_80162F10[30]; -s16 D_80162F50[30]; - -// padding, seemingly? -s32 D_80162F90[4]; - -Vec3f D_80162FA0; -Vec3f D_80162FB0; -Vec3f D_80162FC0; -s16 gTrainSmokeTimer; -s16 sSomeNearestWaypoint; -s16 D_80162FD0; -f32 gCourseCompletionPercentByRank[NUM_PLAYERS]; -/* -The size of many of these arrays is weird. Based on their usage, they would only need -to be 8 entries long (enough for each player). But some are 10 or even 12 long. -Its plausible that this is just some decompilation artifact? -Or maybe at some point in development they had plans for more players? -*/ -s16 D_80162FF8[12]; -s16 D_80163010[12]; -f32 D_80163028[10]; -s16 D_80163050[12]; -f32 D_80163068[10]; -f32 D_80163090[10]; -s32 D_801630B8[10]; -u16 D_801630E0; -s16 D_801630E2; -s16 D_801630E8[10]; -s16 gFerrySmokeTimer; -s32 D_80163100[10]; -s32 D_80163128[10]; -s32 D_80163150[10]; -f32 D_80163178[10]; -f32 D_801631A0[10]; -s16 D_801631C8; -s32 D_801631CC; -TrackWaypoint* D_801631D0; -TrackWaypoint* D_801631D4; -s16* D_801631D8; -s16* D_801631DC; -u16 D_801631E0[12]; -u16 D_801631F8[10]; -f32 D_8016320C; -f32 D_80163210[10]; -s32 D_80163238; -u16 D_80163240[12]; -u16 D_80163258[12]; -u16 D_80163270[12]; -s32 D_80163288[10]; -KartAIBehaviour* sCurrentKartAIBehaviour; -u16 gCurrentKartAIBehaviourId[12]; -u16 gPreviousKartAIBehaviourId[12]; -u16 gKartAIBehaviourState[12]; -s16 D_80163300[12]; -u16 D_80163318[12]; -u16 D_80163330[10]; -u16 D_80163344[2]; -u16 D_80163348[2]; -u16 D_8016334C[2]; -u16 gSpeedKartAIBehaviour[12]; -s32 D_80163368[4]; -s32 D_80163378; -s32 D_8016337C; -s16 D_80163380[12]; -s16 D_80163398[12]; -s16 D_801633B0[12]; -s16 D_801633C8[12]; -s16 D_801633E0[12]; -s16 D_801633F8[12]; -s16 D_80163410[4]; -f32 D_80163418[4]; -f32 D_80163428[4]; -f32 D_80163438[4]; -s32 D_80163448; -f32 D_8016344C; -f32 D_80163450[10]; -s16 D_80163478; -s16 D_8016347A; -s16 D_8016347C; -s16 D_8016347E; -s32 D_80163480; -s32 D_80163484; -s32 D_80163488; -s16 D_8016348C; -s16 D_80163490[12]; -s16 D_801634A8[12]; -s16 D_801634C0[12]; -s16 bStopAICrossing[10]; -s16 D_801634EC; -s32 D_801634F0; -s32 D_801634F4; -Test D_801634F8[10]; -Path2D* gVehicle2DWaypoint; -s32 gVehicle2DWaypointLength; -TrainStuff gTrainList[NUM_TRAINS]; -u16 isCrossingTriggeredByIndex[NUM_CROSSINGS]; -u16 sCrossingActiveTimer[NUM_CROSSINGS]; -PaddleBoatStuff gPaddleBoats[NUM_PADDLE_BOATS]; -VehicleStuff gBoxTruckList[NUM_RACE_BOX_TRUCKS]; -VehicleStuff gSchoolBusList[NUM_RACE_SCHOOL_BUSES]; -VehicleStuff gTankerTruckList[NUM_RACE_TANKER_TRUCKS]; -VehicleStuff gCarList[NUM_RACE_CARS]; -s32 D_80163DD8[4]; -BombKart gBombKarts[NUM_BOMB_KARTS_MAX]; -Collision D_80164038[NUM_BOMB_KARTS_MAX]; -struct unexpiredActors gUnexpiredActorsList[8]; -D_801642D8_entry D_801642D8[8]; -s16 D_80164358; -s16 D_8016435A; -s16 D_8016435C; -s16 gGPCurrentRacePlayerIdByRank[12]; // D_80164360 -s16 D_80164378[12]; -s32 gLapCountByPlayerId[10]; // D_80164390 -s32 gGPCurrentRaceRankByPlayerId[10]; // D_801643B8 -s32 D_801643E0[10]; -s32 D_80164408[10]; -u16 D_80164430; -u16 gNearestWaypointByPlayerId[12]; -s32 D_80164450[10]; -s16 D_80164478[10]; -s32 D_8016448C; -TrackWaypoint* D_80164490; -f32 D_80164498[4]; -f32 gLapCompletionPercentByPlayerId[10]; // D_801644A8 -f32 gCourseCompletionPercentByPlayerId[10]; // D_801644D0 -s16 D_801644F8[12]; -f32 D_80164510[10]; -s16 D_80164538[12]; -TrackWaypoint* D_80164550[4]; -TrackWaypoint* D_80164560[4]; -TrackWaypoint* D_80164570[4]; -s16* D_80164580[4]; -s16* D_80164590[4]; -s16* D_801645A0[4]; -u16 gPathIndexByPlayerId[12]; // D_801645B0 -u16 gWaypointCountByPathIndex[4]; // D_801645C8 -s32 D_801645D0[4]; -s16* D_801645E0; -s32 D_801645E8[4]; -f32 D_801645F8[4]; -s32 D_80164608[4]; -f32 D_80164618[4]; -s32 D_80164628[4]; -f32 D_80164638[4]; -f32 D_80164648[4]; -f32 D_80164658[4]; -s16 gNearestWaypointByCameraId[4]; -s16 D_80164670[4]; -s16 D_80164678[4]; -s16 D_80164680[4]; -f32 D_80164688[4]; -f32 D_80164698; -f32 D_8016469C; -f32 D_801646A0; -// start padding -s32 D_801646A4; -s32 D_801646A8; -s32 D_801646AC; -s32 D_801646B0; -s32 D_801646B4; -s32 D_801646B8; -s32 D_801646BC; -// end padding -s16 D_801646C0[4]; -u32 D_801646C8; -u16 D_801646CC; -UnkStruct_46D0 D_801646D0[4]; - -// Strings, presented by google translate! -// Note that these are EUC-JP encoded, see: -// https://en.wikipedia.org/wiki/Extended_Unix_Code#EUC-JP - -// Force sort immediately after goal -char* D_800EB710 = "ゴール直後の強制ソート\n"; -// Forced sort immediately after one goal in 2PGP -char* D_800EB728 = "2PGPで片方がゴール直後の強制ソート\n"; -// rank calculation error -char* D_800EB74C = "順位計算エラー!! (num %d) (rank %d) (e_rank %d)\n"; -// Bypass switching error!!!(num %d org_bipas %d bipas %d) -char* D_800EB780 = "バイパス切り替え エラー!!!(num %d org_bipas %d bipas %d)\n"; -char* D_800EB7BC = "(%d) rap %3d rate_count_F %10.2f rap_count_F %10.2f area %5d \n"; -// Enter the maze! enemy %d (%d --> %d) -char* D_800EB800 = "迷路に突入! enemy %d (%d --> %d)\n"; -// Out of the maze! enemy %d (%d --> %d) -char* D_800EB824 = "迷路から出た! enemy %d (%d --> %d)\n"; -char* D_800EB84C = "enemy voice set (%d slip_flag %x weapon %x)\n"; -// Spin Voice! ! (%d , name %d) -char* D_800EB87C = "スピンヴォイス!!(%d , name %d)\n"; -// Damage voice! ! (%d, name %d) -char* D_800EB8A0 = "ダメージヴォイス!!(%d, name %d)\n"; -char* D_800EB8C4 = "===== ENEMY DRIVE SUB (%d) =====\n"; -// omission -char* D_800EB8E8 = "ENEMY END(手抜き)\n\n"; -char* D_800EB8FC = "ENEMY END(手抜き)\n\n"; -char* D_800EB910 = "(1)enemy stick angle over!! (%d)\n"; -char* D_800EB934 = "ENEMY END\n\n"; -char* D_800EB940 = "(2)enemy stick angle over!! (%d)\n"; -char* D_800EB964 = "ENEMY END\n\n"; -// AREA ERR!!! (group not registered at current centerline %d) %d -char* D_800EB970 = "AREA ERR!!! (現在のセンターライン %d に未登録のグループです) %d\n"; -// AREA ERR!!! (Unregistered group) %d -char* D_800EB9B4 = "AREA ERR!!! (未登録のグループです) %d\n"; -// get_oga_area_sub_BP() ... Area not found! (b_num = %d) -char* D_800EB9DC = "get_oga_area_sub_BP() ... エリアが見つからないッス! (b_num = %d)\n"; -// Status: (%d, %d, %d) -char* D_800EBA20 = " 状況: (%d, %d, %d) \n"; -char* D_800EBA38 = "<%d> (%d, %d, %d) [%d] lng %f\n"; -// Wario Stadium Jump failed! ! ! (area %d, y %7.2f) -char* D_800EBA58 = "ワリオスタジアム ジャンプ失敗!!! (area %d, y %7.2f)\n"; -// I fell in the water! ! Forced to centerline (num %d: area %d ) (%d,%d,%d) -char* D_800EBA94 = "水に落ちた!! センターラインに強制移動しました (num %d: area %d ) (%d,%d,%d)\n"; -// Course match! ! (Slacking: with bump) Forced move to center line (num %d: area %d ==>%d) (group %d) (%d,%d,%d) -char* D_800EBAE4 = "こーすあうと!!(手抜き中:バンプ有り) センターラインに強制移動しました (num %d: area %d ==>%d) " - "(group %d) (%d,%d,%d)\n"; -// Course match! ! (Sitting corners: no bump) Forced move to center line (num %d: area %d ==>%d) (group %d) (%d,%d,%d) -char* D_800EBB60 = "こーすあうと!!(手抜き中:バンプ無し) センターラインに強制移動しました (num %d: area %d ==>%d) " - "(group %d) (%d,%d,%d)\n"; -// Course match! ! ! Recalculated area (num %d: area %d ==>%d) -char* D_800EBBDC = "こーすあうと!!! エリアを再計算しました (num %d: area %d ==>%d)\n"; -// Direct BOM(%d) (%7.2f, %7.2f, %7.2f) -char* D_800EBC24 = "直接指定のBOM(%d) (%7.2f, %7.2f, %7.2f) \n"; -char* D_800EBC50 = "BOM HIT CHECK\n"; -char* D_800EBC60 = "BOM HIT !!!!! (%d)\n"; -// BOM standby -char* D_800EBC74 = "BOM待機\n"; -char* D_800EBC80 = "RESULT BOM area(%d)\n"; -// BOM dropped. -char* D_800EBC98 = "BOM が 落ちました。\n"; -// Tortoise fire pillar SET failed (TABLE IS FULL) -char* D_800EBCB0 = "カメ用火柱 SET 失敗 (TABLE IS FULL)\n"; -// Red turtle fire pillar set error! (category %d) -char* D_800EBCD8 = "赤ガメ火柱セットエラー! (category %d)\n"; -// Blue turtle fire pillar set error! (category %d) -char* D_800EBD00 = "青ガメ火柱セットエラー! (category %d)\n"; -// Thorn Turtle Fire Pillar Set Error! (category %d) -char* D_800EBD28 = "トゲガメ火柱セットエラー! (category %d)\n"; -// Turtle Fire Pillar Initialization! ! -char* D_800EBD54 = "カメ火柱初期化!!\n"; -// Center line initialization -char* D_800EBD68 = "センターライン初期化\n"; -char* D_800EBD80 = "MAP NUMBER %d\n"; -char* D_800EBD90 = "center_EX ptr = %x %x (%x)\n"; -char* D_800EBDB4 = "\n"; -char* D_800EBDB8 = "center_BP[%d] ptr = %x %x (%x)\n"; -char* D_800EBDE0 = "side_point_L_BP[%d] ptr = %x %x (%x)\n"; -char* D_800EBE08 = "side_point_R_BP[%d] ptr = %x %x (%x)\n"; -char* D_800EBE30 = "curve_BP[%d] ptr = %x %x (%x)\n"; -char* D_800EBE58 = "angle_BP[%d] ptr = %x %x (%x)\n"; -char* D_800EBE80 = "short_cut_data_BP[%d] ptr = %x %x (%x)\n"; -char* D_800EBEA8 = "\n"; -// Ogawa total memory used = %d -char* D_800EBEAC = "小川の使用メモリー合計 = %d\n"; -// Enemy initialization -char* D_800EBECC = "敵初期化\n"; -// End of enemy initialization -char* D_800EBED8 = "敵初期化終了\n"; -// Bypass CENTER LINE Split start -char* D_800EBEE8 = "バイパス CENTER LINE 分割開始\n"; -// Read centerline from ROM (map:%d) -char* D_800EBF08 = "センターラインをROMから読みます (map:%d)\n"; -char* D_800EBF34 = "ROM center (BP%d) line adr. = %x (%x)\n"; -// Calculate centerline (map:%d) -char* D_800EBF5C = "センターラインを計算します (map:%d)\n"; -char* D_800EBF84 = "center (BP%d) line adr. = %x (%x)\n"; -char* D_800EBFA8 = "BP center_point_number : %d\n"; -// Centerline data error! ! -char* D_800EBFC8 = "センターライン データ エラー!!\n"; -// Bypass CENTER LINE split end (%d -> %d number) -char* D_800EBFEC = "バイパス CENTER LINE 分割終了 (%d -> %d 個)\n"; -// No center line. (map: %d) -char* D_800EC01C = "センターラインが ありません。(map:%d)\n"; -// side point calculation (bypass %d) -char* D_800EC044 = "サイドポイント計算 (バイパス %d)\n"; -// Curve data calculation (bypass %d) -char* D_800EC068 = "カーブデータ計算 (バイパス %d)\n"; -// No center line. (map: %d) -char* D_800EC088 = "センターラインが ありません。(map:%d)\n"; -// Angle data calculation (bypass %d) -char* D_800EC0B0 = "アングルデータ計算 (バイパス %d) \n"; -// No center line. (map: %d) -char* D_800EC0D4 = "センターラインが ありません。(map:%d)\n"; -// Shortcut data calculation (bypass %d) -char* D_800EC0FC = "ショートカットデータ計算 (バイパス %d)\n"; -char* D_800EC124 = "extern POINT rom_center_KT%d_BP%d[] = {\n"; -char* D_800EC150 = "\t{%d,%d,%d,%d},\n"; -char* D_800EC164 = "\t0x8000,0x8000,0x8000,0\n};\n\n"; -char* D_800EC184 = "area read from ROM (%d)\n"; -// Normal jump! ! ! (%d) -char* D_800EC1A0 = "ノーマルジャンプ!!!(%d)\n"; -// Turbo on! ! ! (%d) -char* D_800EC1BC = "ターボオン!!!(%d)\n"; -// No cutting corners! ! ! (%d) -char* D_800EC1D4 = "手抜き禁止!!!(%d)\n"; -// Action start data error! (num %d, act %d) -char* D_800EC1EC = "アクション開始データエラー!(num %d, act %d)\n"; -// Action end data error! (num %d, act %d, old_act_num %d) -char* D_800EC21C = "アクション終了データエラー!(num %d, act %d, old_act_num %d)\n"; -char* D_800EC25C = "SL : center_point_number : %d\n"; -// SL: CENTER LINE split start -char* D_800EC27C = "SL: CENTER LINE 分割開始\n"; -// SL: CENTER LINE split ended (%d -> %d indivual) -char* D_800EC298 = "SL: CENTER LINE 分割終了 (%d -> %d 個)\n"; -char* D_800EC2C0 = "SHIP : center_point_number : %d\n"; -// SHIP: CENTER LINE split start -char* D_800EC2E4 = "SHIP: CENTER LINE 分割開始\n"; -// SHIP: CENTER LINE split ended (%d -> %d indivual) -char* D_800EC300 = "SHIP: CENTER LINE 分割終了 (%d -> %d 個)\n"; -// General-purpose OBJ character initialization -char* D_800EC32C = "汎用OBJキャラ初期化\n"; -// SL OBJ settings -char* D_800EC344 = "SL OBJ設定\n"; -// SHIP OBJ settings -char* D_800EC350 = "SHIP OBJ設定\n"; -// Track OBJ settings -char* D_800EC360 = "トラックOBJ設定\n"; -// Bus OBJ setting -char* D_800EC374 = "バスOBJ設定\n"; -// Tank OBJ setting -char* D_800EC384 = "タンクOBJ設定\n"; -// RV OBJ settings -char* D_800EC394 = "RV OBJ設定\n"; -// Generic OBJ character initialization completed -char* D_800EC3A0 = "汎用OBJキャラ初期化終了\n"; -// horn (num %d, permit %d, %d) -char* D_800EC3BC = "クラクション (num %d, permit %d, %d)\n"; -char* D_800EC3E4 = "OGA CAMERA INIT (%d)\n"; -char* D_800EC3FC = "OGA CAMERA INIT END\n"; -// High speed camera ERR !!! (ncx = %f) -char* D_800EC414 = "高速カメラ ERR !!! (ncx = %f)\n"; -// High speed camera ERR !!! (ncz = %f) -char* D_800EC434 = "高速カメラ ERR !!! (ncz = %f)\n"; -// High speed camera ERR !!! (ecx = %f) -char* D_800EC454 = "高速カメラ ERR !!! (ecx = %f)\n"; -// High speed camera ERR !!! (ecz = %f) -char* D_800EC474 = "高速カメラ ERR !!! (ecz = %f)\n"; -char* D_800EC494 = "OGA DRIVERS POINT CAMERA MODE \n"; -char* D_800EC4B4 = "OGA WINNER CAMERA MODE \n"; -char* D_800EC4D0 = "OGA TIMEATTACK QUICK CAMERA INIT \n"; -char* D_800EC4F4 = "OGA BATTLE CAMERA INIT win(%d)\n"; -char* D_800EC514 = "GOAL! <> camera %d rank %d\n"; -char* D_800EC53C = "GOAL! <> camera %d rank %d\n"; -char* D_800EC568 = "GOAL! <> camera %d rank %d\n"; -// Camera and cart collided! ! ! -char* D_800EC594 = "カメラとカートが衝突しました!!! (%d)\n"; -char* D_800EC5C0 = "<<< ITEM OBJ NUMBER ERR !! >>> item %d obj_num %d \n"; -// <<< BANANA SET HOUSE >>> obj_num %d zure %f -char* D_800EC5F8 = "<<< BANANA SET 失敗 >>> obj_num %d zure %f \n"; -// BANANA Caught in owner check. (num %d) -char* D_800EC628 = "BANANA 所有者チェックに引っ掛かりました。(num %d)\n"; -// Reason: EXISTOBJ -char* D_800EC65C = "理由: EXISTOBJ \n"; -// Reason: category -char* D_800EC670 = "理由: category \n"; -// Reason: sparam -char* D_800EC684 = "理由: sparam \n"; -// Reason: num -char* D_800EC694 = "理由: num \n"; -char* D_800EC6A0 = "BANANA HOLD (num %d time %d hold_time %d)\n"; -// Installation Caught in BANANA owner check. (num %d) -char* D_800EC6D0 = "設置 BANANA 所有者チェックに引っ掛かりました。(num %d)\n"; -// Reason: EXISTOBJ -char* D_800EC708 = "理由: EXISTOBJ \n"; -// Reason: category -char* D_800EC71C = "理由: category \n"; -// Reason: sparam -char* D_800EC730 = "理由: sparam \n"; -// Reason: num -char* D_800EC740 = "理由: num \n"; -// I put BANANA. (num %d) -char* D_800EC74C = "BANANA 置きました。 (num %d)\n"; -// <<< BANANA NAGE SET failed >>> obj_num %d -char* D_800EC76C = "<<< BANANA NAGE SET 失敗 >>> obj_num %d \n"; -// BANANA NAGE MOVE Caught in owner check. (num %d) -char* D_800EC798 = "BANANA NAGE MOVE 所有者チェックに引っ掛かりました。(num %d)\n"; -// Reason: EXISTOBJ -char* D_800EC7D8 = "理由: EXISTOBJ \n"; -// Reason: category -char* D_800EC7EC = "理由: category \n"; -// Reason: sparam -char* D_800EC800 = "理由: sparam \n"; -// Reason: num -char* D_800EC810 = "理由: num \n"; -char* D_800EC81C = "BANANA NAGE END 所有者チェックに引っ掛かりました。(num %d)\n"; -// Reason: EXISTOBJ -char* D_800EC858 = "理由: EXISTOBJ \n"; -// Reason: category -char* D_800EC86C = "理由: category \n"; -// Reason: sparam -char* D_800EC880 = "理由: sparam \n"; -// Reason: num -char* D_800EC890 = "理由: num \n"; -char* D_800EC89C = "G_SHELL HOLD (num %d time %d hold_time %d)\n"; -// <<< G_SHELL SET failed >>> obj_num %d -char* D_800EC8CC = "<<< G_SHELL SET 失敗 >>> obj_num %d \n"; -// <<< G_SHELL SET failed >>> object_count %d -char* D_800EC8F4 = "<<< G_SHELL SET 失敗 >>> object_count %d \n"; -// G_SHELL Caught in owner check. (num %d) -char* D_800EC920 = "G_SHELL 所有者チェックに引っ掛かりました。(num %d)\n"; -// Reason: EXISTOBJ -char* D_800EC954 = "理由: EXISTOBJ \n"; -// Reason: category -char* D_800EC968 = "理由: category \n"; -// Reason: sparam -char* D_800EC97C = "理由: sparam \n"; -// Reason: num -char* D_800EC98C = "理由: num \n"; -// Just before launch G_SHELL Caught in owner check. (num %d) -char* D_800EC998 = "発射直前 G_SHELL 所有者チェックに引っ掛かりました。(num %d)\n"; -// Reason: EXISTOBJ -char* D_800EC9D8 = "理由: EXISTOBJ \n"; -// Reason: category -char* D_800EC9EC = "理由: category \n"; -// Reason: sparam -char* D_800ECA00 = "理由: sparam \n"; -// Reason: num -char* D_800ECA10 = "理由: num \n"; -// G_SHELL firing (num %d) -char* D_800ECA1C = "G_SHELL 発射 (num %d)\n"; -char* D_800ECA34 = "R_SHELL HOLD (num %d time %d hold_time %d obj_num %d)\n"; -// <<< R_SHELL SET failed >>> obj_num %d -char* D_800ECA70 = "<<< R_SHELL SET 失敗 >>> obj_num %d \n"; -// <<< R_SHELL SET failed >>> object_count %d -char* D_800ECA98 = "<<< R_SHELL SET 失敗 >>> object_count %d \n"; -// R_SHELL Caught in owner check. (num %d) -char* D_800ECAC4 = "R_SHELL 所有者チェックに引っ掛かりました。(num %d)\n"; -// Reason: EXISTOBJ -char* D_800ECAF8 = "理由: EXISTOBJ \n"; -// Reason: category -char* D_800ECB0C = "理由: category \n"; -// Reason: sparam -char* D_800ECB20 = "理由: sparam \n"; -// Reason: num -char* D_800ECB30 = "理由: num \n"; -char* D_800ECB3C = "R_SHELL SHOOT (num %d time %d hold_time %d obj_num %d)\n"; -// Just before launch R_SHELL Caught in owner check. (num %d) -char* D_800ECB78 = "発射直前 R_SHELL 所有者チェックに引っ掛かりました。(num %d)\n"; -// Reason: EXISTOBJ -char* D_800ECBB8 = "理由: EXISTOBJ \n"; -// Reason: category -char* D_800ECBCC = "理由: category \n"; -// Reason: sparam -char* D_800ECBE0 = "理由: sparam \n"; -// Reason: num -char* D_800ECBF0 = "理由: num \n"; -// R_SHELL firing (num %d) -char* D_800ECBFC = "R_SHELL 発射 (num %d)\n"; -char* D_800ECC14 = "S_BANANA HOLD (num %d time %d hold_time %d)\n"; -// <<< SUPER_BANANA SET failed >>> obj_num %d -char* D_800ECC44 = "<<< SUPER_BANANA SET 失敗 >>> obj_num %d \n"; -// <<< SUPER_BANANA SET failed >>> object_count %d -char* D_800ECC70 = "<<< SUPER_BANANA SET 失敗 >>> object_count %d \n"; -// S_BANANA Caught in owner check. (num %d) -char* D_800ECCA0 = "S_BANANA 所有者チェックに引っ掛かりました。(num %d)\n"; -// Reason: category -char* D_800ECCD8 = "理由: category \n"; -// Reason: sparam -char* D_800ECCEC = "理由: sparam \n"; -// Reason: sb_ok -char* D_800ECCFC = "理由: sb_ok \n"; -char* D_800ECD0C = "S_BANANA RELEASE (num %d time %d )\n"; -// <<< FAKE IBOX SET failed >>> obj_num %d -char* D_800ECD34 = "<<< FAKE IBOX SET 失敗 >>> obj_num %d \n"; -// IBOX Caught in owner check. (num %d) -char* D_800ECD5C = "IBOX 所有者チェックに引っ掛かりました。(num %d)\n"; -// Reason: EXISTOBJ -char* D_800ECD90 = "理由: EXISTOBJ \n"; -// Reason: category -char* D_800ECDA4 = "理由: category \n"; -// Reason: sparam -char* D_800ECDB8 = "理由: sparam \n"; -// Reason: num -char* D_800ECDC8 = "理由: num \n"; -char* D_800ECDD4 = "FBOX HOLD (num %d time %d hold_time %d)\n"; -// Installation IBOX owner check failed. (num %d) -char* D_800ECE00 = "設置 IBOX 所有者チェックに引っ掛かりました。(num %d)\n"; -// Reason: EXISTOBJ -char* D_800ECE38 = "理由: EXISTOBJ \n"; -// Reason: category -char* D_800ECE4C = "理由: category \n"; -// Reason: sparam -char* D_800ECE60 = "理由: sparam \n"; -// Reason: num -char* D_800ECE70 = "理由: num \n"; -// Ray START (%d) -char* D_800ECE7C = "雷START (%d)\n"; -// Ray END (%d) -char* D_800ECE8C = "雷END (%d)\n"; -// ---------- Initialization of commendation table -char* D_800ECE98 = "---------- 表彰台初期化\n"; -// map_number = %d -> 20 Rewriting. -char* D_800ECEB4 = "map_number = %d - > 20 書き換え中。\n"; -// OGA Recognition move begins -char* D_800ECEDC = "OGA 表彰 move 開始\n"; -// I called the display of the 4th place person. -char* D_800ECEF0 = "4位の人の表示をコールしました。\n"; -// Arrive at the podium -char* D_800ECF14 = "表彰台に到着\n"; -// Everyone gather! -char* D_800ECF24 = "全員集合!\n"; -// Arrive on the road -char* D_800ECF30 = "道路に到着\n"; -// 4th place finished -char* D_800ECF3C = "4位の人終了\n"; -// OGA commendation move end -char* D_800ECF4C = "OGA 表彰 move 終了\n"; -char* D_800ECF60 = "OGAWA DEBUG DRAW\n"; - -s16 get_angle_between_waypoints(Vec3f arg0, Vec3f arg1) { - s16 temp_ret; - s16 phi_v1; - - temp_ret = get_angle_between_two_vectors(arg0, arg1); - phi_v1 = temp_ret; - if (gIsMirrorMode != 0) { - phi_v1 = -temp_ret; - } - return phi_v1; -} - -s32 func_80006018(f32 arg0, f32 arg1, f32 arg2, f32 arg3, f32 arg4, f32 arg5, f32 arg6, f32 arg7) { - f32 temp_f0; - f32 temp_f18; - - temp_f0 = sqrtf((arg2 * arg2) + (arg3 * arg3)); - if (temp_f0 < 0.01f) { - return 0; - } - temp_f18 = ((arg2 / temp_f0) * (arg6 - arg0)) + ((arg3 / temp_f0) * (arg7 - arg1)); - if ((-arg4 < temp_f18) && (temp_f18 < arg4)) { - temp_f18 = ((arg3 / temp_f0) * (arg6 - arg0)) + (-(arg2 / temp_f0) * (arg7 - arg1)); - if ((-arg5 < temp_f18) && (temp_f18 < arg5)) { - return 1; - } - } - return 0; -} - -void adjust_position_by_angle(Vec3f newPos, Vec3f oldPos, s16 orientationY) { - f32 x_dist; - f32 z_dist; - f32 temp1; - f32 temp2; - f32 sine; - f32 cosine; - - if (gIsMirrorMode != 0) { - orientationY = -orientationY; - } - x_dist = newPos[0] - oldPos[0]; - z_dist = newPos[2] - oldPos[2]; - sine = sins(orientationY); - cosine = coss(orientationY); - temp1 = ((x_dist * cosine) + (z_dist * sine)); - temp2 = ((z_dist * cosine) - (x_dist * sine)); - newPos[0] = oldPos[0] + temp1; - newPos[2] = oldPos[2] + temp2; -} - -s32 set_vehicle_render_distance_flags(Vec3f vehiclePos, f32 renderDistance, s32 flags) { - Camera* camera; - Player* player; - f32 x; - f32 z; - f32 playerX; - f32 playerZ; - s32 i; - s32 flag; - s8 numScreens; - - x = vehiclePos[0]; - z = vehiclePos[2]; - switch (gActiveScreenMode) { - case SCREEN_MODE_1P: - numScreens = 1; - break; - case SCREEN_MODE_2P_SPLITSCREEN_HORIZONTAL: - case SCREEN_MODE_2P_SPLITSCREEN_VERTICAL: - numScreens = 2; - break; - case SCREEN_MODE_3P_4P_SPLITSCREEN: - numScreens = gPlayerCount; - break; - default: - numScreens = 1; - break; - } - flag = flags; - if (!gDemoMode) { - player = gPlayerOne; - // Checks distance from each player. - for (i = 0; i < gPlayerCount; i++, player++) { - if (((player->type & PLAYER_HUMAN) != 0) && ((player->type & PLAYER_KART_AI) == 0)) { - playerX = player->pos[0]; - playerZ = player->pos[2]; - - // Is player within render distance - if (((playerX - renderDistance) < x) && ((playerX + renderDistance) > x) && - ((playerZ - renderDistance) < z) && ((playerZ + renderDistance) > z)) { - // Sets the render flag to on for each player. - flag |= (RENDER_VEHICLE << i); - } else { - // Sets the render flag to off for each player. - flag &= ~(RENDER_VEHICLE << i); - } - } - } - } else { // Demo cinematic uses the camera to check render distance - camera = camera1; - for (i = 0; i < numScreens; i++, camera++) { - playerX = camera->pos[0]; - playerZ = camera->pos[2]; - if (((playerX - renderDistance) < x) && (x < (playerX + renderDistance)) && - ((playerZ - renderDistance) < z) && (z < (playerZ + renderDistance))) { - flag |= (RENDER_VEHICLE << i); - } else { - flag &= ~(RENDER_VEHICLE << i); - } - } - } - return flag; -} - -void func_800065D0(s32 playerId, Player* player) { - s16 temp_t2; - s16 var_t1; - s16 temp_t3; - s16 a; - u32 b; - - a = (s16) gPathIndexByPlayerId[playerId]; - b = gNearestWaypointByPlayerId[playerId]; - - temp_t2 = (s16) ((s16) player->rotation[1] / 182); - temp_t3 = (s16) ((s16) D_80164590[a][b] / 182); - - var_t1 = temp_t2 - temp_t3; - - if (var_t1 < 0) { - var_t1 = -var_t1; - } - - if ((D_80164450[playerId] < D_80163288[playerId]) && (var_t1 >= 136) && (var_t1 < 225)) { - D_80163258[playerId]++; - if ((D_80163258[playerId]) >= 5) { - D_80163270[playerId] = 1; - D_80163258[playerId] = 5; - gPlayers[playerId].effects |= 0x400000; - } - } else if ((var_t1 < 45) || (var_t1 >= 316)) { - D_80163270[playerId] = 0; - D_80163258[playerId] = 0; - gPlayers[playerId].effects &= 0xFFBFFFFF; - } - D_80163288[playerId] = D_80164450[playerId]; -} - -void set_places(void) { - s32 temp_s2; - f32 temp_f0; - s32 sp80[8]; - s32 a_really_cool_variable_name; - UNUSED s32 pad; - s32 var_t4; - s32 playerId; - s32 temp_a0; - s32 var_t1_3; - - switch (gModeSelection) { - case BATTLE: - default: - return; // HEY! returns, not breaks - case GRAND_PRIX: - case TIME_TRIALS: - var_t4 = NUM_PLAYERS; - break; - case VERSUS: - var_t4 = gPlayerCount; - break; - } - - if (D_8016348C == 0) { - for (playerId = 0; playerId < var_t4; playerId++) { - temp_a0 = gGPCurrentRacePlayerIdByRank[playerId]; - sp80[playerId] = temp_a0; - gCourseCompletionPercentByRank[playerId] = gCourseCompletionPercentByPlayerId[temp_a0]; - } - } else { - for (playerId = 0; playerId < var_t4; playerId++) { - temp_a0 = gGPCurrentRacePlayerIdByRank[playerId]; - sp80[playerId] = temp_a0; - gCourseCompletionPercentByRank[playerId] = -gTimePlayerLastTouchedFinishLine[temp_a0]; - } - } - - for (playerId = 0; playerId < var_t4 - 1; playerId++) { - if ((gPlayers[gGPCurrentRacePlayerIdByRank[playerId]].type & 0x800)) { - continue; - } - - for (var_t1_3 = playerId + 1; var_t1_3 < var_t4; var_t1_3++) { - if (gCourseCompletionPercentByRank[playerId] < gCourseCompletionPercentByRank[var_t1_3]) { - if (!(gPlayers[gGPCurrentRacePlayerIdByRank[var_t1_3]].type & 0x800)) { - temp_s2 = sp80[playerId]; - sp80[playerId] = sp80[var_t1_3]; - sp80[var_t1_3] = temp_s2; - temp_f0 = gCourseCompletionPercentByRank[playerId]; - gCourseCompletionPercentByRank[playerId] = gCourseCompletionPercentByRank[var_t1_3]; - gCourseCompletionPercentByRank[var_t1_3] = temp_f0; - } - } - } - } - - for (playerId = 0; playerId < NUM_PLAYERS; playerId++) { - D_801643E0[playerId] = gGPCurrentRaceRankByPlayerId[playerId]; - } - - for (playerId = 0; playerId < var_t4; playerId++) { - gGPCurrentRacePlayerIdByRank[playerId] = sp80[playerId]; - gGPCurrentRaceRankByPlayerId[sp80[playerId]] = playerId; - } - - for (playerId = 0; playerId < var_t4; playerId++) { - a_really_cool_variable_name = D_80164378[playerId]; - sp80[playerId] = a_really_cool_variable_name; - gCourseCompletionPercentByRank[playerId] = gCourseCompletionPercentByPlayerId[a_really_cool_variable_name]; - } - - for (playerId = 0; playerId < var_t4 - 1; playerId++) { - for (var_t1_3 = playerId + 1; var_t1_3 < var_t4; var_t1_3++) { - if (gCourseCompletionPercentByRank[playerId] < gCourseCompletionPercentByRank[var_t1_3]) { - temp_s2 = sp80[playerId]; - sp80[playerId] = sp80[var_t1_3]; - sp80[var_t1_3] = temp_s2; - temp_f0 = gCourseCompletionPercentByRank[playerId]; - gCourseCompletionPercentByRank[playerId] = gCourseCompletionPercentByRank[var_t1_3]; - gCourseCompletionPercentByRank[var_t1_3] = temp_f0; - } - } - } - - for (playerId = 0; playerId < var_t4; playerId++) { - D_80164408[sp80[playerId]] = playerId; - D_80164378[playerId] = sp80[playerId]; - } -} - -void func_800070F4(void) { - f32 temp_f0; - UNUSED s32 pad; - s32 sp50[8]; - s32 temp_a0; - s32 temp_t2_2; - s32 var_a1_2; - s32 var_a3; - s32 var_a2; - - switch (gModeSelection) { - case BATTLE: - default: - return; // HEY! returns, not breaks - case GRAND_PRIX: - case TIME_TRIALS: - var_a2 = 8; - break; - case VERSUS: - var_a2 = gPlayerCount; - break; - } - - for (var_a3 = 0; var_a3 < var_a2; var_a3++) { - temp_a0 = gGPCurrentRacePlayerIdByRank[var_a3]; - sp50[var_a3] = temp_a0; - gCourseCompletionPercentByRank[var_a3] = -gTimePlayerLastTouchedFinishLine[temp_a0]; - } - - for (var_a3 = 0; var_a3 < (var_a2 - 1); var_a3++) { - for (var_a1_2 = var_a3 + 1; var_a1_2 < var_a2; var_a1_2++) { - if (gCourseCompletionPercentByRank[var_a3] < gCourseCompletionPercentByRank[var_a1_2]) { - temp_t2_2 = sp50[var_a3]; - sp50[var_a3] = sp50[var_a1_2]; - sp50[var_a1_2] = temp_t2_2; - temp_f0 = gCourseCompletionPercentByRank[var_a3]; - gCourseCompletionPercentByRank[var_a3] = gCourseCompletionPercentByRank[var_a1_2]; - gCourseCompletionPercentByRank[var_a1_2] = temp_f0; - } - } - } - - for (var_a3 = 0; var_a3 < NUM_PLAYERS; var_a3++) { - D_801643E0[var_a3] = gGPCurrentRaceRankByPlayerId[var_a3]; - } - - for (var_a3 = 0; var_a3 < var_a2; var_a3++) { - gGPCurrentRaceRankByPlayerId[sp50[var_a3]] = var_a3; - gGPCurrentRacePlayerIdByRank[var_a3] = sp50[var_a3]; - } -} - -void func_800074D4(void) { - f32 temp_a0; - s32 temp; - s32 sp68[8]; - UNUSED s32 pad; - s32 temp_t1; - s32 i; - s32 j; - s32 this_loops_upper_bound_is_brough_to_you_by_the_number = 8; - - for (i = 0; i < this_loops_upper_bound_is_brough_to_you_by_the_number;) { - gCourseCompletionPercentByRank[i++] = 0.0f; - } - - for (j = 0, i = 0; i < this_loops_upper_bound_is_brough_to_you_by_the_number; i++) { - if (gPlayers[i].type & 0x800) { - sp68[j] = i; - gCourseCompletionPercentByRank[j] = -gTimePlayerLastTouchedFinishLine[i]; - j++; - } - } - - temp_t1 = j; - for (i = 0; i < this_loops_upper_bound_is_brough_to_you_by_the_number; i++) { - if (!(gPlayers[i].type & 0x800)) { - sp68[j] = i; - gCourseCompletionPercentByRank[j] = gCourseCompletionPercentByPlayerId[i]; - j++; - } - } - - for (i = 0; i < (temp_t1 - 1); i++) { - for (j = i + 1; j < temp_t1; j++) { - if (gCourseCompletionPercentByRank[i] < gCourseCompletionPercentByRank[j]) { - temp = sp68[i]; - sp68[i] = sp68[j]; - sp68[j] = temp; - temp_a0 = gCourseCompletionPercentByRank[i]; - gCourseCompletionPercentByRank[i] = gCourseCompletionPercentByRank[j]; - gCourseCompletionPercentByRank[j] = temp_a0; - } - } - } - - for (i = temp_t1; i < (this_loops_upper_bound_is_brough_to_you_by_the_number - 1); i++) { - for (j = i + 1; j < this_loops_upper_bound_is_brough_to_you_by_the_number; j++) { - if (gCourseCompletionPercentByRank[i] < gCourseCompletionPercentByRank[j]) { - temp = sp68[i]; - sp68[i] = sp68[j]; - sp68[j] = temp; - temp_a0 = gCourseCompletionPercentByRank[i]; - gCourseCompletionPercentByRank[i] = gCourseCompletionPercentByRank[j]; - gCourseCompletionPercentByRank[j] = temp_a0; - } - } - } - - for (i = 0; i < 8; i++) { - D_801643E0[i] = gGPCurrentRaceRankByPlayerId[i]; - } - - for (i = 0; i < this_loops_upper_bound_is_brough_to_you_by_the_number; i++) { - gGPCurrentRaceRankByPlayerId[sp68[i]] = i; - gGPCurrentRacePlayerIdByRank[i] = sp68[i]; - } -} - -s32 func_80007BF8(u16 arg0, u16 arg1, u16 arg2, u16 arg3, u16 arg4) { - s32 var_v1; - - var_v1 = 0; - if ((arg1 >= arg2) && (arg1 < (arg4 - arg3))) { - if ((arg0 >= (arg1 - arg2)) && ((arg1 + arg3) >= arg0)) { - var_v1 = 1; - } - } else if ((((arg1 + arg3) % arg4) < arg0) && ((((arg1 + arg4) - arg2) % arg4) >= arg0)) { - var_v1 = -1; - } else { - var_v1 = 2; - } - return var_v1; -} - -void func_80007D04(s32 playerId, Player* player) { - s16 temp_t1; - s16 temp_t2; - s32 var_v0; - - temp_t1 = D_80164450[D_80163478]; - temp_t2 = D_80164450[playerId]; - - if (gGPCurrentRaceRankByPlayerId[playerId] < 2) { - s16 val1 = gGPCurrentRaceRankByPlayerId[D_80163478]; - s16 val2 = temp_t2 - temp_t1; - - if (val2 > 400 && val1 >= 6) { - player->effects &= ~0x200000; - player_speed(player); - D_801634C0[playerId] = 4; - return; - } - } else { - player->effects |= 0x200000; - player_speed(player); - D_801634C0[playerId] = 3; - return; - } - - switch (gCCSelection) { // WTF, FAKE ? - case 3: - break; - } - - switch (gCCSelection) { - case 0: - var_v0 = 0; - if (playerId == D_80163344[0]) { - var_v0 = 0x14; - } - break; - - case 1: - var_v0 = 8; - if (playerId == D_80163344[0]) { - var_v0 = 0x18; - } - break; - - case 2: - var_v0 = 0x12; - if (playerId == D_80163344[0]) { - var_v0 = 0x24; - } - break; - - case 3: - var_v0 = 8; - if (playerId == D_80163344[0]) { - var_v0 = 0x18; - } - break; - - default: - var_v0 = 0; - break; - } - - if (temp_t2 < temp_t1) { - player->effects |= 0x200000; - player_speed(player); - D_801634C0[playerId] = 1; - } else if (temp_t2 < (temp_t1 + var_v0 + 0x32)) { - player->effects &= ~0x200000; - player_speed(player); - D_801634C0[playerId] = 3; - } else if (D_801631E0[playerId] == 0) { - player->effects &= ~0x200000; - player_speed(player); - D_801634C0[playerId] = 2; - } else { - player->effects &= ~0x200000; - decelerate_ai_player(player, 1.0f); - D_801634C0[playerId] = -1; - } -} - -void func_80007FA4(s32 arg0, Player* player, f32 arg2) { - f32 temp_f0; - f32 temp_f12; - f32 temp_f2; - s32 test; - - temp_f0 = D_80163418[arg0] - player->pos[0]; - temp_f2 = D_80163438[arg0] - player->pos[2]; - temp_f12 = (temp_f0 * temp_f0) + (temp_f2 * temp_f2); - if (arg0 == 3) { - if ((temp_f12 < 25.0f) && (D_80163410[arg0] < 5)) { - D_80163410[arg0] = 4; - (arg2 < ((2.0 * 18.0) / 216.0)) ? func_80038BE4(player, 1) : decelerate_ai_player(player, 1.0f); - } else if ((temp_f12 < 3600.0f) && (D_80163410[arg0] < 4)) { - D_80163410[arg0] = 3; - (arg2 < ((5.0 * 18.0) / 216.0)) ? func_80038BE4(player, 1) : decelerate_ai_player(player, 5.0f); - } else { - (arg2 < ((20.0 * 18.0) / 216.0)) ? func_80038BE4(player, 10) : decelerate_ai_player(player, 1.0f); - } - } else { - if ((temp_f12 < 25.0f) && (D_80163410[arg0] < 5)) { - D_80163410[arg0] = 4; - test = 2; - (arg2 < ((test * 18.0) / 216.0)) ? func_80038BE4(player, 1) : decelerate_ai_player(player, 1.0f); - } else if ((temp_f12 < 4900.0f) && (D_80163410[arg0] < 4)) { - D_80163410[arg0] = 3; - test = 5; - (arg2 < ((test * 18.0) / 216.0)) ? func_80038BE4(player, 1) : decelerate_ai_player(player, 15.0f); - } else if ((temp_f12 < 22500.0f) && (D_80163410[arg0] < 3)) { - D_80163410[arg0] = 2; - test = 20; - (arg2 < ((test * 18.0) / 216.0)) ? func_80038BE4(player, 5) : decelerate_ai_player(player, 1.0f); - } else if ((temp_f12 < 90000.0f) && (D_80163410[arg0] < 2)) { - D_80163410[arg0] = 1; - test = 30; - (arg2 < ((test * 18.0) / 216.0)) ? func_80038BE4(player, 6) : decelerate_ai_player(player, 1.0f); - } else if (D_80163410[arg0] == 0) { - test = 35; - (arg2 < (((test ^ 0) * 18.0) / 216.0)) ? func_80038BE4(player, 2) : decelerate_ai_player(player, 1.0f); - } else { - decelerate_ai_player(player, 1.0f); - } - } -} - -void func_80008424(s32 playerId, f32 arg1, Player* player) { - f32 var_f2; - f32 var_f0; - UNUSED s32 thing; - s32 var_a1; - - var_f2 = player->unk_094; - if (!(player->effects & 0x80) && !(player->effects & 0x40) && !(player->effects & 0x20000) && - !(player->soundEffects & 0x400000) && !(player->soundEffects & 0x01000000) && !(player->soundEffects & 2) && - !(player->soundEffects & 4)) { - if (gCurrentCourseId == COURSE_AWARD_CEREMONY) { - func_80007FA4(playerId, player, var_f2); - } else if ((bStopAICrossing[playerId] == 1) && !(player->effects & (STAR_EFFECT | BOO_EFFECT))) { - decelerate_ai_player(player, 10.0f); - if (player->currentSpeed == 0.0) { - player->velocity[0] = 0.0f; - player->velocity[2] = 0.0f; - } - } else { - var_f0 = 3.3333333f; - switch (gCCSelection) { /* irregular */ - case 1: - case 3: - break; - case 0: - var_f0 = 2.5f; - break; - case 2: - var_f0 = 3.75f; - break; - } - if (var_f2 < var_f0) { - player->effects &= ~0x00200000; - player_speed(player); - } else if (player->type & 0x800) { - if (var_f2 < arg1) { - player->effects &= ~0x00200000; - player_speed(player); - } else { - player->effects &= ~0x00200000; - decelerate_ai_player(player, 1.0f); - } - } else if ((D_801631E0[playerId] == 1) && (D_80163330[playerId] != 1)) { - if (func_800088D8(playerId, gLapCountByPlayerId[playerId], D_80164408[playerId]) == 1) { - player->effects |= 0x200000; - player_speed(player); - } else { - player->effects &= ~0x00200000; - decelerate_ai_player(player, 1.0f); - } - } else { - var_a1 = 1; - switch (gSpeedKartAIBehaviour[playerId]) { /* switch 1; irregular */ - case SPEED_KART_AI_BEHAVIOUR_FAST: /* switch 1 */ - player->effects &= ~0x00200000; - player_speed(player); - break; - case SPEED_KART_AI_BEHAVIOUR_MAX: /* switch 1 */ - player->effects |= 0x200000; - player_speed(player); - break; - case SPEED_KART_AI_BEHAVIOUR_SLOW: /* switch 1 */ - if (((var_f2 / 18.0f) * 216.0f) > 20.0f) { - arg1 = 1.6666666f; - } - var_a1 = 0; - break; - case SPEED_KART_AI_BEHAVIOUR_NORMAL: /* switch 1 */ - default: /* switch 1 */ - var_a1 = 0; - break; - } - if (var_a1 != 1) { - if (var_f2 < arg1) { - if ((gDemoMode == 1) && (gCurrentCourseId != COURSE_AWARD_CEREMONY)) { - player_speed(player); - } else if (D_80163330[playerId] == 1) { - func_80007D04(playerId, player); - } else if (func_800088D8(playerId, gLapCountByPlayerId[playerId], D_80164408[playerId]) == 1) { - player->effects |= 0x200000; - player_speed(player); - } else { - player->effects &= ~0x00200000; - decelerate_ai_player(player, 1.0f); - } - } else { - player->effects &= ~0x00200000; - if (arg1 > 1.0f) { - decelerate_ai_player(player, 2.0f); - } else { - decelerate_ai_player(player, 5.0f); - } - } - } - } - } - } -} - -#ifdef NON_MATCHING -// generated by m2c commit 05102b12b75400ad2be8bd0872404237b36e1702 on Feb-20-2024 -// static ? D_800DCAF4; /* unable to generate initializer: unknown type */ -// static ? D_800DCB34; /* unable to generate initializer: unknown type */ -// static ? *D_800DCBB4[0x15] = { -// &D_800DCB34, -// &D_800DCAF4, -// &D_800DCAF4, -// &D_800DCAF4, -// &D_800DCAF4, -// &D_800DCAF4, -// &D_800DCAF4, -// &D_800DCAF4, -// &D_800DCAF4, -// &D_800DCAF4, -// &D_800DCAF4, -// &D_800DCAF4, -// &D_800DCAF4, -// &D_800DCAF4, -// &D_800DCAF4, -// &D_800DCAF4, -// &D_800DCAF4, -// &D_800DCAF4, -// &D_800DCAF4, -// &D_800DCAF4, -// &D_800DCAF4, -// }; - -s32 func_800088D8(s32 playerId, s16 arg1, s16 arg2) { - Player* player; - f32 interp; - s16 rank; - s16 var_a0_4; - s16 var_t1; - s16 var_v0; - s16* temp_a3; - s32 temp_a2; - s32 arg1_times_8; - s32 var_a0_2; - s32 progress; - s32 var_a1_4; - s32 i; - - D_80163128[playerId] = -1; - D_80163150[playerId] = -1; - if (gModeSelection == 1) { - return true; - } - if (arg1 < 0) { - return true; - } else if (arg1 >= 4) { - arg1 = 3; - } - if (D_80163330[playerId] == 1) { - return true; - } - player = &gPlayers[playerId]; - if (player->type & 0x4000) { - return true; - } - arg1_times_8 = arg1 * 8; - temp_a3 = &GET_COURSE_800DCBB4(arg1_times_8); - if (arg2 == 0) { - if (gDemoMode == 1) { - temp_a2 = D_80164450[playerId] - D_80164450[D_80164378[7]]; - if (temp_a2 < 0) { - temp_a2 = -temp_a2; - } - if (arg1_times_8 < 24) { - interp = gLapCompletionPercentByPlayerId[playerId]; - D_80163150[playerId] = temp_a3[8] * interp + temp_a3[0] * (1.0f - interp); - } else { - D_80163150[playerId] = temp_a3[0]; - } - if (D_80163150[playerId] < temp_a2 && player->unk_094 / 18.0f * 216.0f >= 20.0f) { - return false; - } - return true; - } - progress = D_80164450[playerId] - D_80164450[D_80163478]; - rank = gGPCurrentRaceRankByPlayerId[2 + (D_80163478 * 4)]; - if (gWaypointCountByPathIndex[0] * 2 / 3 < progress && rank >= 6) { - progress = D_80164450[playerId] - D_80164450[gLapCountByPlayerId[-26 + rank * 2]]; - } - if (progress < 0) { - progress = -progress; - } - if (arg1_times_8 < 24) { - interp = gLapCompletionPercentByPlayerId[playerId]; - var_a0_2 = temp_a3[8] * interp + temp_a3[0] * (1.0f - interp); - } else { - var_a0_2 = temp_a3[0]; - } - D_80163150[playerId] = (gCCSelection + 1) * var_a0_2; - if (D_80163150[playerId] < progress && player->unk_094 / 18.0f * 216.0f >= 20.0f) { - return false; - } - return true; - } else { - var_a1_4 = D_80164450[(s16) *D_80163344] - D_80164450[playerId]; - if (var_a1_4 < 0) { - var_a1_4 = -var_a1_4; - } - var_v0 = 0; - for (i = 0; i < 2; i++) { - if (gGPCurrentRaceRankByPlayerId[D_80163344[i]] < arg2) { - var_v0++; - } - } - var_a0_4 = 0; - for (i = 0; i < gPlayerCount; i++) { - if (gGPCurrentRaceRankByPlayerId[i] < arg2) { - var_a0_4++; - } - } - var_t1 = (arg2 - var_v0) - var_a0_4; - if (var_v0 > 0 || var_a0_4 > 0) { - var_t1++; - } - D_80164538[playerId] = var_t1; - if (var_t1 < 0 || var_t1 >= 8) { - return false; - } - if (arg1_times_8 < 24) { - temp_a3 = &temp_a3[var_t1]; - interp = gLapCompletionPercentByPlayerId[playerId]; - D_80163150[playerId] = temp_a3[8] * interp + temp_a3[0] * (1.0f - interp); - } else { - D_80163150[playerId] = temp_a3[var_t1]; - } - D_80163128[playerId] = var_a1_4; - if (D_80163150[playerId] < var_a1_4) { - return true; - } - return false; - } -} -#else -GLOBAL_ASM("asm/non_matchings/code_80005FD0/func_800088D8.s") -#endif - -void func_80008DC0(s32 pathIndex) { - D_80164490 = D_80164550[pathIndex]; - D_801631D0 = D_80164560[pathIndex]; - D_801631D4 = D_80164570[pathIndex]; - D_801631D8 = D_80164580[pathIndex]; - D_801631DC = D_80164590[pathIndex]; - D_801645E0 = D_801645A0[pathIndex]; - D_80164430 = gWaypointCountByPathIndex[pathIndex]; -} - -s32 func_80008E58(s32 payerId, s32 pathIndex) { - f32 posX; - f32 posY; - f32 posZ; - Player* player; - s32 trackSectionId; - UNUSED s32 stackPadding; - - player = &gPlayers[payerId]; - posX = player->pos[0]; - posY = player->pos[1]; - posZ = player->pos[2]; - stackPadding = pathIndex; - trackSectionId = get_track_section_id(player->collision.meshIndexZX); - D_80163318[payerId] = trackSectionId; - sSomeNearestWaypoint = find_closest_waypoint_track_section(posX, posY, posZ, trackSectionId, &pathIndex); - gNearestWaypointByPlayerId[payerId] = sSomeNearestWaypoint; - if (pathIndex) {}; - gPathIndexByPlayerId[payerId] = pathIndex; - func_80008DC0(pathIndex); - if (stackPadding) {}; - return pathIndex; -} - -void func_80008F38(s32 playerId) { - f32 temp_f0; - - D_80164450[playerId] = (gLapCountByPlayerId[playerId] * gWaypointCountByPathIndex[0]) + sSomeNearestWaypoint; - temp_f0 = - (f32) gNearestWaypointByPlayerId[playerId] / (f32) gWaypointCountByPathIndex[gPathIndexByPlayerId[playerId]]; - gLapCompletionPercentByPlayerId[playerId] = temp_f0; - gCourseCompletionPercentByPlayerId[playerId] = temp_f0; - gCourseCompletionPercentByPlayerId[playerId] += gLapCountByPlayerId[playerId]; -} - -void func_80009000(s32 playerId) { - s16 temp_v0; - - temp_v0 = D_801644F8[playerId]; - if (sSomeNearestWaypoint >= 0x6D) { - D_801644F8[playerId] = 1; - switch (D_80163448) { - case 0: - if (sSomeNearestWaypoint >= 0x20F) { - D_801644F8[playerId] = 0; - } - break; - case 1: - if (sSomeNearestWaypoint >= 0x206) { - D_801644F8[playerId] = 0; - } - break; - case 2: - if (sSomeNearestWaypoint >= 0x211) { - D_801644F8[playerId] = 0; - } - break; - case 3: - if (sSomeNearestWaypoint >= 0x283) { - D_801644F8[playerId] = 0; - } - break; - } - } - if ((temp_v0 == 0) && (D_801644F8[playerId] == 1)) { - D_80163490[playerId] = 1; - } - if ((temp_v0 == 1) && (D_801644F8[playerId] == 0)) { - D_801634A8[playerId] = 1; - } -} - -void func_800090F0(s32 playerId, Player* player) { - f32 posX; - f32 posY; - f32 posZ; - UNUSED f32 pad[2]; - - posX = player->pos[0]; - posY = player->pos[1]; - posZ = player->pos[2]; - if (D_80163490[playerId] == 1) { - D_80163448 = func_80008E58(playerId, random_int(4U)); - sSomeNearestWaypoint = func_8000CD24(posX, posY, posZ, 0, player, playerId, D_80163448); - gNearestWaypointByPlayerId[playerId] = sSomeNearestWaypoint; - func_80008F38(playerId); - D_80163490[playerId] = 0; - } - if (D_801634A8[playerId] == 1) { - D_80163448 = func_80008E58(playerId, 0); - sSomeNearestWaypoint = func_8000CD24(posX, posY, posZ, 0, player, playerId, D_80163448); - gNearestWaypointByPlayerId[playerId] = sSomeNearestWaypoint; - func_80008F38(playerId); - D_801634A8[playerId] = 0; - } -} - -/** - * Helps calculate time since player last touched finishline. - **/ -f32 func_80009258(UNUSED s32 playerId, f32 arg1, f32 arg2) { - f32 temp_f2 = D_8016344C - arg2; - f32 temp_f12 = arg1 - D_8016344C; - return gCourseTimer - ((COURSE_TIMER_ITER_f * temp_f2) / (temp_f2 + temp_f12)); -} - -#ifdef NON_MATCHING -// Weird stack issue, can't figure out how to get rid of it -void func_8000929C(s32 playerId, Player* player) { - f32 tempPos0; - f32 tempPos1; - f32 tempPos2; - s32 var_v0; - s32 var_v1; - f32 someTemp0; - UNUSED s16 stackPadding0; - s16 var_t0; - UNUSED s32 stackPadding1; - - tempPos0 = player->pos[0]; - tempPos1 = player->pos[1]; - tempPos2 = player->pos[2]; - D_801630E2 = 0; - D_80163240[playerId] = 0; - sSomeNearestWaypoint = - func_8000CD24(tempPos0, tempPos1, tempPos2, gNearestWaypointByPlayerId[playerId], player, playerId, D_80163448); - D_801630E0 = sSomeNearestWaypoint; - if (gNearestWaypointByPlayerId[playerId] != sSomeNearestWaypoint) { - gNearestWaypointByPlayerId[playerId] = sSomeNearestWaypoint; - D_801630E2 = 1; - func_80008F38(playerId); - } - if (gCurrentCourseId == COURSE_AWARD_CEREMONY) { - func_8000B95C(playerId, sSomeNearestWaypoint, D_80163448); - return; - } - if ((sSomeNearestWaypoint < 0x14) || ((gWaypointCountByPathIndex[D_80163448] - 0x14) < sSomeNearestWaypoint) || - (gCurrentCourseId == COURSE_KALAMARI_DESERT)) { - var_v1 = 0; - var_t0 = 0; - if (gCurrentCourseId == COURSE_KALAMARI_DESERT) { - D_801634EC = 0; - if (player->effects & 0x200) { - D_801634EC = 1; - } - if (gIsMirrorMode != 0) { - if (tempPos0 < 300.0f) { - var_v1 = 1; - var_t0 = 1; - } else if ((tempPos0 < 1300.0f) && (gLapCountByPlayerId[playerId] < 2) && ((D_801634EC == 1))) { - var_v1 = 1; - var_t0 = 1; - } - } else { - if (tempPos0 > -300.0f) { - var_v1 = 1; - var_t0 = 1; - } else { - if ((tempPos0 > -1300.0f) && (gLapCountByPlayerId[playerId] < 2) && (D_801634EC == 1)) { - var_v1 = 1; - var_t0 = 1; - } - } - } - } else { - var_v1 = 1; - var_t0 = 1; - } - someTemp0 = D_80163450[playerId]; - if ((var_v1 != 0) && (tempPos2 <= D_8016344C)) { - if (D_8016344C < someTemp0) { - gLapCountByPlayerId[playerId]++; - if ((gModeSelection == 0) && (gLapCountByPlayerId[playerId] == 5)) { - if (D_80164408[playerId] == 7) { - for (var_v0 = 0; var_v0 < 8; var_v0++) { - gLapCountByPlayerId[var_v0]--; - } - } - } - D_80163240[playerId] = 1; - func_80008F38(playerId); - reset_kart_ai_behaviour(playerId); - D_801642D8[playerId].unk_06 = 0; - if ((D_8016348C == 0) && !(player->type & 0x800)) { - gTimePlayerLastTouchedFinishLine[playerId] = func_80009258(playerId, someTemp0, tempPos2); - } - } - } - if ((var_t0 != 0) && (someTemp0 <= D_8016344C) && (D_8016344C < tempPos2)) { - gLapCountByPlayerId[playerId]--; - func_80008F38(playerId); - } - } - D_80163450[playerId] = tempPos2; - if ((gCurrentCourseId == COURSE_YOSHI_VALLEY) && (D_801630E2 == 1)) { - func_80009000(playerId); - if (((player->type & 0x4000) == 0) || (player->type & 0x1000)) { - func_800090F0(playerId, player); - } - } - if ((player->type & 0x4000) && !(player->type & 0x1000)) { - func_800065D0(playerId, player); - if ((gModeSelection == 0) && (gPlayerCount == 2) && (playerId == 0)) { - if (D_80164408[0] < D_80164408[1]) { - D_80163478 = 0; - } else { - D_80163478 = 1; - } - } - } else { - //???? - } - func_8000B95C(playerId, sSomeNearestWaypoint, D_80163448); -} -#else -GLOBAL_ASM("asm/non_matchings/code_80005FD0/func_8000929C.s") -#endif - -void update_vehicles(void) { - s32 i; - generate_player_smoke(); - D_8016337C++; - - if (gCurrentCourseId == COURSE_AWARD_CEREMONY) { - for (i = 0; i < 7; i++) { - func_8000DF8C(i); - } - return; - } - - if (D_8016337C & 1) { - if (gModeSelection == VERSUS) { - for (i = 0; i < 7; i++) { - func_8000DF8C(i); - } - } -#if !ENABLE_CUSTOM_COURSE_ENGINE - switch (gCurrentCourseId) { - case COURSE_KALAMARI_DESERT: - update_vehicle_trains(); - break; - case COURSE_DK_JUNGLE: - update_vehicle_paddle_boats(); - break; - case COURSE_TOADS_TURNPIKE: - update_vehicle_box_trucks(); - update_vehicle_school_bus(); - update_vehicle_tanker_trucks(); - update_vehicle_cars(); - break; - } -#else - -#endif - } -} - -void func_800098FC(s32 arg0, Player* player) { - if (D_80163398[arg0] >= 0xB) { - if ((player->effects & 0x80) || (player->effects & 0x40) || (player->effects & 0x20000)) { - func_800C92CC(arg0, 0x2900800AU); - D_80163398[arg0] = 0; - } - } - if (D_801633B0[arg0] >= 0xB) { - if ((player->soundEffects & 0x400000) || (player->soundEffects & 0x01000000) || (player->soundEffects & 2) || - (player->soundEffects & 4) || (player->effects & HIT_EFFECT)) { - func_800C92CC(arg0, 0x2900800BU); - D_801633B0[arg0] = 0; - } - } -} - -void func_800099EC(s32 playerId, UNUSED Player* unused) { - s32 var_s0; - - if (D_801633C8[playerId] >= 0x65) { - for (var_s0 = 0; var_s0 < gPlayerCount; var_s0++) { - if ((gGPCurrentRaceRankByPlayerId[playerId] < gGPCurrentRaceRankByPlayerId[var_s0]) && - (gGPCurrentRaceRankByPlayerId[playerId] == D_801643E0[var_s0]) && - (gGPCurrentRaceRankByPlayerId[var_s0] == D_801643E0[playerId])) { - func_800C92CC(playerId, 0x2900800DU); - D_801633C8[playerId] = 0; - } - } - } - if (D_801633C8[playerId] < 0x3E8) { - D_801633C8[playerId]++; - } - if (D_80163398[playerId] < 0xC8) { - D_80163398[playerId]++; - } - if (D_801633B0[playerId] < 0xC8) { - D_801633B0[playerId]++; - } -} - -#ifdef NON_MATCHING -#define FAKEMATCH1 0 -#define FAKEMATCH2 0 -// https://decomp.me/scratch/uJCh3 -// Lots of register allocation differences, but messing around seems to suggest they stem from 2 specific areas -// MISMATCH1: something about the loading of `playerId` is off -// MISMATCH2: something about the handling of the math is off. Not sure exactly what though -// MISMATCH3: there's a small instruction ordering issue concerning `gCourseMaxX`. No idea what to do about it -// FAKEMATCH1 is the best improvement I've seen yet, MISMATCH2/3 become the only issues. - -void func_80009B60(s32 playerId) { - UNUSED s32 stackPadding00; - UNUSED s32 stackPadding01; - UNUSED s32 stackPadding02; - UNUSED s32 stackPadding03; - UNUSED s32 stackPadding04; - UNUSED s32 stackPadding05; - UNUSED s32 stackPadding06; - UNUSED s32 stackPadding07; - UNUSED s32 stackPadding08; - UNUSED s32 stackPadding09; - UNUSED s32 stackPadding0A; - UNUSED s32 stackPadding0B; - UNUSED s32 stackPadding0C; - UNUSED s32 stackPadding0D; - s16 var_a0_2; - s16 var_a1; - UNUSED s32 stackPadding0E; - UNUSED s32 stackPadding0F; - UNUSED s32 stackPadding10; - UNUSED s32 stackPadding11; - UNUSED s32 stackPadding12; - UNUSED s32 stackPadding13; - UNUSED s32 stackPadding14; - UNUSED s32 stackPadding15; - UNUSED s32 stackPadding16; - UNUSED s32 stackPadding17; - UNUSED s32 stackPadding18; - u16 stackPadding19; - u16 stackPadding1A; - f32 temp_f0; - f32 temp_f2; - s16 var_a2; - s16 var_v1; - s32 temp_f6; - Player* player; - TrackWaypoint* waypoint; - f32 athing = 1.5f; - - player = &gPlayers[playerId]; - if ((s32) GET_COURSE_AIMaximumSeparation >= 0) { - D_80163100[playerId] += 1; - if (playerId == 0) { - D_80163378++; - if (D_80163378 & 1) { - D_80163488 += 1; - } - } - if (!(player->type & 0x8000)) { - D_80164450[playerId] = -0x00000014; - gCourseCompletionPercentByPlayerId[playerId] = -1000.0f; - gLapCompletionPercentByPlayerId[playerId] = -1000.0f; - return; - } - D_801633E0[playerId] = 0; - if (player->pos[0] < gCourseMinX) { - D_801633E0[playerId] = 1; - } - if (gCourseMaxX < player->pos[0]) { - D_801633E0[playerId] = 2; - } - if (player->pos[2] < gCourseMinZ) { - D_801633E0[playerId] = 3; - } - // MISMATCH3 - if (gCourseMaxZ < player->pos[2]) { - D_801633E0[playerId] = 4; - } - if (!(player->unk_0CA & 2) && !(player->unk_0CA & 8)) { - D_80163448 = gPathIndexByPlayerId[playerId]; - func_80008DC0(D_80163448); - switch (gCurrentCourseId) { /* irregular */ - case COURSE_KALAMARI_DESERT: - func_80012DC0(playerId, player); - if (playerId == 0) { - func_80013054(); - } - break; - case COURSE_DK_JUNGLE: - func_80013854(player); - break; - case COURSE_TOADS_TURNPIKE: - func_800148C4(playerId, player); - func_80014A18(playerId, player); - func_80014B6C(playerId, player); - func_80014CC0(playerId, player); - break; - } - if (player->type & 0x800) { - player->effects &= ~0x00400000; - player->unk_044 &= ~0x0001; - } - func_8000929C(playerId, player); - if ((gCurrentCourseId != COURSE_AWARD_CEREMONY) && ((D_80163240[playerId] == 1) || (playerId == 0))) { - set_places(); - } - if (player->type & 0x1000) { - if ((D_801630E2 == 1) && (gCurrentCourseId != COURSE_AWARD_CEREMONY)) { - kart_ai_behaviour(playerId); - } - if ((playerId & 1) != (D_80163378 & 1)) { - kart_ai_use_item_strategy(playerId); - } - func_800099EC(playerId, player); - D_80162FD0 = 0; - switch (gModeSelection) { /* switch 1; irregular */ - case 1: /* switch 1 */ - case 2: /* switch 1 */ - case 3: /* switch 1 */ - break; - case 0: /* switch 1 */ - break; - } - D_801631E0[playerId] = 0; - if ((player->effects & 0x1000) && (gCurrentCourseId != COURSE_AWARD_CEREMONY)) { - D_801631E0[playerId] = 1; - } - if ((D_801646CC == 1) || (player->type & 0x800) || (gCurrentCourseId == COURSE_AWARD_CEREMONY)) { - if (gCurrentCourseId != COURSE_TOADS_TURNPIKE) { - D_801634F8[playerId].unk4 = 0.0f; - } - D_801634F8[playerId].unkC = 0.0f; - } - if (D_80163448 > 0) { - D_801634F8[playerId].unk4 = 0.0f; - D_801634F8[playerId].unkC = 0.0f; - } - // gNearestWaypointByPlayerId[playerId] might need to be saved to a temp - D_80164510[playerId] = D_80164550[D_80163448][gNearestWaypointByPlayerId[playerId]].posY + 4.3f; - if ((D_801631F8[playerId] == 1) && (D_801631E0[playerId] == 0)) { - func_8002E4C4(player); - } - if (D_801631E0[playerId] == 1) { - player->pos[1] = D_80164510[playerId]; - } - D_801631F8[playerId] = D_801631E0[playerId]; - switch (gCurrentCourseId) { - case COURSE_YOSHI_VALLEY: - case COURSE_AWARD_CEREMONY: - D_801634F8[playerId].unk4 = 0.0f; - break; - default: - break; - case COURSE_SKYSCRAPER: - func_8001490C(playerId); - func_80014A60(playerId); - func_80014BB4(playerId); - func_80014D08(playerId); - break; - } - if (D_801631E0[playerId] == 1) { - D_801630E8[playerId] = 0; - player->effects &= ~0x10; - if ((playerId & 1) != (D_80163378 & 1)) { - func_8003680C(player, 0); - func_80008424(playerId, D_80163210[playerId], player); - return; - } - if ((gPlayerCount > 0) && (gPlayerCount < 3) && (D_80163330[playerId] == 1) && - (D_8016334C[playerId] < gGPCurrentRaceRankByPlayerId[playerId])) { - D_80163210[playerId] = 8.333333f; - } else if (D_80162FD0 == (s16) 1U) { - D_80163210[playerId] = GET_COURSE_D_0D0096B8(gCCSelection); - D_801634F8[playerId].unk4 = -0.5f; - } else if (D_801645E0[sSomeNearestWaypoint] > 0) { - D_80163210[playerId] = GET_COURSE_D_0D009418(gCCSelection); - } else { - D_80163210[playerId] = GET_COURSE_D_0D009568(gCCSelection); - } - check_ai_crossing_distance(playerId); - func_8000D3B8(playerId); - func_8000D438(playerId, D_801630E0); - temp_f0 = D_80162FA0[0] - player->pos[0]; - temp_f2 = D_80162FA0[2] - player->pos[2]; - if (!(player->effects & 0x80) && !(player->effects & 0x40) && !(player->effects & 0x800)) { - if (((temp_f0 * temp_f0) + (temp_f2 * temp_f2)) > 6400.0f) { - if (D_80163448 == 0) { - func_8000B140(playerId); - if (D_80162FF8[playerId] > 0) { - stackPadding1A = D_801630E0 + 5; - stackPadding1A %= D_80164430; - func_8000BBD8(stackPadding1A, D_80163090[playerId], D_80163448); - } - } - player->rotation[1] = -get_angle_between_two_vectors(player->pos, D_80162FA0); - } else { - player->rotation[1] = D_80164590[D_80163448][(D_801630E0 + 4) % D_80164430]; - } - } - func_8003680C(player, 0); - func_80008424(playerId, D_80163210[playerId], player); - return; - } - if ((D_801630E8[playerId] == 1) || (D_801630E8[playerId] == -1)) { - player->effects |= 0x10; - } - if (D_801630E8[playerId] != 0) { - D_80163300[playerId] = -get_angle_between_two_vectors(&player->oldPos[0], player->pos); - var_a0_2 = (D_801631DC[(sSomeNearestWaypoint + 2) % D_80164430] * 0x168) / 65535; - var_a1 = (D_80163300[playerId] * 0x168) / 65535; - if (var_a0_2 < -0xB4) { - var_a0_2 += 0x168; - } - if (var_a0_2 > 0xB4) { - var_a0_2 -= 0x168; - } - if (var_a1 < -0xB4) { - var_a1 += 0x168; - } - if (var_a1 > 0xB4) { - var_a1 -= 0x168; - } - var_v1 = var_a0_2 - var_a1; - if (var_v1 < -0xB4) { - var_v1 += 0x168; - } - if (var_v1 > 0xB4) { - var_v1 -= 0x168; - } - switch (D_801630E8[playerId]) { - case -1: - if (var_v1 > 5) { - D_801630E8[playerId] = 0; - player->effects &= ~0x10; - } - break; - case 1: - if (var_v1 < -5) { - D_801630E8[playerId] = 0; - player->effects &= ~0x10; - } - break; - default: - break; - } - } - // MISMATCH1 -#if FAKEMATCH2 == 1 - stackPadding00 = (playerId & 1) != (D_80163378 & 1); - if (stackPadding00) { -#else - if ((playerId & 1) != (D_80163378 & 1)) { -#endif - func_8003680C(player, D_80163050[playerId]); - func_80008424(playerId, D_80163210[playerId], player); - return; - } - D_801630B8[playerId] = func_8000B7E4(playerId, sSomeNearestWaypoint); - func_8000D438(playerId, sSomeNearestWaypoint); - if (gCurrentCourseId != COURSE_AWARD_CEREMONY) { - if (D_80164450[playerId] < 0xB) { - stackPadding1A = D_801630E0; - if ((D_80164450[playerId] > 0) && (gCurrentCourseId == COURSE_TOADS_TURNPIKE)) { - stackPadding1A += 0x14; - stackPadding1A %= D_80164430; - func_8000BBD8(stackPadding1A, 0.0f, 0); - D_801634F8[playerId].unk4 = 0.0f; - } else { - stackPadding1A += 8; - stackPadding1A %= D_80164430; - func_8000BBD8(stackPadding1A, D_80163068[playerId], D_80163448); - D_801634F8[playerId].unk0 = D_80163068[playerId]; - } - } - if ((D_80162FD0 == 1) && (D_80162FF8[playerId] == 0)) { - stackPadding1A = D_801630E0 + 7; - stackPadding1A %= D_80164430; - func_8000BBD8(stackPadding1A, -0.7f, D_80163448); - } - if (D_80163448 == 0) { - func_8000B140(playerId); - if (D_80162FF8[playerId] > 0) { - stackPadding1A = D_801630E0 + 5; -#if FAKEMATCH1 == 1 - if (1) {} - if (1) {} - if (1) {} - if (1) {} - if (1) {} - if (1) {} -#endif - stackPadding1A %= D_80164430; - func_8000BBD8(stackPadding1A, D_80163090[playerId], D_80163448); - } - } - } - if (gCurrentCourseId == COURSE_AWARD_CEREMONY) { - switch (D_80163410[playerId]) { /* switch 3; irregular */ - case 3: /* switch 3 */ - D_80162FA0[0] = D_80163418[playerId]; - D_80162FA0[2] = D_80163438[playerId]; - break; - case 4: /* switch 3 */ - waypoint = &D_80164550[playerId][(gNearestWaypointByPlayerId[playerId] + 0xA) % - gWaypointCountByPathIndex[playerId]]; - D_80162FA0[0] = waypoint->posX; - D_80162FA0[2] = waypoint->posZ; - break; - } - } - D_80162FA0[0] = (D_80163178[playerId] + D_80162FA0[0]) * 0.5f; - D_80162FA0[2] = (D_801631A0[playerId] + D_80162FA0[2]) * 0.5f; - D_80163178[playerId] = D_80162FA0[0]; - D_801631A0[playerId] = D_80162FA0[2]; - temp_f2 = athing * 182.0f; - temp_f6 = -athing * 182.0f; - // MISMATCH2 - // This fixes part of the register allocation problems, makes fixing others - // harder though. Needs more investigation - // var_a2 = (-get_angle_between_two_vectors(player->pos, D_80162FA0)) - (var_a1 = player->rotation[1]); - stackPadding19 = -get_angle_between_two_vectors(player->pos, D_80162FA0) - player->rotation[1]; - var_a1 = stackPadding19; - var_a2 = var_a1; - if ((s16) temp_f2 < var_a1) { - var_a2 = temp_f2; - } - if (var_a2 < (s16) temp_f6) { - var_a2 = temp_f6; - } - var_v1 = GET_COURSE_AISteeringSensitivity; - switch (D_801631D8[playerId]) { /* switch 4; irregular */ - case 2: /* switch 4 */ - if (D_80163068[playerId] > (0.5f * 1.0f)) { - var_v1 = 0x0014; - } - if (D_80163068[playerId] < -0.5f) { - var_v1 = 0x0035; - } - break; - case 3: /* switch 4 */ - if (D_80163068[playerId] > 0.5f) { - var_v1 = 0x0035; - } - if (D_80163068[playerId] < -0.5f) { - var_v1 = 0x0014; - } - break; - } - if ((gKartAIBehaviourState[playerId] == KART_AI_BEHAVIOUR_STATE_RUNNING) && - ((D_80163068[playerId] > 0.9f) || (D_80163068[playerId] < -0.9f))) { - D_801630E8[playerId] = 0; - player->effects &= ~0x10; - } - if (player->effects & 2) { - switch (D_801630E8[playerId]) { - case 1: - var_a1 = 0x0035; - break; - case -1: - var_a1 = -0x0035; - break; - default: - var_a1 = (D_80163050[playerId] + ((var_a2 * var_v1) / temp_f2)) / 2; - break; - } - } else if (player->effects & 0x1000000C) { - var_a1 = 0; - } else { - var_a1 = (D_80163050[playerId] + ((var_a2 * var_v1) / temp_f2)) / 2; - } - func_8003680C(player, var_a1); - D_80163050[playerId] = var_a1; - if ((D_801630B8[playerId] == 1) || (D_801630E8[playerId] == 1) || (D_801630E8[playerId] == -1) || - (player->effects & 0x1000000C)) { - D_80163028[playerId] = GET_COURSE_D_0D009418(gCCSelection); - } else { - D_80163028[playerId] = GET_COURSE_D_0D009568(gCCSelection); - } - if ((D_80163068[playerId] > 0.9f) || (D_80163068[playerId] < -0.9f)) { - D_80163028[playerId] = GET_COURSE_D_0D009808(gCCSelection); - } - if (D_80162FD0 == 1) { - D_80163028[playerId] = GET_COURSE_D_0D0096B8(gCCSelection); - } - if ((D_801630E8[playerId] == 2) || (D_801630E8[playerId] == -2) || (D_801630E8[playerId] == 3)) { - D_80163028[playerId] = 3.3333333f; - } - D_8016320C = D_80163028[playerId]; - player->effects &= ~0x00200000; - D_80163210[playerId] = D_8016320C; - check_ai_crossing_distance(playerId); - func_80008424(playerId, D_8016320C, player); - } - } - } -} -#undef FAKEMATCH1 -#undef FAKEMATCH2 -#else -GLOBAL_ASM("asm/non_matchings/code_80005FD0/func_80009B60.s") -#endif - -#ifdef NON_MATCHING -// Lots of work left to do, might be funtionally accurate? -void func_8000B140(s32 playerId) { - UNUSED f32 stackPadding0; - UNUSED f32 stackPadding1; - UNUSED f32 stackPadding2; - UNUSED f32 stackPadding3; - UNUSED f32 stackPadding4; - UNUSED f32 stackPadding5; - UNUSED f32 stackPadding6; - UNUSED f32 stackPadding7; - f32 temp_f0_2; - f32 temp_f12; - f32 temp_f14; - f32 temp_f16; - f32 temp_f22; - f32 temp_f2; - f32 var_f18; - f32 var_f20; - s16 spB0[8]; - UNUSED f32 stackPadding8; - s16 sp9C[8]; - UNUSED f32 stackPadding9; - f32 sp74[8]; - s32 temp_a1_2; - s16 temp_v1_2; - s16 var_t1; - s32 var_t2; - s32 someIndex; - Player* player; - - player = &gPlayers[playerId]; - if (!(player->effects & 0x10) && (D_801630E8[playerId] != 1) && (D_801630E8[playerId] != -1) && - !(D_80163068[playerId] < -1.0f) && !(D_80163068[playerId] > 1.0f) && (player->characterId != 5) && - (player->characterId != 7) && (player->characterId != 4) && !(player->effects & STAR_EFFECT)) { - var_t1 = gNearestWaypointByPlayerId[playerId]; - temp_f22 = (player->unk_094 / 18.0f) * 216.0f; - for (someIndex = 0; someIndex < 8; someIndex++) { - sp9C[someIndex] = -1; - spB0[someIndex] = 0x03E8; - } - if (D_80163010[playerId] > 0) { - D_80163010[playerId]--; - if (D_80163010[playerId] <= 0) { - D_80162FF8[playerId] = 0; - } - } - var_t2 = 0; - for (someIndex = 0; (var_t2 < 2) && (someIndex < 8); someIndex++) { - if (someIndex == playerId) - continue; - player = &gPlayers[someIndex]; - if (!(player->type & 0x8000)) - continue; - temp_f2 = (temp_f22) -5.0f; - temp_v1_2 = gNearestWaypointByPlayerId[someIndex]; - temp_f0_2 = (player->unk_094 / 18.0f) * 216.0f; - if (temp_f0_2 < temp_f2) { - if (func_80007BF8(temp_v1_2, var_t1, 0U, 0x0014U, D_80164430) > 0) { - temp_a1_2 = temp_v1_2 - var_t1; - sp9C[var_t2] = someIndex; - if (temp_a1_2 > 0) { - spB0[var_t2] = temp_a1_2; - } else { - spB0[var_t2] = (temp_v1_2 + D_80164430) - var_t1; - } - sp74[var_t2] = temp_f2 - temp_f0_2; - var_t2 += 1; - } - } - } - if (var_t2 != 0) { - var_f18 = 1.0f; - var_f20 = -1.0f; - for (someIndex = 0; someIndex < var_t2; someIndex++) { - temp_f2 = D_80163068[sp9C[someIndex]]; - if ((temp_f2 > -1.0f) && (temp_f2 < 1.0f)) { - temp_f12 = sp74[someIndex] + 10.0f; - temp_f12 *= 0.2f * (20.0f / (spB0[someIndex] + 20.0f)); - temp_f12 /= 20.0f; - if ((var_f18 == 1.0f) && (var_f20 == -1.0f)) { - var_f18 = temp_f2 - temp_f12; - var_f20 = temp_f2 + temp_f12; - } else { - temp_f14 = temp_f2 - temp_f12; - temp_f16 = temp_f2 + temp_f12; - if ((temp_f14 < 1.0f) && (temp_f16 > 1.0f)) { - var_f18 = temp_f14; - } - if ((temp_f16 > -1.0f) && (temp_f14 < -1.0f)) { - var_f20 = temp_f16; - } - } - } - } - if (!(var_f20 < var_f18) && !(D_80163068[playerId] < var_f18) && !(var_f20 < D_80163068[playerId])) { - if (var_f20 > 1.0f) { - var_f20 = 1.0f; - } - if (var_f18 < -1.0f) { - var_f18 = -1.0f; - } - if ((var_f18 + 1.0f) < (1.0f - var_f20)) { - D_80163010[playerId] = 0x003C; - D_80162FF8[playerId] = 1; - D_80163090[playerId] = var_f20; - } else { - D_80163010[playerId] = 0x003C; - D_80162FF8[playerId] = 2; - D_80163090[playerId] = var_f18; - } - } - } - } -} -#else -GLOBAL_ASM("asm/non_matchings/code_80005FD0/func_8000B140.s") -#endif - -s32 func_8000B7E4(UNUSED s32 arg0, u16 waypointIndex) { - s16 thing = D_801645E0[waypointIndex]; - if (thing > 0) { - return 1; - } - return 0; -} - -s32 func_8000B820(s32 playerIndex) { - f32 value = D_80163068[playerIndex]; - if ((1.1f <= value) || (value <= -1.1f)) { - return 1; - } - return 0; -} - -f32 func_8000B874(f32 posX, f32 posZ, u16 waypointIndex, s32 pathIndex) { - f32 x1; - f32 z1; - f32 x2; - f32 z2; - f32 squaredDistance; - f32 math; - TrackWaypoint* thing1; - TrackWaypoint* thing2; - - thing1 = &D_80164560[pathIndex][waypointIndex]; - thing2 = &D_80164570[pathIndex][waypointIndex]; - - x1 = thing1->posX; - z1 = thing1->posZ; - x2 = thing2->posX; - z2 = thing2->posZ; - - squaredDistance = ((x2 - x1) * (x2 - x1)) + ((z2 - z1) * (z2 - z1)); - if (squaredDistance < 0.01f) { - return 0.0f; - } - math = ((2.0f * ((x2 - x1) * (posX - x1) + (z2 - z1) * (posZ - z1))) / squaredDistance) - 1.0f; - return math; -} - -void func_8000B95C(s32 playerId, u16 waypointIndex, s32 pathIndex) { - UNUSED Vec3f pad; - D_80163068[playerId] = 0.0f; - if ((s32) GET_COURSE_AIMaximumSeparation >= 0) { - if ((gPlayers[playerId].type & 0x8000) != 0) { - D_80163068[playerId] = - func_8000B874(gPlayers[playerId].pos[0], gPlayers[playerId].pos[2], waypointIndex, pathIndex); - } - } -} - -void func_8000BA14(u16 waypointIndex, f32 arg1, f32 arg2, s16 pathIndex) { - UNUSED s32 pad[4]; - f32 waypointOneX; - f32 waypointOneZ; - f32 waypointTwoX; - f32 waypointTwoZ; - UNUSED s32 pad2; - f32 xdiff; - f32 zdiff; - f32 distance; - UNUSED f32 temp_f12; - UNUSED f32 temp_f2_2; - UNUSED TrackWaypoint* path; - TrackWaypoint* waypointTwo; - TrackWaypoint* waypointOne; - - waypointOne = &D_80164550[pathIndex][waypointIndex]; - waypointOneX = waypointOne->posX; - waypointOneZ = waypointOne->posZ; - waypointTwo = &D_80164550[pathIndex][(waypointIndex + 1) % D_80164430]; - waypointTwoX = waypointTwo->posX; - waypointTwoZ = waypointTwo->posZ; - zdiff = waypointTwoZ - waypointOneZ; - xdiff = waypointTwoX - waypointOneX; - if (xdiff && xdiff) {} - distance = sqrtf((xdiff * xdiff) + (zdiff * zdiff)); - if (distance < 0.01f) { - D_80162FA0[0] = waypointTwoX; - D_80162FA0[2] = waypointTwoZ; - } else { - D_80162FA0[0] = ((0.5f - (arg1 * 0.5f)) * (((arg2 * zdiff) / distance) + waypointOneX)) + - ((1.0f - (0.5f - (arg1 * 0.5f))) * (((arg2 * -zdiff) / distance) + waypointOneX)); - D_80162FA0[2] = ((0.5f - (arg1 * 0.5f)) * (((arg2 * -xdiff) / distance) + waypointOneZ)) + - ((1.0f - (0.5f - (arg1 * 0.5f))) * (((arg2 * xdiff) / distance) + waypointOneZ)); - } -} - -void func_8000BBD8(u16 waypointIndex, f32 arg1, s16 pathIndex) { - TrackWaypoint* path1; - TrackWaypoint* path2; - f32 x1; - f32 z1; - f32 x3; - f32 z3; - f32 x2; - f32 z2; - f32 x4; - f32 z4; - f32 temp_f0; - f32 temp_f12; - - path1 = &D_80164560[pathIndex][waypointIndex]; - path2 = &D_80164570[pathIndex][waypointIndex]; - - x1 = (f32) path1->posX; - z1 = (f32) path1->posZ; - - x2 = (f32) path2->posX; - z2 = (f32) path2->posZ; - - waypointIndex += 1; - waypointIndex = waypointIndex % gWaypointCountByPathIndex[pathIndex]; - - path1 = &D_80164560[pathIndex][waypointIndex]; - path2 = &D_80164570[pathIndex][waypointIndex]; - - x3 = (f32) path1->posX; - z3 = (f32) path1->posZ; - - x4 = (f32) path2->posX; - z4 = (f32) path2->posZ; - - temp_f0 = 0.5f - (arg1 / 2.0f); - temp_f12 = 1.0f - temp_f0; - D_80162FA0[0] = ((temp_f0 * (x1 + x3)) / 2.0f) + ((temp_f12 * (x2 + x4)) / 2.0f); - D_80162FA0[2] = ((temp_f0 * (z1 + z3)) / 2.0f) + ((temp_f12 * (z2 + z4)) / 2.0f); -} - -s16 func_8000BD94(f32 posX, f32 posY, f32 posZ, s32 pathIndex) { - f32 x_dist; - f32 y_dist; - f32 z_dist; - f32 considerSquaredDistance; - f32 minimumSquaredDistance; - s32 considerWaypointIndex; - s32 pathWaypointCount; - s16 nearestWaypointIndex; - TrackWaypoint* pathWaypoints; - TrackWaypoint* considerWaypoint; - - pathWaypoints = D_80164550[pathIndex]; - pathWaypointCount = gWaypointCountByPathIndex[pathIndex]; - considerWaypoint = &pathWaypoints[0]; - x_dist = (f32) considerWaypoint->posX - posX; - y_dist = (f32) considerWaypoint->posY - posY; - z_dist = (f32) considerWaypoint->posZ - posZ; - minimumSquaredDistance = (x_dist * x_dist) + (y_dist * y_dist) + (z_dist * z_dist); - nearestWaypointIndex = 0; - for (considerWaypointIndex = 1; considerWaypointIndex < pathWaypointCount; - considerWaypoint++, considerWaypointIndex++) { - x_dist = (f32) considerWaypoint->posX - posX; - y_dist = (f32) considerWaypoint->posY - posY; - z_dist = (f32) considerWaypoint->posZ - posZ; - considerSquaredDistance = (x_dist * x_dist) + (y_dist * y_dist) + (z_dist * z_dist); - if (considerSquaredDistance < minimumSquaredDistance) { - nearestWaypointIndex = considerWaypointIndex; - minimumSquaredDistance = considerSquaredDistance; - } - } - return nearestWaypointIndex; -} - -s16 find_closest_waypoint_track_section(f32 posX, f32 posY, f32 posZ, u16 trackSectionId, s32* pathIndex) { - TrackWaypoint* pathWaypoints; - TrackWaypoint* considerWaypoint; - f32 x_dist; - f32 y_dist; - f32 z_dist; - f32 considerSquaredDistance; - f32 minimumSquaredDistance; - s32 considerWaypointIndex; - s32 pathWaypointCount; - s32 temp_t0; - s32 var_a1; - s32 var_t1; - s32 considerPathIndex; - s32 var_t4; - s16 nearestWaypointIndex; - - minimumSquaredDistance = 1000000.0f; - temp_t0 = *pathIndex; - nearestWaypointIndex = 0; - var_t1 = 0; - var_a1 = 0; - pathWaypoints = D_80164550[temp_t0]; - pathWaypointCount = gWaypointCountByPathIndex[temp_t0]; - considerWaypoint = &pathWaypoints[0]; - for (considerWaypointIndex = 0; considerWaypointIndex < pathWaypointCount; - considerWaypointIndex++, considerWaypoint++) { - if ((considerWaypoint->trackSectionId == trackSectionId) || (gCurrentCourseId == COURSE_AWARD_CEREMONY)) { - var_t1 = 1; - x_dist = (f32) considerWaypoint->posX - posX; - y_dist = (f32) considerWaypoint->posY - posY; - z_dist = (f32) considerWaypoint->posZ - posZ; - considerSquaredDistance = (x_dist * x_dist) + (y_dist * y_dist) + (z_dist * z_dist); - if (considerSquaredDistance < minimumSquaredDistance) { - nearestWaypointIndex = considerWaypointIndex; - var_a1 = 1; - minimumSquaredDistance = considerSquaredDistance; - } - } - } - if (var_t1 == 0) { - for (considerPathIndex = 0; considerPathIndex < 4; considerPathIndex++) { - if ((considerPathIndex != temp_t0) && (D_80163368[considerPathIndex] >= 2)) { - pathWaypoints = D_80164550[considerPathIndex]; - considerWaypoint = &pathWaypoints[0]; - pathWaypointCount = gWaypointCountByPathIndex[considerPathIndex]; - for (considerWaypointIndex = 0; considerWaypointIndex < pathWaypointCount; - considerWaypointIndex++, considerWaypoint++) { - if (considerWaypoint->trackSectionId == trackSectionId) { - x_dist = (f32) considerWaypoint->posX - posX; - y_dist = (f32) considerWaypoint->posY - posY; - z_dist = (f32) considerWaypoint->posZ - posZ; - considerSquaredDistance = (x_dist * x_dist) + (y_dist * y_dist) + (z_dist * z_dist); - if (considerSquaredDistance < minimumSquaredDistance) { - nearestWaypointIndex = considerWaypointIndex; - var_t4 = considerPathIndex; - var_a1 = 2; - minimumSquaredDistance = considerSquaredDistance; - } - } - } - } - } - } - if (var_a1 == 0) { - pathWaypoints = D_80164550[0]; - pathWaypointCount = gWaypointCountByPathIndex[0]; - considerWaypoint = &pathWaypoints[0]; - x_dist = (f32) considerWaypoint->posX - posX; - y_dist = (f32) considerWaypoint->posY - posY; - z_dist = (f32) considerWaypoint->posZ - posZ; - minimumSquaredDistance = (x_dist * x_dist) + (y_dist * y_dist) + (z_dist * z_dist); - nearestWaypointIndex = 0; - for (considerWaypointIndex = 1; considerWaypointIndex < pathWaypointCount; - considerWaypoint++, considerWaypointIndex++) { - x_dist = (f32) considerWaypoint->posX - posX; - y_dist = (f32) considerWaypoint->posY - posY; - z_dist = (f32) considerWaypoint->posZ - posZ; - considerSquaredDistance = (x_dist * x_dist) + (y_dist * y_dist) + (z_dist * z_dist); - if (considerSquaredDistance < minimumSquaredDistance) { - nearestWaypointIndex = considerWaypointIndex; - var_t4 = 0; - var_a1 = 2; - minimumSquaredDistance = considerSquaredDistance; - } - } - } - if (var_a1 == 2) { - *pathIndex = var_t4; - } - return nearestWaypointIndex; -} - -/** - * Tries to find the waypoint nearest to (posX, posY, posZ) - * Only consider waypoints in the same segment as trackSectionId - * Only considers waypoints within 500 units of(posX, posY, posZ) - * Looks 3 waypoints behind and 6 waypoints ahead of waypointIndex - **/ -s16 func_8000C884(f32 posX, f32 posY, f32 posZ, s16 waypointIndex, s32 pathIndex, u16 trackSectionId) { - s16 nearestWaypointIndex; - s16 searchIndex; - s16 considerIndex; - s32 pathWaypointCount; - f32 x_dist; - f32 y_dist; - f32 z_dist; - f32 minimumDistance; - f32 squaredDistance; - TrackWaypoint* pathWaypoints; - TrackWaypoint* considerWaypoint; - - nearestWaypointIndex = -1; - minimumDistance = 250000.0f; - pathWaypointCount = gWaypointCountByPathIndex[pathIndex]; - pathWaypoints = D_80164550[pathIndex]; - for (searchIndex = waypointIndex - 3; searchIndex < waypointIndex + 7; searchIndex++) { - // Its possible for searchIndex to be less than 0 or greater than the number of waypoints in a given path - // This is done to ensure we access D_80164550 at a valid index - considerIndex = (searchIndex + pathWaypointCount) % pathWaypointCount; - considerWaypoint = &pathWaypoints[considerIndex]; - if (considerWaypoint->trackSectionId == trackSectionId) { - x_dist = considerWaypoint->posX - posX; - y_dist = considerWaypoint->posY - posY; - z_dist = considerWaypoint->posZ - posZ; - squaredDistance = (x_dist * x_dist) + (y_dist * y_dist) + (z_dist * z_dist); - if (squaredDistance < minimumDistance) { - minimumDistance = squaredDistance; - nearestWaypointIndex = considerIndex; - } - } - } - return nearestWaypointIndex; -} - -/** - * Tries to find the waypoint nearest to (posX, posY, posZ) - * Only considers waypoints within 400 units of (posX, posY, posZ) - * Looks 3 waypoints behind and 6 waypoints ahead of waypointIndex - **/ -s16 find_closest_waypoint_with_previous_waypoint(f32 posX, f32 posY, f32 posZ, s16 waypointIndex, s32 pathIndex) { - s16 nearestWaypointIndex; - s16 searchIndex; - s16 considerIndex; - s32 waypointFound; - s32 pathWaypointCount; - f32 x_dist; - f32 y_dist; - f32 z_dist; - f32 minimumDistance; - f32 squaredDistance; - TrackWaypoint* pathWaypoints; - TrackWaypoint* considerWaypoint; - - waypointFound = 0; - nearestWaypointIndex = -1; - minimumDistance = 160000.0f; - pathWaypointCount = gWaypointCountByPathIndex[pathIndex]; - pathWaypoints = D_80164550[pathIndex]; - for (searchIndex = waypointIndex - 3; searchIndex < waypointIndex + 7; searchIndex++) { - // Its possible for searchIndex to be less than 0 or greater than the number of waypoints in a given path - // This is done to ensure we access D_80164550 at a valid index - considerIndex = (searchIndex + pathWaypointCount) % pathWaypointCount; - considerWaypoint = &pathWaypoints[considerIndex]; - x_dist = considerWaypoint->posX - posX; - y_dist = considerWaypoint->posY - posY; - z_dist = considerWaypoint->posZ - posZ; - squaredDistance = (x_dist * x_dist) + (y_dist * y_dist) + (z_dist * z_dist); - if (squaredDistance < minimumDistance) { - minimumDistance = squaredDistance; - nearestWaypointIndex = considerIndex; - waypointFound = 1; - } - } - if (waypointFound == 0) { - for (searchIndex = waypointIndex - 3; searchIndex < waypointIndex + 7; searchIndex++) { - considerIndex = ((searchIndex + pathWaypointCount) % pathWaypointCount); - considerWaypoint = &pathWaypoints[considerIndex]; - /** - * This fake match is done to stop the compiler from optimzing out considerWaypoint. - * Maybe if no waypoint was found some debugging info was printed out, but come - * production time they removed the debug printing but not the loop? - **/ - if (considerWaypoint && considerWaypoint) {}; - } - } - return nearestWaypointIndex; -} - -void func_8000CBA4(UNUSED f32 posX, f32 posY, UNUSED f32 posZ, s16* waypointIndex, UNUSED s32 arg4) { - s16 var_v0; - - var_v0 = *waypointIndex; - if ((gCurrentCourseId == COURSE_WARIO_STADIUM) && (var_v0 >= 0x475) && (var_v0 < 0x480) && (posY < 0.0f)) { - var_v0 = 0x0398; - } - *waypointIndex = var_v0; -} - -void func_8000CBF8(UNUSED f32 posX, UNUSED f32 posY, f32 posZ, s16* waypointIndex, s32 pathIndex) { - s16 temp; - temp = *waypointIndex; - if (temp == 0) { - if (D_8016344C < posZ) { - temp = gWaypointCountByPathIndex[pathIndex] - 1; - } - } else if (((temp + 1) == gWaypointCountByPathIndex[pathIndex]) && (posZ <= D_8016344C)) { - temp = 0; - } - *waypointIndex = temp; -} - -s16 func_8000CC88(f32 posX, f32 posY, f32 posZ, Player* player, s32 playerId, s32* pathIndex) { - u16 trackSectionId; - s16 ret; - - trackSectionId = get_track_section_id(player->collision.meshIndexZX); - if ((trackSectionId <= 0) || (trackSectionId >= 0x33)) { - trackSectionId = D_80163318[playerId]; - } - D_80163318[playerId] = trackSectionId; - ret = find_closest_waypoint_track_section(posX, posY, posZ, trackSectionId, pathIndex); - gPathIndexByPlayerId[playerId] = *pathIndex; - return ret; -} - -s16 func_8000CD24(f32 posX, f32 posY, f32 posZ, s16 waypointIndex, Player* player, s32 playerId, s32 pathIndex) { - s16 newWaypoint; - UNUSED s16 stackPadding0; - UNUSED s32 stackPadding1; - UNUSED s32 stackPadding2; - TrackWaypoint* temp_v1; - - if ((player->type & 0x4000) && !(player->type & 0x1000)) { - newWaypoint = func_8000C884(posX, posY, posZ, waypointIndex, pathIndex, - (u16) get_track_section_id(player->collision.meshIndexZX)); - if (newWaypoint == -1) { - newWaypoint = func_8000CC88(posX, posY, posZ, player, playerId, &pathIndex); - } - } else { - if (D_801631E0[playerId] == 1) { - if (player->unk_0CA & 1) { - temp_v1 = &D_80164550[pathIndex][waypointIndex]; - player->pos[0] = (f32) temp_v1->posX; - player->pos[1] = (f32) temp_v1->posY; - player->pos[2] = (f32) temp_v1->posZ; - player->unk_0CA &= ~0x0001; - return waypointIndex; - } - if (playerId == ((s32) D_80163488 % 8)) { - check_bounding_collision(&player->collision, 10.0f, posX, posY, posZ); - D_80163318[playerId] = get_track_section_id(player->collision.meshIndexZX); - newWaypoint = func_8000C884(posX, posY, posZ, waypointIndex, pathIndex, D_80163318[playerId]); - if (newWaypoint == -1) { - newWaypoint = - find_closest_waypoint_with_previous_waypoint(posX, posY, posZ, waypointIndex, pathIndex); - } - if (newWaypoint == -1) { - newWaypoint = - find_closest_waypoint_track_section(posX, posY, posZ, D_80163318[playerId], &pathIndex); - temp_v1 = &D_80164550[pathIndex][newWaypoint]; - player->pos[0] = (f32) temp_v1->posX; - player->pos[1] = (f32) temp_v1->posY; - player->pos[2] = (f32) temp_v1->posZ; - } - } else { - newWaypoint = find_closest_waypoint_with_previous_waypoint(posX, posY, posZ, waypointIndex, pathIndex); - if (newWaypoint == -1) { - newWaypoint = func_8000BD94(posX, posY, posZ, pathIndex); - temp_v1 = &D_80164550[pathIndex][newWaypoint]; - posX = (f32) temp_v1->posX; - posY = (f32) temp_v1->posY; - posZ = (f32) temp_v1->posZ; - player->pos[0] = posX; - player->pos[1] = posY; - player->pos[2] = posZ; - check_bounding_collision(&player->collision, 10.0f, posX, posY, posZ); - D_80163318[playerId] = get_track_section_id(player->collision.meshIndexZX); - } - } - } else { - newWaypoint = find_closest_waypoint_with_previous_waypoint(posX, posY, posZ, waypointIndex, pathIndex); - if (newWaypoint == -1) { - newWaypoint = func_8000CC88(posX, posY, posZ, player, playerId, &pathIndex); - } - } - func_8000CBA4(posX, posY, posZ, &newWaypoint, pathIndex); - } - func_8000CBF8(posX, posY, posZ, &newWaypoint, pathIndex); - return newWaypoint; -} - -s16 find_closest_vehicles_waypoint(f32 xPos, UNUSED f32 yPos, f32 zPos, s16 waypointIndex) { - f32 xdiff; - f32 zdiff; - f32 minimumDistance; - f32 considerSquaredDistance; - s16 realIndex; - s16 minimumIndex; - s16 considerIndex; - Path2D* considerWaypoint; - - minimumDistance = 250000.0f; - minimumIndex = -1; - for (realIndex = waypointIndex - 2; realIndex < waypointIndex + 7; realIndex++) { - considerIndex = realIndex; - if (realIndex < 0) { - considerIndex = realIndex + gVehicle2DWaypointLength; - } - considerIndex %= gVehicle2DWaypointLength; - considerWaypoint = &gVehicle2DWaypoint[considerIndex]; - xdiff = considerWaypoint->x - xPos; - zdiff = considerWaypoint->z - zPos; - considerSquaredDistance = (xdiff * xdiff) + (zdiff * zdiff); - if (considerSquaredDistance < minimumDistance) { - minimumDistance = considerSquaredDistance; - minimumIndex = considerIndex; - } - } - if (minimumIndex == -1) { - minimumIndex = waypointIndex; - } - return minimumIndex; -} - -s16 func_8000D24C(f32 posX, f32 posY, f32 posZ, s32* pathIndex) { - UNUSED s32 pad; - Collision sp24; - - check_bounding_collision(&sp24, 10.0f, posX, posY, posZ); - return find_closest_waypoint_track_section(posX, posY, posZ, get_track_section_id(sp24.meshIndexZX), pathIndex); -} - -s16 func_8000D2B4(f32 posX, f32 posY, f32 posZ, s16 waypointIndex, s32 pathIndex) { - s16 waypoint; - - waypoint = find_closest_waypoint_with_previous_waypoint(posX, posY, posZ, waypointIndex, pathIndex); - if (waypoint == -1) { - waypoint = func_8000D24C(posX, posY, posZ, &pathIndex); - } - func_8000CBF8(posX, posY, posZ, &waypoint, pathIndex); - return waypoint; -} - -s16 func_8000D33C(f32 posX, f32 posY, f32 posZ, s16 waypointIndex, s32 pathIndex) { - s16 waypoint; - - waypoint = find_closest_waypoint_with_previous_waypoint(posX, posY, posZ, waypointIndex, pathIndex); - if (waypoint == -1) { - waypoint = func_8000D24C(posX, posY, posZ, &pathIndex); - } - return waypoint; -} - -f32 func_8000D3B8(s32 playerId) { - Test* temp_v0; - f32 temp_f0; - f32 var_f2; - - temp_v0 = &D_801634F8[playerId]; - var_f2 = temp_v0->unk0; - temp_f0 = temp_v0->unk4; - if (var_f2 < temp_f0) { - var_f2 += temp_v0->unk8; - if (temp_f0 < var_f2) { - var_f2 = temp_f0; - } - } else if (temp_f0 < var_f2) { - var_f2 -= temp_v0->unk8; - if (var_f2 < temp_f0) { - var_f2 = temp_f0; - } - } - temp_v0->unk0 = var_f2; - return var_f2; -} - -void func_8000D438(s32 arg0, u16 arg1) { - UNUSED s32 stackPadding0; - f32 sp48; - f32 sp44; - UNUSED s32 stackPadding1; - UNUSED s32 stackPadding2; - UNUSED s32 stackPadding3; - f32 stackPadding4; - f32 stackPadding5; - f32 sp2C; - s32 var_a2; - s16 temp_v1; - u16 thing; - - temp_v1 = D_801645E0[arg1]; - var_a2 = 6; - sp2C = func_8000D3B8(arg0); - thing = arg1; - - switch (gCurrentCourseId) { - case COURSE_AWARD_CEREMONY: - var_a2 = 1; - break; - case COURSE_TOADS_TURNPIKE: - var_a2 = 7; - break; - case COURSE_YOSHI_VALLEY: - break; - default: - if (temp_v1 < 6) { - var_a2 = 8; - } else if (temp_v1 >= 0x15) { - var_a2 = 20; - } - break; - } - - if (var_a2 >= 8) { - if ((D_80163068[arg0] > 0.75f) && (D_801631D8[thing] == 0)) { - var_a2 = 7; - } - if ((D_80163068[arg0] < -0.75f) && (D_801631D8[thing] == 1)) { - var_a2 = 7; - } - } - if (func_8000B820(arg0) == 1) { - var_a2 = 5; - } - if (D_80163380[arg0] < var_a2) { - D_80163380[arg0]++; - } - if (var_a2 < D_80163380[arg0]) { - D_80163380[arg0]--; - } - arg1 = (D_80163380[arg0] + arg1) % D_80164430; - func_8000BBD8(arg1, sp2C, D_80163448); - sp48 = D_80162FA0[0]; - sp44 = D_80162FA0[2]; - func_8000BBD8(((arg1 + 1) % D_80164430) & 0xFFFF, sp2C, D_80163448); - stackPadding5 = D_80162FA0[0]; - D_80162FA0[0] = (sp48 + stackPadding5) * 0.5f; - stackPadding4 = D_80162FA0[2]; - D_80162FA0[2] = (sp44 + stackPadding4) * 0.5f; -} - -s16 func_8000D6D0(Vec3f position, s16* waypointIndex, f32 speed, f32 arg3, s16 pathIndex, s16 arg5) { - f32 temp1; - f32 temp2; - f32 midX; - UNUSED s16 stackPadding1; - s16 waypoint1; - s16 waypoint2; - f32 pad3; - f32 midY; - f32 pad4; - f32 midZ; - f32 distance; - f32 oldPosX; - f32 oldPosY; - f32 oldPosZ; - f32 var_f2; - f32 var_f12; - f32 var_f14; - s16 temp_v0; - s32 temp_v1; - f32 xdiff; - f32 ydiff; - f32 zdiff; - Vec3f oldPos; - TrackWaypoint* path; - - path = D_80164550[pathIndex]; - oldPos[0] = position[0]; - oldPos[1] = position[1]; - oldPos[2] = position[2]; - oldPosX = position[0]; - oldPosY = position[1]; - oldPosZ = position[2]; - temp_v0 = func_8000D2B4(oldPosX, oldPosY, oldPosZ, *waypointIndex, (s32) pathIndex); - *waypointIndex = temp_v0; - temp_v1 = temp_v0 + arg5; - waypoint1 = temp_v1 % gWaypointCountByPathIndex[pathIndex]; - waypoint2 = (temp_v1 + 1) % gWaypointCountByPathIndex[pathIndex]; - func_8000BBD8(waypoint1, arg3, pathIndex); - pad3 = D_80162FA0[0]; - pad4 = D_80162FA0[2]; - func_8000BBD8(waypoint2, arg3, pathIndex); - temp1 = D_80162FA0[0]; - temp2 = D_80162FA0[2]; - midY = (path[waypoint1].posY + path[waypoint2].posY) * 0.5f; - midX = (pad3 + temp1) * 0.5f; - midZ = (pad4 + temp2) * 0.5f; - xdiff = midX - oldPosX; - ydiff = midY - oldPosY; - zdiff = midZ - oldPosZ; - distance = sqrtf((xdiff * xdiff) + (ydiff * ydiff) + (zdiff * zdiff)); - if (distance > 0.01f) { - var_f2 = ((xdiff * speed) / distance) + oldPosX; - var_f12 = ((ydiff * speed) / distance) + oldPosY; - var_f14 = ((zdiff * speed) / distance) + oldPosZ; - } else { - var_f2 = oldPosX; - var_f12 = oldPosY; - var_f14 = oldPosZ; - } - position[0] = var_f2; - position[1] = var_f12; - position[2] = var_f14; - return get_angle_between_waypoints(oldPos, position); -} - -s16 func_8000D940(Vec3f pos, s16* waypointIndex, f32 speed, f32 arg3, s16 pathIndex) { - UNUSED f32 pad; - f32 thing1; - f32 thing2; - UNUSED s16 stackPadding1; - s16 waypoint1; - s16 waypoint2; - UNUSED s16 stackPadding2; - f32 pad2; - f32 midX; - f32 pad3; - f32 midY; - f32 midZ; - f32 distance; - f32 temp_f20; - f32 temp_f22; - f32 temp_f24; - f32 var_f2; - f32 var_f12; - f32 var_f14; - s16 temp_v0; - f32 xdiff; - f32 ydiff; - f32 zdiff; - s32 waypointCount; - Vec3f sp54; - - sp54[0] = pos[0]; - sp54[1] = pos[1]; - sp54[2] = pos[2]; - waypointCount = gWaypointCountByPathIndex[pathIndex]; - temp_f20 = pos[0]; - temp_f22 = pos[1]; - temp_f24 = pos[2]; - temp_v0 = func_8000D2B4(temp_f20, temp_f22, temp_f24, *waypointIndex, (s32) pathIndex); - *waypointIndex = temp_v0; - waypoint1 = ((temp_v0 + waypointCount) - 3) % waypointCount; - waypoint2 = ((temp_v0 + waypointCount) - 4) % waypointCount; - func_8000BBD8(waypoint1, arg3, pathIndex); - pad2 = D_80162FA0[0]; - pad3 = D_80162FA0[2]; - func_8000BBD8(waypoint2, arg3, pathIndex); - thing1 = D_80162FA0[0]; - thing2 = D_80162FA0[2]; - midY = (D_80164550[pathIndex][waypoint1].posY + D_80164550[pathIndex][waypoint2].posY) * 0.5f; - midX = (pad2 + thing1) * 0.5f; - midZ = (pad3 + thing2) * 0.5f; - xdiff = midX - temp_f20; - ydiff = midY - temp_f22; - zdiff = midZ - temp_f24; - distance = sqrtf((xdiff * xdiff) + (ydiff * ydiff) + (zdiff * zdiff)); - if (distance > 0.01f) { - var_f2 = ((xdiff * speed) / distance) + temp_f20; - var_f12 = ((ydiff * speed) / distance) + temp_f22; - var_f14 = ((zdiff * speed) / distance) + temp_f24; - } else { - var_f2 = temp_f20; - var_f12 = temp_f22; - var_f14 = temp_f24; - } - pos[0] = var_f2; - pos[1] = var_f12; - pos[2] = var_f14; - return get_angle_between_waypoints(sp54, pos); -} - -s16 update_vehicle_following_waypoint(Vec3f pos, s16* waypointIndex, f32 speed) { - f32 origXPos; - f32 origYPos; - f32 origZPos; - UNUSED s32 stackPadding0; - UNUSED s32 stackPadding1; - UNUSED s32 stackPadding2; - UNUSED s32 stackPadding3; - UNUSED s32 stackPadding4; - UNUSED s32 stackPadding5; - UNUSED s32 stackPadding6; - UNUSED s32 stackPadding7; - UNUSED s32 stackPadding8; - f32 farWaypointAverageX; - f32 farWaypointAverageZ; - f32 x_dist; - f32 y_dist; - f32 distance; - f32 newX; - f32 newZ; - s16 newWaypointIndex; - s16 farWaypoint1; - s16 farWaypoint2; - Path2D* temp_a0; - Path2D* temp_a2; - Vec3f sp38; - - origXPos = pos[0]; - origYPos = pos[1]; - origZPos = pos[2]; - sp38[0] = pos[0]; - sp38[1] = pos[1]; - sp38[2] = pos[2]; - newWaypointIndex = find_closest_vehicles_waypoint(origXPos, origYPos, origZPos, *waypointIndex); - *waypointIndex = newWaypointIndex; - farWaypoint1 = (newWaypointIndex + 3) % gVehicle2DWaypointLength; - farWaypoint2 = (newWaypointIndex + 4) % gVehicle2DWaypointLength; - temp_a0 = &gVehicle2DWaypoint[farWaypoint1]; - temp_a2 = &gVehicle2DWaypoint[farWaypoint2]; - farWaypointAverageX = (temp_a0->x + temp_a2->x) * 0.5f; - farWaypointAverageZ = (temp_a0->z + temp_a2->z) * 0.5f; - x_dist = farWaypointAverageX - origXPos; - y_dist = farWaypointAverageZ - origZPos; - distance = sqrtf((x_dist * x_dist) + (y_dist * y_dist)); - if (distance > 0.01f) { - newX = ((x_dist * speed) / distance) + origXPos; - newZ = ((y_dist * speed) / distance) + origZPos; - } else { - newX = origXPos; - newZ = origZPos; - } - pos[0] = newX; - pos[1] = origYPos; - pos[2] = newZ; - return get_angle_between_waypoints(sp38, pos); -} - -void set_bomb_kart_spawn_positions(void) { - UNUSED Collision* var_s2; - f32 startingXPos; - f32 startingZPos; - f32 startingYPos; - s32 var_s3; - TrackWaypoint* temp_v0; - UNUSED BombKart* var_s0; - BombKartSpawn* bombKartSpawn; - - for (var_s3 = 0; var_s3 < NUM_BOMB_KARTS_VERSUS; var_s3++) { - bombKartSpawn = &gBombKartSpawns[gCurrentCourseId][var_s3]; - switch (gCurrentCourseId) { - case COURSE_YOSHI_VALLEY: - startingXPos = bombKartSpawn->startingXPos; - startingZPos = bombKartSpawn->startingZPos; - startingYPos = get_surface_height(startingXPos, 2000.0f, startingZPos); - break; - case COURSE_AWARD_CEREMONY: - temp_v0 = &D_80164550[3][bombKartSpawn->waypointIndex]; - startingXPos = temp_v0->posX; - startingYPos = temp_v0->posY; - startingZPos = temp_v0->posZ; - break; - default: - temp_v0 = &D_80164550[0][bombKartSpawn->waypointIndex]; - startingXPos = temp_v0->posX; - startingYPos = temp_v0->posY; - startingZPos = temp_v0->posZ; - break; - } - gBombKarts[var_s3].bombPos[0] = startingXPos; - gBombKarts[var_s3].bombPos[1] = startingYPos; - gBombKarts[var_s3].bombPos[2] = startingZPos; - gBombKarts[var_s3].wheel1Pos[0] = startingXPos; - gBombKarts[var_s3].wheel1Pos[1] = startingYPos; - gBombKarts[var_s3].wheel1Pos[2] = startingZPos; - gBombKarts[var_s3].wheel2Pos[0] = startingXPos; - gBombKarts[var_s3].wheel2Pos[1] = startingYPos; - gBombKarts[var_s3].wheel2Pos[2] = startingZPos; - gBombKarts[var_s3].wheel3Pos[0] = startingXPos; - gBombKarts[var_s3].wheel3Pos[1] = startingYPos; - gBombKarts[var_s3].wheel3Pos[2] = startingZPos; - gBombKarts[var_s3].wheel4Pos[0] = startingXPos; - gBombKarts[var_s3].wheel4Pos[1] = startingYPos; - gBombKarts[var_s3].wheel4Pos[2] = startingZPos; - gBombKarts[var_s3].waypointIndex = bombKartSpawn->waypointIndex; - gBombKarts[var_s3].unk_3C = bombKartSpawn->unk_04; - gBombKarts[var_s3].bounceTimer = 0; - gBombKarts[var_s3].circleTimer = 0; - gBombKarts[var_s3].state = bombKartSpawn->startingState; - gBombKarts[var_s3].unk_4A = 0; - gBombKarts[var_s3].unk_4C = 1; - gBombKarts[var_s3].yPos = startingYPos; - check_bounding_collision(&D_80164038[var_s3], 2.0f, startingXPos, startingYPos, startingZPos); - } -} - -void func_8000DF8C(s32 bombKartId) { - UNUSED s32 stackPadding0; - f32 sp118; - f32 var_f18; - TrackWaypoint* temp_v0_2; - f32 temp_f0_3; - f32 sp108; - UNUSED s32 stackPadding1; - UNUSED s32 stackPadding2; - UNUSED s32 stackPadding3; - f32 temp_f14; - UNUSED s32 stackPadding4; - f32 temp_f16; - UNUSED s32 stackPadding5; - UNUSED s32 stackPadding6; - UNUSED s32 stackPadding7; - UNUSED s32 stackPadding8; - UNUSED s32 stackPadding9; - UNUSED s32 stackPaddingA; - UNUSED s32 stackPaddingB; - f32 temp_f0; - f32 temp_f0_4; - u16 spCA; - f32 spC4; - u16 spC2; - f32 temp_f12; - f32 temp_f12_3; - f32 temp_f12_4; - f32 temp_f14_2; - f32 spAC; - UNUSED s32 stackPaddingC; - f32 temp_f16_2; - f32 spA0; - f32 temp_f2; - f32 temp_f2_4; - f32 sp94; - UNUSED s32 stackPaddingD; - f32 var_f20; - f32 sp88; - f32 var_f22; - f32 var_f24; - u16 sp7E; - u16 sp7C; - UNUSED u16 sp4C; - u16 temp_t6; - u16 temp_t7; - u16 var_s1; - s32 var_a0; - UNUSED s32 stackPaddingE; - TrackWaypoint* temp_v0_4; - BombKart* bombKart; - BombKart* bombKart2; - Collision* temp_a0_4; - Player* var_v0; - - bombKart = &gBombKarts[bombKartId]; - - sp7E = bombKart->state; - - if (sp7E == 0) { - return; - } - - if (((bombKart->unk_4A != 1) || (gCurrentCourseId == COURSE_AWARD_CEREMONY))) { - var_f22 = bombKart->bombPos[0]; - var_f20 = bombKart->bombPos[1]; - var_f24 = bombKart->bombPos[2]; - spCA = bombKart->waypointIndex; - spC4 = bombKart->unk_3C; - spC2 = bombKart->someRot; - sp7C = bombKart->bounceTimer; - var_s1 = bombKart->circleTimer; - if ((sp7E != 0) && (sp7E != 4)) { - if (1) {} - if (gCurrentCourseId == COURSE_AWARD_CEREMONY) { - if (D_8016347E == 1) { - var_v0 = gPlayerFour; - temp_f0 = var_f22 - var_v0->pos[0]; - temp_f2 = var_f20 - var_v0->pos[1]; - temp_f12 = var_f24 - var_v0->pos[2]; - if ((((temp_f0 * temp_f0) + (temp_f2 * temp_f2)) + (temp_f12 * temp_f12)) < 25.0f) { - var_s1 = 0; - sp7E = 4; - var_v0->soundEffects |= 0x400000; - var_v0->type &= ~0x2000; - } - } - } else { - - for (var_a0 = 0; var_a0 < gPlayerCount; var_a0++) { - var_v0 = &gPlayers[var_a0]; - if (!(var_v0->effects & 0x80000000)) { - temp_f0 = var_f22 - var_v0->pos[0]; - temp_f2 = var_f20 - var_v0->pos[1]; - temp_f12 = var_f24 - var_v0->pos[2]; - if ((((temp_f0 * temp_f0) + (temp_f2 * temp_f2)) + (temp_f12 * temp_f12)) < 25.0f) { - sp7E = 4; - var_s1 = 0; - if (gCurrentCourseId == COURSE_FRAPPE_SNOWLAND) { - var_v0->soundEffects |= 0x01000000; - } else { - var_v0->soundEffects |= 0x400000; - } - } - } - } - } - } - switch (sp7E) { - case 1: - var_s1 = (var_s1 + 356) % 360; - temp_t6 = (var_s1 * 0xFFFF) / 360; - sp118 = coss(temp_t6) * 25.0; - temp_f0_3 = sins(temp_t6) * 25.0; - temp_v0_2 = &D_80164550[0][spCA]; - var_f22 = temp_v0_2->posX + sp118; - var_f20 = bombKart->yPos + 3.5f; - var_f24 = temp_v0_2->posZ + temp_f0_3; - D_80162FB0[0] = var_f22; - D_80162FB0[1] = var_f20; - D_80162FB0[2] = var_f24; - temp_t7 = (((var_s1 + 1) % 360) * 0xFFFF) / 360; - sp118 = coss(temp_t7) * 25.0; - temp_f0_3 = sins(temp_t7) * 25.0; - D_80162FC0[0] = temp_v0_2->posX + sp118; - D_80162FC0[1] = temp_v0_2->posY; - D_80162FC0[2] = temp_v0_2->posZ + temp_f0_3; - spC2 = (get_angle_between_two_vectors(D_80162FB0, D_80162FC0) * 0xFFFF) / 65520; - break; - case 2: - var_s1 = (var_s1 + 4) % 360; - temp_t6 = (var_s1 * 0xFFFF) / 360; - sp118 = coss(temp_t6) * 25.0; - temp_f0_3 = sins(temp_t6) * 25.0; - temp_v0_2 = &D_80164550[0][spCA]; - var_f22 = temp_v0_2->posX + sp118; - var_f20 = bombKart->yPos + 3.5f; - var_f24 = temp_v0_2->posZ + temp_f0_3; - D_80162FB0[0] = var_f22; - D_80162FB0[1] = var_f20; - D_80162FB0[2] = var_f24; - temp_t7 = (((var_s1 + 1) % 360) * 0xFFFF) / 360; - sp118 = coss(temp_t7) * 25.0; - temp_f0_3 = sins(temp_t7) * 25.0; - D_80162FC0[0] = temp_v0_2->posX + sp118; - D_80162FC0[1] = temp_v0_2->posY; - D_80162FC0[2] = temp_v0_2->posZ + temp_f0_3; - spC2 = (get_angle_between_two_vectors(D_80162FB0, D_80162FC0) * 0xFFFF) / 65520; - break; - case 3: - var_f20 = bombKart->yPos + 3.5f; - spC2 = 0; - break; - - case 5: - if ((D_8016347C == 0) || (gNearestWaypointByPlayerId[3] < 5)) { - break; - } else { - spCA = func_8000D2B4(var_f22, var_f20, var_f24, spCA, 3); - if ((spCA < 0) || (gWaypointCountByPathIndex[3] < spCA)) { - spCA = 0; - } - if (((s32) spCA) < 0x1A) { - temp_v0_2 = &D_80164550[3][(spCA + 1) % gWaypointCountByPathIndex[3]]; - D_80162FB0[0] = temp_v0_2->posX; - D_80162FB0[1] = temp_v0_2->posY; - D_80162FB0[2] = temp_v0_2->posZ; - temp_v0_4 = &D_80164550[3][(spCA + 2) % gWaypointCountByPathIndex[3]]; - D_80162FC0[0] = temp_v0_4->posX; - D_80162FC0[1] = temp_v0_4->posY; - D_80162FC0[2] = temp_v0_4->posZ; - spC2 = (get_angle_between_two_vectors(D_80162FB0, D_80162FC0) * 0xFFFF) / 65520; - } else { - D_80162FB0[0] = var_f22; - D_80162FB0[1] = var_f20; - D_80162FB0[2] = var_f24; - D_80162FC0[0] = -2409.197f; - D_80162FC0[1] = 0.0f; - D_80162FC0[2] = -355.254f; - spC2 = (get_angle_between_two_vectors(D_80162FB0, D_80162FC0) * 0xFFFF) / 65520; - } - temp_f14 = ((D_80162FB0[0] + D_80162FC0[0]) * 0.5f) - var_f22; - temp_f16 = ((D_80162FB0[2] + D_80162FC0[2]) * 0.5f) - var_f24; - temp_f0_4 = sqrtf((temp_f14 * temp_f14) + (temp_f16 * temp_f16)); - if (temp_f0_4 > 0.01f) { - var_f22 += (bombKart->unk_3C * temp_f14) / temp_f0_4; - var_f24 += (bombKart->unk_3C * temp_f16) / temp_f0_4; - } else { - var_f22 += temp_f14 / 5.0f; - var_f24 += temp_f16 / 5.0f; - } - temp_a0_4 = &D_80164038[bombKartId]; - var_f20 = calculate_surface_height(var_f22, 2000.0f, var_f24, temp_a0_4->meshIndexZX) + 3.5f; - if (var_f20 < (-1000.0)) { - var_f20 = bombKart->bombPos[1]; - } - check_bounding_collision(temp_a0_4, 10.0f, var_f22, var_f20, var_f24); - } - break; - case 4: - temp_v0_2 = &D_80164550[0][spCA]; - D_80162FB0[0] = temp_v0_2->posX; - D_80162FB0[1] = temp_v0_2->posY; - D_80162FB0[2] = temp_v0_2->posZ; - temp_v0_4 = &D_80164550[0][(spCA + 1) % gWaypointCountByPathIndex[0]]; - D_80162FC0[0] = temp_v0_4->posX; - D_80162FC0[1] = temp_v0_4->posY; - D_80162FC0[2] = temp_v0_4->posZ; - var_f20 += 3.0f - (var_s1 * 0.3f); - spC2 = (get_angle_between_two_vectors(D_80162FB0, D_80162FC0) * 0xFFFF) / 65520; - break; - default: - break; - } - - if (sp7E == 4) { - sp108 = 2.0f * var_s1; - sp118 = coss(0xFFFF - spC2) * var_s1; - var_f18 = sins(0xFFFF - spC2) * var_s1; - var_s1++; - temp_f2_4 = (var_f20 - 2.3f) + (sp108 / 3.0f); - spAC = temp_f2_4; - spA0 = temp_f2_4; - sp94 = temp_f2_4; - sp88 = temp_f2_4; - if (var_s1 >= 31) { - sp7E = 0; - } - } else { - sp118 = coss(0xFFFF - spC2) * 1.5f; - var_f18 = sins(0xFFFF - spC2) * 1.5f; - temp_f16_2 = var_f20 - 2.3f; - temp_f12_3 = (sp7C % 3) * 0.15f; - temp_f14_2 = temp_f16_2 - temp_f12_3; - temp_f12_4 = temp_f16_2 + temp_f12_3; - spAC = temp_f14_2; - sp94 = temp_f14_2; - spA0 = temp_f12_4; - sp88 = temp_f12_4; - var_f20 += sins((sp7C * 0x13FFEC) / 360); - sp7C = (sp7C + 1) % 18; - } - bombKart2 = bombKart; - bombKart2->wheel1Pos[0] = (sp118 - var_f18) + var_f22; - bombKart2->wheel1Pos[1] = spAC; - bombKart2->wheel1Pos[2] = (var_f18 + sp118) + var_f24; - bombKart2->wheel2Pos[0] = (var_f18 + sp118) + var_f22; - bombKart2->wheel2Pos[1] = spA0; - bombKart2->wheel2Pos[2] = (var_f18 - sp118) + var_f24; - bombKart2->wheel3Pos[0] = ((-sp118) - var_f18) + var_f22; - bombKart2->wheel3Pos[1] = sp94; - bombKart2->wheel3Pos[2] = ((-var_f18) + sp118) + var_f24; - bombKart2->wheel4Pos[0] = ((-sp118) + var_f18) + var_f22; - bombKart2->wheel4Pos[1] = sp88; - bombKart2->wheel4Pos[2] = ((-var_f18) - sp118) + var_f24; - bombKart2->bombPos[0] = var_f22; - bombKart2->bombPos[1] = var_f20; - bombKart2->bombPos[2] = var_f24; - bombKart2->waypointIndex = spCA; - bombKart2->unk_3C = spC4; - bombKart2->someRot = spC2; - bombKart2->state = sp7E; - bombKart2->bounceTimer = sp7C; - bombKart2->circleTimer = var_s1; - } -} - -s32 add_actor_in_unexpired_actor_list(s32 actorIndex, s16 arg1) { - s32 i; - s32 a2 = 0; - - for (i = 0; i < NUM_PLAYERS; i++) { - - if (gUnexpiredActorsList[i].unkC == 0) { - gUnexpiredActorsList[i].unkC = 1; - gUnexpiredActorsList[i].actorIndex = actorIndex; - gUnexpiredActorsList[i].unk10 = arg1; - gUnexpiredActorsList[i].unk14 = 0; - a2 = 1; - break; - } - } - if (a2 == 0) { - return -2; - } - return 0; -} - -s32 add_red_shell_in_unexpired_actor_list(s32 actorIndex) { - struct Actor* actor = &gActorList[actorIndex]; - if (actor->type != ACTOR_RED_SHELL) { - return -1; - } - return add_actor_in_unexpired_actor_list(actorIndex, 0); -} - -s32 add_green_shell_in_unexpired_actor_list(s32 actorIndex) { - struct Actor* actor = &gActorList[actorIndex]; - if (actor->type != ACTOR_GREEN_SHELL) { - return -1; - } - return add_actor_in_unexpired_actor_list(actorIndex, 1); -} - -s32 add_blue_shell_in_unexpired_actor_list(s32 arg0) { - struct Actor* actor = &gActorList[arg0]; - if (actor->type != ACTOR_BLUE_SPINY_SHELL) { - return -1; - } - return add_actor_in_unexpired_actor_list(arg0, 2); -} - -void delete_actor_in_unexpired_actor_list(s32 actorIndex) { - struct unexpiredActors* phi; - s32 i; - - for (i = 0; i < NUM_PLAYERS; i++) { - phi = &gUnexpiredActorsList[i]; - if (actorIndex == phi->actorIndex) { - phi->unkC = 0; - phi->actorIndex = 1000; // out of bounds - } - } -} - -void func_8000EEDC(void) { - struct unexpiredActors* phi; - s32 i; - - for (i = 0; i < NUM_PLAYERS; i++) { - phi = &gUnexpiredActorsList[i]; - phi->unkC = 0; - phi->actorIndex = 1000; // out of bounds - } -} - -void generate_player_smoke(void) { - s32 someIndex; - f32 var_f20; - struct Actor* temp_s1; - struct unexpiredActors* var_s0; - - for (someIndex = 0; someIndex < NUM_PLAYERS; someIndex++) { - var_s0 = &gUnexpiredActorsList[someIndex]; - if (var_s0->unkC == 1) { - temp_s1 = &gActorList[var_s0->actorIndex]; - var_s0->unk14++; - switch (var_s0->unk10) { - case 0: - if (var_s0->unk14 < 0xA) { - var_f20 = 0.3f; - } else { - var_f20 = 0.9f; - } - break; - case 1: - if (var_s0->unk14 < 0xA) { - var_f20 = 0.15f; - } else { - var_f20 = 0.45f; - } - break; - case 2: - if (var_s0->unk14 < 0xA) { - var_f20 = 0.15f; - } else { - var_f20 = 0.45f; - } - break; - default: - var_f20 = 1.0f; - break; - } - if (!(var_s0->unk14 & 1)) { - init_smoke_particle(temp_s1->pos, ((random_int(30) + 20) * var_f20) / 50.0f, var_s0->unk10); - } - } - } -} - -void func_8000F0E0(void) { - s32 i; - for (i = 0; i < 4; i++) { - D_80164670[i] = 0; - D_80164678[i] = 0; - } -} - -void func_8000F124(void) { - s32 var_a1; - s32 i, j; - - for (j = 0; j < 2; j++) { - D_80163348[j] = 0; - } - - if (gDemoMode == 1) { - return; - } - if (gModeSelection != GRAND_PRIX) { - return; - } - - for (i = 0; i < 2; i++) { - - while (1) { - D_80163348[i] = random_int(8); - - if (gPlayerCount > 2) { - break; - } - if (gPlayerCount < 1) { - break; - } - - var_a1 = 0; - - for (j = 0; j < gPlayerCount; j++) { - if (gCharacterSelections[j] == D_80163348[i]) { - var_a1 = 1; - } - } - for (j = 0; j < i; j++) { - if (D_80163348[j] == D_80163348[i]) { - var_a1 = 1; - } - } - if (var_a1 == 0) { - break; - } - } - } -} - -// Delete track waypoints -void func_8000F2BC(TrackWaypoint* arg0, size_t size) { - bzero((void*) arg0, size * sizeof(TrackWaypoint)); -} - -// Appears to allocate memory for each course. -void func_8000F2DC(void) { - - struct _struct_gCoursePathSizes_0x10* ptr = &GET_COURSE_PathSizes; - s32 temp; - s32 i; - - D_80163368[0] = (s32) ptr->unk0; - D_80163368[1] = (s32) ptr->unk2; - D_80163368[2] = (s32) ptr->unk4; - D_80163368[3] = (s32) ptr->unk6; - - temp = ptr->unk8; - gVehicle2DWaypoint = get_next_available_memory_addr(temp * 4); - - // Podium ceremony appears to allocate 1 * 8 bytes of data. Which would be aligned to 0x10. - for (i = 0; i < 4; i++) { - D_80164550[i] = get_next_available_memory_addr(D_80163368[i] * 8); - D_80164560[i] = get_next_available_memory_addr(D_80163368[i] * 8); - D_80164570[i] = get_next_available_memory_addr(D_80163368[i] * 8); - D_80164580[i] = get_next_available_memory_addr(D_80163368[i] * 2); - D_80164590[i] = get_next_available_memory_addr(D_80163368[i] * 2); - D_801645A0[i] = get_next_available_memory_addr(D_80163368[i] * 2); - } - - D_80164490 = D_80164550[0]; - D_801631D0 = D_80164560[0]; - D_801631D4 = D_80164570[0]; - D_801631D8 = D_80164580[0]; - D_801631DC = D_80164590[0]; - D_801645E0 = D_801645A0[0]; - - // zero allocated memory? - //! @warning does not appear to zero all the above allocated variables. - for (i = 0; i < 4; i++) { - func_8000F2BC(D_80164550[i], D_80163368[i]); - func_8000F2BC(D_80164560[i], D_80163368[i]); - func_8000F2BC(D_80164570[i], D_80163368[i]); - } - - // Skip several cpu cycles. - for (i = 0; i < 4; i++) {} - - for (i = 0; i < 4; i++) { - if (D_80163368[i] >= 2) { - func_800100F0(i); - func_80010218(i); - func_800107C4(i); - func_80010DBC(i); - func_80010E6C(i); - } - } - - D_80164430 = *gWaypointCountByPathIndex; -#if !ENABLE_CUSTOM_COURSE_ENGINE - switch (gCurrentCourseId) { - case COURSE_KALAMARI_DESERT: - generate_train_waypoints(); - init_vehicles_trains(); - break; - case COURSE_DK_JUNGLE: - generate_ferry_waypoints(); - init_vehicles_ferry(); - break; - case COURSE_TOADS_TURNPIKE: - init_vehicles_box_trucks(); - init_vehicles_school_buses(); - init_vehicles_trucks(); - init_vehicles_cars(); - break; - } -#else - -#endif - set_bomb_kart_spawn_positions(); - func_8000EEDC(); -} - -void func_8000F628(void) { - - UNUSED Camera* camera; - s32 temp_v0_3; - s32 i; - Test* var_s5; - UNUSED s32 temp_v1; - UNUSED s32 pad; - - for (i = 0; i < NUM_PLAYERS; i++) { - Player* player = &gPlayerOne[i]; - - D_80163050[i] = 0; - D_80162FF8[i] = 0; - D_80163010[i] = 0; - if (gCurrentCourseId < (NUM_COURSES - 1)) { - func_8000B95C(i, 0, 0); - } - D_80163028[i] = GET_COURSE_D_0D009418(gCCSelection); - D_801630E8[i] = 0; - D_80163100[i] = 0; - D_80163178[i] = 0.0f; - D_801631A0[i] = 0.0f; - D_80163210[i] = 0.0f; - gLapCountByPlayerId[i] = -1; - gCourseCompletionPercentByPlayerId[i] = 0.0f; - gTimePlayerLastTouchedFinishLine[i] = 0.0f; - if (gModeSelection == GRAND_PRIX) { - if (1) {}; - if (1) {}; // Maybe some debug code? - gGPCurrentRaceRankByPlayerId[i] = (s32) D_80165270[i]; - D_801643E0[i] = (s32) D_80165270[i]; - } else { - gGPCurrentRaceRankByPlayerId[i] = i; - D_801643E0[i] = i; - } - temp_v0_3 = gGPCurrentRaceRankByPlayerId[i]; - gGPCurrentRacePlayerIdByRank[temp_v0_3] = (s16) i; - D_80164378[temp_v0_3] = (s16) i; - D_80164408[i] = temp_v0_3; - D_80163258[i] = 0; - D_80163270[i] = 0; - D_801631E0[i] = 0; - D_801631F8[i] = 0; - D_80164450[i] = -20; - D_80163288[i] = -20; - D_80164478[gPlayers[i].characterId] = (s16) i; - D_80163068[i] = 0.0f; - D_80163090[i] = 0.0f; - var_s5 = &D_801634F8[i]; - var_s5->unkC = GET_COURSE_AIMinimumSeparation * (f32) (((i + 1) % 3) - 1); - var_s5->unk4 = var_s5->unkC; - var_s5->unk0 = 0.0f; - var_s5->unk8 = 0.015f; - reset_kart_ai_behaviour_none(i); - gSpeedKartAIBehaviour[i] = 0; - D_801644F8[i] = 0; - D_80163398[i] = 0; - D_801633B0[i] = 0; - D_801633C8[i] = 0; - D_801633F8[i] = 0; - D_80163318[i] = 0; - D_80163450[i] = player->pos[2]; - D_80163380[i] = 6; - if (gPlayers[i].type & PLAYER_HUMAN) { - D_80163330[i] = 3; - - } else { - D_80163330[i] = 0; - } - - D_80163490[i] = 0; - D_801634A8[i] = 0; - D_80163128[i] = -1; - D_80163150[i] = -1; - D_80164538[i] = -1; - D_801634C0[i] = 0; - bStopAICrossing[i] = 0; - D_801630B8[i] = 1; - } - -#ifdef AVOID_UB - for (i = 0; i < NUM_CROSSINGS; i++) { - sCrossingActiveTimer[i] = 0; - } -#else - sCrossingActiveTimer[0] = 0; - sCrossingActiveTimer[1] = 0; -#endif - if (gDemoMode == DEMO_MODE_INACTIVE) { - - if (gModeSelection == GRAND_PRIX) { - for (i = 0; i < 2; i++) { - D_80163344[i] = D_80164478[D_80163348[i]]; - D_80163330[D_80163344[i]] = 1; - D_8016334C[D_80163344[i]] = i; - } - } - } - if ((gDemoUseController == 1) && (gCurrentCourseId != COURSE_AWARD_CEREMONY)) { - for (i = 0; i < NUM_PLAYERS; i++) { - D_80163330[i] = 0; - } - if (gModeSelection == VERSUS) { - - D_80163344[0] = cameras->playerId; - D_80163330[D_80163344[0]] = 1; - D_8016334C[D_80163344[0]] = 0; - - for (i = 1; i < 2; i++) { - D_80163344[i] = cameras[i].playerId; - D_80163330[D_80163344[i]] = 1; - D_8016334C[D_80163344[i]] = i; - } - } - } - - for (i = 0; i < NUM_PLAYERS; i++) { - if (1) {}; - gPathIndexByPlayerId[i] = 0; - gNearestWaypointByPlayerId[i] = - gWaypointCountByPathIndex[gPathIndexByPlayerId[i]] - gGPCurrentRaceRankByPlayerId[i] - 4; - } - - D_8016347A = 0; - if (gCCSelection == CC_EXTRA) { - D_8016347A = 1; - } - - for (i = 0; i < 30; i++) { - D_80162F10[i] = -1; - D_80162F50[i] = -1; - } - - D_801631CC = 100000; // 100,000 - D_80164698 = 0.0f; - D_8016469C = 100.0f; - D_801646A0 = 0.0f; - D_80164358 = 0; - D_8016435A = 1; - D_8016435C = 1; - D_80163478 = 0; - D_80163378 = 0; - D_8016337C = 0; - D_8016344C = (f32) D_80164550[0][0].posZ; // [i][2] - D_801634F0 = 0; - D_801634F4 = 0; - D_80163488 = 0; - D_8016348C = 0; - D_801634EC = 0; - func_8001AB00(); - if (gDemoUseController == 1) { - if (gDemoMode == 1) { - - for (i = 0; i < NUM_PLAYERS; i++) { - if (D_80163330[i] == 1) { - gPlayers[i].soundEffects |= 0x02000000; - } - } - } - } - copy_courses_kart_ai_behaviour(); -} - -// @arg index from 0 to 3. - -// Processes course path by index. -// @arg index from 0 to 3. -// Each course can have 1-4 course paths. -void func_800100F0(s32 pathIndex) { - - TrackWaypoint* ptr; - TrackWaypoint* pathDest; - TrackWaypoint* path; - s32 var_v0; - s32 sp24; - UNUSED s32 pad[2]; - s16 bInvalidPath; - s32 i; - - // cast required - if ((s32) GET_COURSE_AIMaximumSeparation >= 0) { - pathDest = D_80164550[pathIndex]; - bInvalidPath = 1; - if (gCurrentCourseId != COURSE_AWARD_CEREMONY) { - var_v0 = process_path_data(pathDest, GET_COURSE_PathTable2(pathIndex)); - gWaypointCountByPathIndex[pathIndex] = (u16) var_v0; - } else { - // Course path included in course_data which has already been loaded into memory. - // This is how we get the addr to our path data. - path = GET_COURSE_PathTable(pathIndex); - ptr = path; - - for (i = 0; i < 3000; i++, ptr++) { - if ((u16) ptr->posX == 0x8000) { - sp24 = i - 1; - bInvalidPath = 0; - break; - } - } - - // If path data higher than 3000 something has gone wrong. - // Skip processing the data. - //! @todo Confirm this comment - if (!bInvalidPath) { - var_v0 = func_80011014(pathDest, path, sp24, pathIndex); - gWaypointCountByPathIndex[pathIndex] = (u16) var_v0; - } - } - } -} - -void func_80010218(s32 pathIndex) { - f32 waypointWidth; - f32 x1; - f32 y1; - f32 z1; - f32 x2; - f32 y2; - f32 z2; - f32 x_dist; - f32 z_dist; - f32 neg_x_dist; - f32 neg_z_dist; - f32 xz_dist; - s32 temp_f16; - s32 waypointIndex; - TrackWaypoint* waypoint; - TrackWaypoint* nextWaypoint; - TrackWaypoint* var_s1; - TrackWaypoint* var_s2; - - if (((s32) GET_COURSE_AIMaximumSeparation) >= 0) { - waypointWidth = GET_COURSE_AIMaximumSeparation; - waypoint = &D_80164550[pathIndex][0]; - var_s1 = &D_80164560[pathIndex][0]; - var_s2 = &D_80164570[pathIndex][0]; - for (waypointIndex = 0; waypointIndex < gWaypointCountByPathIndex[pathIndex]; - waypointIndex++, var_s1++, var_s2++) { - x1 = waypoint->posX; - y1 = waypoint->posY; - z1 = waypoint->posZ; - waypoint++; - nextWaypoint = &D_80164550[pathIndex][(waypointIndex + 1) % ((s32) gWaypointCountByPathIndex[pathIndex])]; - x2 = nextWaypoint->posX; - y2 = nextWaypoint->posY; - z2 = nextWaypoint->posZ; - x_dist = x2 - x1; - z_dist = z2 - z1; - neg_x_dist = x1 - x2; - neg_z_dist = z1 - z2; - xz_dist = sqrtf((x_dist * x_dist) + (z_dist * z_dist)); - temp_f16 = (f32) ((y1 + y2) * 0.5); - var_s1->posX = ((waypointWidth * z_dist) / xz_dist) + x1; - var_s1->posY = temp_f16; - var_s1->posZ = ((waypointWidth * neg_x_dist) / xz_dist) + z1; - var_s2->posX = ((waypointWidth * neg_z_dist) / xz_dist) + x1; - var_s2->posY = temp_f16; - var_s2->posZ = ((waypointWidth * x_dist) / xz_dist) + z1; - } - } -} - -f32 func_80010480(s32 pathIndex, u16 waypointIndex) { - f32 temp_f10_2; - f32 temp_f8; - UNUSED f32 pad; - TrackWaypoint* pathWaypoints; - f32 x1; - f32 z1; - f32 x2; - f32 z2; - f32 x3; - f32 z3; - f32 temp_f8_2; - f32 temp_f10; - s32 waypointCount; - TrackWaypoint* waypoint3; - TrackWaypoint* waypoint2; - TrackWaypoint* waypoint1; - f32 root2; - f32 root1; - - if ((s32) GET_COURSE_AIMaximumSeparation < 0) { - return 0.0f; - } - waypointCount = gWaypointCountByPathIndex[pathIndex]; - pathWaypoints = D_80164550[pathIndex]; - waypoint1 = &pathWaypoints[waypointIndex]; - waypoint2 = &pathWaypoints[(waypointIndex + 1) % waypointCount]; - waypoint3 = &pathWaypoints[(waypointIndex + 2) % waypointCount]; - x1 = waypoint1->posX; - z1 = waypoint1->posZ; - x2 = waypoint2->posX; - z2 = waypoint2->posZ; - x3 = waypoint3->posX; - z3 = waypoint3->posZ; - temp_f8_2 = (((x2 + x3) * 0.5) - x1); - temp_f10 = (((z2 + z3) * 0.5) - z1); - waypoint1 = &pathWaypoints[(waypointIndex + 3) % waypointCount]; - waypoint2 = &pathWaypoints[(waypointIndex + 4) % waypointCount]; - waypoint3 = &pathWaypoints[(waypointIndex + 5) % waypointCount]; - x1 = waypoint1->posX; - z1 = waypoint1->posZ; - x2 = waypoint2->posX; - z2 = waypoint2->posZ; - x3 = waypoint3->posX; - z3 = waypoint3->posZ; - temp_f10_2 = (((x2 + x3) * 0.5) - x1); - temp_f8 = (((z2 + z3) * 0.5) - z1); - root1 = sqrtf((temp_f10 * temp_f10) + (temp_f8_2 * temp_f8_2)); - root2 = sqrtf((temp_f10_2 * temp_f10_2) + (temp_f8 * temp_f8)); - return -((temp_f10 * temp_f10_2) - (temp_f8_2 * temp_f8)) / (root2 * root1); -} - -void func_800107C4(s32 pathIndex) { - f64 temp_f2; - UNUSED s32 pad; - s32 var_a2; - s32 var_s0; - s32 var_t2; - s16* var_t4; - s32 var_a3; - s16* wut; - - if ((s32) GET_COURSE_AIMaximumSeparation >= 0) { - var_a3 = gWaypointCountByPathIndex[pathIndex]; - var_t4 = &D_80164580[pathIndex][0]; - for (var_s0 = 0; var_s0 < var_a3; var_s0++, var_t4++) { - temp_f2 = func_80010480(pathIndex, var_s0); - *var_t4 = 4; - if (temp_f2 > 0.1) { - *var_t4 = 2; - } - if (temp_f2 < -0.1) { - *var_t4 = 3; - } - } - var_t4 = &D_80164580[pathIndex][0]; - for (var_s0 = 0; var_s0 < var_a3; var_s0++, var_t4++) { - if (*var_t4 == 4) { - for (var_t2 = 1; var_t2 < var_a3; var_t2++) { - wut = &D_80164580[pathIndex][(var_s0 + var_t2) % var_a3]; - switch (*wut) { - case 0: - case 2: - for (var_a2 = 0; var_a2 < var_t2; var_a2++) { - D_80164580[pathIndex][(var_s0 + var_a2) % var_a3] = 0; - } - var_s0 += var_t2; - var_t4 += var_t2; - var_t2 = var_a3; - break; - case 1: - case 3: - for (var_a2 = 0; var_a2 < var_t2; var_a2++) { - D_80164580[pathIndex][(var_s0 + var_a2) % var_a3] = 1; - } - var_s0 += var_t2; - var_t4 += var_t2; - var_t2 = var_a3; - break; - } - } - } - } - } -} - -// Seemingly calculates the atan2 angle between a waypoint and its forward neighbor -s16 func_80010CB0(s32 pathIndex, s32 waypointIndex) { - s16 ret; - Vec3f sp30; - Vec3f sp24; - TrackWaypoint* temp_v0; - - temp_v0 = &D_80164550[pathIndex][waypointIndex]; - sp30[0] = temp_v0->posX; - sp30[1] = temp_v0->posY; - sp30[2] = temp_v0->posZ; - temp_v0 = &D_80164550[pathIndex][(waypointIndex + 1) % gWaypointCountByPathIndex[pathIndex]]; - sp24[0] = temp_v0->posX; - sp24[1] = temp_v0->posY; - sp24[2] = temp_v0->posZ; - ret = get_angle_between_two_vectors(sp30, sp24); - return -ret; -} - -// Populates D_80164590 -void func_80010DBC(s32 pathIndex) { - s32 waypointIndex; - u16* angle; - - if ((s32) GET_COURSE_AIMaximumSeparation >= 0) { - for (angle = (u16*) &D_80164590[pathIndex][0], waypointIndex = 0; - waypointIndex < gWaypointCountByPathIndex[pathIndex]; waypointIndex++, angle++) { - *angle = func_80010CB0(pathIndex, waypointIndex); - } - } -} - -void func_80010E6C(s32 pathIndex) { - s16* var_a2; - s16 var_a0; - s16 temp_t0; - s32 temp_v0; - s16* temp; - s32 i, j; - - temp_v0 = gWaypointCountByPathIndex[pathIndex]; - temp = D_80164580[pathIndex]; - var_a2 = D_801645A0[pathIndex]; - - for (i = 0; i < temp_v0; i++) { - var_a0 = 0; - for (j = 0; j < temp_v0; j++) { - temp_t0 = temp[(i + j) % temp_v0]; - if ((temp_t0 == 1) || (temp_t0 == 0)) { - var_a0 += 1; - } else { - break; - } - if (gCurrentCourseId == COURSE_AWARD_CEREMONY) { - break; - } - } - *var_a2 = var_a0; - var_a2++; - } -} - -f32 func_80010F40(f32 arg0, f32 arg1, f32 arg2, UNUSED s32 arg3, UNUSED s32 arg4) { - arg1 = get_surface_height(arg0, 2000.0f, arg2); - check_bounding_collision(&D_80162E70, 1.0f, arg0, arg1, arg2); - return arg1; -} - -f32 func_80010FA0(f32 arg0, f32 arg1, f32 arg2, UNUSED s32 arg3, UNUSED s32 arg4) { - arg1 = get_surface_height(arg0, (f32) ((f64) arg1 + 30.0), arg2); - check_bounding_collision(&D_80162E70, 10.0f, arg0, arg1, arg2); - return arg1; -} - -/** - * @return's the number of items processed. - */ -s32 func_80011014(TrackWaypoint* pathDest, TrackWaypoint* path, s32 numPathPoints, UNUSED s32 pathIndex) { - f32 temp_f24_2; - f32 temp_f2_3; - f32 var_f20_2; - f32 x1; - f32 z1; - f32 x2; - f32 z2; - f32 x3; - f32 z3; - f32 x1_2; - f32 z1_3; - f32 temp_f20; - f32 var_f30; - f32 temp_f22; - f32 temp_f16; - s32 i; - - f32 j; - s32 var_s0; - f32 var_f28; - - TrackWaypoint* point1; - TrackWaypoint* point2; - TrackWaypoint* point3; - f32 temp; - UNUSED TrackWaypoint* dest; - var_f30 = 0.0f; - var_s0 = 0; - temp_f20 = (f32) path[0].posX; - temp_f22 = (f32) path[0].posZ; - var_f28 = func_80010F40(temp_f20, 2000.0f, temp_f22, gCurrentCourseId, 0); - - for (i = 0; i < numPathPoints; i++) { - point1 = &path[i % numPathPoints]; - point2 = &path[(i + 1) % numPathPoints]; - point3 = &path[(s32) (i + 2) % numPathPoints]; - x1 = (f32) point1->posX; - z1 = (f32) point1->posZ; - x2 = (f32) point2->posX; - z2 = (f32) point2->posZ; - x3 = (f32) point3->posX; - z3 = (f32) point3->posZ; - - temp = 0.05 / (sqrtf(((x2 - x1) * (x2 - x1)) + ((z2 - z1) * (z2 - z1))) + - (sqrtf(((x3 - x2) * (x3 - x2)) + ((z3 - z2) * (z3 - z2))))); - - for (j = 0.0f; j <= 1.0; j += temp) { - - temp_f2_3 = (f32) ((1.0 - j) * 0.5 * (1.0 - j)); - z1_3 = (f32) (((1.0 - j) * j) + 0.5); - temp_f16 = (f32) (j * 0.5 * j); - - temp_f24_2 = (temp_f2_3 * x1) + (z1_3 * x2) + (temp_f16 * x3); - x1_2 = (temp_f2_3 * z1) + (z1_3 * z2) + (temp_f16 * z3); - - var_f30 += - sqrtf(((temp_f24_2 - temp_f20) * (temp_f24_2 - temp_f20)) + ((x1_2 - temp_f22) * (x1_2 - temp_f22))); - - temp_f20 = temp_f24_2; - temp_f22 = x1_2; - - if ((var_f30 > 20.0f) || ((i == 0) && (j == 0.0))) { - if (gIsMirrorMode) { - // temp_f12 = -temp_f24_2; - pathDest->posX = (s16) -temp_f24_2; - var_f20_2 = func_80010FA0(-temp_f24_2, var_f28, x1_2, gCurrentCourseId, var_s0); - } else { - pathDest->posX = (s16) temp_f24_2; - var_f20_2 = func_80010FA0(temp_f24_2, var_f28, x1_2, gCurrentCourseId, var_s0); - } - - pathDest->posZ = (s16) temp_f22; - pathDest->trackSectionId = get_track_section_id(D_80162E70.meshIndexZX); - - if (var_f20_2 < -500.0) { - var_f20_2 = var_f28; - } else { - - switch (gCurrentCourseId) { - case COURSE_RAINBOW_ROAD: - if (var_f20_2 < (var_f28 - 15.0)) { - var_f20_2 = (f32) var_f28 - 15.0; - } - break; - case COURSE_WARIO_STADIUM: - if ((var_s0 >= 1140) && (var_s0 <= 1152)) { - var_f20_2 = var_f28; - } else { - if (var_f20_2 < (var_f28 - 10.0)) { - var_f20_2 = (f32) (var_f28 - 4.0); - } - } - break; - case COURSE_DK_JUNGLE: - if ((var_s0 > 204) && (var_s0 < 220)) { - var_f20_2 = var_f28; - } else { - if (var_f20_2 < (var_f28 - 10.0)) { - var_f20_2 = (f32) (var_f28 - 4.0); - } - } - break; - default: - if (var_f20_2 < (var_f28 - 10.0)) { - var_f20_2 = (f32) var_f28 - 10.0; - } - break; - } - } - var_f28 = var_f20_2; - pathDest->posY = (s16) (s32) var_f20_2; - var_f30 = 0.0f; - pathDest++; - var_s0 += 1; - } - } - } - return var_s0; -} - -// Returns number of waypoints processed. -s32 process_path_data(TrackWaypoint* dest, TrackWaypoint* src) { - s16 temp_a0; - s16 temp_a2; - s16 temp_a3; - s32 var_v0; - s32 var_v1; - u16 temp_t0; - - var_v1 = 0; - for (var_v0 = 0; var_v0 < 0x7D0; var_v0++) { - temp_a0 = src->posX; - temp_a2 = src->posY; - temp_a3 = src->posZ; - temp_t0 = src->trackSectionId; - src++; - if (((temp_a0 & 0xFFFF) == 0x8000) && ((temp_a2 & 0xFFFF) == 0x8000) && ((temp_a3 & 0xFFFF) == 0x8000)) { - break; - } - if (gIsMirrorMode != 0) { - dest->posX = -temp_a0; - } else { - dest->posX = temp_a0; - } - var_v1++; - dest->posY = temp_a2; - dest->posZ = temp_a3; - dest->trackSectionId = temp_t0; - dest++; - } - return var_v1; -} - -s32 generate_2d_path(Path2D* pathDest, TrackWaypoint* pathSrc, s32 numWaypoints) { - f32 temp_f14_3; - f32 temp_f16_2; - UNUSED s32 pad; - - f32 x1; - f32 z1; - f32 x2; - f32 z2; - f32 x3; - f32 z3; - - UNUSED s32 pad2; - f32 temp_f24; - - f32 spA8; - f32 temp_f26; - f32 spA0; - - f32 temp_f2_3; - - TrackWaypoint* point1; - f32 j; - TrackWaypoint* point2; - TrackWaypoint* point3; - s32 i; - f32 temp_f6 = 0.0f; - s32 nbElement; - f32 sp7C; - - spA8 = pathSrc[0].posX; - spA0 = pathSrc[0].posZ; - nbElement = 0; - - for (i = 0; i < numWaypoints; i++) { - point1 = &pathSrc[((i % numWaypoints))]; - point2 = &pathSrc[(((i + 1) % numWaypoints))]; - point3 = &pathSrc[(((i + 2) % numWaypoints))]; - x1 = point1->posX; - z1 = point1->posZ; - x2 = point2->posX; - z2 = point2->posZ; - x3 = point3->posX; - z3 = point3->posZ; - - sp7C = 0.05 / (sqrtf(((x2 - x1) * (x2 - x1)) + ((z2 - z1) * (z2 - z1))) + - sqrtf(((x3 - x2) * (x3 - x2)) + ((z3 - z2) * (z3 - z2)))); - - for (j = 0.0f; j <= 1.0; j += sp7C) { - temp_f2_3 = (1.0 - j) * 0.5 * (1.0 - j); - temp_f14_3 = ((1.0 - j) * j) + 0.5; - temp_f16_2 = j * 0.5 * j; - - temp_f24 = (temp_f2_3 * x1) + (temp_f14_3 * x2) + (temp_f16_2 * x3); - temp_f26 = (temp_f2_3 * z1) + (temp_f14_3 * z2) + (temp_f16_2 * z3); - temp_f6 += sqrtf(((temp_f24 - spA8) * (temp_f24 - spA8)) + ((temp_f26 - spA0) * (temp_f26 - spA0))); - spA8 = temp_f24; - spA0 = temp_f26; - if ((temp_f6 > 20.0f) || ((i == 0) && (j == 0.0))) { - if (gIsMirrorMode) { - pathDest->x = (s16) -spA8; - } else { - pathDest->x = (s16) spA8; - } - pathDest->z = spA0; - nbElement += 1; - pathDest++; - temp_f6 = 0.0f; - } - } - } - return nbElement; -} - -void copy_courses_kart_ai_behaviour(void) { - s32 i; - for (i = 0; i < NUM_COURSES - 1; i++) { - gCoursesKartAIBehaviour[i] = GET_COURSE_AIBehaviour; - } -} - -void reset_kart_ai_behaviour_none(s32 playerIndex) { - gCurrentKartAIBehaviourId[playerIndex] = 0; - gPreviousKartAIBehaviourId[playerIndex] = 0; - gKartAIBehaviourState[playerIndex] = KART_AI_BEHAVIOUR_STATE_NONE; -} - -void reset_kart_ai_behaviour(s32 playerIndex) { - gCurrentKartAIBehaviourId[playerIndex] = 0; - gPreviousKartAIBehaviourId[playerIndex] = 0; - gKartAIBehaviourState[playerIndex] = KART_AI_BEHAVIOUR_STATE_START; -} - -void kart_ai_behaviour_start(s32 playerId, Player* player) { - u16 playerWaypoint; - s16 waypointStart; - s16 waypointEnd; - s32 behaviourType; - UNUSED s32 test; - - sCurrentKartAIBehaviour = &gCoursesKartAIBehaviour[gCurrentCourseId][gCurrentKartAIBehaviourId[playerId]]; - - playerWaypoint = gNearestWaypointByPlayerId[playerId]; - - waypointStart = sCurrentKartAIBehaviour->waypointStart; - waypointEnd = sCurrentKartAIBehaviour->waypointEnd; - behaviourType = sCurrentKartAIBehaviour->type; - - if ((waypointStart == -1) && (waypointEnd == -1)) { - sCurrentKartAIBehaviour = &gCoursesKartAIBehaviour[gCurrentCourseId][0]; - reset_kart_ai_behaviour_none(playerId); - return; - } - if ((u32) playerWaypoint == (u32) waypointStart) { - gKartAIBehaviourState[playerId] = KART_AI_BEHAVIOUR_STATE_RUNNING; - gPreviousKartAIBehaviourId[playerId] = gCurrentKartAIBehaviourId[playerId]; - gCurrentKartAIBehaviourId[playerId]++; - switch (behaviourType) { - case BEHAVIOUR_1: - func_80011EC0(playerId, player, player->unk_07C >> 0x10, playerWaypoint); - break; - case BEHAVIOUR_HOP: - kart_hop(player); - player->effects &= ~0x10; - D_801630E8[playerId] = 0; - break; - case BEHAVIOUR_3: - D_801634F8[playerId].unk4 = 0.0f; - break; - case BEHAVIOUR_4: - D_801634F8[playerId].unk4 = -0.6f; - break; - case BEHAVIOUR_5: - D_801634F8[playerId].unk4 = 0.6f; - break; - case BEHAVIOUR_NORMAL_SPEED: - gSpeedKartAIBehaviour[playerId] = SPEED_KART_AI_BEHAVIOUR_NORMAL; - break; - case BEHAVIOUR_FAST_SPEED: - gSpeedKartAIBehaviour[playerId] = SPEED_KART_AI_BEHAVIOUR_FAST; - break; - case BEHAVIOUR_SLOW_SPEED: - gSpeedKartAIBehaviour[playerId] = SPEED_KART_AI_BEHAVIOUR_SLOW; - break; - case BEHAVIOUR_MAX_SPEED: - gSpeedKartAIBehaviour[playerId] = SPEED_KART_AI_BEHAVIOUR_MAX; - break; - case BEHAVIOUR_9: - D_801633F8[playerId] = 1; - D_801631E0[playerId] = 0; - gPlayers[playerId].effects &= ~0x1000; - break; - case BEHAVIOUR_10: - D_801633F8[playerId] = 0; - break; - } - } -} - -void kart_ai_behaviour_end(s32 playerIndex, Player* player) { - u16 nearestWaypoint; - u32 waypointEnd; - s32 behaviourType; - - sCurrentKartAIBehaviour = &gCoursesKartAIBehaviour[gCurrentCourseId][gPreviousKartAIBehaviourId[playerIndex]]; - nearestWaypoint = gNearestWaypointByPlayerId[playerIndex]; - behaviourType = sCurrentKartAIBehaviour->type; - waypointEnd = sCurrentKartAIBehaviour->waypointEnd; - if (nearestWaypoint >= waypointEnd) { - switch (behaviourType) { - case BEHAVIOUR_1: - player->effects &= ~0x10; - D_801630E8[playerIndex] = 0; - gKartAIBehaviourState[playerIndex] = KART_AI_BEHAVIOUR_STATE_START; - break; - case BEHAVIOUR_3: - case BEHAVIOUR_4: - case BEHAVIOUR_5: - D_801634F8[playerIndex].unk4 = D_801634F8[playerIndex].unkC; - gKartAIBehaviourState[playerIndex] = KART_AI_BEHAVIOUR_STATE_START; - break; - case BEHAVIOUR_HOP: - case BEHAVIOUR_NORMAL_SPEED: - case BEHAVIOUR_FAST_SPEED: - case BEHAVIOUR_SLOW_SPEED: - case BEHAVIOUR_9: - case BEHAVIOUR_10: - case BEHAVIOUR_MAX_SPEED: - gKartAIBehaviourState[playerIndex] = KART_AI_BEHAVIOUR_STATE_START; - break; - default: - break; - } - } -} - -void kart_ai_behaviour(s32 playerIndex) { - Player* player = gPlayerOne + playerIndex; - - switch (gKartAIBehaviourState[playerIndex]) { - case KART_AI_BEHAVIOUR_STATE_NONE: - break; - case KART_AI_BEHAVIOUR_STATE_START: - kart_ai_behaviour_start(playerIndex, player); - break; - case KART_AI_BEHAVIOUR_STATE_RUNNING: - kart_ai_behaviour_end(playerIndex, player); - break; - } -} - -void func_80011EC0(s32 arg0, Player* player, s32 arg2, UNUSED u16 arg3) { - if ((((player->unk_094 / 18.0f) * 216.0f) >= 45.0f) && (D_801630E8[arg0] == 0)) { - switch (D_801631D8[sSomeNearestWaypoint]) { - case 0: - case 2: - if ((arg2 >= -9) && (D_80162FF8[arg0] == 0)) { - if ((D_80163068[arg0] > -0.8) && (D_80163068[arg0] < 0.5)) { - kart_hop(player); - player->effects |= 0x10; - D_801630E8[arg0] = 1; - break; - } - } - D_801630E8[arg0] = 2; - break; - case 1: - case 3: - if ((arg2 < 0xA) && (D_80162FF8[arg0] == 0)) { - if ((D_80163068[arg0] > -0.5) && (D_80163068[arg0] < 0.8)) { - kart_hop(player); - player->effects |= 0x10; - D_801630E8[arg0] = -1; - break; - } - } - D_801630E8[arg0] = -2; - break; - } - } else { - D_801630E8[arg0] = 3; - } -} - -#define GET_PATH_LENGTH(waypoint) \ - for (i = 0;; i++) { \ - if ((u16) waypoint[i].posX == 0x8000) { \ - break; \ - } \ - } - -void generate_train_waypoints(void) { - s32 i; - Path2D* temp; - TrackWaypoint* waypoint = - (TrackWaypoint*) VIRTUAL_TO_PHYSICAL2(gSegmentTable[SEGMENT_NUMBER2(d_course_kalimari_desert_train_waypoints)] + - SEGMENT_OFFSET(d_course_kalimari_desert_train_waypoints)); - - GET_PATH_LENGTH(waypoint) - - temp = gVehicle2DWaypoint; - gVehicle2DWaypointLength = generate_2d_path(temp, waypoint, i - 1); - D_80162EB0 = get_surface_height(temp[0].x, 2000.0f, temp[0].z); -} - -void generate_ferry_waypoints(void) { - TrackWaypoint* waypoint; - s32 i; - - waypoint = (TrackWaypoint*) VIRTUAL_TO_PHYSICAL2( - gSegmentTable[SEGMENT_NUMBER2(d_course_dks_jungle_parkway_ferry_waypoints)] + - (SEGMENT_OFFSET(d_course_dks_jungle_parkway_ferry_waypoints))); - - GET_PATH_LENGTH(waypoint) - - gVehicle2DWaypointLength = generate_2d_path(gVehicle2DWaypoint, waypoint, i - 1); - D_80162EB2 = -40; -} - -void spawn_vehicle_on_road(VehicleStuff* vehicle) { - f32 origXPos; - UNUSED f32 pad; - f32 origZPos; - - origXPos = vehicle->position[0]; - origZPos = vehicle->position[2]; - if (D_8016347A == 0) { - func_8000D6D0(vehicle->position, (s16*) &vehicle->waypointIndex, vehicle->speed, - vehicle->someMultiplierTheSequel, 0, 3); - vehicle->rotation[0] = 0; - vehicle->rotation[1] = -0x8000; - vehicle->rotation[2] = 0; - } else { - func_8000D940(vehicle->position, (s16*) &vehicle->waypointIndex, vehicle->speed, - vehicle->someMultiplierTheSequel, 0); - vehicle->rotation[0] = 0; - vehicle->rotation[1] = 0; - vehicle->rotation[2] = 0; - } - vehicle->velocity[0] = vehicle->position[0] - origXPos; - vehicle->velocity[2] = vehicle->position[2] - origZPos; -} - -void spawn_course_vehicles(void) { - s16 trainCarYRot; - UNUSED Vec3f pad; - TrainCarStuff* tempLocomotive; - TrainCarStuff* tempTender; - TrainCarStuff* tempPassengerCar; - Vec3s trainCarRot; - VehicleStuff* tempBoxTruck; - VehicleStuff* tempSchoolBus; - VehicleStuff* tempTankerTruck; - VehicleStuff* tempCar; - PaddleBoatStuff* tempPaddleWheelBoat; - Vec3s paddleWheelBoatRot; - s32 loopIndex; - s32 loopIndex2; - f32 origXPos; - f32 origZPos; - -#if !ENABLE_CUSTOM_COURSE_ENGINE - switch (gCurrentCourseId) { - case COURSE_KALAMARI_DESERT: - for (loopIndex = 0; loopIndex < NUM_TRAINS; loopIndex++) { - tempLocomotive = &gTrainList[loopIndex].locomotive; - origXPos = tempLocomotive->position[0]; - origZPos = tempLocomotive->position[2]; - trainCarYRot = update_vehicle_following_waypoint( - tempLocomotive->position, (s16*) &tempLocomotive->waypointIndex, gTrainList[loopIndex].speed); - tempLocomotive->velocity[0] = tempLocomotive->position[0] - origXPos; - tempLocomotive->velocity[2] = tempLocomotive->position[2] - origZPos; - vec3s_set(trainCarRot, 0, trainCarYRot, 0); - tempLocomotive->actorIndex = add_actor_to_empty_slot(tempLocomotive->position, trainCarRot, - tempLocomotive->velocity, ACTOR_TRAIN_ENGINE); - - tempTender = &gTrainList[loopIndex].tender; - if (tempTender->isActive == 1) { - origXPos = tempTender->position[0]; - origZPos = tempTender->position[2]; - trainCarYRot = update_vehicle_following_waypoint( - tempTender->position, (s16*) &tempTender->waypointIndex, gTrainList[loopIndex].speed); - tempTender->velocity[0] = tempTender->position[0] - origXPos; - tempTender->velocity[2] = tempTender->position[2] - origZPos; - vec3s_set(trainCarRot, 0, trainCarYRot, 0); - tempTender->actorIndex = add_actor_to_empty_slot(tempTender->position, trainCarRot, - tempTender->velocity, ACTOR_TRAIN_TENDER); - } - - for (loopIndex2 = 0; loopIndex2 < NUM_PASSENGER_CAR_ENTRIES; loopIndex2++) { - tempPassengerCar = &gTrainList[loopIndex].passengerCars[loopIndex2]; - if (tempPassengerCar->isActive == 1) { - origXPos = tempPassengerCar->position[0]; - origZPos = tempPassengerCar->position[2]; - trainCarYRot = update_vehicle_following_waypoint(tempPassengerCar->position, - (s16*) &tempPassengerCar->waypointIndex, - gTrainList[loopIndex].speed); - tempPassengerCar->velocity[0] = tempPassengerCar->position[0] - origXPos; - tempPassengerCar->velocity[2] = tempPassengerCar->position[2] - origZPos; - vec3s_set(trainCarRot, 0, trainCarYRot, 0); - tempPassengerCar->actorIndex = - add_actor_to_empty_slot(tempPassengerCar->position, trainCarRot, tempPassengerCar->velocity, - ACTOR_TRAIN_PASSENGER_CAR); - } - } - } - break; - case COURSE_DK_JUNGLE: - for (loopIndex = 0; loopIndex < NUM_ACTIVE_PADDLE_BOATS; loopIndex++) { - tempPaddleWheelBoat = &gPaddleBoats[loopIndex]; - if (tempPaddleWheelBoat->isActive == 1) { - origXPos = tempPaddleWheelBoat->position[0]; - origZPos = tempPaddleWheelBoat->position[2]; - tempPaddleWheelBoat->rotY = update_vehicle_following_waypoint( - tempPaddleWheelBoat->position, (s16*) &tempPaddleWheelBoat->waypointIndex, - tempPaddleWheelBoat->speed); - tempPaddleWheelBoat->velocity[0] = tempPaddleWheelBoat->position[0] - origXPos; - tempPaddleWheelBoat->velocity[2] = tempPaddleWheelBoat->position[2] - origZPos; - vec3s_set(paddleWheelBoatRot, 0, tempPaddleWheelBoat->rotY, 0); - tempPaddleWheelBoat->actorIndex = - add_actor_to_empty_slot(tempPaddleWheelBoat->position, paddleWheelBoatRot, - tempPaddleWheelBoat->velocity, ACTOR_PADDLE_BOAT); - } - } - break; - case COURSE_TOADS_TURNPIKE: - for (loopIndex = 0; loopIndex < NUM_RACE_BOX_TRUCKS; loopIndex++) { - tempBoxTruck = &gBoxTruckList[loopIndex]; - spawn_vehicle_on_road(tempBoxTruck); - tempBoxTruck->actorIndex = add_actor_to_empty_slot(tempBoxTruck->position, tempBoxTruck->rotation, - tempBoxTruck->velocity, ACTOR_BOX_TRUCK); - } - for (loopIndex = 0; loopIndex < NUM_RACE_SCHOOL_BUSES; loopIndex++) { - tempSchoolBus = &gSchoolBusList[loopIndex]; - spawn_vehicle_on_road(tempSchoolBus); - tempSchoolBus->actorIndex = add_actor_to_empty_slot(tempSchoolBus->position, tempSchoolBus->rotation, - tempSchoolBus->velocity, ACTOR_SCHOOL_BUS); - } - for (loopIndex = 0; loopIndex < NUM_RACE_TANKER_TRUCKS; loopIndex++) { - tempTankerTruck = &gTankerTruckList[loopIndex]; - spawn_vehicle_on_road(tempTankerTruck); - tempTankerTruck->actorIndex = - add_actor_to_empty_slot(tempTankerTruck->position, tempTankerTruck->rotation, - tempTankerTruck->velocity, ACTOR_TANKER_TRUCK); - } - for (loopIndex = 0; loopIndex < NUM_RACE_CARS; loopIndex++) { - tempCar = &gCarList[loopIndex]; - spawn_vehicle_on_road(tempCar); - tempCar->actorIndex = - add_actor_to_empty_slot(tempCar->position, tempCar->rotation, tempCar->velocity, ACTOR_CAR); - } - break; - } -#else - -#endif -} - -void set_vehicle_pos_waypoint(TrainCarStuff* trainCar, Path2D* posXZ, u16 waypoint) { - trainCar->position[0] = (f32) posXZ->x; - trainCar->position[1] = (f32) D_80162EB0; - trainCar->position[2] = (f32) posXZ->z; - trainCar->actorIndex = -1; - trainCar->waypointIndex = waypoint; - trainCar->isActive = 0; - trainCar->velocity[0] = 0.0f; - trainCar->velocity[1] = 0.0f; - trainCar->velocity[2] = 0.0f; -} - -/** - * Set waypoint spawn locations for each rolling stock - * The railroad has 465 waypoints - */ -void init_vehicles_trains(void) { - u16 waypointOffset; - TrainCarStuff* ptr1; - Path2D* pos; - s32 i; - s32 j; - - for (i = 0; i < NUM_TRAINS; i++) { - // outputs 160 or 392 depending on the train. - // Wraps the value around to always output a valid waypoint. - waypointOffset = (((i * gVehicle2DWaypointLength) / NUM_TRAINS) + 160) % gVehicle2DWaypointLength; - - // 120.0f is about the maximum usable value - gTrainList[i].speed = 5.0f; - for (j = 0; j < NUM_PASSENGER_CAR_ENTRIES; j++) { - waypointOffset += 4; - ptr1 = &gTrainList[i].passengerCars[j]; - pos = &gVehicle2DWaypoint[waypointOffset]; - set_vehicle_pos_waypoint(ptr1, pos, waypointOffset); - } - // Smaller offset for the tender - waypointOffset += 3; - ptr1 = &gTrainList[i].tender; - pos = &gVehicle2DWaypoint[waypointOffset]; - set_vehicle_pos_waypoint(ptr1, pos, waypointOffset); - - waypointOffset += 4; - ptr1 = &gTrainList[i].locomotive; - pos = &gVehicle2DWaypoint[waypointOffset]; - set_vehicle_pos_waypoint(ptr1, pos, waypointOffset); - - // Only use locomotive unless overwritten below. - gTrainList[i].numCars = LOCOMOTIVE_ONLY; - } - - // Spawn all rolling stock in single player mode. - switch (gScreenModeSelection) { - case SCREEN_MODE_1P: // single player - for (i = 0; i < NUM_TRAINS; i++) { - gTrainList[i].tender.isActive = 1; - - // clang-format off - // Same line required for matching... - for (j = 0; j < NUM_PASSENGER_CAR_ENTRIES; j++) { gTrainList[i].passengerCars[j].isActive = 1; } - // clang-format on - - gTrainList[i].numCars = NUM_TENDERS + NUM_PASSENGER_CAR_ENTRIES; - } - break; - - // Spawn locomotive, tender, and one passenger car in versus 2/3 player mode. - case SCREEN_MODE_2P_SPLITSCREEN_HORIZONTAL: // multiplayer fall-through - case SCREEN_MODE_2P_SPLITSCREEN_VERTICAL: - if (gModeSelection != GRAND_PRIX) { - for (i = 0; i < NUM_TRAINS; i++) { - gTrainList[i].tender.isActive = 1; - gTrainList[i].passengerCars[4].isActive = 1; - gTrainList[i].numCars = NUM_TENDERS + NUM_2P_PASSENGER_CARS; - } - } - break; - } - - gTrainSmokeTimer = 0; -} -/** - * @brief sync the train components vehicle with the actor - * - * @param trainCar - * @param orientationY - */ -void sync_train_components(TrainCarStuff* trainCar, s16 orientationY) { - struct TrainCar* trainCarActor; - - trainCarActor = (struct TrainCar*) &gActorList[trainCar->actorIndex]; - trainCarActor->pos[0] = trainCar->position[0]; - trainCarActor->pos[1] = trainCar->position[1]; - trainCarActor->pos[2] = trainCar->position[2]; - if (gIsMirrorMode != 0) { - trainCarActor->rot[1] = -orientationY; - } else { - trainCarActor->rot[1] = orientationY; - } - trainCarActor->velocity[0] = trainCar->velocity[0]; - trainCarActor->velocity[2] = trainCar->velocity[2]; -} - -void update_vehicle_trains(void) { - UNUSED s32 pad[3]; - f32 temp_f20; - TrainCarStuff* car; - u16 oldWaypointIndex; - s16 orientationYUpdate; - f32 temp_f22; - s32 i; - s32 j; - Vec3f smokePos; - - gTrainSmokeTimer += 1; - - for (i = 0; i < NUM_TRAINS; i++) { - oldWaypointIndex = (u16) gTrainList[i].locomotive.waypointIndex; - - temp_f20 = gTrainList[i].locomotive.position[0]; - temp_f22 = gTrainList[i].locomotive.position[2]; - - orientationYUpdate = update_vehicle_following_waypoint( - gTrainList[i].locomotive.position, (s16*) &gTrainList[i].locomotive.waypointIndex, gTrainList[i].speed); - - gTrainList[i].locomotive.velocity[0] = gTrainList[i].locomotive.position[0] - temp_f20; - gTrainList[i].locomotive.velocity[2] = gTrainList[i].locomotive.position[2] - temp_f22; - - sync_train_components(&gTrainList[i].locomotive, orientationYUpdate); - - if ((oldWaypointIndex != gTrainList[i].locomotive.waypointIndex) && - ((gTrainList[i].locomotive.waypointIndex == 0x00BE) || - (gTrainList[i].locomotive.waypointIndex == 0x0140))) { // play crossing bell sound - func_800C98B8(gTrainList[i].locomotive.position, gTrainList[i].locomotive.velocity, - SOUND_ARG_LOAD(0x19, 0x01, 0x80, 0x0E)); - } else if (random_int(100) == 0) { // play train whistle sound - func_800C98B8(gTrainList[i].locomotive.position, gTrainList[i].locomotive.velocity, - SOUND_ARG_LOAD(0x19, 0x01, 0x80, 0x0D)); - } - - gTrainList[i].someFlags = set_vehicle_render_distance_flags( - gTrainList[i].locomotive.position, TRAIN_SMOKE_RENDER_DISTANCE, gTrainList[i].someFlags); - // Renders locomotive smoke on all screens if any player is within range. - if ((((s16) gTrainSmokeTimer % 5) == 0) && (gTrainList[i].someFlags != 0)) { - smokePos[0] = gTrainList[i].locomotive.position[0]; - smokePos[1] = (f32) ((f64) gTrainList[i].locomotive.position[1] + 65.0); - smokePos[2] = (f32) ((f64) gTrainList[i].locomotive.position[2] + 25.0); - adjust_position_by_angle(smokePos, gTrainList[i].locomotive.position, orientationYUpdate); - spawn_train_smoke(i, smokePos, 1.1f); - } - - car = &gTrainList[i].tender; - - if (car->isActive == 1) { - temp_f20 = car->position[0]; - temp_f22 = car->position[2]; - orientationYUpdate = - update_vehicle_following_waypoint(car->position, (s16*) &car->waypointIndex, gTrainList[i].speed); - car->velocity[0] = car->position[0] - temp_f20; - car->velocity[2] = car->position[2] - temp_f22; - sync_train_components(car, orientationYUpdate); - } - - for (j = 0; j < NUM_PASSENGER_CAR_ENTRIES; j++) { - car = &gTrainList[i].passengerCars[j]; - if (car->isActive == 1) { - temp_f20 = car->position[0]; - temp_f22 = car->position[2]; - - orientationYUpdate = - update_vehicle_following_waypoint(car->position, (s16*) &car->waypointIndex, gTrainList[i].speed); - car->velocity[0] = car->position[0] - temp_f20; - car->velocity[2] = car->position[2] - temp_f22; - sync_train_components(car, orientationYUpdate); - } - } - } -} - -void func_80012DC0(s32 playerId, Player* player) { - TrainCarStuff* trainCar; - f32 playerPosX; - f32 playerPosZ; - f32 x_dist; - f32 z_dist; - s32 trainIndex; - s32 passengerCarIndex; - - if (D_801631E0[playerId] != 1) { - if (!(player->effects & 0x01000000)) { - playerPosX = player->pos[0]; - playerPosZ = player->pos[2]; - for (trainIndex = 0; trainIndex < NUM_TRAINS; trainIndex++) { - trainCar = &gTrainList[trainIndex].locomotive; - x_dist = playerPosX - trainCar->position[0]; - z_dist = playerPosZ - trainCar->position[2]; - if ((x_dist > -100.0) && (x_dist < 100.0)) { - if ((z_dist > -100.0) && (z_dist < 100.0)) { - if (func_80006018(trainCar->position[0], trainCar->position[2], trainCar->velocity[0], - trainCar->velocity[2], 60.0f, 20.0f, playerPosX, playerPosZ) == 1) { - player->soundEffects |= REVERSE_SOUND_EFFECT; - } - trainCar = &gTrainList[trainIndex].tender; - if (trainCar->isActive == 1) { - if (func_80006018(trainCar->position[0], trainCar->position[2], trainCar->velocity[0], - trainCar->velocity[2], 30.0f, 20.0f, playerPosX, playerPosZ) == 1) { - player->soundEffects |= REVERSE_SOUND_EFFECT; - } - } - } - } - - for (passengerCarIndex = 0; passengerCarIndex < NUM_PASSENGER_CAR_ENTRIES; passengerCarIndex++) { - trainCar = &gTrainList[trainIndex].passengerCars[passengerCarIndex]; - x_dist = playerPosX - trainCar->position[0]; - z_dist = playerPosZ - trainCar->position[2]; - if (trainCar->isActive == 1) { - if ((x_dist > -100.0) && (x_dist < 100.0)) { - if ((z_dist > -100.0) && (z_dist < 100.0)) { - if (func_80006018(trainCar->position[0], trainCar->position[2], trainCar->velocity[0], - trainCar->velocity[2], 30.0f, 20.0f, playerPosX, playerPosZ) == 1) { - player->soundEffects |= REVERSE_SOUND_EFFECT; - } - } - } - } - } - } - } - } -} - -/** - * Appears to check if the train is close to the crossing. - * Implements sCrossingActiveTimer as a counter - */ -void func_80013054(void) { - f32 temp_f16; - f32 temp_f18; - f32 temp_f12; - s32 i; - isCrossingTriggeredByIndex[0] = 0; - isCrossingTriggeredByIndex[1] = 0; - - for (i = 0; i < NUM_TRAINS; i++) { - temp_f16 = gTrainList[i].locomotive.waypointIndex / ((f32) gVehicle2DWaypointLength); - temp_f18 = 0.72017354f; - temp_f12 = 0.42299348f; - - if (((temp_f12 - 0.1) < temp_f16) && - (temp_f16 < ((((f64) gTrainList[i].numCars) * 0.01) + (temp_f12 + 0.01)))) { - - isCrossingTriggeredByIndex[0] = 1; - } - if (((temp_f18 - 0.1) < temp_f16) && - (temp_f16 < ((((f64) gTrainList[i].numCars) * 0.01) + (temp_f18 + 0.01)))) { - - isCrossingTriggeredByIndex[1] = 1; - } - } - - for (i = 0; i < NUM_CROSSINGS; i++) { - if (isCrossingTriggeredByIndex[i] == 1) { - sCrossingActiveTimer[i] += 1; - } else { - sCrossingActiveTimer[i] = 0; - } - } -} - -void check_ai_crossing_distance(s32 playerId) { - bStopAICrossing[playerId] = 0; - if (gCurrentCourseId == COURSE_KALAMARI_DESERT) { - if ((!(D_801631E0[playerId] != 0)) || - (set_vehicle_render_distance_flags(gPlayers[playerId].pos, TRAIN_CROSSING_AI_DISTANCE, 0))) { - - if ((isCrossingTriggeredByIndex[1] == 1) && ((sCrossingActiveTimer[1]) > FRAMES_SINCE_CROSSING_ACTIVATED)) { - - if ((sSomeNearestWaypoint > 176) && (sSomeNearestWaypoint < 182)) { - bStopAICrossing[playerId] = 1; - } - } - if ((isCrossingTriggeredByIndex[0] == 1) && ((sCrossingActiveTimer[0]) > FRAMES_SINCE_CROSSING_ACTIVATED)) { - if ((sSomeNearestWaypoint >= 306) && (sSomeNearestWaypoint < 310)) { - bStopAICrossing[playerId] = 1; - } - } - } - } -} - -void init_vehicles_ferry(void) { - PaddleBoatStuff* paddleBoat; - s32 i; - Path2D* temp_a2; - u16 temp; - for (i = 0; i < NUM_ACTIVE_PADDLE_BOATS; i++) { - temp = i * 0xB4; - paddleBoat = &gPaddleBoats[i]; - temp_a2 = &gVehicle2DWaypoint[temp]; - paddleBoat->position[0] = temp_a2->x; - paddleBoat->position[1] = D_80162EB2; - paddleBoat->position[2] = temp_a2->z; - paddleBoat->waypointIndex = i * 0xB4; - paddleBoat->actorIndex = -1; - - if (gPlayerCount >= 3) { - paddleBoat->isActive = 0; - } else { - paddleBoat->isActive = 1; - } - paddleBoat->velocity[0] = 0.0f; - paddleBoat->velocity[1] = 0.0f; - paddleBoat->velocity[2] = 0.0f; - paddleBoat->speed = 1.6666666f; - paddleBoat->rotY = 0; - } - gFerrySmokeTimer = 0; -} - -void update_vehicle_paddle_boats(void) { - PaddleBoatStuff* paddleBoat; - Path2D* waypoint; - s32 i; - struct Actor* paddleBoatActor; - f32 temp_f26; - f32 temp_f28; - f32 temp_f30; - s16 temp_a1; - s32 temp; - s16 var_v1; - Vec3f sp94; - Vec3f sp88; - UNUSED s32 pad; - Vec3f smokePos; - UNUSED s32 pad2; - gFerrySmokeTimer += 1; - for (i = 0; i < NUM_ACTIVE_PADDLE_BOATS; i++) { - paddleBoat = &gPaddleBoats[i]; - if (paddleBoat->isActive == 1) { - temp_f26 = paddleBoat->position[0]; - temp_f28 = paddleBoat->position[1]; - temp_f30 = paddleBoat->position[2]; - update_vehicle_following_waypoint(paddleBoat->position, (s16*) &paddleBoat->waypointIndex, - paddleBoat->speed); - paddleBoat->someFlags = set_vehicle_render_distance_flags(paddleBoat->position, BOAT_SMOKE_RENDER_DISTANCE, - paddleBoat->someFlags); - if ((((s16) gFerrySmokeTimer % 10) == 0) && (paddleBoat->someFlags != 0)) { - smokePos[0] = (f32) ((f64) paddleBoat->position[0] - 30.0); - smokePos[1] = (f32) ((f64) paddleBoat->position[1] + 180.0); - smokePos[2] = (f32) ((f64) paddleBoat->position[2] + 45.0); - adjust_position_by_angle(smokePos, paddleBoat->position, paddleBoat->rotY); - spawn_ferry_smoke(i, smokePos, 1.1f); - smokePos[0] = (f32) ((f64) paddleBoat->position[0] + 30.0); - smokePos[1] = (f32) ((f64) paddleBoat->position[1] + 180.0); - smokePos[2] = (f32) ((f64) paddleBoat->position[2] + 45.0); - adjust_position_by_angle(smokePos, paddleBoat->position, paddleBoat->rotY); - spawn_ferry_smoke(i, smokePos, 1.1f); - } - if (random_int(100) == 0) { - if (random_int(2) == 0) { - func_800C98B8(paddleBoat->position, paddleBoat->velocity, SOUND_ARG_LOAD(0x19, 0x01, 0x80, 0x47)); - } else { - func_800C98B8(paddleBoat->position, paddleBoat->velocity, SOUND_ARG_LOAD(0x19, 0x01, 0x80, 0x48)); - } - } - sp94[0] = temp_f26; - sp94[1] = temp_f28; - sp94[2] = temp_f30; - waypoint = &gVehicle2DWaypoint[(paddleBoat->waypointIndex + 5) % gVehicle2DWaypointLength]; - sp88[0] = (f32) waypoint->x; - sp88[1] = (f32) D_80162EB0; - sp88[2] = (f32) waypoint->z; - temp_a1 = get_angle_between_waypoints(sp94, sp88); - temp = temp_a1 - paddleBoat->rotY; - var_v1 = temp; - if (var_v1 < 0) { - var_v1 = -var_v1; - } - if (var_v1 >= 0x1771) { - if (paddleBoat->speed > 0.2) { - paddleBoat->speed -= 0.04; - } - if (var_v1 >= 0x3D) { - var_v1 = 0x003C; - } - } else { - if (paddleBoat->speed < 2.0) { - paddleBoat->speed += 0.02; - } - if (var_v1 >= 0x1F) { - var_v1 = 0x001E; - } - } - if (temp >= 0x8000) { - paddleBoat->rotY -= var_v1; - } else if (temp > 0) { - paddleBoat->rotY += var_v1; - } else if (temp < -0x7FFF) { - paddleBoat->rotY += var_v1; - } else if (temp < 0) { - paddleBoat->rotY -= var_v1; - } - paddleBoat->velocity[0] = paddleBoat->position[0] - temp_f26; - paddleBoat->velocity[1] = paddleBoat->position[1] - temp_f28; - paddleBoat->velocity[2] = paddleBoat->position[2] - temp_f30; - paddleBoatActor = &gActorList[paddleBoat->actorIndex]; - paddleBoatActor->pos[0] = paddleBoat->position[0]; - paddleBoatActor->pos[1] = paddleBoat->position[1]; - paddleBoatActor->pos[2] = paddleBoat->position[2]; - if (gIsMirrorMode != 0) { - paddleBoatActor->rot[1] = -paddleBoat->rotY; - } else { - paddleBoatActor->rot[1] = paddleBoat->rotY; - } - paddleBoatActor->velocity[0] = paddleBoat->velocity[0]; - paddleBoatActor->velocity[1] = paddleBoat->velocity[1]; - paddleBoatActor->velocity[2] = paddleBoat->velocity[2]; - } - } -} - -void func_80013854(Player* player) { - s32 someIndex; - PaddleBoatStuff* tempPaddleWheelBoat; - f32 x_diff; - f32 y_diff; - f32 z_diff; - f32 playerX; - f32 playerZ; - f32 playerY; - - if (!((player->effects & 0x01000000)) && (!(player->effects & HIT_BY_ITEM_EFFECT))) { - playerX = player->pos[0]; - playerY = player->pos[1]; - playerZ = player->pos[2]; - for (someIndex = 0; someIndex < NUM_ACTIVE_PADDLE_BOATS; someIndex++) { - tempPaddleWheelBoat = &gPaddleBoats[someIndex]; - if (tempPaddleWheelBoat->isActive == 1) { - x_diff = playerX - tempPaddleWheelBoat->position[0]; - y_diff = playerY - tempPaddleWheelBoat->position[1]; - z_diff = playerZ - tempPaddleWheelBoat->position[2]; - if ((x_diff > -300.0) && (x_diff < 300.0)) { - if ((z_diff > -300.0) && (z_diff < 300.0)) { - if ((func_80006018(tempPaddleWheelBoat->position[0], tempPaddleWheelBoat->position[2], - tempPaddleWheelBoat->velocity[0], tempPaddleWheelBoat->velocity[2], 200.0f, - 60.0f, playerX, playerZ) == 1) && - (y_diff < 60.0)) { - player->soundEffects |= 0x80000; - } - } - } - } - } - } -} - -void initialize_toads_turnpike_vehicle(f32 speedA, f32 speedB, s32 numVehicles, s32 arg3, VehicleStuff* vehicleList, - TrackWaypoint* waypointList) { - VehicleStuff* veh; - TrackWaypoint* temp_v0; - s32 i; - u16 waypointOffset; - s32 numWaypoints = gWaypointCountByPathIndex[0]; - for (i = 0; i < numVehicles; i++) { - waypointOffset = (((i * numWaypoints) / numVehicles) + arg3) % numWaypoints; - veh = &vehicleList[i]; - temp_v0 = &waypointList[waypointOffset]; - veh->position[0] = (f32) temp_v0->posX; - veh->position[1] = (f32) temp_v0->posY; - veh->position[2] = (f32) temp_v0->posZ; - veh->actorIndex = -1; - veh->waypointIndex = waypointOffset; - veh->unused = 0; - veh->velocity[0] = 0.0f; - veh->velocity[1] = 0.0f; - veh->velocity[2] = 0.0f; - veh->someFlags = 0; - veh->someFlagsTheSequel = 0; - if (gModeSelection == TIME_TRIALS) { - veh->someType = (i % 3); - } else { - veh->someType = random_int(3); - } - veh->someMultiplierTheSequel = (f32) ((f64) (f32) (veh->someType - 1) * 0.6); - if (((gCCSelection > CC_50) || (gModeSelection == TIME_TRIALS)) && (veh->someType == 2)) { - veh->speed = speedA; - } else { - veh->speed = speedB; - } - veh->rotation[0] = 0; - veh->rotation[2] = 0; - if (D_8016347A == 0) { - veh->rotation[1] = func_8000D6D0(veh->position, (s16*) &veh->waypointIndex, veh->speed, - veh->someMultiplierTheSequel, 0, 3); - } else { - veh->rotation[1] = - func_8000D940(veh->position, (s16*) &veh->waypointIndex, veh->speed, veh->someMultiplierTheSequel, 0); - } - } - D_801631C8 = 10; -} - -f32 func_80013C74(s16 someType, s16 waypointIndex) { - f32 var_f2; - - var_f2 = 0.0f; - if (waypointIndex < 0x28A) { - switch (someType) { - case 0: - var_f2 = -0.7f; - break; - case 1: - break; - case 2: - var_f2 = 0.7f; - break; - default: - break; - } - } else { - switch (someType) { - case 0: - case 1: - var_f2 = -0.5f; - break; - case 2: - var_f2 = 0.5f; - break; - default: - break; - } - } - return var_f2; -} - -void update_vehicle_follow_waypoint(VehicleStuff* vehicle) { - f32 temp_f0_2; - f32 temp_f0_3; - f32 sp5C; - f32 sp58; - f32 sp54; - f32 temp_f2_2; - s16 var_a1; - s16 thing; - Vec3f sp40; - Vec3f sp34; - struct Actor* vehicleActor; - - sp5C = vehicle->position[0]; - sp58 = vehicle->position[1]; - sp54 = vehicle->position[2]; - sp40[0] = sp58; - sp40[1] = 0.0f; - sp40[2] = 0.0f; - temp_f0_2 = func_80013C74(vehicle->someType, vehicle->waypointIndex); - if (vehicle->someMultiplierTheSequel < temp_f0_2) { - vehicle->someMultiplierTheSequel = vehicle->someMultiplierTheSequel + 0.06; - if (temp_f0_2 < vehicle->someMultiplierTheSequel) { - vehicle->someMultiplierTheSequel = temp_f0_2; - } - } - if (temp_f0_2 < vehicle->someMultiplierTheSequel) { - vehicle->someMultiplierTheSequel = vehicle->someMultiplierTheSequel - 0.06; - if (vehicle->someMultiplierTheSequel < temp_f0_2) { - vehicle->someMultiplierTheSequel = temp_f0_2; - } - } - if (D_8016347A == 0) { - var_a1 = func_8000D6D0(vehicle->position, (s16*) &vehicle->waypointIndex, vehicle->speed, - vehicle->someMultiplierTheSequel, 0, 3); - } else { - var_a1 = func_8000D940(vehicle->position, (s16*) &vehicle->waypointIndex, vehicle->speed, - vehicle->someMultiplierTheSequel, 0); - } - adjust_angle(&vehicle->rotation[1], var_a1, 100); - temp_f0_3 = vehicle->position[0] - sp5C; - temp_f2_2 = vehicle->position[2] - sp54; - sp34[0] = vehicle->position[1]; - sp34[1] = 0.0f; - sp34[2] = sqrtf((temp_f0_3 * temp_f0_3) + (temp_f2_2 * temp_f2_2)); - thing = get_angle_between_two_vectors(sp40, sp34); - adjust_angle(&vehicle->rotation[0], -thing, 100); - vehicle->velocity[0] = vehicle->position[0] - sp5C; - vehicle->velocity[1] = vehicle->position[1] - sp58; - vehicle->velocity[2] = vehicle->position[2] - sp54; - vehicleActor = &gActorList[vehicle->actorIndex]; - vehicleActor->pos[0] = vehicle->position[0]; - vehicleActor->pos[1] = vehicle->position[1]; - vehicleActor->pos[2] = vehicle->position[2]; - vehicleActor->rot[0] = vehicle->rotation[0]; - if (gIsMirrorMode != 0) { - vehicleActor->rot[1] = -vehicle->rotation[1]; - } else { - vehicleActor->rot[1] = vehicle->rotation[1]; - } - vehicleActor->rot[2] = vehicle->rotation[2]; - vehicleActor->velocity[0] = vehicle->velocity[0]; - vehicleActor->velocity[1] = vehicle->velocity[1]; - vehicleActor->velocity[2] = vehicle->velocity[2]; -} - -void func_80013F7C(s32 playerId, Player* player, VehicleStuff* vehicle, f32 arg3, f32 arg4, s32 arg5, u32 soundBits) { - f32 temp_f12; - f32 temp_f14; - f32 temp_f22; - - s32 i; - - f32 spC4; - f32 spC0; - f32 spBC; - - if (((D_801631E0[playerId] != 1) || ((((player->type & PLAYER_HUMAN) != 0)) && !(player->type & PLAYER_KART_AI))) && - !(player->effects & 0x01000000)) { - - spC4 = player->pos[0]; - spC0 = player->pos[1]; - spBC = player->pos[2]; - - for (i = 0; i < arg5; i++) { - temp_f12 = spC4 - vehicle->position[0]; - temp_f22 = spC0 - vehicle->position[1]; - temp_f14 = spBC - vehicle->position[2]; - - if (((temp_f12) > -100.0) && ((temp_f12) < 100.0)) { - if ((temp_f22 > -20.0) && (temp_f22 < 20.0)) { - - if (((temp_f14) > -100.0) && ((temp_f14) < 100.0)) { - if (func_80006018(vehicle->position[0], vehicle->position[2], vehicle->velocity[0], - vehicle->velocity[2], arg3, arg4, spC4, spBC) == (s32) 1) { - player->soundEffects |= REVERSE_SOUND_EFFECT; - } - } - } - } - if ((player->type & PLAYER_HUMAN) && !(player->type & PLAYER_KART_AI)) { - if (((temp_f12) > -300.0) && ((temp_f12) < 300.0) && ((temp_f22 > -20.0)) && (temp_f22 < 20.0) && - (((temp_f14) > -300.0)) && ((temp_f14) < 300.0)) { - if ((D_801631C8 > 0) && (vehicle->someFlags == 0)) { - D_801631C8 -= 1; - vehicle->someFlags |= (RENDER_VEHICLE << playerId); - func_800C9D80(vehicle->position, vehicle->velocity, soundBits); - } - } else { - if (vehicle->someFlags != 0) { - vehicle->someFlags &= ~(RENDER_VEHICLE << playerId); - if (vehicle->someFlags == 0) { - D_801631C8 += 1; - func_800C9EF4(vehicle->position, soundBits); - } - } - } - - if (((temp_f12) > -200.0) && ((temp_f12) < 200.0) && ((temp_f22 > -20.0)) && (temp_f22 < 20.0) && - (((temp_f14) > -200.0)) && ((temp_f14) < 200.0)) { - if (!(vehicle->someFlagsTheSequel & ((1 << playerId)))) { - - s32 var_s1 = 0; - u16 path = gWaypointCountByPathIndex[0]; - s32 t1; - s32 t2; - - switch (D_8016347A) { - case 0: - t1 = func_80007BF8(vehicle->waypointIndex, gNearestWaypointByPlayerId[playerId], 10, 0, - path); - if ((D_80163270[playerId] == 0) && (t1 > 0) && (player->unk_094 < vehicle->speed)) { - var_s1 = 1; - } - if ((D_80163270[playerId] == 1) && (t1 > 0)) { - var_s1 = 1; - } - break; - case 1: - t2 = func_80007BF8(vehicle->waypointIndex, gNearestWaypointByPlayerId[playerId], 0, 10, - path); - if (t2 > 0) { - if (random_int(2) == 0) { - // temp_v1_2 = D_80163270[playerId]; - if (D_80163270[playerId] == 0) { - var_s1 = 1; - } - if ((D_80163270[playerId] == 1) && (player->unk_094 < vehicle->speed)) { - var_s1 = 1; - } - } else { - vehicle->someFlagsTheSequel |= ((1 << playerId)); - } - } - break; - } - if (var_s1 == 1) { - - u32 soundBits2 = SOUND_ARG_LOAD(0x19, 0x01, 0x70, 0x3B); - - switch (soundBits) { - case SOUND_ARG_LOAD(0x51, 0x01, 0x80, 0x05): - soundBits2 = SOUND_ARG_LOAD(0x19, 0x01, 0x70, 0x3B); - if (random_int(4) == 0) { - soundBits2 = SOUND_ARG_LOAD(0x19, 0x01, 0x70, 0x3C); - } - break; - case SOUND_ARG_LOAD(0x51, 0x01, 0x80, 0x02): - if (random_int(2) != 0) { - soundBits2 = SOUND_ARG_LOAD(0x19, 0x01, 0x70, 0x3D); - } else { - soundBits2 = SOUND_ARG_LOAD(0x19, 0x01, 0x70, 0x3E); - } - break; - case SOUND_ARG_LOAD(0x51, 0x01, 0x80, 0x03): - if (random_int(2) != 0) { - soundBits2 = SOUND_ARG_LOAD(0x19, 0x01, 0x70, 0x3F); - } else { - soundBits2 = SOUND_ARG_LOAD(0x19, 0x01, 0x70, 0x40); - } - break; - case SOUND_ARG_LOAD(0x51, 0x01, 0x80, 0x04): - if (random_int(2) != 0) { - soundBits2 = SOUND_ARG_LOAD(0x19, 0x01, 0x70, 0x41); - } else { - soundBits2 = SOUND_ARG_LOAD(0x19, 0x01, 0x70, 0x42); - } - break; - } - vehicle->someFlagsTheSequel |= ((1 << playerId)); - func_800C98B8(vehicle->position, vehicle->velocity, soundBits2); - } - } - } else { - if (vehicle->someFlagsTheSequel & ((1 << playerId))) { - vehicle->someFlagsTheSequel &= ~((1 << playerId)); - } - } - } - vehicle++; - } - } -} - -f32 func_800145A8(s16 arg0, f32 arg1, s16 arg2) { - if (arg2 < 0x28A) { - switch (arg0) { - case 0: - if (arg1 < 0.0) { - arg1 = 0.0f; - } - break; - case 1: - if (arg1 < 0.0) { - arg1 = -0.8f; - } else { - arg1 = 0.8f; - } - break; - case 2: - if (arg1 >= 0.0) { - arg1 = 0.0f; - } - break; - default: - break; - } - } else { - switch (arg0) { - case 0: - case 1: - arg1 = 0.5f; - break; - case 2: - arg1 = -0.5f; - break; - default: - break; - } - } - return arg1; -} - -void func_800146B8(s32 playerId, s32 arg1, VehicleStuff* vehicle) { - UNUSED s32 var_v1; - s32 var_v0; - s32 var_s2; - s32 waypointCount; - u16 temp_a1; - UNUSED VehicleStuff* tempVehicle; - - waypointCount = gWaypointCountByPathIndex[0]; - if (!(gPlayers[playerId].unk_094 < 1.6666666666666667)) { - for (var_s2 = 0; var_s2 < arg1; var_s2++, vehicle++) { - temp_a1 = vehicle->waypointIndex; - for (var_v0 = 0; var_v0 < 0x18; var_v0 += 3) { - if (((sSomeNearestWaypoint + var_v0) % waypointCount) == temp_a1) { - D_801634F8[playerId].unk4 = func_800145A8(vehicle->someType, D_80163068[playerId], temp_a1); - return; - } - } - } - } -} - -void init_vehicles_box_trucks(void) { - f32 a = ((gCCSelection * 90.0) / 216.0f) + 4.583333333333333; - f32 b = ((gCCSelection * 90.0) / 216.0f) + 2.9166666666666665; - s32 numTrucks = NUM_RACE_BOX_TRUCKS; - if (gModeSelection == TIME_TRIALS) { - numTrucks = NUM_TIME_TRIAL_BOX_TRUCKS; - } - initialize_toads_turnpike_vehicle(a, b, numTrucks, 0, gBoxTruckList, &D_80164550[0][0]); -} - -void update_vehicle_box_trucks(void) { - s32 loopIndex; - for (loopIndex = 0; loopIndex < NUM_RACE_BOX_TRUCKS; loopIndex++) { - update_vehicle_follow_waypoint(&gBoxTruckList[loopIndex]); - } -} - -void func_800148C4(s32 playerId, Player* player) { - func_80013F7C(playerId, player, gBoxTruckList, 55.0f, 12.5f, NUM_RACE_BOX_TRUCKS, - SOUND_ARG_LOAD(0x51, 0x01, 0x80, 0x03)); -} - -void func_8001490C(s32 playerId) { - func_800146B8(playerId, NUM_RACE_BOX_TRUCKS, gBoxTruckList); -} - -void init_vehicles_school_buses(void) { - s32 numBusses; - f32 a = ((gCCSelection * 90.0) / 216.0f) + 4.583333333333333; - f32 b = ((gCCSelection * 90.0) / 216.0f) + 2.9166666666666665; - - numBusses = NUM_RACE_SCHOOL_BUSES; - if (gModeSelection == TIME_TRIALS) { - numBusses = NUM_TIME_TRIAL_SCHOOL_BUSES; - } - initialize_toads_turnpike_vehicle(a, b, numBusses, 75, gSchoolBusList, &D_80164550[0][0]); -} - -void update_vehicle_school_bus(void) { - s32 loopIndex; - for (loopIndex = 0; loopIndex < NUM_RACE_SCHOOL_BUSES; loopIndex++) { - update_vehicle_follow_waypoint(&gSchoolBusList[loopIndex]); - } -} - -void func_80014A18(s32 playerId, Player* player) { - func_80013F7C(playerId, player, gSchoolBusList, 70.0f, 12.5f, NUM_RACE_SCHOOL_BUSES, - SOUND_ARG_LOAD(0x51, 0x01, 0x80, 0x02)); -} - -void func_80014A60(s32 playerId) { - func_800146B8(playerId, NUM_RACE_SCHOOL_BUSES, gSchoolBusList); -} - -void init_vehicles_trucks(void) { - s32 numTrucks; - f32 a = ((gCCSelection * 90.0) / 216.0f) + 4.583333333333333; - f32 b = ((gCCSelection * 90.0) / 216.0f) + 2.9166666666666665; - - numTrucks = NUM_RACE_TANKER_TRUCKS; - if (gModeSelection == TIME_TRIALS) { - numTrucks = NUM_TIME_TRIAL_TANKER_TRUCKS; - } - initialize_toads_turnpike_vehicle(a, b, numTrucks, 50, gTankerTruckList, &D_80164550[0][0]); -} - -void update_vehicle_tanker_trucks(void) { - s32 loopIndex; - for (loopIndex = 0; loopIndex < NUM_RACE_TANKER_TRUCKS; loopIndex++) { - update_vehicle_follow_waypoint(&gTankerTruckList[loopIndex]); - } -} - -void func_80014B6C(s32 playerId, Player* player) { - func_80013F7C(playerId, player, gTankerTruckList, 55.0f, 12.5f, NUM_RACE_TANKER_TRUCKS, - SOUND_ARG_LOAD(0x51, 0x01, 0x80, 0x04)); -} - -void func_80014BB4(s32 playerId) { - func_800146B8(playerId, NUM_RACE_TANKER_TRUCKS, gTankerTruckList); -} - -void init_vehicles_cars(void) { - s32 numCars; - f32 a = ((gCCSelection * 90.0) / 216.0f) + 4.583333333333333; - f32 b = ((gCCSelection * 90.0) / 216.0f) + 2.9166666666666665; - - numCars = NUM_RACE_CARS; - if (gModeSelection == TIME_TRIALS) { - numCars = NUM_TIME_TRIAL_CARS; - } - initialize_toads_turnpike_vehicle(a, b, numCars, 25, gCarList, &D_80164550[0][0]); -} - -void update_vehicle_cars(void) { - s32 loopIndex; - for (loopIndex = 0; loopIndex < NUM_RACE_CARS; loopIndex++) { - update_vehicle_follow_waypoint(&gCarList[loopIndex]); - } -} - -void func_80014CC0(s32 playerId, Player* player) { - func_80013F7C(playerId, player, gCarList, 11.5f, 8.5f, NUM_RACE_CARS, SOUND_ARG_LOAD(0x51, 0x01, 0x80, 0x05)); -} - -void func_80014D08(s32 playerId) { - func_800146B8(playerId, NUM_RACE_CARS, gCarList); -} - -void func_80014D30(s32 cameraId, s32 pathIndex) { - s16 cameraWaypoint; - TrackWaypoint* temp_v0; - - cameraWaypoint = gNearestWaypointByCameraId[cameraId]; - temp_v0 = &D_80164550[pathIndex][cameraWaypoint]; - check_bounding_collision(&cameras[cameraId].collision, 10.0f, (f32) temp_v0->posX, (f32) temp_v0->posY + 30.0f, - (f32) temp_v0->posZ); -} - -void func_80014DE4(s32 cameraIndex) { - s32 cameraId; - - D_801646CC = 0; - D_80164678[cameraIndex] = D_80164670[cameraIndex]; - if ((gModeSelection != 1) && ((gCourseIndexInCup == COURSE_ONE) || (gDemoMode == (u16) 1))) { - D_80164678[cameraIndex] = 0; - } else if ((D_80164678[cameraIndex] != 0) && (D_80164678[cameraIndex] != (s16) 1) && - (D_80164678[cameraIndex] != 2) && (D_80164678[cameraIndex] != 3)) { - D_80164678[cameraIndex] = 0; - } - D_80164680[cameraIndex] = -1; - D_80163238 = 0; - D_801646C0[cameraIndex] = 0; - D_801646C8 = 0; - D_801646D0[cameraIndex].unk0 = 0; - D_801646D0[cameraIndex].unk2 = 0; - D_801646D0[cameraIndex].unk4 = 0; - if ((gModeSelection == 1) && (gCourseMapInit == 0)) { - D_80164678[cameraIndex] = 0; - } - - for (cameraId = 0; cameraId < 4; cameraId++) { - gNearestWaypointByCameraId[cameraId] = 0; - } -} - -f32 func_80014EE4(f32 arg0, s32 arg1) { - f32 temp_f0; - f64 temp_f2; - - temp_f0 = D_80164498[arg1]; - switch (D_80164678[arg1]) { /* irregular */ - default: - arg0 = 40.0f; - break; - case 0: - temp_f2 = 40.0; - temp_f2 += temp_f0; - if (temp_f2 < arg0) { - arg0 -= 1.0; - if (arg0 < temp_f2) { - arg0 = temp_f2; - } - } - if (arg0 < temp_f2) { - arg0 += 1.0; - if (temp_f2 < arg0) { - arg0 = temp_f2; - ; - } - } - break; - case 1: - temp_f2 = 60.0; - temp_f2 += temp_f0; - if (arg0 < temp_f2) { - arg0 += 1.0; - if (temp_f2 < arg0) { - arg0 = temp_f2; - } - } - if (temp_f2 < arg0) { - arg0 -= 1.0; - if (arg0 < temp_f2) { - arg0 = temp_f2; - ; - } - } - break; - case 3: - temp_f2 = 60.0; - temp_f2 += temp_f0; - if (arg0 < temp_f2) { - arg0 += 0.5; - if (temp_f2 < arg0) { - arg0 = temp_f2; - } - } - if (temp_f2 < arg0) { - arg0 -= 0.5; - if (arg0 < temp_f2) { - arg0 = temp_f2; - } - } - break; - case 2: - temp_f2 = 60.0; - temp_f2 += temp_f0; - if (arg0 < temp_f2) { - arg0 += 1.0; - if (temp_f2 < arg0) { - arg0 = temp_f2; - } - } - if (temp_f2 < arg0) { - arg0 -= 1.0; - if (arg0 < temp_f2) { - arg0 = temp_f2; - } - } - break; - } - return arg0; -} - -void calculate_camera_up_vector(Camera* camera, s32 cameraIndex) { - f32 xnorm; - f32 ynorm; - f32 znorm; - f32 xdiff; - f32 ydiff; - f32 zdiff; - f32 distance; - f32 sp28; - u16 thing; - - thing = D_801646C0[cameraIndex]; - if (thing == 0) { - camera->up[0] = 0.0f; - camera->up[2] = 0.0f; - camera->up[1] = 1.0f; - } else { - xdiff = camera->lookAt[0] - camera->pos[0]; - ydiff = camera->lookAt[1] - camera->pos[1]; - zdiff = camera->lookAt[2] - camera->pos[2]; - distance = sqrtf((xdiff * xdiff) + (ydiff * ydiff) + (zdiff * zdiff)); - xnorm = xdiff / distance; - ynorm = ydiff / distance; - znorm = zdiff / distance; - sp28 = 1.0 - coss(thing); - camera->up[0] = (sp28 * xnorm * ynorm) - (sins(thing) * znorm); - camera->up[1] = coss(thing) + (sp28 * ynorm * ynorm); - camera->up[2] = (sins(thing) * xnorm) + (sp28 * ynorm * znorm); - } -} - -UNUSED void func_8001530C(void) { -} - -void func_80015314(s32 playerId, UNUSED f32 arg1, s32 cameraId) { - Camera* temp_a0; - Player* temp_a1; - - // wtf is up with the pointer accesses here? - // What aren't they just doing thing = &some_pointer[some_index]? - temp_a1 = gPlayerOne; - temp_a0 = camera1; - temp_a1 += playerId; - temp_a0 += cameraId; - temp_a0->unk_2C = temp_a1->rotation[1]; - func_80015390(temp_a0, temp_a1, 0); -} - -void func_80015390(Camera* camera, UNUSED Player* player, UNUSED s32 arg2) { - UNUSED s32 pad[6]; - f32 temp_f12; - f32 sp90; - f32 temp_f14; - Player* temp_s1; - f32 sp84; - f32 sp80; - f32 sp7C; - UNUSED Vec3f pad2; - Vec3f sp64; - UNUSED s32 pad3[9]; - s16 var_a2; - - /* - Doing the more sensible: - temp_s1 = &gPlayerOne[camera->playerId]; - leads to some regalloc differences - */ - temp_s1 = gPlayerOne; - temp_s1 += camera->playerId; - if (temp_s1->unk_078 == 0) { - var_a2 = 0x0064; - } else if (temp_s1->unk_078 < 0) { - var_a2 = 0xA0 - (temp_s1->unk_078 / 16); - } else { - var_a2 = 0xA0 + (temp_s1->unk_078 / 16); - } - if (!((temp_s1->effects & 0x80) || (temp_s1->effects & 0x40))) { - adjust_angle(&camera->unk_2C, temp_s1->rotation[1], var_a2); - } - func_8001D794(temp_s1, camera, sp64, &sp84, &sp80, &sp7C, camera->unk_2C); - check_bounding_collision(&camera->collision, 10.0f, sp84, sp80, sp7C); - camera->lookAt[0] = sp64[0]; - camera->lookAt[1] = sp64[1]; - camera->lookAt[2] = sp64[2]; - camera->pos[0] = sp84; - camera->pos[1] = sp80; - camera->pos[2] = sp7C; - temp_f12 = camera->lookAt[0] - camera->pos[0]; - sp90 = camera->lookAt[1] - camera->pos[1]; - temp_f14 = camera->lookAt[2] - camera->pos[2]; - camera->rot[1] = atan2s(temp_f12, temp_f14); - camera->rot[0] = atan2s(sqrtf((temp_f12 * temp_f12) + (temp_f14 * temp_f14)), sp90); - camera->rot[2] = 0; -} - -void func_80015544(s32 playerId, f32 arg1, s32 cameraId, s32 pathIndex) { - Camera* camera; - - f32 temp_f12; - f32 temp_f2; - s32 test = gWaypointCountByPathIndex[pathIndex]; - - D_80164688[cameraId] = arg1; - camera = cameras + cameraId; - gNearestWaypointByCameraId[cameraId] = (gNearestWaypointByPlayerId[playerId] + 10) % test; - - func_8000BBD8(gNearestWaypointByCameraId[cameraId], arg1, pathIndex); - - D_801645F8[cameraId] = D_80162FA0[0]; - D_80164638[cameraId] = D_80162FA0[2]; - - temp_f2 = (f32) D_80164550[pathIndex][gNearestWaypointByCameraId[cameraId]].posY; - - temp_f12 = get_surface_height(D_80162FA0[0], (f32) (temp_f2 + 30.0), D_80162FA0[2]); - if ((temp_f12 < (temp_f2 - 20.0)) || (temp_f12 >= 3000.0)) { - D_80164618[cameraId] = (f32) (temp_f2 + 10.0); - } else { - D_80164618[cameraId] = (f32) (temp_f12 + 10.0); - } - D_80164648[cameraId] = 0.0f; - camera->pos[0] = D_801645F8[cameraId]; - camera->pos[1] = D_80164618[cameraId]; - camera->pos[2] = D_80164638[cameraId]; -} - -void func_8001577C(Camera* camera, UNUSED Player* playerArg, UNUSED s32 arg2, s32 cameraId) { - s16 cameraWaypoint; - s16 playerWaypoint; - UNUSED s32 pad; - f32 xdiff; - f32 ydiff; - f32 zdiff; - UNUSED s32 pad2; - s32 playerId; - UNUSED s32 pad3[9]; - Player* player; - s32 waypointDiff; - s32 pathIndex; - - playerId = camera->playerId; - pathIndex = gPathIndexByPlayerId[playerId]; - player = gPlayerOne; - player += playerId; - gNearestWaypointByCameraId[cameraId] = - func_8000D33C(camera->pos[0], camera->pos[1], camera->pos[2], gNearestWaypointByCameraId[cameraId], pathIndex); - playerWaypoint = gNearestWaypointByPlayerId[playerId]; - cameraWaypoint = gNearestWaypointByCameraId[cameraId]; - if (func_80007BF8(playerWaypoint, cameraWaypoint, 0x0032U, 0x000FU, gWaypointCountByPathIndex[pathIndex]) <= 0) { - func_8001A348(cameraId, D_80164688[cameraId], D_80164680[cameraId]); - } else { - if (D_80163068[playerId] < (-0.7)) { - waypointDiff = playerWaypoint - cameraWaypoint; - if ((D_80164688[cameraId] < (-0.5)) && ((waypointDiff * waypointDiff) < 5)) { - func_8001A348(cameraId, 1.0f, 3); - goto alable; - } - } - // clang-format off - // I hate this, but a fakematch is a fakematch - if (D_80163068[playerId] > 0.7) { waypointDiff = playerWaypoint - cameraWaypoint; if ((D_80164688[cameraId] > 0.5) && ((waypointDiff * waypointDiff) < 5)) { - func_8001A348(cameraId, -1.0f, 2); - // clang-format on - } - } - } -alable: - camera->pos[0] = D_801645F8[cameraId]; - camera->pos[1] = D_80164618[cameraId]; - camera->pos[2] = D_80164638[cameraId]; - camera->lookAt[0] = player->pos[0]; - camera->lookAt[1] = player->pos[1] + 6.0; - camera->lookAt[2] = player->pos[2]; - func_80014D30(cameraId, pathIndex); - xdiff = camera->lookAt[0] - camera->pos[0]; - ydiff = camera->lookAt[1] - camera->pos[1]; - zdiff = camera->lookAt[2] - camera->pos[2]; - camera->rot[1] = atan2s(xdiff, zdiff); - camera->rot[0] = atan2s(sqrtf((xdiff * xdiff) + (zdiff * zdiff)), ydiff); - camera->rot[2] = 0; -} - -void func_80015A9C(s32 playerId, f32 arg1, s32 cameraId, s16 pathIndex) { - Camera* camera = cameras + cameraId; - - D_80164688[cameraId] = arg1; - gNearestWaypointByCameraId[cameraId] = gNearestWaypointByPlayerId[playerId] + 10; - gNearestWaypointByCameraId[cameraId] = - (gNearestWaypointByCameraId[cameraId]) % gWaypointCountByPathIndex[pathIndex]; - - func_8000BBD8(gNearestWaypointByCameraId[cameraId], arg1, pathIndex); - - D_801645F8[cameraId] = D_80162FA0[0]; - D_80164618[cameraId] = (f32) D_80164550[pathIndex][gNearestWaypointByCameraId[cameraId]].posY; - D_80164638[cameraId] = D_80162FA0[2]; - - D_80164648[cameraId] = gPlayers[playerId].unk_094 / 5.0f; - if ((f64) D_80164648[cameraId] < 0.0) { - D_80164648[cameraId] = 0.0f; - } - - camera->pos[0] = D_801645F8[cameraId]; - camera->pos[1] = D_80164618[cameraId]; - camera->pos[2] = D_80164638[cameraId]; -} - -void func_80015C94(Camera* camera, UNUSED Player* unusedPlayer, UNUSED s32 arg2, s32 cameraId) { - s16 playerWaypoint; - s16 cameraWaypoint; - UNUSED s32 stackPadding0; - f32 xdiff2; - f32 ydiff2; - f32 zdiff2; - Player* player; - s32 playerId; - f32 midX; - f32 midY; - f32 midZ; - f32 xdiff; - f32 ydiff; - f32 zdiff; - f32 distance; - UNUSED s32 stackPadding1; - s16 waypoint1; - s16 waypoint2; - UNUSED f32 var_f18; - UNUSED f32 var_f20; - f32 temp_f2_2; - s32 pathIndex; - - playerId = camera->playerId; - player = gPlayerOne; - player += playerId; - D_80163238 = playerId; - pathIndex = gPathIndexByPlayerId[playerId]; - gNearestWaypointByCameraId[cameraId] = - func_8000D33C(camera->pos[0], camera->pos[1], camera->pos[2], gNearestWaypointByCameraId[cameraId], pathIndex); - playerWaypoint = gNearestWaypointByPlayerId[playerId]; - cameraWaypoint = gNearestWaypointByCameraId[cameraId]; - if (func_80007BF8(playerWaypoint, cameraWaypoint, 0x0032U, 0x000FU, gWaypointCountByPathIndex[pathIndex]) <= 0) { - func_8001A348(cameraId, D_80164688[cameraId], D_80164680[cameraId]); - } else if ((D_80163068[playerId] < -0.5) && (D_80164688[cameraId] < -0.5)) { - func_8001A348(cameraId, 1.0f, 7); - } else if ((D_80163068[playerId] > 0.5) && (D_80164688[cameraId] > 0.5)) { - func_8001A348(cameraId, -1.0f, 6); - } - waypoint1 = (gNearestWaypointByCameraId[cameraId] + 1) % gWaypointCountByPathIndex[pathIndex]; - waypoint2 = (gNearestWaypointByCameraId[cameraId] + 2) % gWaypointCountByPathIndex[pathIndex]; - func_8000BBD8(waypoint1, D_80164688[cameraId], pathIndex); - midX = D_80162FA0[0] * 0.5; - midZ = D_80162FA0[2] * 0.5; - func_8000BBD8(waypoint2, D_80164688[cameraId], pathIndex); - midX += D_80162FA0[0] * 0.5; - midZ += D_80162FA0[2] * 0.5; - midY = (D_80164550[pathIndex][waypoint1].posY + D_80164550[pathIndex][waypoint2].posY) / 2.0; - xdiff = midX - D_801645F8[cameraId]; - ydiff = midY - D_80164618[cameraId]; - zdiff = midZ - D_80164638[cameraId]; - distance = sqrtf((xdiff * xdiff) + (ydiff * ydiff) + (zdiff * zdiff)); - if (distance != 0.0) { - midX = D_801645F8[cameraId] + ((D_80164648[cameraId] * xdiff) / distance); - midY = D_80164618[cameraId] + ((D_80164648[cameraId] * ydiff) / distance); - midZ = D_80164638[cameraId] + ((D_80164648[cameraId] * zdiff) / distance); - } else { - midX = D_801645F8[cameraId]; - midY = D_80164618[cameraId]; - midZ = D_80164638[cameraId]; - } - camera->pos[0] = midX; - camera->pos[2] = midZ; - temp_f2_2 = get_surface_height(midX, (midY + 30.0), midZ); - if ((temp_f2_2 < (midY - 20.0)) || (temp_f2_2 >= 3000.0)) { - camera->pos[1] = midY + 10.0; - } else { - camera->pos[1] = temp_f2_2 + 8.0; - } - D_801645F8[cameraId] = midX; - D_80164618[cameraId] = midY; - D_80164638[cameraId] = midZ; - camera->lookAt[0] = player->pos[0]; - camera->lookAt[1] = player->pos[1] + 6.0; - camera->lookAt[2] = player->pos[2]; - func_80014D30(cameraId, pathIndex); - xdiff2 = camera->lookAt[0] - camera->pos[0]; - ydiff2 = camera->lookAt[1] - camera->pos[1]; - zdiff2 = camera->lookAt[2] - camera->pos[2]; - camera->rot[1] = atan2s(xdiff2, zdiff2); - camera->rot[0] = atan2s(sqrtf((xdiff2 * xdiff2) + (zdiff2 * zdiff2)), ydiff2); - camera->rot[2] = 0; -} - -void func_800162CC(s32 playerId, f32 arg1, s32 cameraId, s16 pathIndex) { - Camera* camera = cameras + cameraId; - - D_80164688[cameraId] = arg1; - gNearestWaypointByCameraId[cameraId] = gNearestWaypointByPlayerId[playerId]; - gNearestWaypointByCameraId[cameraId] = - (gNearestWaypointByCameraId[cameraId]) % gWaypointCountByPathIndex[pathIndex]; - - func_8000BBD8(gNearestWaypointByCameraId[cameraId], arg1, pathIndex); - - D_801645F8[cameraId] = D_80162FA0[0]; - D_80164618[cameraId] = (f32) D_80164550[pathIndex][gNearestWaypointByCameraId[cameraId]].posY; - D_80164638[cameraId] = D_80162FA0[2]; - - D_80164658[cameraId] = gPlayers[playerId].unk_094; - D_80164648[cameraId] = gPlayers[playerId].unk_094; - - camera->pos[0] = D_801645F8[cameraId]; - camera->pos[1] = D_80164618[cameraId]; - camera->pos[2] = D_80164638[cameraId]; -} - -void func_80016494(Camera* camera, UNUSED Player* unusedPlayer, UNUSED s32 arg2, s32 cameraId) { - s16 cameraWaypoint; - s16 playerWaypoint; - UNUSED s32 stackPadding0; - f32 xdiff2; - f32 ydiff2; - f32 zdiff2; - Player* player; - s32 playerId; - f32 midX; - f32 midY; - f32 midZ; - f32 xdiff; - f32 ydiff; - f32 zdiff; - f32 distance; - UNUSED f32 sp98; - s16 waypoint1; - s16 waypoint2; - UNUSED f32 sp94; - UNUSED f32 sp90; - UNUSED s32 stackPadding1; - s32 pathIndex; - f32 temp_f2_5; - - playerId = camera->playerId; - player = gPlayerOne; - D_80164648[cameraId] += ((D_80164658[cameraId] - D_80164648[cameraId]) * 0.5f); - D_80163238 = playerId; - pathIndex = gPathIndexByPlayerId[playerId]; - player += playerId; - gNearestWaypointByCameraId[cameraId] = - func_8000D33C(camera->pos[0], camera->pos[1], camera->pos[2], gNearestWaypointByCameraId[cameraId], pathIndex); - temp_f2_5 = (D_80163068[playerId] - D_80164688[cameraId]); - temp_f2_5 *= temp_f2_5; - playerWaypoint = gNearestWaypointByPlayerId[playerId]; - cameraWaypoint = gNearestWaypointByCameraId[cameraId]; - if (func_80007BF8(playerWaypoint, cameraWaypoint, 0x000FU, 0x000FU, gWaypointCountByPathIndex[pathIndex]) <= 0) { - func_8001A348(cameraId, D_80164688[cameraId], D_80164680[cameraId]); - } else { - if ((D_80163068[playerId] < 0.0) && (D_80164688[cameraId] < 0.0) && (temp_f2_5 < 0.01)) { - func_8001A348(cameraId, 1.0f, 5); - } else { - if ((D_80163068[playerId] > 0.0) && (D_80164688[cameraId] > 0.0) && (temp_f2_5 < 0.01)) { - func_8001A348(cameraId, -1.0f, 4); - } else { - if ((cameraWaypoint < playerWaypoint) && ((playerWaypoint - cameraWaypoint) < 0xA)) { - D_80164658[cameraId] = gPlayers[playerId].unk_094 + 0.4; - } - if ((playerWaypoint < cameraWaypoint) && ((cameraWaypoint - playerWaypoint) < 0xA)) { - D_80164658[cameraId] = gPlayers[playerId].unk_094 - 0.4; - } - if (D_80164658[cameraId] > 10.0) { - D_80164658[cameraId] = 10.0f; - } - if (D_80164658[cameraId] < 0.0) { - D_80164658[cameraId] = 0.0f; - } - } - } - } - waypoint1 = (gNearestWaypointByCameraId[cameraId] + 1) % gWaypointCountByPathIndex[pathIndex]; - waypoint2 = (gNearestWaypointByCameraId[cameraId] + 2) % gWaypointCountByPathIndex[pathIndex]; - func_8000BBD8(waypoint1, D_80164688[cameraId], pathIndex); - midX = D_80162FA0[0] * 0.5; - midZ = D_80162FA0[2] * 0.5; - func_8000BBD8(waypoint2, D_80164688[cameraId], pathIndex); - midX += D_80162FA0[0] * 0.5; - midZ += D_80162FA0[2] * 0.5; - midY = (D_80164550[pathIndex][waypoint1].posY + D_80164550[pathIndex][waypoint2].posY) / 2.0; - xdiff = midX - D_801645F8[cameraId]; - ydiff = midY - D_80164618[cameraId]; - zdiff = midZ - D_80164638[cameraId]; - distance = sqrtf((xdiff * xdiff) + (ydiff * ydiff) + (zdiff * zdiff)); - if (distance != 0.0) { - midX = D_801645F8[cameraId] + ((D_80164648[cameraId] * xdiff) / distance); - midY = D_80164618[cameraId] + ((D_80164648[cameraId] * ydiff) / distance); - midZ = D_80164638[cameraId] + ((D_80164648[cameraId] * zdiff) / distance); - } else { - midX = D_801645F8[cameraId]; - midY = D_80164618[cameraId]; - midZ = D_80164638[cameraId]; - } - camera->pos[0] = midX; - camera->pos[2] = midZ; - temp_f2_5 = get_surface_height(midX, midY + 30.0, midZ); - if ((temp_f2_5 < (midY - 20.0)) || (temp_f2_5 >= 3000.0)) { - camera->pos[1] = midY + 10.0; - } else { - camera->pos[1] = temp_f2_5 + 10.0; - } - D_801645F8[cameraId] = midX; - D_80164618[cameraId] = midY; - D_80164638[cameraId] = midZ; - camera->lookAt[0] = player->pos[0]; - camera->lookAt[1] = player->pos[1] + 6.0; - camera->lookAt[2] = player->pos[2]; - func_80014D30(cameraId, pathIndex); - xdiff2 = camera->lookAt[0] - camera->pos[0]; - ydiff2 = camera->lookAt[1] - camera->pos[1]; - zdiff2 = camera->lookAt[2] - camera->pos[2]; - camera->rot[1] = atan2s(xdiff2, zdiff2); - camera->rot[0] = atan2s(sqrtf((xdiff2 * xdiff2) + (zdiff2 * zdiff2)), ydiff2); - camera->rot[2] = 0; -} - -void func_80016C3C(UNUSED s32 playerId, UNUSED f32 arg1, s32 cameraId) { - UNUSED s32 stackPadding0; - UNUSED s32 stackPadding1; - f32 temp_f2; - UNUSED s32 stackPadding2; - f32 temp_f12; - TrackWaypoint** path; - f32 sp54; - s32 temp_s0; - s16 sp48; - s16 sp44; - Camera* camera; - - if (random_int(0x0064U) < 0x32) { - D_80164688[cameraId] = 0.1f; - } else { - D_80164688[cameraId] = -0.1f; - } - D_80163DD8[cameraId] = 0; - if (gCurrentCourseId == COURSE_YOSHI_VALLEY) { - D_80163DD8[cameraId] = random_int(4U); - D_80164688[cameraId] = 0.0f; - } - temp_s0 = gWaypointCountByPathIndex[D_80163DD8[cameraId]]; - gNearestWaypointByCameraId[cameraId] %= temp_s0; - func_8000BBD8(gNearestWaypointByCameraId[cameraId], D_80164688[cameraId], 0); - D_801645F8[cameraId] = D_80162FA0[0]; - D_80164618[cameraId] = D_80164550[0][gNearestWaypointByCameraId[cameraId]].posY; - path = D_80164550; - D_80164638[cameraId] = D_80162FA0[2]; - D_80164658[cameraId] = 16.666666f; - D_80164648[cameraId] = 0.0f; - sp48 = (gNearestWaypointByCameraId[cameraId] + 0xA) % temp_s0; - sp44 = (gNearestWaypointByCameraId[cameraId] + 0xB) % temp_s0; - func_8000BBD8(sp48, D_80164688[cameraId], 0); - temp_f2 = D_80162FA0[0] * 0.5; - temp_f12 = D_80162FA0[2] * 0.5; - func_8000BBD8(sp44, D_80164688[cameraId], 0); - temp_f2 += D_80162FA0[0] * 0.5; - temp_f12 += D_80162FA0[2] * 0.5; - sp48 = (gNearestWaypointByCameraId[cameraId] + 0x5) % temp_s0; - sp44 = (gNearestWaypointByCameraId[cameraId] + 0x6) % temp_s0; - sp54 = (path[0][sp48].posY + path[0][sp44].posY) * 0.5f; - camera = cameras; - camera += cameraId; - camera->lookAt[0] = temp_f2; - camera->lookAt[2] = temp_f12; - camera->lookAt[1] = sp54 + 8.0; - camera->pos[0] = D_801645F8[cameraId]; - camera->pos[1] = D_80164618[cameraId]; - camera->pos[2] = D_80164638[cameraId]; -} - -void func_80017054(Camera* camera, UNUSED Player* player, UNUSED s32 index, s32 cameraId); -#ifdef NON_MATCHING -// https://decomp.me/scratch/Ck7hV -// Really crazy diff, permuter only able to find fakematches for improvements (and they're big improvements) -// There's something really, really wrong with the empty `if` statement -void func_80017054(Camera* camera, UNUSED Player* player, UNUSED s32 index, s32 cameraId) { - UNUSED s32 stackPadding0; - UNUSED s32 stackPadding1; - f32 spAC; - f32 spA8; - f32 spA4; - UNUSED s32 stackPadding2; - UNUSED s32 stackPadding3; - f32 sp98; - f32 sp94; - f32 sp90; - f32 sp8C; - f32 sp88; - f32 sp84; - UNUSED f32 stackPadding4; - UNUSED f32 stackPadding5; - UNUSED f32 stackPadding6; - UNUSED s32 stackPadding7; - UNUSED s32 stackPadding8; - s16 sp6E; - s16 sp6C; - UNUSED s32 stackPadding9; - UNUSED s32 stackPaddingA; - UNUSED s32 stackPaddingB; - s32 pathIndex; - UNUSED s32 stackPaddingC; - s32 sp58; - s16 sp56; - s32 playerId; - - playerId = camera->playerId; - pathIndex = D_80163DD8[cameraId]; - D_80164648[cameraId] += (D_80164658[cameraId] - D_80164648[cameraId]) * 0.5f; - sp58 = gWaypointCountByPathIndex[pathIndex]; - D_80163238 = playerId; - sp56 = gNearestWaypointByCameraId[cameraId]; - gNearestWaypointByCameraId[cameraId] = - func_8000D33C(camera->pos[0], camera->pos[1], camera->pos[2], gNearestWaypointByCameraId[cameraId], pathIndex); - if (gCurrentCourseId == COURSE_YOSHI_VALLEY) { - if ((sp56 != gNearestWaypointByCameraId[cameraId]) && (gNearestWaypointByCameraId[cameraId] == 1)) { - pathIndex = (D_80163DD8[cameraId] = random_int(4U)); - gNearestWaypointByCameraId[cameraId] = func_8000D33C(camera->pos[0], camera->pos[1], camera->pos[2], - gNearestWaypointByCameraId[cameraId], pathIndex); - } - } - sp6E = (gNearestWaypointByCameraId[cameraId] + 0xA) % sp58; - sp6C = (gNearestWaypointByCameraId[cameraId] + 0xB) % sp58; - func_8000BBD8(sp6E, D_80164688[cameraId], pathIndex); - sp8C = D_80162FA0[0] * 0.5; - sp84 = D_80162FA0[2] * 0.5; - func_8000BBD8(sp6C, D_80164688[cameraId], pathIndex); - sp8C += D_80162FA0[0] * 0.5; - sp84 += D_80162FA0[2] * 0.5; - sp6E = (gNearestWaypointByCameraId[cameraId] + 5) % sp58; - sp6C = (gNearestWaypointByCameraId[cameraId] + 6) % sp58; - sp88 = (D_80164550[pathIndex][sp6E].posY + D_80164550[pathIndex][sp6C].posY) * 0.5f; - sp6E = (gNearestWaypointByCameraId[cameraId] + 1) % sp58; - sp6C = (gNearestWaypointByCameraId[cameraId] + 2) % sp58; - func_8000BBD8(sp6E, D_80164688[cameraId], pathIndex); - sp98 = D_80162FA0[0] * 0.5; - sp90 = D_80162FA0[2] * 0.5; - func_8000BBD8(sp6C, D_80164688[cameraId], pathIndex); - sp98 += D_80162FA0[0] * 0.5; - sp90 += D_80162FA0[2] * 0.5; - sp94 = (D_80164550[pathIndex][sp6E].posY + D_80164550[pathIndex][sp6C].posY) * 0.5f; - stackPadding4 = sp98 - D_801645F8[cameraId]; - stackPadding5 = sp90 - D_80164618[cameraId]; - stackPadding6 = sp94 - D_80164638[cameraId]; - spAC = sqrtf(((sp98 * sp98) + (sp94 * sp94)) + (sp90 * sp90)); - if (spAC != 0.0) { - sp98 = D_801645F8[cameraId] + ((D_80164648[cameraId] * stackPadding4) / spAC); - sp94 = D_80164618[cameraId] + ((D_80164648[cameraId] * stackPadding5) / spAC); - sp90 = D_80164638[cameraId] + ((D_80164648[cameraId] * stackPadding6) / spAC); - } else { - sp98 = D_801645F8[cameraId]; - sp94 = D_80164618[cameraId]; - sp90 = D_80164638[cameraId]; - } - if ((!(sp98 < (-10000.0))) && (sp98 > 10000.0)) { - if (sp98 && sp98) {} - } - camera->pos[0] = sp98; - camera->pos[1] = sp94 + 10.0; - camera->pos[2] = sp90; - if (1) {} - if (1) {} - if (1) {} - if (1) {} - if (1) {} - D_801645F8[cameraId] = sp98; - D_80164638[cameraId] = sp90; - D_80164618[cameraId] = sp94; - camera->lookAt[0] = sp8C; - camera->lookAt[1] = sp88 + 8.0; - camera->lookAt[2] = sp84; - func_80014D30(cameraId, pathIndex); - spAC = camera->lookAt[0] - camera->pos[0]; - spA8 = camera->lookAt[1] - camera->pos[1]; - spA4 = camera->lookAt[2] - camera->pos[2]; - camera->rot[1] = atan2s(spAC, spA4); - camera->rot[0] = atan2s(sqrtf((spAC * spAC) + (spA4 * spA4)), spA8); - camera->rot[2] = 0; -} -#else -GLOBAL_ASM("asm/non_matchings/code_80005FD0/func_80017054.s") -#endif - -void func_80017720(s32 playerId, UNUSED f32 arg1, s32 cameraId, s16 pathIndex) { - Camera* camera = cameras + cameraId; - UNUSED s32 pad; - - D_80164688[cameraId] = D_80163068[playerId]; - gNearestWaypointByCameraId[cameraId] = gNearestWaypointByPlayerId[playerId] + 3; - gNearestWaypointByCameraId[cameraId] = gNearestWaypointByCameraId[cameraId] % gWaypointCountByPathIndex[pathIndex]; - - func_8000BBD8(gNearestWaypointByCameraId[cameraId], D_80163068[playerId], pathIndex); - - D_801645F8[cameraId] = D_80162FA0[0]; - D_80164618[cameraId] = (f32) D_80164550[pathIndex][gNearestWaypointByCameraId[cameraId]].posY; - D_80164638[cameraId] = D_80162FA0[2]; - - D_80164658[cameraId] = gPlayers[playerId].unk_094; - D_80164648[cameraId] = gPlayers[playerId].unk_094; - - camera->pos[0] = D_801645F8[cameraId]; - camera->pos[1] = D_80164618[cameraId]; - camera->pos[2] = D_80164638[cameraId]; -} - -void func_800178F4(Camera* camera, UNUSED Player* unusedPlayer, UNUSED s32 arg2, s32 cameraId) { - s16 cameraWaypoint; - s16 playerWaypoint; - UNUSED f32 stackPadding0; - f32 xdiff2; - f32 ydiff2; - f32 zdiff2; - Player* player; - f32 distance; - f32 midX; - f32 midY; - f32 midZ; - f32 xdiff; - f32 ydiff; - f32 zdiff; - UNUSED f32 var_f2; - UNUSED f32 var_f18; - s16 waypoint1; - s16 waypoint2; - UNUSED f32 stackPadding1; - UNUSED f32 var_f14; - s32 playerId; - s32 pathIndex; - s32 waypointCount; - - playerId = camera->playerId; - player = gPlayerOne; - D_80164688[cameraId] = D_80163068[playerId]; - D_80164648[cameraId] += ((D_80164658[cameraId] - D_80164648[cameraId]) / 2.0f); - D_80163238 = playerId; - pathIndex = gPathIndexByPlayerId[playerId]; - player += playerId; - waypointCount = gWaypointCountByPathIndex[pathIndex]; - gNearestWaypointByCameraId[cameraId] = - func_8000D33C(camera->pos[0], camera->pos[1], camera->pos[2], gNearestWaypointByCameraId[cameraId], pathIndex); - playerWaypoint = (gNearestWaypointByPlayerId[playerId] + 3) % waypointCount; - cameraWaypoint = gNearestWaypointByCameraId[cameraId]; - if (func_80007BF8(playerWaypoint, cameraWaypoint, 0x000DU, 1U, waypointCount) <= 0) { - func_8001A348(cameraId, D_80164688[cameraId], D_80164680[cameraId]); - } else { - if ((cameraWaypoint < playerWaypoint) && ((playerWaypoint - cameraWaypoint) < 3)) { - D_80164658[cameraId] = gPlayers[playerId].unk_094 + 0.1; - } - if ((playerWaypoint < cameraWaypoint) && ((cameraWaypoint - playerWaypoint) < 3)) { - D_80164658[cameraId] = gPlayers[playerId].unk_094 - 0.1; - } - if (D_80164658[cameraId] > 10.0) { - D_80164658[cameraId] = 10.0f; - } - if (D_80164658[cameraId] < 0.0) { - D_80164658[cameraId] = 0.0f; - } - } - waypoint1 = (gNearestWaypointByCameraId[cameraId] + 1) % waypointCount; - waypoint2 = (gNearestWaypointByCameraId[cameraId] + 2) % waypointCount; - func_8000BBD8(waypoint1, D_80164688[cameraId], pathIndex); - midX = D_80162FA0[0] * 0.5; - midZ = D_80162FA0[2] * 0.5; - func_8000BBD8(waypoint2, D_80164688[cameraId], pathIndex); - midX += D_80162FA0[0] * 0.5; - midZ += D_80162FA0[2] * 0.5; - midY = (D_80164550[pathIndex][waypoint1].posY + D_80164550[pathIndex][waypoint2].posY) / 2.0; - xdiff = midX - D_801645F8[cameraId]; - ydiff = midY - D_80164618[cameraId]; - zdiff = midZ - D_80164638[cameraId]; - distance = sqrtf((xdiff * xdiff) + (ydiff * ydiff) + (zdiff * zdiff)); - if (distance != 0.0) { - midX = D_801645F8[cameraId] + ((D_80164648[cameraId] * xdiff) / distance); - midY = D_80164618[cameraId] + ((D_80164648[cameraId] * ydiff) / distance); - midZ = D_80164638[cameraId] + ((D_80164648[cameraId] * zdiff) / distance); - } else { - midX = D_801645F8[cameraId]; - midY = D_80164618[cameraId]; - midZ = D_80164638[cameraId]; - } - camera->pos[0] = midX; - camera->pos[2] = midZ; - camera->pos[1] = midY + 10.0; - D_801645F8[cameraId] = midX; - D_80164618[cameraId] = midY; - D_80164638[cameraId] = midZ; - camera->lookAt[0] = player->pos[0]; - camera->lookAt[1] = player->pos[1] + 6.0; - camera->lookAt[2] = player->pos[2]; - func_80014D30(cameraId, pathIndex); - xdiff2 = camera->lookAt[0] - camera->pos[0]; - ydiff2 = camera->lookAt[1] - camera->pos[1]; - zdiff2 = camera->lookAt[2] - camera->pos[2]; - camera->rot[1] = atan2s(xdiff2, zdiff2); - camera->rot[0] = atan2s(sqrtf((xdiff2 * xdiff2) + (zdiff2 * zdiff2)), ydiff2); - camera->rot[2] = 0; -} - -void func_80017F10(s32 playerId, UNUSED f32 arg1, s32 cameraId, s16 pathIndex) { - Camera* camera = cameras + cameraId; - s32 test = gWaypointCountByPathIndex[pathIndex]; - - D_80164688[cameraId] = D_80163068[playerId]; - gNearestWaypointByCameraId[cameraId] = (gNearestWaypointByPlayerId[playerId] + test) - 2; - gNearestWaypointByCameraId[cameraId] = gNearestWaypointByCameraId[cameraId] % test; - - func_8000BBD8(gNearestWaypointByCameraId[cameraId], D_80163068[playerId], pathIndex); - - D_801645F8[cameraId] = D_80162FA0[0]; - D_80164618[cameraId] = (f32) D_80164550[pathIndex][gNearestWaypointByCameraId[cameraId]].posY; - D_80164638[cameraId] = D_80162FA0[2]; - - D_80164658[cameraId] = gPlayers[playerId].unk_094; - D_80164648[cameraId] = gPlayers[playerId].unk_094; - - camera->pos[0] = D_801645F8[cameraId]; - camera->pos[1] = D_80164618[cameraId]; - camera->pos[2] = D_80164638[cameraId]; -} - -void func_800180F0(Camera* camera, UNUSED Player* unusedPlayer, UNUSED s32 arg2, s32 cameraId) { - s16 cameraWaypoint; - s16 playerWaypoint; - UNUSED s32 stackPadding3; - f32 sp94; - f32 sp90; - f32 sp8C; - UNUSED s32 stackPadding4; - f32 distance; - f32 midX; - f32 midY; - f32 midZ; - f32 xdiff; - f32 ydiff; - f32 zdiff; - Player* player; - s32 playerId; - s16 waypoint1; - s16 waypoint2; - UNUSED f32 var_f2; - UNUSED f32 var_f18; - UNUSED f32 var_f14; - s32 pathIndex; - s32 waypointCount; - - playerId = camera->playerId; - player = gPlayerOne; - D_80164688[cameraId] = D_80163068[playerId]; - D_80164648[cameraId] += ((D_80164658[cameraId] - D_80164648[cameraId]) * 0.5f); - D_80163238 = playerId; - pathIndex = gPathIndexByPlayerId[playerId]; - waypointCount = gWaypointCountByPathIndex[pathIndex]; - player += playerId; - gNearestWaypointByCameraId[cameraId] = - func_8000D33C(camera->pos[0], camera->pos[1], camera->pos[2], gNearestWaypointByCameraId[cameraId], pathIndex); - playerWaypoint = ((gNearestWaypointByPlayerId[playerId] + waypointCount) - 2) % waypointCount; - cameraWaypoint = gNearestWaypointByCameraId[cameraId]; - if (func_80007BF8(playerWaypoint, cameraWaypoint, 1U, 0x000AU, waypointCount) <= 0) { - func_8001A348(cameraId, D_80164688[cameraId], D_80164680[cameraId]); - } else { - if ((cameraWaypoint < playerWaypoint) && ((playerWaypoint - cameraWaypoint) < 3)) { - D_80164658[cameraId] = gPlayers[playerId].unk_094 + 0.1; - } - if ((playerWaypoint < cameraWaypoint) && ((cameraWaypoint - playerWaypoint) < 3)) { - D_80164658[cameraId] = gPlayers[playerId].unk_094 - 0.1; - } - if (D_80164658[cameraId] > 10.0) { - D_80164658[cameraId] = 10.0f; - } - if (D_80164658[cameraId] < 0.0) { - D_80164658[cameraId] = 0.0f; - } - } - waypoint1 = (gNearestWaypointByCameraId[cameraId] + 1) % waypointCount; - waypoint2 = (gNearestWaypointByCameraId[cameraId] + 2) % waypointCount; - func_8000BBD8(waypoint1, D_80164688[cameraId], pathIndex); - midX = D_80162FA0[0] * 0.5; - midZ = D_80162FA0[2] * 0.5; - func_8000BBD8(waypoint2, D_80164688[cameraId], pathIndex); - midX += D_80162FA0[0] * 0.5; - midZ += D_80162FA0[2] * 0.5; - midY = (D_80164550[pathIndex][waypoint1].posY + D_80164550[pathIndex][waypoint2].posY) / 2.0; - xdiff = midX - D_801645F8[cameraId]; - ydiff = midY - D_80164618[cameraId]; - zdiff = midZ - D_80164638[cameraId]; - distance = sqrtf((xdiff * xdiff) + (ydiff * ydiff) + (zdiff * zdiff)); - if (distance != 0.0) { - midX = D_801645F8[cameraId] + ((D_80164648[cameraId] * xdiff) / distance); - midY = D_80164618[cameraId] + ((D_80164648[cameraId] * ydiff) / distance); - midZ = D_80164638[cameraId] + ((D_80164648[cameraId] * zdiff) / distance); - } else { - midX = D_801645F8[cameraId]; - midY = D_80164618[cameraId]; - midZ = D_80164638[cameraId]; - } - camera->pos[0] = midX; - camera->pos[2] = midZ; - camera->pos[1] = player->pos[1] + 10.0; - D_801645F8[cameraId] = midX; - D_80164618[cameraId] = midY; - D_80164638[cameraId] = midZ; - camera->lookAt[0] = player->pos[0]; - camera->lookAt[1] = player->pos[1] + 6.0; - camera->lookAt[2] = player->pos[2]; - func_80014D30(cameraId, pathIndex); - sp94 = camera->lookAt[0] - camera->pos[0]; - sp90 = camera->lookAt[1] - camera->pos[1]; - sp8C = camera->lookAt[2] - camera->pos[2]; - camera->rot[1] = atan2s(sp94, sp8C); - camera->rot[0] = atan2s(sqrtf((sp94 * sp94) + (sp8C * sp8C)), sp90); - camera->rot[2] = 0; -} - -void func_80018718(s32 playerId, UNUSED f32 arg1, s32 cameraId, s16 pathIndex) { - Camera* camera = cameras + cameraId; - s32 test = gWaypointCountByPathIndex[pathIndex]; - - D_80164688[cameraId] = D_80163068[playerId]; - gNearestWaypointByCameraId[cameraId] = ((gNearestWaypointByPlayerId[playerId] + test) - 5) % test; - - func_8000BA14(gNearestWaypointByCameraId[cameraId], D_80163068[playerId], 60.0f, pathIndex); - - D_801645F8[cameraId] = D_80162FA0[0]; - D_80164618[cameraId] = (f32) D_80164550[pathIndex][gNearestWaypointByCameraId[cameraId]].posY; - D_80164638[cameraId] = D_80162FA0[2]; - - D_80164658[cameraId] = gPlayers[playerId].unk_094; - D_80164648[cameraId] = gPlayers[playerId].unk_094; - D_8016448C = 1; - camera->pos[0] = D_801645F8[cameraId]; - camera->pos[1] = D_80164618[cameraId]; - camera->pos[2] = D_80164638[cameraId]; -} - -void func_800188F4(Camera* camera, UNUSED Player* unusePlayer, UNUSED s32 arg2, s32 cameraId) { - s16 cameraWaypoint; - s16 playerWaypoint; - UNUSED s32 stackPadding0; - f32 spAC; - f32 spA8; - f32 spA4; - Player* player; - f32 distance; - f32 midX; - f32 midY; - f32 midZ; - f32 xdiff; - f32 ydiff; - f32 zdiff; - UNUSED f32 sp64; - UNUSED f32 sp60; - s16 waypoint1; - s16 waypoint2; - UNUSED f32 sp5C; - f32 temp_f2_4; - s32 playerId; - s32 pathIndex; - s32 waypointCount; - - player = gPlayerOne; - playerId = camera->playerId; - pathIndex = gPathIndexByPlayerId[playerId]; - waypointCount = gWaypointCountByPathIndex[pathIndex]; - D_80164648[cameraId] = gPlayers[playerId].unk_094; - if (D_8016448C == 0) { - if (gNearestWaypointByCameraId[cameraId] == - (((gNearestWaypointByPlayerId[playerId] + waypointCount) - 6) % waypointCount)) { - D_8016448C = 1; - } - if (D_80164688[cameraId] < (D_80163068[playerId] - 0.2)) { - D_80164648[cameraId] = gPlayers[playerId].unk_094 * 0.7; - } - if ((D_80163068[playerId] - 0.5) < D_80164688[cameraId]) { - D_80164688[cameraId] -= 0.01; - } - if (D_80164688[cameraId] < -0.9) { - D_80164688[cameraId] = -0.9f; - D_80164648[cameraId] = gPlayers[playerId].unk_094 * 0.8; - } - } else { - if (gNearestWaypointByCameraId[cameraId] == ((gNearestWaypointByPlayerId[playerId] + 6) % waypointCount)) { - D_8016448C = 0; - } - if ((D_80163068[playerId] + 0.2) < D_80164688[cameraId]) { - D_80164648[cameraId] = gPlayers[playerId].unk_094 * 1.3; - } - if (D_80164688[cameraId] < (D_80163068[playerId] + 0.5)) { - D_80164688[cameraId] += 0.01; - } - if (D_80164688[cameraId] > 0.9) { - D_80164688[cameraId] = 0.9f; - D_80164648[cameraId] = gPlayers[playerId].unk_094 * 1.2; - } - } - D_80163238 = playerId; - player += playerId; - gNearestWaypointByCameraId[cameraId] = - func_8000D33C(camera->pos[0], camera->pos[1], camera->pos[2], gNearestWaypointByCameraId[cameraId], pathIndex); - playerWaypoint = gNearestWaypointByPlayerId[playerId]; - cameraWaypoint = gNearestWaypointByCameraId[cameraId]; - if (func_80007BF8(playerWaypoint, cameraWaypoint, 0x000FU, 0x000FU, waypointCount) <= 0) { - func_8001A348(cameraId, D_80164688[cameraId], D_80164680[cameraId]); - } - waypoint1 = (gNearestWaypointByCameraId[cameraId] + 1) % waypointCount; - waypoint2 = (gNearestWaypointByCameraId[cameraId] + 2) % waypointCount; - func_8000BA14(waypoint1, D_80164688[cameraId], 60.0f, pathIndex); - midX = D_80162FA0[0] * 0.5; - midZ = D_80162FA0[2] * 0.5; - func_8000BA14(waypoint2, D_80164688[cameraId], 60.0f, pathIndex); - midX += D_80162FA0[0] * 0.5; - midZ += D_80162FA0[2] * 0.5; - midY = (D_80164550[pathIndex][waypoint1].posY + D_80164550[pathIndex][waypoint2].posY) / 2.0; - xdiff = midX - D_801645F8[cameraId]; - ydiff = midY - D_80164618[cameraId]; - zdiff = midZ - D_80164638[cameraId]; - distance = sqrtf((xdiff * xdiff) + (ydiff * ydiff) + (zdiff * zdiff)); - if (distance != 0.0) { - midX = D_801645F8[cameraId] + ((D_80164648[cameraId] * xdiff) / distance); - midY = D_80164618[cameraId] + ((D_80164648[cameraId] * ydiff) / distance); - midZ = D_80164638[cameraId] + ((D_80164648[cameraId] * zdiff) / distance); - } else { - midX = D_801645F8[cameraId]; - midY = D_80164618[cameraId]; - midZ = D_80164638[cameraId]; - } - camera->pos[0] = midX; - camera->pos[2] = midZ; - temp_f2_4 = get_surface_height(midX, midY + 30.0, midZ); - if ((temp_f2_4 < (midY - 20.0)) || (temp_f2_4 >= 3000.0)) { - camera->pos[1] = midY + 10.0; - } else { - camera->pos[1] = temp_f2_4 + 8.0; - } - D_801645F8[cameraId] = midX; - D_80164618[cameraId] = midY; - D_80164638[cameraId] = midZ; - camera->lookAt[0] = player->pos[0]; - camera->lookAt[1] = player->pos[1] + 6.0; - camera->lookAt[2] = player->pos[2]; - func_80014D30(cameraId, pathIndex); - spAC = camera->lookAt[0] - camera->pos[0]; - spA8 = camera->lookAt[1] - camera->pos[1]; - spA4 = camera->lookAt[2] - camera->pos[2]; - camera->rot[1] = atan2s(spAC, spA4); - camera->rot[0] = atan2s(sqrtf((spAC * spAC) + (spA4 * spA4)), spA8); - camera->rot[2] = 0; -} - -void func_80019118(s32 playerId, f32 arg1, s32 cameraId, UNUSED s16 pathIndex) { - Camera* camera = cameras + cameraId; - s32 test = gWaypointCountByPathIndex[0]; - f32 temp_f12; - f32 temp_f2; - - D_80164688[cameraId] = arg1; - gNearestWaypointByCameraId[cameraId] = gNearestWaypointByPlayerId[playerId] + 12; - gNearestWaypointByCameraId[cameraId] = gNearestWaypointByCameraId[cameraId] % test; - - func_8000BBD8(gNearestWaypointByCameraId[cameraId], arg1, 0); - D_801645F8[cameraId] = D_80162FA0[0]; - D_80164638[cameraId] = D_80162FA0[2]; - temp_f2 = (f32) D_80164550[0][gNearestWaypointByCameraId[cameraId]].posY; - - temp_f12 = get_surface_height(D_80162FA0[0], (f32) (temp_f2 + 30.0), D_80162FA0[2]); - - if ((temp_f12 < (temp_f2 - 20.0)) || (temp_f12 >= 3000.0)) { - D_80164618[cameraId] = (f32) (temp_f2 + 10.0); - } else { - D_80164618[cameraId] = (f32) (temp_f12 + 10.0); - } - D_80164648[cameraId] = 0.0f; - camera->pos[0] = D_801645F8[cameraId]; - camera->pos[1] = D_80164618[cameraId]; - camera->pos[2] = D_80164638[cameraId]; -} - -void func_8001933C(Camera* camera, UNUSED Player* playerArg, UNUSED s32 arg2, s32 cameraId) { - s16 cameraWaypoint; - s16 playerWaypoint; - UNUSED s32 pad; - f32 xdiff; - f32 ydiff; - f32 zdiff; - UNUSED s32 pad2; - s32 playerId; - UNUSED s32 pad3[10]; - Player* player; - TrackWaypoint* waypoint; - s32 pathIndex; - s32 waypointCount; - - playerId = camera->playerId; - pathIndex = gPathIndexByPlayerId[playerId]; - player = gPlayerOne; - player += playerId; - waypointCount = gWaypointCountByPathIndex[pathIndex]; - gNearestWaypointByCameraId[cameraId] = - func_8000D33C(camera->pos[0], camera->pos[1], camera->pos[2], gNearestWaypointByCameraId[cameraId], 0); - playerWaypoint = gNearestWaypointByPlayerId[playerId]; - cameraWaypoint = gNearestWaypointByCameraId[cameraId]; - if (func_80007BF8(playerWaypoint, cameraWaypoint, 0x0032U, 0x0014U, waypointCount) <= 0) { - func_8001A348(cameraId, D_80164688[cameraId], D_80164680[cameraId]); - } else { - if ((D_80163068[playerId] < -0.5) && ((f64) D_80164688[cameraId] < -0.5)) { - func_8001A348(cameraId, 1.0f, 0x0000000D); - } else if ((D_80163068[playerId] > 0.5) && ((f64) D_80164688[cameraId] > 0.5)) { - func_8001A348(cameraId, -1.0f, 0x0000000C); - } - } - camera->pos[0] = D_801645F8[cameraId]; - camera->pos[1] = D_80164618[cameraId]; - camera->pos[2] = D_80164638[cameraId]; - waypoint = &D_80164550[pathIndex][cameraWaypoint]; - camera->lookAt[0] = (player->pos[0] * 0.8) + (0.2 * waypoint->posX); - camera->lookAt[1] = (player->pos[1] * 0.8) + (0.2 * waypoint->posY); - camera->lookAt[2] = (player->pos[2] * 0.8) + (0.2 * waypoint->posZ); - func_80014D30(cameraId, pathIndex); - xdiff = camera->lookAt[0] - camera->pos[0]; - ydiff = camera->lookAt[1] - camera->pos[1]; - zdiff = camera->lookAt[2] - camera->pos[2]; - camera->rot[1] = atan2s(xdiff, zdiff); - camera->rot[0] = atan2s(sqrtf((xdiff * xdiff) + (zdiff * zdiff)), ydiff); - camera->rot[2] = 0; -} - -void func_8001968C(void) { - D_80164678[0] = 3; -} - -void func_8001969C(UNUSED s32 playerId, UNUSED f32 arg1, s32 cameraId, UNUSED s16 pathIndex) { - TrackWaypoint* waypoint; - - gNearestWaypointByCameraId[cameraId] = gWaypointCountByPathIndex[0] - 18; - - waypoint = &D_80164550[0][gNearestWaypointByCameraId[cameraId]]; - - D_801645F8[cameraId] = waypoint->posX; - //! @bug Adding an (f32) cast changes asm, why? - D_80164618[cameraId] = waypoint->posY + 10.0; - D_80164638[cameraId] = waypoint->posZ; - D_80164648[cameraId] = 0.0f; - D_80164678[cameraId] = 0; -} - -void func_80019760(Camera* camera, UNUSED Player* player, UNUSED s32 arg2, s32 cameraId) { - UNUSED s32 pad[2]; - f32 xdiff; - f32 ydiff; - f32 zdiff; - TrackWaypoint* temp_v1; - - camera->pos[0] = D_801645F8[cameraId]; - camera->pos[1] = D_80164618[cameraId]; - camera->pos[2] = D_80164638[cameraId]; - temp_v1 = &(*D_80164550)[gNearestWaypointByCameraId[cameraId]]; - camera->lookAt[0] = (f32) temp_v1->posX; - camera->lookAt[1] = (f32) temp_v1->posY; - camera->lookAt[2] = (f32) temp_v1->posZ; - func_80014D30(cameraId, 0); - xdiff = camera->lookAt[0] - camera->pos[0]; - ydiff = camera->lookAt[1] - camera->pos[1]; - zdiff = camera->lookAt[2] - camera->pos[2]; - camera->rot[1] = atan2s(xdiff, zdiff); - camera->rot[0] = atan2s(sqrtf((xdiff * xdiff) + (zdiff * zdiff)), ydiff); - camera->rot[2] = 0; -} - -void func_80019890(s32 playerId, s32 cameraId) { - s32 pathIndex; - Camera* camera = camera1; - camera += cameraId; - camera->playerId = playerId; - - D_801646C0[cameraId] = 0; - pathIndex = gPathIndexByPlayerId[playerId]; - - switch (D_80164680[cameraId]) { - case 0: - func_80015314(playerId, 0.0f, cameraId); - break; - case 2: - func_80015544(playerId, -1.0f, cameraId, pathIndex); - break; - case 3: - func_80015544(playerId, 1.0f, cameraId, pathIndex); - break; - case 6: - func_80015A9C(playerId, -0.6f, cameraId, (s16) pathIndex); - break; - case 7: - func_80015A9C(playerId, 0.6f, cameraId, (s16) pathIndex); - break; - case 4: - func_800162CC(playerId, -1.0f, cameraId, (s16) pathIndex); - break; - case 5: - func_800162CC(playerId, 1.0f, cameraId, (s16) pathIndex); - break; - case 9: - func_80016C3C(playerId, 0.0f, cameraId); - break; - case 1: - func_80017720(playerId, 0.0f, cameraId, (s16) pathIndex); - break; - case 14: - func_80017F10(playerId, 0.0f, cameraId, (s16) pathIndex); - break; - case 8: - func_80018718(playerId, 0.0f, cameraId, (s16) pathIndex); - break; - case 12: - func_80019118(playerId, -1.0f, cameraId, (s16) pathIndex); - break; - case 13: - func_80019118(playerId, 1.0f, cameraId, (s16) pathIndex); - break; - case 15: - func_8001969C(playerId, -1.0f, cameraId, (s16) pathIndex); - break; - case 16: - func_8001969C(playerId, 1.0f, cameraId, (s16) pathIndex); - break; - default: - func_80015314(playerId, 0.0f, cameraId); - break; - } - gNearestWaypointByCameraId[cameraId] = - func_8000BD94(camera->pos[0], camera->pos[1], camera->pos[2], (s32) pathIndex); - if ((s16) D_80164680[cameraId] == 9) { - D_80163DD8[cameraId] = (s32) pathIndex; - } -} - -void func_80019B50(s32 cameraIndex, u16 arg1) { - u16 var_v0; - - var_v0 = D_801646C0[cameraIndex]; - if (var_v0 < arg1) { - if ((arg1 - var_v0) < 0x8000) { - var_v0 += 0x5A; - if (arg1 < var_v0) { - var_v0 = arg1; - } - if (var_v0 < 0x5A) { - var_v0 = 0; - } - } else if ((arg1 - var_v0) >= 0x8000) { - var_v0 -= 0x5A; - } - } else if (arg1 < var_v0) { - if ((var_v0 - arg1) < 0x8000) { - var_v0 -= 0x5A; - if (var_v0 < arg1) { - var_v0 = arg1; - } - if (var_v0 >= 0xFFA6) { - var_v0 = 0; - } - } else if ((var_v0 - arg1) >= 0x8000) { - var_v0 += 0x5A; - if (!cameraIndex) {} // wtf? - } - } - D_801646C0[cameraIndex] = (s16) var_v0; -} - -void func_80019C50(s32 arg0) { - switch (D_80164678[arg0]) { - case 0: - if (D_80164608[arg0] == 1) { - D_80164678[arg0] = 1; - func_800C9060(arg0, SOUND_ARG_LOAD(0x19, 0x00, 0x90, 0x4F)); - D_80164670[arg0] = D_80164678[arg0]; - } - break; - case 1: - if (D_80164608[arg0] == 1) { - D_80164678[arg0] = 0; - func_800C9060(arg0, SOUND_ARG_LOAD(0x19, 0x00, 0x90, 0x50)); - D_80164670[arg0] = D_80164678[arg0]; - } - break; - } -} - -void func_80019D2C(Camera* camera, Player* player, s32 arg2) { - s32 playerId; - s32 nearestWaypoint; - - playerId = camera->playerId; - if ((D_80163378 != 0) && (gCurrentCourseId == COURSE_LUIGI_RACEWAY)) { - calculate_camera_up_vector(camera, arg2); - nearestWaypoint = gNearestWaypointByPlayerId[playerId]; - if (((nearestWaypoint >= 0x65) && (nearestWaypoint < 0xFA)) || - ((nearestWaypoint >= 0x1AF) && (nearestWaypoint < 0x226))) { - func_80019B50(arg2, (player->unk_206 * 2)); - } else { - func_80019B50(arg2, 0U); - } - } -} - -void func_80019DE4(void) { - D_801646CC = 1; -} - -void func_80019DF4(void) { - s32 i; - s32 playerId = gGPCurrentRacePlayerIdByRank[0]; - // clang-format off - // Has to be on a single line to match. Because IDO hates you :) - for (i = 0; i < 4; i++) { D_80164670[i] = D_80164678[i]; } - // clang-format on - camera1->playerId = playerId; - D_80164678[0] = 1; - D_801646CC = 2; -} - -void func_80019E58(void) { - D_80164680[0] = 1; - func_80019890(0, 0); - D_80164670[0] = D_80164678[0]; - D_80164678[0] = 1; - D_80164680[1] = 9; - func_80019890(0, 1); - D_80164670[1] = D_80164678[1]; - D_80164678[1] = 0; -} - -void func_80019ED0(void) { - s32 i; - - for (i = 0; i < 4; i++) { - D_80164670[i] = D_80164678[i]; - } - - gGPCurrentRacePlayerIdByRank[0] = (s16) gPlayerWinningIndex; - - camera1->playerId = (s16) gPlayerWinningIndex; - - for (i = 0; i < 4; i++) { - D_80164680[i] = 0; - func_80015314(gPlayerWinningIndex, 0, i); - D_80164678[i] = 1; - } -} - -void func_80019FB4(s32 cameraId) { - struct Controller* controller; - - controller = &gControllerOne[cameraId]; - if (controller->buttonPressed & 2) { - D_801645D0[cameraId] += 1; - } else { - D_801645D0[cameraId] = 0; - } - if (controller->buttonPressed & 4) { - D_801645E8[cameraId] += 1; - } else { - D_801645E8[cameraId] = 0; - } - if (controller->buttonPressed & 8) { - D_80164608[cameraId] += 1; - } else { - D_80164608[cameraId] = 0; - } - if (controller->buttonPressed & 1) { - D_80164628[cameraId] += 1; - } else { - D_80164628[cameraId] = 0; - } -} - -void func_8001A0A4(UNUSED u16* arg0, UNUSED Camera* arg1, UNUSED Player* arg2, UNUSED s8 arg3, s32 arg4) { - func_80019FB4(arg4); - func_80019C50(arg4); -} - -void func_8001A0DC(u16* arg0, Camera* arg1, Player* arg2, s8 arg3, s32 arg4) { - func_8001A0A4(arg0, arg1, arg2, arg3, arg4); - func_80019D2C(arg1, arg2, arg4); -} - -void func_8001A124(s32 arg0, s32 arg1) { - switch (gGPCurrentRaceRankByPlayerId[arg0]) { /* irregular */ - case 0: - if (random_int(0x0064U) < 0x32) { - D_80164680[arg1] = 0x000C; - } else { - D_80164680[arg1] = 0x000D; - } - func_800CA270(); - break; - case 1: - case 2: - case 3: - D_80164680[arg1] = 8; - break; - default: - if (random_int(0x0064U) < 0x32) { - D_80164680[arg1] = 0x000F; - } else { - D_80164680[arg1] = 0x0010; - } - break; - } -} - -void func_8001A220(UNUSED s32 arg0, s32 cameraId) { - switch (random_int(6)) { - case 0: - D_80164680[cameraId] = 4; - break; - case 1: - D_80164680[cameraId] = 5; - break; - case 2: - D_80164680[cameraId] = 6; - break; - case 3: - D_80164680[cameraId] = 7; - break; - case 4: - D_80164680[cameraId] = 8; - break; - case 5: - D_80164680[cameraId] = 1; - break; - default: - D_80164680[cameraId] = 8; - break; - } -} - -s32 func_8001A310(s32 waypoint, s32 arg1) { - if ((gCurrentCourseId == COURSE_BOWSER_CASTLE) && (arg1 != 0) && (waypoint >= 0xE7) && (waypoint < 0x1C2)) { - arg1 = 0; - } - return arg1; -} - -void func_8001A348(s32 cameraId, f32 arg1, s32 arg2) { - UNUSED s32 pad; - s32 playerId; - - playerId = cameras[cameraId].playerId; - D_80164688[cameraId] = arg1; - D_80164680[cameraId] = func_8001A310((s32) gNearestWaypointByCameraId[cameraId], arg2); - func_80019890(playerId, cameraId); -} - -void func_8001A3D8(s32 arg0, f32 arg1, s32 arg2) { - s32 playerId; - - playerId = cameras[arg0].playerId; - D_80164688[arg0] = arg1; - if (arg2 != D_80164680[arg0]) { - D_80164680[arg0] = arg2; - func_80019890(playerId, arg0); - } -} - -void func_8001A450(s32 playerId, s32 arg1, s32 arg2) { - s32 temp_v1; - s16 waypoint; - s32 temp_v0; - - if (!(gPlayers[playerId].effects & 0x1000000C)) { - temp_v1 = D_80164680[arg1]; - waypoint = gNearestWaypointByCameraId[arg1]; - temp_v0 = func_8001A310(waypoint, (temp_v1 + 1) % 10); - if ((temp_v0 != temp_v1) || (arg2 != playerId)) { - D_80164680[arg1] = temp_v0; - func_80019890(arg2, arg1); - } - } -} - -void func_8001A518(s32 arg0, s32 arg1, s32 arg2) { - switch (arg1) { /* irregular */ - case 0: - D_80164680[arg2] = 1; - break; - case 1: - case 2: - case 3: - func_8001A450(arg0, arg2, arg0); - break; - default: - D_80164680[arg2] = 0; - break; - } -} - -void func_8001A588(UNUSED u16* localD_80152300, Camera* camera, Player* player, s8 index, s32 cameraIndex) { - s32 var_v1; - UnkStruct_46D0* temp_v0_4; - s32 sp44; - s32 playerId; - playerId = camera->playerId; - - if (gModeSelection == TIME_TRIALS) { - playerId = 0; - } - func_80019FB4(cameraIndex); - - if ((s32) (camera->pos[0] * 10.0) == (s32) ((f64) camera->lookAt[0] * 10.0)) { - - if ((s32) (camera->pos[2] * 10.0) == (s32) ((f64) camera->lookAt[2] * 10.0)) { - camera->pos[0] = (f32) (camera->pos[0] + 100.0); - camera->pos[2] = (f32) (camera->pos[2] + 100.0); - } - } - if ((gModeSelection != BATTLE) && (D_80164680[cameraIndex] == -1) && (player->type & 0x800) && - ((u16) D_801646CC == 0) && (D_801646C8 == 0)) { - if (gModeSelection == VERSUS) { - func_8001A220(playerId, cameraIndex); - } else { - func_8001A124((s32) playerId, cameraIndex); - } - func_80019890((s32) playerId, cameraIndex); - } - - if ((D_80164680[cameraIndex] == 14) || (D_80164680[cameraIndex] == 0)) { - func_80019D2C(camera, player, cameraIndex); - } else { - D_801646C0[cameraIndex] = 0; - calculate_camera_up_vector(camera, cameraIndex); - } - switch ((u16) D_801646CC) { - case 1: - D_801646C8 += 1; - if (D_801646C8 >= 501) { - D_801646C8 = 0; - } - if ((cameraIndex == 0) && (((D_801646C8 == 10)) || (D_801646C8 == 11))) { - func_8001A518((s32) playerId, gGPCurrentRaceRankByPlayerId[playerId], 0); - } - if ((gModeSelection != TIME_TRIALS) && (cameraIndex == 1) && - (((D_801646C8 == 260)) || (D_801646C8 == 261))) { - - var_v1 = 0; - if (gPlayerCount == 2) { - func_8001A518((s32) playerId, gGPCurrentRaceRankByPlayerId[playerId], 1); - } else { - sp44 = (s32) playerId; - while (var_v1 != 8) { - playerId += 1; - var_v1 += 1; - if (playerId >= 8) { - playerId = 1; - } - if ((!(gPlayers[playerId].unk_0CA & 2) && !(gPlayers[playerId].unk_0CA & 8))) { - break; - } - } - func_8001A450(sp44, cameraIndex, (s32) playerId); - } - } - break; - case 2: - D_801646C8 += 1; - if (D_801646C8 > 250) { - D_801646C8 = 0; - } - if ((cameraIndex == 0) && (D_801646C8 == 10)) { - func_8001A450((s32) playerId, cameraIndex, (s32) playerId); - } - break; - default: - temp_v0_4 = &D_801646D0[cameraIndex]; - if (temp_v0_4->unk0 == (s16) 1) { - playerId = temp_v0_4->unk4; - temp_v0_4->unk0 = 0; - cameras[cameraIndex].playerId = playerId; - func_8001A3D8(cameraIndex, 0.0f, (s32) temp_v0_4->unk2); - } - break; - } - func_80019C50(cameraIndex); - switch (D_80164680[cameraIndex]) { - case 0: - func_80015390(camera, player, index); - break; - case 2: - case 3: - func_8001577C(camera, player, index, cameraIndex); - break; - case 6: - case 7: - func_80015C94(camera, player, index, cameraIndex); - break; - case 4: - case 5: - func_80016494(camera, player, index, cameraIndex); - break; - case 9: - func_80017054(camera, player, index, cameraIndex); - break; - case 1: - func_800178F4(camera, player, index, cameraIndex); - break; - case 14: - func_800180F0(camera, player, index, cameraIndex); - break; - case 8: - func_800188F4(camera, player, index, cameraIndex); - break; - case 12: - case 13: - func_8001933C(camera, player, index, cameraIndex); - break; - case 15: - case 16: - func_80019760(camera, player, index, cameraIndex); - break; - default: - func_80015390(camera, player, index); - break; - } -} - -void func_8001AAAC(s16 arg0, s16 arg1, s16 arg2) { - if (D_801646D0[arg0].unk0 == 0) { - D_801646D0[arg0].unk0 = 1; - D_801646D0[arg0].unk2 = arg1; - D_801646D0[arg0].unk4 = arg2; - } -} - -void func_8001AB00(void) { - s32 var_v1; - - for (var_v1 = 0; var_v1 < NUM_PLAYERS; var_v1++) { - D_801642D8[var_v1].unk_00 = 0; - D_801642D8[var_v1].unk_04 = 0; - D_801642D8[var_v1].actorIndex = -1; - D_801642D8[var_v1].unk_06 = 0; - D_801642D8[var_v1].unk_08 = 0; - } -} - -void kart_ai_decisions_branch_item(UNUSED s32 arg0, s16* arg1, s32 arg2) { - s32 value = -1; - switch (arg2) { - case ITEM_FAKE_ITEM_BOX: - value = 0xD; - break; - case ITEM_BOO: - value = 0x1B; - break; - case ITEM_BANANA: - value = 1; - break; - case ITEM_THUNDERBOLT: - value = 0x16; - break; - case ITEM_STAR: - value = 0x19; - break; - case ITEM_MUSHROOM: - value = 0x1D; - break; - case ITEM_DOUBLE_MUSHROOM: - break; - case ITEM_TRIPLE_MUSHROOM: - break; - case ITEM_SUPER_MUSHROOM: - break; - } - if (value >= 0) { - *arg1 = value; - } -} - -void func_8001ABE0(UNUSED s32 arg0, UNUSED D_801642D8_entry* arg1) { -} - -void func_8001ABEC(struct struct_801642D8* arg0) { - if ((arg0->ffff < 0) || (arg0->ffff >= 100)) { - arg0->unk0 = 0; - arg0->timer = 0; - } -} - -#ifdef NON_MATCHING -// By the looks of this function is probably something like `kart_ai_use_item_strategy` -// The use of several different actor types might make getting a match hard(er), -// might have to get creative/ugly with just a single generic `Actor` variable. -// https://decomp.me/scratch/FOlbG -void kart_ai_use_item_strategy(s32 playerId) { - s32 var_v0; - Player* player; - TrackWaypoint* waypoint; - D_801642D8_entry* temp_s0; - struct Actor* actor; - struct ShellActor* shell; - struct BananaActor* banana; - struct FakeItemBox* fakeItemBox; - struct BananaBunchParent* bananaBunchParent; - - player = &gPlayerOne[playerId]; - if (((gModeSelection != ((s32) 1)) && (((u16) D_801646CC) != ((u16) 1))) && - (!(player->type & PLAYER_CINEMATIC_MODE))) { - temp_s0 = &D_801642D8[playerId]; - switch (temp_s0->unk_00) { - case 0: - temp_s0->actorIndex = -1; - if ((((playerId * 0x14) + 0x64) < D_80164450[playerId]) && (temp_s0->unk_04 >= 0x259) && - (temp_s0->unk_06 < 3) && (gLapCountByPlayerId[playerId] < 3)) { - kart_ai_decisions_branch_item(playerId, &temp_s0->unk_00, - kart_ai_gen_random_item((s16) gLapCountByPlayerId[playerId], - gGPCurrentRaceRankByPlayerId[playerId])); - } else { - func_8001ABE0(playerId, temp_s0); - } - break; - - case 1: - if ((gLapCountByPlayerId[playerId] > 0) && - (gGPCurrentRaceRankByPlayerId[D_80163478] > gGPCurrentRaceRankByPlayerId[playerId]) && - (gGPCurrentRaceRankByPlayerId[D_80163478] == 0)) { - switch (player->characterId) { - case 4: - if (func_80007BF8(gNearestWaypointByPlayerId[playerId], - gNearestWaypointByPlayerId[D_80163478], 0x0028U, 2U, - (u16) ((s32) D_80164430)) > 0) { - temp_s0->unk_00 = 0x0022; - } - break; - - case 6: - if (func_80007BF8(gNearestWaypointByPlayerId[playerId], - gNearestWaypointByPlayerId[D_80163478], 4U, 2U, - (u16) ((s32) D_80164430)) > 0) { - temp_s0->unk_00 = 0x0022; - } - break; - - default: - if (func_80007BF8(gNearestWaypointByPlayerId[playerId], - gNearestWaypointByPlayerId[D_80163478], 0x000AU, 2U, - (u16) ((s32) D_80164430)) > 0) { - temp_s0->unk_00 = 0x0022; - } - break; - } - } else if (temp_s0->unk_00 == 1) { - temp_s0->actorIndex = use_banana_item(player); - if ((temp_s0->actorIndex >= 0) && (temp_s0->actorIndex < 0x64)) { - player->soundEffects |= HOLD_BANANA_SOUND_EFFECT; - temp_s0->unk_00 = 2; - temp_s0->unk_04 = 0; - temp_s0->unk_06 += 1; - temp_s0->unk_0E = (random_int(3U) * 0x14) + 0xA; - } else { - temp_s0->unk_00 = 0; - temp_s0->unk_04 = 0; - } - } - break; - - case 2: - banana = (struct BananaActor*) &gActorList[temp_s0->actorIndex]; - if ((!(banana->flags & 0x8000)) || (banana->type != 6) || (banana->state != 0) || - (playerId != banana->playerId)) { - temp_s0->unk_00 = 0; - temp_s0->unk_04 = 0; - player->soundEffects &= ~0x00040000; - } else if (temp_s0->unk_0E < temp_s0->unk_04) { - temp_s0->unk_00 = 3; - } - break; - - case 3: - banana = (struct BananaActor*) &gActorList[temp_s0->actorIndex]; - if ((((!(banana->flags & 0x8000)) || (banana->type != 6)) || (banana->state != 0)) || - (playerId != banana->playerId)) { - if (playerId != banana->playerId) {} - } else { - banana->state = 1; - banana->velocity[0] = 0.0f; - banana->velocity[1] = 0.0f; - banana->velocity[2] = 0.0f; - if (D_801631E0[playerId] == ((u16) 1)) { - banana->pos[1] = - get_surface_height(player->pos[0], (f32) (((f64) player->pos[1]) + 30.0), player->pos[2]) + - (banana->boundingBoxSize + 1.0f); - } - } - player->soundEffects &= ~0x00040000; - temp_s0->unk_04 = 0; - temp_s0->unk_00 = 0; - break; - - case 34: - temp_s0->actorIndex = use_banana_item(player); - if ((temp_s0->actorIndex >= 0) && (temp_s0->actorIndex < 0x64)) { - banana = (struct BananaActor*) &gActorList[temp_s0->actorIndex]; - banana->state = 4; - player->soundEffects |= HOLD_BANANA_SOUND_EFFECT; - temp_s0->unk_00 = 0x0023; - temp_s0->unk_04 = 0; - temp_s0->unk_06 += 1; - waypoint = &D_80164550[gPathIndexByPlayerId[0]] - [(gNearestWaypointByPlayerId[D_80163478] + 0x1E) % - gWaypointCountByPathIndex[gPathIndexByPlayerId[D_80163478]]]; - banana->velocity[0] = (waypoint->posX - player->pos[0]) / 20.0; - banana->velocity[1] = ((waypoint->posY - player->pos[1]) / 20.0) + 4.0; - banana->velocity[2] = (waypoint->posZ - player->pos[2]) / 20.0; - banana->pos[1] = player->pos[1]; - func_800C92CC(playerId, SOUND_ARG_LOAD(0x29, 0x00, 0x80, 0x09)); - func_800C98B8(player->pos, player->velocity, SOUND_ARG_LOAD(0x19, 0x01, 0x80, 0x14)); - } else { - temp_s0->unk_00 = 0; - temp_s0->unk_04 = 0; - } - break; - - case 35: - banana = (struct BananaActor*) &gActorList[temp_s0->actorIndex]; - if ((((!(banana->flags & 0x8000)) || (banana->type != 6)) || (banana->state != 4)) || - (playerId != banana->playerId)) { - temp_s0->unk_00 = 0; - temp_s0->unk_04 = 0; - player->soundEffects &= ~0x00040000; - } else { - banana->velocity[1] -= 0.4; - banana->pos[0] += banana->velocity[0]; - banana->pos[1] += banana->velocity[1]; - banana->pos[2] += banana->velocity[2]; - if (temp_s0->unk_04 >= 0x15) { - temp_s0->unk_00 = 0x0024; - } - } - break; - - case 36: - banana = (struct BananaActor*) &gActorList[temp_s0->actorIndex]; - if ((((!(banana->flags & 0x8000)) || (banana->type != 6)) || (banana->state != 4)) || - (playerId != banana->playerId)) { - if (playerId != banana->playerId) {} - } else { - banana->state = 1; - banana->velocity[0] = 0.0f; - banana->velocity[1] = 0.0f; - banana->velocity[2] = 0.0f; - banana->pos[1] = - get_surface_height(banana->pos[0], (f32) (((f64) banana->pos[1]) + 30.0), banana->pos[2]) + - (banana->boundingBoxSize + 1.0f); - } - player->soundEffects &= ~0x00040000; - temp_s0->unk_00 = 0; - temp_s0->unk_04 = 0; - break; - - case 4: - if (((s32) gNumActors) < 0x50) { - temp_s0->actorIndex = use_green_shell_item(player); - if ((temp_s0->actorIndex >= 0) && (temp_s0->actorIndex < 0x64)) { - temp_s0->unk_00 = 5; - temp_s0->unk_04 = 0; - temp_s0->unk_06 += 1; - temp_s0->unk_0E = (random_int(3U) * 0x14) + 0xA; - } else { - temp_s0->unk_00 = 0; - } - } else { - temp_s0->unk_00 = 0; - } - break; - - case 5: - actor = &gActorList[temp_s0->actorIndex]; - if ((((!(actor->flags & 0x8000)) || (actor->type != 7)) || (actor->state != 0)) || - (playerId != actor->rot[2])) { - temp_s0->unk_00 = 0; - temp_s0->unk_04 = 0; - } else if (temp_s0->unk_0E < temp_s0->unk_04) { - temp_s0->unk_00 = 6; - temp_s0->unk_04 = 0; - } - break; - - case 6: - actor = &gActorList[temp_s0->actorIndex]; - if ((((!(actor->flags & 0x8000)) || (actor->type != 7)) || (actor->state != 0)) || - (playerId != actor->rot[2])) { - temp_s0->unk_00 = 0; - temp_s0->unk_04 = 0; - } else { - actor->state = 1; - temp_s0->unk_04 = 0; - temp_s0->unk_00 = 0; - } - break; - - case 7: - if (((s32) gNumActors) < 0x50) { - temp_s0->actorIndex = use_red_shell_item(player); - if ((temp_s0->actorIndex >= 0) && (temp_s0->actorIndex < 0x64)) { - temp_s0->unk_00 = 8; - temp_s0->unk_04 = 0; - temp_s0->unk_06 += 1; - temp_s0->unk_0E = (random_int(3U) * 0x14) + 0xA; - } else { - temp_s0->unk_00 = 0; - } - } else { - temp_s0->unk_00 = 0; - } - break; - - case 8: - shell = (struct ShellActor*) &gActorList[temp_s0->actorIndex]; - if ((((!(shell->flags & 0x8000)) || (shell->type != 8)) || (shell->state != 0)) || - (playerId != shell->playerId)) { - temp_s0->unk_00 = 0; - temp_s0->unk_04 = 0; - } else if (temp_s0->unk_0E < temp_s0->unk_04) { - temp_s0->unk_00 = 9; - } - break; - - case 9: - func_8001ABEC((struct struct_801642D8*) temp_s0); - shell = (struct ShellActor*) &gActorList[temp_s0->actorIndex]; - if ((((!(shell->flags & 0x8000)) || (shell->type != 8)) || (shell->state != 0)) || - (playerId != shell->playerId)) { - temp_s0->unk_00 = 0; - temp_s0->unk_04 = 0; - } else { - shell->state = 1; - temp_s0->unk_04 = 0; - temp_s0->unk_00 = 0; - } - break; - - case 10: - if (((s32) gNumActors) < 0x50) { - temp_s0->actorIndex = use_banana_bunch_item(player); - if ((temp_s0->actorIndex >= 0) && (temp_s0->actorIndex < 0x64)) { - temp_s0->unk_00 = 0x000B; - temp_s0->unk_04 = 0; - temp_s0->unk_06 += 1; - temp_s0->unk_0E = (random_int(3U) * 0x14) + 0x3C; - } else { - temp_s0->unk_00 = 0; - } - } else { - temp_s0->unk_00 = 0; - } - break; - - case 11: - bananaBunchParent = (struct BananaBunchParent*) &gActorList[temp_s0->actorIndex]; - if (bananaBunchParent->state == 6) { - var_v0 = 0; - if (bananaBunchParent->bananaIndices[4] != (-1)) { - var_v0 = 1; - } - if (bananaBunchParent->bananaIndices[3] != (-1)) { - var_v0 = 1; - } - if (bananaBunchParent->bananaIndices[2] != (-1)) { - var_v0 = 1; - } - if (bananaBunchParent->bananaIndices[1] != (-1)) { - var_v0 = 1; - } - if (bananaBunchParent->bananaIndices[0] != (-1)) { - var_v0 = 1; - } - if ((bananaBunchParent->type != 0x000E) || (var_v0 == 0)) { - temp_s0->unk_00 = 0; - temp_s0->unk_04 = 0; - } else if (temp_s0->unk_0E < temp_s0->unk_04) { - temp_s0->unk_00 = 0x000C; - temp_s0->unk_08 = 0; - temp_s0->unk_04 = 0; - } - } - break; - - case 12: - if ((((s16) temp_s0->unk_04) % 10) == 0) { - if (temp_s0->unk_08 < 5) { - bananaBunchParent = (struct BananaBunchParent*) &gActorList[temp_s0->actorIndex]; - var_v0 = 0; - switch (temp_s0->unk_08) { - case 0: - if (bananaBunchParent->bananaIndices[4] != (-1)) { - var_v0 = 1; - } - break; - - case 1: - if (bananaBunchParent->bananaIndices[3] != (-1)) { - var_v0 = 1; - } - break; - - case 2: - if (bananaBunchParent->bananaIndices[2] != (-1)) { - var_v0 = 1; - } - break; - - case 3: - if (bananaBunchParent->bananaIndices[1] != (-1)) { - var_v0 = 1; - } - break; - - case 4: - if (bananaBunchParent->bananaIndices[0] != (-1)) { - var_v0 = 1; - } - break; - } - - if (((bananaBunchParent->type == 0x000E) && (bananaBunchParent->state == 6)) && (var_v0 == 1)) { - func_802B0648(bananaBunchParent); - } - temp_s0->unk_08 += 1; - } else { - temp_s0->unk_00 = 0; - temp_s0->unk_04 = 0; - } - } - break; - - case 13: - temp_s0->actorIndex = use_fake_itembox_item(player); - if ((temp_s0->actorIndex >= 0) && (temp_s0->actorIndex < 0x64)) { - temp_s0->unk_00 = 0x000E; - temp_s0->unk_04 = 0; - temp_s0->unk_06 += 1; - temp_s0->unk_0E = (random_int(3U) * 0x14) + 0xA; - } else { - temp_s0->unk_00 = 0; - } - break; - - case 14: - fakeItemBox = (struct FakeItemBox*) &gActorList[temp_s0->actorIndex]; - if ((((!(fakeItemBox->flags & 0x8000)) || (fakeItemBox->type != 0x000D)) || - (fakeItemBox->state != 0)) || - (playerId != ((s32) fakeItemBox->playerId))) { - temp_s0->unk_00 = 0; - temp_s0->unk_04 = 0; - } else if (temp_s0->unk_0E < temp_s0->unk_04) { - temp_s0->unk_00 = 0x000F; - } - break; - - case 15: - fakeItemBox = (struct FakeItemBox*) &gActorList[temp_s0->actorIndex]; - if ((((!(fakeItemBox->flags & 0x8000)) || (fakeItemBox->type != 0x000D)) || - (fakeItemBox->state != 0)) || - (playerId != ((s32) fakeItemBox->playerId))) { - if (playerId != fakeItemBox->rot[0]) {} - } else { - func_802A1064(fakeItemBox); - if (D_801631E0[playerId] == 1) { - fakeItemBox->pos[1] = - get_surface_height(fakeItemBox->pos[0], fakeItemBox->pos[1] + 30.0, fakeItemBox->pos[2]) + - fakeItemBox->boundingBoxSize; - } - } - temp_s0->unk_00 = 0; - temp_s0->unk_04 = 0; - break; - - case 22: - use_thunder_item(player); - func_800CAC60(playerId); - func_8009E5BC(); - temp_s0->unk_00 = 0x0017; - temp_s0->unk_04 = 0; - temp_s0->unk_06 += 1; - break; - - case 23: - if (temp_s0->unk_04 >= 0xF1) { - func_800CAD40((s32) ((u8) playerId)); - temp_s0->unk_00 = 0; - temp_s0->unk_04 = 0; - } - break; - - case 25: - player->soundEffects |= STAR_SOUND_EFFECT; - temp_s0->unk_00 = 0x001A; - temp_s0->unk_04 = 0; - temp_s0->unk_06 += 1; - break; - - case 26: - if (!(player->effects & STAR_EFFECT)) { - temp_s0->unk_00 = 0; - } - temp_s0->unk_04 = 0; - break; - - case 27: - player->soundEffects |= BOO_SOUND_EFFECT; - temp_s0->unk_00 = 0x001C; - temp_s0->unk_04 = 0; - temp_s0->unk_06 += 1; - break; - - case 28: - if (!(player->effects & BOO_EFFECT)) { - temp_s0->unk_00 = 0; - } - temp_s0->unk_04 = 0; - break; - - case 29: - player->soundEffects |= BOOST_SOUND_EFFECT; - temp_s0->unk_00 = 0; - temp_s0->unk_04 = 0; - temp_s0->unk_06 += 1; - break; - - case 30: - if (temp_s0->unk_04 >= 0x3D) { - player->soundEffects |= BOOST_SOUND_EFFECT; - temp_s0->unk_00 = 0x001D; - temp_s0->unk_04 = 0; - } - break; - - case 31: - if (temp_s0->unk_04 >= 0x3D) { - player->soundEffects |= BOOST_SOUND_EFFECT; - temp_s0->unk_00 = 0x001E; - temp_s0->unk_04 = 0; - } - break; - - case 32: - temp_s0->unk_00 = 0x0021; - temp_s0->unk_04 = 0; - temp_s0->unk_0E = 0x0258; - break; - - case 33: - if ((((s16) temp_s0->unk_04) % 60) == 0) { - player->soundEffects |= BOOST_SOUND_EFFECT; - if (temp_s0->unk_0E < temp_s0->unk_04) { - temp_s0->unk_00 = 0; - temp_s0->unk_04 = 0; - } - } - break; - - default: - break; - } - - if (temp_s0->unk_04 < 0x2710) { - temp_s0->unk_04 += 1; - } - if (player->effects & (BOO_EFFECT | BOOST_EFFECT | STAR_EFFECT)) { // 0x80002200 - temp_s0->unk_04 = 0; - } - } -} -#else -GLOBAL_ASM("asm/non_matchings/code_80005FD0/kart_ai_use_item_strategy.s") -#endif - -void func_8001BE78(void) { - Player* temp_s1; - TrackWaypoint* temp_s0; - s32 i; - - func_8000F628(); - for (i = 0; i < 4; i++) { - temp_s1 = &gPlayerOne[i]; - temp_s1->type &= 0xDFFF; - gPathIndexByPlayerId[i] = i; - D_801634F8[i].unkC = 0.0f; - D_801634F8[i].unk4 = 0.0f; - D_801634F8[i].unk0 = 0.0f; - switch (i) { - case 0: - gNearestWaypointByPlayerId[i] = 6; - break; - case 1: - gNearestWaypointByPlayerId[i] = 1; - break; - case 2: - gNearestWaypointByPlayerId[i] = 6; - break; - case 3: - gNearestWaypointByPlayerId[i] = 1; - break; - } - temp_s0 = &D_80164550[i][gNearestWaypointByPlayerId[i]]; - temp_s1->pos[0] = (f32) temp_s0->posX; - temp_s1->pos[1] = - get_surface_height((f32) temp_s0->posX, 2000.0f, (f32) temp_s0->posZ) + temp_s1->boundingBoxSize; - temp_s1->pos[2] = (f32) temp_s0->posZ; - temp_s1->rotation[1] = (s16) *D_80164590[i]; - func_8003680C(temp_s1, 0); - temp_s1++; - D_80163410[i] = 0; - } -} - -void func_8001C05C(void) { - init_segment_racing(); - gCurrentCourseId = COURSE_AWARD_CEREMONY; - D_8016347C = 0; - D_8016347E = 0; - D_80163480 = 0; - D_80163484 = 0; - func_8000F2DC(); - func_80014DE4(0); - func_8001BE78(); - D_80163418[0] = -3202.475097656f; - D_80163428[0] = 19.166999817f; - D_80163438[0] = -477.623992920f; - D_80163418[1] = -3205.080078125f; - D_80163428[1] = 19.166999817f; - D_80163438[1] = -462.851989746f; - D_80163418[2] = -3199.870117188f; - D_80163428[2] = 19.166999817f; - D_80163438[2] = -492.395996094f; - D_80163418[3] = -2409.197021484f; - D_80163428[3] = 0.0f; - D_80163438[3] = -355.253997803; -} - -void func_8001C14C(void) { - f32 temp_f0; - f32 temp_f2; - s32 var_s1; - Player* temp_s0; - - if (D_8016347C == 1) { - D_80163480 += 1; - } - if ((D_8016347E == 1) && (gBombKarts[0].state == 0) && (D_802874D8.unk1D >= 3)) { - D_80163484++; - if (D_80163484 >= 0xF) { - D_80163484 = 0; - D_8016347E = 2; - func_8009265C(); - } - } - for (var_s1 = 0; var_s1 < 4; var_s1++) { - if ((var_s1 == 3) && (D_8016347C == 0)) { - break; - } - - temp_s0 = &gPlayerOne[var_s1]; - func_80009B60(var_s1); - if (!(temp_s0->type & 0x2000)) { - temp_f0 = D_80163418[var_s1] - temp_s0->pos[0]; - temp_f2 = D_80163438[var_s1] - temp_s0->pos[2]; - if ((f64) ((temp_f0 * temp_f0) + (temp_f2 * temp_f2)) < 1.0) { - if (var_s1 != 3) { - if (1) {} - // Why oh why is a ternary required here? Who does that? - (D_8016347C == 0) ? (temp_s0->type |= 0x2000) : (temp_s0->type &= ~0x2000); - if ((gPlayerOne->type & 0x2000) && (gPlayerTwo->type & 0x2000) && (gPlayerThree->type & 0x2000)) { - D_8016347C = 1; - D_80163480 = 0; - } - } else if (D_8016347E == 0) { - if (!(temp_s0->effects & 0x01000000)) { - temp_s0->type |= 0x2000; - } - D_8016347E = 1; - D_80163484 = 0; - } else if (!(temp_s0->effects & 0x01000000)) { - temp_s0->type |= 0x2000; - } - } - } - } -} - -void func_8001C3C4(s32 cameraId) { - if (gCurrentCourseId == COURSE_AWARD_CEREMONY) { - if (gBombKarts[0].waypointIndex >= 16) { - func_80057114(PLAYER_FOUR); - } - } else { - if (gModeSelection == VERSUS) { - func_80057114(cameraId); - } - } -} - -UNUSED void func_8001C42C(void) { - if (D_800DDB20 == 0) { - if ((gControllerThree->buttonPressed & 0x20) != 0) { - D_800DDB20 = 1; - } - } else { - if ((gControllerThree->buttonPressed & 0x20) != 0) { - D_800DDB20 = 0; - } - func_80057C60(); - gSPDisplayList(gDisplayListHead++, D_0D0076F8); - func_80057CE4(); - } -} diff --git a/src/code_80005FD0.h b/src/code_80005FD0.h deleted file mode 100644 index 61dff34355..0000000000 --- a/src/code_80005FD0.h +++ /dev/null @@ -1,413 +0,0 @@ -#ifndef CODE_80005FD0_H -#define CODE_80005FD0_H - -#include "vehicles.h" -#include "camera.h" -#include "waypoints.h" -#include - -struct struct_801642D8 { - /* 0x0 */ u16 unk0; - /* 0x2 */ s16 ffff; - /* 0x4 */ s16 timer; // confirm? - /* 0x6 */ s16 laps; // confirm? - /* 0x8 */ s32 blank; - /* 0xC */ s32 unkC; -}; - -struct unexpiredActors { - /* 0x00 */ s32 unk0; - /* 0x04 */ s32 unk4; - /* 0x08 */ s32 unk8; - /* 0x0C */ u16 unkC; - /* 0x0E */ u16 actorIndex; - /* 0x10 */ s16 unk10; - /* 0x12 */ // s16 compilerPadding; - /* 0x14 */ u32 unk14; - /* 0x18 */ s32 unk18; -}; // size = 0x1C - -typedef struct { - /* 0x00 */ f32 unk0; - /* 0x04 */ f32 unk4; - /* 0x08 */ f32 unk8; - /* 0x0C */ f32 unkC; -} Test; // size = 0x10 - -// Something related to CPU item usage -typedef struct { - /* 0x00 */ s16 unk_00; - /* 0x02 */ s16 actorIndex; - /* 0x04 */ s16 unk_04; - /* 0x06 */ s16 unk_06; - /* 0x08 */ s16 unk_08; - /* 0x0A */ s16 unk_0A; - /* 0x0C */ s16 unk_0C; - /* 0x0E */ s16 unk_0E; -} D_801642D8_entry; // size = 0x10 - -typedef struct { - s16 unk0; - s16 unk2; - s16 unk4; - u16 unk6; -} UnkStruct_46D0; - -typedef struct { - s16 x; - s16 z; -} Path2D; - -/* Function Prototypes */ -s16 get_angle_between_waypoints(Vec3f, Vec3f); - -s32 func_80006018(f32, f32, f32, f32, f32, f32, f32, f32); -void adjust_position_by_angle(Vec3f, Vec3f, s16); -s32 set_vehicle_render_distance_flags(Vec3f, f32, s32); -void func_800065D0(s32, Player*); -void set_places(void); - -void func_800070F4(void); -void func_800074D4(void); -s32 func_80007BF8(u16, u16, u16, u16, u16); -void func_80007D04(s32, Player*); -void func_80007FA4(s32, Player*, f32); - -void func_80008424(s32, f32, Player*); -s32 func_800088D8(s32, s16, s16); -void func_80008DC0(s32); -s32 func_80008E58(s32, s32); -void func_80008F38(s32); - -void func_80009000(s32); -void func_800090F0(s32, Player*); -f32 func_80009258(s32, f32, f32); -void func_8000929C(s32, Player*); -void update_vehicles(void); -void func_800098FC(s32, Player*); -void func_800099EC(s32, Player*); -void func_80009B60(s32); - -void func_8000B140(s32); -s32 func_8000B7E4(s32, u16); -s32 func_8000B820(s32); -f32 func_8000B874(f32, f32, u16, s32); -void func_8000B95C(s32, u16, s32); -void func_8000BA14(u16, f32, f32, s16); -void func_8000BBD8(u16, f32, s16); -s16 func_8000BD94(f32, f32, f32, s32); - -s16 find_closest_waypoint_track_section(f32, f32, f32, u16, s32*); -s16 func_8000C884(f32, f32, f32, s16, s32, u16); -s16 find_closest_waypoint_with_previous_waypoint(f32, f32, f32, s16, s32); -void func_8000CBA4(f32, f32, f32, s16*, s32); -void func_8000CBF8(f32, f32, f32, s16*, s32); -s16 func_8000CC88(f32, f32, f32, Player*, s32, s32*); -s16 func_8000CD24(f32, f32, f32, s16, Player*, s32, s32); - -s16 find_closest_vehicles_waypoint(f32, f32, f32, s16); -s16 func_8000D24C(f32, f32, f32, s32*); -s16 func_8000D2B4(f32, f32, f32, s16, s32); -s16 func_8000D33C(f32, f32, f32, s16, s32); -f32 func_8000D3B8(s32); -void func_8000D438(s32, u16); -s16 func_8000D6D0(Vec3f, s16*, f32, f32, s16, s16); -s16 func_8000D940(Vec3f, s16*, f32, f32, s16); -s16 update_vehicle_following_waypoint(Vec3f, s16*, f32); -void set_bomb_kart_spawn_positions(void); -void func_8000DF8C(s32); - -s32 add_actor_in_unexpired_actor_list(s32, s16); -s32 add_red_shell_in_unexpired_actor_list(s32); -s32 add_green_shell_in_unexpired_actor_list(s32); -s32 add_blue_shell_in_unexpired_actor_list(s32); -void delete_actor_in_unexpired_actor_list(s32); -void func_8000EEDC(void); -void generate_player_smoke(void); - -void func_8000F0E0(void); -void func_8000F124(void); -void func_8000F2BC(TrackWaypoint*, size_t); -void func_8000F2DC(void); -void func_8000F628(void); - -void func_800100F0(s32); -void func_80010218(s32); -f32 func_80010480(s32, u16); -void func_800107C4(s32); -s16 func_80010CB0(s32, s32); -void func_80010DBC(s32); -void func_80010E6C(s32); -f32 func_80010F40(f32, f32, f32, s32, s32); -f32 func_80010FA0(f32, f32, f32, s32, s32); - -s32 func_80011014(TrackWaypoint*, TrackWaypoint*, s32, s32); -s32 process_path_data(TrackWaypoint*, TrackWaypoint*); -s32 generate_2d_path(Path2D*, TrackWaypoint*, s32); -void copy_courses_kart_ai_behaviour(void); -void reset_kart_ai_behaviour_none(s32); -void reset_kart_ai_behaviour(s32); -void kart_ai_behaviour_start(s32, Player*); -void kart_ai_behaviour_end(s32, Player*); -void kart_ai_behaviour(s32); -void func_80011EC0(s32, Player*, s32, u16); - -void generate_train_waypoints(void); -void generate_ferry_waypoints(void); -void spawn_vehicle_on_road(VehicleStuff*); -void spawn_course_vehicles(void); -void set_vehicle_pos_waypoint(TrainCarStuff*, Path2D*, u16); -void init_vehicles_trains(void); -void sync_train_components(TrainCarStuff*, s16); -void update_vehicle_trains(void); -void func_80012DC0(s32, Player*); - -void func_80013054(void); -void check_ai_crossing_distance(s32); -void init_vehicles_ferry(void); -void update_vehicle_paddle_boats(void); -void func_80013854(Player*); -void initialize_toads_turnpike_vehicle(f32, f32, s32, s32, VehicleStuff*, TrackWaypoint*); -f32 func_80013C74(s16, s16); -void update_vehicle_follow_waypoint(VehicleStuff*); -void func_80013F7C(s32, Player*, VehicleStuff*, f32, f32, s32, u32); - -f32 func_800145A8(s16, f32, s16); -void func_800146B8(s32, s32, VehicleStuff*); -void init_vehicles_box_trucks(void); -void update_vehicle_box_trucks(void); -void func_800148C4(s32, Player*); -void func_8001490C(s32); -void init_vehicles_school_buses(void); -void update_vehicle_school_bus(void); -void func_80014A18(s32, Player*); -void func_80014A60(s32); -void init_vehicles_trucks(void); -void update_vehicle_tanker_trucks(void); -void func_80014B6C(s32, Player*); -void func_80014BB4(s32); -void init_vehicles_cars(void); -void update_vehicle_cars(void); -void func_80014CC0(s32, Player*); -void func_80014D08(s32); -void func_80014D30(s32, s32); -void func_80014DE4(s32); -f32 func_80014EE4(f32, s32); - -void calculate_camera_up_vector(Camera*, s32); -void func_8001530C(void); -void func_80015314(s32, f32, s32); -void func_80015390(Camera*, Player*, s32); -void func_80015544(s32, f32, s32, s32); -void func_8001577C(Camera*, UNUSED Player*, s32, s32); -void func_80015A9C(s32, f32, s32, s16); -void func_80015C94(Camera*, Player*, s32, s32); - -void func_800162CC(s32, f32, s32, s16); -void func_80016494(Camera*, Player*, s32, s32); -void func_80016C3C(s32, f32, s32); - -void func_80017720(s32, f32, s32, s16); -void func_800178F4(Camera*, Player*, s32, s32); -void func_80017F10(s32, f32, s32, s16); - -void func_800180F0(Camera*, Player*, s32, s32); -void func_80018718(s32, f32, s32, s16); -void func_800188F4(Camera*, Player*, s32, s32); - -void func_80019118(s32, f32, s32, s16); -void func_8001933C(Camera*, UNUSED Player*, s32, s32); -void func_8001968C(void); -void func_8001969C(s32, f32, s32, s16); -void func_80019760(Camera*, UNUSED Player*, s32, s32); -void func_80019890(s32, s32); -void func_80019B50(s32, u16); -void func_80019C50(s32); -void func_80019D2C(Camera*, Player*, s32); -void func_80019DE4(void); -void func_80019DF4(void); -void func_80019E58(void); -void func_80019ED0(void); -void func_80019FB4(s32); - -void func_8001A0A4(u16*, Camera*, Player*, s8, s32); -void func_8001A0DC(u16*, Camera*, Player*, s8, s32); -void func_8001A124(s32, s32); -s32 func_8001A310(s32, s32); -void func_8001A348(s32, f32, s32); -void func_8001A3D8(s32, f32, s32); -void func_8001A450(s32, s32, s32); -void func_8001A518(s32, s32, s32); -void func_8001A588(u16*, Camera*, Player*, s8, s32); -void func_8001AAAC(s16, s16, s16); -void func_8001AB00(void); -void kart_ai_decisions_branch_item(s32, s16*, s32); -void func_8001ABE0(s32, D_801642D8_entry*); -void func_8001ABEC(struct struct_801642D8*); -void kart_ai_use_item_strategy(s32); - -void func_8001BE78(void); - -void func_8001C05C(void); -void func_8001C14C(void); -void func_8001C3C4(s32); -void func_8001C42C(void); - -/* This is where I'd put my static data, if I had any */ - -extern Collision D_80162E70; -extern s16 D_80162EB0; // Possibly a float. -extern s16 D_80162EB2; // possibly [3] -extern KartAIBehaviour* gCoursesKartAIBehaviour[]; -extern s16 D_80162F10[]; -extern s16 D_80162F50[]; -extern Vec3f D_80162FA0; -extern Vec3f D_80162FB0; -extern Vec3f D_80162FC0; -extern s16 gTrainSmokeTimer; -extern s16 D_80162FD0; -extern f32 gCourseCompletionPercentByRank[]; // D_80162FD8 -extern s16 D_80162FF8[]; -extern s16 D_80163010[]; -extern f32 D_80163028[]; -extern s16 D_80163050[]; -extern f32 D_80163068[]; -extern f32 D_80163090[]; -extern s32 D_801630B8[]; -extern u16 D_801630E0; -extern s16 D_801630E2; -extern s16 D_801630E8[]; -extern s16 gFerrySmokeTimer; -extern s32 D_80163100[]; -extern s32 D_80163128[]; -extern s32 D_80163150[]; -extern f32 D_80163178[]; -extern f32 D_801631A0[]; -extern s16 D_801631C8; -extern s32 D_801631CC; -extern TrackWaypoint* D_801631D0; -extern TrackWaypoint* D_801631D4; -extern s16* D_801631D8; -extern u16 D_801631E0[]; -extern u16 D_801631F8[]; -extern f32 D_8016320C; -extern f32 D_80163210[]; -extern s32 D_80163238; -extern u16 D_80163240[]; -extern u16 D_80163258[]; -extern u16 D_80163270[]; -extern s32 D_80163288[]; -// Exact pointer type unknown -extern KartAIBehaviour* sCurrentKartAIBehaviour; -extern u16 gCurrentKartAIBehaviourId[]; -extern u16 gPreviousKartAIBehaviourId[]; -extern u16 gKartAIBehaviourState[]; - -enum { KART_AI_BEHAVIOUR_STATE_NONE, KART_AI_BEHAVIOUR_STATE_START, KART_AI_BEHAVIOUR_STATE_RUNNING }; - -extern s16 D_80163300[]; -extern u16 D_80163318[]; -extern u16 D_80163330[]; -extern u16 D_80163344[]; -extern u16 D_80163348[]; -extern u16 D_8016334C[]; -extern u16 gSpeedKartAIBehaviour[]; - -enum { - SPEED_KART_AI_BEHAVIOUR_NORMAL, - SPEED_KART_AI_BEHAVIOUR_FAST, - SPEED_KART_AI_BEHAVIOUR_SLOW, - SPEED_KART_AI_BEHAVIOUR_MAX -}; - -extern s32 D_80163368[]; -extern s32 D_80163378; -extern s32 D_8016337C; -extern s16 D_80163380[]; -extern s16 D_80163398[]; -extern s16 D_801633B0[]; -extern s16 D_801633C8[]; -extern s16 D_801633E0[]; -extern s16 D_801633F8[]; -extern s16 D_80163410[]; -extern f32 D_80163418[]; -extern f32 D_80163428[]; -extern f32 D_80163438[]; -extern s32 D_80163448; -extern f32 D_8016344C; -extern f32 D_80163450[]; -extern s16 D_80163478; -// 0 or 1, only 1 when when in extra (mirror) mode -extern s16 D_8016347A; -extern s16 D_8016347C; -extern s16 D_8016347E; -extern s32 D_80163480; -extern s32 D_80163484; -extern s32 D_80163488; -extern s16 D_8016348C; -extern s16 D_80163490[]; -extern s16 D_801634A8[]; -extern s16 D_801634C0[]; -extern s16 bStopAICrossing[]; -extern s16 D_801634EC; -extern s32 D_801634F0; -extern s32 D_801634F4; -extern Test D_801634F8[]; -extern Path2D* gVehicle2DWaypoint; -extern s32 gVehicle2DWaypointLength; -extern u16 isCrossingTriggeredByIndex[]; -extern u16 sCrossingActiveTimer[]; -extern s32 D_80163DD8[]; -extern struct unexpiredActors gUnexpiredActorsList[]; -extern D_801642D8_entry D_801642D8[]; -extern s16 D_80164358; -extern s16 D_8016435A; -extern s16 D_8016435C; -extern s16 gGPCurrentRacePlayerIdByRank[]; // D_80164360 -extern s16 D_80164378[]; -extern s32 gLapCountByPlayerId[]; // D_80164390 -extern s32 gGPCurrentRaceRankByPlayerId[]; // D_801643B8 -extern s32 D_801643E0[]; -extern s32 D_80164408[]; -extern u16 D_80164430; -extern u16 gNearestWaypointByPlayerId[]; -extern s32 D_80164450[]; -extern s16 D_80164478[]; -extern s32 D_8016448C; -extern f32 D_80164498[]; -extern f32 gLapCompletionPercentByPlayerId[]; // D_801644A8 -extern f32 gCourseCompletionPercentByPlayerId[]; // D_801644D0 -extern s16 D_801644F8[]; -extern f32 D_80164510[]; -extern s16 D_80164538[]; -extern s32 D_801645D0[]; -extern s32 D_801645E8[]; -extern f32 D_801645F8[]; -extern s32 D_80164608[]; -extern f32 D_80164618[]; -extern s32 D_80164628[]; -extern f32 D_80164638[]; -extern f32 D_80164648[]; -extern f32 D_80164658[]; -extern s16 D_80164670[]; -extern s16 D_80164678[]; -extern s16 D_80164680[]; -extern f32 D_80164688[]; -extern f32 D_80164698; -extern f32 D_8016469C; -extern f32 D_801646A0; -extern s16 D_801646C0[]; -extern u32 D_801646C8; -extern u16 D_801646CC; -extern UnkStruct_46D0 D_801646D0[]; - -// See bss_80005FD0.s -extern f32 gCourseCompletionPercentByRank[NUM_PLAYERS]; -extern s32 D_801643E0[]; -extern s32 D_8016448C; -extern u16 D_801637BE; -extern u16 D_80163E2A; - -// extern Gfx D_0D0076F8[]; - -#endif diff --git a/src/code_8003DC40.c b/src/code_8003DC40.c index b97838b710..3ea44467ee 100644 --- a/src/code_8003DC40.c +++ b/src/code_8003DC40.c @@ -61,6 +61,7 @@ UNUSED void func_8003DE4C(Player* player, Vec3f arg1) { arg1[1] = 0.0f; mtxf_translate_vec3f_mat3(arg1, player->orientationMatrix); } + // Stick to ground? void func_8003E048(Player* player, Vec3f arg1, Vec3f arg2, Vec3f arg3, f32* arg4, f32* arg5, f32* arg6, f32* arg7) { *arg5 += arg1[0] * player->collision.surfaceDistance[2] * 1; @@ -70,14 +71,15 @@ void func_8003E048(Player* player, Vec3f arg1, Vec3f arg2, Vec3f arg3, f32* arg4 if (player->collision.orientationVector[1] <= 0.8829f) { arg3[0] = ((player->unk_206 / 182) * 0xB4); arg3[2] = (-(player->slopeAccel / 182) * 0xB4); - decelerate_ai_player(player, 4.0f); + decelerate_player(player, 4.0f); player->unk_DAC = 0.5f; if ((player->effects & BOOST_EFFECT) != 0) { remove_boost_effect(player); player->currentSpeed /= 2; player->unk_08C /= 2; } - } else if ((((player->unk_094 / 18.0f) * 216.0f) > 20.0f) || ((player->effects & 0x10000) == 0x10000)) { + } else if ((((player->speed / 18.0f) * 216.0f) > 20.0f) || + ((player->effects & UNKNOWN_EFFECT_0x10000) == UNKNOWN_EFFECT_0x10000)) { arg3[0] = ((player->unk_206 / 182) * 0x32); arg3[2] = (-(player->slopeAccel / 182) * 0x3C); } else { @@ -96,8 +98,8 @@ void func_8003E37C(Player* player, Vec3f arg1, Vec3f arg2, Vec3f arg3, f32* arg4 if ((player->collision.orientationVector[1] <= 0.7318f) || (player->surfaceType == CLIFF)) { arg3[0] = ((player->unk_206 / 182) * 0xB4); arg3[2] = (-(player->slopeAccel / 182) * 0xB4); - if (((player->unk_094 / 18.0f) * 216.0f) >= 8.0f) { - decelerate_ai_player(player, 5.0f); + if (((player->speed / 18.0f) * 216.0f) >= 8.0f) { + decelerate_player(player, 5.0f); } player->unk_DAC = 0.5f; if ((player->effects & BOOST_EFFECT) != 0) { @@ -105,7 +107,8 @@ void func_8003E37C(Player* player, Vec3f arg1, Vec3f arg2, Vec3f arg3, f32* arg4 player->currentSpeed /= 2; player->unk_08C /= 2; } - } else if ((((player->unk_094 / 18.0f) * 216.0f) > 20.0f) || ((player->effects & 0x10000) == 0x10000)) { + } else if ((((player->speed / 18.0f) * 216.0f) > 20.0f) || + ((player->effects & UNKNOWN_EFFECT_0x10000) == UNKNOWN_EFFECT_0x10000)) { arg3[0] = ((player->unk_206 / 182) * 0x32); arg3[2] = (-(player->slopeAccel / 182) * 0x32); } else { @@ -124,9 +127,10 @@ void func_8003E6EC(Player* player, Vec3f arg1, Vec3f arg2, Vec3f arg3, f32* arg4 if (player->collision.orientationVector[1] <= 0.8829f) { arg3[0] = ((player->unk_206 / 182) * 0xB4); arg3[2] = (-(player->slopeAccel / 182) * 0xB4); - decelerate_ai_player(player, 4.0f); + decelerate_player(player, 4.0f); func_8003DC40(player); - } else if ((((player->unk_094 / 18.0f) * 216.0f) > 20.0f) || ((player->effects & 0x10000) == 0x10000)) { + } else if ((((player->speed / 18.0f) * 216.0f) > 20.0f) || + ((player->effects & UNKNOWN_EFFECT_0x10000) == UNKNOWN_EFFECT_0x10000)) { arg3[0] = ((player->unk_206 / 182) * 0x32); arg3[2] = (-(player->slopeAccel / 182) * 0x3C); } else { @@ -145,10 +149,11 @@ void func_8003E9EC(Player* player, Vec3f arg1, Vec3f arg2, Vec3f arg3, f32* arg4 if (player->collision.orientationVector[1] <= 0.8357f) { arg3[0] = ((player->unk_206 / 182) * 0x78); arg3[2] = (-(player->slopeAccel / 182) * 0xB4); - decelerate_ai_player(player, 4.0f); + decelerate_player(player, 4.0f); func_8003DC40(player); } else { - if ((((player->unk_094 / 18.0f) * 216.0f) > 20.0f) || ((player->effects & 0x10000) == 0x10000)) { + if ((((player->speed / 18.0f) * 216.0f) > 20.0f) || + ((player->effects & UNKNOWN_EFFECT_0x10000) == UNKNOWN_EFFECT_0x10000)) { if ((player->tyres[BACK_LEFT].surfaceType == ASPHALT) || (player->tyres[BACK_RIGHT].surfaceType == ASPHALT) || (player->tyres[FRONT_RIGHT].surfaceType == ASPHALT) || @@ -162,7 +167,7 @@ void func_8003E9EC(Player* player, Vec3f arg1, Vec3f arg2, Vec3f arg3, f32* arg4 arg3[0] = 0.0f; arg3[2] = (-(player->slopeAccel / 182) * 0x32); } - if ((player->effects & 0x10000) != 0) { + if ((player->effects & UNKNOWN_EFFECT_0x10000) != 0) { arg3[0] = ((player->unk_206 / 182) * 0x78); arg3[2] = (-(player->slopeAccel / 182) * 0xB4); } @@ -179,9 +184,10 @@ void func_8003EE2C(Player* player, Vec3f arg1, Vec3f arg2, Vec3f arg3, f32* arg4 if (player->collision.orientationVector[1] <= 0.8357f) { arg3[0] = ((player->unk_206 / 182) * 0x78); arg3[2] = (-(player->slopeAccel / 182) * 0xB4); - decelerate_ai_player(player, 4.0f); + decelerate_player(player, 4.0f); func_8003DC40(player); - } else if ((((player->unk_094 / 18.0f) * 216.0f) > 20.0f) || ((player->effects & 0x10000) == 0x10000)) { + } else if ((((player->speed / 18.0f) * 216.0f) > 20.0f) || + ((player->effects & UNKNOWN_EFFECT_0x10000) == UNKNOWN_EFFECT_0x10000)) { arg3[0] = ((player->unk_206 / 182) * 0x32); arg3[2] = (-(player->slopeAccel / 182) * 0x3C); } else { @@ -203,10 +209,11 @@ void func_8003F138(Player* player, Vec3f arg1, Vec3f arg2, Vec3f arg3, f32* arg4 if (player->collision.orientationVector[1] <= 0.8357f) { arg3[0] = ((player->unk_206 / 182) * 0xC8); arg3[2] = (-(player->slopeAccel / 182) * 0xC8); - decelerate_ai_player(player, 4.0f); + decelerate_player(player, 4.0f); player->unk_DAC = 0.5f; arg3[0] = 0; - } else if ((((player->unk_094 / 18.0f) * 216.0f) > 20.0f) || ((player->effects & 0x10000) == 0x10000)) { + } else if ((((player->speed / 18.0f) * 216.0f) > 20.0f) || + ((player->effects & UNKNOWN_EFFECT_0x10000) == UNKNOWN_EFFECT_0x10000)) { arg3[0] = ((player->unk_206 / 182) * 0x78); arg3[2] = (-(player->slopeAccel / 182) * 0x78); arg3[0] = 0; @@ -261,7 +268,7 @@ void func_8003F46C(Player* player, Vec3f arg1, Vec3f arg2, Vec3f arg3, f32* arg4 #else #endif - if (player->effects & 0x10000) { + if (player->effects & UNKNOWN_EFFECT_0x10000) { player->unk_DAC = 0.5f; } } @@ -279,7 +286,7 @@ void func_8003F734(Player* player, Vec3f arg1, Vec3f arg2, f32* arg3, f32* arg4, *arg4 += arg1[0] * player->collision.surfaceDistance[0] * 1; *arg5 += arg1[1] * player->collision.surfaceDistance[0] * 0.1; *arg6 += arg1[2] * player->collision.surfaceDistance[0] * 1; - if ((player->slopeAccel < 0) && (((player->unk_094 / 18.0f) * 216.0f) < 10.0f)) { + if ((player->slopeAccel < 0) && (((player->speed / 18.0f) * 216.0f) < 10.0f)) { func_8002A5F4(arg1, *arg3, arg2, 2.5f, 0); } else { func_8002A5F4(arg1, *arg3, arg2, 0.5f, 0); @@ -289,7 +296,7 @@ void func_8003F734(Player* player, Vec3f arg1, Vec3f arg2, f32* arg3, f32* arg4, *arg5 += arg1[1] * player->collision.surfaceDistance[0] * 0.1; *arg6 += arg1[2] * player->collision.surfaceDistance[0] * 1; func_8002A5F4(arg1, *arg3, arg2, 1, 0); - if ((!(player->effects & 0x10000)) && ((player->effects & 8) == 0)) { + if ((!(player->effects & UNKNOWN_EFFECT_0x10000)) && ((player->effects & 8) == 0)) { arg2[1] *= -1e-05; } } else { @@ -302,7 +309,7 @@ void func_8003F734(Player* player, Vec3f arg1, Vec3f arg2, f32* arg3, f32* arg4, } *arg6 += arg1[2] * player->collision.surfaceDistance[0] * 1; func_8002A5F4(arg1, *arg3, arg2, 1.2f, 0); - if ((!(player->effects & 0x10000)) && ((player->effects & 8) == 0)) { + if ((!(player->effects & UNKNOWN_EFFECT_0x10000)) && ((player->effects & 8) == 0)) { arg2[1] *= -1e-05; } } @@ -333,7 +340,7 @@ void func_8003FBAC(Player* player, Vec3f arg1, Vec3f arg2, f32* arg3, f32* arg4, *arg4 += arg1[0] * player->collision.surfaceDistance[1] * 1; *arg5 += arg1[1] * player->collision.surfaceDistance[1] * 0.1; *arg6 += arg1[2] * player->collision.surfaceDistance[1] * 1; - if ((player->slopeAccel < 0) && (((player->unk_094 / 18.0f) * 216.0f) < 10.0f)) { + if ((player->slopeAccel < 0) && (((player->speed / 18.0f) * 216.0f) < 10.0f)) { func_8002A5F4(arg1, *arg3, arg2, 1.5f, 0); } else { func_8002A5F4(arg1, *arg3, arg2, 0.5f, 0); @@ -343,7 +350,7 @@ void func_8003FBAC(Player* player, Vec3f arg1, Vec3f arg2, f32* arg3, f32* arg4, *arg5 += arg1[1] * player->collision.surfaceDistance[1] * 0.1; *arg6 += arg1[2] * player->collision.surfaceDistance[1] * 1; func_8002A5F4(arg1, *arg3, arg2, 1, 0); - if ((!(player->effects & 0x10000)) && ((player->effects & 8) == 0)) { + if ((!(player->effects & UNKNOWN_EFFECT_0x10000)) && ((player->effects & 8) == 0)) { arg2[1] *= -1e-05; } } else { @@ -356,7 +363,7 @@ void func_8003FBAC(Player* player, Vec3f arg1, Vec3f arg2, f32* arg3, f32* arg4, } *arg6 += arg1[2] * player->collision.surfaceDistance[1] * 1; func_8002A5F4(arg1, *arg3, arg2, 1.2f, 0); - if ((!(player->effects & 0x10000)) && ((player->effects & 8) == 0)) { + if ((!(player->effects & UNKNOWN_EFFECT_0x10000)) && ((player->effects & 8) == 0)) { arg2[1] *= -1e-05; } } diff --git a/src/code_80057C60.c b/src/code_80057C60.c index 4a0134e081..58e7cf20bb 100644 --- a/src/code_80057C60.c +++ b/src/code_80057C60.c @@ -18,7 +18,7 @@ #include #include "math_util.h" #include "math_util_2.h" -#include "code_80005FD0.h" +#include "cpu_vehicles_camera_path.h" #include "render_player.h" #include "render_objects.h" #include "code_8006E9C0.h" @@ -785,7 +785,7 @@ void render_object_for_player(s32 cameraId) { render_object_leaf_particle(cameraId); if (D_80165730 != 0) { - func_80053E6C(cameraId); + render_object_grand_prix_balloons(cameraId); } if (gModeSelection == BATTLE) { render_object_bomb_kart(cameraId); @@ -1321,7 +1321,7 @@ void func_80059D00(void) { } course_update_clouds(0); if (playerHUD[PLAYER_ONE].raceCompleteBool == 0) { - func_8005C360((gPlayerOneCopy->unk_094 / 18.0f) * 216.0f); + func_8005C360((gPlayerOneCopy->speed / 18.0f) * 216.0f); } func_8005D0FC(PLAYER_ONE); } else { @@ -2718,22 +2718,22 @@ void func_8005D18C(void) { } void func_8005D1F4(s32 arg0) { - s32 playerWaypoint; - s32 bombWaypoint; + s32 playerPathPoint; + s32 bombPathPoint; s32 var_a2; - s32 waypointDiff; + s32 pathPointDiff; if (gModeSelection == 2) { - playerWaypoint = gNearestWaypointByPlayerId[arg0]; + playerPathPoint = gNearestPathPointByPlayerId[arg0]; playerHUD[arg0].unk_74 = 0; for (var_a2 = 0; var_a2 < NUM_BOMB_KARTS_VERSUS; var_a2++) { if ((gBombKarts[var_a2].state == BOMB_STATE_EXPLODED) || (gBombKarts[var_a2].state == BOMB_STATE_INACTIVE)) { continue; } - bombWaypoint = gBombKarts[var_a2].waypointIndex; - waypointDiff = bombWaypoint - playerWaypoint; - if ((waypointDiff < -5) || (waypointDiff > 0x1E)) { + bombPathPoint = gBombKarts[var_a2].pathPointIndex; + pathPointDiff = bombPathPoint - playerPathPoint; + if ((pathPointDiff < -5) || (pathPointDiff > 0x1E)) { continue; } playerHUD[arg0].unk_74 = 1; @@ -2930,7 +2930,7 @@ void func_8005DAF4(Player* player, s16 arg1, s32 arg2, UNUSED s8 arg3, UNUSED s8 case DIRT: if ((arg1 == 0) && ((player->unk_258[10 + arg2].unk_01E > 0) || (player->unk_258[10 + arg2].unk_01C == 0))) { - if (((player->unk_094 / 18.0f) * 216.0f) >= 10.0f) { + if (((player->speed / 18.0f) * 216.0f) >= 10.0f) { func_8005D794(player, &player->unk_258[10 + arg1], var_f2, var_f12, var_f14, (s8) surfaceType, (s8) var_t3); func_8005D7D8(&player->unk_258[10 + arg1], 2, 0.46f); @@ -2954,7 +2954,7 @@ void func_8005DAF4(Player* player, s16 arg1, s32 arg2, UNUSED s8 arg3, UNUSED s8 } player->unk_258[10 + arg1].unk_03A = random_int(0x0010U); } - } else if ((player->unk_258[10 + arg2].unk_01E > 0) && (((player->unk_094 / 18.0f) * 216.0f) >= 10.0f)) { + } else if ((player->unk_258[10 + arg2].unk_01E > 0) && (((player->speed / 18.0f) * 216.0f) >= 10.0f)) { func_8005D794(player, &player->unk_258[10 + arg1], var_f2, var_f12, var_f14, (s8) surfaceType, (s8) var_t3); func_8005D7D8(&player->unk_258[10 + arg1], 2, 0.46f); @@ -2982,7 +2982,7 @@ void func_8005DAF4(Player* player, s16 arg1, s32 arg2, UNUSED s8 arg3, UNUSED s8 case GRASS: if ((arg1 == 0) && ((player->unk_258[10 + arg2].unk_01E > 0) || (player->unk_258[10 + arg2].unk_01C == 0))) { - if (((player->unk_094 / 18.0f) * 216.0f) >= 10.0f) { + if (((player->speed / 18.0f) * 216.0f) >= 10.0f) { func_8005D794(player, &player->unk_258[10 + arg1], var_f2, var_f12, var_f14, (s8) surfaceType, (s8) var_t3); func_8005D7D8(&player->unk_258[10 + arg1], 3, 1.0f); @@ -2991,7 +2991,7 @@ void func_8005DAF4(Player* player, s16 arg1, s32 arg2, UNUSED s8 arg3, UNUSED s8 player->unk_258[10 + arg1].unk_03A -= arg1 * 8; player->unk_258[10 + arg1].unk_03C -= arg1 * 8; } - } else if ((player->unk_258[10 + arg2].unk_01E > 0) && (((player->unk_094 / 18.0f) * 216.0f) >= 10.0f)) { + } else if ((player->unk_258[10 + arg2].unk_01E > 0) && (((player->speed / 18.0f) * 216.0f) >= 10.0f)) { func_8005D794(player, &player->unk_258[10 + arg1], var_f2, var_f12, var_f14, (s8) surfaceType, (s8) var_t3); func_8005D7D8(&player->unk_258[10 + arg1], 3, 1.0f); @@ -3005,14 +3005,14 @@ void func_8005DAF4(Player* player, s16 arg1, s32 arg2, UNUSED s8 arg3, UNUSED s8 case SAND_OFFROAD: if ((arg1 == 0) && ((player->unk_258[10 + arg2].unk_01E > 0) || (player->unk_258[10 + arg2].unk_01C == 0))) { - if (((player->unk_094 / 18.0f) * 216.0f) >= 10.0f) { + if (((player->speed / 18.0f) * 216.0f) >= 10.0f) { func_8005D794(player, &player->unk_258[10 + arg1], var_f2, var_f12, var_f14, (s8) surfaceType, (s8) var_t3); func_8005D7D8(&player->unk_258[10 + arg1], 2, 0.46f); func_8005DAD8(&player->unk_258[10 + arg1], 2, 1, 0x00A8); player->unk_258[10 + arg1].unk_03A = random_int(0x0010U); } - } else if ((player->unk_258[10 + arg2].unk_01E > 0) && (((player->unk_094 / 18.0f) * 216.0f) >= 10.0f)) { + } else if ((player->unk_258[10 + arg2].unk_01E > 0) && (((player->speed / 18.0f) * 216.0f) >= 10.0f)) { func_8005D794(player, &player->unk_258[10 + arg1], var_f2, var_f12, var_f14, (s8) surfaceType, (s8) var_t3); func_8005D7D8(&player->unk_258[10 + arg1], 2, 0.46f); @@ -3023,14 +3023,14 @@ void func_8005DAF4(Player* player, s16 arg1, s32 arg2, UNUSED s8 arg3, UNUSED s8 case SAND: if ((arg1 == 0) && ((player->unk_258[10 + arg2].unk_01E > 0) || (player->unk_258[10 + arg2].unk_01C == 0))) { - if (((player->unk_094 / 18.0f) * 216.0f) >= 10.0f) { + if (((player->speed / 18.0f) * 216.0f) >= 10.0f) { func_8005D794(player, &player->unk_258[10 + arg1], var_f2, var_f12, var_f14, (s8) surfaceType, (s8) var_t3); func_8005D7D8(&player->unk_258[10 + arg1], 2, 0.46f); func_8005DAD8(&player->unk_258[10 + arg1], 3, 1, 0x00A8); player->unk_258[10 + arg1].unk_03A = random_int(0x0010U); } - } else if ((player->unk_258[10 + arg2].unk_01E > 0) && (((player->unk_094 / 18.0f) * 216.0f) >= 10.0f)) { + } else if ((player->unk_258[10 + arg2].unk_01E > 0) && (((player->speed / 18.0f) * 216.0f) >= 10.0f)) { func_8005D794(player, &player->unk_258[10 + arg1], var_f2, var_f12, var_f14, (s8) surfaceType, (s8) var_t3); func_8005D7D8(&player->unk_258[10 + arg1], 2, 0.46f); @@ -3041,14 +3041,14 @@ void func_8005DAF4(Player* player, s16 arg1, s32 arg2, UNUSED s8 arg3, UNUSED s8 case WET_SAND: if ((arg1 == 0) && ((player->unk_258[10 + arg2].unk_01E > 0) || (player->unk_258[10 + arg2].unk_01C == 0))) { - if (((player->unk_094 / 18.0f) * 216.0f) >= 10.0f) { + if (((player->speed / 18.0f) * 216.0f) >= 10.0f) { func_8005D794(player, &player->unk_258[10 + arg1], var_f2, var_f12, var_f14, (s8) surfaceType, (s8) var_t3); func_8005D7D8(&player->unk_258[10 + arg1], 2, 0.46f); func_8005DAD8(&player->unk_258[10 + arg1], 4, 1, 0x00A8); player->unk_258[10 + arg1].unk_03A = random_int(0x0010U); } - } else if ((player->unk_258[10 + arg2].unk_01E > 0) && (((player->unk_094 / 18.0f) * 216.0f) >= 10.0f)) { + } else if ((player->unk_258[10 + arg2].unk_01E > 0) && (((player->speed / 18.0f) * 216.0f) >= 10.0f)) { func_8005D794(player, &player->unk_258[10 + arg1], var_f2, var_f12, var_f14, (s8) surfaceType, (s8) var_t3); func_8005D7D8(&player->unk_258[10 + arg1], 2, 0.46f); @@ -3059,14 +3059,14 @@ void func_8005DAF4(Player* player, s16 arg1, s32 arg2, UNUSED s8 arg3, UNUSED s8 case DIRT_OFFROAD: if ((arg1 == 0) && ((player->unk_258[10 + arg2].unk_01E > 0) || (player->unk_258[10 + arg2].unk_01C == 0))) { - if (((player->unk_094 / 18.0f) * 216.0f) >= 10.0f) { + if (((player->speed / 18.0f) * 216.0f) >= 10.0f) { func_8005D794(player, &player->unk_258[10 + arg1], var_f2, var_f12, var_f14, (s8) surfaceType, (s8) var_t3); func_8005D7D8(&player->unk_258[10 + arg1], 2, 0.46f); func_8005DAD8(&player->unk_258[10 + arg1], 5, 1, 0x00A8); player->unk_258[10 + arg1].unk_03A = random_int(0x0010U); } - } else if ((player->unk_258[10 + arg2].unk_01E > 0) && (((player->unk_094 / 18.0f) * 216.0f) >= 10.0f)) { + } else if ((player->unk_258[10 + arg2].unk_01E > 0) && (((player->speed / 18.0f) * 216.0f) >= 10.0f)) { func_8005D794(player, &player->unk_258[10 + arg1], var_f2, var_f12, var_f14, (s8) surfaceType, (s8) var_t3); func_8005D7D8(&player->unk_258[10 + arg1], 2, 0.46f); @@ -3079,14 +3079,14 @@ void func_8005DAF4(Player* player, s16 arg1, s32 arg2, UNUSED s8 arg3, UNUSED s8 case SNOW_OFFROAD: if ((arg1 == 0) && ((player->unk_258[10 + arg2].unk_01E > 0) || (player->unk_258[10 + arg2].unk_01C == 0))) { - if (((player->unk_094 / 18.0f) * 216.0f) >= 10.0f) { + if (((player->speed / 18.0f) * 216.0f) >= 10.0f) { func_8005D794(player, &player->unk_258[10 + arg1], var_f2, var_f12, var_f14, (s8) surfaceType, (s8) var_t3); func_8005D7D8(&player->unk_258[10 + arg1], 2, 0.46f); func_8005DAD8(&player->unk_258[10 + arg1], 6, 1, 0x00A8); player->unk_258[10 + arg1].unk_03A = random_int(0x0010U); } - } else if ((player->unk_258[10 + arg2].unk_01E > 0) && (((player->unk_094 / 18.0f) * 216.0f) >= 10.0f)) { + } else if ((player->unk_258[10 + arg2].unk_01E > 0) && (((player->speed / 18.0f) * 216.0f) >= 10.0f)) { func_8005D794(player, &player->unk_258[10 + arg1], var_f2, var_f12, var_f14, (s8) surfaceType, (s8) var_t3); func_8005D7D8(&player->unk_258[10 + arg1], 2, 0.46f); @@ -3099,9 +3099,9 @@ void func_8005DAF4(Player* player, s16 arg1, s32 arg2, UNUSED s8 arg3, UNUSED s8 case BRIDGE: if ((arg1 == 0) && ((player->unk_258[10 + arg2].unk_01E > 0) || (player->unk_258[10 + arg2].unk_01C == 0))) { - if (((((player->unk_094 / 18.0f) * 216.0f) >= 30.0f) && + if (((((player->speed / 18.0f) * 216.0f) >= 30.0f) && ((((player->unk_0C0 / 182) > 0x14) || ((player->unk_0C0 / 182) < (-0x14))))) || - ((player->unk_22C - player->unk_094) >= 0.04)) { + ((player->previousSpeed - player->speed) >= 0.04)) { func_8005D794(player, &player->unk_258[10 + arg1], var_f2, var_f12, var_f14, (s8) surfaceType, (s8) var_t3); func_8005D7D8(&player->unk_258[10 + arg1], 2, 0.46f); @@ -3109,9 +3109,9 @@ void func_8005DAF4(Player* player, s16 arg1, s32 arg2, UNUSED s8 arg3, UNUSED s8 player->unk_258[10 + arg1].unk_03A = random_int(0x0010U); } } else if ((player->unk_258[10 + arg2].unk_01E > 0) && - (((((player->unk_094 / 18.0f) * 216.0f) >= 30.0f) && + (((((player->speed / 18.0f) * 216.0f) >= 30.0f) && (((player->unk_0C0 / 182) >= 0x15) || ((player->unk_0C0 / 182) < -0x14))) || - ((player->unk_22C - player->unk_094) >= 0.04))) { + ((player->previousSpeed - player->speed) >= 0.04))) { func_8005D794(player, &player->unk_258[10 + arg1], var_f2, var_f12, var_f14, (s8) surfaceType, (s8) var_t3); func_8005D7D8(&player->unk_258[10 + arg1], 2, 0.46f); @@ -3156,12 +3156,12 @@ void func_8005EA94(Player* player, s16 arg1, s32 arg2, s8 arg3, UNUSED s8 arg4) if (1) {} if (var_t0 == 0) { if ((arg1 == 0) && ((player->unk_258[10 + arg2].unk_01E > 0) || (player->unk_258[10 + arg2].unk_01C == 0))) { - if (((player->unk_094 / 18.0f) * 216.0f) >= 10.0f) { + if (((player->speed / 18.0f) * 216.0f) >= 10.0f) { func_8005D794(player, &player->unk_258[10 + arg1], var_f2, var_f12, var_f14, var_t0, var_t1); func_8005D7D8(&player->unk_258[10 + arg1], 9, 0.8f); func_8005D800(&player->unk_258[10 + arg1], 0x00FFFFFF, 0x00AF); } - } else if ((player->unk_258[10 + arg2].unk_01E > 0) && (((player->unk_094 / 18.0f) * 216.0f) >= 10.0f)) { + } else if ((player->unk_258[10 + arg2].unk_01E > 0) && (((player->speed / 18.0f) * 216.0f) >= 10.0f)) { func_8005D794(player, &player->unk_258[10 + arg1], var_f2, var_f12, var_f14, var_t0, var_t1); func_8005D7D8(&player->unk_258[10 + arg1], 9, 0.8f); func_8005D800(&player->unk_258[10 + arg1], 0x00FFFFFF, 0x00AF); @@ -3647,7 +3647,7 @@ void func_800608E0(Player* player, s16 arg1, UNUSED s32 arg2, s8 arg3, UNUSED s8 func_8005D800(&player->unk_258[arg1], 0x00FFFFFF, 0x00CF); } func_80062B18(&sp50, &sp4C, &sp48, 0.0f, sp4C, - ((-player->unk_258[arg1].unk_01E * (player->unk_094 / 18.0f) * 216.0f) / 10.0f) + -4.0f, + ((-player->unk_258[arg1].unk_01E * (player->speed / 18.0f) * 216.0f) / 10.0f) + -4.0f, -player->unk_258[arg1].unk_020, -player->unk_206 * 2); player->unk_258[arg1].unk_000[0] = player->pos[0] + sp50; player->unk_258[arg1].unk_000[2] = player->pos[2] + sp48; @@ -3832,8 +3832,8 @@ void func_80061754(Player* player, s16 arg1, UNUSED s32 arg2, UNUSED s32 arg3, U sp48 = random_int(2U); func_8005D794(player, &player->unk_258[0x1E + arg1], 0.0f, 0.0f, 0.0f, (s8) 0, (s8) 0); func_8005D7D8(&player->unk_258[0x1E + arg1], 6, 1.0f); - if ((player->effects & HIT_BY_ITEM_EFFECT) || ((player->effects) & 0x01000000) || ((player->effects) & 0x400) || - ((player->effects) & BOO_EFFECT)) { + if ((player->effects & HIT_BY_ITEM_EFFECT) || ((player->effects) & UNKNOWN_EFFECT_0x1000000) || + ((player->effects) & 0x400) || ((player->effects) & BOO_EFFECT)) { func_8005D800(&player->unk_258[0x1E + arg1], 0x00FFFFFF, 0x00A0); player->unk_258[0x1E + arg1].unk_038 -= temp_s1; player->unk_258[0x1E + arg1].unk_03A -= temp_s1; @@ -4419,34 +4419,34 @@ void func_800635D4(Player* player, s16 arg1, UNUSED s8 arg2, UNUSED s8 arg3) { if (player->unk_258[10 + arg1].unk_010 == 1) { if ((player->effects & LIGHTNING_EFFECT)) { func_80062B18(&sp44, &sp40, &sp3C, -2.0f, 0.0f, - (-player->unk_258[10 + arg1].unk_01E * (player->unk_094 / 18.0f) * 216.0f) / 16, + (-player->unk_258[10 + arg1].unk_01E * (player->speed / 18.0f) * 216.0f) / 16, -player->unk_258[10 + arg1].unk_020, 2 * -player->unk_206); player->unk_258[10 + arg1].unk_000[0] = player->tyres[BACK_LEFT].pos[0] + sp44; player->unk_258[10 + arg1].unk_000[2] = player->tyres[BACK_LEFT].pos[2] + sp3C; } else { player->unk_258[10 + arg1].unk_000[2] = player->tyres[BACK_LEFT].pos[2] + - ((-player->unk_258[10 + arg1].unk_01E * (player->unk_094 / 18.0f) * 216.0f) / 16) * + ((-player->unk_258[10 + arg1].unk_01E * (player->speed / 18.0f) * 216.0f) / 16) * coss(player->unk_258[10 + arg1].unk_020); player->unk_258[10 + arg1].unk_000[0] = player->tyres[BACK_LEFT].pos[0] + - ((-player->unk_258[10 + arg1].unk_01E * (player->unk_094 / 18.0f) * 216.0f) / 16) * + ((-player->unk_258[10 + arg1].unk_01E * (player->speed / 18.0f) * 216.0f) / 16) * sins(player->unk_258[10 + arg1].unk_020); } } else if ((player->effects & LIGHTNING_EFFECT)) { func_80062B18(&sp44, &sp40, &sp3C, 2.0f, 0.0f, - (-player->unk_258[10 + arg1].unk_01E * (player->unk_094 / 18.0f) * 216.0f) / 16, + (-player->unk_258[10 + arg1].unk_01E * (player->speed / 18.0f) * 216.0f) / 16, -player->unk_258[10 + arg1].unk_020, 2 * -player->unk_206); player->unk_258[10 + arg1].unk_000[0] = player->tyres[BACK_RIGHT].pos[0] + sp44; player->unk_258[10 + arg1].unk_000[2] = player->tyres[BACK_RIGHT].pos[2] + sp3C; } else { player->unk_258[10 + arg1].unk_000[2] = player->tyres[BACK_RIGHT].pos[2] + - ((-player->unk_258[10 + arg1].unk_01E * (player->unk_094 / 18.0f) * 216.0f) / 16) * + ((-player->unk_258[10 + arg1].unk_01E * (player->speed / 18.0f) * 216.0f) / 16) * coss(player->unk_258[10 + arg1].unk_020); player->unk_258[10 + arg1].unk_000[0] = player->tyres[BACK_RIGHT].pos[0] + - ((-player->unk_258[10 + arg1].unk_01E * (player->unk_094 / 18.0f) * 216.0f) / 16) * + ((-player->unk_258[10 + arg1].unk_01E * (player->speed / 18.0f) * 216.0f) / 16) * sins(player->unk_258[10 + arg1].unk_020); } @@ -4557,20 +4557,20 @@ void func_80063D58(Player* player, s16 arg1, UNUSED s8 arg2, UNUSED s8 arg3) { if (player->unk_258[10 + arg1].unk_010 == 1) { player->unk_258[10 + arg1].unk_000[2] = player->tyres[BACK_LEFT].pos[2] + - ((-player->unk_258[10 + arg1].unk_01E * (player->unk_094 / 18.0f) * 216.0f) / 20.0f) * + ((-player->unk_258[10 + arg1].unk_01E * (player->speed / 18.0f) * 216.0f) / 20.0f) * coss(player->unk_258[10 + arg1].unk_020); player->unk_258[10 + arg1].unk_000[0] = player->tyres[BACK_LEFT].pos[0] + - ((-player->unk_258[10 + arg1].unk_01E * (player->unk_094 / 18.0f) * 216.0f) / 20.0f) * + ((-player->unk_258[10 + arg1].unk_01E * (player->speed / 18.0f) * 216.0f) / 20.0f) * sins(player->unk_258[10 + arg1].unk_020); } else { player->unk_258[10 + arg1].unk_000[2] = player->tyres[BACK_RIGHT].pos[2] + - ((-player->unk_258[10 + arg1].unk_01E * (player->unk_094 / 18.0f) * 216.0f) / 20.0f) * + ((-player->unk_258[10 + arg1].unk_01E * (player->speed / 18.0f) * 216.0f) / 20.0f) * coss(player->unk_258[10 + arg1].unk_020); player->unk_258[10 + arg1].unk_000[0] = player->tyres[BACK_RIGHT].pos[0] + - ((-player->unk_258[10 + arg1].unk_01E * (player->unk_094 / 18.0f) * 216.0f) / 20.0f) * + ((-player->unk_258[10 + arg1].unk_01E * (player->speed / 18.0f) * 216.0f) / 20.0f) * sins(player->unk_258[10 + arg1].unk_020); } @@ -4601,11 +4601,11 @@ void func_80063FBC(Player* player, s16 arg1, UNUSED s32 arg2, UNUSED s32 arg3) { if (player->unk_258[10 + arg1].unk_010 == 1) { func_80062B18(&sp3C, &sp34, &sp38, 3.0f, 0.0f, - -5.5 - (player->unk_258[10 + arg1].unk_01E * (((player->unk_094 / 18.0f) * 216.0f) / 15.0f)), + -5.5 - (player->unk_258[10 + arg1].unk_01E * (((player->speed / 18.0f) * 216.0f) / 15.0f)), -player->unk_258[10 + arg1].unk_020, 0); } else { func_80062B18(&sp3C, &sp34, &sp38, -3.0f, 0.0f, - -5.5 - (player->unk_258[10 + arg1].unk_01E * (((player->unk_094 / 18.0f) * 216.0f) / 15.0f)), + -5.5 - (player->unk_258[10 + arg1].unk_01E * (((player->speed / 18.0f) * 216.0f) / 15.0f)), -player->unk_258[10 + arg1].unk_020, 0); } player->unk_258[10 + arg1].unk_000[0] = player->pos[0] + sp3C; @@ -4630,7 +4630,7 @@ void func_80064184(Player* player, s16 arg1, s8 arg2, UNUSED s8 arg3) { } func_80062B18(&sp44, &sp40, &sp3C, 0.0f, sp40, - -4.0f + ((-player->unk_258[arg1].unk_01E * (player->unk_094 / 18.0f) * 216.0f) / 10.0f), + -4.0f + ((-player->unk_258[arg1].unk_01E * (player->speed / 18.0f) * 216.0f) / 10.0f), -player->unk_258[arg1].unk_020, 2 * -player->unk_206); player->unk_258[arg1].unk_000[0] = player->pos[0] + sp44; player->unk_258[arg1].unk_000[2] = player->pos[2] + sp3C; @@ -5896,9 +5896,9 @@ void func_8006A7C0(Player* player, f32 arg1, f32 arg2, s8 arg3, s8 arg4) { UNUSED s32 stackPadding1; UNUSED s32 stackPadding2; - sp6C = (-(player->unk_094 / 18.0f) * 216.0f) / 10.0f; + sp6C = (-(player->speed / 18.0f) * 216.0f) / 10.0f; if ((gPlayerBalloonStatus[arg3][arg4] & 2) != 2) { - D_8018D650[arg3][arg4] += -0.003 + (-player->unk_094 * 0.0006); + D_8018D650[arg3][arg4] += -0.003 + (-player->speed * 0.0006); if (D_8018D650[arg3][arg4] >= 0.05) { D_8018D650[arg3][arg4] = 0.05f; } @@ -5919,12 +5919,12 @@ void func_8006A7C0(Player* player, f32 arg1, f32 arg2, s8 arg3, s8 arg4) { D_8018D710[arg3][arg4] = 0.0f; } D_8018D620[arg3][arg4] = -player->rotation[1] - player->unk_0C0; - move_s16_towards(&D_8018D890[arg3][arg4], player->unk_094 * 182.0f, 0.1f); + move_s16_towards(&D_8018D890[arg3][arg4], player->speed * 182.0f, 0.1f); } if (D_8018D830[arg3][arg4] == 1) { - D_8018D770[arg3][arg4] += D_8018D800[arg3][arg4] - player->unk_094; + D_8018D770[arg3][arg4] += D_8018D800[arg3][arg4] - player->speed; } else { - D_8018D770[arg3][arg4] += D_8018D800[arg3][arg4] + player->unk_094; + D_8018D770[arg3][arg4] += D_8018D800[arg3][arg4] + player->speed; } if (D_8018D770[arg3][arg4] >= 0xB) { D_8018D770[arg3][arg4] = 0x000B; @@ -6296,7 +6296,8 @@ void func_8006C6AC(Player* player, s16 arg1, s8 arg2, s8 arg3) { if (player->unk_0DE & 1) { func_80060BCC(player, arg1, sp28, arg2_copy, arg3); } else if (!(player->effects & 8) && !(player->effects & 2)) { - if (((player->effects & 0x10) == 0x10) && ((player->type & PLAYER_HUMAN) == PLAYER_HUMAN)) { + if (((player->effects & UNKNOWN_EFFECT_0x10) == UNKNOWN_EFFECT_0x10) && + ((player->type & PLAYER_HUMAN) == PLAYER_HUMAN)) { func_8005DA30(player, arg1, sp28, arg2_copy, arg3); } else if (((f64) (D_801652A0[arg2_copy] - player->tyres[BACK_RIGHT].baseHeight) >= 3.5) || ((f64) (D_801652A0[arg2_copy] - player->tyres[BACK_LEFT].baseHeight) >= 3.5)) { @@ -6367,7 +6368,8 @@ void func_8006C9B8(Player* player, s16 arg1, s8 arg2, s8 arg3) { player->unk_044 &= ~0x0100; return; } - if (((((player->unk_0CA & 0x1000) == 0x1000) || ((player->unk_0E0 < 2) && (player->effects & 0x01000000))) || + if (((((player->unk_0CA & 0x1000) == 0x1000) || + ((player->unk_0E0 < 2) && (player->effects & UNKNOWN_EFFECT_0x1000000))) || ((player->unk_0E0 < 2) && (player->effects & HIT_BY_ITEM_EFFECT))) || (player->effects & 0x400)) { func_8006199C(player, arg1, sp28, arg2, arg3); @@ -6392,7 +6394,7 @@ void func_8006C9B8(Player* player, s16 arg1, s8 arg2, s8 arg3) { player->unk_044 &= ~0x0100; return; } - if (((player->unk_046 & 0x20) == 0x20) && (((player->unk_094 / 18.0f) * 216.0f) >= 20.0f)) { + if (((player->unk_046 & 0x20) == 0x20) && (((player->speed / 18.0f) * 216.0f) >= 20.0f)) { func_80061D4C(player, arg1, sp28, arg2, arg3); player->unk_046 &= ~0x0008; player->unk_044 &= ~0x0100; @@ -6459,7 +6461,7 @@ void func_8006CEC0(Player* arg0, s16 arg1, s8 arg2, s8 arg3) { switch (gActiveScreenMode) { case SCREEN_MODE_1P: if (((arg0->effects & 0x04000000) != 0x04000000) && ((arg0->effects & 0x400) != 0x400) && - ((arg0->effects & 0x01000000) != 0x01000000)) { + ((arg0->effects & UNKNOWN_EFFECT_0x1000000) != UNKNOWN_EFFECT_0x1000000)) { if (((arg0->unk_0CA & 2) != 2) && ((arg0->unk_0CA & 0x10) != 0x10) && !(arg0->unk_0CA & 0x100)) { func_80060504(arg0, arg1, sp20, arg2, arg3); } @@ -6471,7 +6473,8 @@ void func_8006CEC0(Player* arg0, s16 arg1, s8 arg2, s8 arg3) { case SCREEN_MODE_2P_SPLITSCREEN_VERTICAL: case SCREEN_MODE_3P_4P_SPLITSCREEN: if (((arg0->type & 0x4000) != 0) && ((arg0->effects & 0x04000000) != 0x04000000) && - ((arg0->effects & 0x400) != 0x400) && ((arg0->effects & 0x01000000) != 0x01000000)) { + ((arg0->effects & 0x400) != 0x400) && + ((arg0->effects & UNKNOWN_EFFECT_0x1000000) != UNKNOWN_EFFECT_0x1000000)) { if (((arg0->unk_0CA & 2) != 2) && ((arg0->unk_0CA & 0x10) != 0x10) && !(arg0->unk_0CA & 0x100)) { func_80060504(arg0, arg1, sp20, arg2, arg3); } @@ -6787,7 +6790,7 @@ void func_8006E058(void) { case TIME_TRIALS: func_8006E420(gPlayerOne, 0, 0); - if ((gPlayerTwo->type & 0x8000) == 0x8000) { + if ((gPlayerTwo->type & PLAYER_EXISTS) == PLAYER_EXISTS) { func_8006E420(gPlayerTwo, 1, 0); break; } diff --git a/src/code_8006E9C0.c b/src/code_8006E9C0.c index 54603dd0cc..584c76a81c 100644 --- a/src/code_8006E9C0.c +++ b/src/code_8006E9C0.c @@ -5,7 +5,7 @@ #include #include "code_800029B0.h" -#include "code_80005FD0.h" +#include "cpu_vehicles_camera_path.h" #include "code_80057C60.h" #include "code_8006E9C0.h" #include "code_80086E70.h" diff --git a/src/code_80086E70.c b/src/code_80086E70.c index f19f1a8163..263ab09640 100644 --- a/src/code_80086E70.c +++ b/src/code_80086E70.c @@ -1070,8 +1070,7 @@ void func_80089474(s32 objectIndex, s32 playerId, f32 arg2, f32 arg3, u32 soundB if (is_obj_flag_status_active(objectIndex, 0x04000000) != 0) { func_80072180(); } - if ((func_8008933C(player, objectIndex, arg2, arg3) >= 4.0) && - ((player->type & PLAYER_KART_AI) != PLAYER_KART_AI)) { + if ((func_8008933C(player, objectIndex, arg2, arg3) >= 4.0) && ((player->type & PLAYER_CPU) != PLAYER_CPU)) { func_800C9060(playerId, soundBits); } } @@ -1081,8 +1080,7 @@ void func_80089538(s32 objectIndex, s32 playerId, f32 arg2, f32 arg3, u32 soundB Player* player; player = &gPlayerOne[playerId]; - if ((func_8008933C(player, objectIndex, arg2, arg3) >= 4.0) && - ((player->type & PLAYER_KART_AI) != PLAYER_KART_AI)) { + if ((func_8008933C(player, objectIndex, arg2, arg3) >= 4.0) && ((player->type & PLAYER_CPU) != PLAYER_CPU)) { func_800C9060((u8) playerId, soundBits); } } @@ -1144,7 +1142,7 @@ void func_80089820(s32 objectIndex, f32 arg1, f32 arg2, u32 arg3) { func_80072180(); } if ((func_8008933C(player, objectIndex, arg1, arg2 * 1.1) >= 4.0) && - ((player->type & PLAYER_KART_AI) != PLAYER_KART_AI)) { + ((player->type & PLAYER_CPU) != PLAYER_CPU)) { func_800C9060(var_s1, arg3); } } @@ -1183,7 +1181,7 @@ s32 func_80089B50(s32 objectIndex) { player = gPlayerOne; if (is_obj_flag_status_active(objectIndex, 0x00000200) != 0) { for (var_s1 = 0; var_s1 < D_8018D158; var_s1++, player++, test++) { - if ((gObjectList[objectIndex].state != 0) && !(player->effects & 0x81000000) && + if ((gObjectList[objectIndex].state != 0) && !(player->effects & (BOO_EFFECT | UNKNOWN_EFFECT_0x1000000)) && (player->type & PLAYER_EXISTS) && !(player->type & PLAYER_INVISIBLE_OR_BOMB) && (has_collided_horizontally_with_player(objectIndex, player) != 0)) { if (!(player->effects & STAR_EFFECT)) { @@ -1210,7 +1208,7 @@ s32 func_80089CBC(s32 objectIndex, f32 arg1) { player = gPlayerOne; if (is_obj_flag_status_active(objectIndex, 0x00000200) != 0) { for (var_s1 = 0; var_s1 < D_8018D158; var_s1++, player++) { - if ((gObjectList[objectIndex].state != 0) && !(player->effects & 0x81000000)) { + if ((gObjectList[objectIndex].state != 0) && !(player->effects & (BOO_EFFECT | UNKNOWN_EFFECT_0x1000000))) { if ((player->type & PLAYER_EXISTS) && !(player->type & PLAYER_INVISIBLE_OR_BOMB) && (has_collided_with_player_and_within_height(objectIndex, player, arg1) != 0)) { if (!(player->effects & STAR_EFFECT)) { diff --git a/src/cpu_vehicles_camera_path.c b/src/cpu_vehicles_camera_path.c new file mode 100644 index 0000000000..b6d46e0467 --- /dev/null +++ b/src/cpu_vehicles_camera_path.c @@ -0,0 +1,4565 @@ +#include +#include +#include + +#include "cpu_vehicles_camera_path.h" +#include "math_util.h" +#include "code_800029B0.h" +#include "racing/memory.h" +#include "path.h" +#include "camera.h" +#include "actors.h" +#include "actors_extended.h" +#include "render_player.h" +#include "player_controller.h" +#include "update_objects.h" +#include "collision.h" +#include +#include "vehicles.h" +#include "render_objects.h" +#include "code_80057C60.h" +#include "bomb_kart.h" +#include "courses/all_course_data.h" +#include +#include +#include "main.h" +#include "menus.h" +#include "menu_items.h" +#include "audio/external.h" +#include "ending/podium_ceremony_actors.h" +#include "spawn_players.h" +#include "sounds.h" +#include "data/path_spawn_metadata.h" +#include "math_util_2.h" + +s32 unk_cpu_vehicles_camera_path_pad[24]; +Collision D_80162E70; +s16 D_80162EB0; // Possibly a float. +s16 D_80162EB2; // possibly [3] + +CPUBehaviour* gCoursesCPUBehaviour[NUM_COURSES - 1]; + +// more padding? +s32 D_80162F08[2]; + +s16 D_80162F10[30]; +s16 D_80162F50[30]; + +// padding, seemingly? +s32 D_80162F90[4]; + +Vec3f gOffsetPosition; +Vec3f D_80162FB0; +Vec3f D_80162FC0; +s16 gTrainSmokeTimer; +s16 sSomeNearestPathPoint; +s16 D_80162FD0; +f32 gCourseCompletionPercentByRank[NUM_PLAYERS]; +/* +The size of many of these arrays is weird. Based on their usage, they would only need +to be 8 entries long (enough for each player). But some are 10 or even 12 long. +Its plausible that this is just some decompilation artifact? +Or maybe at some point in development they had plans for more players? +*/ +s16 D_80162FF8[12]; +s16 D_80163010[12]; +f32 cpu_TargetSpeed[10]; +s16 gPreviousAngleSteering[12]; +f32 gTrackPositionFactor[10]; +f32 D_80163090[10]; +bool gIsPlayerInCurve[10]; +u16 gCurrentNearestPathPoint; +s16 gIsPlayerNewPathPoint; +s16 D_801630E8[10]; +s16 gFerrySmokeTimer; +s32 D_80163100[10]; +s32 D_80163128[10]; +s32 D_80163150[10]; +f32 gPreviousPlayerAiOffsetX[10]; +f32 gPreviousPlayerAiOffsetZ[10]; +s16 sVehicleSoundRenderCounter; +s32 D_801631CC; +TrackPathPoint* gCurrentTrackLeftPath; +TrackPathPoint* gCurrentTrackRightPath; +s16* gCurrentTrackSectionTypesPath; +s16* gCurrentPathPointExpectedRotationPath; +u16 D_801631E0[12]; +u16 D_801631F8[10]; +f32 gCurrentCpuTargetSpeed; +f32 gPreviousCpuTargetSpeed[10]; +s32 D_80163238; +u16 D_80163240[12]; +u16 gWrongDirectionCounter[12]; +u16 gIsPlayerWrongDirection[12]; +s32 gPreviousLapProgressScore[10]; +CPUBehaviour* sCurrentCPUBehaviour; +u16 gCurrentCPUBehaviourId[12]; +u16 gPreviousCPUBehaviourId[12]; +u16 cpu_BehaviourState[12]; +s16 sPlayerAngle[12]; +u16 gPlayersTrackSectionId[12]; +u16 D_80163330[10]; +u16 D_80163344[2]; +u16 D_80163348[2]; +u16 D_8016334C[2]; +u16 gSpeedCPUBehaviour[12]; +s32 gSizePath[4]; +s32 gIncrementUpdatePlayer; +s32 D_8016337C; +s16 gCurrentPlayerLookAhead[12]; +s16 D_80163398[12]; +s16 D_801633B0[12]; +s16 gPositionSwapTimer[12]; +s16 D_801633E0[12]; +s16 D_801633F8[12]; +s16 D_80163410[4]; +f32 D_80163418[4]; +f32 D_80163428[4]; +f32 D_80163438[4]; +s32 gPlayerPathIndex; +f32 gPathStartZ; +f32 gPreviousPlayerZ[10]; +s16 gBestRankedHumanPlayer; +s16 gIsInExtra; +s16 D_8016347C; +s16 D_8016347E; +s32 D_80163480; +s32 D_80163484; +s32 D_80163488; +s16 D_8016348C; +s16 cpu_enteringPathIntersection[12]; +s16 cpu_exitingPathIntersection[12]; +s16 D_801634C0[12]; +s16 bStopAICrossing[10]; +s16 D_801634EC; +s32 D_801634F0; +s32 D_801634F4; +TrackPositionFactorInstruction gPlayerTrackPositionFactorInstruction[10]; +Path2D* gVehicle2DPathPoint; +s32 gVehicle2DPathLength; +TrainStuff gTrainList[NUM_TRAINS]; +u16 isCrossingTriggeredByIndex[NUM_CROSSINGS]; +u16 sCrossingActiveTimer[NUM_CROSSINGS]; +PaddleBoatStuff gPaddleBoats[NUM_PADDLE_BOATS]; +VehicleStuff gBoxTruckList[NUM_RACE_BOX_TRUCKS]; +VehicleStuff gSchoolBusList[NUM_RACE_SCHOOL_BUSES]; +VehicleStuff gTankerTruckList[NUM_RACE_TANKER_TRUCKS]; +VehicleStuff gCarList[NUM_RACE_CARS]; +s32 D_80163DD8[4]; +BombKart gBombKarts[NUM_BOMB_KARTS_MAX]; +Collision D_80164038[NUM_BOMB_KARTS_MAX]; +struct unexpiredActors gUnexpiredActorsList[8]; +CpuItemStrategyData cpu_ItemStrategy[NUM_PLAYERS]; +s16 D_80164358; +s16 D_8016435A; +s16 D_8016435C; +s16 gGPCurrentRacePlayerIdByRank[12]; // D_80164360 +s16 D_80164378[12]; +s32 gLapCountByPlayerId[10]; // D_80164390 +s32 gGPCurrentRaceRankByPlayerId[10]; // D_801643B8 +s32 gPreviousGPCurrentRaceRankByPlayerId[10]; +s32 gGPCurrentRaceRankByPlayerIdDup[10]; +u16 gSelectedPathCount; +u16 gNearestPathPointByPlayerId[12]; +s32 gNumPathPointsTraversed[10]; +s16 gGetPlayerByCharacterId[10]; +s32 D_8016448C; +TrackPathPoint* gCurrentTrackPath; +f32 D_80164498[4]; +f32 gLapCompletionPercentByPlayerId[10]; // D_801644A8 +f32 gCourseCompletionPercentByPlayerId[10]; // D_801644D0 +s16 bInMultiPathSection[12]; +f32 gPlayerPathY[10]; +s16 D_80164538[12]; +TrackPathPoint* gTrackPaths[4]; +TrackPathPoint* gTrackLeftPaths[4]; +TrackPathPoint* gTrackRightPaths[4]; +s16* gTrackSectionTypes[4]; +s16* gPathExpectedRotation[4]; +s16* gTrackConsecutiveCurveCounts[4]; +u16 gPathIndexByPlayerId[12]; // D_801645B0 +u16 gPathCountByPathIndex[4]; // D_801645C8 +s32 D_801645D0[4]; +s16* gCurrentTrackConsecutiveCurveCountsPath; +s32 D_801645E8[4]; +f32 D_801645F8[4]; +s32 D_80164608[4]; +f32 D_80164618[4]; +s32 D_80164628[4]; +f32 D_80164638[4]; +f32 D_80164648[4]; +f32 D_80164658[4]; +s16 gNearestPathPointByCameraId[4]; +s16 D_80164670[4]; +s16 D_80164678[4]; +s16 D_80164680[4]; +f32 D_80164688[4]; +f32 D_80164698; +f32 D_8016469C; +f32 D_801646A0; +// start padding +s32 D_801646A4; +s32 D_801646A8; +s32 D_801646AC; +s32 D_801646B0; +s32 D_801646B4; +s32 D_801646B8; +s32 D_801646BC; +// end padding +s16 D_801646C0[4]; +u32 D_801646C8; +u16 D_801646CC; +UnkStruct_46D0 D_801646D0[4]; + +// Strings, presented by google translate! +// Note that these are EUC-JP encoded, see: +// https://en.wikipedia.org/wiki/Extended_Unix_Code#EUC-JP + +// Force sort immediately after goal +char* D_800EB710 = "ゴール直後の強制ソート\n"; +// Forced sort immediately after one goal in 2PGP +char* D_800EB728 = "2PGPで片方がゴール直後の強制ソート\n"; +// rank calculation error +char* D_800EB74C = "順位計算エラー!! (num %d) (rank %d) (e_rank %d)\n"; +// Bypass switching error!!!(num %d org_bipas %d bipas %d) +char* D_800EB780 = "バイパス切り替え エラー!!!(num %d org_bipas %d bipas %d)\n"; +char* D_800EB7BC = "(%d) rap %3d rate_count_F %10.2f rap_count_F %10.2f area %5d \n"; +// Enter the maze! enemy %d (%d --> %d) +char* D_800EB800 = "迷路に突入! enemy %d (%d --> %d)\n"; +// Out of the maze! enemy %d (%d --> %d) +char* D_800EB824 = "迷路から出た! enemy %d (%d --> %d)\n"; +char* D_800EB84C = "enemy voice set (%d slip_flag %x weapon %x)\n"; +// Spin Voice! ! (%d , name %d) +char* D_800EB87C = "スピンヴォイス!!(%d , name %d)\n"; +// Damage voice! ! (%d, name %d) +char* D_800EB8A0 = "ダメージヴォイス!!(%d, name %d)\n"; +char* D_800EB8C4 = "===== ENEMY DRIVE SUB (%d) =====\n"; +// omission +char* D_800EB8E8 = "ENEMY END(手抜き)\n\n"; +char* D_800EB8FC = "ENEMY END(手抜き)\n\n"; +char* D_800EB910 = "(1)enemy stick angle over!! (%d)\n"; +char* D_800EB934 = "ENEMY END\n\n"; +char* D_800EB940 = "(2)enemy stick angle over!! (%d)\n"; +char* D_800EB964 = "ENEMY END\n\n"; +// AREA ERR!!! (group not registered at current centerline %d) %d +char* D_800EB970 = "AREA ERR!!! (現在のセンターライン %d に未登録のグループです) %d\n"; +// AREA ERR!!! (Unregistered group) %d +char* D_800EB9B4 = "AREA ERR!!! (未登録のグループです) %d\n"; +// get_oga_area_sub_BP() ... Area not found! (b_num = %d) +char* D_800EB9DC = "get_oga_area_sub_BP() ... エリアが見つからないッス! (b_num = %d)\n"; +// Status: (%d, %d, %d) +char* D_800EBA20 = " 状況: (%d, %d, %d) \n"; +char* D_800EBA38 = "<%d> (%d, %d, %d) [%d] lng %f\n"; +// Wario Stadium Jump failed! ! ! (area %d, y %7.2f) +char* D_800EBA58 = "ワリオスタジアム ジャンプ失敗!!! (area %d, y %7.2f)\n"; +// I fell in the water! ! Forced to centerline (num %d: area %d ) (%d,%d,%d) +char* D_800EBA94 = "水に落ちた!! センターラインに強制移動しました (num %d: area %d ) (%d,%d,%d)\n"; +// Course match! ! (Slacking: with bump) Forced move to center line (num %d: area %d ==>%d) (group %d) (%d,%d,%d) +char* D_800EBAE4 = "こーすあうと!!(手抜き中:バンプ有り) センターラインに強制移動しました (num %d: area %d ==>%d) " + "(group %d) (%d,%d,%d)\n"; +// Course match! ! (Sitting corners: no bump) Forced move to center line (num %d: area %d ==>%d) (group %d) (%d,%d,%d) +char* D_800EBB60 = "こーすあうと!!(手抜き中:バンプ無し) センターラインに強制移動しました (num %d: area %d ==>%d) " + "(group %d) (%d,%d,%d)\n"; +// Course match! ! ! Recalculated area (num %d: area %d ==>%d) +char* D_800EBBDC = "こーすあうと!!! エリアを再計算しました (num %d: area %d ==>%d)\n"; +// Direct BOM(%d) (%7.2f, %7.2f, %7.2f) +char* D_800EBC24 = "直接指定のBOM(%d) (%7.2f, %7.2f, %7.2f) \n"; +char* D_800EBC50 = "BOM HIT CHECK\n"; +char* D_800EBC60 = "BOM HIT !!!!! (%d)\n"; +// BOM standby +char* D_800EBC74 = "BOM待機\n"; +char* D_800EBC80 = "RESULT BOM area(%d)\n"; +// BOM dropped. +char* D_800EBC98 = "BOM が 落ちました。\n"; +// Tortoise fire pillar SET failed (TABLE IS FULL) +char* D_800EBCB0 = "カメ用火柱 SET 失敗 (TABLE IS FULL)\n"; +// Red turtle fire pillar set error! (category %d) +char* D_800EBCD8 = "赤ガメ火柱セットエラー! (category %d)\n"; +// Blue turtle fire pillar set error! (category %d) +char* D_800EBD00 = "青ガメ火柱セットエラー! (category %d)\n"; +// Thorn Turtle Fire Pillar Set Error! (category %d) +char* D_800EBD28 = "トゲガメ火柱セットエラー! (category %d)\n"; +// Turtle Fire Pillar Initialization! ! +char* D_800EBD54 = "カメ火柱初期化!!\n"; +// Center line initialization +char* D_800EBD68 = "センターライン初期化\n"; +char* D_800EBD80 = "MAP NUMBER %d\n"; +char* D_800EBD90 = "center_EX ptr = %x %x (%x)\n"; +char* D_800EBDB4 = "\n"; +char* D_800EBDB8 = "center_BP[%d] ptr = %x %x (%x)\n"; +char* D_800EBDE0 = "side_point_L_BP[%d] ptr = %x %x (%x)\n"; +char* D_800EBE08 = "side_point_R_BP[%d] ptr = %x %x (%x)\n"; +char* D_800EBE30 = "curve_BP[%d] ptr = %x %x (%x)\n"; +char* D_800EBE58 = "angle_BP[%d] ptr = %x %x (%x)\n"; +char* D_800EBE80 = "short_cut_data_BP[%d] ptr = %x %x (%x)\n"; +char* D_800EBEA8 = "\n"; +// Ogawa total memory used = %d +char* D_800EBEAC = "小川の使用メモリー合計 = %d\n"; +// Enemy initialization +char* D_800EBECC = "敵初期化\n"; +// End of enemy initialization +char* D_800EBED8 = "敵初期化終了\n"; +// Bypass CENTER LINE Split start +char* D_800EBEE8 = "バイパス CENTER LINE 分割開始\n"; +// Read centerline from ROM (map:%d) +char* D_800EBF08 = "センターラインをROMから読みます (map:%d)\n"; +char* D_800EBF34 = "ROM center (BP%d) line adr. = %x (%x)\n"; +// Calculate centerline (map:%d) +char* D_800EBF5C = "センターラインを計算します (map:%d)\n"; +char* D_800EBF84 = "center (BP%d) line adr. = %x (%x)\n"; +char* D_800EBFA8 = "BP center_point_number : %d\n"; +// Centerline data error! ! +char* D_800EBFC8 = "センターライン データ エラー!!\n"; +// Bypass CENTER LINE split end (%d -> %d number) +char* D_800EBFEC = "バイパス CENTER LINE 分割終了 (%d -> %d 個)\n"; +// No center line. (map: %d) +char* D_800EC01C = "センターラインが ありません。(map:%d)\n"; +// side point calculation (bypass %d) +char* D_800EC044 = "サイドポイント計算 (バイパス %d)\n"; +// Curve data calculation (bypass %d) +char* D_800EC068 = "カーブデータ計算 (バイパス %d)\n"; +// No center line. (map: %d) +char* D_800EC088 = "センターラインが ありません。(map:%d)\n"; +// Angle data calculation (bypass %d) +char* D_800EC0B0 = "アングルデータ計算 (バイパス %d) \n"; +// No center line. (map: %d) +char* D_800EC0D4 = "センターラインが ありません。(map:%d)\n"; +// Shortcut data calculation (bypass %d) +char* D_800EC0FC = "ショートカットデータ計算 (バイパス %d)\n"; +char* D_800EC124 = "extern POINT rom_center_KT%d_BP%d[] = {\n"; +char* D_800EC150 = "\t{%d,%d,%d,%d},\n"; +char* D_800EC164 = "\t0x8000,0x8000,0x8000,0\n};\n\n"; +char* D_800EC184 = "area read from ROM (%d)\n"; +// Normal jump! ! ! (%d) +char* D_800EC1A0 = "ノーマルジャンプ!!!(%d)\n"; +// Turbo on! ! ! (%d) +char* D_800EC1BC = "ターボオン!!!(%d)\n"; +// No cutting corners! ! ! (%d) +char* D_800EC1D4 = "手抜き禁止!!!(%d)\n"; +// Action start data error! (num %d, act %d) +char* D_800EC1EC = "アクション開始データエラー!(num %d, act %d)\n"; +// Action end data error! (num %d, act %d, old_act_num %d) +char* D_800EC21C = "アクション終了データエラー!(num %d, act %d, old_act_num %d)\n"; +char* D_800EC25C = "SL : center_point_number : %d\n"; +// SL: CENTER LINE split start +char* D_800EC27C = "SL: CENTER LINE 分割開始\n"; +// SL: CENTER LINE split ended (%d -> %d indivual) +char* D_800EC298 = "SL: CENTER LINE 分割終了 (%d -> %d 個)\n"; +char* D_800EC2C0 = "SHIP : center_point_number : %d\n"; +// SHIP: CENTER LINE split start +char* D_800EC2E4 = "SHIP: CENTER LINE 分割開始\n"; +// SHIP: CENTER LINE split ended (%d -> %d indivual) +char* D_800EC300 = "SHIP: CENTER LINE 分割終了 (%d -> %d 個)\n"; +// General-purpose OBJ character initialization +char* D_800EC32C = "汎用OBJキャラ初期化\n"; +// SL OBJ settings +char* D_800EC344 = "SL OBJ設定\n"; +// SHIP OBJ settings +char* D_800EC350 = "SHIP OBJ設定\n"; +// Track OBJ settings +char* D_800EC360 = "トラックOBJ設定\n"; +// Bus OBJ setting +char* D_800EC374 = "バスOBJ設定\n"; +// Tank OBJ setting +char* D_800EC384 = "タンクOBJ設定\n"; +// RV OBJ settings +char* D_800EC394 = "RV OBJ設定\n"; +// Generic OBJ character initialization completed +char* D_800EC3A0 = "汎用OBJキャラ初期化終了\n"; +// horn (num %d, permit %d, %d) +char* D_800EC3BC = "クラクション (num %d, permit %d, %d)\n"; +char* D_800EC3E4 = "OGA CAMERA INIT (%d)\n"; +char* D_800EC3FC = "OGA CAMERA INIT END\n"; +// High speed camera ERR !!! (ncx = %f) +char* D_800EC414 = "高速カメラ ERR !!! (ncx = %f)\n"; +// High speed camera ERR !!! (ncz = %f) +char* D_800EC434 = "高速カメラ ERR !!! (ncz = %f)\n"; +// High speed camera ERR !!! (ecx = %f) +char* D_800EC454 = "高速カメラ ERR !!! (ecx = %f)\n"; +// High speed camera ERR !!! (ecz = %f) +char* D_800EC474 = "高速カメラ ERR !!! (ecz = %f)\n"; +char* D_800EC494 = "OGA DRIVERS POINT CAMERA MODE \n"; +char* D_800EC4B4 = "OGA WINNER CAMERA MODE \n"; +char* D_800EC4D0 = "OGA TIMEATTACK QUICK CAMERA INIT \n"; +char* D_800EC4F4 = "OGA BATTLE CAMERA INIT win(%d)\n"; +char* D_800EC514 = "GOAL! <> camera %d rank %d\n"; +char* D_800EC53C = "GOAL! <> camera %d rank %d\n"; +char* D_800EC568 = "GOAL! <> camera %d rank %d\n"; +// Camera and cart collided! ! ! +char* D_800EC594 = "カメラとカートが衝突しました!!! (%d)\n"; +char* D_800EC5C0 = "<<< ITEM OBJ NUMBER ERR !! >>> item %d obj_num %d \n"; +// <<< BANANA SET HOUSE >>> obj_num %d zure %f +char* D_800EC5F8 = "<<< BANANA SET 失敗 >>> obj_num %d zure %f \n"; +// BANANA Caught in owner check. (num %d) +char* D_800EC628 = "BANANA 所有者チェックに引っ掛かりました。(num %d)\n"; +// Reason: EXISTOBJ +char* D_800EC65C = "理由: EXISTOBJ \n"; +// Reason: category +char* D_800EC670 = "理由: category \n"; +// Reason: sparam +char* D_800EC684 = "理由: sparam \n"; +// Reason: num +char* D_800EC694 = "理由: num \n"; +char* D_800EC6A0 = "BANANA HOLD (num %d time %d hold_time %d)\n"; +// Installation Caught in BANANA owner check. (num %d) +char* D_800EC6D0 = "設置 BANANA 所有者チェックに引っ掛かりました。(num %d)\n"; +// Reason: EXISTOBJ +char* D_800EC708 = "理由: EXISTOBJ \n"; +// Reason: category +char* D_800EC71C = "理由: category \n"; +// Reason: sparam +char* D_800EC730 = "理由: sparam \n"; +// Reason: num +char* D_800EC740 = "理由: num \n"; +// I put BANANA. (num %d) +char* D_800EC74C = "BANANA 置きました。 (num %d)\n"; +// <<< BANANA NAGE SET failed >>> obj_num %d +char* D_800EC76C = "<<< BANANA NAGE SET 失敗 >>> obj_num %d \n"; +// BANANA NAGE MOVE Caught in owner check. (num %d) +char* D_800EC798 = "BANANA NAGE MOVE 所有者チェックに引っ掛かりました。(num %d)\n"; +// Reason: EXISTOBJ +char* D_800EC7D8 = "理由: EXISTOBJ \n"; +// Reason: category +char* D_800EC7EC = "理由: category \n"; +// Reason: sparam +char* D_800EC800 = "理由: sparam \n"; +// Reason: num +char* D_800EC810 = "理由: num \n"; +char* D_800EC81C = "BANANA NAGE END 所有者チェックに引っ掛かりました。(num %d)\n"; +// Reason: EXISTOBJ +char* D_800EC858 = "理由: EXISTOBJ \n"; +// Reason: category +char* D_800EC86C = "理由: category \n"; +// Reason: sparam +char* D_800EC880 = "理由: sparam \n"; +// Reason: num +char* D_800EC890 = "理由: num \n"; +char* D_800EC89C = "G_SHELL HOLD (num %d time %d hold_time %d)\n"; +// <<< G_SHELL SET failed >>> obj_num %d +char* D_800EC8CC = "<<< G_SHELL SET 失敗 >>> obj_num %d \n"; +// <<< G_SHELL SET failed >>> object_count %d +char* D_800EC8F4 = "<<< G_SHELL SET 失敗 >>> object_count %d \n"; +// G_SHELL Caught in owner check. (num %d) +char* D_800EC920 = "G_SHELL 所有者チェックに引っ掛かりました。(num %d)\n"; +// Reason: EXISTOBJ +char* D_800EC954 = "理由: EXISTOBJ \n"; +// Reason: category +char* D_800EC968 = "理由: category \n"; +// Reason: sparam +char* D_800EC97C = "理由: sparam \n"; +// Reason: num +char* D_800EC98C = "理由: num \n"; +// Just before launch G_SHELL Caught in owner check. (num %d) +char* D_800EC998 = "発射直前 G_SHELL 所有者チェックに引っ掛かりました。(num %d)\n"; +// Reason: EXISTOBJ +char* D_800EC9D8 = "理由: EXISTOBJ \n"; +// Reason: category +char* D_800EC9EC = "理由: category \n"; +// Reason: sparam +char* D_800ECA00 = "理由: sparam \n"; +// Reason: num +char* D_800ECA10 = "理由: num \n"; +// G_SHELL firing (num %d) +char* D_800ECA1C = "G_SHELL 発射 (num %d)\n"; +char* D_800ECA34 = "R_SHELL HOLD (num %d time %d hold_time %d obj_num %d)\n"; +// <<< R_SHELL SET failed >>> obj_num %d +char* D_800ECA70 = "<<< R_SHELL SET 失敗 >>> obj_num %d \n"; +// <<< R_SHELL SET failed >>> object_count %d +char* D_800ECA98 = "<<< R_SHELL SET 失敗 >>> object_count %d \n"; +// R_SHELL Caught in owner check. (num %d) +char* D_800ECAC4 = "R_SHELL 所有者チェックに引っ掛かりました。(num %d)\n"; +// Reason: EXISTOBJ +char* D_800ECAF8 = "理由: EXISTOBJ \n"; +// Reason: category +char* D_800ECB0C = "理由: category \n"; +// Reason: sparam +char* D_800ECB20 = "理由: sparam \n"; +// Reason: num +char* D_800ECB30 = "理由: num \n"; +char* D_800ECB3C = "R_SHELL SHOOT (num %d time %d hold_time %d obj_num %d)\n"; +// Just before launch R_SHELL Caught in owner check. (num %d) +char* D_800ECB78 = "発射直前 R_SHELL 所有者チェックに引っ掛かりました。(num %d)\n"; +// Reason: EXISTOBJ +char* D_800ECBB8 = "理由: EXISTOBJ \n"; +// Reason: category +char* D_800ECBCC = "理由: category \n"; +// Reason: sparam +char* D_800ECBE0 = "理由: sparam \n"; +// Reason: num +char* D_800ECBF0 = "理由: num \n"; +// R_SHELL firing (num %d) +char* D_800ECBFC = "R_SHELL 発射 (num %d)\n"; +char* D_800ECC14 = "S_BANANA HOLD (num %d time %d hold_time %d)\n"; +// <<< SUPER_BANANA SET failed >>> obj_num %d +char* D_800ECC44 = "<<< SUPER_BANANA SET 失敗 >>> obj_num %d \n"; +// <<< SUPER_BANANA SET failed >>> object_count %d +char* D_800ECC70 = "<<< SUPER_BANANA SET 失敗 >>> object_count %d \n"; +// S_BANANA Caught in owner check. (num %d) +char* D_800ECCA0 = "S_BANANA 所有者チェックに引っ掛かりました。(num %d)\n"; +// Reason: category +char* D_800ECCD8 = "理由: category \n"; +// Reason: sparam +char* D_800ECCEC = "理由: sparam \n"; +// Reason: sb_ok +char* D_800ECCFC = "理由: sb_ok \n"; +char* D_800ECD0C = "S_BANANA RELEASE (num %d time %d )\n"; +// <<< FAKE IBOX SET failed >>> obj_num %d +char* D_800ECD34 = "<<< FAKE IBOX SET 失敗 >>> obj_num %d \n"; +// IBOX Caught in owner check. (num %d) +char* D_800ECD5C = "IBOX 所有者チェックに引っ掛かりました。(num %d)\n"; +// Reason: EXISTOBJ +char* D_800ECD90 = "理由: EXISTOBJ \n"; +// Reason: category +char* D_800ECDA4 = "理由: category \n"; +// Reason: sparam +char* D_800ECDB8 = "理由: sparam \n"; +// Reason: num +char* D_800ECDC8 = "理由: num \n"; +char* D_800ECDD4 = "FBOX HOLD (num %d time %d hold_time %d)\n"; +// Installation IBOX owner check failed. (num %d) +char* D_800ECE00 = "設置 IBOX 所有者チェックに引っ掛かりました。(num %d)\n"; +// Reason: EXISTOBJ +char* D_800ECE38 = "理由: EXISTOBJ \n"; +// Reason: category +char* D_800ECE4C = "理由: category \n"; +// Reason: sparam +char* D_800ECE60 = "理由: sparam \n"; +// Reason: num +char* D_800ECE70 = "理由: num \n"; +// Ray START (%d) +char* D_800ECE7C = "雷START (%d)\n"; +// Ray END (%d) +char* D_800ECE8C = "雷END (%d)\n"; +// ---------- Initialization of commendation table +char* D_800ECE98 = "---------- 表彰台初期化\n"; +// map_number = %d -> 20 Rewriting. +char* D_800ECEB4 = "map_number = %d - > 20 書き換え中。\n"; +// OGA Recognition move begins +char* D_800ECEDC = "OGA 表彰 move 開始\n"; +// I called the display of the 4th place person. +char* D_800ECEF0 = "4位の人の表示をコールしました。\n"; +// Arrive at the podium +char* D_800ECF14 = "表彰台に到着\n"; +// Everyone gather! +char* D_800ECF24 = "全員集合!\n"; +// Arrive on the road +char* D_800ECF30 = "道路に到着\n"; +// 4th place finished +char* D_800ECF3C = "4位の人終了\n"; +// OGA commendation move end +char* D_800ECF4C = "OGA 表彰 move 終了\n"; +char* D_800ECF60 = "OGAWA DEBUG DRAW\n"; + +// utils function path, cpu, vehicle + +s16 get_angle_between_path(Vec3f arg0, Vec3f arg1) { + s16 temp_ret; + s16 phi_v1; + + temp_ret = get_angle_between_two_vectors(arg0, arg1); + phi_v1 = temp_ret; + if (gIsMirrorMode != 0) { + phi_v1 = -temp_ret; + } + return phi_v1; +} + +bool is_collide_with_vehicle(f32 vehicleX, f32 vehicleY, f32 vehicleVelocityX, f32 vehicleVelocityZ, f32 distanceX, + f32 distanceY, f32 playerX, f32 playerZ) { + f32 velocity; + f32 temp_f18; + + velocity = sqrtf((vehicleVelocityX * vehicleVelocityX) + (vehicleVelocityZ * vehicleVelocityZ)); + if (velocity < 0.01f) { + return false; + } + temp_f18 = + ((vehicleVelocityX / velocity) * (playerX - vehicleX)) + ((vehicleVelocityZ / velocity) * (playerZ - vehicleY)); + if ((-distanceX < temp_f18) && (temp_f18 < distanceX)) { + temp_f18 = ((vehicleVelocityZ / velocity) * (playerX - vehicleX)) + + (-(vehicleVelocityX / velocity) * (playerZ - vehicleY)); + if ((-distanceY < temp_f18) && (temp_f18 < distanceY)) { + return true; + } + } + return false; +} + +void adjust_position_by_angle(Vec3f newPos, Vec3f oldPos, s16 orientationY) { + f32 x_dist; + f32 z_dist; + f32 temp1; + f32 temp2; + f32 sine; + f32 cosine; + + if (gIsMirrorMode != 0) { + orientationY = -orientationY; + } + x_dist = newPos[0] - oldPos[0]; + z_dist = newPos[2] - oldPos[2]; + sine = sins(orientationY); + cosine = coss(orientationY); + temp1 = ((x_dist * cosine) + (z_dist * sine)); + temp2 = ((z_dist * cosine) - (x_dist * sine)); + newPos[0] = oldPos[0] + temp1; + newPos[2] = oldPos[2] + temp2; +} + +s32 set_vehicle_render_distance_flags(Vec3f vehiclePos, f32 renderDistance, s32 flags) { + Camera* camera; + Player* player; + f32 x; + f32 z; + f32 playerX; + f32 playerZ; + s32 i; + s32 flag; + s8 numScreens; + + x = vehiclePos[0]; + z = vehiclePos[2]; + switch (gActiveScreenMode) { + case SCREEN_MODE_1P: + numScreens = 1; + break; + case SCREEN_MODE_2P_SPLITSCREEN_HORIZONTAL: + case SCREEN_MODE_2P_SPLITSCREEN_VERTICAL: + numScreens = 2; + break; + case SCREEN_MODE_3P_4P_SPLITSCREEN: + numScreens = gPlayerCount; + break; + default: + numScreens = 1; + break; + } + flag = flags; + if (!gDemoMode) { + player = gPlayerOne; + // Checks distance from each player. + for (i = 0; i < gPlayerCount; i++, player++) { + if (((player->type & PLAYER_HUMAN) != 0) && ((player->type & PLAYER_CPU) == 0)) { + playerX = player->pos[0]; + playerZ = player->pos[2]; + + // Is player within render distance + if (((playerX - renderDistance) < x) && ((playerX + renderDistance) > x) && + ((playerZ - renderDistance) < z) && ((playerZ + renderDistance) > z)) { + // Sets the render flag to on for each player. + flag |= (RENDER_VEHICLE << i); + } else { + // Sets the render flag to off for each player. + flag &= ~(RENDER_VEHICLE << i); + } + } + } + } else { // Demo cinematic uses the camera to check render distance + camera = camera1; + for (i = 0; i < numScreens; i++, camera++) { + playerX = camera->pos[0]; + playerZ = camera->pos[2]; + if (((playerX - renderDistance) < x) && (x < (playerX + renderDistance)) && + ((playerZ - renderDistance) < z) && (z < (playerZ + renderDistance))) { + flag |= (RENDER_VEHICLE << i); + } else { + flag &= ~(RENDER_VEHICLE << i); + } + } + } + return flag; +} + +void detect_wrong_player_direction(s32 playerId, Player* player) { + s16 playerAngle; + s16 rotationDifference; + s16 pathPointAngle; + s16 pathIndex; + u32 pathPoint; + + pathIndex = (s16) gPathIndexByPlayerId[playerId]; + pathPoint = gNearestPathPointByPlayerId[playerId]; + + playerAngle = (s16) ((s16) player->rotation[1] / DEGREES_CONVERSION_FACTOR); + pathPointAngle = (s16) ((s16) gPathExpectedRotation[pathIndex][pathPoint] / DEGREES_CONVERSION_FACTOR); + + rotationDifference = playerAngle - pathPointAngle; + + if (rotationDifference < 0) { + rotationDifference = -rotationDifference; + } + + if ((gNumPathPointsTraversed[playerId] < gPreviousLapProgressScore[playerId]) && + (rotationDifference >= SEVERE_WRONG_DIRECTION_MIN) && (rotationDifference < SEVERE_WRONG_DIRECTION_MAX)) { + gWrongDirectionCounter[playerId]++; + if ((gWrongDirectionCounter[playerId]) >= WRONG_DIRECTION_FRAMES_LIMIT) { + gIsPlayerWrongDirection[playerId] = 1; + gWrongDirectionCounter[playerId] = WRONG_DIRECTION_FRAMES_LIMIT; + gPlayers[playerId].effects |= REVERSE_EFFECT; + } + } else if ((rotationDifference < SEVERE_CORRECT_DIRECTION_MIN) || + (rotationDifference >= SEVERE_CORRECT_DIRECTION_MAX)) { + gIsPlayerWrongDirection[playerId] = 0; + gWrongDirectionCounter[playerId] = 0; + gPlayers[playerId].effects &= ~REVERSE_EFFECT; + } + gPreviousLapProgressScore[playerId] = gNumPathPointsTraversed[playerId]; +} + +void set_places(void) { + s32 temp_s2; + f32 temp_f0; + s32 rankPlayer[8]; + s32 a_really_cool_variable_name; + UNUSED s32 pad; + s32 numPlayer; + s32 playerId; + s32 temp_a0; + s32 var_t1_3; + + switch (gModeSelection) { + case BATTLE: + default: + return; // HEY! returns, not breaks + case GRAND_PRIX: + case TIME_TRIALS: + numPlayer = NUM_PLAYERS; + break; + case VERSUS: + numPlayer = gPlayerCount; + break; + } + + if (D_8016348C == 0) { + for (playerId = 0; playerId < numPlayer; playerId++) { + temp_a0 = gGPCurrentRacePlayerIdByRank[playerId]; + rankPlayer[playerId] = temp_a0; + gCourseCompletionPercentByRank[playerId] = gCourseCompletionPercentByPlayerId[temp_a0]; + } + } else { + for (playerId = 0; playerId < numPlayer; playerId++) { + temp_a0 = gGPCurrentRacePlayerIdByRank[playerId]; + rankPlayer[playerId] = temp_a0; + gCourseCompletionPercentByRank[playerId] = -gTimePlayerLastTouchedFinishLine[temp_a0]; + } + } + + for (playerId = 0; playerId < numPlayer - 1; playerId++) { + if ((gPlayers[gGPCurrentRacePlayerIdByRank[playerId]].type & 0x800)) { + continue; + } + + for (var_t1_3 = playerId + 1; var_t1_3 < numPlayer; var_t1_3++) { + if (gCourseCompletionPercentByRank[playerId] < gCourseCompletionPercentByRank[var_t1_3]) { + if (!(gPlayers[gGPCurrentRacePlayerIdByRank[var_t1_3]].type & 0x800)) { + temp_s2 = rankPlayer[playerId]; + rankPlayer[playerId] = rankPlayer[var_t1_3]; + rankPlayer[var_t1_3] = temp_s2; + temp_f0 = gCourseCompletionPercentByRank[playerId]; + gCourseCompletionPercentByRank[playerId] = gCourseCompletionPercentByRank[var_t1_3]; + gCourseCompletionPercentByRank[var_t1_3] = temp_f0; + } + } + } + } + + for (playerId = 0; playerId < NUM_PLAYERS; playerId++) { + gPreviousGPCurrentRaceRankByPlayerId[playerId] = gGPCurrentRaceRankByPlayerId[playerId]; + } + + for (playerId = 0; playerId < numPlayer; playerId++) { + gGPCurrentRacePlayerIdByRank[playerId] = rankPlayer[playerId]; + gGPCurrentRaceRankByPlayerId[rankPlayer[playerId]] = playerId; + } + + for (playerId = 0; playerId < numPlayer; playerId++) { + a_really_cool_variable_name = D_80164378[playerId]; + rankPlayer[playerId] = a_really_cool_variable_name; + gCourseCompletionPercentByRank[playerId] = gCourseCompletionPercentByPlayerId[a_really_cool_variable_name]; + } + + for (playerId = 0; playerId < numPlayer - 1; playerId++) { + for (var_t1_3 = playerId + 1; var_t1_3 < numPlayer; var_t1_3++) { + if (gCourseCompletionPercentByRank[playerId] < gCourseCompletionPercentByRank[var_t1_3]) { + temp_s2 = rankPlayer[playerId]; + rankPlayer[playerId] = rankPlayer[var_t1_3]; + rankPlayer[var_t1_3] = temp_s2; + temp_f0 = gCourseCompletionPercentByRank[playerId]; + gCourseCompletionPercentByRank[playerId] = gCourseCompletionPercentByRank[var_t1_3]; + gCourseCompletionPercentByRank[var_t1_3] = temp_f0; + } + } + } + + for (playerId = 0; playerId < numPlayer; playerId++) { + gGPCurrentRaceRankByPlayerIdDup[rankPlayer[playerId]] = playerId; + D_80164378[playerId] = rankPlayer[playerId]; + } +} + +void update_player_rankings(void) { + f32 temp_f0; + UNUSED s32 pad; + s32 playerIds[8]; + s32 temp_a0; + s32 temp_t2_2; + s32 compareIndex; + s32 i; + s32 numRacers; + + switch (gModeSelection) { + case BATTLE: + default: + return; // HEY! returns, not breaks + case GRAND_PRIX: + case TIME_TRIALS: + numRacers = 8; + break; + case VERSUS: + numRacers = gPlayerCount; + break; + } + + for (i = 0; i < numRacers; i++) { + temp_a0 = gGPCurrentRacePlayerIdByRank[i]; + playerIds[i] = temp_a0; + gCourseCompletionPercentByRank[i] = -gTimePlayerLastTouchedFinishLine[temp_a0]; + } + + for (i = 0; i < (numRacers - 1); i++) { + for (compareIndex = i + 1; compareIndex < numRacers; compareIndex++) { + if (gCourseCompletionPercentByRank[i] < gCourseCompletionPercentByRank[compareIndex]) { + temp_t2_2 = playerIds[i]; + playerIds[i] = playerIds[compareIndex]; + playerIds[compareIndex] = temp_t2_2; + temp_f0 = gCourseCompletionPercentByRank[i]; + gCourseCompletionPercentByRank[i] = gCourseCompletionPercentByRank[compareIndex]; + gCourseCompletionPercentByRank[compareIndex] = temp_f0; + } + } + } + + for (i = 0; i < NUM_PLAYERS; i++) { + gPreviousGPCurrentRaceRankByPlayerId[i] = gGPCurrentRaceRankByPlayerId[i]; + } + + for (i = 0; i < numRacers; i++) { + gGPCurrentRaceRankByPlayerId[playerIds[i]] = i; + gGPCurrentRacePlayerIdByRank[i] = playerIds[i]; + } +} + +void set_places_end_course_with_time(void) { + f32 temp_a0; + s32 temp; + s32 sp68[8]; + UNUSED s32 pad; + s32 temp_t1; + s32 i; + s32 j; + s32 this_loops_upper_bound_is_brough_to_you_by_the_number = 8; + + for (i = 0; i < this_loops_upper_bound_is_brough_to_you_by_the_number;) { + gCourseCompletionPercentByRank[i++] = 0.0f; + } + + for (j = 0, i = 0; i < this_loops_upper_bound_is_brough_to_you_by_the_number; i++) { + if (gPlayers[i].type & PLAYER_CINEMATIC_MODE) { + sp68[j] = i; + gCourseCompletionPercentByRank[j] = -gTimePlayerLastTouchedFinishLine[i]; + j++; + } + } + + temp_t1 = j; + for (i = 0; i < this_loops_upper_bound_is_brough_to_you_by_the_number; i++) { + if (!(gPlayers[i].type & PLAYER_CINEMATIC_MODE)) { + sp68[j] = i; + gCourseCompletionPercentByRank[j] = gCourseCompletionPercentByPlayerId[i]; + j++; + } + } + + for (i = 0; i < (temp_t1 - 1); i++) { + for (j = i + 1; j < temp_t1; j++) { + if (gCourseCompletionPercentByRank[i] < gCourseCompletionPercentByRank[j]) { + temp = sp68[i]; + sp68[i] = sp68[j]; + sp68[j] = temp; + temp_a0 = gCourseCompletionPercentByRank[i]; + gCourseCompletionPercentByRank[i] = gCourseCompletionPercentByRank[j]; + gCourseCompletionPercentByRank[j] = temp_a0; + } + } + } + + for (i = temp_t1; i < (this_loops_upper_bound_is_brough_to_you_by_the_number - 1); i++) { + for (j = i + 1; j < this_loops_upper_bound_is_brough_to_you_by_the_number; j++) { + if (gCourseCompletionPercentByRank[i] < gCourseCompletionPercentByRank[j]) { + temp = sp68[i]; + sp68[i] = sp68[j]; + sp68[j] = temp; + temp_a0 = gCourseCompletionPercentByRank[i]; + gCourseCompletionPercentByRank[i] = gCourseCompletionPercentByRank[j]; + gCourseCompletionPercentByRank[j] = temp_a0; + } + } + } + + for (i = 0; i < NUM_PLAYERS; i++) { + gPreviousGPCurrentRaceRankByPlayerId[i] = gGPCurrentRaceRankByPlayerId[i]; + } + + for (i = 0; i < this_loops_upper_bound_is_brough_to_you_by_the_number; i++) { + gGPCurrentRaceRankByPlayerId[sp68[i]] = i; + gGPCurrentRacePlayerIdByRank[i] = sp68[i]; + } +} + +/** + * Checks if a path point is within a valid range of another path point, accounting for track wrapping + * + * @param pathPoint The path point to check + * @param currentPathPoint The reference path point + * @param backwardRange Number of path to look behind + * @param forwardRange Number of path to look ahead + * @param totalPathPoints Total number of path in the track + * @return + * 1: path point is within normal range + * -1: path point is within wrapped range + * 2: path point is out of range + * 0: invalid range parameters + */ +s32 is_path_point_in_range(u16 pathPoint, u16 currentPathPoint, u16 backwardRange, u16 forwardRange, + u16 totalPathPoints) { + s32 var_v1; + + var_v1 = 0; + if ((currentPathPoint >= backwardRange) && (currentPathPoint < (totalPathPoints - forwardRange))) { + if ((pathPoint >= (currentPathPoint - backwardRange)) && ((currentPathPoint + forwardRange) >= pathPoint)) { + var_v1 = 1; + } + } else if ((((currentPathPoint + forwardRange) % totalPathPoints) < pathPoint) && + ((((currentPathPoint + totalPathPoints) - backwardRange) % totalPathPoints) >= pathPoint)) { + var_v1 = -1; + } else { + var_v1 = 2; + } + return var_v1; +} + +// cpu utils function + +#include "cpu_vehicles_camera_path/cpu_speed_control.inc.c" + +#ifdef NON_MATCHING +// generated by m2c commit 05102b12b75400ad2be8bd0872404237b36e1702 on Feb-20-2024 +// static ? D_800DCAF4; /* unable to generate initializer: unknown type */ +// static ? D_800DCB34; /* unable to generate initializer: unknown type */ +// static ? *D_800DCBB4[0x15] = { +// &D_800DCB34, +// &D_800DCAF4, +// &D_800DCAF4, +// &D_800DCAF4, +// &D_800DCAF4, +// &D_800DCAF4, +// &D_800DCAF4, +// &D_800DCAF4, +// &D_800DCAF4, +// &D_800DCAF4, +// &D_800DCAF4, +// &D_800DCAF4, +// &D_800DCAF4, +// &D_800DCAF4, +// &D_800DCAF4, +// &D_800DCAF4, +// &D_800DCAF4, +// &D_800DCAF4, +// &D_800DCAF4, +// &D_800DCAF4, +// &D_800DCAF4, +// }; + +bool func_800088D8(s32 playerId, s16 arg1, s16 arg2) { + Player* player; + f32 interp; + s16 rank; + s16 var_a0_4; + s16 var_t1; + s16 var_v0; + s16* temp_a3; + s32 temp_a2; + s32 arg1_times_8; + s32 var_a0_2; + s32 progress; + s32 var_a1_4; + s32 i; + + D_80163128[playerId] = -1; + D_80163150[playerId] = -1; + if (gModeSelection == TIME_TRIALS) { + return true; + } + if (arg1 < 0) { + return true; + } else if (arg1 >= 4) { + arg1 = 3; + } + if (D_80163330[playerId] == 1) { + return true; + } + player = &gPlayers[playerId]; + if (player->type & PLAYER_HUMAN) { + return true; + } + arg1_times_8 = arg1 * 8; + temp_a3 = &GET_COURSE_800DCBB4(arg1_times_8); + if (arg2 == 0) { + if (gDemoMode == 1) { + temp_a2 = gNumPathPointsTraversed[playerId] - gNumPathPointsTraversed[D_80164378[7]]; + if (temp_a2 < 0) { + temp_a2 = -temp_a2; + } + if (arg1_times_8 < 24) { + interp = gLapCompletionPercentByPlayerId[playerId]; + D_80163150[playerId] = temp_a3[8] * interp + temp_a3[0] * (1.0f - interp); + } else { + D_80163150[playerId] = temp_a3[0]; + } + if (D_80163150[playerId] < temp_a2 && player->speed / 18.0f * 216.0f >= 20.0f) { + return false; + } + return true; + } + progress = gNumPathPointsTraversed[playerId] - gNumPathPointsTraversed[gBestRankedHumanPlayer]; + rank = gGPCurrentRaceRankByPlayerId[2 + (gBestRankedHumanPlayer * 4)]; + if (gPathCountByPathIndex[0] * 2 / 3 < progress && rank >= 6) { + progress = gNumPathPointsTraversed[playerId] - gNumPathPointsTraversed[gLapCountByPlayerId[-26 + rank * 2]]; + } + if (progress < 0) { + progress = -progress; + } + if (arg1_times_8 < 24) { + interp = gLapCompletionPercentByPlayerId[playerId]; + var_a0_2 = temp_a3[8] * interp + temp_a3[0] * (1.0f - interp); + } else { + var_a0_2 = temp_a3[0]; + } + D_80163150[playerId] = (gCCSelection + 1) * var_a0_2; + if (D_80163150[playerId] < progress && player->speed / 18.0f * 216.0f >= 20.0f) { + return false; + } + return true; + } else { + var_a1_4 = gNumPathPointsTraversed[(s16) *D_80163344] - gNumPathPointsTraversed[playerId]; + if (var_a1_4 < 0) { + var_a1_4 = -var_a1_4; + } + var_v0 = 0; + for (i = 0; i < 2; i++) { + if (gGPCurrentRaceRankByPlayerId[D_80163344[i]] < arg2) { + var_v0++; + } + } + var_a0_4 = 0; + for (i = 0; i < gPlayerCount; i++) { + if (gGPCurrentRaceRankByPlayerId[i] < arg2) { + var_a0_4++; + } + } + var_t1 = (arg2 - var_v0) - var_a0_4; + if (var_v0 > 0 || var_a0_4 > 0) { + var_t1++; + } + D_80164538[playerId] = var_t1; + if (var_t1 < 0 || var_t1 >= 8) { + return false; + } + if (arg1_times_8 < 24) { + temp_a3 = &temp_a3[var_t1]; + interp = gLapCompletionPercentByPlayerId[playerId]; + D_80163150[playerId] = temp_a3[8] * interp + temp_a3[0] * (1.0f - interp); + } else { + D_80163150[playerId] = temp_a3[var_t1]; + } + D_80163128[playerId] = var_a1_4; + if (D_80163150[playerId] < var_a1_4) { + return true; + } + return false; + } +} +#else +GLOBAL_ASM("asm/non_matchings/cpu_vehicles_camera_path/func_800088D8.s") +#endif + +void set_current_path(s32 pathIndex) { + gCurrentTrackPath = gTrackPaths[pathIndex]; + gCurrentTrackLeftPath = gTrackLeftPaths[pathIndex]; + gCurrentTrackRightPath = gTrackRightPaths[pathIndex]; + gCurrentTrackSectionTypesPath = gTrackSectionTypes[pathIndex]; + gCurrentPathPointExpectedRotationPath = gPathExpectedRotation[pathIndex]; + gCurrentTrackConsecutiveCurveCountsPath = gTrackConsecutiveCurveCounts[pathIndex]; + gSelectedPathCount = gPathCountByPathIndex[pathIndex]; +} + +s32 update_player_path_selection(s32 payerId, s32 pathIndex) { + f32 posX; + f32 posY; + f32 posZ; + Player* player; + s32 trackSectionId; + UNUSED s32 stackPadding; + + player = &gPlayers[payerId]; + posX = player->pos[0]; + posY = player->pos[1]; + posZ = player->pos[2]; + stackPadding = pathIndex; + trackSectionId = get_track_section_id(player->collision.meshIndexZX); + gPlayersTrackSectionId[payerId] = trackSectionId; + sSomeNearestPathPoint = find_closest_pathPoint_track_section(posX, posY, posZ, trackSectionId, &pathIndex); + gNearestPathPointByPlayerId[payerId] = sSomeNearestPathPoint; + if (pathIndex) {}; + gPathIndexByPlayerId[payerId] = pathIndex; + set_current_path(pathIndex); + if (stackPadding) {}; + return pathIndex; +} + +void update_player_completion(s32 playerId) { + f32 percent; + + // arbitrary score calculation + gNumPathPointsTraversed[playerId] = + (gLapCountByPlayerId[playerId] * gPathCountByPathIndex[0]) + sSomeNearestPathPoint; + + // calculate completion in percent + percent = (f32) gNearestPathPointByPlayerId[playerId] / (f32) gPathCountByPathIndex[gPathIndexByPlayerId[playerId]]; + gLapCompletionPercentByPlayerId[playerId] = percent; + gCourseCompletionPercentByPlayerId[playerId] = percent; + gCourseCompletionPercentByPlayerId[playerId] += gLapCountByPlayerId[playerId]; +} + +void yoshi_valley_cpu_path(s32 playerId) { + s16 previous; + + previous = bInMultiPathSection[playerId]; + if (sSomeNearestPathPoint >= 0x6D) { + bInMultiPathSection[playerId] = true; + switch (gPlayerPathIndex) { + case 0: + if (sSomeNearestPathPoint >= 0x20F) { + bInMultiPathSection[playerId] = false; + } + break; + case 1: + if (sSomeNearestPathPoint >= 0x206) { + bInMultiPathSection[playerId] = false; + } + break; + case 2: + if (sSomeNearestPathPoint >= 0x211) { + bInMultiPathSection[playerId] = false; + } + break; + case 3: + if (sSomeNearestPathPoint >= 0x283) { + bInMultiPathSection[playerId] = false; + } + break; + } + } + if ((previous == false) && (bInMultiPathSection[playerId] == true)) { + cpu_enteringPathIntersection[playerId] = true; + } + if ((previous == true) && (bInMultiPathSection[playerId] == false)) { + cpu_exitingPathIntersection[playerId] = true; + } +} + +void update_cpu_path_completion(s32 playerId, Player* player) { + f32 posX; + f32 posY; + f32 posZ; + UNUSED f32 pad[2]; + + posX = player->pos[0]; + posY = player->pos[1]; + posZ = player->pos[2]; + if (cpu_enteringPathIntersection[playerId] == 1) { + gPlayerPathIndex = update_player_path_selection(playerId, random_int(4U)); + sSomeNearestPathPoint = update_player_path(posX, posY, posZ, 0, player, playerId, gPlayerPathIndex); + gNearestPathPointByPlayerId[playerId] = sSomeNearestPathPoint; + update_player_completion(playerId); + cpu_enteringPathIntersection[playerId] = 0; + } + if (cpu_exitingPathIntersection[playerId] == 1) { + gPlayerPathIndex = update_player_path_selection(playerId, 0); + sSomeNearestPathPoint = update_player_path(posX, posY, posZ, 0, player, playerId, gPlayerPathIndex); + gNearestPathPointByPlayerId[playerId] = sSomeNearestPathPoint; + update_player_completion(playerId); + cpu_exitingPathIntersection[playerId] = 0; + } +} + +/** + * Helps calculate time since player last touched finishline. + **/ +f32 func_80009258(UNUSED s32 playerId, f32 arg1, f32 arg2) { + f32 temp_f2 = gPathStartZ - arg2; + f32 temp_f12 = arg1 - gPathStartZ; + return gCourseTimer - ((COURSE_TIMER_ITER_f * temp_f2) / (temp_f2 + temp_f12)); +} + +#ifdef NON_MATCHING +// Weird stack issue, can't figure out how to get rid of it +void update_player_path_completion(s32 playerId, Player* player) { + f32 playerX; + f32 playerY; + f32 playerZ; + s32 var_v0; + s32 var_v1; + f32 previousPlayerZ; + UNUSED s16 stackPadding0; + s16 var_t0; + UNUSED s32 stackPadding1; + + playerX = player->pos[0]; + playerY = player->pos[1]; + playerZ = player->pos[2]; + gIsPlayerNewPathPoint = false; + D_80163240[playerId] = 0; + sSomeNearestPathPoint = update_player_path(playerX, playerY, playerZ, gNearestPathPointByPlayerId[playerId], player, + playerId, gPlayerPathIndex); + gCurrentNearestPathPoint = sSomeNearestPathPoint; + if (gNearestPathPointByPlayerId[playerId] != sSomeNearestPathPoint) { + gNearestPathPointByPlayerId[playerId] = sSomeNearestPathPoint; + gIsPlayerNewPathPoint = true; + update_player_completion(playerId); + } + if (gCurrentCourseId == COURSE_AWARD_CEREMONY) { + update_player_position_factor(playerId, sSomeNearestPathPoint, gPlayerPathIndex); + return; + } + if ((sSomeNearestPathPoint < 0x14) || ((gPathCountByPathIndex[gPlayerPathIndex] - 0x14) < sSomeNearestPathPoint) || + (gCurrentCourseId == COURSE_KALAMARI_DESERT)) { + var_v1 = 0; + var_t0 = 0; + if (gCurrentCourseId == COURSE_KALAMARI_DESERT) { + D_801634EC = 0; + if (player->effects & 0x200) { + D_801634EC = 1; + } + if (gIsMirrorMode != 0) { + if (playerX < 300.0f) { + var_v1 = 1; + var_t0 = 1; + } else if ((playerX < 1300.0f) && (gLapCountByPlayerId[playerId] < 2) && ((D_801634EC == 1))) { + var_v1 = 1; + var_t0 = 1; + } + } else { + if (playerX > -300.0f) { + var_v1 = 1; + var_t0 = 1; + } else { + if ((playerX > -1300.0f) && (gLapCountByPlayerId[playerId] < 2) && (D_801634EC == 1)) { + var_v1 = 1; + var_t0 = 1; + } + } + } + } else { + var_v1 = 1; + var_t0 = 1; + } + previousPlayerZ = gPreviousPlayerZ[playerId]; + if ((var_v1 != 0) && (playerZ <= gPathStartZ)) { + if (gPathStartZ < previousPlayerZ) { + gLapCountByPlayerId[playerId]++; + if ((gModeSelection == 0) && (gLapCountByPlayerId[playerId] == 5)) { + if (gGPCurrentRaceRankByPlayerIdDup[playerId] == 7) { + for (var_v0 = 0; var_v0 < NUM_PLAYERS; var_v0++) { + gLapCountByPlayerId[var_v0]--; + } + } + } + D_80163240[playerId] = 1; + update_player_completion(playerId); + reset_cpu_behaviour(playerId); + cpu_ItemStrategy[playerId].timer = 0; + if ((D_8016348C == 0) && !(player->type & PLAYER_CINEMATIC_MODE)) { + gTimePlayerLastTouchedFinishLine[playerId] = func_80009258(playerId, previousPlayerZ, playerZ); + } + } + } + if ((var_t0 != 0) && (previousPlayerZ <= gPathStartZ) && (gPathStartZ < playerZ)) { + gLapCountByPlayerId[playerId]--; + update_player_completion(playerId); + } + } + gPreviousPlayerZ[playerId] = playerZ; + if ((gCurrentCourseId == COURSE_YOSHI_VALLEY) && (gIsPlayerNewPathPoint == true)) { + yoshi_valley_cpu_path(playerId); + if (((player->type & PLAYER_HUMAN) == 0) || (player->type & PLAYER_CPU)) { + update_cpu_path_completion(playerId, player); + } + } + if ((player->type & PLAYER_HUMAN) && !(player->type & PLAYER_CPU)) { + detect_wrong_player_direction(playerId, player); + if ((gModeSelection == 0) && (gPlayerCount == 2) && (playerId == 0)) { + if (gGPCurrentRaceRankByPlayerIdDup[PLAYER_ONE] < gGPCurrentRaceRankByPlayerIdDup[PLAYER_TWO]) { + gBestRankedHumanPlayer = PLAYER_ONE; + } else { + gBestRankedHumanPlayer = PLAYER_TWO; + } + } + } else { + //???? + } + update_player_position_factor(playerId, sSomeNearestPathPoint, gPlayerPathIndex); +} +#else +GLOBAL_ASM("asm/non_matchings/cpu_vehicles_camera_path/update_player_path_completion.s") +#endif + +void update_vehicles(void) { + s32 i; + generate_player_smoke(); + D_8016337C++; + + if (gCurrentCourseId == COURSE_AWARD_CEREMONY) { + for (i = 0; i < 7; i++) { + func_8000DF8C(i); + } + return; + } + + if (D_8016337C & 1) { + if (gModeSelection == VERSUS) { + for (i = 0; i < 7; i++) { + func_8000DF8C(i); + } + } +#if !ENABLE_CUSTOM_COURSE_ENGINE + switch (gCurrentCourseId) { + case COURSE_KALAMARI_DESERT: + update_vehicle_trains(); + break; + case COURSE_DK_JUNGLE: + update_vehicle_paddle_boats(); + break; + case COURSE_TOADS_TURNPIKE: + update_vehicle_box_trucks(); + update_vehicle_school_bus(); + update_vehicle_tanker_trucks(); + update_vehicle_cars(); + break; + } +#else + +#endif + } +} + +void play_cpu_sound_effect(s32 arg0, Player* player) { + if (D_80163398[arg0] >= 0xB) { + if ((player->effects & 0x80) || (player->effects & 0x40) || (player->effects & 0x20000)) { + func_800C92CC(arg0, SOUND_ARG_LOAD(0x29, 0x00, 0x80, 0x0A)); + D_80163398[arg0] = 0; + } + } + if (D_801633B0[arg0] >= 0xB) { + if ((player->soundEffects & REVERSE_EFFECT) || (player->soundEffects & 0x01000000) || + (player->soundEffects & 2) || (player->soundEffects & 4) || (player->effects & HIT_EFFECT)) { + func_800C92CC(arg0, SOUND_ARG_LOAD(0x29, 0x00, 0x80, 0x0B)); + D_801633B0[arg0] = 0; + } + } +} + +void update_player_timer_sound(s32 playerId, UNUSED Player* unused) { + s32 otherPlayerId; + + if (gPositionSwapTimer[playerId] >= 0x65) { + for (otherPlayerId = 0; otherPlayerId < gPlayerCount; otherPlayerId++) { + // detect swap of positions + if ((gGPCurrentRaceRankByPlayerId[playerId] < gGPCurrentRaceRankByPlayerId[otherPlayerId]) && + (gGPCurrentRaceRankByPlayerId[playerId] == gPreviousGPCurrentRaceRankByPlayerId[otherPlayerId]) && + (gGPCurrentRaceRankByPlayerId[otherPlayerId] == gPreviousGPCurrentRaceRankByPlayerId[playerId])) { + func_800C92CC(playerId, SOUND_ARG_LOAD(0x29, 0x00, 0x80, 0x0D)); + gPositionSwapTimer[playerId] = 0; + } + } + } + if (gPositionSwapTimer[playerId] < 0x3E8) { + gPositionSwapTimer[playerId]++; + } + if (D_80163398[playerId] < 0xC8) { + D_80163398[playerId]++; + } + if (D_801633B0[playerId] < 0xC8) { + D_801633B0[playerId]++; + } +} + +#ifdef NON_MATCHING +#define FAKEMATCH1 0 +#define FAKEMATCH2 0 +// https://decomp.me/scratch/uJCh3 +// Lots of register allocation differences, but messing around seems to suggest they stem from 2 specific areas +// MISMATCH1: something about the loading of `playerId` is off +// MISMATCH2: something about the handling of the math is off. Not sure exactly what though +// MISMATCH3: there's a small instruction ordering issue concerning `gCourseMaxX`. No idea what to do about it +// FAKEMATCH1 is the best improvement I've seen yet, MISMATCH2/3 become the only issues. + +void update_player(s32 playerId) { + UNUSED s32 stackPadding00; + UNUSED s32 stackPadding01; + UNUSED s32 stackPadding02; + UNUSED s32 stackPadding03; + UNUSED s32 stackPadding04; + UNUSED s32 stackPadding05; + UNUSED s32 stackPadding06; + UNUSED s32 stackPadding07; + UNUSED s32 stackPadding08; + UNUSED s32 stackPadding09; + UNUSED s32 stackPadding0A; + UNUSED s32 stackPadding0B; + UNUSED s32 stackPadding0C; + UNUSED s32 stackPadding0D; + s16 var_a0_2; + s16 newAngle; + UNUSED s32 stackPadding0E; + UNUSED s32 stackPadding0F; + UNUSED s32 stackPadding10; + UNUSED s32 stackPadding11; + UNUSED s32 stackPadding12; + UNUSED s32 stackPadding13; + UNUSED s32 stackPadding14; + UNUSED s32 stackPadding15; + UNUSED s32 stackPadding16; + UNUSED s32 stackPadding17; + UNUSED s32 stackPadding18; + u16 stackPadding19; + u16 pathIndex; + f32 distX; + f32 minAngle; + s16 angle; + s16 steeringSensitivity; + s32 maxAngle; + Player* player; + TrackPathPoint* pathPoint; + f32 onePointFive = 1.5f; + + player = &gPlayers[playerId]; + if ((s32) GET_COURSE_AIMaximumSeparation >= 0) { + D_80163100[playerId] += 1; + if (playerId == 0) { + gIncrementUpdatePlayer++; + if (gIncrementUpdatePlayer & 1) { + D_80163488 += 1; + } + } + if (!(player->type & PLAYER_EXISTS)) { + gNumPathPointsTraversed[playerId] = -0x00000014; + gCourseCompletionPercentByPlayerId[playerId] = -1000.0f; + gLapCompletionPercentByPlayerId[playerId] = -1000.0f; + return; + } + D_801633E0[playerId] = 0; + if (player->pos[0] < gCourseMinX) { + D_801633E0[playerId] = 1; + } + if (gCourseMaxX < player->pos[0]) { + D_801633E0[playerId] = 2; + } + if (player->pos[2] < gCourseMinZ) { + D_801633E0[playerId] = 3; + } + // MISMATCH3 + if (gCourseMaxZ < player->pos[2]) { + D_801633E0[playerId] = 4; + } + if (!(player->unk_0CA & 2) && !(player->unk_0CA & 8)) { + gPlayerPathIndex = gPathIndexByPlayerId[playerId]; + set_current_path(gPlayerPathIndex); + switch (gCurrentCourseId) { /* irregular */ + case COURSE_KALAMARI_DESERT: + handle_trains_interactions(playerId, player); + if (playerId == 0) { + func_80013054(); + } + break; + case COURSE_DK_JUNGLE: + handle_paddleBoats_interactions(player); + break; + case COURSE_TOADS_TURNPIKE: + handle_box_trucks_interactions(playerId, player); + handle_school_buses_interactions(playerId, player); + handle_tanker_trucks_interactions(playerId, player); + handle_cars_interactions(playerId, player); + break; + } + if (player->type & PLAYER_CINEMATIC_MODE) { + player->effects &= ~REVERSE_EFFECT; + player->unk_044 &= ~0x0001; + } + update_player_path_completion(playerId, player); + if ((gCurrentCourseId != COURSE_AWARD_CEREMONY) && ((D_80163240[playerId] == 1) || (playerId == 0))) { + set_places(); + } + if (player->type & PLAYER_CPU) { + if ((gIsPlayerNewPathPoint == true) && (gCurrentCourseId != COURSE_AWARD_CEREMONY)) { + cpu_behaviour(playerId); + } + // one update it try to use an item, the other it doesn't + if ((playerId & 1) != (gIncrementUpdatePlayer & 1)) { + cpu_use_item_strategy(playerId); + } + update_player_timer_sound(playerId, player); + D_80162FD0 = 0; + switch (gModeSelection) { /* switch 1; irregular */ + case 1: /* switch 1 */ + case 2: /* switch 1 */ + case 3: /* switch 1 */ + break; + case 0: /* switch 1 */ + break; + } + D_801631E0[playerId] = false; + if ((player->effects & UNKNOWN_EFFECT_0x1000) && (gCurrentCourseId != COURSE_AWARD_CEREMONY)) { + D_801631E0[playerId] = true; + } + if ((D_801646CC == 1) || (player->type & PLAYER_CINEMATIC_MODE) || + (gCurrentCourseId == COURSE_AWARD_CEREMONY)) { + if (gCurrentCourseId != COURSE_TOADS_TURNPIKE) { + gPlayerTrackPositionFactorInstruction[playerId].target = 0.0f; + } + gPlayerTrackPositionFactorInstruction[playerId].unkC = 0.0f; + } + if (gPlayerPathIndex > 0) { + gPlayerTrackPositionFactorInstruction[playerId].target = 0.0f; + gPlayerTrackPositionFactorInstruction[playerId].unkC = 0.0f; + } + // gNearestPathPointByPlayerId[playerId] might need to be saved to a temp + gPlayerPathY[playerId] = + gTrackPaths[gPlayerPathIndex][gNearestPathPointByPlayerId[playerId]].posY + 4.3f; + if ((D_801631F8[playerId] == 1) && (D_801631E0[playerId] == false)) { + func_8002E4C4(player); + } + if (D_801631E0[playerId] == true) { + player->pos[1] = gPlayerPathY[playerId]; + } + D_801631F8[playerId] = D_801631E0[playerId]; + switch (gCurrentCourseId) { + case COURSE_YOSHI_VALLEY: + case COURSE_AWARD_CEREMONY: + gPlayerTrackPositionFactorInstruction[playerId].target = 0.0f; + break; + default: + break; + case COURSE_SKYSCRAPER: + update_player_track_position_factor_from_box_trucks(playerId); + update_player_track_position_factor_from_buses(playerId); + update_player_track_position_factor_from_tanker_truck(playerId); + update_player_track_position_factor_from_cars(playerId); + break; + } + if (D_801631E0[playerId] == true) { + D_801630E8[playerId] = 0; + player->effects &= ~0x10; + if ((playerId & 1) != (gIncrementUpdatePlayer & 1)) { + apply_cpu_turn(player, 0); + regulate_cpu_speed(playerId, gPreviousCpuTargetSpeed[playerId], player); + return; + } + if ((gPlayerCount > 0) && (gPlayerCount < 3) && (D_80163330[playerId] == 1) && + (D_8016334C[playerId] < gGPCurrentRaceRankByPlayerId[playerId])) { + gPreviousCpuTargetSpeed[playerId] = 8.333333f; + } else if (D_80162FD0 == (s16) 1U) { + gPreviousCpuTargetSpeed[playerId] = GET_COURSE_D_0D0096B8(gCCSelection); + gPlayerTrackPositionFactorInstruction[playerId].target = -0.5f; + } else if (gCurrentTrackConsecutiveCurveCountsPath[sSomeNearestPathPoint] > 0) { + gPreviousCpuTargetSpeed[playerId] = GET_COURSE_cpu_CurveTargetSpeed(gCCSelection); + } else { + gPreviousCpuTargetSpeed[playerId] = GET_COURSE_cpu_NormalTargetSpeed(gCCSelection); + } + check_ai_crossing_distance(playerId); + cpu_track_position_factor(playerId); + determine_ideal_cpu_position_offset(playerId, gCurrentNearestPathPoint); + distX = gOffsetPosition[0] - player->pos[0]; + minAngle = gOffsetPosition[2] - player->pos[2]; + if (!(player->effects & 0x80) && !(player->effects & 0x40) && !(player->effects & 0x800)) { + if (((distX * distX) + (minAngle * minAngle)) > 6400.0f) { + if (gPlayerPathIndex == 0) { + func_8000B140(playerId); + if (D_80162FF8[playerId] > 0) { + pathIndex = gCurrentNearestPathPoint + 5; + pathIndex %= gSelectedPathCount; + set_track_offset_position(pathIndex, D_80163090[playerId], gPlayerPathIndex); + } + } + player->rotation[1] = -get_angle_between_two_vectors(player->pos, gOffsetPosition); + } else { + player->rotation[1] = + gPathExpectedRotation[gPlayerPathIndex] + [(gCurrentNearestPathPoint + 4) % gSelectedPathCount]; + } + } + apply_cpu_turn(player, 0); + regulate_cpu_speed(playerId, gPreviousCpuTargetSpeed[playerId], player); + return; + } + if ((D_801630E8[playerId] == 1) || (D_801630E8[playerId] == -1)) { + player->effects |= UNKNOWN_EFFECT_0x10; + } + if (D_801630E8[playerId] != 0) { + sPlayerAngle[playerId] = -get_angle_between_two_vectors(player->oldPos, player->pos); + var_a0_2 = + (gCurrentPathPointExpectedRotationPath[(sSomeNearestPathPoint + 2) % gSelectedPathCount] * + 0x168) / + 65535; + newAngle = (sPlayerAngle[playerId] * 0x168) / 65535; + if (var_a0_2 < -0xB4) { + var_a0_2 += 0x168; + } + if (var_a0_2 > 0xB4) { + var_a0_2 -= 0x168; + } + if (newAngle < -0xB4) { + newAngle += 0x168; + } + if (newAngle > 0xB4) { + newAngle -= 0x168; + } + steeringSensitivity = var_a0_2 - newAngle; + if (steeringSensitivity < -0xB4) { + steeringSensitivity += 0x168; + } + if (steeringSensitivity > 0xB4) { + steeringSensitivity -= 0x168; + } + switch (D_801630E8[playerId]) { + case -1: + if (steeringSensitivity > 5) { + D_801630E8[playerId] = 0; + player->effects &= ~0x10; + } + break; + case 1: + if (steeringSensitivity < -5) { + D_801630E8[playerId] = 0; + player->effects &= ~0x10; + } + break; + default: + break; + } + } + // MISMATCH1 +#if FAKEMATCH2 == 1 + stackPadding00 = (playerId & 1) != (gIncrementUpdatePlayer & 1); + if (stackPadding00) { +#else + if ((playerId & 1) != (gIncrementUpdatePlayer & 1)) { +#endif + apply_cpu_turn(player, gPreviousAngleSteering[playerId]); + regulate_cpu_speed(playerId, gPreviousCpuTargetSpeed[playerId], player); + return; + } + gIsPlayerInCurve[playerId] = are_in_curve(playerId, sSomeNearestPathPoint); + determine_ideal_cpu_position_offset(playerId, sSomeNearestPathPoint); + if (gCurrentCourseId != COURSE_AWARD_CEREMONY) { + if (gNumPathPointsTraversed[playerId] < 0xB) { + pathIndex = gCurrentNearestPathPoint; + if ((gNumPathPointsTraversed[playerId] > 0) && (gCurrentCourseId == COURSE_TOADS_TURNPIKE)) { + pathIndex += 0x14; + pathIndex %= gSelectedPathCount; + set_track_offset_position(pathIndex, 0.0f, 0); + gPlayerTrackPositionFactorInstruction[playerId].target = 0.0f; + } else { + pathIndex += 8; + pathIndex %= gSelectedPathCount; + set_track_offset_position(pathIndex, gTrackPositionFactor[playerId], gPlayerPathIndex); + gPlayerTrackPositionFactorInstruction[playerId].current = gTrackPositionFactor[playerId]; + } + } + if ((D_80162FD0 == 1) && (D_80162FF8[playerId] == 0)) { + pathIndex = gCurrentNearestPathPoint + 7; + pathIndex %= gSelectedPathCount; + set_track_offset_position(pathIndex, -0.7f, gPlayerPathIndex); + } + if (gPlayerPathIndex == 0) { + func_8000B140(playerId); + if (D_80162FF8[playerId] > 0) { + pathIndex = gCurrentNearestPathPoint + 5; +#if FAKEMATCH1 == 1 + if (1) {} + if (1) {} + if (1) {} + if (1) {} + if (1) {} + if (1) {} +#endif + pathIndex %= gSelectedPathCount; + set_track_offset_position(pathIndex, D_80163090[playerId], gPlayerPathIndex); + } + } + } + if (gCurrentCourseId == COURSE_AWARD_CEREMONY) { + switch (D_80163410[playerId]) { /* switch 3; irregular */ + case 3: /* switch 3 */ + gOffsetPosition[0] = D_80163418[playerId]; + gOffsetPosition[2] = D_80163438[playerId]; + break; + case 4: /* switch 3 */ + pathPoint = &gTrackPaths[playerId][(gNearestPathPointByPlayerId[playerId] + 0xA) % + gPathCountByPathIndex[playerId]]; + gOffsetPosition[0] = pathPoint->posX; + gOffsetPosition[2] = pathPoint->posZ; + break; + } + } + gOffsetPosition[0] = (gPreviousPlayerAiOffsetX[playerId] + gOffsetPosition[0]) * 0.5f; // average + gOffsetPosition[2] = (gPreviousPlayerAiOffsetZ[playerId] + gOffsetPosition[2]) * 0.5f; // average + gPreviousPlayerAiOffsetX[playerId] = gOffsetPosition[0]; + gPreviousPlayerAiOffsetZ[playerId] = gOffsetPosition[2]; + minAngle = onePointFive * 182.0f; + maxAngle = -onePointFive * 182.0f; + // MISMATCH2 + // This fixes part of the register allocation problems, makes fixing others + // harder though. Needs more investigation + // angle = (-get_angle_between_two_vectors(player->pos, gOffsetPosition)) - (var_a1 = + // player->rotation[1]); + stackPadding19 = -get_angle_between_two_vectors(player->pos, gOffsetPosition) - player->rotation[1]; + newAngle = stackPadding19; + angle = newAngle; + if ((s16) minAngle < newAngle) { + angle = minAngle; + } + if (angle < (s16) maxAngle) { + angle = maxAngle; + } + steeringSensitivity = GET_COURSE_AISteeringSensitivity; + switch (gCurrentTrackSectionTypesPath[playerId]) { /* switch 4; irregular */ + case RIGHT_CURVE: /* switch 4 */ + if (gTrackPositionFactor[playerId] > (0.5f * 1.0f)) { + steeringSensitivity = 0x0014; + } + if (gTrackPositionFactor[playerId] < -0.5f) { + steeringSensitivity = 0x0035; + } + break; + case LEFT_CURVE: /* switch 4 */ + if (gTrackPositionFactor[playerId] > 0.5f) { + steeringSensitivity = 0x0035; + } + if (gTrackPositionFactor[playerId] < -0.5f) { + steeringSensitivity = 0x0014; + } + break; + } + if ((cpu_BehaviourState[playerId] == cpu_BEHAVIOUR_STATE_RUNNING) && + ((gTrackPositionFactor[playerId] > 0.9f) || (gTrackPositionFactor[playerId] < -0.9f))) { + D_801630E8[playerId] = 0; + player->effects &= ~0x10; + } + if (player->effects & 2) { + switch (D_801630E8[playerId]) { + case 1: + newAngle = 0x0035; + break; + case -1: + newAngle = -0x0035; + break; + default: + newAngle = + (gPreviousAngleSteering[playerId] + ((angle * steeringSensitivity) / minAngle)) / 2; + break; + } + } else if (player->effects & (UNKNOWN_EFFECT_0x10000000 | UNKNOWN_EFFECT_0xC)) { + newAngle = 0; + } else { + newAngle = (gPreviousAngleSteering[playerId] + ((angle * steeringSensitivity) / minAngle)) / 2; + } + apply_cpu_turn(player, newAngle); + gPreviousAngleSteering[playerId] = newAngle; + if ((gIsPlayerInCurve[playerId] == true) || (D_801630E8[playerId] == 1) || + (D_801630E8[playerId] == -1) || + (player->effects & (UNKNOWN_EFFECT_0x10000000 | UNKNOWN_EFFECT_0xC))) { + cpu_TargetSpeed[playerId] = GET_COURSE_cpu_CurveTargetSpeed(gCCSelection); + } else { + cpu_TargetSpeed[playerId] = GET_COURSE_cpu_NormalTargetSpeed(gCCSelection); + } + if ((gTrackPositionFactor[playerId] > 0.9f) || (gTrackPositionFactor[playerId] < -0.9f)) { + cpu_TargetSpeed[playerId] = GET_COURSE_cpu_OffTrackTargetSpeed(gCCSelection); + } + if (D_80162FD0 == 1) { + cpu_TargetSpeed[playerId] = GET_COURSE_D_0D0096B8(gCCSelection); + } + if ((D_801630E8[playerId] == 2) || (D_801630E8[playerId] == -2) || (D_801630E8[playerId] == 3)) { + cpu_TargetSpeed[playerId] = 3.3333333f; + } + gCurrentCpuTargetSpeed = cpu_TargetSpeed[playerId]; + player->effects &= ~UNKNOWN_EFFECT_0x200000; + gPreviousCpuTargetSpeed[playerId] = gCurrentCpuTargetSpeed; + check_ai_crossing_distance(playerId); + regulate_cpu_speed(playerId, gCurrentCpuTargetSpeed, player); + } + } + } +} +#undef FAKEMATCH1 +#undef FAKEMATCH2 +#else +GLOBAL_ASM("asm/non_matchings/cpu_vehicles_camera_path/update_player.s") +#endif + +#ifdef NON_MATCHING +// Lots of work left to do, might be funtionally accurate? +void func_8000B140(s32 playerId) { + UNUSED f32 stackPadding0; + UNUSED f32 stackPadding1; + UNUSED f32 stackPadding2; + UNUSED f32 stackPadding3; + UNUSED f32 stackPadding4; + UNUSED f32 stackPadding5; + UNUSED f32 stackPadding6; + UNUSED f32 stackPadding7; + f32 temp_f0_2; + f32 temp_f12; + f32 temp_f14; + f32 temp_f16; + f32 temp_f22; + f32 temp_f2; + f32 var_f18; + f32 var_f20; + s16 spB0[8]; + UNUSED f32 stackPadding8; + s16 sp9C[8]; + UNUSED f32 stackPadding9; + f32 sp74[8]; + s32 temp_a1_2; + s16 temp_v1_2; + s16 currPathPoint; + s32 j; + s32 i; + Player* player; + + player = &gPlayers[playerId]; + + if (player->effects & UNKNOWN_EFFECT_0x10) + return; + + if (D_801630E8[playerId] == 1) + return; + if (D_801630E8[playerId] == -1) + return; + if (gTrackPositionFactor[playerId] < -1.0f) + return; + if (gTrackPositionFactor[playerId] > 1.0f) + return; + + // Exclude heavyweights + if (player->characterId == WARIO) + return; + if (player->characterId == BOWSER) + return; + if (player->characterId == DK) + return; + // Skip if player has starman + if (player->effects & STAR_EFFECT) + return; + + currPathPoint = gNearestPathPointByPlayerId[playerId]; + temp_f22 = (player->speed / 18.0f) * 216.0f; + for (i = 0; i < 8; i++) { + sp9C[i] = -1; + spB0[i] = 0x03E8; + } + if (D_80163010[playerId] > 0) { + D_80163010[playerId]--; + if (D_80163010[playerId] <= 0) { + D_80162FF8[playerId] = 0; + } + } + j = 0; + for (i = 0; (j < 2) && (i < 8); i++) { + if (i == playerId) + continue; + player = &gPlayers[i]; + if (!(player->type & PLAYER_EXISTS)) + continue; + temp_f2 = (temp_f22) -5.0f; + temp_v1_2 = gNearestPathPointByPlayerId[i]; + temp_f0_2 = (player->speed / 18.0f) * 216.0f; + if (temp_f0_2 < temp_f2) { + if (is_path_point_in_range(temp_v1_2, currPathPoint, 0U, 0x0014U, gSelectedPathCount) > 0) { + temp_a1_2 = temp_v1_2 - currPathPoint; + sp9C[j] = i; + if (temp_a1_2 > 0) { + spB0[j] = temp_a1_2; + } else { + spB0[j] = (temp_v1_2 + gSelectedPathCount) - currPathPoint; + } + sp74[j] = temp_f2 - temp_f0_2; + j += 1; + } + } + } + if (j != 0) { + var_f18 = 1.0f; + var_f20 = -1.0f; + for (i = 0; i < j; i++) { + temp_f2 = gTrackPositionFactor[sp9C[i]]; + if ((temp_f2 > -1.0f) && (temp_f2 < 1.0f)) { + temp_f12 = sp74[i] + 10.0f; + temp_f12 *= 0.2f * (20.0f / (spB0[i] + 20.0f)); + temp_f12 /= 20.0f; + if ((var_f18 == 1.0f) && (var_f20 == -1.0f)) { + var_f18 = temp_f2 - temp_f12; + var_f20 = temp_f2 + temp_f12; + } else { + temp_f14 = temp_f2 - temp_f12; + temp_f16 = temp_f2 + temp_f12; + if ((temp_f14 < 1.0f) && (temp_f16 > 1.0f)) { + var_f18 = temp_f14; + } + if ((temp_f16 > -1.0f) && (temp_f14 < -1.0f)) { + var_f20 = temp_f16; + } + } + } + } + if (!(var_f20 < var_f18) && !(gTrackPositionFactor[playerId] < var_f18) && + !(var_f20 < gTrackPositionFactor[playerId])) { + if (var_f20 > 1.0f) { + var_f20 = 1.0f; + } + if (var_f18 < -1.0f) { + var_f18 = -1.0f; + } + if ((var_f18 + 1.0f) < (1.0f - var_f20)) { + D_80163010[playerId] = 0x003C; + D_80162FF8[playerId] = 1; + D_80163090[playerId] = var_f20; + } else { + D_80163010[playerId] = 0x003C; + D_80162FF8[playerId] = 2; + D_80163090[playerId] = var_f18; + } + } + } +} +#else +GLOBAL_ASM("asm/non_matchings/cpu_vehicles_camera_path/func_8000B140.s") +#endif + +// utils track position + +#include "cpu_vehicles_camera_path/path_utils.inc.c" + +// bomb_kart utils + +#include "cpu_vehicles_camera_path/bomb_kart.inc.c" + +// actor utils + +#include "cpu_vehicles_camera_path/actor_utils.inc.c" + +void func_8000F0E0(void) { + s32 i; + for (i = 0; i < 4; i++) { + D_80164670[i] = 0; + D_80164678[i] = 0; + } +} + +void func_8000F124(void) { + s32 shouldContinue; + s32 i, j; + + for (j = 0; j < 2; j++) { + D_80163348[j] = 0; + } + + if (gDemoMode == 1) { + return; + } + if (gModeSelection != GRAND_PRIX) { + return; + } + + for (i = 0; i < 2; i++) { + + while (1) { + D_80163348[i] = random_int(NUM_PLAYERS); + + if (gPlayerCount > 2) { + break; + } + if (gPlayerCount < 1) { + break; + } + + shouldContinue = false; + + for (j = 0; j < gPlayerCount; j++) { + if (gCharacterSelections[j] == D_80163348[i]) { + shouldContinue = true; + } + } + for (j = 0; j < i; j++) { + if (D_80163348[j] == D_80163348[i]) { + shouldContinue = true; + } + } + if (shouldContinue == false) { + break; + } + } + } +} + +// Delete track path +void clear_pathPoint(TrackPathPoint* arg0, size_t size) { + bzero((void*) arg0, size * sizeof(TrackPathPoint)); +} + +// Appears to allocate memory for each course. +void init_course_path_point(void) { + + struct _struct_gCoursePathSizes_0x10* ptr = &GET_COURSE_PathSizes; + s32 temp; + s32 i; + + gSizePath[0] = (s32) ptr->firstPath; + gSizePath[1] = (s32) ptr->secondPath; + gSizePath[2] = (s32) ptr->thirdPath; + gSizePath[3] = (s32) ptr->fourthPath; + + temp = ptr->unk8; + gVehicle2DPathPoint = get_next_available_memory_addr(temp * 4); + + // Podium ceremony appears to allocate 1 * 8 bytes of data. Which would be aligned to 0x10. + for (i = 0; i < 4; i++) { + gTrackPaths[i] = get_next_available_memory_addr(gSizePath[i] * sizeof(TrackPathPoint)); + gTrackLeftPaths[i] = get_next_available_memory_addr(gSizePath[i] * sizeof(TrackPathPoint)); + gTrackRightPaths[i] = get_next_available_memory_addr(gSizePath[i] * sizeof(TrackPathPoint)); + gTrackSectionTypes[i] = get_next_available_memory_addr(gSizePath[i] * sizeof(s16)); + gPathExpectedRotation[i] = get_next_available_memory_addr(gSizePath[i] * sizeof(s16)); + gTrackConsecutiveCurveCounts[i] = get_next_available_memory_addr(gSizePath[i] * sizeof(s16)); + } + + gCurrentTrackPath = gTrackPaths[0]; + gCurrentTrackLeftPath = gTrackLeftPaths[0]; + gCurrentTrackRightPath = gTrackRightPaths[0]; + gCurrentTrackSectionTypesPath = gTrackSectionTypes[0]; + gCurrentPathPointExpectedRotationPath = gPathExpectedRotation[0]; + gCurrentTrackConsecutiveCurveCountsPath = gTrackConsecutiveCurveCounts[0]; + + // zero allocated memory? + //! @warning does not appear to zero all the above allocated variables. + for (i = 0; i < 4; i++) { + clear_pathPoint(gTrackPaths[i], gSizePath[i]); + clear_pathPoint(gTrackLeftPaths[i], gSizePath[i]); + clear_pathPoint(gTrackRightPaths[i], gSizePath[i]); + } + + // Skip several cpu cycles. + for (i = 0; i < 4; i++) {} + + for (i = 0; i < 4; i++) { + if (gSizePath[i] >= 2) { + load_track_path(i); + calculate_track_boundaries(i); + analize_track_section(i); + analyse_angle_path(i); + analisze_curved_path(i); + } + } + + gSelectedPathCount = *gPathCountByPathIndex; +#if !ENABLE_CUSTOM_COURSE_ENGINE + switch (gCurrentCourseId) { + case COURSE_KALAMARI_DESERT: + generate_train_path(); + init_vehicles_trains(); + break; + case COURSE_DK_JUNGLE: + generate_ferry_path(); + init_vehicles_ferry(); + break; + case COURSE_TOADS_TURNPIKE: + init_vehicles_box_trucks(); + init_vehicles_school_buses(); + init_vehicles_trucks(); + init_vehicles_cars(); + break; + } +#else + +#endif + set_bomb_kart_spawn_positions(); + func_8000EEDC(); +} + +void init_players(void) { + + UNUSED Camera* camera; + s32 temp_v0_3; + s32 i; + TrackPositionFactorInstruction* var_s5; + UNUSED s32 temp_v1; + UNUSED s32 pad; + + for (i = 0; i < NUM_PLAYERS; i++) { + Player* player = &gPlayerOne[i]; + + gPreviousAngleSteering[i] = 0; + D_80162FF8[i] = 0; + D_80163010[i] = 0; + if (gCurrentCourseId < (NUM_COURSES - 1)) { + update_player_position_factor(i, 0, 0); + } + cpu_TargetSpeed[i] = GET_COURSE_cpu_CurveTargetSpeed(gCCSelection); + D_801630E8[i] = 0; + D_80163100[i] = 0; + gPreviousPlayerAiOffsetX[i] = 0.0f; + gPreviousPlayerAiOffsetZ[i] = 0.0f; + gPreviousCpuTargetSpeed[i] = 0.0f; + gLapCountByPlayerId[i] = -1; + gCourseCompletionPercentByPlayerId[i] = 0.0f; + gTimePlayerLastTouchedFinishLine[i] = 0.0f; + if (gModeSelection == GRAND_PRIX) { + if (1) {}; + if (1) {}; // Maybe some debug code? + gGPCurrentRaceRankByPlayerId[i] = (s32) D_80165270[i]; + gPreviousGPCurrentRaceRankByPlayerId[i] = (s32) D_80165270[i]; + } else { + gGPCurrentRaceRankByPlayerId[i] = i; + gPreviousGPCurrentRaceRankByPlayerId[i] = i; + } + temp_v0_3 = gGPCurrentRaceRankByPlayerId[i]; + gGPCurrentRacePlayerIdByRank[temp_v0_3] = (s16) i; + D_80164378[temp_v0_3] = (s16) i; + gGPCurrentRaceRankByPlayerIdDup[i] = temp_v0_3; + gWrongDirectionCounter[i] = 0; + gIsPlayerWrongDirection[i] = 0; + D_801631E0[i] = false; + D_801631F8[i] = 0; + gNumPathPointsTraversed[i] = -20; + gPreviousLapProgressScore[i] = -20; + gGetPlayerByCharacterId[gPlayers[i].characterId] = (s16) i; + gTrackPositionFactor[i] = 0.0f; + D_80163090[i] = 0.0f; + var_s5 = &gPlayerTrackPositionFactorInstruction[i]; + var_s5->unkC = GET_COURSE_AIMinimumSeparation * (f32) (((i + 1) % 3) - 1); + var_s5->target = var_s5->unkC; + var_s5->current = 0.0f; + var_s5->step = 0.015f; + reset_cpu_behaviour_none(i); + gSpeedCPUBehaviour[i] = 0; + bInMultiPathSection[i] = 0; + D_80163398[i] = 0; + D_801633B0[i] = 0; + gPositionSwapTimer[i] = 0; + D_801633F8[i] = 0; + gPlayersTrackSectionId[i] = 0; + gPreviousPlayerZ[i] = player->pos[2]; + gCurrentPlayerLookAhead[i] = 6; + if (gPlayers[i].type & PLAYER_HUMAN) { + D_80163330[i] = 3; + + } else { + D_80163330[i] = 0; + } + + cpu_enteringPathIntersection[i] = 0; + cpu_exitingPathIntersection[i] = 0; + D_80163128[i] = -1; + D_80163150[i] = -1; + D_80164538[i] = -1; + D_801634C0[i] = 0; + bStopAICrossing[i] = 0; + gIsPlayerInCurve[i] = true; + } + +#ifdef AVOID_UB + for (i = 0; i < NUM_CROSSINGS; i++) { + sCrossingActiveTimer[i] = 0; + } +#else + sCrossingActiveTimer[0] = 0; + sCrossingActiveTimer[1] = 0; +#endif + if (gDemoMode == DEMO_MODE_INACTIVE) { + + if (gModeSelection == GRAND_PRIX) { + for (i = 0; i < 2; i++) { + D_80163344[i] = gGetPlayerByCharacterId[D_80163348[i]]; + D_80163330[D_80163344[i]] = 1; + D_8016334C[D_80163344[i]] = i; + } + } + } + if ((gDemoUseController == 1) && (gCurrentCourseId != COURSE_AWARD_CEREMONY)) { + for (i = 0; i < NUM_PLAYERS; i++) { + D_80163330[i] = 0; + } + if (gModeSelection == VERSUS) { + + D_80163344[0] = cameras->playerId; + D_80163330[D_80163344[0]] = 1; + D_8016334C[D_80163344[0]] = 0; + + for (i = 1; i < 2; i++) { + D_80163344[i] = cameras[i].playerId; + D_80163330[D_80163344[i]] = 1; + D_8016334C[D_80163344[i]] = i; + } + } + } + + for (i = 0; i < NUM_PLAYERS; i++) { + if (1) {}; + gPathIndexByPlayerId[i] = 0; + gNearestPathPointByPlayerId[i] = + gPathCountByPathIndex[gPathIndexByPlayerId[i]] - gGPCurrentRaceRankByPlayerId[i] - 4; + } + + gIsInExtra = false; + if (gCCSelection == CC_EXTRA) { + gIsInExtra = true; + } + + for (i = 0; i < 30; i++) { + D_80162F10[i] = -1; + D_80162F50[i] = -1; + } + + D_801631CC = 100000; // 100,000 + D_80164698 = 0.0f; + D_8016469C = 100.0f; + D_801646A0 = 0.0f; + D_80164358 = 0; + D_8016435A = 1; + D_8016435C = 1; + gBestRankedHumanPlayer = PLAYER_ONE; + gIncrementUpdatePlayer = 0; + D_8016337C = 0; + gPathStartZ = (f32) gTrackPaths[0][0].posZ; // [i][2] + D_801634F0 = 0; + D_801634F4 = 0; + D_80163488 = 0; + D_8016348C = 0; + D_801634EC = 0; + func_8001AB00(); + if (gDemoUseController == 1) { + if (gDemoMode == 1) { + + for (i = 0; i < NUM_PLAYERS; i++) { + if (D_80163330[i] == 1) { + gPlayers[i].soundEffects |= 0x02000000; + } + } + } + } + copy_courses_cpu_behaviour(); +} + +#include "cpu_vehicles_camera_path/path_calc.inc.c" + +#include "cpu_vehicles_camera_path/behaviour_utils.inc.c" + +#include "cpu_vehicles_camera_path/vehicle_utils.inc.c" + +void func_80014D30(s32 cameraId, s32 pathIndex) { + s16 cameraPathPoint; + TrackPathPoint* temp_v0; + + cameraPathPoint = gNearestPathPointByCameraId[cameraId]; + temp_v0 = &gTrackPaths[pathIndex][cameraPathPoint]; + check_bounding_collision(&cameras[cameraId].collision, 10.0f, (f32) temp_v0->posX, (f32) temp_v0->posY + 30.0f, + (f32) temp_v0->posZ); +} + +void func_80014DE4(s32 cameraIndex) { + s32 cameraId; + + D_801646CC = 0; + D_80164678[cameraIndex] = D_80164670[cameraIndex]; + if ((gModeSelection != 1) && ((gCourseIndexInCup == COURSE_ONE) || (gDemoMode == (u16) 1))) { + D_80164678[cameraIndex] = 0; + } else if ((D_80164678[cameraIndex] != 0) && (D_80164678[cameraIndex] != (s16) 1) && + (D_80164678[cameraIndex] != 2) && (D_80164678[cameraIndex] != 3)) { + D_80164678[cameraIndex] = 0; + } + D_80164680[cameraIndex] = -1; + D_80163238 = 0; + D_801646C0[cameraIndex] = 0; + D_801646C8 = 0; + D_801646D0[cameraIndex].unk0 = 0; + D_801646D0[cameraIndex].unk2 = 0; + D_801646D0[cameraIndex].unk4 = 0; + if ((gModeSelection == 1) && (gCourseMapInit == 0)) { + D_80164678[cameraIndex] = 0; + } + + for (cameraId = 0; cameraId < 4; cameraId++) { + gNearestPathPointByCameraId[cameraId] = 0; + } +} + +f32 func_80014EE4(f32 arg0, s32 arg1) { + f32 temp_f0; + f64 temp_f2; + + temp_f0 = D_80164498[arg1]; + switch (D_80164678[arg1]) { /* irregular */ + default: + arg0 = 40.0f; + break; + case 0: + temp_f2 = 40.0; + temp_f2 += temp_f0; + if (temp_f2 < arg0) { + arg0 -= 1.0; + if (arg0 < temp_f2) { + arg0 = temp_f2; + } + } + if (arg0 < temp_f2) { + arg0 += 1.0; + if (temp_f2 < arg0) { + arg0 = temp_f2; + ; + } + } + break; + case 1: + temp_f2 = 60.0; + temp_f2 += temp_f0; + if (arg0 < temp_f2) { + arg0 += 1.0; + if (temp_f2 < arg0) { + arg0 = temp_f2; + } + } + if (temp_f2 < arg0) { + arg0 -= 1.0; + if (arg0 < temp_f2) { + arg0 = temp_f2; + ; + } + } + break; + case 3: + temp_f2 = 60.0; + temp_f2 += temp_f0; + if (arg0 < temp_f2) { + arg0 += 0.5; + if (temp_f2 < arg0) { + arg0 = temp_f2; + } + } + if (temp_f2 < arg0) { + arg0 -= 0.5; + if (arg0 < temp_f2) { + arg0 = temp_f2; + } + } + break; + case 2: + temp_f2 = 60.0; + temp_f2 += temp_f0; + if (arg0 < temp_f2) { + arg0 += 1.0; + if (temp_f2 < arg0) { + arg0 = temp_f2; + } + } + if (temp_f2 < arg0) { + arg0 -= 1.0; + if (arg0 < temp_f2) { + arg0 = temp_f2; + } + } + break; + } + return arg0; +} + +void calculate_camera_up_vector(Camera* camera, s32 cameraIndex) { + f32 xnorm; + f32 ynorm; + f32 znorm; + f32 xdiff; + f32 ydiff; + f32 zdiff; + f32 distance; + f32 sp28; + u16 thing; + + thing = D_801646C0[cameraIndex]; + if (thing == 0) { + camera->up[0] = 0.0f; + camera->up[2] = 0.0f; + camera->up[1] = 1.0f; + } else { + xdiff = camera->lookAt[0] - camera->pos[0]; + ydiff = camera->lookAt[1] - camera->pos[1]; + zdiff = camera->lookAt[2] - camera->pos[2]; + distance = sqrtf((xdiff * xdiff) + (ydiff * ydiff) + (zdiff * zdiff)); + xnorm = xdiff / distance; + ynorm = ydiff / distance; + znorm = zdiff / distance; + sp28 = 1.0 - coss(thing); + camera->up[0] = (sp28 * xnorm * ynorm) - (sins(thing) * znorm); + camera->up[1] = coss(thing) + (sp28 * ynorm * ynorm); + camera->up[2] = (sins(thing) * xnorm) + (sp28 * ynorm * znorm); + } +} + +UNUSED void func_8001530C(void) { +} + +void func_80015314(s32 playerId, UNUSED f32 arg1, s32 cameraId) { + Camera* temp_a0; + Player* temp_a1; + + // wtf is up with the pointer accesses here? + // What aren't they just doing thing = &some_pointer[some_index]? + temp_a1 = gPlayerOne; + temp_a0 = camera1; + temp_a1 += playerId; + temp_a0 += cameraId; + temp_a0->unk_2C = temp_a1->rotation[1]; + func_80015390(temp_a0, temp_a1, 0); +} + +void func_80015390(Camera* camera, UNUSED Player* player, UNUSED s32 arg2) { + UNUSED s32 pad[6]; + f32 temp_f12; + f32 sp90; + f32 temp_f14; + Player* temp_s1; + f32 sp84; + f32 sp80; + f32 sp7C; + UNUSED Vec3f pad2; + Vec3f sp64; + UNUSED s32 pad3[9]; + s16 var_a2; + + /* + Doing the more sensible: + temp_s1 = &gPlayerOne[camera->playerId]; + leads to some regalloc differences + */ + temp_s1 = gPlayerOne; + temp_s1 += camera->playerId; + if (temp_s1->unk_078 == 0) { + var_a2 = 0x0064; + } else if (temp_s1->unk_078 < 0) { + var_a2 = 0xA0 - (temp_s1->unk_078 / 16); + } else { + var_a2 = 0xA0 + (temp_s1->unk_078 / 16); + } + if (!((temp_s1->effects & 0x80) || (temp_s1->effects & 0x40))) { + adjust_angle(&camera->unk_2C, temp_s1->rotation[1], var_a2); + } + func_8001D794(temp_s1, camera, sp64, &sp84, &sp80, &sp7C, camera->unk_2C); + check_bounding_collision(&camera->collision, 10.0f, sp84, sp80, sp7C); + camera->lookAt[0] = sp64[0]; + camera->lookAt[1] = sp64[1]; + camera->lookAt[2] = sp64[2]; + camera->pos[0] = sp84; + camera->pos[1] = sp80; + camera->pos[2] = sp7C; + temp_f12 = camera->lookAt[0] - camera->pos[0]; + sp90 = camera->lookAt[1] - camera->pos[1]; + temp_f14 = camera->lookAt[2] - camera->pos[2]; + camera->rot[1] = atan2s(temp_f12, temp_f14); + camera->rot[0] = atan2s(sqrtf((temp_f12 * temp_f12) + (temp_f14 * temp_f14)), sp90); + camera->rot[2] = 0; +} + +void func_80015544(s32 playerId, f32 arg1, s32 cameraId, s32 pathIndex) { + Camera* camera; + + f32 temp_f12; + f32 temp_f2; + s32 test = gPathCountByPathIndex[pathIndex]; + + D_80164688[cameraId] = arg1; + camera = cameras + cameraId; + gNearestPathPointByCameraId[cameraId] = (gNearestPathPointByPlayerId[playerId] + 10) % test; + + set_track_offset_position(gNearestPathPointByCameraId[cameraId], arg1, pathIndex); + + D_801645F8[cameraId] = gOffsetPosition[0]; + D_80164638[cameraId] = gOffsetPosition[2]; + + temp_f2 = (f32) gTrackPaths[pathIndex][gNearestPathPointByCameraId[cameraId]].posY; + + temp_f12 = get_surface_height(gOffsetPosition[0], (f32) (temp_f2 + 30.0), gOffsetPosition[2]); + if ((temp_f12 < (temp_f2 - 20.0)) || (temp_f12 >= 3000.0)) { + D_80164618[cameraId] = (f32) (temp_f2 + 10.0); + } else { + D_80164618[cameraId] = (f32) (temp_f12 + 10.0); + } + D_80164648[cameraId] = 0.0f; + camera->pos[0] = D_801645F8[cameraId]; + camera->pos[1] = D_80164618[cameraId]; + camera->pos[2] = D_80164638[cameraId]; +} + +void func_8001577C(Camera* camera, UNUSED Player* playerArg, UNUSED s32 arg2, s32 cameraId) { + s16 cameraPathPoint; + s16 playerPathPoint; + UNUSED s32 pad; + f32 xdiff; + f32 ydiff; + f32 zdiff; + UNUSED s32 pad2; + s32 playerId; + UNUSED s32 pad3[9]; + Player* player; + s32 pathPointDiff; + s32 pathIndex; + + playerId = camera->playerId; + pathIndex = gPathIndexByPlayerId[playerId]; + player = gPlayerOne; + player += playerId; + gNearestPathPointByCameraId[cameraId] = + func_8000D33C(camera->pos[0], camera->pos[1], camera->pos[2], gNearestPathPointByCameraId[cameraId], pathIndex); + playerPathPoint = gNearestPathPointByPlayerId[playerId]; + cameraPathPoint = gNearestPathPointByCameraId[cameraId]; + if (is_path_point_in_range(playerPathPoint, cameraPathPoint, 0x0032U, 0x000FU, gPathCountByPathIndex[pathIndex]) <= + 0) { + func_8001A348(cameraId, D_80164688[cameraId], D_80164680[cameraId]); + } else { + if (gTrackPositionFactor[playerId] < (-0.7)) { + pathPointDiff = playerPathPoint - cameraPathPoint; + if ((D_80164688[cameraId] < (-0.5)) && ((pathPointDiff * pathPointDiff) < 5)) { + func_8001A348(cameraId, 1.0f, 3); + goto alable; + } + } + // clang-format off + // I hate this, but a fakematch is a fakematch + if (gTrackPositionFactor[playerId] > 0.7) { pathPointDiff = playerPathPoint - cameraPathPoint; if ((D_80164688[cameraId] > 0.5) && ((pathPointDiff * pathPointDiff) < 5)) { + func_8001A348(cameraId, -1.0f, 2); + // clang-format on + } + } + } +alable: + camera->pos[0] = D_801645F8[cameraId]; + camera->pos[1] = D_80164618[cameraId]; + camera->pos[2] = D_80164638[cameraId]; + camera->lookAt[0] = player->pos[0]; + camera->lookAt[1] = player->pos[1] + 6.0; + camera->lookAt[2] = player->pos[2]; + func_80014D30(cameraId, pathIndex); + xdiff = camera->lookAt[0] - camera->pos[0]; + ydiff = camera->lookAt[1] - camera->pos[1]; + zdiff = camera->lookAt[2] - camera->pos[2]; + camera->rot[1] = atan2s(xdiff, zdiff); + camera->rot[0] = atan2s(sqrtf((xdiff * xdiff) + (zdiff * zdiff)), ydiff); + camera->rot[2] = 0; +} + +void func_80015A9C(s32 playerId, f32 arg1, s32 cameraId, s16 pathIndex) { + Camera* camera = cameras + cameraId; + + D_80164688[cameraId] = arg1; + gNearestPathPointByCameraId[cameraId] = gNearestPathPointByPlayerId[playerId] + 10; + gNearestPathPointByCameraId[cameraId] = (gNearestPathPointByCameraId[cameraId]) % gPathCountByPathIndex[pathIndex]; + + set_track_offset_position(gNearestPathPointByCameraId[cameraId], arg1, pathIndex); + + D_801645F8[cameraId] = gOffsetPosition[0]; + D_80164618[cameraId] = (f32) gTrackPaths[pathIndex][gNearestPathPointByCameraId[cameraId]].posY; + D_80164638[cameraId] = gOffsetPosition[2]; + + D_80164648[cameraId] = gPlayers[playerId].speed / 5.0f; + if ((f64) D_80164648[cameraId] < 0.0) { + D_80164648[cameraId] = 0.0f; + } + + camera->pos[0] = D_801645F8[cameraId]; + camera->pos[1] = D_80164618[cameraId]; + camera->pos[2] = D_80164638[cameraId]; +} + +void func_80015C94(Camera* camera, UNUSED Player* unusedPlayer, UNUSED s32 arg2, s32 cameraId) { + s16 playerPathPoint; + s16 cameraPathPoint; + UNUSED s32 stackPadding0; + f32 xdiff2; + f32 ydiff2; + f32 zdiff2; + Player* player; + s32 playerId; + f32 midX; + f32 midY; + f32 midZ; + f32 xdiff; + f32 ydiff; + f32 zdiff; + f32 distance; + UNUSED s32 stackPadding1; + s16 pathPoint1; + s16 pathPoint2; + UNUSED f32 var_f18; + UNUSED f32 var_f20; + f32 temp_f2_2; + s32 pathIndex; + + playerId = camera->playerId; + player = gPlayerOne; + player += playerId; + D_80163238 = playerId; + pathIndex = gPathIndexByPlayerId[playerId]; + gNearestPathPointByCameraId[cameraId] = + func_8000D33C(camera->pos[0], camera->pos[1], camera->pos[2], gNearestPathPointByCameraId[cameraId], pathIndex); + playerPathPoint = gNearestPathPointByPlayerId[playerId]; + cameraPathPoint = gNearestPathPointByCameraId[cameraId]; + if (is_path_point_in_range(playerPathPoint, cameraPathPoint, 0x0032U, 0x000FU, gPathCountByPathIndex[pathIndex]) <= + 0) { + func_8001A348(cameraId, D_80164688[cameraId], D_80164680[cameraId]); + } else if ((gTrackPositionFactor[playerId] < -0.5) && (D_80164688[cameraId] < -0.5)) { + func_8001A348(cameraId, 1.0f, 7); + } else if ((gTrackPositionFactor[playerId] > 0.5) && (D_80164688[cameraId] > 0.5)) { + func_8001A348(cameraId, -1.0f, 6); + } + pathPoint1 = (gNearestPathPointByCameraId[cameraId] + 1) % gPathCountByPathIndex[pathIndex]; + pathPoint2 = (gNearestPathPointByCameraId[cameraId] + 2) % gPathCountByPathIndex[pathIndex]; + set_track_offset_position(pathPoint1, D_80164688[cameraId], pathIndex); + midX = gOffsetPosition[0] * 0.5; + midZ = gOffsetPosition[2] * 0.5; + set_track_offset_position(pathPoint2, D_80164688[cameraId], pathIndex); + midX += gOffsetPosition[0] * 0.5; + midZ += gOffsetPosition[2] * 0.5; + midY = (gTrackPaths[pathIndex][pathPoint1].posY + gTrackPaths[pathIndex][pathPoint2].posY) / 2.0; + xdiff = midX - D_801645F8[cameraId]; + ydiff = midY - D_80164618[cameraId]; + zdiff = midZ - D_80164638[cameraId]; + distance = sqrtf((xdiff * xdiff) + (ydiff * ydiff) + (zdiff * zdiff)); + if (distance != 0.0) { + midX = D_801645F8[cameraId] + ((D_80164648[cameraId] * xdiff) / distance); + midY = D_80164618[cameraId] + ((D_80164648[cameraId] * ydiff) / distance); + midZ = D_80164638[cameraId] + ((D_80164648[cameraId] * zdiff) / distance); + } else { + midX = D_801645F8[cameraId]; + midY = D_80164618[cameraId]; + midZ = D_80164638[cameraId]; + } + camera->pos[0] = midX; + camera->pos[2] = midZ; + temp_f2_2 = get_surface_height(midX, (midY + 30.0), midZ); + if ((temp_f2_2 < (midY - 20.0)) || (temp_f2_2 >= 3000.0)) { + camera->pos[1] = midY + 10.0; + } else { + camera->pos[1] = temp_f2_2 + 8.0; + } + D_801645F8[cameraId] = midX; + D_80164618[cameraId] = midY; + D_80164638[cameraId] = midZ; + camera->lookAt[0] = player->pos[0]; + camera->lookAt[1] = player->pos[1] + 6.0; + camera->lookAt[2] = player->pos[2]; + func_80014D30(cameraId, pathIndex); + xdiff2 = camera->lookAt[0] - camera->pos[0]; + ydiff2 = camera->lookAt[1] - camera->pos[1]; + zdiff2 = camera->lookAt[2] - camera->pos[2]; + camera->rot[1] = atan2s(xdiff2, zdiff2); + camera->rot[0] = atan2s(sqrtf((xdiff2 * xdiff2) + (zdiff2 * zdiff2)), ydiff2); + camera->rot[2] = 0; +} + +void func_800162CC(s32 playerId, f32 arg1, s32 cameraId, s16 pathIndex) { + Camera* camera = cameras + cameraId; + + D_80164688[cameraId] = arg1; + gNearestPathPointByCameraId[cameraId] = gNearestPathPointByPlayerId[playerId]; + gNearestPathPointByCameraId[cameraId] = (gNearestPathPointByCameraId[cameraId]) % gPathCountByPathIndex[pathIndex]; + + set_track_offset_position(gNearestPathPointByCameraId[cameraId], arg1, pathIndex); + + D_801645F8[cameraId] = gOffsetPosition[0]; + D_80164618[cameraId] = (f32) gTrackPaths[pathIndex][gNearestPathPointByCameraId[cameraId]].posY; + D_80164638[cameraId] = gOffsetPosition[2]; + + D_80164658[cameraId] = gPlayers[playerId].speed; + D_80164648[cameraId] = gPlayers[playerId].speed; + + camera->pos[0] = D_801645F8[cameraId]; + camera->pos[1] = D_80164618[cameraId]; + camera->pos[2] = D_80164638[cameraId]; +} + +void func_80016494(Camera* camera, UNUSED Player* unusedPlayer, UNUSED s32 arg2, s32 cameraId) { + s16 cameraPathPoint; + s16 playerPathPoint; + UNUSED s32 stackPadding0; + f32 xdiff2; + f32 ydiff2; + f32 zdiff2; + Player* player; + s32 playerId; + f32 midX; + f32 midY; + f32 midZ; + f32 xdiff; + f32 ydiff; + f32 zdiff; + f32 distance; + UNUSED f32 sp98; + s16 pathPoint1; + s16 pathPoint2; + UNUSED f32 sp94; + UNUSED f32 sp90; + UNUSED s32 stackPadding1; + s32 pathIndex; + f32 temp_f2_5; + + playerId = camera->playerId; + player = gPlayerOne; + D_80164648[cameraId] += ((D_80164658[cameraId] - D_80164648[cameraId]) * 0.5f); + D_80163238 = playerId; + pathIndex = gPathIndexByPlayerId[playerId]; + player += playerId; + gNearestPathPointByCameraId[cameraId] = + func_8000D33C(camera->pos[0], camera->pos[1], camera->pos[2], gNearestPathPointByCameraId[cameraId], pathIndex); + temp_f2_5 = (gTrackPositionFactor[playerId] - D_80164688[cameraId]); + temp_f2_5 *= temp_f2_5; + playerPathPoint = gNearestPathPointByPlayerId[playerId]; + cameraPathPoint = gNearestPathPointByCameraId[cameraId]; + if (is_path_point_in_range(playerPathPoint, cameraPathPoint, 0x000FU, 0x000FU, gPathCountByPathIndex[pathIndex]) <= + 0) { + func_8001A348(cameraId, D_80164688[cameraId], D_80164680[cameraId]); + } else { + if ((gTrackPositionFactor[playerId] < 0.0) && (D_80164688[cameraId] < 0.0) && (temp_f2_5 < 0.01)) { + func_8001A348(cameraId, 1.0f, 5); + } else { + if ((gTrackPositionFactor[playerId] > 0.0) && (D_80164688[cameraId] > 0.0) && (temp_f2_5 < 0.01)) { + func_8001A348(cameraId, -1.0f, 4); + } else { + if ((cameraPathPoint < playerPathPoint) && ((playerPathPoint - cameraPathPoint) < 0xA)) { + D_80164658[cameraId] = gPlayers[playerId].speed + 0.4; + } + if ((playerPathPoint < cameraPathPoint) && ((cameraPathPoint - playerPathPoint) < 0xA)) { + D_80164658[cameraId] = gPlayers[playerId].speed - 0.4; + } + if (D_80164658[cameraId] > 10.0) { + D_80164658[cameraId] = 10.0f; + } + if (D_80164658[cameraId] < 0.0) { + D_80164658[cameraId] = 0.0f; + } + } + } + } + pathPoint1 = (gNearestPathPointByCameraId[cameraId] + 1) % gPathCountByPathIndex[pathIndex]; + pathPoint2 = (gNearestPathPointByCameraId[cameraId] + 2) % gPathCountByPathIndex[pathIndex]; + set_track_offset_position(pathPoint1, D_80164688[cameraId], pathIndex); + midX = gOffsetPosition[0] * 0.5; + midZ = gOffsetPosition[2] * 0.5; + set_track_offset_position(pathPoint2, D_80164688[cameraId], pathIndex); + midX += gOffsetPosition[0] * 0.5; + midZ += gOffsetPosition[2] * 0.5; + midY = (gTrackPaths[pathIndex][pathPoint1].posY + gTrackPaths[pathIndex][pathPoint2].posY) / 2.0; + xdiff = midX - D_801645F8[cameraId]; + ydiff = midY - D_80164618[cameraId]; + zdiff = midZ - D_80164638[cameraId]; + distance = sqrtf((xdiff * xdiff) + (ydiff * ydiff) + (zdiff * zdiff)); + if (distance != 0.0) { + midX = D_801645F8[cameraId] + ((D_80164648[cameraId] * xdiff) / distance); + midY = D_80164618[cameraId] + ((D_80164648[cameraId] * ydiff) / distance); + midZ = D_80164638[cameraId] + ((D_80164648[cameraId] * zdiff) / distance); + } else { + midX = D_801645F8[cameraId]; + midY = D_80164618[cameraId]; + midZ = D_80164638[cameraId]; + } + camera->pos[0] = midX; + camera->pos[2] = midZ; + temp_f2_5 = get_surface_height(midX, midY + 30.0, midZ); + if ((temp_f2_5 < (midY - 20.0)) || (temp_f2_5 >= 3000.0)) { + camera->pos[1] = midY + 10.0; + } else { + camera->pos[1] = temp_f2_5 + 10.0; + } + D_801645F8[cameraId] = midX; + D_80164618[cameraId] = midY; + D_80164638[cameraId] = midZ; + camera->lookAt[0] = player->pos[0]; + camera->lookAt[1] = player->pos[1] + 6.0; + camera->lookAt[2] = player->pos[2]; + func_80014D30(cameraId, pathIndex); + xdiff2 = camera->lookAt[0] - camera->pos[0]; + ydiff2 = camera->lookAt[1] - camera->pos[1]; + zdiff2 = camera->lookAt[2] - camera->pos[2]; + camera->rot[1] = atan2s(xdiff2, zdiff2); + camera->rot[0] = atan2s(sqrtf((xdiff2 * xdiff2) + (zdiff2 * zdiff2)), ydiff2); + camera->rot[2] = 0; +} + +void func_80016C3C(UNUSED s32 playerId, UNUSED f32 arg1, s32 cameraId) { + UNUSED s32 stackPadding0; + UNUSED s32 stackPadding1; + f32 temp_f2; + UNUSED s32 stackPadding2; + f32 temp_f12; + TrackPathPoint** path; + f32 sp54; + s32 temp_s0; + s16 sp48; + s16 sp44; + Camera* camera; + + if (random_int(0x0064U) < 0x32) { + D_80164688[cameraId] = 0.1f; + } else { + D_80164688[cameraId] = -0.1f; + } + D_80163DD8[cameraId] = 0; + if (gCurrentCourseId == COURSE_YOSHI_VALLEY) { + D_80163DD8[cameraId] = random_int(4U); + D_80164688[cameraId] = 0.0f; + } + temp_s0 = gPathCountByPathIndex[D_80163DD8[cameraId]]; + gNearestPathPointByCameraId[cameraId] %= temp_s0; + set_track_offset_position(gNearestPathPointByCameraId[cameraId], D_80164688[cameraId], 0); + D_801645F8[cameraId] = gOffsetPosition[0]; + D_80164618[cameraId] = gTrackPaths[0][gNearestPathPointByCameraId[cameraId]].posY; + path = gTrackPaths; + D_80164638[cameraId] = gOffsetPosition[2]; + D_80164658[cameraId] = 16.666666f; + D_80164648[cameraId] = 0.0f; + sp48 = (gNearestPathPointByCameraId[cameraId] + 0xA) % temp_s0; + sp44 = (gNearestPathPointByCameraId[cameraId] + 0xB) % temp_s0; + set_track_offset_position(sp48, D_80164688[cameraId], 0); + temp_f2 = gOffsetPosition[0] * 0.5; + temp_f12 = gOffsetPosition[2] * 0.5; + set_track_offset_position(sp44, D_80164688[cameraId], 0); + temp_f2 += gOffsetPosition[0] * 0.5; + temp_f12 += gOffsetPosition[2] * 0.5; + sp48 = (gNearestPathPointByCameraId[cameraId] + 0x5) % temp_s0; + sp44 = (gNearestPathPointByCameraId[cameraId] + 0x6) % temp_s0; + sp54 = (path[0][sp48].posY + path[0][sp44].posY) * 0.5f; + camera = cameras; + camera += cameraId; + camera->lookAt[0] = temp_f2; + camera->lookAt[2] = temp_f12; + camera->lookAt[1] = sp54 + 8.0; + camera->pos[0] = D_801645F8[cameraId]; + camera->pos[1] = D_80164618[cameraId]; + camera->pos[2] = D_80164638[cameraId]; +} + +void func_80017054(Camera* camera, UNUSED Player* player, UNUSED s32 index, s32 cameraId); +#ifdef NON_MATCHING +// https://decomp.me/scratch/Ck7hV +// Really crazy diff, permuter only able to find fakematches for improvements (and they're big improvements) +// There's something really, really wrong with the empty `if` statement +void func_80017054(Camera* camera, UNUSED Player* player, UNUSED s32 index, s32 cameraId) { + UNUSED s32 stackPadding0; + UNUSED s32 stackPadding1; + f32 spAC; + f32 spA8; + f32 spA4; + UNUSED s32 stackPadding2; + UNUSED s32 stackPadding3; + f32 sp98; + f32 sp94; + f32 sp90; + f32 sp8C; + f32 sp88; + f32 sp84; + UNUSED f32 stackPadding4; + UNUSED f32 stackPadding5; + UNUSED f32 stackPadding6; + UNUSED s32 stackPadding7; + UNUSED s32 stackPadding8; + s16 sp6E; + s16 sp6C; + UNUSED s32 stackPadding9; + UNUSED s32 stackPaddingA; + UNUSED s32 stackPaddingB; + s32 pathIndex; + UNUSED s32 stackPaddingC; + s32 sp58; + s16 sp56; + s32 playerId; + + playerId = camera->playerId; + pathIndex = D_80163DD8[cameraId]; + D_80164648[cameraId] += (D_80164658[cameraId] - D_80164648[cameraId]) * 0.5f; + sp58 = gPathCountByPathIndex[pathIndex]; + D_80163238 = playerId; + sp56 = gNearestPathPointByCameraId[cameraId]; + gNearestPathPointByCameraId[cameraId] = + func_8000D33C(camera->pos[0], camera->pos[1], camera->pos[2], gNearestPathPointByCameraId[cameraId], pathIndex); + if (gCurrentCourseId == COURSE_YOSHI_VALLEY) { + if ((sp56 != gNearestPathPointByCameraId[cameraId]) && (gNearestPathPointByCameraId[cameraId] == 1)) { + pathIndex = (D_80163DD8[cameraId] = random_int(4U)); + gNearestPathPointByCameraId[cameraId] = func_8000D33C(camera->pos[0], camera->pos[1], camera->pos[2], + gNearestPathPointByCameraId[cameraId], pathIndex); + } + } + sp6E = (gNearestPathPointByCameraId[cameraId] + 0xA) % sp58; + sp6C = (gNearestPathPointByCameraId[cameraId] + 0xB) % sp58; + set_track_offset_position(sp6E, D_80164688[cameraId], pathIndex); + sp8C = gOffsetPosition[0] * 0.5; + sp84 = gOffsetPosition[2] * 0.5; + set_track_offset_position(sp6C, D_80164688[cameraId], pathIndex); + sp8C += gOffsetPosition[0] * 0.5; + sp84 += gOffsetPosition[2] * 0.5; + sp6E = (gNearestPathPointByCameraId[cameraId] + 5) % sp58; + sp6C = (gNearestPathPointByCameraId[cameraId] + 6) % sp58; + sp88 = (gTrackPaths[pathIndex][sp6E].posY + gTrackPaths[pathIndex][sp6C].posY) * 0.5f; + sp6E = (gNearestPathPointByCameraId[cameraId] + 1) % sp58; + sp6C = (gNearestPathPointByCameraId[cameraId] + 2) % sp58; + set_track_offset_position(sp6E, D_80164688[cameraId], pathIndex); + sp98 = gOffsetPosition[0] * 0.5; + sp90 = gOffsetPosition[2] * 0.5; + set_track_offset_position(sp6C, D_80164688[cameraId], pathIndex); + sp98 += gOffsetPosition[0] * 0.5; + sp90 += gOffsetPosition[2] * 0.5; + sp94 = (gTrackPaths[pathIndex][sp6E].posY + gTrackPaths[pathIndex][sp6C].posY) * 0.5f; + stackPadding4 = sp98 - D_801645F8[cameraId]; + stackPadding5 = sp90 - D_80164618[cameraId]; + stackPadding6 = sp94 - D_80164638[cameraId]; + spAC = sqrtf(((sp98 * sp98) + (sp94 * sp94)) + (sp90 * sp90)); + if (spAC != 0.0) { + sp98 = D_801645F8[cameraId] + ((D_80164648[cameraId] * stackPadding4) / spAC); + sp94 = D_80164618[cameraId] + ((D_80164648[cameraId] * stackPadding5) / spAC); + sp90 = D_80164638[cameraId] + ((D_80164648[cameraId] * stackPadding6) / spAC); + } else { + sp98 = D_801645F8[cameraId]; + sp94 = D_80164618[cameraId]; + sp90 = D_80164638[cameraId]; + } + if ((!(sp98 < (-10000.0))) && (sp98 > 10000.0)) { + if (sp98 && sp98) {} + } + camera->pos[0] = sp98; + camera->pos[1] = sp94 + 10.0; + camera->pos[2] = sp90; + if (1) {} + if (1) {} + if (1) {} + if (1) {} + if (1) {} + D_801645F8[cameraId] = sp98; + D_80164638[cameraId] = sp90; + D_80164618[cameraId] = sp94; + camera->lookAt[0] = sp8C; + camera->lookAt[1] = sp88 + 8.0; + camera->lookAt[2] = sp84; + func_80014D30(cameraId, pathIndex); + spAC = camera->lookAt[0] - camera->pos[0]; + spA8 = camera->lookAt[1] - camera->pos[1]; + spA4 = camera->lookAt[2] - camera->pos[2]; + camera->rot[1] = atan2s(spAC, spA4); + camera->rot[0] = atan2s(sqrtf((spAC * spAC) + (spA4 * spA4)), spA8); + camera->rot[2] = 0; +} +#else +GLOBAL_ASM("asm/non_matchings/cpu_vehicles_camera_path/func_80017054.s") +#endif + +void func_80017720(s32 playerId, UNUSED f32 arg1, s32 cameraId, s16 pathIndex) { + Camera* camera = cameras + cameraId; + UNUSED s32 pad; + + D_80164688[cameraId] = gTrackPositionFactor[playerId]; + gNearestPathPointByCameraId[cameraId] = gNearestPathPointByPlayerId[playerId] + 3; + gNearestPathPointByCameraId[cameraId] = gNearestPathPointByCameraId[cameraId] % gPathCountByPathIndex[pathIndex]; + + set_track_offset_position(gNearestPathPointByCameraId[cameraId], gTrackPositionFactor[playerId], pathIndex); + + D_801645F8[cameraId] = gOffsetPosition[0]; + D_80164618[cameraId] = (f32) gTrackPaths[pathIndex][gNearestPathPointByCameraId[cameraId]].posY; + D_80164638[cameraId] = gOffsetPosition[2]; + + D_80164658[cameraId] = gPlayers[playerId].speed; + D_80164648[cameraId] = gPlayers[playerId].speed; + + camera->pos[0] = D_801645F8[cameraId]; + camera->pos[1] = D_80164618[cameraId]; + camera->pos[2] = D_80164638[cameraId]; +} + +void func_800178F4(Camera* camera, UNUSED Player* unusedPlayer, UNUSED s32 arg2, s32 cameraId) { + s16 cameraPathPoint; + s16 playerPathPoint; + UNUSED f32 stackPadding0; + f32 xdiff2; + f32 ydiff2; + f32 zdiff2; + Player* player; + f32 distance; + f32 midX; + f32 midY; + f32 midZ; + f32 xdiff; + f32 ydiff; + f32 zdiff; + UNUSED f32 var_f2; + UNUSED f32 var_f18; + s16 pathPoint1; + s16 pathPoint2; + UNUSED f32 stackPadding1; + UNUSED f32 var_f14; + s32 playerId; + s32 pathIndex; + s32 pathPointCount; + + playerId = camera->playerId; + player = gPlayerOne; + D_80164688[cameraId] = gTrackPositionFactor[playerId]; + D_80164648[cameraId] += ((D_80164658[cameraId] - D_80164648[cameraId]) / 2.0f); + D_80163238 = playerId; + pathIndex = gPathIndexByPlayerId[playerId]; + player += playerId; + pathPointCount = gPathCountByPathIndex[pathIndex]; + gNearestPathPointByCameraId[cameraId] = + func_8000D33C(camera->pos[0], camera->pos[1], camera->pos[2], gNearestPathPointByCameraId[cameraId], pathIndex); + playerPathPoint = (gNearestPathPointByPlayerId[playerId] + 3) % pathPointCount; + cameraPathPoint = gNearestPathPointByCameraId[cameraId]; + if (is_path_point_in_range(playerPathPoint, cameraPathPoint, 0x000DU, 1U, pathPointCount) <= 0) { + func_8001A348(cameraId, D_80164688[cameraId], D_80164680[cameraId]); + } else { + if ((cameraPathPoint < playerPathPoint) && ((playerPathPoint - cameraPathPoint) < 3)) { + D_80164658[cameraId] = gPlayers[playerId].speed + 0.1; + } + if ((playerPathPoint < cameraPathPoint) && ((cameraPathPoint - playerPathPoint) < 3)) { + D_80164658[cameraId] = gPlayers[playerId].speed - 0.1; + } + if (D_80164658[cameraId] > 10.0) { + D_80164658[cameraId] = 10.0f; + } + if (D_80164658[cameraId] < 0.0) { + D_80164658[cameraId] = 0.0f; + } + } + pathPoint1 = (gNearestPathPointByCameraId[cameraId] + 1) % pathPointCount; + pathPoint2 = (gNearestPathPointByCameraId[cameraId] + 2) % pathPointCount; + set_track_offset_position(pathPoint1, D_80164688[cameraId], pathIndex); + midX = gOffsetPosition[0] * 0.5; + midZ = gOffsetPosition[2] * 0.5; + set_track_offset_position(pathPoint2, D_80164688[cameraId], pathIndex); + midX += gOffsetPosition[0] * 0.5; + midZ += gOffsetPosition[2] * 0.5; + midY = (gTrackPaths[pathIndex][pathPoint1].posY + gTrackPaths[pathIndex][pathPoint2].posY) / 2.0; + xdiff = midX - D_801645F8[cameraId]; + ydiff = midY - D_80164618[cameraId]; + zdiff = midZ - D_80164638[cameraId]; + distance = sqrtf((xdiff * xdiff) + (ydiff * ydiff) + (zdiff * zdiff)); + if (distance != 0.0) { + midX = D_801645F8[cameraId] + ((D_80164648[cameraId] * xdiff) / distance); + midY = D_80164618[cameraId] + ((D_80164648[cameraId] * ydiff) / distance); + midZ = D_80164638[cameraId] + ((D_80164648[cameraId] * zdiff) / distance); + } else { + midX = D_801645F8[cameraId]; + midY = D_80164618[cameraId]; + midZ = D_80164638[cameraId]; + } + camera->pos[0] = midX; + camera->pos[2] = midZ; + camera->pos[1] = midY + 10.0; + D_801645F8[cameraId] = midX; + D_80164618[cameraId] = midY; + D_80164638[cameraId] = midZ; + camera->lookAt[0] = player->pos[0]; + camera->lookAt[1] = player->pos[1] + 6.0; + camera->lookAt[2] = player->pos[2]; + func_80014D30(cameraId, pathIndex); + xdiff2 = camera->lookAt[0] - camera->pos[0]; + ydiff2 = camera->lookAt[1] - camera->pos[1]; + zdiff2 = camera->lookAt[2] - camera->pos[2]; + camera->rot[1] = atan2s(xdiff2, zdiff2); + camera->rot[0] = atan2s(sqrtf((xdiff2 * xdiff2) + (zdiff2 * zdiff2)), ydiff2); + camera->rot[2] = 0; +} + +void func_80017F10(s32 playerId, UNUSED f32 arg1, s32 cameraId, s16 pathIndex) { + Camera* camera = cameras + cameraId; + s32 test = gPathCountByPathIndex[pathIndex]; + + D_80164688[cameraId] = gTrackPositionFactor[playerId]; + gNearestPathPointByCameraId[cameraId] = (gNearestPathPointByPlayerId[playerId] + test) - 2; + gNearestPathPointByCameraId[cameraId] = gNearestPathPointByCameraId[cameraId] % test; + + set_track_offset_position(gNearestPathPointByCameraId[cameraId], gTrackPositionFactor[playerId], pathIndex); + + D_801645F8[cameraId] = gOffsetPosition[0]; + D_80164618[cameraId] = (f32) gTrackPaths[pathIndex][gNearestPathPointByCameraId[cameraId]].posY; + D_80164638[cameraId] = gOffsetPosition[2]; + + D_80164658[cameraId] = gPlayers[playerId].speed; + D_80164648[cameraId] = gPlayers[playerId].speed; + + camera->pos[0] = D_801645F8[cameraId]; + camera->pos[1] = D_80164618[cameraId]; + camera->pos[2] = D_80164638[cameraId]; +} + +void func_800180F0(Camera* camera, UNUSED Player* unusedPlayer, UNUSED s32 arg2, s32 cameraId) { + s16 cameraPathPoint; + s16 playerPathPoint; + UNUSED s32 stackPadding3; + f32 sp94; + f32 sp90; + f32 sp8C; + UNUSED s32 stackPadding4; + f32 distance; + f32 midX; + f32 midY; + f32 midZ; + f32 xdiff; + f32 ydiff; + f32 zdiff; + Player* player; + s32 playerId; + s16 pathPoint1; + s16 pathPoint2; + UNUSED f32 var_f2; + UNUSED f32 var_f18; + UNUSED f32 var_f14; + s32 pathIndex; + s32 pathPointCount; + + playerId = camera->playerId; + player = gPlayerOne; + D_80164688[cameraId] = gTrackPositionFactor[playerId]; + D_80164648[cameraId] += ((D_80164658[cameraId] - D_80164648[cameraId]) * 0.5f); + D_80163238 = playerId; + pathIndex = gPathIndexByPlayerId[playerId]; + pathPointCount = gPathCountByPathIndex[pathIndex]; + player += playerId; + gNearestPathPointByCameraId[cameraId] = + func_8000D33C(camera->pos[0], camera->pos[1], camera->pos[2], gNearestPathPointByCameraId[cameraId], pathIndex); + playerPathPoint = ((gNearestPathPointByPlayerId[playerId] + pathPointCount) - 2) % pathPointCount; + cameraPathPoint = gNearestPathPointByCameraId[cameraId]; + if (is_path_point_in_range(playerPathPoint, cameraPathPoint, 1U, 0x000AU, pathPointCount) <= 0) { + func_8001A348(cameraId, D_80164688[cameraId], D_80164680[cameraId]); + } else { + if ((cameraPathPoint < playerPathPoint) && ((playerPathPoint - cameraPathPoint) < 3)) { + D_80164658[cameraId] = gPlayers[playerId].speed + 0.1; + } + if ((playerPathPoint < cameraPathPoint) && ((cameraPathPoint - playerPathPoint) < 3)) { + D_80164658[cameraId] = gPlayers[playerId].speed - 0.1; + } + if (D_80164658[cameraId] > 10.0) { + D_80164658[cameraId] = 10.0f; + } + if (D_80164658[cameraId] < 0.0) { + D_80164658[cameraId] = 0.0f; + } + } + pathPoint1 = (gNearestPathPointByCameraId[cameraId] + 1) % pathPointCount; + pathPoint2 = (gNearestPathPointByCameraId[cameraId] + 2) % pathPointCount; + set_track_offset_position(pathPoint1, D_80164688[cameraId], pathIndex); + midX = gOffsetPosition[0] * 0.5; + midZ = gOffsetPosition[2] * 0.5; + set_track_offset_position(pathPoint2, D_80164688[cameraId], pathIndex); + midX += gOffsetPosition[0] * 0.5; + midZ += gOffsetPosition[2] * 0.5; + midY = (gTrackPaths[pathIndex][pathPoint1].posY + gTrackPaths[pathIndex][pathPoint2].posY) / 2.0; + xdiff = midX - D_801645F8[cameraId]; + ydiff = midY - D_80164618[cameraId]; + zdiff = midZ - D_80164638[cameraId]; + distance = sqrtf((xdiff * xdiff) + (ydiff * ydiff) + (zdiff * zdiff)); + if (distance != 0.0) { + midX = D_801645F8[cameraId] + ((D_80164648[cameraId] * xdiff) / distance); + midY = D_80164618[cameraId] + ((D_80164648[cameraId] * ydiff) / distance); + midZ = D_80164638[cameraId] + ((D_80164648[cameraId] * zdiff) / distance); + } else { + midX = D_801645F8[cameraId]; + midY = D_80164618[cameraId]; + midZ = D_80164638[cameraId]; + } + camera->pos[0] = midX; + camera->pos[2] = midZ; + camera->pos[1] = player->pos[1] + 10.0; + D_801645F8[cameraId] = midX; + D_80164618[cameraId] = midY; + D_80164638[cameraId] = midZ; + camera->lookAt[0] = player->pos[0]; + camera->lookAt[1] = player->pos[1] + 6.0; + camera->lookAt[2] = player->pos[2]; + func_80014D30(cameraId, pathIndex); + sp94 = camera->lookAt[0] - camera->pos[0]; + sp90 = camera->lookAt[1] - camera->pos[1]; + sp8C = camera->lookAt[2] - camera->pos[2]; + camera->rot[1] = atan2s(sp94, sp8C); + camera->rot[0] = atan2s(sqrtf((sp94 * sp94) + (sp8C * sp8C)), sp90); + camera->rot[2] = 0; +} + +void func_80018718(s32 playerId, UNUSED f32 arg1, s32 cameraId, s16 pathIndex) { + Camera* camera = cameras + cameraId; + s32 test = gPathCountByPathIndex[pathIndex]; + + D_80164688[cameraId] = gTrackPositionFactor[playerId]; + gNearestPathPointByCameraId[cameraId] = ((gNearestPathPointByPlayerId[playerId] + test) - 5) % test; + + calculate_track_offset_position(gNearestPathPointByCameraId[cameraId], gTrackPositionFactor[playerId], 60.0f, + pathIndex); + + D_801645F8[cameraId] = gOffsetPosition[0]; + D_80164618[cameraId] = (f32) gTrackPaths[pathIndex][gNearestPathPointByCameraId[cameraId]].posY; + D_80164638[cameraId] = gOffsetPosition[2]; + + D_80164658[cameraId] = gPlayers[playerId].speed; + D_80164648[cameraId] = gPlayers[playerId].speed; + D_8016448C = 1; + camera->pos[0] = D_801645F8[cameraId]; + camera->pos[1] = D_80164618[cameraId]; + camera->pos[2] = D_80164638[cameraId]; +} + +void func_800188F4(Camera* camera, UNUSED Player* unusePlayer, UNUSED s32 arg2, s32 cameraId) { + s16 cameraPathPoint; + s16 playerPathPoint; + UNUSED s32 stackPadding0; + f32 spAC; + f32 spA8; + f32 spA4; + Player* player; + f32 distance; + f32 midX; + f32 midY; + f32 midZ; + f32 xdiff; + f32 ydiff; + f32 zdiff; + UNUSED f32 sp64; + UNUSED f32 sp60; + s16 pathPoint1; + s16 pathPoint2; + UNUSED f32 sp5C; + f32 temp_f2_4; + s32 playerId; + s32 pathIndex; + s32 pathPointCount; + + player = gPlayerOne; + playerId = camera->playerId; + pathIndex = gPathIndexByPlayerId[playerId]; + pathPointCount = gPathCountByPathIndex[pathIndex]; + D_80164648[cameraId] = gPlayers[playerId].speed; + if (D_8016448C == 0) { + if (gNearestPathPointByCameraId[cameraId] == + (((gNearestPathPointByPlayerId[playerId] + pathPointCount) - 6) % pathPointCount)) { + D_8016448C = 1; + } + if (D_80164688[cameraId] < (gTrackPositionFactor[playerId] - 0.2)) { + D_80164648[cameraId] = gPlayers[playerId].speed * 0.7; + } + if ((gTrackPositionFactor[playerId] - 0.5) < D_80164688[cameraId]) { + D_80164688[cameraId] -= 0.01; + } + if (D_80164688[cameraId] < -0.9) { + D_80164688[cameraId] = -0.9f; + D_80164648[cameraId] = gPlayers[playerId].speed * 0.8; + } + } else { + if (gNearestPathPointByCameraId[cameraId] == ((gNearestPathPointByPlayerId[playerId] + 6) % pathPointCount)) { + D_8016448C = 0; + } + if ((gTrackPositionFactor[playerId] + 0.2) < D_80164688[cameraId]) { + D_80164648[cameraId] = gPlayers[playerId].speed * 1.3; + } + if (D_80164688[cameraId] < (gTrackPositionFactor[playerId] + 0.5)) { + D_80164688[cameraId] += 0.01; + } + if (D_80164688[cameraId] > 0.9) { + D_80164688[cameraId] = 0.9f; + D_80164648[cameraId] = gPlayers[playerId].speed * 1.2; + } + } + D_80163238 = playerId; + player += playerId; + gNearestPathPointByCameraId[cameraId] = + func_8000D33C(camera->pos[0], camera->pos[1], camera->pos[2], gNearestPathPointByCameraId[cameraId], pathIndex); + playerPathPoint = gNearestPathPointByPlayerId[playerId]; + cameraPathPoint = gNearestPathPointByCameraId[cameraId]; + if (is_path_point_in_range(playerPathPoint, cameraPathPoint, 0x000FU, 0x000FU, pathPointCount) <= 0) { + func_8001A348(cameraId, D_80164688[cameraId], D_80164680[cameraId]); + } + pathPoint1 = (gNearestPathPointByCameraId[cameraId] + 1) % pathPointCount; + pathPoint2 = (gNearestPathPointByCameraId[cameraId] + 2) % pathPointCount; + calculate_track_offset_position(pathPoint1, D_80164688[cameraId], 60.0f, pathIndex); + midX = gOffsetPosition[0] * 0.5; + midZ = gOffsetPosition[2] * 0.5; + calculate_track_offset_position(pathPoint2, D_80164688[cameraId], 60.0f, pathIndex); + midX += gOffsetPosition[0] * 0.5; + midZ += gOffsetPosition[2] * 0.5; + midY = (gTrackPaths[pathIndex][pathPoint1].posY + gTrackPaths[pathIndex][pathPoint2].posY) / 2.0; + xdiff = midX - D_801645F8[cameraId]; + ydiff = midY - D_80164618[cameraId]; + zdiff = midZ - D_80164638[cameraId]; + distance = sqrtf((xdiff * xdiff) + (ydiff * ydiff) + (zdiff * zdiff)); + if (distance != 0.0) { + midX = D_801645F8[cameraId] + ((D_80164648[cameraId] * xdiff) / distance); + midY = D_80164618[cameraId] + ((D_80164648[cameraId] * ydiff) / distance); + midZ = D_80164638[cameraId] + ((D_80164648[cameraId] * zdiff) / distance); + } else { + midX = D_801645F8[cameraId]; + midY = D_80164618[cameraId]; + midZ = D_80164638[cameraId]; + } + camera->pos[0] = midX; + camera->pos[2] = midZ; + temp_f2_4 = get_surface_height(midX, midY + 30.0, midZ); + if ((temp_f2_4 < (midY - 20.0)) || (temp_f2_4 >= 3000.0)) { + camera->pos[1] = midY + 10.0; + } else { + camera->pos[1] = temp_f2_4 + 8.0; + } + D_801645F8[cameraId] = midX; + D_80164618[cameraId] = midY; + D_80164638[cameraId] = midZ; + camera->lookAt[0] = player->pos[0]; + camera->lookAt[1] = player->pos[1] + 6.0; + camera->lookAt[2] = player->pos[2]; + func_80014D30(cameraId, pathIndex); + spAC = camera->lookAt[0] - camera->pos[0]; + spA8 = camera->lookAt[1] - camera->pos[1]; + spA4 = camera->lookAt[2] - camera->pos[2]; + camera->rot[1] = atan2s(spAC, spA4); + camera->rot[0] = atan2s(sqrtf((spAC * spAC) + (spA4 * spA4)), spA8); + camera->rot[2] = 0; +} + +void func_80019118(s32 playerId, f32 arg1, s32 cameraId, UNUSED s16 pathIndex) { + Camera* camera = cameras + cameraId; + s32 test = gPathCountByPathIndex[0]; + f32 temp_f12; + f32 temp_f2; + + D_80164688[cameraId] = arg1; + gNearestPathPointByCameraId[cameraId] = gNearestPathPointByPlayerId[playerId] + 12; + gNearestPathPointByCameraId[cameraId] = gNearestPathPointByCameraId[cameraId] % test; + + set_track_offset_position(gNearestPathPointByCameraId[cameraId], arg1, 0); + D_801645F8[cameraId] = gOffsetPosition[0]; + D_80164638[cameraId] = gOffsetPosition[2]; + temp_f2 = (f32) gTrackPaths[0][gNearestPathPointByCameraId[cameraId]].posY; + + temp_f12 = get_surface_height(gOffsetPosition[0], (f32) (temp_f2 + 30.0), gOffsetPosition[2]); + + if ((temp_f12 < (temp_f2 - 20.0)) || (temp_f12 >= 3000.0)) { + D_80164618[cameraId] = (f32) (temp_f2 + 10.0); + } else { + D_80164618[cameraId] = (f32) (temp_f12 + 10.0); + } + D_80164648[cameraId] = 0.0f; + camera->pos[0] = D_801645F8[cameraId]; + camera->pos[1] = D_80164618[cameraId]; + camera->pos[2] = D_80164638[cameraId]; +} + +void func_8001933C(Camera* camera, UNUSED Player* playerArg, UNUSED s32 arg2, s32 cameraId) { + s16 cameraPathPoint; + s16 playerPathPoint; + UNUSED s32 pad; + f32 xdiff; + f32 ydiff; + f32 zdiff; + UNUSED s32 pad2; + s32 playerId; + UNUSED s32 pad3[10]; + Player* player; + TrackPathPoint* pathPoint; + s32 pathIndex; + s32 pathPointCount; + + playerId = camera->playerId; + pathIndex = gPathIndexByPlayerId[playerId]; + player = gPlayerOne; + player += playerId; + pathPointCount = gPathCountByPathIndex[pathIndex]; + gNearestPathPointByCameraId[cameraId] = + func_8000D33C(camera->pos[0], camera->pos[1], camera->pos[2], gNearestPathPointByCameraId[cameraId], 0); + playerPathPoint = gNearestPathPointByPlayerId[playerId]; + cameraPathPoint = gNearestPathPointByCameraId[cameraId]; + if (is_path_point_in_range(playerPathPoint, cameraPathPoint, 0x0032U, 0x0014U, pathPointCount) <= 0) { + func_8001A348(cameraId, D_80164688[cameraId], D_80164680[cameraId]); + } else { + if ((gTrackPositionFactor[playerId] < -0.5) && ((f64) D_80164688[cameraId] < -0.5)) { + func_8001A348(cameraId, 1.0f, 0x0000000D); + } else if ((gTrackPositionFactor[playerId] > 0.5) && ((f64) D_80164688[cameraId] > 0.5)) { + func_8001A348(cameraId, -1.0f, 0x0000000C); + } + } + camera->pos[0] = D_801645F8[cameraId]; + camera->pos[1] = D_80164618[cameraId]; + camera->pos[2] = D_80164638[cameraId]; + pathPoint = &gTrackPaths[pathIndex][cameraPathPoint]; + camera->lookAt[0] = (player->pos[0] * 0.8) + (0.2 * pathPoint->posX); + camera->lookAt[1] = (player->pos[1] * 0.8) + (0.2 * pathPoint->posY); + camera->lookAt[2] = (player->pos[2] * 0.8) + (0.2 * pathPoint->posZ); + func_80014D30(cameraId, pathIndex); + xdiff = camera->lookAt[0] - camera->pos[0]; + ydiff = camera->lookAt[1] - camera->pos[1]; + zdiff = camera->lookAt[2] - camera->pos[2]; + camera->rot[1] = atan2s(xdiff, zdiff); + camera->rot[0] = atan2s(sqrtf((xdiff * xdiff) + (zdiff * zdiff)), ydiff); + camera->rot[2] = 0; +} + +void func_8001968C(void) { + D_80164678[0] = 3; +} + +void func_8001969C(UNUSED s32 playerId, UNUSED f32 arg1, s32 cameraId, UNUSED s16 pathIndex) { + TrackPathPoint* pathPoint; + + gNearestPathPointByCameraId[cameraId] = gPathCountByPathIndex[0] - 18; + + pathPoint = &gTrackPaths[0][gNearestPathPointByCameraId[cameraId]]; + + D_801645F8[cameraId] = pathPoint->posX; + //! @bug Adding an (f32) cast changes asm, why? + D_80164618[cameraId] = pathPoint->posY + 10.0; + D_80164638[cameraId] = pathPoint->posZ; + D_80164648[cameraId] = 0.0f; + D_80164678[cameraId] = 0; +} + +void func_80019760(Camera* camera, UNUSED Player* player, UNUSED s32 arg2, s32 cameraId) { + UNUSED s32 pad[2]; + f32 xdiff; + f32 ydiff; + f32 zdiff; + TrackPathPoint* temp_v1; + + camera->pos[0] = D_801645F8[cameraId]; + camera->pos[1] = D_80164618[cameraId]; + camera->pos[2] = D_80164638[cameraId]; + temp_v1 = &(*gTrackPaths)[gNearestPathPointByCameraId[cameraId]]; + camera->lookAt[0] = (f32) temp_v1->posX; + camera->lookAt[1] = (f32) temp_v1->posY; + camera->lookAt[2] = (f32) temp_v1->posZ; + func_80014D30(cameraId, 0); + xdiff = camera->lookAt[0] - camera->pos[0]; + ydiff = camera->lookAt[1] - camera->pos[1]; + zdiff = camera->lookAt[2] - camera->pos[2]; + camera->rot[1] = atan2s(xdiff, zdiff); + camera->rot[0] = atan2s(sqrtf((xdiff * xdiff) + (zdiff * zdiff)), ydiff); + camera->rot[2] = 0; +} + +void func_80019890(s32 playerId, s32 cameraId) { + s32 pathIndex; + Camera* camera = camera1; + camera += cameraId; + camera->playerId = playerId; + + D_801646C0[cameraId] = 0; + pathIndex = gPathIndexByPlayerId[playerId]; + + switch (D_80164680[cameraId]) { + case 0: + func_80015314(playerId, 0.0f, cameraId); + break; + case 2: + func_80015544(playerId, -1.0f, cameraId, pathIndex); + break; + case 3: + func_80015544(playerId, 1.0f, cameraId, pathIndex); + break; + case 6: + func_80015A9C(playerId, -0.6f, cameraId, (s16) pathIndex); + break; + case 7: + func_80015A9C(playerId, 0.6f, cameraId, (s16) pathIndex); + break; + case 4: + func_800162CC(playerId, -1.0f, cameraId, (s16) pathIndex); + break; + case 5: + func_800162CC(playerId, 1.0f, cameraId, (s16) pathIndex); + break; + case 9: + func_80016C3C(playerId, 0.0f, cameraId); + break; + case 1: + func_80017720(playerId, 0.0f, cameraId, (s16) pathIndex); + break; + case 14: + func_80017F10(playerId, 0.0f, cameraId, (s16) pathIndex); + break; + case 8: + func_80018718(playerId, 0.0f, cameraId, (s16) pathIndex); + break; + case 12: + func_80019118(playerId, -1.0f, cameraId, (s16) pathIndex); + break; + case 13: + func_80019118(playerId, 1.0f, cameraId, (s16) pathIndex); + break; + case 15: + func_8001969C(playerId, -1.0f, cameraId, (s16) pathIndex); + break; + case 16: + func_8001969C(playerId, 1.0f, cameraId, (s16) pathIndex); + break; + default: + func_80015314(playerId, 0.0f, cameraId); + break; + } + gNearestPathPointByCameraId[cameraId] = + func_8000BD94(camera->pos[0], camera->pos[1], camera->pos[2], (s32) pathIndex); + if ((s16) D_80164680[cameraId] == 9) { + D_80163DD8[cameraId] = (s32) pathIndex; + } +} + +void func_80019B50(s32 cameraIndex, u16 arg1) { + u16 var_v0; + + var_v0 = D_801646C0[cameraIndex]; + if (var_v0 < arg1) { + if ((arg1 - var_v0) < 0x8000) { + var_v0 += 0x5A; + if (arg1 < var_v0) { + var_v0 = arg1; + } + if (var_v0 < 0x5A) { + var_v0 = 0; + } + } else if ((arg1 - var_v0) >= 0x8000) { + var_v0 -= 0x5A; + } + } else if (arg1 < var_v0) { + if ((var_v0 - arg1) < 0x8000) { + var_v0 -= 0x5A; + if (var_v0 < arg1) { + var_v0 = arg1; + } + if (var_v0 >= 0xFFA6) { + var_v0 = 0; + } + } else if ((var_v0 - arg1) >= 0x8000) { + var_v0 += 0x5A; + if (!cameraIndex) {} // wtf? + } + } + D_801646C0[cameraIndex] = (s16) var_v0; +} + +void func_80019C50(s32 arg0) { + switch (D_80164678[arg0]) { + case 0: + if (D_80164608[arg0] == 1) { + D_80164678[arg0] = 1; + func_800C9060(arg0, SOUND_ARG_LOAD(0x19, 0x00, 0x90, 0x4F)); + D_80164670[arg0] = D_80164678[arg0]; + } + break; + case 1: + if (D_80164608[arg0] == 1) { + D_80164678[arg0] = 0; + func_800C9060(arg0, SOUND_ARG_LOAD(0x19, 0x00, 0x90, 0x50)); + D_80164670[arg0] = D_80164678[arg0]; + } + break; + } +} + +void func_80019D2C(Camera* camera, Player* player, s32 arg2) { + s32 playerId; + s32 nearestPathPoint; + + playerId = camera->playerId; + if ((gIncrementUpdatePlayer != 0) && (gCurrentCourseId == COURSE_LUIGI_RACEWAY)) { + calculate_camera_up_vector(camera, arg2); + nearestPathPoint = gNearestPathPointByPlayerId[playerId]; + if (((nearestPathPoint >= 0x65) && (nearestPathPoint < 0xFA)) || + ((nearestPathPoint >= 0x1AF) && (nearestPathPoint < 0x226))) { + func_80019B50(arg2, (player->unk_206 * 2)); + } else { + func_80019B50(arg2, 0U); + } + } +} + +void func_80019DE4(void) { + D_801646CC = 1; +} + +void func_80019DF4(void) { + s32 i; + s32 playerId = gGPCurrentRacePlayerIdByRank[0]; + // clang-format off + // Has to be on a single line to match. Because IDO hates you :) + for (i = 0; i < 4; i++) { D_80164670[i] = D_80164678[i]; } + // clang-format on + camera1->playerId = playerId; + D_80164678[0] = 1; + D_801646CC = 2; +} + +void func_80019E58(void) { + D_80164680[0] = 1; + func_80019890(0, 0); + D_80164670[0] = D_80164678[0]; + D_80164678[0] = 1; + D_80164680[1] = 9; + func_80019890(0, 1); + D_80164670[1] = D_80164678[1]; + D_80164678[1] = 0; +} + +void func_80019ED0(void) { + s32 i; + + for (i = 0; i < 4; i++) { + D_80164670[i] = D_80164678[i]; + } + + gGPCurrentRacePlayerIdByRank[0] = (s16) gPlayerWinningIndex; + + camera1->playerId = (s16) gPlayerWinningIndex; + + for (i = 0; i < 4; i++) { + D_80164680[i] = 0; + func_80015314(gPlayerWinningIndex, 0, i); + D_80164678[i] = 1; + } +} + +void func_80019FB4(s32 cameraId) { + struct Controller* controller; + + controller = &gControllerOne[cameraId]; + if (controller->buttonPressed & L_CBUTTONS) { + D_801645D0[cameraId] += 1; + } else { + D_801645D0[cameraId] = 0; + } + if (controller->buttonPressed & D_CBUTTONS) { + D_801645E8[cameraId] += 1; + } else { + D_801645E8[cameraId] = 0; + } + if (controller->buttonPressed & U_CBUTTONS) { + D_80164608[cameraId] += 1; + } else { + D_80164608[cameraId] = 0; + } + if (controller->buttonPressed & R_CBUTTONS) { + D_80164628[cameraId] += 1; + } else { + D_80164628[cameraId] = 0; + } +} + +void func_8001A0A4(UNUSED u16* arg0, UNUSED Camera* arg1, UNUSED Player* arg2, UNUSED s8 arg3, s32 arg4) { + func_80019FB4(arg4); + func_80019C50(arg4); +} + +void func_8001A0DC(u16* arg0, Camera* arg1, Player* arg2, s8 arg3, s32 arg4) { + func_8001A0A4(arg0, arg1, arg2, arg3, arg4); + func_80019D2C(arg1, arg2, arg4); +} + +void func_8001A124(s32 arg0, s32 arg1) { + switch (gGPCurrentRaceRankByPlayerId[arg0]) { /* irregular */ + case 0: + if (random_int(0x0064U) < 0x32) { + D_80164680[arg1] = 0x000C; + } else { + D_80164680[arg1] = 0x000D; + } + func_800CA270(); + break; + case 1: + case 2: + case 3: + D_80164680[arg1] = 8; + break; + default: + if (random_int(0x0064U) < 0x32) { + D_80164680[arg1] = 0x000F; + } else { + D_80164680[arg1] = 0x0010; + } + break; + } +} + +void func_8001A220(UNUSED s32 arg0, s32 cameraId) { + switch (random_int(6)) { + case 0: + D_80164680[cameraId] = 4; + break; + case 1: + D_80164680[cameraId] = 5; + break; + case 2: + D_80164680[cameraId] = 6; + break; + case 3: + D_80164680[cameraId] = 7; + break; + case 4: + D_80164680[cameraId] = 8; + break; + case 5: + D_80164680[cameraId] = 1; + break; + default: + D_80164680[cameraId] = 8; + break; + } +} + +s32 func_8001A310(s32 pathPoint, s32 arg1) { + if ((gCurrentCourseId == COURSE_BOWSER_CASTLE) && (arg1 != 0) && (pathPoint >= 0xE7) && (pathPoint < 0x1C2)) { + arg1 = 0; + } + return arg1; +} + +void func_8001A348(s32 cameraId, f32 arg1, s32 arg2) { + UNUSED s32 pad; + s32 playerId; + + playerId = cameras[cameraId].playerId; + D_80164688[cameraId] = arg1; + D_80164680[cameraId] = func_8001A310((s32) gNearestPathPointByCameraId[cameraId], arg2); + func_80019890(playerId, cameraId); +} + +void func_8001A3D8(s32 arg0, f32 arg1, s32 arg2) { + s32 playerId; + + playerId = cameras[arg0].playerId; + D_80164688[arg0] = arg1; + if (arg2 != D_80164680[arg0]) { + D_80164680[arg0] = arg2; + func_80019890(playerId, arg0); + } +} + +void func_8001A450(s32 playerId, s32 arg1, s32 arg2) { + s32 temp_v1; + s16 pathPoint; + s32 temp_v0; + + if (!(gPlayers[playerId].effects & (UNKNOWN_EFFECT_0x10000000 | UNKNOWN_EFFECT_0xC))) { + temp_v1 = D_80164680[arg1]; + pathPoint = gNearestPathPointByCameraId[arg1]; + temp_v0 = func_8001A310(pathPoint, (temp_v1 + 1) % 10); + if ((temp_v0 != temp_v1) || (arg2 != playerId)) { + D_80164680[arg1] = temp_v0; + func_80019890(arg2, arg1); + } + } +} + +void func_8001A518(s32 arg0, s32 arg1, s32 arg2) { + switch (arg1) { /* irregular */ + case 0: + D_80164680[arg2] = 1; + break; + case 1: + case 2: + case 3: + func_8001A450(arg0, arg2, arg0); + break; + default: + D_80164680[arg2] = 0; + break; + } +} + +void func_8001A588(UNUSED u16* localD_80152300, Camera* camera, Player* player, s8 index, s32 cameraIndex) { + s32 var_v1; + UnkStruct_46D0* temp_v0_4; + s32 sp44; + s32 playerId; + playerId = camera->playerId; + + if (gModeSelection == TIME_TRIALS) { + playerId = 0; + } + func_80019FB4(cameraIndex); + + if ((s32) (camera->pos[0] * 10.0) == (s32) ((f64) camera->lookAt[0] * 10.0)) { + + if ((s32) (camera->pos[2] * 10.0) == (s32) ((f64) camera->lookAt[2] * 10.0)) { + camera->pos[0] = (f32) (camera->pos[0] + 100.0); + camera->pos[2] = (f32) (camera->pos[2] + 100.0); + } + } + if ((gModeSelection != BATTLE) && (D_80164680[cameraIndex] == -1) && (player->type & PLAYER_CINEMATIC_MODE) && + ((u16) D_801646CC == 0) && (D_801646C8 == 0)) { + if (gModeSelection == VERSUS) { + func_8001A220(playerId, cameraIndex); + } else { + func_8001A124((s32) playerId, cameraIndex); + } + func_80019890((s32) playerId, cameraIndex); + } + + if ((D_80164680[cameraIndex] == 14) || (D_80164680[cameraIndex] == 0)) { + func_80019D2C(camera, player, cameraIndex); + } else { + D_801646C0[cameraIndex] = 0; + calculate_camera_up_vector(camera, cameraIndex); + } + switch ((u16) D_801646CC) { + case 1: + D_801646C8 += 1; + if (D_801646C8 >= 501) { + D_801646C8 = 0; + } + if ((cameraIndex == 0) && (((D_801646C8 == 10)) || (D_801646C8 == 11))) { + func_8001A518((s32) playerId, gGPCurrentRaceRankByPlayerId[playerId], 0); + } + if ((gModeSelection != TIME_TRIALS) && (cameraIndex == 1) && + (((D_801646C8 == 260)) || (D_801646C8 == 261))) { + + var_v1 = 0; + if (gPlayerCount == 2) { + func_8001A518((s32) playerId, gGPCurrentRaceRankByPlayerId[playerId], 1); + } else { + sp44 = (s32) playerId; + while (var_v1 != 8) { + playerId += 1; + var_v1 += 1; + if (playerId >= 8) { + playerId = 1; + } + if ((!(gPlayers[playerId].unk_0CA & 2) && !(gPlayers[playerId].unk_0CA & 8))) { + break; + } + } + func_8001A450(sp44, cameraIndex, (s32) playerId); + } + } + break; + case 2: + D_801646C8 += 1; + if (D_801646C8 > 250) { + D_801646C8 = 0; + } + if ((cameraIndex == 0) && (D_801646C8 == 10)) { + func_8001A450((s32) playerId, cameraIndex, (s32) playerId); + } + break; + default: + temp_v0_4 = &D_801646D0[cameraIndex]; + if (temp_v0_4->unk0 == (s16) 1) { + playerId = temp_v0_4->unk4; + temp_v0_4->unk0 = 0; + cameras[cameraIndex].playerId = playerId; + func_8001A3D8(cameraIndex, 0.0f, (s32) temp_v0_4->unk2); + } + break; + } + func_80019C50(cameraIndex); + switch (D_80164680[cameraIndex]) { + case 0: + func_80015390(camera, player, index); + break; + case 2: + case 3: + func_8001577C(camera, player, index, cameraIndex); + break; + case 6: + case 7: + func_80015C94(camera, player, index, cameraIndex); + break; + case 4: + case 5: + func_80016494(camera, player, index, cameraIndex); + break; + case 9: + func_80017054(camera, player, index, cameraIndex); + break; + case 1: + func_800178F4(camera, player, index, cameraIndex); + break; + case 14: + func_800180F0(camera, player, index, cameraIndex); + break; + case 8: + func_800188F4(camera, player, index, cameraIndex); + break; + case 12: + case 13: + func_8001933C(camera, player, index, cameraIndex); + break; + case 15: + case 16: + func_80019760(camera, player, index, cameraIndex); + break; + default: + func_80015390(camera, player, index); + break; + } +} + +void func_8001AAAC(s16 arg0, s16 arg1, s16 arg2) { + if (D_801646D0[arg0].unk0 == 0) { + D_801646D0[arg0].unk0 = 1; + D_801646D0[arg0].unk2 = arg1; + D_801646D0[arg0].unk4 = arg2; + } +} + +#include "cpu_vehicles_camera_path/cpu_item_strategy.inc.c" + +#ifdef NON_MATCHING +// By the looks of this function is probably something like `cpu_use_item_strategy` +// The use of several different actor types might make getting a match hard(er), +// might have to get creative/ugly with just a single generic `Actor` variable. +// https://decomp.me/scratch/FOlbG +void cpu_use_item_strategy(s32 playerId) { + bool isNoProblem; + Player* player; + TrackPathPoint* pathPoint; + CpuItemStrategyData* temp_s0; + struct Actor* actor; + struct ShellActor* shell; + struct BananaActor* banana; + struct FakeItemBox* fakeItemBox; + struct BananaBunchParent* bananaBunchParent; + + player = &gPlayerOne[playerId]; + if (((gModeSelection != ((s32) 1)) && (((u16) D_801646CC) != ((u16) 1))) && + (!(player->type & PLAYER_CINEMATIC_MODE))) { + temp_s0 = &cpu_ItemStrategy[playerId]; + switch (temp_s0->branch) { + case CPU_STRATEGY_WAIT_NEXT_ITEM: + temp_s0->actorIndex = -1; + if ((((playerId * 0x14) + 0x64) < gNumPathPointsTraversed[playerId]) && (temp_s0->timer >= 0x259) && + (temp_s0->numItemUse < 3) && (gLapCountByPlayerId[playerId] < 3)) { + cpu_decisions_branch_item(playerId, &temp_s0->branch, + cpu_gen_random_item((s16) gLapCountByPlayerId[playerId], + gGPCurrentRaceRankByPlayerId[playerId])); + } else { + func_8001ABE0(playerId, temp_s0); + } + break; + + case CPU_STRATEGY_ITEM_BANANA: + // never true + if ((gLapCountByPlayerId[playerId] > 0) && + (gGPCurrentRaceRankByPlayerId[gBestRankedHumanPlayer] > gGPCurrentRaceRankByPlayerId[playerId]) && + (gGPCurrentRaceRankByPlayerId[gBestRankedHumanPlayer] == FIRST_PLACE)) { + switch (player->characterId) { + case DK: + if (is_path_point_in_range(gNearestPathPointByPlayerId[playerId], + gNearestPathPointByPlayerId[gBestRankedHumanPlayer], 0x0028U, 2U, + (u16) ((s32) gSelectedPathCount)) > 0) { + temp_s0->branch = CPU_STRATEGY_THROW_BANANA; + } + break; + + case PEACH: + if (is_path_point_in_range(gNearestPathPointByPlayerId[playerId], + gNearestPathPointByPlayerId[gBestRankedHumanPlayer], 4U, 2U, + (u16) ((s32) gSelectedPathCount)) > 0) { + temp_s0->branch = CPU_STRATEGY_THROW_BANANA; + } + break; + + default: + if (is_path_point_in_range(gNearestPathPointByPlayerId[playerId], + gNearestPathPointByPlayerId[gBestRankedHumanPlayer], 0x000AU, 2U, + (u16) ((s32) gSelectedPathCount)) > 0) { + temp_s0->branch = CPU_STRATEGY_THROW_BANANA; + } + break; + } + } else if (temp_s0->branch == CPU_STRATEGY_ITEM_BANANA) { + temp_s0->actorIndex = use_banana_item(player); + if ((temp_s0->actorIndex >= 0) && (temp_s0->actorIndex < 0x64)) { + player->soundEffects |= HOLD_BANANA_SOUND_EFFECT; + temp_s0->branch = CPU_STRATEGY_HOLD_BANANA; + temp_s0->timer = 0; + temp_s0->numItemUse += 1; + temp_s0->timeBeforeThrow = (random_int(3U) * 0x14) + 0xA; + } else { + temp_s0->branch = CPU_STRATEGY_WAIT_NEXT_ITEM; + temp_s0->timer = 0; + } + } + break; + + case CPU_STRATEGY_HOLD_BANANA: + banana = (struct BananaActor*) &gActorList[temp_s0->actorIndex]; + if ((!(banana->flags & 0x8000)) || (banana->type != ACTOR_BANANA) || (banana->state != HELD_BANANA) || + (playerId != banana->playerId)) { + temp_s0->branch = CPU_STRATEGY_WAIT_NEXT_ITEM; + temp_s0->timer = 0; + player->soundEffects &= ~HOLD_BANANA_SOUND_EFFECT; + } else if (temp_s0->timeBeforeThrow < temp_s0->timer) { + temp_s0->branch = CPU_STRATEGY_DROP_BANANA; + } + break; + + case CPU_STRATEGY_DROP_BANANA: + banana = (struct BananaActor*) &gActorList[temp_s0->actorIndex]; + if ((((!(banana->flags & 0x8000)) || (banana->type != ACTOR_BANANA)) || + (banana->state != HELD_BANANA)) || + (playerId != banana->playerId)) { + if (playerId != banana->playerId) {} + } else { + banana->state = DROPPED_BANANA; + banana->velocity[0] = 0.0f; + banana->velocity[1] = 0.0f; + banana->velocity[2] = 0.0f; + if (D_801631E0[playerId] == ((u16) true)) { + banana->pos[1] = + get_surface_height(player->pos[0], (f32) (((f64) player->pos[1]) + 30.0), player->pos[2]) + + (banana->boundingBoxSize + 1.0f); + } + } + player->soundEffects &= ~HOLD_BANANA_SOUND_EFFECT; + temp_s0->timer = 0; + temp_s0->branch = CPU_STRATEGY_WAIT_NEXT_ITEM; + break; + + case CPU_STRATEGY_THROW_BANANA: + temp_s0->actorIndex = use_banana_item(player); + if ((temp_s0->actorIndex >= 0) && (temp_s0->actorIndex < 0x64)) { + banana = (struct BananaActor*) &gActorList[temp_s0->actorIndex]; + banana->state = BANANA_ON_GROUND; + player->soundEffects |= HOLD_BANANA_SOUND_EFFECT; + temp_s0->branch = CPU_STRATEGY_HOLD_THROW_BANANA; + temp_s0->timer = 0; + temp_s0->numItemUse += 1; + pathPoint = &gTrackPaths[gPathIndexByPlayerId[0]] + [(gNearestPathPointByPlayerId[gBestRankedHumanPlayer] + 0x1E) % + gPathCountByPathIndex[gPathIndexByPlayerId[gBestRankedHumanPlayer]]]; + banana->velocity[0] = (pathPoint->posX - player->pos[0]) / 20.0; + banana->velocity[1] = ((pathPoint->posY - player->pos[1]) / 20.0) + 4.0; + banana->velocity[2] = (pathPoint->posZ - player->pos[2]) / 20.0; + banana->pos[1] = player->pos[1]; + func_800C92CC(playerId, SOUND_ARG_LOAD(0x29, 0x00, 0x80, 0x09)); + func_800C98B8(player->pos, player->velocity, SOUND_ARG_LOAD(0x19, 0x01, 0x80, 0x14)); + } else { + temp_s0->branch = CPU_STRATEGY_WAIT_NEXT_ITEM; + temp_s0->timer = 0; + } + break; + + case CPU_STRATEGY_HOLD_THROW_BANANA: + banana = (struct BananaActor*) &gActorList[temp_s0->actorIndex]; + if ((((!(banana->flags & 0x8000)) || (banana->type != ACTOR_BANANA)) || + (banana->state != BANANA_ON_GROUND)) || + (playerId != banana->playerId)) { + temp_s0->branch = CPU_STRATEGY_WAIT_NEXT_ITEM; + temp_s0->timer = 0; + player->soundEffects &= ~HOLD_BANANA_SOUND_EFFECT; + } else { + banana->velocity[1] -= 0.4; + banana->pos[0] += banana->velocity[0]; + banana->pos[1] += banana->velocity[1]; + banana->pos[2] += banana->velocity[2]; + if (temp_s0->timer >= 0x15) { + temp_s0->branch = CPU_STRATEGY_END_THROW_BANANA; + } + } + break; + + case CPU_STRATEGY_END_THROW_BANANA: + banana = (struct BananaActor*) &gActorList[temp_s0->actorIndex]; + if ((((!(banana->flags & 0x8000)) || (banana->type != ACTOR_BANANA)) || + (banana->state != BANANA_ON_GROUND)) || + (playerId != banana->playerId)) { + if (playerId != banana->playerId) {} + } else { + banana->state = DROPPED_BANANA; + banana->velocity[0] = 0.0f; + banana->velocity[1] = 0.0f; + banana->velocity[2] = 0.0f; + banana->pos[1] = + get_surface_height(banana->pos[0], (f32) (((f64) banana->pos[1]) + 30.0), banana->pos[2]) + + (banana->boundingBoxSize + 1.0f); + } + player->soundEffects &= ~HOLD_BANANA_SOUND_EFFECT; + temp_s0->branch = CPU_STRATEGY_WAIT_NEXT_ITEM; + temp_s0->timer = 0; + break; + + case CPU_STRATEGY_ITEM_GREEN_SHELL: + if (((s32) gNumActors) < 0x50) { + temp_s0->actorIndex = use_green_shell_item(player); + if ((temp_s0->actorIndex >= 0) && (temp_s0->actorIndex < 0x64)) { + temp_s0->branch = CPU_STRATEGY_HOLD_GREEN_SHELL; + temp_s0->timer = 0; + temp_s0->numItemUse += 1; + temp_s0->timeBeforeThrow = (random_int(3U) * 0x14) + 0xA; + } else { + temp_s0->branch = CPU_STRATEGY_WAIT_NEXT_ITEM; + } + } else { + temp_s0->branch = CPU_STRATEGY_WAIT_NEXT_ITEM; + } + break; + + case CPU_STRATEGY_HOLD_GREEN_SHELL: + actor = &gActorList[temp_s0->actorIndex]; + if ((((!(actor->flags & 0x8000)) || (actor->type != ACTOR_GREEN_SHELL)) || + (actor->state != HELD_SHELL)) || + (playerId != actor->rot[2])) { + temp_s0->branch = CPU_STRATEGY_WAIT_NEXT_ITEM; + temp_s0->timer = 0; + } else if (temp_s0->timeBeforeThrow < temp_s0->timer) { + temp_s0->branch = CPU_STRATEGY_THROW_GREEN_SHELL; + temp_s0->timer = 0; + } + break; + + case CPU_STRATEGY_THROW_GREEN_SHELL: + actor = &gActorList[temp_s0->actorIndex]; + if ((((!(actor->flags & 0x8000)) || (actor->type != ACTOR_GREEN_SHELL)) || + (actor->state != HELD_SHELL)) || + (playerId != actor->rot[2])) { + temp_s0->branch = CPU_STRATEGY_WAIT_NEXT_ITEM; + temp_s0->timer = 0; + } else { + actor->state = RELEASED_SHELL; + temp_s0->timer = 0; + temp_s0->branch = CPU_STRATEGY_WAIT_NEXT_ITEM; + } + break; + + case CPU_STRATEGY_ITEM_RED_SHELL: + if (((s32) gNumActors) < 0x50) { + temp_s0->actorIndex = use_red_shell_item(player); + if ((temp_s0->actorIndex >= 0) && (temp_s0->actorIndex < 0x64)) { + temp_s0->branch = CPU_STRATEGY_HOLD_RED_SHELL; + temp_s0->timer = 0; + temp_s0->numItemUse += 1; + temp_s0->timeBeforeThrow = (random_int(3U) * 0x14) + 0xA; + } else { + temp_s0->branch = CPU_STRATEGY_WAIT_NEXT_ITEM; + } + } else { + temp_s0->branch = CPU_STRATEGY_WAIT_NEXT_ITEM; + } + break; + + case CPU_STRATEGY_HOLD_RED_SHELL: + shell = (struct ShellActor*) &gActorList[temp_s0->actorIndex]; + if ((((!(shell->flags & 0x8000)) || (shell->type != ACTOR_RED_SHELL)) || + (shell->state != HELD_SHELL)) || + (playerId != shell->playerId)) { + temp_s0->branch = CPU_STRATEGY_WAIT_NEXT_ITEM; + temp_s0->timer = 0; + } else if (temp_s0->timeBeforeThrow < temp_s0->timer) { + temp_s0->branch = CPU_STRATEGY_THROW_RED_SHELL; + } + break; + + case CPU_STRATEGY_THROW_RED_SHELL: + clear_expired_strategies(temp_s0); + shell = (struct ShellActor*) &gActorList[temp_s0->actorIndex]; + if ((((!(shell->flags & 0x8000)) || (shell->type != ACTOR_RED_SHELL)) || + (shell->state != HELD_SHELL)) || + (playerId != shell->playerId)) { + temp_s0->branch = CPU_STRATEGY_WAIT_NEXT_ITEM; + temp_s0->timer = 0; + } else { + shell->state = RELEASED_SHELL; + temp_s0->timer = 0; + temp_s0->branch = CPU_STRATEGY_WAIT_NEXT_ITEM; + } + break; + + case CPU_STRATEGY_ITEM_BANANA_BUNCH: + if (((s32) gNumActors) < 0x50) { + temp_s0->actorIndex = use_banana_bunch_item(player); + if ((temp_s0->actorIndex >= 0) && (temp_s0->actorIndex < 0x64)) { + temp_s0->branch = CPU_STRATEGY_WAIT_INIT_BANANA_BUNCH; + temp_s0->timer = 0; + temp_s0->numItemUse += 1; + temp_s0->timeBeforeThrow = (random_int(3U) * 0x14) + 0x3C; + } else { + temp_s0->branch = CPU_STRATEGY_WAIT_NEXT_ITEM; + } + } else { + temp_s0->branch = CPU_STRATEGY_WAIT_NEXT_ITEM; + } + break; + + case CPU_STRATEGY_WAIT_INIT_BANANA_BUNCH: + bananaBunchParent = (struct BananaBunchParent*) &gActorList[temp_s0->actorIndex]; + if (bananaBunchParent->state == 6) { + isNoProblem = false; + if (bananaBunchParent->bananaIndices[4] != (-1)) { + isNoProblem = true; + } + if (bananaBunchParent->bananaIndices[3] != (-1)) { + isNoProblem = true; + } + if (bananaBunchParent->bananaIndices[2] != (-1)) { + isNoProblem = true; + } + if (bananaBunchParent->bananaIndices[1] != (-1)) { + isNoProblem = true; + } + if (bananaBunchParent->bananaIndices[0] != (-1)) { + isNoProblem = true; + } + if ((bananaBunchParent->type != ACTOR_BANANA_BUNCH) || (isNoProblem == false)) { + temp_s0->branch = CPU_STRATEGY_WAIT_NEXT_ITEM; + temp_s0->timer = 0; + } else if (temp_s0->timeBeforeThrow < temp_s0->timer) { + temp_s0->branch = CPU_STRATEGY_DROP_BANANA_BUNCH; + temp_s0->numDroppedBananaBunch = 0; + temp_s0->timer = 0; + } + } + break; + + case CPU_STRATEGY_DROP_BANANA_BUNCH: + if ((((s16) temp_s0->timer) % 10) == 0) { + if (temp_s0->numDroppedBananaBunch < 5) { + bananaBunchParent = (struct BananaBunchParent*) &gActorList[temp_s0->actorIndex]; + isNoProblem = 0; + switch (temp_s0->numDroppedBananaBunch) { + case 0: + if (bananaBunchParent->bananaIndices[4] != (-1)) { + isNoProblem = true; + } + break; + + case 1: + if (bananaBunchParent->bananaIndices[3] != (-1)) { + isNoProblem = true; + } + break; + + case 2: + if (bananaBunchParent->bananaIndices[2] != (-1)) { + isNoProblem = true; + } + break; + + case 3: + if (bananaBunchParent->bananaIndices[1] != (-1)) { + isNoProblem = true; + } + break; + + case 4: + if (bananaBunchParent->bananaIndices[0] != (-1)) { + isNoProblem = true; + } + break; + } + + if (((bananaBunchParent->type == ACTOR_BANANA_BUNCH) && (bananaBunchParent->state == 6)) && + (isNoProblem == true)) { + drop_banana_in_banana_bunch(bananaBunchParent); + } + temp_s0->numDroppedBananaBunch += 1; + } else { + temp_s0->branch = CPU_STRATEGY_WAIT_NEXT_ITEM; + temp_s0->timer = 0; + } + } + break; + + case CPU_STRATEGY_ITEM_FAKE_ITEM_BOX: + temp_s0->actorIndex = use_fake_itembox_item(player); + if ((temp_s0->actorIndex >= 0) && (temp_s0->actorIndex < 0x64)) { + temp_s0->branch = CPU_STRATEGY_HOLD_FAKE_ITEM_BOX; + temp_s0->timer = 0; + temp_s0->numItemUse += 1; + temp_s0->timeBeforeThrow = (random_int(3U) * 0x14) + 0xA; + } else { + temp_s0->branch = CPU_STRATEGY_WAIT_NEXT_ITEM; + } + break; + + case CPU_STRATEGY_HOLD_FAKE_ITEM_BOX: + fakeItemBox = (struct FakeItemBox*) &gActorList[temp_s0->actorIndex]; + if ((((!(fakeItemBox->flags & 0x8000)) || (fakeItemBox->type != ACTOR_FAKE_ITEM_BOX)) || + (fakeItemBox->state != 0)) || + (playerId != ((s32) fakeItemBox->playerId))) { + temp_s0->branch = CPU_STRATEGY_WAIT_NEXT_ITEM; + temp_s0->timer = 0; + } else if (temp_s0->timeBeforeThrow < temp_s0->timer) { + temp_s0->branch = CPU_STRATEGY_THROW_FAKE_ITEM_BOX; + } + break; + + case CPU_STRATEGY_THROW_FAKE_ITEM_BOX: + fakeItemBox = (struct FakeItemBox*) &gActorList[temp_s0->actorIndex]; + if ((((!(fakeItemBox->flags & 0x8000)) || (fakeItemBox->type != ACTOR_FAKE_ITEM_BOX)) || + (fakeItemBox->state != 0)) || + (playerId != ((s32) fakeItemBox->playerId))) { + if (playerId != fakeItemBox->rot[0]) {} + } else { + func_802A1064(fakeItemBox); + if (D_801631E0[playerId] == true) { + fakeItemBox->pos[1] = + get_surface_height(fakeItemBox->pos[0], fakeItemBox->pos[1] + 30.0, fakeItemBox->pos[2]) + + fakeItemBox->boundingBoxSize; + } + } + temp_s0->branch = CPU_STRATEGY_WAIT_NEXT_ITEM; + temp_s0->timer = 0; + break; + + case CPU_STRATEGY_ITEM_THUNDERBOLT: + use_thunder_item(player); + func_800CAC60(playerId); + func_8009E5BC(); + temp_s0->branch = CPU_STRATEGY_END_THUNDERBOLT; + temp_s0->timer = 0; + temp_s0->numItemUse += 1; + break; + + case CPU_STRATEGY_END_THUNDERBOLT: + if (temp_s0->timer >= 0xF1) { + func_800CAD40((s32) ((u8) playerId)); + temp_s0->branch = CPU_STRATEGY_WAIT_NEXT_ITEM; + temp_s0->timer = 0; + } + break; + + case CPU_STRATEGY_ITEM_STAR: + player->soundEffects |= STAR_SOUND_EFFECT; + temp_s0->branch = CPU_STRATEGY_END_ITEM_STAR; + temp_s0->timer = 0; + temp_s0->numItemUse += 1; + break; + + case CPU_STRATEGY_END_ITEM_STAR: + if (!(player->effects & STAR_EFFECT)) { + temp_s0->branch = CPU_STRATEGY_WAIT_NEXT_ITEM; + } + temp_s0->timer = 0; + break; + + case CPU_STRATEGY_ITEM_BOO: + player->soundEffects |= BOO_SOUND_EFFECT; + temp_s0->branch = CPU_STRATEGY_WAIT_END_BOO; + temp_s0->timer = 0; + temp_s0->numItemUse += 1; + break; + + case CPU_STRATEGY_WAIT_END_BOO: + if (!(player->effects & BOO_EFFECT)) { + temp_s0->branch = CPU_STRATEGY_WAIT_NEXT_ITEM; + } + temp_s0->timer = 0; + break; + + case CPU_STRATEGY_ITEM_MUSHROOM: + player->soundEffects |= BOOST_SOUND_EFFECT; + temp_s0->branch = CPU_STRATEGY_WAIT_NEXT_ITEM; + temp_s0->timer = 0; + temp_s0->numItemUse += 1; + break; + + case CPU_STRATEGY_ITEM_DOUBLE_MUSHROOM: + if (temp_s0->timer >= 0x3D) { + player->soundEffects |= BOOST_SOUND_EFFECT; + temp_s0->branch = CPU_STRATEGY_ITEM_MUSHROOM; + temp_s0->timer = 0; + } + break; + + case CPU_STRATEGY_ITEM_TRIPLE_MUSHROOM: + if (temp_s0->timer >= 0x3D) { + player->soundEffects |= BOOST_SOUND_EFFECT; + temp_s0->branch = CPU_STRATEGY_ITEM_DOUBLE_MUSHROOM; + temp_s0->timer = 0; + } + break; + + case CPU_STRATEGY_ITEM_SUPER_MUSHROOM: + temp_s0->branch = CPU_STRATEGY_USE_SUPER_MUSHROOM; + temp_s0->timer = 0; + temp_s0->timeBeforeThrow = 0x0258; + break; + + case CPU_STRATEGY_USE_SUPER_MUSHROOM: + if ((((s16) temp_s0->timer) % 60) == 0) { + player->soundEffects |= BOOST_SOUND_EFFECT; + if (temp_s0->timeBeforeThrow < temp_s0->timer) { + temp_s0->branch = CPU_STRATEGY_WAIT_NEXT_ITEM; + temp_s0->timer = 0; + } + } + break; + + default: + break; + } + + if (temp_s0->timer < 0x2710) { + temp_s0->timer += 1; + } + if (player->effects & (BOO_EFFECT | BOOST_EFFECT | STAR_EFFECT)) { // 0x80002200 + temp_s0->timer = 0; + } + } +} +#else +GLOBAL_ASM("asm/non_matchings/cpu_vehicles_camera_path/cpu_use_item_strategy.s") +#endif + +void func_8001BE78(void) { + Player* temp_s1; + TrackPathPoint* temp_s0; + s32 i; + + init_players(); + for (i = 0; i < 4; i++) { + temp_s1 = &gPlayerOne[i]; + temp_s1->type &= 0xDFFF; + gPathIndexByPlayerId[i] = i; + gPlayerTrackPositionFactorInstruction[i].unkC = 0.0f; + gPlayerTrackPositionFactorInstruction[i].target = 0.0f; + gPlayerTrackPositionFactorInstruction[i].current = 0.0f; + switch (i) { + case 0: + gNearestPathPointByPlayerId[i] = 6; + break; + case 1: + gNearestPathPointByPlayerId[i] = 1; + break; + case 2: + gNearestPathPointByPlayerId[i] = 6; + break; + case 3: + gNearestPathPointByPlayerId[i] = 1; + break; + } + temp_s0 = &gTrackPaths[i][gNearestPathPointByPlayerId[i]]; + temp_s1->pos[0] = (f32) temp_s0->posX; + temp_s1->pos[1] = + get_surface_height((f32) temp_s0->posX, 2000.0f, (f32) temp_s0->posZ) + temp_s1->boundingBoxSize; + temp_s1->pos[2] = (f32) temp_s0->posZ; + temp_s1->rotation[1] = (s16) *gPathExpectedRotation[i]; + apply_cpu_turn(temp_s1, 0); + temp_s1++; + D_80163410[i] = 0; + } +} + +void func_8001C05C(void) { + init_segment_racing(); + gCurrentCourseId = COURSE_AWARD_CEREMONY; + D_8016347C = 0; + D_8016347E = 0; + D_80163480 = 0; + D_80163484 = 0; + init_course_path_point(); + func_80014DE4(0); + func_8001BE78(); + D_80163418[0] = -3202.475097656f; + D_80163428[0] = 19.166999817f; + D_80163438[0] = -477.623992920f; + D_80163418[1] = -3205.080078125f; + D_80163428[1] = 19.166999817f; + D_80163438[1] = -462.851989746f; + D_80163418[2] = -3199.870117188f; + D_80163428[2] = 19.166999817f; + D_80163438[2] = -492.395996094f; + D_80163418[3] = -2409.197021484f; + D_80163428[3] = 0.0f; + D_80163438[3] = -355.253997803; +} + +void func_8001C14C(void) { + f32 temp_f0; + f32 temp_f2; + s32 playerId; + Player* temp_s0; + + if (D_8016347C == 1) { + D_80163480 += 1; + } + if ((D_8016347E == 1) && (gBombKarts[0].state == 0) && (D_802874D8.unk1D >= 3)) { + D_80163484++; + if (D_80163484 >= 0xF) { + D_80163484 = 0; + D_8016347E = 2; + func_8009265C(); + } + } + for (playerId = 0; playerId < 4; playerId++) { + if ((playerId == 3) && (D_8016347C == 0)) { + break; + } + + temp_s0 = &gPlayerOne[playerId]; + update_player(playerId); + if (!(temp_s0->type & 0x2000)) { + temp_f0 = D_80163418[playerId] - temp_s0->pos[0]; + temp_f2 = D_80163438[playerId] - temp_s0->pos[2]; + if ((f64) ((temp_f0 * temp_f0) + (temp_f2 * temp_f2)) < 1.0) { + if (playerId != 3) { + if (1) {} + // Why oh why is a ternary required here? Who does that? + (D_8016347C == 0) ? (temp_s0->type |= 0x2000) : (temp_s0->type &= ~0x2000); + if ((gPlayerOne->type & 0x2000) && (gPlayerTwo->type & 0x2000) && (gPlayerThree->type & 0x2000)) { + D_8016347C = 1; + D_80163480 = 0; + } + } else if (D_8016347E == 0) { + if (!(temp_s0->effects & UNKNOWN_EFFECT_0x1000000)) { + temp_s0->type |= 0x2000; + } + D_8016347E = 1; + D_80163484 = 0; + } else if (!(temp_s0->effects & UNKNOWN_EFFECT_0x1000000)) { + temp_s0->type |= 0x2000; + } + } + } + } +} + +void func_8001C3C4(s32 cameraId) { + if (gCurrentCourseId == COURSE_AWARD_CEREMONY) { + if (gBombKarts[0].pathPointIndex >= 16) { + func_80057114(PLAYER_FOUR); + } + } else { + if (gModeSelection == VERSUS) { + func_80057114(cameraId); + } + } +} + +UNUSED void func_8001C42C(void) { + if (D_800DDB20 == 0) { + if ((gControllerThree->buttonPressed & 0x20) != 0) { + D_800DDB20 = 1; + } + } else { + if ((gControllerThree->buttonPressed & 0x20) != 0) { + D_800DDB20 = 0; + } + func_80057C60(); + gSPDisplayList(gDisplayListHead++, D_0D0076F8); + func_80057CE4(); + } +} diff --git a/src/cpu_vehicles_camera_path.h b/src/cpu_vehicles_camera_path.h new file mode 100644 index 0000000000..fc9171d613 --- /dev/null +++ b/src/cpu_vehicles_camera_path.h @@ -0,0 +1,448 @@ +#ifndef cpu_vehicles_camera_path_H +#define cpu_vehicles_camera_path_H + +#include "vehicles.h" +#include "camera.h" +#include "path.h" +#include + +struct unexpiredActors { + /* 0x00 */ s32 unk0; + /* 0x04 */ s32 unk4; + /* 0x08 */ s32 unk8; + /* 0x0C */ u16 unkC; + /* 0x0E */ u16 actorIndex; + /* 0x10 */ s16 unk10; + /* 0x12 */ // s16 compilerPadding; + /* 0x14 */ u32 unk14; + /* 0x18 */ s32 unk18; +}; // size = 0x1C + +typedef struct { + /* 0x00 */ f32 current; + /* 0x04 */ f32 target; + /* 0x08 */ f32 step; + /* 0x0C */ f32 unkC; +} TrackPositionFactorInstruction; // size = 0x10 + +// Something related to CPU item usage +typedef struct { + /* 0x00 */ s16 branch; + /* 0x02 */ s16 actorIndex; + /* 0x04 */ s16 timer; // confirm? + /* 0x06 */ s16 numItemUse; // confirm? + /* 0x08 */ s16 numDroppedBananaBunch; + /* 0x0A */ s16 unk_0A; + /* 0x0C */ s16 unk_0C; + /* 0x0E */ s16 timeBeforeThrow; +} CpuItemStrategyData; // size = 0x10 + +typedef struct { + s16 unk0; + s16 unk2; + s16 unk4; + u16 unk6; +} UnkStruct_46D0; + +typedef struct { + s16 x; + s16 z; +} Path2D; + +enum CpuItemStrategyEnum { + CPU_STRATEGY_WAIT_NEXT_ITEM = 0, + + CPU_STRATEGY_ITEM_BANANA, + CPU_STRATEGY_HOLD_BANANA, + CPU_STRATEGY_DROP_BANANA, + + CPU_STRATEGY_ITEM_GREEN_SHELL, + CPU_STRATEGY_HOLD_GREEN_SHELL, + CPU_STRATEGY_THROW_GREEN_SHELL, + + CPU_STRATEGY_ITEM_RED_SHELL, + CPU_STRATEGY_HOLD_RED_SHELL, + CPU_STRATEGY_THROW_RED_SHELL, + + CPU_STRATEGY_ITEM_BANANA_BUNCH, + CPU_STRATEGY_WAIT_INIT_BANANA_BUNCH, + CPU_STRATEGY_DROP_BANANA_BUNCH, + + CPU_STRATEGY_ITEM_FAKE_ITEM_BOX, + CPU_STRATEGY_HOLD_FAKE_ITEM_BOX, + CPU_STRATEGY_THROW_FAKE_ITEM_BOX, + + CPU_STRATEGY_ITEM_THUNDERBOLT = 0x16, + CPU_STRATEGY_END_THUNDERBOLT, + + CPU_STRATEGY_ITEM_STAR = 0x19, + CPU_STRATEGY_END_ITEM_STAR, + + CPU_STRATEGY_ITEM_BOO, + CPU_STRATEGY_WAIT_END_BOO, + + CPU_STRATEGY_ITEM_MUSHROOM, + CPU_STRATEGY_ITEM_DOUBLE_MUSHROOM, + CPU_STRATEGY_ITEM_TRIPLE_MUSHROOM, + CPU_STRATEGY_ITEM_SUPER_MUSHROOM, + CPU_STRATEGY_USE_SUPER_MUSHROOM, + + CPU_STRATEGY_THROW_BANANA, + CPU_STRATEGY_HOLD_THROW_BANANA, + CPU_STRATEGY_END_THROW_BANANA +}; + +/* Function Prototypes */ +s16 get_angle_between_path(Vec3f, Vec3f); + +s32 is_collide_with_vehicle(f32, f32, f32, f32, f32, f32, f32, f32); +void adjust_position_by_angle(Vec3f, Vec3f, s16); +s32 set_vehicle_render_distance_flags(Vec3f, f32, s32); +void detect_wrong_player_direction(s32, Player*); +void set_places(void); + +void update_player_rankings(void); +void set_places_end_course_with_time(void); +s32 is_path_point_in_range(u16, u16, u16, u16, u16); +void func_80007D04(s32, Player*); +void func_80007FA4(s32, Player*, f32); + +void regulate_cpu_speed(s32, f32, Player*); +bool func_800088D8(s32, s16, s16); +void set_current_path(s32); +s32 update_player_path_selection(s32, s32); +void update_player_completion(s32); + +void yoshi_valley_cpu_path(s32); +void update_cpu_path_completion(s32, Player*); +f32 func_80009258(s32, f32, f32); +void update_player_path_completion(s32, Player*); +void update_vehicles(void); +void play_cpu_sound_effect(s32, Player*); +void update_player_timer_sound(s32, Player*); +void update_player(s32); + +void func_8000B140(s32); +s32 are_in_curve(s32, u16); +bool is_far_from_path(s32); +f32 calculate_track_position_factor(f32, f32, u16, s32); +void update_player_position_factor(s32, u16, s32); +void calculate_track_offset_position(u16, f32, f32, s16); +void set_track_offset_position(u16, f32, s16); +s16 func_8000BD94(f32, f32, f32, s32); + +s16 find_closest_pathPoint_track_section(f32, f32, f32, u16, s32*); +s16 update_path_index_with_track(f32, f32, f32, s16, s32, u16); +s16 update_path_index(f32, f32, f32, s16, s32); +void tweak_path_index_wario_stadium(f32, f32, f32, s16*, s32); +void adjust_path_at_start_line(f32, f32, f32, s16*, s32); +s16 update_path_index_track_section(f32, f32, f32, Player*, s32, s32*); +s16 update_player_path(f32, f32, f32, s16, Player*, s32, s32); + +s16 find_closest_vehicles_pathPoint(f32, f32, f32, s16); +s16 func_8000D24C(f32, f32, f32, s32*); +s16 func_8000D2B4(f32, f32, f32, s16, s32); +s16 func_8000D33C(f32, f32, f32, s16, s32); +f32 cpu_track_position_factor(s32); +void determine_ideal_cpu_position_offset(s32, u16); +s16 func_8000D6D0(Vec3f, s16*, f32, f32, s16, s16); +s16 func_8000D940(Vec3f, s16*, f32, f32, s16); +s16 update_vehicle_following_path(Vec3f, s16*, f32); +void set_bomb_kart_spawn_positions(void); +void func_8000DF8C(s32); + +s32 add_actor_in_unexpired_actor_list(s32, s16); +s32 add_red_shell_in_unexpired_actor_list(s32); +s32 add_green_shell_in_unexpired_actor_list(s32); +s32 add_blue_shell_in_unexpired_actor_list(s32); +void delete_actor_in_unexpired_actor_list(s32); +void func_8000EEDC(void); +void generate_player_smoke(void); + +void func_8000F0E0(void); +void func_8000F124(void); +void clear_pathPoint(TrackPathPoint*, size_t); +void init_course_path_point(void); +void init_players(void); + +void load_track_path(s32); +void calculate_track_boundaries(s32); +f32 calculate_track_curvature(s32, u16); +void analize_track_section(s32); +s16 calculate_angle_path(s32, s32); +void analyse_angle_path(s32); +void analisze_curved_path(s32); +f32 func_80010F40(f32, f32, f32, s32, s32); +f32 func_80010FA0(f32, f32, f32, s32, s32); + +s32 func_80011014(TrackPathPoint*, TrackPathPoint*, s32, s32); +s32 process_path_data(TrackPathPoint*, TrackPathPoint*); +s32 generate_2d_path(Path2D*, TrackPathPoint*, s32); +void copy_courses_cpu_behaviour(void); +void reset_cpu_behaviour_none(s32); +void reset_cpu_behaviour(s32); +void cpu_behaviour_start(s32, Player*); +void cpu_behaviour_end(s32, Player*); +void cpu_behaviour(s32); +void func_80011EC0(s32, Player*, s32, u16); + +void generate_train_path(void); +void generate_ferry_path(void); +void spawn_vehicle_on_road(VehicleStuff*); +void spawn_course_vehicles(void); +void set_vehicle_pos_pathPoint(TrainCarStuff*, Path2D*, u16); +void init_vehicles_trains(void); +void sync_train_components(TrainCarStuff*, s16); +void update_vehicle_trains(void); +void handle_trains_interactions(s32, Player*); + +void func_80013054(void); +void check_ai_crossing_distance(s32); +void init_vehicles_ferry(void); +void update_vehicle_paddle_boats(void); +void handle_paddleBoats_interactions(Player*); +void initialize_toads_turnpike_vehicle(f32, f32, s32, s32, VehicleStuff*, TrackPathPoint*); +f32 func_80013C74(s16, s16); +void update_vehicle_follow_pathPoint(VehicleStuff*); +void handle_vehicle_interactions(s32, Player*, VehicleStuff*, f32, f32, s32, u32); + +f32 player_track_position_factor_vehicle(s16, f32, s16); +void update_player_track_position_factor_from_vehicle(s32, s32, VehicleStuff*); +void init_vehicles_box_trucks(void); +void update_vehicle_box_trucks(void); +void handle_box_trucks_interactions(s32, Player*); +void update_player_track_position_factor_from_box_trucks(s32); +void init_vehicles_school_buses(void); +void update_vehicle_school_bus(void); +void handle_school_buses_interactions(s32, Player*); +void update_player_track_position_factor_from_buses(s32); +void init_vehicles_trucks(void); +void update_vehicle_tanker_trucks(void); +void handle_tanker_trucks_interactions(s32, Player*); +void update_player_track_position_factor_from_tanker_truck(s32); +void init_vehicles_cars(void); +void update_vehicle_cars(void); +void handle_cars_interactions(s32, Player*); +void update_player_track_position_factor_from_cars(s32); +void func_80014D30(s32, s32); +void func_80014DE4(s32); +f32 func_80014EE4(f32, s32); + +void calculate_camera_up_vector(Camera*, s32); +void func_8001530C(void); +void func_80015314(s32, f32, s32); +void func_80015390(Camera*, Player*, s32); +void func_80015544(s32, f32, s32, s32); +void func_8001577C(Camera*, UNUSED Player*, s32, s32); +void func_80015A9C(s32, f32, s32, s16); +void func_80015C94(Camera*, Player*, s32, s32); + +void func_800162CC(s32, f32, s32, s16); +void func_80016494(Camera*, Player*, s32, s32); +void func_80016C3C(s32, f32, s32); + +void func_80017720(s32, f32, s32, s16); +void func_800178F4(Camera*, Player*, s32, s32); +void func_80017F10(s32, f32, s32, s16); + +void func_800180F0(Camera*, Player*, s32, s32); +void func_80018718(s32, f32, s32, s16); +void func_800188F4(Camera*, Player*, s32, s32); + +void func_80019118(s32, f32, s32, s16); +void func_8001933C(Camera*, UNUSED Player*, s32, s32); +void func_8001968C(void); +void func_8001969C(s32, f32, s32, s16); +void func_80019760(Camera*, UNUSED Player*, s32, s32); +void func_80019890(s32, s32); +void func_80019B50(s32, u16); +void func_80019C50(s32); +void func_80019D2C(Camera*, Player*, s32); +void func_80019DE4(void); +void func_80019DF4(void); +void func_80019E58(void); +void func_80019ED0(void); +void func_80019FB4(s32); + +void func_8001A0A4(u16*, Camera*, Player*, s8, s32); +void func_8001A0DC(u16*, Camera*, Player*, s8, s32); +void func_8001A124(s32, s32); +s32 func_8001A310(s32, s32); +void func_8001A348(s32, f32, s32); +void func_8001A3D8(s32, f32, s32); +void func_8001A450(s32, s32, s32); +void func_8001A518(s32, s32, s32); +void func_8001A588(u16*, Camera*, Player*, s8, s32); +void func_8001AAAC(s16, s16, s16); +void func_8001AB00(void); +void cpu_decisions_branch_item(s32, s16*, s32); +void func_8001ABE0(s32, CpuItemStrategyData*); +void clear_expired_strategies(CpuItemStrategyData*); +void cpu_use_item_strategy(s32); + +void func_8001BE78(void); + +void func_8001C05C(void); +void func_8001C14C(void); +void func_8001C3C4(s32); +void func_8001C42C(void); + +/* This is where I'd put my static data, if I had any */ + +extern Collision D_80162E70; +extern s16 D_80162EB0; // Possibly a float. +extern s16 D_80162EB2; // possibly [3] +extern CPUBehaviour* gCoursesCPUBehaviour[]; +extern s16 D_80162F10[]; +extern s16 D_80162F50[]; +extern Vec3f gOffsetPosition; +extern Vec3f D_80162FB0; +extern Vec3f D_80162FC0; +extern s16 gTrainSmokeTimer; +extern s16 D_80162FD0; +extern f32 gCourseCompletionPercentByRank[]; // D_80162FD8 +extern s16 D_80162FF8[]; +extern s16 D_80163010[]; +extern f32 cpu_TargetSpeed[]; +extern s16 gPreviousAngleSteering[]; +extern f32 gTrackPositionFactor[]; +extern f32 D_80163090[]; +extern bool gIsPlayerInCurve[]; +extern u16 gCurrentNearestPathPoint; +extern s16 gIsPlayerNewPathPoint; +extern s16 D_801630E8[]; +extern s16 gFerrySmokeTimer; +extern s32 D_80163100[]; +extern s32 D_80163128[]; +extern s32 D_80163150[]; +extern f32 gPreviousPlayerAiOffsetX[]; +extern f32 gPreviousPlayerAiOffsetZ[]; +extern s16 sVehicleSoundRenderCounter; +extern s32 D_801631CC; +extern TrackPathPoint* gCurrentTrackLeftPath; +extern TrackPathPoint* gCurrentTrackRightPath; +extern s16* gCurrentTrackSectionTypesPath; +extern u16 D_801631E0[]; +extern u16 D_801631F8[]; +extern f32 gCurrentCpuTargetSpeed; +extern f32 gPreviousCpuTargetSpeed[]; +extern s32 D_80163238; +extern u16 D_80163240[]; +extern u16 gWrongDirectionCounter[]; +extern u16 gIsPlayerWrongDirection[]; +extern s32 gPreviousLapProgressScore[]; +// Exact pointer type unknown +extern CPUBehaviour* sCurrentCPUBehaviour; +extern u16 gCurrentCPUBehaviourId[]; +extern u16 gPreviousCPUBehaviourId[]; +extern u16 cpu_BehaviourState[]; + +enum { cpu_BEHAVIOUR_STATE_NONE, cpu_BEHAVIOUR_STATE_START, cpu_BEHAVIOUR_STATE_RUNNING }; + +extern s16 sPlayerAngle[]; +extern u16 gPlayersTrackSectionId[]; +extern u16 D_80163330[]; +extern u16 D_80163344[]; +extern u16 D_80163348[]; +extern u16 D_8016334C[]; +extern u16 gSpeedCPUBehaviour[]; + +enum { SPEED_cpu_BEHAVIOUR_NORMAL, SPEED_cpu_BEHAVIOUR_FAST, SPEED_cpu_BEHAVIOUR_SLOW, SPEED_cpu_BEHAVIOUR_MAX }; + +extern s32 D_80163368[]; +extern s32 gIncrementUpdatePlayer; +extern s32 D_8016337C; +extern s16 gCurrentPlayerLookAhead[]; +extern s16 D_80163398[]; +extern s16 D_801633B0[]; +extern s16 D_801633C8[]; +extern s16 D_801633E0[]; +extern s16 D_801633F8[]; +extern s16 D_80163410[]; +extern f32 D_80163418[]; +extern f32 D_80163428[]; +extern f32 D_80163438[]; +extern s32 gPlayerPathIndex; +extern f32 gPathStartZ; +extern f32 gPreviousPlayerZ[]; +extern s16 gBestRankedHumanPlayer; +// 0 or 1, only 1 when when in extra (mirror) mode +extern s16 gIsInExtra; +extern s16 D_8016347C; +extern s16 D_8016347E; +extern s32 D_80163480; +extern s32 D_80163484; +extern s32 D_80163488; +extern s16 D_8016348C; +extern s16 cpu_enteringPathIntersection[]; +extern s16 cpu_exitingPathIntersection[]; +extern s16 D_801634C0[]; +extern s16 bStopAICrossing[]; +extern s16 D_801634EC; +extern s32 D_801634F0; +extern s32 D_801634F4; +extern TrackPositionFactorInstruction gPlayerTrackPositionFactorInstruction[]; +extern Path2D* gVehicle2DPathPoint; +extern s32 gVehicle2DPathLength; +extern u16 isCrossingTriggeredByIndex[]; +extern u16 sCrossingActiveTimer[]; +extern s32 D_80163DD8[]; +extern struct unexpiredActors gUnexpiredActorsList[]; +extern CpuItemStrategyData cpu_ItemStrategy[]; +extern s16 D_80164358; +extern s16 D_8016435A; +extern s16 D_8016435C; +extern s16 gGPCurrentRacePlayerIdByRank[]; // D_80164360 +extern s16 D_80164378[]; +extern s32 gLapCountByPlayerId[]; // D_80164390 +extern s32 gGPCurrentRaceRankByPlayerId[]; // D_801643B8 +extern s32 gPreviousGPCurrentRaceRankByPlayerId[]; +extern s32 gGPCurrentRaceRankByPlayerIdDup[]; +extern u16 gSelectedPathCount; +extern u16 gNearestPathPointByPlayerId[]; +extern s32 gNumPathPointsTraversed[]; +extern s16 gGetPlayerByCharacterId[]; +extern s32 D_8016448C; +extern f32 D_80164498[]; +extern f32 gLapCompletionPercentByPlayerId[]; // D_801644A8 +extern f32 gCourseCompletionPercentByPlayerId[]; // D_801644D0 +extern s16 bInMultiPathSection[]; +extern f32 gPlayerPathY[]; +extern s16 D_80164538[]; +extern s32 D_801645D0[]; +extern s32 D_801645E8[]; +extern f32 D_801645F8[]; +extern s32 D_80164608[]; +extern f32 D_80164618[]; +extern s32 D_80164628[]; +extern f32 D_80164638[]; +extern f32 D_80164648[]; +extern f32 D_80164658[]; +extern s16 D_80164670[]; +extern s16 D_80164678[]; +extern s16 D_80164680[]; +extern f32 D_80164688[]; +extern f32 D_80164698; +extern f32 D_8016469C; +extern f32 D_801646A0; +extern s16 D_801646C0[]; +extern u32 D_801646C8; +extern u16 D_801646CC; +extern UnkStruct_46D0 D_801646D0[]; + +// See bss_80005FD0.s +extern f32 gCourseCompletionPercentByRank[NUM_PLAYERS]; +extern s32 gPreviousGPCurrentRaceRankByPlayerId[]; +extern s32 D_8016448C; +extern u16 D_801637BE; +extern u16 D_80163E2A; + +#define SEVERE_WRONG_DIRECTION_MIN 136 +#define SEVERE_WRONG_DIRECTION_MAX 225 +#define SEVERE_CORRECT_DIRECTION_MIN 45 +#define SEVERE_CORRECT_DIRECTION_MAX 316 +#define WRONG_DIRECTION_FRAMES_LIMIT 5 + +// extern Gfx D_0D0076F8[]; + +#endif diff --git a/src/cpu_vehicles_camera_path/actor_utils.inc.c b/src/cpu_vehicles_camera_path/actor_utils.inc.c new file mode 100644 index 0000000000..0827885ac2 --- /dev/null +++ b/src/cpu_vehicles_camera_path/actor_utils.inc.c @@ -0,0 +1,112 @@ +s32 add_actor_in_unexpired_actor_list(s32 actorIndex, s16 arg1) { + s32 i; + s32 a2 = 0; + + for (i = 0; i < NUM_PLAYERS; i++) { + + if (gUnexpiredActorsList[i].unkC == 0) { + gUnexpiredActorsList[i].unkC = 1; + gUnexpiredActorsList[i].actorIndex = actorIndex; + gUnexpiredActorsList[i].unk10 = arg1; + gUnexpiredActorsList[i].unk14 = 0; + a2 = 1; + break; + } + } + if (a2 == 0) { + return -2; + } + return 0; +} + +s32 add_red_shell_in_unexpired_actor_list(s32 actorIndex) { + struct Actor* actor = &gActorList[actorIndex]; + if (actor->type != ACTOR_RED_SHELL) { + return -1; + } + return add_actor_in_unexpired_actor_list(actorIndex, 0); +} + +s32 add_green_shell_in_unexpired_actor_list(s32 actorIndex) { + struct Actor* actor = &gActorList[actorIndex]; + if (actor->type != ACTOR_GREEN_SHELL) { + return -1; + } + return add_actor_in_unexpired_actor_list(actorIndex, 1); +} + +s32 add_blue_shell_in_unexpired_actor_list(s32 arg0) { + struct Actor* actor = &gActorList[arg0]; + if (actor->type != ACTOR_BLUE_SPINY_SHELL) { + return -1; + } + return add_actor_in_unexpired_actor_list(arg0, 2); +} + +void delete_actor_in_unexpired_actor_list(s32 actorIndex) { + struct unexpiredActors* phi; + s32 i; + + for (i = 0; i < NUM_PLAYERS; i++) { + phi = &gUnexpiredActorsList[i]; + if (actorIndex == phi->actorIndex) { + phi->unkC = 0; + phi->actorIndex = 1000; // out of bounds + } + } +} + +void func_8000EEDC(void) { + struct unexpiredActors* phi; + s32 i; + + for (i = 0; i < NUM_PLAYERS; i++) { + phi = &gUnexpiredActorsList[i]; + phi->unkC = 0; + phi->actorIndex = 1000; // out of bounds + } +} + +void generate_player_smoke(void) { + s32 someIndex; + f32 var_f20; + struct Actor* temp_s1; + struct unexpiredActors* var_s0; + + for (someIndex = 0; someIndex < NUM_PLAYERS; someIndex++) { + var_s0 = &gUnexpiredActorsList[someIndex]; + if (var_s0->unkC == 1) { + temp_s1 = &gActorList[var_s0->actorIndex]; + var_s0->unk14++; + switch (var_s0->unk10) { + case 0: + if (var_s0->unk14 < 0xA) { + var_f20 = 0.3f; + } else { + var_f20 = 0.9f; + } + break; + case 1: + if (var_s0->unk14 < 0xA) { + var_f20 = 0.15f; + } else { + var_f20 = 0.45f; + } + break; + case 2: + if (var_s0->unk14 < 0xA) { + var_f20 = 0.15f; + } else { + var_f20 = 0.45f; + } + break; + default: + var_f20 = 1.0f; + break; + } + if (!(var_s0->unk14 & 1)) { + init_smoke_particle(temp_s1->pos, ((random_int(30) + 20) * var_f20) / 50.0f, var_s0->unk10); + } + } + } +} diff --git a/src/cpu_vehicles_camera_path/behaviour_utils.inc.c b/src/cpu_vehicles_camera_path/behaviour_utils.inc.c new file mode 100644 index 0000000000..5af84fd1b0 --- /dev/null +++ b/src/cpu_vehicles_camera_path/behaviour_utils.inc.c @@ -0,0 +1,170 @@ +void copy_courses_cpu_behaviour(void) { + s32 i; + for (i = 0; i < NUM_COURSES - 1; i++) { + gCoursesCPUBehaviour[i] = GET_COURSE_AIBehaviour; + } +} + +void reset_cpu_behaviour_none(s32 playerIndex) { + gCurrentCPUBehaviourId[playerIndex] = 0; + gPreviousCPUBehaviourId[playerIndex] = 0; + cpu_BehaviourState[playerIndex] = cpu_BEHAVIOUR_STATE_NONE; +} + +void reset_cpu_behaviour(s32 playerIndex) { + gCurrentCPUBehaviourId[playerIndex] = 0; + gPreviousCPUBehaviourId[playerIndex] = 0; + cpu_BehaviourState[playerIndex] = cpu_BEHAVIOUR_STATE_START; +} + +void cpu_behaviour_start(s32 playerId, Player* player) { + u16 playerPathPoint; + s16 pathPointStart; + s16 pathPointEnd; + s32 behaviourType; + UNUSED s32 test; + + sCurrentCPUBehaviour = &gCoursesCPUBehaviour[gCurrentCourseId][gCurrentCPUBehaviourId[playerId]]; + + playerPathPoint = gNearestPathPointByPlayerId[playerId]; + + pathPointStart = sCurrentCPUBehaviour->pathPointStart; + pathPointEnd = sCurrentCPUBehaviour->pathPointEnd; + behaviourType = sCurrentCPUBehaviour->type; + + if ((pathPointStart == -1) && (pathPointEnd == -1)) { + sCurrentCPUBehaviour = &gCoursesCPUBehaviour[gCurrentCourseId][0]; + reset_cpu_behaviour_none(playerId); + return; + } + if ((u32) playerPathPoint == (u32) pathPointStart) { + cpu_BehaviourState[playerId] = cpu_BEHAVIOUR_STATE_RUNNING; + gPreviousCPUBehaviourId[playerId] = gCurrentCPUBehaviourId[playerId]; + gCurrentCPUBehaviourId[playerId]++; + switch (behaviourType) { + case BEHAVIOUR_1: + func_80011EC0(playerId, player, player->unk_07C >> 0x10, playerPathPoint); + break; + case BEHAVIOUR_HOP: + kart_hop(player); + player->effects &= ~0x10; + D_801630E8[playerId] = 0; + break; + case BEHAVIOUR_DRIVE_CENTER: + gPlayerTrackPositionFactorInstruction[playerId].target = 0.0f; + break; + case BEHAVIOUR_DRIVE_LEFT: + gPlayerTrackPositionFactorInstruction[playerId].target = -0.6f; + break; + case BEHAVIOUR_DRIVE_OUTER: + gPlayerTrackPositionFactorInstruction[playerId].target = 0.6f; + break; + case BEHAVIOUR_NORMAL_SPEED: + gSpeedCPUBehaviour[playerId] = SPEED_cpu_BEHAVIOUR_NORMAL; + break; + case BEHAVIOUR_FAST_SPEED: + gSpeedCPUBehaviour[playerId] = SPEED_cpu_BEHAVIOUR_FAST; + break; + case BEHAVIOUR_SLOW_SPEED: + gSpeedCPUBehaviour[playerId] = SPEED_cpu_BEHAVIOUR_SLOW; + break; + case BEHAVIOUR_MAX_SPEED: + gSpeedCPUBehaviour[playerId] = SPEED_cpu_BEHAVIOUR_MAX; + break; + case BEHAVIOUR_9: + D_801633F8[playerId] = 1; + D_801631E0[playerId] = false; + gPlayers[playerId].effects &= ~UNKNOWN_EFFECT_0x1000; + break; + case BEHAVIOUR_10: + D_801633F8[playerId] = 0; + break; + } + } +} + +void cpu_behaviour_end(s32 playerIndex, Player* player) { + u16 nearestPathPoint; + u32 pathPointEnd; + s32 behaviourType; + + sCurrentCPUBehaviour = &gCoursesCPUBehaviour[gCurrentCourseId][gPreviousCPUBehaviourId[playerIndex]]; + nearestPathPoint = gNearestPathPointByPlayerId[playerIndex]; + behaviourType = sCurrentCPUBehaviour->type; + pathPointEnd = sCurrentCPUBehaviour->pathPointEnd; + if (nearestPathPoint >= pathPointEnd) { + switch (behaviourType) { + case BEHAVIOUR_1: + player->effects &= ~0x10; + D_801630E8[playerIndex] = 0; + cpu_BehaviourState[playerIndex] = cpu_BEHAVIOUR_STATE_START; + break; + case BEHAVIOUR_DRIVE_CENTER: + case BEHAVIOUR_DRIVE_LEFT: + case BEHAVIOUR_DRIVE_OUTER: + gPlayerTrackPositionFactorInstruction[playerIndex].target = + gPlayerTrackPositionFactorInstruction[playerIndex].unkC; + cpu_BehaviourState[playerIndex] = cpu_BEHAVIOUR_STATE_START; + break; + case BEHAVIOUR_HOP: + case BEHAVIOUR_NORMAL_SPEED: + case BEHAVIOUR_FAST_SPEED: + case BEHAVIOUR_SLOW_SPEED: + case BEHAVIOUR_9: + case BEHAVIOUR_10: + case BEHAVIOUR_MAX_SPEED: + cpu_BehaviourState[playerIndex] = cpu_BEHAVIOUR_STATE_START; + break; + default: + break; + } + } +} + +void cpu_behaviour(s32 playerIndex) { + Player* player = gPlayerOne + playerIndex; + + switch (cpu_BehaviourState[playerIndex]) { + case cpu_BEHAVIOUR_STATE_NONE: + break; + case cpu_BEHAVIOUR_STATE_START: + cpu_behaviour_start(playerIndex, player); + break; + case cpu_BEHAVIOUR_STATE_RUNNING: + cpu_behaviour_end(playerIndex, player); + break; + } +} + +void func_80011EC0(s32 arg0, Player* player, s32 arg2, UNUSED u16 arg3) { + if ((((player->speed / 18.0f) * 216.0f) >= 45.0f) && (D_801630E8[arg0] == 0)) { + switch (gCurrentTrackSectionTypesPath[sSomeNearestPathPoint]) { + case RIGHT_LEANING_CURVE: + case RIGHT_CURVE: + if ((arg2 >= -9) && (D_80162FF8[arg0] == 0)) { + if ((gTrackPositionFactor[arg0] > -0.8) && (gTrackPositionFactor[arg0] < 0.5)) { + kart_hop(player); + player->effects |= UNKNOWN_EFFECT_0x10; + D_801630E8[arg0] = 1; + break; + } + } + D_801630E8[arg0] = 2; + break; + case LEFT_LEANING_CURVE: + case LEFT_CURVE: + if ((arg2 < 0xA) && (D_80162FF8[arg0] == 0)) { + if ((gTrackPositionFactor[arg0] > -0.5) && (gTrackPositionFactor[arg0] < 0.8)) { + kart_hop(player); + player->effects |= UNKNOWN_EFFECT_0x10; + D_801630E8[arg0] = -1; + break; + } + } + D_801630E8[arg0] = -2; + break; + } + } else { + D_801630E8[arg0] = 3; + } +} diff --git a/src/cpu_vehicles_camera_path/bomb_kart.inc.c b/src/cpu_vehicles_camera_path/bomb_kart.inc.c new file mode 100644 index 0000000000..8ad48aea0e --- /dev/null +++ b/src/cpu_vehicles_camera_path/bomb_kart.inc.c @@ -0,0 +1,324 @@ +void set_bomb_kart_spawn_positions(void) { + UNUSED Collision* var_s2; + f32 startingXPos; + f32 startingZPos; + f32 startingYPos; + s32 var_s3; + TrackPathPoint* temp_v0; + UNUSED BombKart* var_s0; + BombKartSpawn* bombKartSpawn; + + for (var_s3 = 0; var_s3 < NUM_BOMB_KARTS_VERSUS; var_s3++) { + bombKartSpawn = &gBombKartSpawns[gCurrentCourseId][var_s3]; + switch (gCurrentCourseId) { + case COURSE_YOSHI_VALLEY: + startingXPos = bombKartSpawn->startingXPos; + startingZPos = bombKartSpawn->startingZPos; + startingYPos = get_surface_height(startingXPos, 2000.0f, startingZPos); + break; + case COURSE_AWARD_CEREMONY: + temp_v0 = &gTrackPaths[3][bombKartSpawn->pathPointIndex]; + startingXPos = temp_v0->posX; + startingYPos = temp_v0->posY; + startingZPos = temp_v0->posZ; + break; + default: + temp_v0 = &gTrackPaths[0][bombKartSpawn->pathPointIndex]; + startingXPos = temp_v0->posX; + startingYPos = temp_v0->posY; + startingZPos = temp_v0->posZ; + break; + } + gBombKarts[var_s3].bombPos[0] = startingXPos; + gBombKarts[var_s3].bombPos[1] = startingYPos; + gBombKarts[var_s3].bombPos[2] = startingZPos; + gBombKarts[var_s3].wheel1Pos[0] = startingXPos; + gBombKarts[var_s3].wheel1Pos[1] = startingYPos; + gBombKarts[var_s3].wheel1Pos[2] = startingZPos; + gBombKarts[var_s3].wheel2Pos[0] = startingXPos; + gBombKarts[var_s3].wheel2Pos[1] = startingYPos; + gBombKarts[var_s3].wheel2Pos[2] = startingZPos; + gBombKarts[var_s3].wheel3Pos[0] = startingXPos; + gBombKarts[var_s3].wheel3Pos[1] = startingYPos; + gBombKarts[var_s3].wheel3Pos[2] = startingZPos; + gBombKarts[var_s3].wheel4Pos[0] = startingXPos; + gBombKarts[var_s3].wheel4Pos[1] = startingYPos; + gBombKarts[var_s3].wheel4Pos[2] = startingZPos; + gBombKarts[var_s3].pathPointIndex = bombKartSpawn->pathPointIndex; + gBombKarts[var_s3].unk_3C = bombKartSpawn->unk_04; + gBombKarts[var_s3].bounceTimer = 0; + gBombKarts[var_s3].circleTimer = 0; + gBombKarts[var_s3].state = bombKartSpawn->startingState; + gBombKarts[var_s3].unk_4A = 0; + gBombKarts[var_s3].unk_4C = 1; + gBombKarts[var_s3].yPos = startingYPos; + check_bounding_collision(&D_80164038[var_s3], 2.0f, startingXPos, startingYPos, startingZPos); + } +} + +void func_8000DF8C(s32 bombKartId) { + UNUSED s32 stackPadding0; + f32 sp118; + f32 var_f18; + TrackPathPoint* temp_v0_2; + f32 temp_f0_3; + f32 sp108; + UNUSED s32 stackPadding1; + UNUSED s32 stackPadding2; + UNUSED s32 stackPadding3; + f32 temp_f14; + UNUSED s32 stackPadding4; + f32 temp_f16; + UNUSED s32 stackPadding5; + UNUSED s32 stackPadding6; + UNUSED s32 stackPadding7; + UNUSED s32 stackPadding8; + UNUSED s32 stackPadding9; + UNUSED s32 stackPaddingA; + UNUSED s32 stackPaddingB; + f32 temp_f0; + f32 temp_f0_4; + u16 spCA; + f32 spC4; + u16 spC2; + f32 temp_f12; + f32 temp_f12_3; + f32 temp_f12_4; + f32 temp_f14_2; + f32 spAC; + UNUSED s32 stackPaddingC; + f32 temp_f16_2; + f32 spA0; + f32 temp_f2; + f32 temp_f2_4; + f32 sp94; + UNUSED s32 stackPaddingD; + f32 var_f20; + f32 sp88; + f32 var_f22; + f32 var_f24; + u16 sp7E; + u16 sp7C; + UNUSED u16 sp4C; + u16 temp_t6; + u16 temp_t7; + u16 var_s1; + s32 var_a0; + UNUSED s32 stackPaddingE; + TrackPathPoint* temp_v0_4; + BombKart* bombKart; + BombKart* bombKart2; + Collision* temp_a0_4; + Player* var_v0; + + bombKart = &gBombKarts[bombKartId]; + + sp7E = bombKart->state; + + if (sp7E == 0) { + return; + } + + if (((bombKart->unk_4A != 1) || (gCurrentCourseId == COURSE_AWARD_CEREMONY))) { + var_f22 = bombKart->bombPos[0]; + var_f20 = bombKart->bombPos[1]; + var_f24 = bombKart->bombPos[2]; + spCA = bombKart->pathPointIndex; + spC4 = bombKart->unk_3C; + spC2 = bombKart->someRot; + sp7C = bombKart->bounceTimer; + var_s1 = bombKart->circleTimer; + if ((sp7E != 0) && (sp7E != 4)) { + if (1) {} + if (gCurrentCourseId == COURSE_AWARD_CEREMONY) { + if (D_8016347E == 1) { + var_v0 = gPlayerFour; + temp_f0 = var_f22 - var_v0->pos[0]; + temp_f2 = var_f20 - var_v0->pos[1]; + temp_f12 = var_f24 - var_v0->pos[2]; + if ((((temp_f0 * temp_f0) + (temp_f2 * temp_f2)) + (temp_f12 * temp_f12)) < 25.0f) { + var_s1 = 0; + sp7E = 4; + var_v0->soundEffects |= 0x400000; + var_v0->type &= ~0x2000; + } + } + } else { + + for (var_a0 = 0; var_a0 < gPlayerCount; var_a0++) { + var_v0 = &gPlayers[var_a0]; + if (!(var_v0->effects & 0x80000000)) { + temp_f0 = var_f22 - var_v0->pos[0]; + temp_f2 = var_f20 - var_v0->pos[1]; + temp_f12 = var_f24 - var_v0->pos[2]; + if ((((temp_f0 * temp_f0) + (temp_f2 * temp_f2)) + (temp_f12 * temp_f12)) < 25.0f) { + sp7E = 4; + var_s1 = 0; + if (gCurrentCourseId == COURSE_FRAPPE_SNOWLAND) { + var_v0->soundEffects |= 0x01000000; + } else { + var_v0->soundEffects |= 0x400000; + } + } + } + } + } + } + switch (sp7E) { + case 1: + var_s1 = (var_s1 + 356) % 360; + temp_t6 = (var_s1 * 0xFFFF) / 360; + sp118 = coss(temp_t6) * 25.0; + temp_f0_3 = sins(temp_t6) * 25.0; + temp_v0_2 = &gTrackPaths[0][spCA]; + var_f22 = temp_v0_2->posX + sp118; + var_f20 = bombKart->yPos + 3.5f; + var_f24 = temp_v0_2->posZ + temp_f0_3; + D_80162FB0[0] = var_f22; + D_80162FB0[1] = var_f20; + D_80162FB0[2] = var_f24; + temp_t7 = (((var_s1 + 1) % 360) * 0xFFFF) / 360; + sp118 = coss(temp_t7) * 25.0; + temp_f0_3 = sins(temp_t7) * 25.0; + D_80162FC0[0] = temp_v0_2->posX + sp118; + D_80162FC0[1] = temp_v0_2->posY; + D_80162FC0[2] = temp_v0_2->posZ + temp_f0_3; + spC2 = (get_angle_between_two_vectors(D_80162FB0, D_80162FC0) * 0xFFFF) / 65520; + break; + case 2: + var_s1 = (var_s1 + 4) % 360; + temp_t6 = (var_s1 * 0xFFFF) / 360; + sp118 = coss(temp_t6) * 25.0; + temp_f0_3 = sins(temp_t6) * 25.0; + temp_v0_2 = &gTrackPaths[0][spCA]; + var_f22 = temp_v0_2->posX + sp118; + var_f20 = bombKart->yPos + 3.5f; + var_f24 = temp_v0_2->posZ + temp_f0_3; + D_80162FB0[0] = var_f22; + D_80162FB0[1] = var_f20; + D_80162FB0[2] = var_f24; + temp_t7 = (((var_s1 + 1) % 360) * 0xFFFF) / 360; + sp118 = coss(temp_t7) * 25.0; + temp_f0_3 = sins(temp_t7) * 25.0; + D_80162FC0[0] = temp_v0_2->posX + sp118; + D_80162FC0[1] = temp_v0_2->posY; + D_80162FC0[2] = temp_v0_2->posZ + temp_f0_3; + spC2 = (get_angle_between_two_vectors(D_80162FB0, D_80162FC0) * 0xFFFF) / 65520; + break; + case 3: + var_f20 = bombKart->yPos + 3.5f; + spC2 = 0; + break; + + case 5: + if ((D_8016347C == 0) || (gNearestPathPointByPlayerId[3] < 5)) { + break; + } else { + spCA = func_8000D2B4(var_f22, var_f20, var_f24, spCA, 3); + if ((spCA < 0) || (gPathCountByPathIndex[3] < spCA)) { + spCA = 0; + } + if (((s32) spCA) < 0x1A) { + temp_v0_2 = &gTrackPaths[3][(spCA + 1) % gPathCountByPathIndex[3]]; + D_80162FB0[0] = temp_v0_2->posX; + D_80162FB0[1] = temp_v0_2->posY; + D_80162FB0[2] = temp_v0_2->posZ; + temp_v0_4 = &gTrackPaths[3][(spCA + 2) % gPathCountByPathIndex[3]]; + D_80162FC0[0] = temp_v0_4->posX; + D_80162FC0[1] = temp_v0_4->posY; + D_80162FC0[2] = temp_v0_4->posZ; + spC2 = (get_angle_between_two_vectors(D_80162FB0, D_80162FC0) * 0xFFFF) / 65520; + } else { + D_80162FB0[0] = var_f22; + D_80162FB0[1] = var_f20; + D_80162FB0[2] = var_f24; + D_80162FC0[0] = -2409.197f; + D_80162FC0[1] = 0.0f; + D_80162FC0[2] = -355.254f; + spC2 = (get_angle_between_two_vectors(D_80162FB0, D_80162FC0) * 0xFFFF) / 65520; + } + temp_f14 = ((D_80162FB0[0] + D_80162FC0[0]) * 0.5f) - var_f22; + temp_f16 = ((D_80162FB0[2] + D_80162FC0[2]) * 0.5f) - var_f24; + temp_f0_4 = sqrtf((temp_f14 * temp_f14) + (temp_f16 * temp_f16)); + if (temp_f0_4 > 0.01f) { + var_f22 += (bombKart->unk_3C * temp_f14) / temp_f0_4; + var_f24 += (bombKart->unk_3C * temp_f16) / temp_f0_4; + } else { + var_f22 += temp_f14 / 5.0f; + var_f24 += temp_f16 / 5.0f; + } + temp_a0_4 = &D_80164038[bombKartId]; + var_f20 = calculate_surface_height(var_f22, 2000.0f, var_f24, temp_a0_4->meshIndexZX) + 3.5f; + if (var_f20 < (-1000.0)) { + var_f20 = bombKart->bombPos[1]; + } + check_bounding_collision(temp_a0_4, 10.0f, var_f22, var_f20, var_f24); + } + break; + case 4: + temp_v0_2 = &gTrackPaths[0][spCA]; + D_80162FB0[0] = temp_v0_2->posX; + D_80162FB0[1] = temp_v0_2->posY; + D_80162FB0[2] = temp_v0_2->posZ; + temp_v0_4 = &gTrackPaths[0][(spCA + 1) % gPathCountByPathIndex[0]]; + D_80162FC0[0] = temp_v0_4->posX; + D_80162FC0[1] = temp_v0_4->posY; + D_80162FC0[2] = temp_v0_4->posZ; + var_f20 += 3.0f - (var_s1 * 0.3f); + spC2 = (get_angle_between_two_vectors(D_80162FB0, D_80162FC0) * 0xFFFF) / 65520; + break; + default: + break; + } + + if (sp7E == 4) { + sp108 = 2.0f * var_s1; + sp118 = coss(0xFFFF - spC2) * var_s1; + var_f18 = sins(0xFFFF - spC2) * var_s1; + var_s1++; + temp_f2_4 = (var_f20 - 2.3f) + (sp108 / 3.0f); + spAC = temp_f2_4; + spA0 = temp_f2_4; + sp94 = temp_f2_4; + sp88 = temp_f2_4; + if (var_s1 >= 31) { + sp7E = 0; + } + } else { + sp118 = coss(0xFFFF - spC2) * 1.5f; + var_f18 = sins(0xFFFF - spC2) * 1.5f; + temp_f16_2 = var_f20 - 2.3f; + temp_f12_3 = (sp7C % 3) * 0.15f; + temp_f14_2 = temp_f16_2 - temp_f12_3; + temp_f12_4 = temp_f16_2 + temp_f12_3; + spAC = temp_f14_2; + sp94 = temp_f14_2; + spA0 = temp_f12_4; + sp88 = temp_f12_4; + var_f20 += sins((sp7C * 0x13FFEC) / 360); + sp7C = (sp7C + 1) % 18; + } + bombKart2 = bombKart; + bombKart2->wheel1Pos[0] = (sp118 - var_f18) + var_f22; + bombKart2->wheel1Pos[1] = spAC; + bombKart2->wheel1Pos[2] = (var_f18 + sp118) + var_f24; + bombKart2->wheel2Pos[0] = (var_f18 + sp118) + var_f22; + bombKart2->wheel2Pos[1] = spA0; + bombKart2->wheel2Pos[2] = (var_f18 - sp118) + var_f24; + bombKart2->wheel3Pos[0] = ((-sp118) - var_f18) + var_f22; + bombKart2->wheel3Pos[1] = sp94; + bombKart2->wheel3Pos[2] = ((-var_f18) + sp118) + var_f24; + bombKart2->wheel4Pos[0] = ((-sp118) + var_f18) + var_f22; + bombKart2->wheel4Pos[1] = sp88; + bombKart2->wheel4Pos[2] = ((-var_f18) - sp118) + var_f24; + bombKart2->bombPos[0] = var_f22; + bombKart2->bombPos[1] = var_f20; + bombKart2->bombPos[2] = var_f24; + bombKart2->pathPointIndex = spCA; + bombKart2->unk_3C = spC4; + bombKart2->someRot = spC2; + bombKart2->state = sp7E; + bombKart2->bounceTimer = sp7C; + bombKart2->circleTimer = var_s1; + } +} diff --git a/src/cpu_vehicles_camera_path/cpu_item_strategy.inc.c b/src/cpu_vehicles_camera_path/cpu_item_strategy.inc.c new file mode 100644 index 0000000000..1da40aa367 --- /dev/null +++ b/src/cpu_vehicles_camera_path/cpu_item_strategy.inc.c @@ -0,0 +1,59 @@ +#include +#include "cpu_vehicles_camera_path.h" +#include +#include + +void func_8001AB00(void) { + s32 var_v1; + + for (var_v1 = 0; var_v1 < NUM_PLAYERS; var_v1++) { + cpu_ItemStrategy[var_v1].branch = 0; + cpu_ItemStrategy[var_v1].timer = 0; + cpu_ItemStrategy[var_v1].actorIndex = -1; + cpu_ItemStrategy[var_v1].numItemUse = 0; + cpu_ItemStrategy[var_v1].numDroppedBananaBunch = 0; + } +} + +void cpu_decisions_branch_item(UNUSED s32 playerId, s16* branch, s32 itemId) { + s32 value = -1; + switch (itemId) { + case ITEM_FAKE_ITEM_BOX: + value = CPU_STRATEGY_ITEM_FAKE_ITEM_BOX; + break; + case ITEM_BOO: + value = CPU_STRATEGY_ITEM_BOO; + break; + case ITEM_BANANA: + value = CPU_STRATEGY_ITEM_BANANA; + break; + case ITEM_THUNDERBOLT: + value = CPU_STRATEGY_ITEM_THUNDERBOLT; + break; + case ITEM_STAR: + value = CPU_STRATEGY_ITEM_STAR; + break; + case ITEM_MUSHROOM: + value = CPU_STRATEGY_ITEM_MUSHROOM; + break; + case ITEM_DOUBLE_MUSHROOM: + break; + case ITEM_TRIPLE_MUSHROOM: + break; + case ITEM_SUPER_MUSHROOM: + break; + } + if (value >= 0) { + *branch = value; + } +} + +void func_8001ABE0(UNUSED s32 playerId, UNUSED CpuItemStrategyData* arg1) { +} + +void clear_expired_strategies(CpuItemStrategyData* arg0) { + if ((arg0->actorIndex < 0) || (arg0->actorIndex >= 0x64)) { + arg0->branch = 0; + arg0->timer = 0; + } +} diff --git a/src/cpu_vehicles_camera_path/cpu_speed_control.inc.c b/src/cpu_vehicles_camera_path/cpu_speed_control.inc.c new file mode 100644 index 0000000000..9dc128351c --- /dev/null +++ b/src/cpu_vehicles_camera_path/cpu_speed_control.inc.c @@ -0,0 +1,228 @@ +void func_80007D04(s32 playerId, Player* player) { + s16 temp_t1; + s16 temp_t2; + s32 var_v0; + + temp_t1 = gNumPathPointsTraversed[gBestRankedHumanPlayer]; + temp_t2 = gNumPathPointsTraversed[playerId]; + + if (gGPCurrentRaceRankByPlayerId[playerId] < 2) { + s16 val1 = gGPCurrentRaceRankByPlayerId[gBestRankedHumanPlayer]; + s16 val2 = temp_t2 - temp_t1; + + if (val2 > 400 && val1 >= 6) { + player->effects &= ~UNKNOWN_EFFECT_0x200000; + player_accelerate(player); + D_801634C0[playerId] = 4; + return; + } + } else { + player->effects |= UNKNOWN_EFFECT_0x200000; + player_accelerate(player); + D_801634C0[playerId] = 3; + return; + } + + switch (gCCSelection) { // WTF, FAKE ? + case CC_EXTRA: + break; + } + + switch (gCCSelection) { + case CC_50: + var_v0 = 0; + if (playerId == D_80163344[0]) { + var_v0 = 0x14; + } + break; + + case CC_100: + var_v0 = 8; + if (playerId == D_80163344[0]) { + var_v0 = 0x18; + } + break; + + case CC_150: + var_v0 = 0x12; + if (playerId == D_80163344[0]) { + var_v0 = 0x24; + } + break; + + case CC_EXTRA: + var_v0 = 8; + if (playerId == D_80163344[0]) { + var_v0 = 0x18; + } + break; + + default: + var_v0 = 0; + break; + } + + if (temp_t2 < temp_t1) { + player->effects |= UNKNOWN_EFFECT_0x200000; + player_accelerate(player); + D_801634C0[playerId] = 1; + } else if (temp_t2 < (temp_t1 + var_v0 + 0x32)) { + player->effects &= ~UNKNOWN_EFFECT_0x200000; + player_accelerate(player); + D_801634C0[playerId] = 3; + } else if (D_801631E0[playerId] == false) { + player->effects &= ~UNKNOWN_EFFECT_0x200000; + player_accelerate(player); + D_801634C0[playerId] = 2; + } else { + player->effects &= ~UNKNOWN_EFFECT_0x200000; + decelerate_player(player, 1.0f); + D_801634C0[playerId] = -1; + } +} + +void func_80007FA4(s32 playerId, Player* player, f32 arg2) { + f32 temp_f0; + f32 dist; + f32 temp_f2; + s32 test; + + temp_f0 = D_80163418[playerId] - player->pos[0]; + temp_f2 = D_80163438[playerId] - player->pos[2]; + dist = (temp_f0 * temp_f0) + (temp_f2 * temp_f2); + if (playerId == 3) { + if ((dist < 25.0f) && (D_80163410[playerId] < 5)) { + D_80163410[playerId] = 4; + (arg2 < ((2.0 * 18.0) / 216.0)) ? func_80038BE4(player, 1) : decelerate_player(player, 1.0f); + } else if ((dist < 3600.0f) && (D_80163410[playerId] < 4)) { + D_80163410[playerId] = 3; + (arg2 < ((5.0 * 18.0) / 216.0)) ? func_80038BE4(player, 1) : decelerate_player(player, 5.0f); + } else { + (arg2 < ((20.0 * 18.0) / 216.0)) ? func_80038BE4(player, 10) : decelerate_player(player, 1.0f); + } + } else { + if ((dist < 25.0f) && (D_80163410[playerId] < 5)) { + D_80163410[playerId] = 4; + test = 2; + (arg2 < ((test * 18.0) / 216.0)) ? func_80038BE4(player, 1) : decelerate_player(player, 1.0f); + } else if ((dist < 4900.0f) && (D_80163410[playerId] < 4)) { + D_80163410[playerId] = 3; + test = 5; + (arg2 < ((test * 18.0) / 216.0)) ? func_80038BE4(player, 1) : decelerate_player(player, 15.0f); + } else if ((dist < 22500.0f) && (D_80163410[playerId] < 3)) { + D_80163410[playerId] = 2; + test = 20; + (arg2 < ((test * 18.0) / 216.0)) ? func_80038BE4(player, 5) : decelerate_player(player, 1.0f); + } else if ((dist < 90000.0f) && (D_80163410[playerId] < 2)) { + D_80163410[playerId] = 1; + test = 30; + (arg2 < ((test * 18.0) / 216.0)) ? func_80038BE4(player, 6) : decelerate_player(player, 1.0f); + } else if (D_80163410[playerId] == 0) { + test = 35; + (arg2 < (((test ^ 0) * 18.0) / 216.0)) ? func_80038BE4(player, 2) : decelerate_player(player, 1.0f); + } else { + decelerate_player(player, 1.0f); + } + } +} + +void regulate_cpu_speed(s32 playerId, f32 targetSpeed, Player* player) { + f32 speed; + f32 var_f0; + UNUSED s32 thing; + s32 var_a1; + + speed = player->speed; + if (!(player->effects & 0x80) && !(player->effects & 0x40) && !(player->effects & 0x20000) && + !(player->soundEffects & 0x400000) && !(player->soundEffects & 0x01000000) && !(player->soundEffects & 2) && + !(player->soundEffects & 4)) { + if (gCurrentCourseId == COURSE_AWARD_CEREMONY) { + func_80007FA4(playerId, player, speed); + } else if ((bStopAICrossing[playerId] == true) && !(player->effects & (STAR_EFFECT | BOO_EFFECT))) { + decelerate_player(player, 10.0f); + if (player->currentSpeed == 0.0) { + player->velocity[0] = 0.0f; + player->velocity[2] = 0.0f; + } + } else { + var_f0 = 3.3333333f; + switch (gCCSelection) { /* irregular */ + case CC_100: + case CC_EXTRA: + break; + case CC_50: + var_f0 = 2.5f; + break; + case CC_150: + var_f0 = 3.75f; + break; + } + if (speed < var_f0) { + player->effects &= ~UNKNOWN_EFFECT_0x200000; + player_accelerate(player); + } else if (player->type & PLAYER_CINEMATIC_MODE) { + if (speed < targetSpeed) { + player->effects &= ~UNKNOWN_EFFECT_0x200000; + player_accelerate(player); + } else { + player->effects &= ~UNKNOWN_EFFECT_0x200000; + decelerate_player(player, 1.0f); + } + } else if ((D_801631E0[playerId] == true) && (D_80163330[playerId] != 1)) { + if (func_800088D8(playerId, gLapCountByPlayerId[playerId], gGPCurrentRaceRankByPlayerIdDup[playerId]) == + 1) { + player->effects |= UNKNOWN_EFFECT_0x200000; + player_accelerate(player); + } else { + player->effects &= ~UNKNOWN_EFFECT_0x200000; + decelerate_player(player, 1.0f); + } + } else { + var_a1 = 1; + switch (gSpeedCPUBehaviour[playerId]) { /* switch 1; irregular */ + case SPEED_cpu_BEHAVIOUR_FAST: /* switch 1 */ + player->effects &= ~UNKNOWN_EFFECT_0x200000; + player_accelerate(player); + break; + case SPEED_cpu_BEHAVIOUR_MAX: /* switch 1 */ + player->effects |= UNKNOWN_EFFECT_0x200000; + player_accelerate(player); + break; + case SPEED_cpu_BEHAVIOUR_SLOW: /* switch 1 */ + if (((speed / 18.0f) * 216.0f) > 20.0f) { + targetSpeed = 1.6666666f; + } + var_a1 = 0; + break; + case SPEED_cpu_BEHAVIOUR_NORMAL: /* switch 1 */ + default: /* switch 1 */ + var_a1 = 0; + break; + } + if (var_a1 != 1) { + if (speed < targetSpeed) { + if ((gDemoMode == 1) && (gCurrentCourseId != COURSE_AWARD_CEREMONY)) { + player_accelerate(player); + } else if (D_80163330[playerId] == 1) { + func_80007D04(playerId, player); + } else if (func_800088D8(playerId, gLapCountByPlayerId[playerId], + gGPCurrentRaceRankByPlayerIdDup[playerId]) == true) { + player->effects |= UNKNOWN_EFFECT_0x200000; + player_accelerate(player); + } else { + player->effects &= ~UNKNOWN_EFFECT_0x200000; + decelerate_player(player, 1.0f); + } + } else { + player->effects &= ~UNKNOWN_EFFECT_0x200000; + if (targetSpeed > 1.0f) { + decelerate_player(player, 2.0f); + } else { + decelerate_player(player, 5.0f); + } + } + } + } + } + } +} diff --git a/src/cpu_vehicles_camera_path/path_calc.inc.c b/src/cpu_vehicles_camera_path/path_calc.inc.c new file mode 100644 index 0000000000..ddf1b850be --- /dev/null +++ b/src/cpu_vehicles_camera_path/path_calc.inc.c @@ -0,0 +1,534 @@ +// @arg index from 0 to 3. + +// Processes course path by index. +// @arg index from 0 to 3. +// Each course can have 1-4 course paths. +void load_track_path(s32 pathIndex) { + + TrackPathPoint* ptr; + TrackPathPoint* pathDest; + TrackPathPoint* path; + s32 var_v0; + s32 sp24; + UNUSED s32 pad[2]; + s16 bInvalidPath; + s32 i; + + // cast required + if ((s32) GET_COURSE_AIMaximumSeparation >= 0) { + pathDest = gTrackPaths[pathIndex]; + bInvalidPath = 1; + if (gCurrentCourseId != COURSE_AWARD_CEREMONY) { + var_v0 = process_path_data(pathDest, GET_COURSE_PathTable2(pathIndex)); + gPathCountByPathIndex[pathIndex] = (u16) var_v0; + } else { + // Course path included in course_data which has already been loaded into memory. + // This is how we get the addr to our path data. + path = GET_COURSE_PathTable(pathIndex); + ptr = path; + + for (i = 0; i < 3000; i++, ptr++) { + if ((u16) ptr->posX == 0x8000) { + sp24 = i - 1; + bInvalidPath = 0; + break; + } + } + + // If path data higher than 3000 something has gone wrong. + // Skip processing the data. + //! @todo Confirm this comment + if (!bInvalidPath) { + var_v0 = func_80011014(pathDest, path, sp24, pathIndex); + gPathCountByPathIndex[pathIndex] = (u16) var_v0; + } + } + } +} + +void calculate_track_boundaries(s32 pathIndex) { + f32 pathPointWidth; + f32 x1; + f32 y1; + f32 z1; + f32 x2; + f32 y2; + f32 z2; + f32 x_dist; + f32 z_dist; + f32 neg_x_dist; + f32 neg_z_dist; + f32 xz_dist; + s32 temp_f16; + s32 pathPointIndex; + TrackPathPoint* pathPoint; + TrackPathPoint* nextPathPoint; + TrackPathPoint* var_s1; + TrackPathPoint* var_s2; + + if (((s32) GET_COURSE_AIMaximumSeparation) >= 0) { + pathPointWidth = GET_COURSE_AIMaximumSeparation; + pathPoint = &gTrackPaths[pathIndex][0]; + var_s1 = &gTrackLeftPaths[pathIndex][0]; + var_s2 = &gTrackRightPaths[pathIndex][0]; + for (pathPointIndex = 0; pathPointIndex < gPathCountByPathIndex[pathIndex]; + pathPointIndex++, var_s1++, var_s2++) { + x1 = pathPoint->posX; + y1 = pathPoint->posY; + z1 = pathPoint->posZ; + pathPoint++; + nextPathPoint = &gTrackPaths[pathIndex][(pathPointIndex + 1) % ((s32) gPathCountByPathIndex[pathIndex])]; + x2 = nextPathPoint->posX; + y2 = nextPathPoint->posY; + z2 = nextPathPoint->posZ; + x_dist = x2 - x1; + z_dist = z2 - z1; + neg_x_dist = x1 - x2; + neg_z_dist = z1 - z2; + xz_dist = sqrtf((x_dist * x_dist) + (z_dist * z_dist)); + temp_f16 = (f32) ((y1 + y2) * 0.5); + + // Calculate left boundary position + // Uses perpendicular vector (Z, -X) normalized by segment length + var_s1->posX = ((pathPointWidth * z_dist) / xz_dist) + x1; + var_s1->posY = temp_f16; + var_s1->posZ = ((pathPointWidth * neg_x_dist) / xz_dist) + z1; + + // Calculate right boundary position + // Uses opposite perpendicular vector (-Z, X) + var_s2->posX = ((pathPointWidth * neg_z_dist) / xz_dist) + x1; + var_s2->posY = temp_f16; + var_s2->posZ = ((pathPointWidth * x_dist) / xz_dist) + z1; + } + } +} + +/** + * Calculates the track curvature using two sets of three path. + * Returns a normalized value indicating curve direction and severity: + * - Positive: Right turn + * - Negative: Left turn + * - Near zero: Straight section + * + * @param pathIndex Track path index + * @param pathPointIndex Starting pathPoint for calculation + * @return Normalized curvature value (-1 to 1) + */ +f32 calculate_track_curvature(s32 pathIndex, u16 pathPointIndex) { + f32 secondVectorX; + f32 secondVectorZ; + UNUSED f32 pad; + TrackPathPoint* pathPathPoints; + f32 x1; + f32 z1; + f32 x2; + f32 z2; + f32 x3; + f32 z3; + f32 firstVectorX; + f32 firstVectorZ; + s32 pathPointCount; + TrackPathPoint* pathPoint3; + TrackPathPoint* pathPoint2; + TrackPathPoint* pathPoint1; + f32 secondLength; + f32 firstLength; + + if ((s32) GET_COURSE_AIMaximumSeparation < 0) { + return 0.0f; + } + pathPointCount = gPathCountByPathIndex[pathIndex]; + pathPathPoints = gTrackPaths[pathIndex]; + + pathPoint1 = &pathPathPoints[pathPointIndex]; + pathPoint2 = &pathPathPoints[(pathPointIndex + 1) % pathPointCount]; + pathPoint3 = &pathPathPoints[(pathPointIndex + 2) % pathPointCount]; + + x1 = pathPoint1->posX; + z1 = pathPoint1->posZ; + x2 = pathPoint2->posX; + z2 = pathPoint2->posZ; + x3 = pathPoint3->posX; + z3 = pathPoint3->posZ; + + firstVectorX = (((x2 + x3) * 0.5) - x1); + firstVectorZ = (((z2 + z3) * 0.5) - z1); + + pathPoint1 = &pathPathPoints[(pathPointIndex + 3) % pathPointCount]; + pathPoint2 = &pathPathPoints[(pathPointIndex + 4) % pathPointCount]; + pathPoint3 = &pathPathPoints[(pathPointIndex + 5) % pathPointCount]; + + x1 = pathPoint1->posX; + z1 = pathPoint1->posZ; + x2 = pathPoint2->posX; + z2 = pathPoint2->posZ; + x3 = pathPoint3->posX; + z3 = pathPoint3->posZ; + + secondVectorX = (((x2 + x3) * 0.5) - x1); + secondVectorZ = (((z2 + z3) * 0.5) - z1); + + firstLength = sqrtf((firstVectorZ * firstVectorZ) + (firstVectorX * firstVectorX)); + secondLength = sqrtf((secondVectorX * secondVectorX) + (secondVectorZ * secondVectorZ)); + return -((firstVectorZ * secondVectorX) - (firstVectorX * secondVectorZ)) / (secondLength * firstLength); +} + +void analize_track_section(s32 pathIndex) { + f64 sectionCurvature; + UNUSED s32 pad; + s32 k; + s32 i; + s32 j; + s16* currentSection; + s32 pathPointCount; + s16* nextSection; + + if ((s32) GET_COURSE_AIMaximumSeparation >= 0) { + pathPointCount = gPathCountByPathIndex[pathIndex]; + currentSection = gTrackSectionTypes[pathIndex]; + for (i = 0; i < pathPointCount; i++, currentSection++) { + sectionCurvature = calculate_track_curvature(pathIndex, i); + *currentSection = STRAIGHT; + if (sectionCurvature > 0.1) { + *currentSection = RIGHT_CURVE; + } + if (sectionCurvature < -0.1) { + *currentSection = LEFT_CURVE; + } + } + currentSection = gTrackSectionTypes[pathIndex]; + for (i = 0; i < pathPointCount; i++, currentSection++) { + if (*currentSection == STRAIGHT) { + // Look ahead for next curved section + for (j = 1; j < pathPointCount; j++) { + nextSection = &gTrackSectionTypes[pathIndex][(i + j) % pathPointCount]; + switch (*nextSection) { + case RIGHT_LEANING_CURVE: + case RIGHT_CURVE: + for (k = 0; k < j; k++) { + gTrackSectionTypes[pathIndex][(i + k) % pathPointCount] = RIGHT_LEANING_CURVE; + } + i += j; + currentSection += j; + j = pathPointCount; + break; + case LEFT_LEANING_CURVE: + case LEFT_CURVE: + for (k = 0; k < j; k++) { + gTrackSectionTypes[pathIndex][(i + k) % pathPointCount] = LEFT_LEANING_CURVE; + } + i += j; + currentSection += j; + j = pathPointCount; + break; + } + } + } + } + } +} + +// Seemingly calculates the atan2 angle between a pathPoint and its forward neighbor +s16 calculate_angle_path(s32 pathIndex, s32 pathPointIndex) { + s16 ret; + Vec3f sp30; + Vec3f sp24; + TrackPathPoint* temp_v0; + + temp_v0 = &gTrackPaths[pathIndex][pathPointIndex]; + sp30[0] = temp_v0->posX; + sp30[1] = temp_v0->posY; + sp30[2] = temp_v0->posZ; + temp_v0 = &gTrackPaths[pathIndex][(pathPointIndex + 1) % gPathCountByPathIndex[pathIndex]]; + sp24[0] = temp_v0->posX; + sp24[1] = temp_v0->posY; + sp24[2] = temp_v0->posZ; + ret = get_angle_between_two_vectors(sp30, sp24); + return -ret; +} + +// Populates gPathExpectedRotation +void analyse_angle_path(s32 pathIndex) { + s32 pathPointIndex; + u16* angle; + + if ((s32) GET_COURSE_AIMaximumSeparation >= 0) { + for (angle = (u16*) &gPathExpectedRotation[pathIndex][0], pathPointIndex = 0; + pathPointIndex < gPathCountByPathIndex[pathIndex]; pathPointIndex++, angle++) { + *angle = calculate_angle_path(pathIndex, pathPointIndex); + } + } +} + +void analisze_curved_path(s32 pathIndex) { + s16* trackCurveCount; + s16 curveCount; + s16 temp_t0; + s32 pathPointCount; + s16* trackSectionType; + s32 i, j; + + pathPointCount = gPathCountByPathIndex[pathIndex]; + trackSectionType = gTrackSectionTypes[pathIndex]; + trackCurveCount = gTrackConsecutiveCurveCounts[pathIndex]; + + for (i = 0; i < pathPointCount; i++) { + curveCount = 0; + for (j = 0; j < pathPointCount; j++) { + temp_t0 = trackSectionType[(i + j) % pathPointCount]; + if ((temp_t0 == LEFT_LEANING_CURVE) || (temp_t0 == RIGHT_LEANING_CURVE)) { + curveCount += 1; + } else { + break; + } + if (gCurrentCourseId == COURSE_AWARD_CEREMONY) { + break; + } + } + *trackCurveCount = curveCount; + trackCurveCount++; + } +} + +f32 func_80010F40(f32 arg0, f32 arg1, f32 arg2, UNUSED s32 arg3, UNUSED s32 arg4) { + arg1 = get_surface_height(arg0, 2000.0f, arg2); + check_bounding_collision(&D_80162E70, 1.0f, arg0, arg1, arg2); + return arg1; +} + +f32 func_80010FA0(f32 arg0, f32 arg1, f32 arg2, UNUSED s32 arg3, UNUSED s32 arg4) { + arg1 = get_surface_height(arg0, (f32) ((f64) arg1 + 30.0), arg2); + check_bounding_collision(&D_80162E70, 10.0f, arg0, arg1, arg2); + return arg1; +} + +/** + * @return's the number of items processed. + */ +s32 func_80011014(TrackPathPoint* pathDest, TrackPathPoint* path, s32 numPathPoints, UNUSED s32 pathIndex) { + f32 temp_f24_2; + f32 temp_f2_3; + f32 var_f20_2; + f32 x1; + f32 z1; + f32 x2; + f32 z2; + f32 x3; + f32 z3; + f32 x1_2; + f32 z1_3; + f32 temp_f20; + f32 var_f30; + f32 temp_f22; + f32 temp_f16; + s32 i; + + f32 j; + s32 var_s0; + f32 var_f28; + + TrackPathPoint* point1; + TrackPathPoint* point2; + TrackPathPoint* point3; + f32 temp; + UNUSED TrackPathPoint* dest; + var_f30 = 0.0f; + var_s0 = 0; + temp_f20 = (f32) path[0].posX; + temp_f22 = (f32) path[0].posZ; + var_f28 = func_80010F40(temp_f20, 2000.0f, temp_f22, gCurrentCourseId, 0); + + for (i = 0; i < numPathPoints; i++) { + point1 = &path[i % numPathPoints]; + point2 = &path[(i + 1) % numPathPoints]; + point3 = &path[(s32) (i + 2) % numPathPoints]; + x1 = (f32) point1->posX; + z1 = (f32) point1->posZ; + x2 = (f32) point2->posX; + z2 = (f32) point2->posZ; + x3 = (f32) point3->posX; + z3 = (f32) point3->posZ; + + temp = 0.05 / (sqrtf(((x2 - x1) * (x2 - x1)) + ((z2 - z1) * (z2 - z1))) + + (sqrtf(((x3 - x2) * (x3 - x2)) + ((z3 - z2) * (z3 - z2))))); + + for (j = 0.0f; j <= 1.0; j += temp) { + + temp_f2_3 = (f32) ((1.0 - j) * 0.5 * (1.0 - j)); + z1_3 = (f32) (((1.0 - j) * j) + 0.5); + temp_f16 = (f32) (j * 0.5 * j); + + temp_f24_2 = (temp_f2_3 * x1) + (z1_3 * x2) + (temp_f16 * x3); + x1_2 = (temp_f2_3 * z1) + (z1_3 * z2) + (temp_f16 * z3); + + var_f30 += + sqrtf(((temp_f24_2 - temp_f20) * (temp_f24_2 - temp_f20)) + ((x1_2 - temp_f22) * (x1_2 - temp_f22))); + + temp_f20 = temp_f24_2; + temp_f22 = x1_2; + + if ((var_f30 > 20.0f) || ((i == 0) && (j == 0.0))) { + if (gIsMirrorMode) { + // temp_f12 = -temp_f24_2; + pathDest->posX = (s16) -temp_f24_2; + var_f20_2 = func_80010FA0(-temp_f24_2, var_f28, x1_2, gCurrentCourseId, var_s0); + } else { + pathDest->posX = (s16) temp_f24_2; + var_f20_2 = func_80010FA0(temp_f24_2, var_f28, x1_2, gCurrentCourseId, var_s0); + } + + pathDest->posZ = (s16) temp_f22; + pathDest->trackSectionId = get_track_section_id(D_80162E70.meshIndexZX); + + if (var_f20_2 < -500.0) { + var_f20_2 = var_f28; + } else { + + switch (gCurrentCourseId) { + case COURSE_RAINBOW_ROAD: + if (var_f20_2 < (var_f28 - 15.0)) { + var_f20_2 = (f32) var_f28 - 15.0; + } + break; + case COURSE_WARIO_STADIUM: + if ((var_s0 >= 1140) && (var_s0 <= 1152)) { + var_f20_2 = var_f28; + } else { + if (var_f20_2 < (var_f28 - 10.0)) { + var_f20_2 = (f32) (var_f28 - 4.0); + } + } + break; + case COURSE_DK_JUNGLE: + if ((var_s0 > 204) && (var_s0 < 220)) { + var_f20_2 = var_f28; + } else { + if (var_f20_2 < (var_f28 - 10.0)) { + var_f20_2 = (f32) (var_f28 - 4.0); + } + } + break; + default: + if (var_f20_2 < (var_f28 - 10.0)) { + var_f20_2 = (f32) var_f28 - 10.0; + } + break; + } + } + var_f28 = var_f20_2; + pathDest->posY = (s16) (s32) var_f20_2; + var_f30 = 0.0f; + pathDest++; + var_s0 += 1; + } + } + } + return var_s0; +} + +// Returns number of path processed. +s32 process_path_data(TrackPathPoint* dest, TrackPathPoint* src) { + s16 temp_a0; + s16 temp_a2; + s16 temp_a3; + s32 var_v0; + s32 var_v1; + u16 temp_t0; + + var_v1 = 0; + for (var_v0 = 0; var_v0 < 0x7D0; var_v0++) { + temp_a0 = src->posX; + temp_a2 = src->posY; + temp_a3 = src->posZ; + temp_t0 = src->trackSectionId; + src++; + if (((temp_a0 & 0xFFFF) == 0x8000) && ((temp_a2 & 0xFFFF) == 0x8000) && ((temp_a3 & 0xFFFF) == 0x8000)) { + break; + } + if (gIsMirrorMode != 0) { + dest->posX = -temp_a0; + } else { + dest->posX = temp_a0; + } + var_v1++; + dest->posY = temp_a2; + dest->posZ = temp_a3; + dest->trackSectionId = temp_t0; + dest++; + } + return var_v1; +} + +s32 generate_2d_path(Path2D* pathDest, TrackPathPoint* pathSrc, s32 numPathPoints) { + f32 temp_f14_3; + f32 temp_f16_2; + UNUSED s32 pad; + + f32 x1; + f32 z1; + f32 x2; + f32 z2; + f32 x3; + f32 z3; + + UNUSED s32 pad2; + f32 temp_f24; + + f32 spA8; + f32 temp_f26; + f32 spA0; + + f32 temp_f2_3; + + TrackPathPoint* point1; + f32 j; + TrackPathPoint* point2; + TrackPathPoint* point3; + s32 i; + f32 temp_f6 = 0.0f; + s32 nbElement; + f32 sp7C; + + spA8 = pathSrc[0].posX; + spA0 = pathSrc[0].posZ; + nbElement = 0; + + for (i = 0; i < numPathPoints; i++) { + point1 = &pathSrc[((i % numPathPoints))]; + point2 = &pathSrc[(((i + 1) % numPathPoints))]; + point3 = &pathSrc[(((i + 2) % numPathPoints))]; + x1 = point1->posX; + z1 = point1->posZ; + x2 = point2->posX; + z2 = point2->posZ; + x3 = point3->posX; + z3 = point3->posZ; + + sp7C = 0.05 / (sqrtf(((x2 - x1) * (x2 - x1)) + ((z2 - z1) * (z2 - z1))) + + sqrtf(((x3 - x2) * (x3 - x2)) + ((z3 - z2) * (z3 - z2)))); + + for (j = 0.0f; j <= 1.0; j += sp7C) { + temp_f2_3 = (1.0 - j) * 0.5 * (1.0 - j); + temp_f14_3 = ((1.0 - j) * j) + 0.5; + temp_f16_2 = j * 0.5 * j; + + temp_f24 = (temp_f2_3 * x1) + (temp_f14_3 * x2) + (temp_f16_2 * x3); + temp_f26 = (temp_f2_3 * z1) + (temp_f14_3 * z2) + (temp_f16_2 * z3); + temp_f6 += sqrtf(((temp_f24 - spA8) * (temp_f24 - spA8)) + ((temp_f26 - spA0) * (temp_f26 - spA0))); + spA8 = temp_f24; + spA0 = temp_f26; + if ((temp_f6 > 20.0f) || ((i == 0) && (j == 0.0))) { + if (gIsMirrorMode) { + pathDest->x = (s16) -spA8; + } else { + pathDest->x = (s16) spA8; + } + pathDest->z = spA0; + nbElement += 1; + pathDest++; + temp_f6 = 0.0f; + } + } + } + return nbElement; +} diff --git a/src/cpu_vehicles_camera_path/path_utils.inc.c b/src/cpu_vehicles_camera_path/path_utils.inc.c new file mode 100644 index 0000000000..f1fbe8b6bf --- /dev/null +++ b/src/cpu_vehicles_camera_path/path_utils.inc.c @@ -0,0 +1,849 @@ +#include +#include +#include +#include +#include +#include "main.h" +#include "cpu_vehicles_camera_path.h" + +bool are_in_curve(UNUSED s32 arg0, u16 pathPointIndex) { + s16 thing = gCurrentTrackConsecutiveCurveCountsPath[pathPointIndex]; + if (thing > 0) { + return true; + } + return false; +} + +bool is_far_from_path(s32 playerIndex) { + f32 value = gTrackPositionFactor[playerIndex]; + if ((1.1f <= value) || (value <= -1.1f)) { + return true; + } + return false; +} + +/** + * Calculates a factor representing where the player is positioned between left and right track boundaries + * Returns a value between -1.0 and 1.0: + * -1.0 = On the left boundary + * 0.0 = In the middle of the track + * 1.0 = On the right boundary + * + * @param posX Player's X position + * @param posZ Player's Z position + * @param pathPointIndex Current pathPoint index + * @param pathIndex Current path/track index + * @return Position factor between track boundaries + */ +f32 calculate_track_position_factor(f32 posX, f32 posZ, u16 pathPointIndex, s32 pathIndex) { + f32 leftX; + f32 leftZ; + f32 rightX; + f32 rightZ; + f32 boundarySquaredDistance; + f32 positionFactor; + TrackPathPoint* leftPathPoint; + TrackPathPoint* rightPathPoint; + + leftPathPoint = &gTrackLeftPaths[pathIndex][pathPointIndex]; + rightPathPoint = &gTrackRightPaths[pathIndex][pathPointIndex]; + + leftX = leftPathPoint->posX; + leftZ = leftPathPoint->posZ; + rightX = rightPathPoint->posX; + rightZ = rightPathPoint->posZ; + + boundarySquaredDistance = ((rightX - leftX) * (rightX - leftX)) + ((rightZ - leftZ) * (rightZ - leftZ)); + + // Avoid division by zero for very close or identical boundary points + if (boundarySquaredDistance < 0.01f) { + return 0.0f; + } + // Calculate normalized position factor using vector projection + // Formula: 2 * (dot product of vectors) / (squared magnitude) - 1 + // This maps the position to a -1 to 1 range + positionFactor = + ((2.0f * ((rightX - leftX) * (posX - leftX) + (rightZ - leftZ) * (posZ - leftZ))) / boundarySquaredDistance) - + 1.0f; + return positionFactor; +} + +void update_player_position_factor(s32 playerId, u16 pathPointIndex, s32 pathIndex) { + UNUSED Vec3f pad; + gTrackPositionFactor[playerId] = 0.0f; + if ((s32) GET_COURSE_AIMaximumSeparation >= 0) { + if ((gPlayers[playerId].type & PLAYER_EXISTS) != 0) { + gTrackPositionFactor[playerId] = calculate_track_position_factor( + gPlayers[playerId].pos[0], gPlayers[playerId].pos[2], pathPointIndex, pathIndex); + } + } +} + +void calculate_track_offset_position(u16 pathPointIndex, f32 lerpFactor, f32 offsetDistance, s16 pathIndex) { + UNUSED s32 pad[4]; + f32 pathPointOneX; + f32 pathPointOneZ; + f32 pathPointTwoX; + f32 pathPointTwoZ; + UNUSED s32 pad2; + f32 xdiff; + f32 zdiff; + f32 segmentLength; + UNUSED f32 temp_f12; + UNUSED f32 temp_f2_2; + UNUSED TrackPathPoint* path; + TrackPathPoint* pathPointTwo; + TrackPathPoint* pathPointOne; + + pathPointOne = &gTrackPaths[pathIndex][pathPointIndex]; + pathPointOneX = pathPointOne->posX; + pathPointOneZ = pathPointOne->posZ; + pathPointTwo = &gTrackPaths[pathIndex][(pathPointIndex + 1) % gSelectedPathCount]; + pathPointTwoX = pathPointTwo->posX; + pathPointTwoZ = pathPointTwo->posZ; + + // Calculate vector between path + zdiff = pathPointTwoZ - pathPointOneZ; + xdiff = pathPointTwoX - pathPointOneX; + if (xdiff && xdiff) {} + + segmentLength = sqrtf((xdiff * xdiff) + (zdiff * zdiff)); + if (segmentLength < 0.01f) { + gOffsetPosition[0] = pathPointTwoX; + gOffsetPosition[2] = pathPointTwoZ; + } else { + gOffsetPosition[0] = + ((0.5f - (lerpFactor * 0.5f)) * (((offsetDistance * zdiff) / segmentLength) + pathPointOneX)) + + ((1.0f - (0.5f - (lerpFactor * 0.5f))) * (((offsetDistance * -zdiff) / segmentLength) + pathPointOneX)); + gOffsetPosition[2] = + ((0.5f - (lerpFactor * 0.5f)) * (((offsetDistance * -xdiff) / segmentLength) + pathPointOneZ)) + + ((1.0f - (0.5f - (lerpFactor * 0.5f))) * (((offsetDistance * xdiff) / segmentLength) + pathPointOneZ)); + } +} + +/** + * Calculates an interpolated position between left and right track paths. + * + * @param currentPathPoint Index of the current pathPoint + * @param trackOffset Value between 0.0 and 1.0 determining position between left (0.0) and right (1.0) path + * @param pathIndex Index of the track/path segment + */ +void set_track_offset_position(u16 pathPointIndex, f32 trackOffset, s16 pathIndex) { + TrackPathPoint* path1; + TrackPathPoint* path2; + f32 x1; + f32 z1; + f32 x3; + f32 z3; + f32 x2; + f32 z2; + f32 x4; + f32 z4; + f32 temp_f0; + f32 temp_f12; + + path1 = &gTrackLeftPaths[pathIndex][pathPointIndex]; + path2 = &gTrackRightPaths[pathIndex][pathPointIndex]; + + x1 = (f32) path1->posX; + z1 = (f32) path1->posZ; + + x2 = (f32) path2->posX; + z2 = (f32) path2->posZ; + + pathPointIndex += 1; + pathPointIndex = pathPointIndex % gPathCountByPathIndex[pathIndex]; + + path1 = &gTrackLeftPaths[pathIndex][pathPointIndex]; + path2 = &gTrackRightPaths[pathIndex][pathPointIndex]; + + x3 = (f32) path1->posX; + z3 = (f32) path1->posZ; + + x4 = (f32) path2->posX; + z4 = (f32) path2->posZ; + + temp_f0 = 0.5f - (trackOffset / 2.0f); + temp_f12 = 1.0f - temp_f0; + gOffsetPosition[0] = ((temp_f0 * (x1 + x3)) / 2.0f) + ((temp_f12 * (x2 + x4)) / 2.0f); + gOffsetPosition[2] = ((temp_f0 * (z1 + z3)) / 2.0f) + ((temp_f12 * (z2 + z4)) / 2.0f); +} + +s16 func_8000BD94(f32 posX, f32 posY, f32 posZ, s32 pathIndex) { + f32 x_dist; + f32 y_dist; + f32 z_dist; + f32 considerSquaredDistance; + f32 minimumSquaredDistance; + s32 considerPathPointIndex; + s32 pathPathPointCount; + s16 nearestPathPointIndex; + TrackPathPoint* pathPathPoints; + TrackPathPoint* considerPathPoint; + + pathPathPoints = gTrackPaths[pathIndex]; + pathPathPointCount = gPathCountByPathIndex[pathIndex]; + considerPathPoint = &pathPathPoints[0]; + x_dist = (f32) considerPathPoint->posX - posX; + y_dist = (f32) considerPathPoint->posY - posY; + z_dist = (f32) considerPathPoint->posZ - posZ; + minimumSquaredDistance = (x_dist * x_dist) + (y_dist * y_dist) + (z_dist * z_dist); + nearestPathPointIndex = 0; + for (considerPathPointIndex = 1; considerPathPointIndex < pathPathPointCount; + considerPathPoint++, considerPathPointIndex++) { + x_dist = (f32) considerPathPoint->posX - posX; + y_dist = (f32) considerPathPoint->posY - posY; + z_dist = (f32) considerPathPoint->posZ - posZ; + considerSquaredDistance = (x_dist * x_dist) + (y_dist * y_dist) + (z_dist * z_dist); + if (considerSquaredDistance < minimumSquaredDistance) { + nearestPathPointIndex = considerPathPointIndex; + minimumSquaredDistance = considerSquaredDistance; + } + } + return nearestPathPointIndex; +} + +s16 find_closest_pathPoint_track_section(f32 posX, f32 posY, f32 posZ, u16 trackSectionId, s32* pathIndex) { + TrackPathPoint* pathPathPoints; + TrackPathPoint* considerPathPoint; + f32 x_dist; + f32 y_dist; + f32 z_dist; + f32 considerSquaredDistance; + f32 minimumSquaredDistance; + s32 considerPathPointIndex; + s32 pathPathPointCount; + s32 temp_t0; + s32 var_a1; + s32 var_t1; + s32 considerPathIndex; + s32 var_t4; + s16 nearestPathPointIndex; + + minimumSquaredDistance = 1000000.0f; + temp_t0 = *pathIndex; + nearestPathPointIndex = 0; + var_t1 = 0; + var_a1 = 0; + pathPathPoints = gTrackPaths[temp_t0]; + pathPathPointCount = gPathCountByPathIndex[temp_t0]; + considerPathPoint = &pathPathPoints[0]; + for (considerPathPointIndex = 0; considerPathPointIndex < pathPathPointCount; + considerPathPointIndex++, considerPathPoint++) { + if ((considerPathPoint->trackSectionId == trackSectionId) || (gCurrentCourseId == COURSE_AWARD_CEREMONY)) { + var_t1 = 1; + x_dist = (f32) considerPathPoint->posX - posX; + y_dist = (f32) considerPathPoint->posY - posY; + z_dist = (f32) considerPathPoint->posZ - posZ; + considerSquaredDistance = (x_dist * x_dist) + (y_dist * y_dist) + (z_dist * z_dist); + if (considerSquaredDistance < minimumSquaredDistance) { + nearestPathPointIndex = considerPathPointIndex; + var_a1 = 1; + minimumSquaredDistance = considerSquaredDistance; + } + } + } + if (var_t1 == 0) { + for (considerPathIndex = 0; considerPathIndex < 4; considerPathIndex++) { + if ((considerPathIndex != temp_t0) && (gSizePath[considerPathIndex] >= 2)) { + pathPathPoints = gTrackPaths[considerPathIndex]; + considerPathPoint = &pathPathPoints[0]; + pathPathPointCount = gPathCountByPathIndex[considerPathIndex]; + for (considerPathPointIndex = 0; considerPathPointIndex < pathPathPointCount; + considerPathPointIndex++, considerPathPoint++) { + if (considerPathPoint->trackSectionId == trackSectionId) { + x_dist = (f32) considerPathPoint->posX - posX; + y_dist = (f32) considerPathPoint->posY - posY; + z_dist = (f32) considerPathPoint->posZ - posZ; + considerSquaredDistance = (x_dist * x_dist) + (y_dist * y_dist) + (z_dist * z_dist); + if (considerSquaredDistance < minimumSquaredDistance) { + nearestPathPointIndex = considerPathPointIndex; + var_t4 = considerPathIndex; + var_a1 = 2; + minimumSquaredDistance = considerSquaredDistance; + } + } + } + } + } + } + if (var_a1 == 0) { + pathPathPoints = gTrackPaths[0]; + pathPathPointCount = gPathCountByPathIndex[0]; + considerPathPoint = &pathPathPoints[0]; + x_dist = (f32) considerPathPoint->posX - posX; + y_dist = (f32) considerPathPoint->posY - posY; + z_dist = (f32) considerPathPoint->posZ - posZ; + minimumSquaredDistance = (x_dist * x_dist) + (y_dist * y_dist) + (z_dist * z_dist); + nearestPathPointIndex = 0; + for (considerPathPointIndex = 1; considerPathPointIndex < pathPathPointCount; + considerPathPoint++, considerPathPointIndex++) { + x_dist = (f32) considerPathPoint->posX - posX; + y_dist = (f32) considerPathPoint->posY - posY; + z_dist = (f32) considerPathPoint->posZ - posZ; + considerSquaredDistance = (x_dist * x_dist) + (y_dist * y_dist) + (z_dist * z_dist); + if (considerSquaredDistance < minimumSquaredDistance) { + nearestPathPointIndex = considerPathPointIndex; + var_t4 = 0; + var_a1 = 2; + minimumSquaredDistance = considerSquaredDistance; + } + } + } + if (var_a1 == 2) { + *pathIndex = var_t4; + } + return nearestPathPointIndex; +} + +/** + * Tries to find the pathPoint nearest to (posX, posY, posZ) + * Only consider path in the same segment as trackSectionId + * Only considers path within 500 units of(posX, posY, posZ) + * Looks 3 path behind and 6 path ahead of pathPointIndex + **/ +s16 update_path_index_with_track(f32 posX, f32 posY, f32 posZ, s16 pathPointIndex, s32 pathIndex, u16 trackSectionId) { + s16 nearestPathPointIndex; + s16 searchIndex; + s16 considerIndex; + s32 pathPathPointCount; + f32 x_dist; + f32 y_dist; + f32 z_dist; + f32 minimumDistance; + f32 squaredDistance; + TrackPathPoint* pathPathPoints; + TrackPathPoint* considerPathPoint; + + nearestPathPointIndex = -1; + minimumDistance = 500.0f * 500.0f; + pathPathPointCount = gPathCountByPathIndex[pathIndex]; + pathPathPoints = gTrackPaths[pathIndex]; + for (searchIndex = pathPointIndex - 3; searchIndex < pathPointIndex + 7; searchIndex++) { + // Its possible for searchIndex to be less than 0 or greater than the number of path in a given path + // This is done to ensure we access gTrackPaths at a valid index + considerIndex = (searchIndex + pathPathPointCount) % pathPathPointCount; + considerPathPoint = &pathPathPoints[considerIndex]; + if (considerPathPoint->trackSectionId == trackSectionId) { + x_dist = considerPathPoint->posX - posX; + y_dist = considerPathPoint->posY - posY; + z_dist = considerPathPoint->posZ - posZ; + squaredDistance = (x_dist * x_dist) + (y_dist * y_dist) + (z_dist * z_dist); + if (squaredDistance < minimumDistance) { + minimumDistance = squaredDistance; + nearestPathPointIndex = considerIndex; + } + } + } + return nearestPathPointIndex; +} + +/** + * Tries to find the pathPoint nearest to (posX, posY, posZ) + * Only considers path within 400 units of (posX, posY, posZ) + * Looks 3 path behind and 6 path ahead of pathPointIndex + **/ +s16 update_path_index(f32 posX, f32 posY, f32 posZ, s16 pathPointIndex, s32 pathIndex) { + s16 nearestPathPointIndex; + s16 searchIndex; + s16 considerIndex; + bool pathPointFound; + s32 pathPathPointCount; + f32 x_dist; + f32 y_dist; + f32 z_dist; + f32 minimumDistance; + f32 squaredDistance; + TrackPathPoint* pathPathPoints; + TrackPathPoint* considerPathPoint; + + pathPointFound = false; + nearestPathPointIndex = -1; + minimumDistance = 400.0f * 400.0f; + pathPathPointCount = gPathCountByPathIndex[pathIndex]; + pathPathPoints = gTrackPaths[pathIndex]; + for (searchIndex = pathPointIndex - 3; searchIndex < pathPointIndex + 7; searchIndex++) { + // Its possible for searchIndex to be less than 0 or greater than the number of path in a given path + // This is done to ensure we access gTrackPaths at a valid index + considerIndex = (searchIndex + pathPathPointCount) % pathPathPointCount; + considerPathPoint = &pathPathPoints[considerIndex]; + x_dist = considerPathPoint->posX - posX; + y_dist = considerPathPoint->posY - posY; + z_dist = considerPathPoint->posZ - posZ; + squaredDistance = (x_dist * x_dist) + (y_dist * y_dist) + (z_dist * z_dist); + if (squaredDistance < minimumDistance) { + minimumDistance = squaredDistance; + nearestPathPointIndex = considerIndex; + pathPointFound = true; + } + } + if (pathPointFound == false) { + for (searchIndex = pathPointIndex - 3; searchIndex < pathPointIndex + 7; searchIndex++) { + considerIndex = ((searchIndex + pathPathPointCount) % pathPathPointCount); + considerPathPoint = &pathPathPoints[considerIndex]; + /** + * This fake match is done to stop the compiler from optimzing out considerPathPoint. + * Maybe if no pathPoint was found some debugging info was printed out, but come + * production time they removed the debug printing but not the loop? + **/ + if (considerPathPoint && considerPathPoint) {}; + } + } + return nearestPathPointIndex; +} + +void tweak_path_index_wario_stadium(UNUSED f32 posX, f32 posY, UNUSED f32 posZ, s16* pathPointIndex, UNUSED s32 arg4) { + s16 var_v0; + + var_v0 = *pathPointIndex; + if ((gCurrentCourseId == COURSE_WARIO_STADIUM) && (var_v0 >= 0x475) && (var_v0 < 0x480) && (posY < 0.0f)) { + var_v0 = 0x0398; + } + *pathPointIndex = var_v0; +} + +void adjust_path_at_start_line(UNUSED f32 posX, UNUSED f32 posY, f32 posZ, s16* pathPointIndex, s32 pathIndex) { + s16 pathPoint; + pathPoint = *pathPointIndex; + if (pathPoint == 0) { + if (gPathStartZ < posZ) { + pathPoint = gPathCountByPathIndex[pathIndex] - 1; + } + } else if (((pathPoint + 1) == gPathCountByPathIndex[pathIndex]) && (posZ <= gPathStartZ)) { + pathPoint = 0; + } + *pathPointIndex = pathPoint; +} + +s16 update_path_index_track_section(f32 posX, f32 posY, f32 posZ, Player* player, s32 playerId, s32* pathIndex) { + u16 trackSectionId; + s16 ret; + + trackSectionId = get_track_section_id(player->collision.meshIndexZX); + if ((trackSectionId <= 0) || (trackSectionId >= 0x33)) { + trackSectionId = gPlayersTrackSectionId[playerId]; + } + gPlayersTrackSectionId[playerId] = trackSectionId; + ret = find_closest_pathPoint_track_section(posX, posY, posZ, trackSectionId, pathIndex); + gPathIndexByPlayerId[playerId] = *pathIndex; + return ret; +} + +/** + * Updates and validates a player's pathPoint position on the track + * Handles different logic for human players vs AI, and includes recovery mechanisms + * + * @param posX Current X position + * @param posY Current Y position + * @param posZ Current Z position + * @param pathPointIndex Current pathPoint index + * @param player Pointer to player structure + * @param playerId Player's ID + * @param pathIndex Current track path index + * @return New pathPoint index or -1 if invalid + */ +s16 update_player_path(f32 posX, f32 posY, f32 posZ, s16 pathPointIndex, Player* player, s32 playerId, s32 pathIndex) { + s16 newPathPoint; + UNUSED s16 stackPadding0; + UNUSED s32 stackPadding1; + UNUSED s32 stackPadding2; + TrackPathPoint* temp_v1; + + // Human player handling (non-AI controlled) + if ((player->type & PLAYER_HUMAN) && !(player->type & PLAYER_CPU)) { + newPathPoint = update_path_index_with_track(posX, posY, posZ, pathPointIndex, pathIndex, + (u16) get_track_section_id(player->collision.meshIndexZX)); + if (newPathPoint == -1) { + newPathPoint = update_path_index_track_section(posX, posY, posZ, player, playerId, &pathIndex); + } + } else { // AI or special case player handling + if (D_801631E0[playerId] == true) { + if (player->unk_0CA & 1) { + temp_v1 = &gTrackPaths[pathIndex][pathPointIndex]; + player->pos[0] = (f32) temp_v1->posX; + player->pos[1] = (f32) temp_v1->posY; + player->pos[2] = (f32) temp_v1->posZ; + player->unk_0CA &= ~0x0001; + return pathPointIndex; + } + if (playerId == ((s32) D_80163488 % 8)) { + check_bounding_collision(&player->collision, 10.0f, posX, posY, posZ); + gPlayersTrackSectionId[playerId] = get_track_section_id(player->collision.meshIndexZX); + newPathPoint = update_path_index_with_track(posX, posY, posZ, pathPointIndex, pathIndex, + gPlayersTrackSectionId[playerId]); + if (newPathPoint == -1) { + newPathPoint = update_path_index(posX, posY, posZ, pathPointIndex, pathIndex); + } + if (newPathPoint == -1) { + newPathPoint = find_closest_pathPoint_track_section(posX, posY, posZ, + gPlayersTrackSectionId[playerId], &pathIndex); + temp_v1 = &gTrackPaths[pathIndex][newPathPoint]; + player->pos[0] = (f32) temp_v1->posX; + player->pos[1] = (f32) temp_v1->posY; + player->pos[2] = (f32) temp_v1->posZ; + } + } else { + newPathPoint = update_path_index(posX, posY, posZ, pathPointIndex, pathIndex); + if (newPathPoint == -1) { + newPathPoint = func_8000BD94(posX, posY, posZ, pathIndex); + temp_v1 = &gTrackPaths[pathIndex][newPathPoint]; + posX = (f32) temp_v1->posX; + posY = (f32) temp_v1->posY; + posZ = (f32) temp_v1->posZ; + player->pos[0] = posX; + player->pos[1] = posY; + player->pos[2] = posZ; + check_bounding_collision(&player->collision, 10.0f, posX, posY, posZ); + gPlayersTrackSectionId[playerId] = get_track_section_id(player->collision.meshIndexZX); + } + } + } else { + newPathPoint = update_path_index(posX, posY, posZ, pathPointIndex, pathIndex); + if (newPathPoint == -1) { + newPathPoint = update_path_index_track_section(posX, posY, posZ, player, playerId, &pathIndex); + } + } + tweak_path_index_wario_stadium(posX, posY, posZ, &newPathPoint, pathIndex); + } + adjust_path_at_start_line(posX, posY, posZ, &newPathPoint, pathIndex); + return newPathPoint; +} + +s16 find_closest_vehicles_pathPoint(f32 xPos, UNUSED f32 yPos, f32 zPos, s16 pathPointIndex) { + f32 xdiff; + f32 zdiff; + f32 minimumDistance; + f32 considerSquaredDistance; + s16 realIndex; + s16 minimumIndex; + s16 considerIndex; + Path2D* considerPathPoint; + + minimumDistance = 250000.0f; + minimumIndex = -1; + for (realIndex = pathPointIndex - 2; realIndex < pathPointIndex + 7; realIndex++) { + considerIndex = realIndex; + if (realIndex < 0) { + considerIndex = realIndex + gVehicle2DPathLength; + } + considerIndex %= gVehicle2DPathLength; + considerPathPoint = &gVehicle2DPathPoint[considerIndex]; + xdiff = considerPathPoint->x - xPos; + zdiff = considerPathPoint->z - zPos; + considerSquaredDistance = (xdiff * xdiff) + (zdiff * zdiff); + if (considerSquaredDistance < minimumDistance) { + minimumDistance = considerSquaredDistance; + minimumIndex = considerIndex; + } + } + if (minimumIndex == -1) { + minimumIndex = pathPointIndex; + } + return minimumIndex; +} + +s16 func_8000D24C(f32 posX, f32 posY, f32 posZ, s32* pathIndex) { + UNUSED s32 pad; + Collision sp24; + + check_bounding_collision(&sp24, 10.0f, posX, posY, posZ); + return find_closest_pathPoint_track_section(posX, posY, posZ, get_track_section_id(sp24.meshIndexZX), pathIndex); +} + +s16 func_8000D2B4(f32 posX, f32 posY, f32 posZ, s16 pathPointIndex, s32 pathIndex) { + s16 pathPoint; + + pathPoint = update_path_index(posX, posY, posZ, pathPointIndex, pathIndex); + if (pathPoint == -1) { + pathPoint = func_8000D24C(posX, posY, posZ, &pathIndex); + } + adjust_path_at_start_line(posX, posY, posZ, &pathPoint, pathIndex); + return pathPoint; +} + +s16 func_8000D33C(f32 posX, f32 posY, f32 posZ, s16 pathPointIndex, s32 pathIndex) { + s16 pathPoint; + + pathPoint = update_path_index(posX, posY, posZ, pathPointIndex, pathIndex); + if (pathPoint == -1) { + pathPoint = func_8000D24C(posX, posY, posZ, &pathIndex); + } + return pathPoint; +} + +f32 cpu_track_position_factor(s32 playerId) { + TrackPositionFactorInstruction* temp_v0; + f32 target; + f32 current; + + temp_v0 = &gPlayerTrackPositionFactorInstruction[playerId]; + current = temp_v0->current; + target = temp_v0->target; + if (current < target) { + current += temp_v0->step; + if (target < current) { + current = target; + } + } else if (target < current) { + current -= temp_v0->step; + if (current < target) { + current = target; + } + } + temp_v0->current = current; + return current; +} + +void determine_ideal_cpu_position_offset(s32 playerId, u16 pathPoint) { + UNUSED s32 stackPadding0; + f32 sp48; + f32 sp44; + UNUSED s32 stackPadding1; + UNUSED s32 stackPadding2; + UNUSED s32 stackPadding3; + f32 stackPadding4; + f32 stackPadding5; + f32 sp2C; + s32 lookAheadDistance; + s16 curveCount; + u16 thing; + + curveCount = gCurrentTrackConsecutiveCurveCountsPath[pathPoint]; + lookAheadDistance = 6; + sp2C = cpu_track_position_factor(playerId); + thing = pathPoint; + + switch (gCurrentCourseId) { + case COURSE_AWARD_CEREMONY: + lookAheadDistance = 1; + break; + case COURSE_TOADS_TURNPIKE: + lookAheadDistance = 7; + break; + case COURSE_YOSHI_VALLEY: + break; + default: + if (curveCount < 6) { + lookAheadDistance = 8; + } else if (curveCount >= 0x15) { + lookAheadDistance = 20; + } + break; + } + + if (lookAheadDistance >= 8) { + if ((gTrackPositionFactor[playerId] > 0.75f) && (gCurrentTrackSectionTypesPath[thing] == RIGHT_LEANING_CURVE)) { + lookAheadDistance = 7; + } + if ((gTrackPositionFactor[playerId] < -0.75f) && (gCurrentTrackSectionTypesPath[thing] == LEFT_LEANING_CURVE)) { + lookAheadDistance = 7; + } + } + if (is_far_from_path(playerId) == true) { + lookAheadDistance = 5; + } + if (gCurrentPlayerLookAhead[playerId] < lookAheadDistance) { + gCurrentPlayerLookAhead[playerId]++; + } + if (lookAheadDistance < gCurrentPlayerLookAhead[playerId]) { + gCurrentPlayerLookAhead[playerId]--; + } + pathPoint = (gCurrentPlayerLookAhead[playerId] + pathPoint) % gSelectedPathCount; + set_track_offset_position(pathPoint, sp2C, gPlayerPathIndex); + sp48 = gOffsetPosition[0]; + sp44 = gOffsetPosition[2]; + set_track_offset_position(((pathPoint + 1) % gSelectedPathCount) & 0xFFFF, sp2C, gPlayerPathIndex); + stackPadding5 = gOffsetPosition[0]; + gOffsetPosition[0] = (sp48 + stackPadding5) * 0.5f; + stackPadding4 = gOffsetPosition[2]; + gOffsetPosition[2] = (sp44 + stackPadding4) * 0.5f; +} + +s16 func_8000D6D0(Vec3f position, s16* pathPointIndex, f32 speed, f32 arg3, s16 pathIndex, s16 arg5) { + f32 temp1; + f32 temp2; + f32 midX; + UNUSED s16 stackPadding1; + s16 pathPoint1; + s16 pathPoint2; + f32 pad3; + f32 midY; + f32 pad4; + f32 midZ; + f32 distance; + f32 oldPosX; + f32 oldPosY; + f32 oldPosZ; + f32 var_f2; + f32 var_f12; + f32 var_f14; + s16 temp_v0; + s32 temp_v1; + f32 xdiff; + f32 ydiff; + f32 zdiff; + Vec3f oldPos; + TrackPathPoint* path; + + path = gTrackPaths[pathIndex]; + oldPos[0] = position[0]; + oldPos[1] = position[1]; + oldPos[2] = position[2]; + oldPosX = position[0]; + oldPosY = position[1]; + oldPosZ = position[2]; + temp_v0 = func_8000D2B4(oldPosX, oldPosY, oldPosZ, *pathPointIndex, (s32) pathIndex); + *pathPointIndex = temp_v0; + temp_v1 = temp_v0 + arg5; + pathPoint1 = temp_v1 % gPathCountByPathIndex[pathIndex]; + pathPoint2 = (temp_v1 + 1) % gPathCountByPathIndex[pathIndex]; + set_track_offset_position(pathPoint1, arg3, pathIndex); + pad3 = gOffsetPosition[0]; + pad4 = gOffsetPosition[2]; + set_track_offset_position(pathPoint2, arg3, pathIndex); + temp1 = gOffsetPosition[0]; + temp2 = gOffsetPosition[2]; + midY = (path[pathPoint1].posY + path[pathPoint2].posY) * 0.5f; + midX = (pad3 + temp1) * 0.5f; + midZ = (pad4 + temp2) * 0.5f; + xdiff = midX - oldPosX; + ydiff = midY - oldPosY; + zdiff = midZ - oldPosZ; + distance = sqrtf((xdiff * xdiff) + (ydiff * ydiff) + (zdiff * zdiff)); + if (distance > 0.01f) { + var_f2 = ((xdiff * speed) / distance) + oldPosX; + var_f12 = ((ydiff * speed) / distance) + oldPosY; + var_f14 = ((zdiff * speed) / distance) + oldPosZ; + } else { + var_f2 = oldPosX; + var_f12 = oldPosY; + var_f14 = oldPosZ; + } + position[0] = var_f2; + position[1] = var_f12; + position[2] = var_f14; + return get_angle_between_path(oldPos, position); +} + +s16 func_8000D940(Vec3f pos, s16* pathPointIndex, f32 speed, f32 arg3, s16 pathIndex) { + UNUSED f32 pad; + f32 thing1; + f32 thing2; + UNUSED s16 stackPadding1; + s16 pathPoint1; + s16 pathPoint2; + UNUSED s16 stackPadding2; + f32 pad2; + f32 midX; + f32 pad3; + f32 midY; + f32 midZ; + f32 distance; + f32 temp_f20; + f32 temp_f22; + f32 temp_f24; + f32 var_f2; + f32 var_f12; + f32 var_f14; + s16 temp_v0; + f32 xdiff; + f32 ydiff; + f32 zdiff; + s32 pathPointCount; + Vec3f sp54; + + sp54[0] = pos[0]; + sp54[1] = pos[1]; + sp54[2] = pos[2]; + pathPointCount = gPathCountByPathIndex[pathIndex]; + temp_f20 = pos[0]; + temp_f22 = pos[1]; + temp_f24 = pos[2]; + temp_v0 = func_8000D2B4(temp_f20, temp_f22, temp_f24, *pathPointIndex, (s32) pathIndex); + *pathPointIndex = temp_v0; + pathPoint1 = ((temp_v0 + pathPointCount) - 3) % pathPointCount; + pathPoint2 = ((temp_v0 + pathPointCount) - 4) % pathPointCount; + set_track_offset_position(pathPoint1, arg3, pathIndex); + pad2 = gOffsetPosition[0]; + pad3 = gOffsetPosition[2]; + set_track_offset_position(pathPoint2, arg3, pathIndex); + thing1 = gOffsetPosition[0]; + thing2 = gOffsetPosition[2]; + midY = (gTrackPaths[pathIndex][pathPoint1].posY + gTrackPaths[pathIndex][pathPoint2].posY) * 0.5f; + midX = (pad2 + thing1) * 0.5f; + midZ = (pad3 + thing2) * 0.5f; + xdiff = midX - temp_f20; + ydiff = midY - temp_f22; + zdiff = midZ - temp_f24; + distance = sqrtf((xdiff * xdiff) + (ydiff * ydiff) + (zdiff * zdiff)); + if (distance > 0.01f) { + var_f2 = ((xdiff * speed) / distance) + temp_f20; + var_f12 = ((ydiff * speed) / distance) + temp_f22; + var_f14 = ((zdiff * speed) / distance) + temp_f24; + } else { + var_f2 = temp_f20; + var_f12 = temp_f22; + var_f14 = temp_f24; + } + pos[0] = var_f2; + pos[1] = var_f12; + pos[2] = var_f14; + return get_angle_between_path(sp54, pos); +} + +s16 update_vehicle_following_path(Vec3f pos, s16* pathPointIndex, f32 speed) { + f32 origXPos; + f32 origYPos; + f32 origZPos; + UNUSED s32 stackPadding0; + UNUSED s32 stackPadding1; + UNUSED s32 stackPadding2; + UNUSED s32 stackPadding3; + UNUSED s32 stackPadding4; + UNUSED s32 stackPadding5; + UNUSED s32 stackPadding6; + UNUSED s32 stackPadding7; + UNUSED s32 stackPadding8; + f32 farPathPointAverageX; + f32 farPathPointAverageZ; + f32 x_dist; + f32 y_dist; + f32 distance; + f32 newX; + f32 newZ; + s16 newPathPointIndex; + s16 farPathPoint1; + s16 farPathPoint2; + Path2D* temp_a0; + Path2D* temp_a2; + Vec3f sp38; + + origXPos = pos[0]; + origYPos = pos[1]; + origZPos = pos[2]; + sp38[0] = pos[0]; + sp38[1] = pos[1]; + sp38[2] = pos[2]; + newPathPointIndex = find_closest_vehicles_pathPoint(origXPos, origYPos, origZPos, *pathPointIndex); + *pathPointIndex = newPathPointIndex; + farPathPoint1 = (newPathPointIndex + 3) % gVehicle2DPathLength; + farPathPoint2 = (newPathPointIndex + 4) % gVehicle2DPathLength; + temp_a0 = &gVehicle2DPathPoint[farPathPoint1]; + temp_a2 = &gVehicle2DPathPoint[farPathPoint2]; + farPathPointAverageX = (temp_a0->x + temp_a2->x) * 0.5f; + farPathPointAverageZ = (temp_a0->z + temp_a2->z) * 0.5f; + x_dist = farPathPointAverageX - origXPos; + y_dist = farPathPointAverageZ - origZPos; + distance = sqrtf((x_dist * x_dist) + (y_dist * y_dist)); + if (distance > 0.01f) { + newX = ((x_dist * speed) / distance) + origXPos; + newZ = ((y_dist * speed) / distance) + origZPos; + } else { + newX = origXPos; + newZ = origZPos; + } + pos[0] = newX; + pos[1] = origYPos; + pos[2] = newZ; + return get_angle_between_path(sp38, pos); +} diff --git a/src/cpu_vehicles_camera_path/vehicle_utils.inc.c b/src/cpu_vehicles_camera_path/vehicle_utils.inc.c new file mode 100644 index 0000000000..270520d04c --- /dev/null +++ b/src/cpu_vehicles_camera_path/vehicle_utils.inc.c @@ -0,0 +1,1091 @@ +#define GET_PATH_LENGTH(pathPoint) \ + for (i = 0;; i++) { \ + if ((u16) pathPoint[i].posX == 0x8000) { \ + break; \ + } \ + } + +void generate_train_path(void) { + s32 i; + Path2D* temp; + TrackPathPoint* pathPoint = + (TrackPathPoint*) VIRTUAL_TO_PHYSICAL2(gSegmentTable[SEGMENT_NUMBER2(d_course_kalimari_desert_train_path)] + + SEGMENT_OFFSET(d_course_kalimari_desert_train_path)); + + GET_PATH_LENGTH(pathPoint) + + temp = gVehicle2DPathPoint; + gVehicle2DPathLength = generate_2d_path(temp, pathPoint, i - 1); + D_80162EB0 = get_surface_height(temp[0].x, 2000.0f, temp[0].z); +} + +void generate_ferry_path(void) { + TrackPathPoint* pathPoint; + s32 i; + + pathPoint = + (TrackPathPoint*) VIRTUAL_TO_PHYSICAL2(gSegmentTable[SEGMENT_NUMBER2(d_course_dks_jungle_parkway_ferry_path)] + + (SEGMENT_OFFSET(d_course_dks_jungle_parkway_ferry_path))); + + GET_PATH_LENGTH(pathPoint) + + gVehicle2DPathLength = generate_2d_path(gVehicle2DPathPoint, pathPoint, i - 1); + D_80162EB2 = -40; +} + +void spawn_vehicle_on_road(VehicleStuff* vehicle) { + f32 origXPos; + UNUSED f32 pad; + f32 origZPos; + + origXPos = vehicle->position[0]; + origZPos = vehicle->position[2]; + if (gIsInExtra == false) { + func_8000D6D0(vehicle->position, (s16*) &vehicle->pathPointIndex, vehicle->speed, + vehicle->someMultiplierTheSequel, 0, 3); + vehicle->rotation[0] = 0; + vehicle->rotation[1] = -0x8000; + vehicle->rotation[2] = 0; + } else { + func_8000D940(vehicle->position, (s16*) &vehicle->pathPointIndex, vehicle->speed, + vehicle->someMultiplierTheSequel, 0); + vehicle->rotation[0] = 0; + vehicle->rotation[1] = 0; + vehicle->rotation[2] = 0; + } + vehicle->velocity[0] = vehicle->position[0] - origXPos; + vehicle->velocity[2] = vehicle->position[2] - origZPos; +} + +void spawn_course_vehicles(void) { + s16 trainCarYRot; + UNUSED Vec3f pad; + TrainCarStuff* tempLocomotive; + TrainCarStuff* tempTender; + TrainCarStuff* tempPassengerCar; + Vec3s trainCarRot; + VehicleStuff* tempBoxTruck; + VehicleStuff* tempSchoolBus; + VehicleStuff* tempTankerTruck; + VehicleStuff* tempCar; + PaddleBoatStuff* tempPaddleWheelBoat; + Vec3s paddleWheelBoatRot; + s32 loopIndex; + s32 loopIndex2; + f32 origXPos; + f32 origZPos; + +#if !ENABLE_CUSTOM_COURSE_ENGINE + switch (gCurrentCourseId) { + case COURSE_KALAMARI_DESERT: + for (loopIndex = 0; loopIndex < NUM_TRAINS; loopIndex++) { + tempLocomotive = &gTrainList[loopIndex].locomotive; + origXPos = tempLocomotive->position[0]; + origZPos = tempLocomotive->position[2]; + trainCarYRot = update_vehicle_following_path( + tempLocomotive->position, (s16*) &tempLocomotive->pathPointIndex, gTrainList[loopIndex].speed); + tempLocomotive->velocity[0] = tempLocomotive->position[0] - origXPos; + tempLocomotive->velocity[2] = tempLocomotive->position[2] - origZPos; + vec3s_set(trainCarRot, 0, trainCarYRot, 0); + tempLocomotive->actorIndex = add_actor_to_empty_slot(tempLocomotive->position, trainCarRot, + tempLocomotive->velocity, ACTOR_TRAIN_ENGINE); + + tempTender = &gTrainList[loopIndex].tender; + if (tempTender->isActive == 1) { + origXPos = tempTender->position[0]; + origZPos = tempTender->position[2]; + trainCarYRot = update_vehicle_following_path( + tempTender->position, (s16*) &tempTender->pathPointIndex, gTrainList[loopIndex].speed); + tempTender->velocity[0] = tempTender->position[0] - origXPos; + tempTender->velocity[2] = tempTender->position[2] - origZPos; + vec3s_set(trainCarRot, 0, trainCarYRot, 0); + tempTender->actorIndex = add_actor_to_empty_slot(tempTender->position, trainCarRot, + tempTender->velocity, ACTOR_TRAIN_TENDER); + } + + for (loopIndex2 = 0; loopIndex2 < NUM_PASSENGER_CAR_ENTRIES; loopIndex2++) { + tempPassengerCar = &gTrainList[loopIndex].passengerCars[loopIndex2]; + if (tempPassengerCar->isActive == 1) { + origXPos = tempPassengerCar->position[0]; + origZPos = tempPassengerCar->position[2]; + trainCarYRot = update_vehicle_following_path(tempPassengerCar->position, + (s16*) &tempPassengerCar->pathPointIndex, + gTrainList[loopIndex].speed); + tempPassengerCar->velocity[0] = tempPassengerCar->position[0] - origXPos; + tempPassengerCar->velocity[2] = tempPassengerCar->position[2] - origZPos; + vec3s_set(trainCarRot, 0, trainCarYRot, 0); + tempPassengerCar->actorIndex = + add_actor_to_empty_slot(tempPassengerCar->position, trainCarRot, tempPassengerCar->velocity, + ACTOR_TRAIN_PASSENGER_CAR); + } + } + } + break; + case COURSE_DK_JUNGLE: + for (loopIndex = 0; loopIndex < NUM_ACTIVE_PADDLE_BOATS; loopIndex++) { + tempPaddleWheelBoat = &gPaddleBoats[loopIndex]; + if (tempPaddleWheelBoat->isActive == 1) { + origXPos = tempPaddleWheelBoat->position[0]; + origZPos = tempPaddleWheelBoat->position[2]; + tempPaddleWheelBoat->rotY = update_vehicle_following_path( + tempPaddleWheelBoat->position, (s16*) &tempPaddleWheelBoat->pathPointIndex, + tempPaddleWheelBoat->speed); + tempPaddleWheelBoat->velocity[0] = tempPaddleWheelBoat->position[0] - origXPos; + tempPaddleWheelBoat->velocity[2] = tempPaddleWheelBoat->position[2] - origZPos; + vec3s_set(paddleWheelBoatRot, 0, tempPaddleWheelBoat->rotY, 0); + tempPaddleWheelBoat->actorIndex = + add_actor_to_empty_slot(tempPaddleWheelBoat->position, paddleWheelBoatRot, + tempPaddleWheelBoat->velocity, ACTOR_PADDLE_BOAT); + } + } + break; + case COURSE_TOADS_TURNPIKE: + for (loopIndex = 0; loopIndex < NUM_RACE_BOX_TRUCKS; loopIndex++) { + tempBoxTruck = &gBoxTruckList[loopIndex]; + spawn_vehicle_on_road(tempBoxTruck); + tempBoxTruck->actorIndex = add_actor_to_empty_slot(tempBoxTruck->position, tempBoxTruck->rotation, + tempBoxTruck->velocity, ACTOR_BOX_TRUCK); + } + for (loopIndex = 0; loopIndex < NUM_RACE_SCHOOL_BUSES; loopIndex++) { + tempSchoolBus = &gSchoolBusList[loopIndex]; + spawn_vehicle_on_road(tempSchoolBus); + tempSchoolBus->actorIndex = add_actor_to_empty_slot(tempSchoolBus->position, tempSchoolBus->rotation, + tempSchoolBus->velocity, ACTOR_SCHOOL_BUS); + } + for (loopIndex = 0; loopIndex < NUM_RACE_TANKER_TRUCKS; loopIndex++) { + tempTankerTruck = &gTankerTruckList[loopIndex]; + spawn_vehicle_on_road(tempTankerTruck); + tempTankerTruck->actorIndex = + add_actor_to_empty_slot(tempTankerTruck->position, tempTankerTruck->rotation, + tempTankerTruck->velocity, ACTOR_TANKER_TRUCK); + } + for (loopIndex = 0; loopIndex < NUM_RACE_CARS; loopIndex++) { + tempCar = &gCarList[loopIndex]; + spawn_vehicle_on_road(tempCar); + tempCar->actorIndex = + add_actor_to_empty_slot(tempCar->position, tempCar->rotation, tempCar->velocity, ACTOR_CAR); + } + break; + } +#else + +#endif +} + +void set_vehicle_pos_pathPoint(TrainCarStuff* trainCar, Path2D* posXZ, u16 pathPoint) { + trainCar->position[0] = (f32) posXZ->x; + trainCar->position[1] = (f32) D_80162EB0; + trainCar->position[2] = (f32) posXZ->z; + trainCar->actorIndex = -1; + trainCar->pathPointIndex = pathPoint; + trainCar->isActive = 0; + trainCar->velocity[0] = 0.0f; + trainCar->velocity[1] = 0.0f; + trainCar->velocity[2] = 0.0f; +} + +/** + * Set pathPoint spawn locations for each rolling stock + * The railroad has 465 path + */ +void init_vehicles_trains(void) { + u16 pathPointOffset; + TrainCarStuff* ptr1; + Path2D* pos; + s32 i; + s32 j; + + for (i = 0; i < NUM_TRAINS; i++) { + // outputs 160 or 392 depending on the train. + // Wraps the value around to always output a valid pathPoint. + pathPointOffset = (((i * gVehicle2DPathLength) / NUM_TRAINS) + 160) % gVehicle2DPathLength; + + // 120.0f is about the maximum usable value + gTrainList[i].speed = 5.0f; + for (j = 0; j < NUM_PASSENGER_CAR_ENTRIES; j++) { + pathPointOffset += 4; + ptr1 = &gTrainList[i].passengerCars[j]; + pos = &gVehicle2DPathPoint[pathPointOffset]; + set_vehicle_pos_pathPoint(ptr1, pos, pathPointOffset); + } + // Smaller offset for the tender + pathPointOffset += 3; + ptr1 = &gTrainList[i].tender; + pos = &gVehicle2DPathPoint[pathPointOffset]; + set_vehicle_pos_pathPoint(ptr1, pos, pathPointOffset); + + pathPointOffset += 4; + ptr1 = &gTrainList[i].locomotive; + pos = &gVehicle2DPathPoint[pathPointOffset]; + set_vehicle_pos_pathPoint(ptr1, pos, pathPointOffset); + + // Only use locomotive unless overwritten below. + gTrainList[i].numCars = LOCOMOTIVE_ONLY; + } + + // Spawn all rolling stock in single player mode. + switch (gScreenModeSelection) { + case SCREEN_MODE_1P: // single player + for (i = 0; i < NUM_TRAINS; i++) { + gTrainList[i].tender.isActive = 1; + + // clang-format off + // Same line required for matching... + for (j = 0; j < NUM_PASSENGER_CAR_ENTRIES; j++) { gTrainList[i].passengerCars[j].isActive = 1; } + // clang-format on + + gTrainList[i].numCars = NUM_TENDERS + NUM_PASSENGER_CAR_ENTRIES; + } + break; + + // Spawn locomotive, tender, and one passenger car in versus 2/3 player mode. + case SCREEN_MODE_2P_SPLITSCREEN_HORIZONTAL: // multiplayer fall-through + case SCREEN_MODE_2P_SPLITSCREEN_VERTICAL: + if (gModeSelection != GRAND_PRIX) { + for (i = 0; i < NUM_TRAINS; i++) { + gTrainList[i].tender.isActive = 1; + gTrainList[i].passengerCars[4].isActive = 1; + gTrainList[i].numCars = NUM_TENDERS + NUM_2P_PASSENGER_CARS; + } + } + break; + } + + gTrainSmokeTimer = 0; +} +/** + * @brief sync the train components vehicle with the actor + * + * @param trainCar + * @param orientationY + */ +void sync_train_components(TrainCarStuff* trainCar, s16 orientationY) { + struct TrainCar* trainCarActor; + + trainCarActor = (struct TrainCar*) &gActorList[trainCar->actorIndex]; + trainCarActor->pos[0] = trainCar->position[0]; + trainCarActor->pos[1] = trainCar->position[1]; + trainCarActor->pos[2] = trainCar->position[2]; + if (gIsMirrorMode != 0) { + trainCarActor->rot[1] = -orientationY; + } else { + trainCarActor->rot[1] = orientationY; + } + trainCarActor->velocity[0] = trainCar->velocity[0]; + trainCarActor->velocity[2] = trainCar->velocity[2]; +} + +void update_vehicle_trains(void) { + UNUSED s32 pad[3]; + f32 temp_f20; + TrainCarStuff* car; + u16 oldPathPointIndex; + s16 orientationYUpdate; + f32 temp_f22; + s32 i; + s32 j; + Vec3f smokePos; + + gTrainSmokeTimer += 1; + + for (i = 0; i < NUM_TRAINS; i++) { + oldPathPointIndex = (u16) gTrainList[i].locomotive.pathPointIndex; + + temp_f20 = gTrainList[i].locomotive.position[0]; + temp_f22 = gTrainList[i].locomotive.position[2]; + + orientationYUpdate = update_vehicle_following_path( + gTrainList[i].locomotive.position, (s16*) &gTrainList[i].locomotive.pathPointIndex, gTrainList[i].speed); + + gTrainList[i].locomotive.velocity[0] = gTrainList[i].locomotive.position[0] - temp_f20; + gTrainList[i].locomotive.velocity[2] = gTrainList[i].locomotive.position[2] - temp_f22; + + sync_train_components(&gTrainList[i].locomotive, orientationYUpdate); + + if ((oldPathPointIndex != gTrainList[i].locomotive.pathPointIndex) && + ((gTrainList[i].locomotive.pathPointIndex == 0x00BE) || + (gTrainList[i].locomotive.pathPointIndex == 0x0140))) { // play crossing bell sound + func_800C98B8(gTrainList[i].locomotive.position, gTrainList[i].locomotive.velocity, + SOUND_ARG_LOAD(0x19, 0x01, 0x80, 0x0E)); + } else if (random_int(100) == 0) { // play train whistle sound + func_800C98B8(gTrainList[i].locomotive.position, gTrainList[i].locomotive.velocity, + SOUND_ARG_LOAD(0x19, 0x01, 0x80, 0x0D)); + } + + gTrainList[i].someFlags = set_vehicle_render_distance_flags( + gTrainList[i].locomotive.position, TRAIN_SMOKE_RENDER_DISTANCE, gTrainList[i].someFlags); + // Renders locomotive smoke on all screens if any player is within range. + if ((((s16) gTrainSmokeTimer % 5) == 0) && (gTrainList[i].someFlags != 0)) { + smokePos[0] = gTrainList[i].locomotive.position[0]; + smokePos[1] = (f32) ((f64) gTrainList[i].locomotive.position[1] + 65.0); + smokePos[2] = (f32) ((f64) gTrainList[i].locomotive.position[2] + 25.0); + adjust_position_by_angle(smokePos, gTrainList[i].locomotive.position, orientationYUpdate); + spawn_train_smoke(i, smokePos, 1.1f); + } + + car = &gTrainList[i].tender; + + if (car->isActive == 1) { + temp_f20 = car->position[0]; + temp_f22 = car->position[2]; + orientationYUpdate = + update_vehicle_following_path(car->position, (s16*) &car->pathPointIndex, gTrainList[i].speed); + car->velocity[0] = car->position[0] - temp_f20; + car->velocity[2] = car->position[2] - temp_f22; + sync_train_components(car, orientationYUpdate); + } + + for (j = 0; j < NUM_PASSENGER_CAR_ENTRIES; j++) { + car = &gTrainList[i].passengerCars[j]; + if (car->isActive == 1) { + temp_f20 = car->position[0]; + temp_f22 = car->position[2]; + + orientationYUpdate = + update_vehicle_following_path(car->position, (s16*) &car->pathPointIndex, gTrainList[i].speed); + car->velocity[0] = car->position[0] - temp_f20; + car->velocity[2] = car->position[2] - temp_f22; + sync_train_components(car, orientationYUpdate); + } + } + } +} + +void handle_trains_interactions(s32 playerId, Player* player) { + TrainCarStuff* trainCar; + f32 playerPosX; + f32 playerPosZ; + f32 x_dist; + f32 z_dist; + s32 trainIndex; + s32 passengerCarIndex; + + if (D_801631E0[playerId] != true) { + if (!(player->effects & UNKNOWN_EFFECT_0x1000000)) { + playerPosX = player->pos[0]; + playerPosZ = player->pos[2]; + for (trainIndex = 0; trainIndex < NUM_TRAINS; trainIndex++) { + trainCar = &gTrainList[trainIndex].locomotive; + x_dist = playerPosX - trainCar->position[0]; + z_dist = playerPosZ - trainCar->position[2]; + if ((x_dist > -100.0) && (x_dist < 100.0)) { + if ((z_dist > -100.0) && (z_dist < 100.0)) { + if (is_collide_with_vehicle(trainCar->position[0], trainCar->position[2], trainCar->velocity[0], + trainCar->velocity[2], 60.0f, 20.0f, playerPosX, playerPosZ) == 1) { + player->soundEffects |= REVERSE_SOUND_EFFECT; + } + trainCar = &gTrainList[trainIndex].tender; + if (trainCar->isActive == 1) { + if (is_collide_with_vehicle(trainCar->position[0], trainCar->position[2], + trainCar->velocity[0], trainCar->velocity[2], 30.0f, 20.0f, + playerPosX, playerPosZ) == 1) { + player->soundEffects |= REVERSE_SOUND_EFFECT; + } + } + } + } + + for (passengerCarIndex = 0; passengerCarIndex < NUM_PASSENGER_CAR_ENTRIES; passengerCarIndex++) { + trainCar = &gTrainList[trainIndex].passengerCars[passengerCarIndex]; + x_dist = playerPosX - trainCar->position[0]; + z_dist = playerPosZ - trainCar->position[2]; + if (trainCar->isActive == 1) { + if ((x_dist > -100.0) && (x_dist < 100.0)) { + if ((z_dist > -100.0) && (z_dist < 100.0)) { + if (is_collide_with_vehicle(trainCar->position[0], trainCar->position[2], + trainCar->velocity[0], trainCar->velocity[2], 30.0f, 20.0f, + playerPosX, playerPosZ) == 1) { + player->soundEffects |= REVERSE_SOUND_EFFECT; + } + } + } + } + } + } + } + } +} + +/** + * Appears to check if the train is close to the crossing. + * Implements sCrossingActiveTimer as a counter + */ +void func_80013054(void) { + f32 temp_f16; + f32 temp_f18; + f32 temp_f12; + s32 i; + isCrossingTriggeredByIndex[0] = 0; + isCrossingTriggeredByIndex[1] = 0; + + for (i = 0; i < NUM_TRAINS; i++) { + temp_f16 = gTrainList[i].locomotive.pathPointIndex / ((f32) gVehicle2DPathLength); + temp_f18 = 0.72017354f; + temp_f12 = 0.42299348f; + + if (((temp_f12 - 0.1) < temp_f16) && + (temp_f16 < ((((f64) gTrainList[i].numCars) * 0.01) + (temp_f12 + 0.01)))) { + + isCrossingTriggeredByIndex[0] = 1; + } + if (((temp_f18 - 0.1) < temp_f16) && + (temp_f16 < ((((f64) gTrainList[i].numCars) * 0.01) + (temp_f18 + 0.01)))) { + + isCrossingTriggeredByIndex[1] = 1; + } + } + + for (i = 0; i < NUM_CROSSINGS; i++) { + if (isCrossingTriggeredByIndex[i] == 1) { + sCrossingActiveTimer[i] += 1; + } else { + sCrossingActiveTimer[i] = 0; + } + } +} + +void check_ai_crossing_distance(s32 playerId) { + bStopAICrossing[playerId] = 0; + if (gCurrentCourseId == COURSE_KALAMARI_DESERT) { + if ((!(D_801631E0[playerId] != false)) || + (set_vehicle_render_distance_flags(gPlayers[playerId].pos, TRAIN_CROSSING_AI_DISTANCE, 0))) { + + if ((isCrossingTriggeredByIndex[1] == 1) && ((sCrossingActiveTimer[1]) > FRAMES_SINCE_CROSSING_ACTIVATED)) { + + if ((sSomeNearestPathPoint > 176) && (sSomeNearestPathPoint < 182)) { + bStopAICrossing[playerId] = 1; + } + } + if ((isCrossingTriggeredByIndex[0] == 1) && ((sCrossingActiveTimer[0]) > FRAMES_SINCE_CROSSING_ACTIVATED)) { + if ((sSomeNearestPathPoint >= 306) && (sSomeNearestPathPoint < 310)) { + bStopAICrossing[playerId] = 1; + } + } + } + } +} + +void init_vehicles_ferry(void) { + PaddleBoatStuff* paddleBoat; + s32 i; + Path2D* temp_a2; + u16 temp; + for (i = 0; i < NUM_ACTIVE_PADDLE_BOATS; i++) { + temp = i * 0xB4; + paddleBoat = &gPaddleBoats[i]; + temp_a2 = &gVehicle2DPathPoint[temp]; + paddleBoat->position[0] = temp_a2->x; + paddleBoat->position[1] = D_80162EB2; + paddleBoat->position[2] = temp_a2->z; + paddleBoat->pathPointIndex = i * 0xB4; + paddleBoat->actorIndex = -1; + + if (gPlayerCount >= 3) { + paddleBoat->isActive = 0; + } else { + paddleBoat->isActive = 1; + } + paddleBoat->velocity[0] = 0.0f; + paddleBoat->velocity[1] = 0.0f; + paddleBoat->velocity[2] = 0.0f; + paddleBoat->speed = 1.6666666f; + paddleBoat->rotY = 0; + } + gFerrySmokeTimer = 0; +} + +void update_vehicle_paddle_boats(void) { + PaddleBoatStuff* paddleBoat; + Path2D* pathPoint; + s32 i; + struct Actor* paddleBoatActor; + f32 temp_f26; + f32 temp_f28; + f32 temp_f30; + s16 temp_a1; + s32 temp; + s16 var_v1; + Vec3f sp94; + Vec3f sp88; + UNUSED s32 pad; + Vec3f smokePos; + UNUSED s32 pad2; + gFerrySmokeTimer += 1; + for (i = 0; i < NUM_ACTIVE_PADDLE_BOATS; i++) { + paddleBoat = &gPaddleBoats[i]; + if (paddleBoat->isActive == 1) { + temp_f26 = paddleBoat->position[0]; + temp_f28 = paddleBoat->position[1]; + temp_f30 = paddleBoat->position[2]; + update_vehicle_following_path(paddleBoat->position, (s16*) &paddleBoat->pathPointIndex, paddleBoat->speed); + paddleBoat->someFlags = set_vehicle_render_distance_flags(paddleBoat->position, BOAT_SMOKE_RENDER_DISTANCE, + paddleBoat->someFlags); + if ((((s16) gFerrySmokeTimer % 10) == 0) && (paddleBoat->someFlags != 0)) { + smokePos[0] = (f32) ((f64) paddleBoat->position[0] - 30.0); + smokePos[1] = (f32) ((f64) paddleBoat->position[1] + 180.0); + smokePos[2] = (f32) ((f64) paddleBoat->position[2] + 45.0); + adjust_position_by_angle(smokePos, paddleBoat->position, paddleBoat->rotY); + spawn_ferry_smoke(i, smokePos, 1.1f); + smokePos[0] = (f32) ((f64) paddleBoat->position[0] + 30.0); + smokePos[1] = (f32) ((f64) paddleBoat->position[1] + 180.0); + smokePos[2] = (f32) ((f64) paddleBoat->position[2] + 45.0); + adjust_position_by_angle(smokePos, paddleBoat->position, paddleBoat->rotY); + spawn_ferry_smoke(i, smokePos, 1.1f); + } + if (random_int(100) == 0) { + if (random_int(2) == 0) { + func_800C98B8(paddleBoat->position, paddleBoat->velocity, SOUND_ARG_LOAD(0x19, 0x01, 0x80, 0x47)); + } else { + func_800C98B8(paddleBoat->position, paddleBoat->velocity, SOUND_ARG_LOAD(0x19, 0x01, 0x80, 0x48)); + } + } + sp94[0] = temp_f26; + sp94[1] = temp_f28; + sp94[2] = temp_f30; + pathPoint = &gVehicle2DPathPoint[(paddleBoat->pathPointIndex + 5) % gVehicle2DPathLength]; + sp88[0] = (f32) pathPoint->x; + sp88[1] = (f32) D_80162EB0; + sp88[2] = (f32) pathPoint->z; + temp_a1 = get_angle_between_path(sp94, sp88); + temp = temp_a1 - paddleBoat->rotY; + var_v1 = temp; + if (var_v1 < 0) { + var_v1 = -var_v1; + } + if (var_v1 >= 0x1771) { + if (paddleBoat->speed > 0.2) { + paddleBoat->speed -= 0.04; + } + if (var_v1 >= 0x3D) { + var_v1 = 0x003C; + } + } else { + if (paddleBoat->speed < 2.0) { + paddleBoat->speed += 0.02; + } + if (var_v1 >= 0x1F) { + var_v1 = 0x001E; + } + } + if (temp >= 0x8000) { + paddleBoat->rotY -= var_v1; + } else if (temp > 0) { + paddleBoat->rotY += var_v1; + } else if (temp < -0x7FFF) { + paddleBoat->rotY += var_v1; + } else if (temp < 0) { + paddleBoat->rotY -= var_v1; + } + paddleBoat->velocity[0] = paddleBoat->position[0] - temp_f26; + paddleBoat->velocity[1] = paddleBoat->position[1] - temp_f28; + paddleBoat->velocity[2] = paddleBoat->position[2] - temp_f30; + paddleBoatActor = &gActorList[paddleBoat->actorIndex]; + paddleBoatActor->pos[0] = paddleBoat->position[0]; + paddleBoatActor->pos[1] = paddleBoat->position[1]; + paddleBoatActor->pos[2] = paddleBoat->position[2]; + if (gIsMirrorMode != 0) { + paddleBoatActor->rot[1] = -paddleBoat->rotY; + } else { + paddleBoatActor->rot[1] = paddleBoat->rotY; + } + paddleBoatActor->velocity[0] = paddleBoat->velocity[0]; + paddleBoatActor->velocity[1] = paddleBoat->velocity[1]; + paddleBoatActor->velocity[2] = paddleBoat->velocity[2]; + } + } +} + +void handle_paddleBoats_interactions(Player* player) { + s32 someIndex; + PaddleBoatStuff* tempPaddleWheelBoat; + f32 x_diff; + f32 y_diff; + f32 z_diff; + f32 playerX; + f32 playerZ; + f32 playerY; + + if (!((player->effects & UNKNOWN_EFFECT_0x1000000)) && (!(player->effects & HIT_BY_ITEM_EFFECT))) { + playerX = player->pos[0]; + playerY = player->pos[1]; + playerZ = player->pos[2]; + for (someIndex = 0; someIndex < NUM_ACTIVE_PADDLE_BOATS; someIndex++) { + tempPaddleWheelBoat = &gPaddleBoats[someIndex]; + if (tempPaddleWheelBoat->isActive == 1) { + x_diff = playerX - tempPaddleWheelBoat->position[0]; + y_diff = playerY - tempPaddleWheelBoat->position[1]; + z_diff = playerZ - tempPaddleWheelBoat->position[2]; + if ((x_diff > -300.0) && (x_diff < 300.0)) { + if ((z_diff > -300.0) && (z_diff < 300.0)) { + if ((is_collide_with_vehicle(tempPaddleWheelBoat->position[0], tempPaddleWheelBoat->position[2], + tempPaddleWheelBoat->velocity[0], tempPaddleWheelBoat->velocity[2], + 200.0f, 60.0f, playerX, playerZ) == 1) && + (y_diff < 60.0)) { + player->soundEffects |= 0x80000; + } + } + } + } + } + } +} + +void initialize_toads_turnpike_vehicle(f32 speedA, f32 speedB, s32 numVehicles, s32 arg3, VehicleStuff* vehicleList, + TrackPathPoint* pathPointList) { + VehicleStuff* veh; + TrackPathPoint* temp_v0; + s32 i; + u16 pathPointOffset; + s32 numPathPoints = gPathCountByPathIndex[0]; + for (i = 0; i < numVehicles; i++) { + pathPointOffset = (((i * numPathPoints) / numVehicles) + arg3) % numPathPoints; + veh = &vehicleList[i]; + temp_v0 = &pathPointList[pathPointOffset]; + veh->position[0] = (f32) temp_v0->posX; + veh->position[1] = (f32) temp_v0->posY; + veh->position[2] = (f32) temp_v0->posZ; + veh->actorIndex = -1; + veh->pathPointIndex = pathPointOffset; + veh->unused = 0; + veh->velocity[0] = 0.0f; + veh->velocity[1] = 0.0f; + veh->velocity[2] = 0.0f; + veh->someFlags = 0; + veh->someFlagsTheSequel = 0; + if (gModeSelection == TIME_TRIALS) { + veh->someType = (i % 3); + } else { + veh->someType = random_int(3); + } + veh->someMultiplierTheSequel = (f32) ((f64) (f32) (veh->someType - 1) * 0.6); + if (((gCCSelection > CC_50) || (gModeSelection == TIME_TRIALS)) && (veh->someType == 2)) { + veh->speed = speedA; + } else { + veh->speed = speedB; + } + veh->rotation[0] = 0; + veh->rotation[2] = 0; + if (gIsInExtra == false) { + veh->rotation[1] = func_8000D6D0(veh->position, (s16*) &veh->pathPointIndex, veh->speed, + veh->someMultiplierTheSequel, 0, 3); + } else { + veh->rotation[1] = + func_8000D940(veh->position, (s16*) &veh->pathPointIndex, veh->speed, veh->someMultiplierTheSequel, 0); + } + } + sVehicleSoundRenderCounter = 10; +} + +f32 func_80013C74(s16 someType, s16 pathPointIndex) { + f32 var_f2; + + var_f2 = 0.0f; + if (pathPointIndex < 0x28A) { + switch (someType) { + case 0: + var_f2 = -0.7f; + break; + case 1: + break; + case 2: + var_f2 = 0.7f; + break; + default: + break; + } + } else { + switch (someType) { + case 0: + case 1: + var_f2 = -0.5f; + break; + case 2: + var_f2 = 0.5f; + break; + default: + break; + } + } + return var_f2; +} + +void update_vehicle_follow_pathPoint(VehicleStuff* vehicle) { + f32 temp_f0_2; + f32 temp_f0_3; + f32 sp5C; + f32 sp58; + f32 sp54; + f32 temp_f2_2; + s16 var_a1; + s16 thing; + Vec3f sp40; + Vec3f sp34; + struct Actor* vehicleActor; + + sp5C = vehicle->position[0]; + sp58 = vehicle->position[1]; + sp54 = vehicle->position[2]; + sp40[0] = sp58; + sp40[1] = 0.0f; + sp40[2] = 0.0f; + temp_f0_2 = func_80013C74(vehicle->someType, vehicle->pathPointIndex); + if (vehicle->someMultiplierTheSequel < temp_f0_2) { + vehicle->someMultiplierTheSequel = vehicle->someMultiplierTheSequel + 0.06; + if (temp_f0_2 < vehicle->someMultiplierTheSequel) { + vehicle->someMultiplierTheSequel = temp_f0_2; + } + } + if (temp_f0_2 < vehicle->someMultiplierTheSequel) { + vehicle->someMultiplierTheSequel = vehicle->someMultiplierTheSequel - 0.06; + if (vehicle->someMultiplierTheSequel < temp_f0_2) { + vehicle->someMultiplierTheSequel = temp_f0_2; + } + } + if (gIsInExtra == false) { + var_a1 = func_8000D6D0(vehicle->position, (s16*) &vehicle->pathPointIndex, vehicle->speed, + vehicle->someMultiplierTheSequel, 0, 3); + } else { + var_a1 = func_8000D940(vehicle->position, (s16*) &vehicle->pathPointIndex, vehicle->speed, + vehicle->someMultiplierTheSequel, 0); + } + adjust_angle(&vehicle->rotation[1], var_a1, 100); + temp_f0_3 = vehicle->position[0] - sp5C; + temp_f2_2 = vehicle->position[2] - sp54; + sp34[0] = vehicle->position[1]; + sp34[1] = 0.0f; + sp34[2] = sqrtf((temp_f0_3 * temp_f0_3) + (temp_f2_2 * temp_f2_2)); + thing = get_angle_between_two_vectors(sp40, sp34); + adjust_angle(&vehicle->rotation[0], -thing, 100); + vehicle->velocity[0] = vehicle->position[0] - sp5C; + vehicle->velocity[1] = vehicle->position[1] - sp58; + vehicle->velocity[2] = vehicle->position[2] - sp54; + vehicleActor = &gActorList[vehicle->actorIndex]; + vehicleActor->pos[0] = vehicle->position[0]; + vehicleActor->pos[1] = vehicle->position[1]; + vehicleActor->pos[2] = vehicle->position[2]; + vehicleActor->rot[0] = vehicle->rotation[0]; + if (gIsMirrorMode != 0) { + vehicleActor->rot[1] = -vehicle->rotation[1]; + } else { + vehicleActor->rot[1] = vehicle->rotation[1]; + } + vehicleActor->rot[2] = vehicle->rotation[2]; + vehicleActor->velocity[0] = vehicle->velocity[0]; + vehicleActor->velocity[1] = vehicle->velocity[1]; + vehicleActor->velocity[2] = vehicle->velocity[2]; +} + +void handle_vehicle_interactions(s32 playerId, Player* player, VehicleStuff* vehicle, f32 distanceX, f32 distanceY, + s32 vehicleCount, u32 soundBits) { + f32 deltaX; + f32 deltaZ; + f32 deltaY; + + s32 i; + + f32 playerX; + f32 playerY; + f32 playerZ; + + if (((D_801631E0[playerId] != true) || ((((player->type & PLAYER_HUMAN) != 0)) && !(player->type & PLAYER_CPU))) && + !(player->effects & UNKNOWN_EFFECT_0x1000000)) { + + playerX = player->pos[0]; + playerY = player->pos[1]; + playerZ = player->pos[2]; + + for (i = 0; i < vehicleCount; i++) { + deltaX = playerX - vehicle->position[0]; + deltaY = playerY - vehicle->position[1]; + deltaZ = playerZ - vehicle->position[2]; + + if (((deltaX) > -100.0) && ((deltaX) < 100.0)) { + if ((deltaY > -20.0) && (deltaY < 20.0)) { + if (((deltaZ) > -100.0) && ((deltaZ) < 100.0)) { + if (is_collide_with_vehicle(vehicle->position[0], vehicle->position[2], vehicle->velocity[0], + vehicle->velocity[2], distanceX, distanceY, playerX, + playerZ) == (s32) 1) { + player->soundEffects |= REVERSE_SOUND_EFFECT; + } + } + } + } + + // Human player specific interactions + if ((player->type & PLAYER_HUMAN) && !(player->type & PLAYER_CPU)) { + if (((deltaX) > -300.0) && ((deltaX) < 300.0) && ((deltaY > -20.0)) && (deltaY < 20.0) && + (((deltaZ) > -300.0)) && ((deltaZ) < 300.0)) { + if ((sVehicleSoundRenderCounter > 0) && (vehicle->someFlags == 0)) { + sVehicleSoundRenderCounter--; + vehicle->someFlags |= (RENDER_VEHICLE << playerId); + func_800C9D80(vehicle->position, vehicle->velocity, soundBits); + } + } else { + if (vehicle->someFlags != 0) { + vehicle->someFlags &= ~(RENDER_VEHICLE << playerId); + if (vehicle->someFlags == 0) { + sVehicleSoundRenderCounter++; + func_800C9EF4(vehicle->position, soundBits); + } + } + } + + if (((deltaX) > -200.0) && ((deltaX) < 200.0) && ((deltaY > -20.0)) && (deltaY < 20.0) && + (((deltaZ) > -200.0)) && ((deltaZ) < 200.0)) { + if (!(vehicle->someFlagsTheSequel & ((1 << playerId)))) { + + bool shouldInteract = false; + u16 path = gPathCountByPathIndex[0]; + s32 t1; + s32 t2; + + switch (gIsInExtra) { + case false: + t1 = is_path_point_in_range(vehicle->pathPointIndex, + gNearestPathPointByPlayerId[playerId], 10, 0, path); + if ((gIsPlayerWrongDirection[playerId] == 0) && (t1 > 0) && + (player->speed < vehicle->speed)) { + shouldInteract = true; + } + if ((gIsPlayerWrongDirection[playerId] == 1) && (t1 > 0)) { + shouldInteract = true; + } + break; + case true: + t2 = is_path_point_in_range(vehicle->pathPointIndex, + gNearestPathPointByPlayerId[playerId], 0, 10, path); + if (t2 > 0) { + if (random_int(2) == 0) { + // temp_v1_2 = gIsPlayerWrongDirection[playerId]; + if (gIsPlayerWrongDirection[playerId] == 0) { + shouldInteract = true; + } + if ((gIsPlayerWrongDirection[playerId] == 1) && + (player->speed < vehicle->speed)) { + shouldInteract = true; + } + } else { + vehicle->someFlagsTheSequel |= ((1 << playerId)); + } + } + break; + } + if (shouldInteract == true) { + + u32 soundBits2 = SOUND_ARG_LOAD(0x19, 0x01, 0x70, 0x3B); + + switch (soundBits) { + case SOUND_ARG_LOAD(0x51, 0x01, 0x80, 0x05): + soundBits2 = SOUND_ARG_LOAD(0x19, 0x01, 0x70, 0x3B); + if (random_int(4) == 0) { + soundBits2 = SOUND_ARG_LOAD(0x19, 0x01, 0x70, 0x3C); + } + break; + case SOUND_ARG_LOAD(0x51, 0x01, 0x80, 0x02): + if (random_int(2) != 0) { + soundBits2 = SOUND_ARG_LOAD(0x19, 0x01, 0x70, 0x3D); + } else { + soundBits2 = SOUND_ARG_LOAD(0x19, 0x01, 0x70, 0x3E); + } + break; + case SOUND_ARG_LOAD(0x51, 0x01, 0x80, 0x03): + if (random_int(2) != 0) { + soundBits2 = SOUND_ARG_LOAD(0x19, 0x01, 0x70, 0x3F); + } else { + soundBits2 = SOUND_ARG_LOAD(0x19, 0x01, 0x70, 0x40); + } + break; + case SOUND_ARG_LOAD(0x51, 0x01, 0x80, 0x04): + if (random_int(2) != 0) { + soundBits2 = SOUND_ARG_LOAD(0x19, 0x01, 0x70, 0x41); + } else { + soundBits2 = SOUND_ARG_LOAD(0x19, 0x01, 0x70, 0x42); + } + break; + } + vehicle->someFlagsTheSequel |= ((1 << playerId)); + func_800C98B8(vehicle->position, vehicle->velocity, soundBits2); + } + } + } else { + if (vehicle->someFlagsTheSequel & ((1 << playerId))) { + vehicle->someFlagsTheSequel &= ~((1 << playerId)); + } + } + } + vehicle++; + } + } +} + +f32 player_track_position_factor_vehicle(s16 someType, f32 arg1, s16 pathIndex) { + if (pathIndex < 0x28A) { + switch (someType) { + case 0: + if (arg1 < 0.0) { + arg1 = 0.0f; + } + break; + case 1: + if (arg1 < 0.0) { + arg1 = -0.8f; + } else { + arg1 = 0.8f; + } + break; + case 2: + if (arg1 >= 0.0) { + arg1 = 0.0f; + } + break; + default: + break; + } + } else { + switch (someType) { + case 0: + case 1: + arg1 = 0.5f; + break; + case 2: + arg1 = -0.5f; + break; + default: + break; + } + } + return arg1; +} + +void update_player_track_position_factor_from_vehicle(s32 playerId, s32 vehicleCount, VehicleStuff* vehicle) { + UNUSED s32 var_v1; + s32 pathPointOffset; + s32 var_s2; + s32 pathPointCount; + u16 vehiclePathPoint; + UNUSED VehicleStuff* tempVehicle; + + pathPointCount = gPathCountByPathIndex[0]; + if (!(gPlayers[playerId].speed < 1.6666666666666667)) { + for (var_s2 = 0; var_s2 < vehicleCount; var_s2++, vehicle++) { + vehiclePathPoint = vehicle->pathPointIndex; + for (pathPointOffset = 0; pathPointOffset < 0x18; pathPointOffset += 3) { + if (((sSomeNearestPathPoint + pathPointOffset) % pathPointCount) == vehiclePathPoint) { + gPlayerTrackPositionFactorInstruction[playerId].target = player_track_position_factor_vehicle( + vehicle->someType, gTrackPositionFactor[playerId], vehiclePathPoint); + return; + } + } + } + } +} + +void init_vehicles_box_trucks(void) { + f32 a = ((gCCSelection * 90.0) / 216.0f) + 4.583333333333333; + f32 b = ((gCCSelection * 90.0) / 216.0f) + 2.9166666666666665; + s32 numTrucks = NUM_RACE_BOX_TRUCKS; + if (gModeSelection == TIME_TRIALS) { + numTrucks = NUM_TIME_TRIAL_BOX_TRUCKS; + } + initialize_toads_turnpike_vehicle(a, b, numTrucks, 0, gBoxTruckList, &gTrackPaths[0][0]); +} + +void update_vehicle_box_trucks(void) { + s32 loopIndex; + for (loopIndex = 0; loopIndex < NUM_RACE_BOX_TRUCKS; loopIndex++) { + update_vehicle_follow_pathPoint(&gBoxTruckList[loopIndex]); + } +} + +void handle_box_trucks_interactions(s32 playerId, Player* player) { + handle_vehicle_interactions(playerId, player, gBoxTruckList, 55.0f, 12.5f, NUM_RACE_BOX_TRUCKS, + SOUND_ARG_LOAD(0x51, 0x01, 0x80, 0x03)); +} + +void update_player_track_position_factor_from_box_trucks(s32 playerId) { + update_player_track_position_factor_from_vehicle(playerId, NUM_RACE_BOX_TRUCKS, gBoxTruckList); +} + +void init_vehicles_school_buses(void) { + s32 numBusses; + f32 a = ((gCCSelection * 90.0) / 216.0f) + 4.583333333333333; + f32 b = ((gCCSelection * 90.0) / 216.0f) + 2.9166666666666665; + + numBusses = NUM_RACE_SCHOOL_BUSES; + if (gModeSelection == TIME_TRIALS) { + numBusses = NUM_TIME_TRIAL_SCHOOL_BUSES; + } + initialize_toads_turnpike_vehicle(a, b, numBusses, 75, gSchoolBusList, &gTrackPaths[0][0]); +} + +void update_vehicle_school_bus(void) { + s32 loopIndex; + for (loopIndex = 0; loopIndex < NUM_RACE_SCHOOL_BUSES; loopIndex++) { + update_vehicle_follow_pathPoint(&gSchoolBusList[loopIndex]); + } +} + +void handle_school_buses_interactions(s32 playerId, Player* player) { + handle_vehicle_interactions(playerId, player, gSchoolBusList, 70.0f, 12.5f, NUM_RACE_SCHOOL_BUSES, + SOUND_ARG_LOAD(0x51, 0x01, 0x80, 0x02)); +} + +void update_player_track_position_factor_from_buses(s32 playerId) { + update_player_track_position_factor_from_vehicle(playerId, NUM_RACE_SCHOOL_BUSES, gSchoolBusList); +} + +void init_vehicles_trucks(void) { + s32 numTrucks; + f32 a = ((gCCSelection * 90.0) / 216.0f) + 4.583333333333333; + f32 b = ((gCCSelection * 90.0) / 216.0f) + 2.9166666666666665; + + numTrucks = NUM_RACE_TANKER_TRUCKS; + if (gModeSelection == TIME_TRIALS) { + numTrucks = NUM_TIME_TRIAL_TANKER_TRUCKS; + } + initialize_toads_turnpike_vehicle(a, b, numTrucks, 50, gTankerTruckList, &gTrackPaths[0][0]); +} + +void update_vehicle_tanker_trucks(void) { + s32 loopIndex; + for (loopIndex = 0; loopIndex < NUM_RACE_TANKER_TRUCKS; loopIndex++) { + update_vehicle_follow_pathPoint(&gTankerTruckList[loopIndex]); + } +} + +void handle_tanker_trucks_interactions(s32 playerId, Player* player) { + handle_vehicle_interactions(playerId, player, gTankerTruckList, 55.0f, 12.5f, NUM_RACE_TANKER_TRUCKS, + SOUND_ARG_LOAD(0x51, 0x01, 0x80, 0x04)); +} + +void update_player_track_position_factor_from_tanker_truck(s32 playerId) { + update_player_track_position_factor_from_vehicle(playerId, NUM_RACE_TANKER_TRUCKS, gTankerTruckList); +} + +void init_vehicles_cars(void) { + s32 numCars; + f32 a = ((gCCSelection * 90.0) / 216.0f) + 4.583333333333333; + f32 b = ((gCCSelection * 90.0) / 216.0f) + 2.9166666666666665; + + numCars = NUM_RACE_CARS; + if (gModeSelection == TIME_TRIALS) { + numCars = NUM_TIME_TRIAL_CARS; + } + initialize_toads_turnpike_vehicle(a, b, numCars, 25, gCarList, &gTrackPaths[0][0]); +} + +void update_vehicle_cars(void) { + s32 loopIndex; + for (loopIndex = 0; loopIndex < NUM_RACE_CARS; loopIndex++) { + update_vehicle_follow_pathPoint(&gCarList[loopIndex]); + } +} + +void handle_cars_interactions(s32 playerId, Player* player) { + handle_vehicle_interactions(playerId, player, gCarList, 11.5f, 8.5f, NUM_RACE_CARS, + SOUND_ARG_LOAD(0x51, 0x01, 0x80, 0x05)); +} + +void update_player_track_position_factor_from_cars(s32 playerId) { + update_player_track_position_factor_from_vehicle(playerId, NUM_RACE_CARS, gCarList); +} diff --git a/src/data/path_spawn_metadata.c b/src/data/path_spawn_metadata.c index eccb145d77..375a283bb5 100644 --- a/src/data/path_spawn_metadata.c +++ b/src/data/path_spawn_metadata.c @@ -4,38 +4,38 @@ #if !ENABLE_CUSTOM_COURSE_ENGINE // @warning Array contains an extra zero element at the end. -KartAIBehaviour* gKartAIBehaviourLUT[] = { -#include "assets/course_metadata/gKartAIBehaviourLUT.inc.c" +CPUBehaviour* cpu_BehaviourLUT[] = { +#include "assets/course_metadata/cpu_BehaviourLUT.inc.c" }; #else #endif -TrackWaypoint nullPath = { 0x8000, 0x0000, 0x0000, 0x0000 }; +TrackPathPoint nullPath = { 0x8000, 0x0000, 0x0000, 0x0000 }; #if !ENABLE_CUSTOM_COURSE_ENGINE -TrackWaypoint* gCoursePathTable[][4] = { +TrackPathPoint* gCoursePathTable[][4] = { #include "assets/course_metadata/gCoursePathTableUnknown.inc.c" }; -TrackWaypoint* gCoursePathTable2[][4] = { +TrackPathPoint* gCoursePathTable2[][4] = { #include "assets/course_metadata/gCoursePathTable.inc.c" }; /// @warning Array contains an extra zero element at the end. -s16 gKartAISteeringSensitivity[] = { -#include "assets/course_metadata/gCPUSteeringSensitivity.inc.c" +s16 cpu_SteeringSensitivity[] = { +#include "assets/course_metadata/cpu_SteeringSensitivity.inc.c" }; // Possibly maximum cpu separation -f32 gKartAICourseMaximumSeparation[] = { -#include "assets/course_metadata/gKartAICourseMaximumSeparation.inc.c" +f32 cpu_CourseMaximumSeparation[] = { +#include "assets/course_metadata/cpu_CourseMaximumSeparation.inc.c" }; // Possibly minimum cpu separation -f32 gKartAICourseMinimumSeparation[] = { -#include "assets/course_metadata/gKartAICourseMinimumSeparation.inc.c" +f32 cpu_CourseMinimumSeparation[] = { +#include "assets/course_metadata/cpu_CourseMinimumSeparation.inc.c" }; #else diff --git a/src/data/path_spawn_metadata.h b/src/data/path_spawn_metadata.h index 2dd6834855..e8fa2c2bb6 100644 --- a/src/data/path_spawn_metadata.h +++ b/src/data/path_spawn_metadata.h @@ -1,12 +1,12 @@ #ifndef PATH_SPAWN_METADATA_H #define PATH_SPAWN_METADATA_H -#include "waypoints.h" +#include "path.h" #include #include #include "include/bomb_kart.h" -extern TrackWaypoint nullPath; +extern TrackPathPoint nullPath; extern s16 D_800DCAF4[]; extern s16 D_800DCB34[]; extern BombKartSpawn gBombKartSpawns[][NUM_BOMB_KARTS_MAX]; diff --git a/src/debug/all_variables.h b/src/debug/all_variables.h index 88d9c8fbbf..54ef962476 100644 --- a/src/debug/all_variables.h +++ b/src/debug/all_variables.h @@ -12,7 +12,7 @@ #include #include #include -#include +#include #include #include #include @@ -65,7 +65,7 @@ #include "buffers/trig_tables.h" #include #include -#include +#include #include #include diff --git a/src/effects.c b/src/effects.c index 0bd12bb15b..a57157f343 100644 --- a/src/effects.c +++ b/src/effects.c @@ -7,8 +7,8 @@ #include "code_800029B0.h" #include "math_util.h" #include "kart_attributes.h" -#include "waypoints.h" -#include "code_80005FD0.h" +#include "path.h" +#include "cpu_vehicles_camera_path.h" #include "render_player.h" #include "player_controller.h" #include "render_objects.h" @@ -167,7 +167,7 @@ void clean_effect(Player* player, s8 arg1) { if ((player->effects & 0x800000) == 0x800000) { func_8008D97C(player); } - if ((player->effects & 0x1000000) == 0x1000000) { + if ((player->effects & UNKNOWN_EFFECT_0x1000000) == UNKNOWN_EFFECT_0x1000000) { func_8008E884(player, arg1); } if ((player->effects & HIT_BY_ITEM_EFFECT) == HIT_BY_ITEM_EFFECT) { @@ -182,10 +182,10 @@ void clean_effect(Player* player, s8 arg1) { if ((player->effects & 0x4000) == 0x4000) { func_8008F3E0(player); } - if ((player->effects & 0x10000) == 0x10000) { + if ((player->effects & UNKNOWN_EFFECT_0x10000) == UNKNOWN_EFFECT_0x10000) { func_8008F5A4(player, arg1); } - if ((player->effects & 0x10000000) == 0x10000000) { + if ((player->effects & UNKNOWN_EFFECT_0x10000000) == UNKNOWN_EFFECT_0x10000000) { func_8008FEDC(player, arg1); } player->unk_044 = (s16) (player->unk_044 & 0xFFFE); @@ -214,14 +214,14 @@ void func_8008C528(Player* player, s8 arg1) { func_800C90F4(arg1, (temp_v1 * 0x10) + 0x29008005); func_800C9060(arg1, SOUND_ACTION_EXPLOSION); } else { - func_800098FC(arg1, player); + play_cpu_sound_effect(arg1, player); } player->soundEffects = (s32) (player->soundEffects & ~4); } void func_8008C62C(Player* player, s8 arg1) { - decelerate_ai_player(player, 5.0f); + decelerate_player(player, 5.0f); player->unk_0A8 += (s16) 0xA0; player->unk_042 += (s16) 0x71C; if (player->unk_0A8 >= 0x2000) { @@ -285,7 +285,7 @@ void func_8008C73C(Player* player, s8 arg1) { ((player->type & PLAYER_INVISIBLE_OR_BOMB) != PLAYER_INVISIBLE_OR_BOMB)) { func_800C90F4(arg1, (player->characterId * 0x10) + 0x29008003); } else { - func_800098FC(arg1, player); + play_cpu_sound_effect(arg1, player); } } } @@ -309,7 +309,7 @@ void func_8008C8C4(Player* player, s8 playerId) { if ((gIsPlayerTripleAButtonCombo[playerId] == true) && ((player->type & PLAYER_HUMAN) == PLAYER_HUMAN)) { player->currentSpeed = (f32) (player->currentSpeed + 100.0f); } - if ((gModeSelection == VERSUS) && ((player->type & PLAYER_KART_AI) == PLAYER_KART_AI) && (!gDemoMode) && + if ((gModeSelection == VERSUS) && ((player->type & PLAYER_CPU) == PLAYER_CPU) && (!gDemoMode) && ((player->unk_0CA & 2) == 0) && (gGPCurrentRaceRankByPlayerId[playerId] != 0)) { player->soundEffects = (s32) (player->soundEffects | REVERSE_SOUND_EFFECT); } @@ -323,15 +323,15 @@ void func_8008C9EC(Player* player, s8 arg1) { player->unk_206 = 0; player->slopeAccel = 0; if ((player->unk_046 & 0x40) == 0x40) { - decelerate_ai_player(player, 100.0f); + decelerate_player(player, 100.0f); } else { if ((player->type & PLAYER_HUMAN) == PLAYER_HUMAN) { - decelerate_ai_player(player, 1.0f); + decelerate_player(player, 1.0f); } else { - decelerate_ai_player(player, 4.0f); + decelerate_player(player, 4.0f); } if (!(player->type & PLAYER_HUMAN)) { - decelerate_ai_player(player, 30.0f); + decelerate_player(player, 30.0f); } } if ((player->effects & 0x80) == 0x80) { @@ -379,8 +379,8 @@ void func_8008CDC0(Player* player, s8 arg1) { player->effects &= ~0x10; if (((player->unk_07C >> 0x10) >= 0x14) || ((player->unk_07C >> 0x10) < -0x13) || - (((player->unk_094 / 18.0f) * 216.0f) <= 30.0f) || ((player->effects & 8) != 0) || - (((player->type & PLAYER_HUMAN) == 0) && ((player->effects & 0x1000) == 0))) { + (((player->speed / 18.0f) * 216.0f) <= 30.0f) || ((player->effects & 8) != 0) || + (((player->type & PLAYER_HUMAN) == 0) && ((player->effects & UNKNOWN_EFFECT_0x1000) == 0))) { func_8008C73C(player, arg1); } else { player->effects |= 0x800; @@ -714,7 +714,7 @@ void apply_hit_sound_effect(Player* player, s8 arg1) { player->effects |= HIT_EFFECT; if (((player->type) & 0x1000) != 0) { - func_800098FC(arg1, player); + play_cpu_sound_effect(arg1, player); } } } @@ -727,7 +727,7 @@ void apply_hit_effect(Player* player, s8 arg1) { player->unk_08C = 0.0f; player->currentSpeed = 0.0f; // clang-format off - if ((player->collision.surfaceDistance[2] >= 600.0f) || ((player->effects & 0x1000) != 0)) { D_8018D990[arg1] = 3; } // placed block on same line to match + if ((player->collision.surfaceDistance[2] >= 600.0f) || ((player->effects & UNKNOWN_EFFECT_0x1000) != 0)) { D_8018D990[arg1] = 3; } // placed block on same line to match // clang-format on switch (D_8018D990[arg1]) { @@ -854,7 +854,7 @@ void apply_hit_rotating_sound_effect(Player* player, s8 arg1) { ((player->type & PLAYER_INVISIBLE_OR_BOMB) != PLAYER_INVISIBLE_OR_BOMB)) { func_800C90F4(arg1, (player->characterId * 0x10) + 0x29008003); } else { - func_800098FC(arg1, player); + play_cpu_sound_effect(arg1, player); } if (gModeSelection == BATTLE) { func_8006B8B4(player, arg1); @@ -893,7 +893,7 @@ void apply_lightning_effect(Player* player, s8 arg1) { D_80165190[3][arg1] = 1; } } - decelerate_ai_player(player, 1.0f); + decelerate_player(player, 1.0f); } else { player->unk_0B0 += 1; player->unk_08C = (f32) ((f64) player->unk_08C * 0.6); @@ -949,7 +949,7 @@ void func_8008E4A4(Player* player, s8 arg1) { } if (player->unk_0E0 == 3) { - player->effects &= ~0x01000000; + player->effects &= ~UNKNOWN_EFFECT_0x1000000; player->unk_0A8 = 0; player->unk_236 = 0; D_80165190[0][arg1] = 1; @@ -971,7 +971,7 @@ void func_8008E4A4(Player* player, s8 arg1) { player->unk_0A8 = 0; --player->unk_236; if (player->unk_236 == 0) { - player->effects &= ~0x01000000; + player->effects &= ~UNKNOWN_EFFECT_0x1000000; player->unk_236 = 0; D_80165190[0][arg1] = 1; D_80165190[1][arg1] = 1; @@ -997,7 +997,7 @@ void apply_reverse_sound_effect(Player* player, s8 arg1) { func_8008C310(player); player->unk_0A8 = 0; - player->effects |= 0x01000000; + player->effects |= UNKNOWN_EFFECT_0x1000000; player->effects &= ~0x10; player->kartHopJerk = 0.0f; player->kartHopAcceleration = 0.0f; @@ -1010,19 +1010,19 @@ void apply_reverse_sound_effect(Player* player, s8 arg1) { if (((player->type & PLAYER_HUMAN) == PLAYER_HUMAN) && ((player->type & PLAYER_INVISIBLE_OR_BOMB) != PLAYER_INVISIBLE_OR_BOMB)) { - if (((gModeSelection == VERSUS) && ((player->type & PLAYER_KART_AI) != 0)) && (!gDemoMode)) { + if (((gModeSelection == VERSUS) && ((player->type & PLAYER_CPU) != 0)) && (!gDemoMode)) { func_800CA24C(arg1); } if (1) {} func_800C90F4(arg1, (player->characterId * 0x10) + 0x29008005); - if (((gModeSelection == VERSUS) && ((player->type & PLAYER_KART_AI) != 0)) && (!gDemoMode)) { + if (((gModeSelection == VERSUS) && ((player->type & PLAYER_CPU) != 0)) && (!gDemoMode)) { func_800CA24C(arg1); } func_800C9060(arg1, SOUND_ACTION_EXPLOSION); } else { - func_800098FC(arg1, player); + play_cpu_sound_effect(arg1, player); } player->soundEffects &= ~(REVERSE_SOUND_EFFECT | 0x80000); @@ -1034,7 +1034,7 @@ void apply_reverse_sound_effect(Player* player, s8 arg1) { } void func_8008E884(Player* player, s8 arg1) { - player->effects &= ~0x01000000; + player->effects &= ~UNKNOWN_EFFECT_0x1000000; player->unk_0A8 = 0; player->unk_236 = 0; D_80165190[0][arg1] = 1; @@ -1121,7 +1121,7 @@ void apply_hit_by_item_sound_effect(Player* player, s8 arg1) { func_800C90F4(arg1, (player->characterId * 0x10) + 0x29008005); func_800C9060(arg1, SOUND_ACTION_EXPLOSION); } else { - func_800098FC(arg1, player); + play_cpu_sound_effect(arg1, player); } player->effects |= HIT_BY_ITEM_EFFECT; @@ -1315,7 +1315,7 @@ void func_8008F3F4(Player* player, UNUSED s8 arg1) { player->unk_0A8 = 0; --player->unk_236; if (player->unk_236 == 0) { - player->effects &= ~0x00010000; + player->effects &= ~UNKNOWN_EFFECT_0x10000; func_80090778(player); func_80090868(player); } @@ -1323,8 +1323,9 @@ void func_8008F3F4(Player* player, UNUSED s8 arg1) { } void func_8008F494(Player* player, s8 arg1) { - if ((((player->effects & 0x80) != 0) || ((player->effects & 0x40) != 0) || ((player->effects & 0x01000000)) || - ((player->effects & HIT_BY_ITEM_EFFECT)) || ((player->effects & 0x400) != 0)) && + if ((((player->effects & UNKNOWN_EFFECT_0x80) != 0) || ((player->effects & UNKNOWN_EFFECT_0x40) != 0) || + ((player->effects & UNKNOWN_EFFECT_0x1000000)) || ((player->effects & HIT_BY_ITEM_EFFECT)) || + ((player->effects & 0x400) != 0)) && (gModeSelection == BATTLE)) { player->unk_044 |= 0x8000; } @@ -1333,7 +1334,7 @@ void func_8008F494(Player* player, s8 arg1) { func_8008F86C(player, arg1); player->unk_0A8 = 0; - player->effects |= 0x10000; + player->effects |= UNKNOWN_EFFECT_0x10000; player->effects &= ~0x10; player->unk_236 = 0x1E; player->unk_042 = 0; @@ -1353,7 +1354,7 @@ void func_8008F5A4(Player* player, s8 arg1) { player->unk_206 = 0; player->slopeAccel = 0; - player->effects &= ~0x10000; + player->effects &= ~UNKNOWN_EFFECT_0x10000; player->unk_0A8 = 0; player->unk_0C0 = 0; player->unk_07C = 0; @@ -1569,94 +1570,94 @@ void func_8008FDF4(Player* player, UNUSED s8 arg1) { player->kartHopAcceleration = 0.0f; player->kartHopVelocity = D_800E37D0[player->characterId]; player->soundEffects &= ~0x00100000; - player->effects |= 0x10000000; + player->effects |= UNKNOWN_EFFECT_0x10000000; } void func_8008FE84(Player* player, UNUSED s8 arg1) { player->effects &= ~0x10; if ((player->effects & 8) != 8) { - player->effects &= ~0x10000000; + player->effects &= ~UNKNOWN_EFFECT_0x10000000; player->currentSpeed /= 2; player->unk_08C /= 2; } } void func_8008FEDC(Player* player, UNUSED s8 arg1) { - player->effects &= ~0x10000000; + player->effects &= ~UNKNOWN_EFFECT_0x10000000; player->kartHopJerk = 0.0f; player->kartHopVelocity = 0.0f; player->kartHopAcceleration = 0.0f; } -void course_update_waypoint(Player* player, s8 playerId) { - s16 waypoint; +void course_update_path_point(Player* player, s8 playerId) { + s16 pathPoint; #if !ENABLE_CUSTOM_COURSE_ENGINE switch (gCurrentCourseId) { case COURSE_BOWSER_CASTLE: - waypoint = gNearestWaypointByPlayerId[playerId]; - if ((waypoint >= 0x235) && (waypoint < 0x247)) { - player->nearestWaypointId = 0x214; - } else if ((waypoint >= 0x267) && (waypoint < 0x277)) { - player->nearestWaypointId = 0x25B; + pathPoint = gNearestPathPointByPlayerId[playerId]; + if ((pathPoint >= 0x235) && (pathPoint < 0x247)) { + player->nearestPathPointId = 0x214; + } else if ((pathPoint >= 0x267) && (pathPoint < 0x277)) { + player->nearestPathPointId = 0x25B; } else { - player->nearestWaypointId = gNearestWaypointByPlayerId[playerId]; - if (player->nearestWaypointId < 0) { - player->nearestWaypointId = gWaypointCountByPathIndex[0] + player->nearestWaypointId; + player->nearestPathPointId = gNearestPathPointByPlayerId[playerId]; + if (player->nearestPathPointId < 0) { + player->nearestPathPointId = gPathCountByPathIndex[0] + player->nearestPathPointId; } } break; case COURSE_BANSHEE_BOARDWALK: - waypoint = gNearestWaypointByPlayerId[playerId]; - if ((waypoint >= 0x12C) && (waypoint < 0x13C)) { - player->nearestWaypointId = 0x12CU; + pathPoint = gNearestPathPointByPlayerId[playerId]; + if ((pathPoint >= 0x12C) && (pathPoint < 0x13C)) { + player->nearestPathPointId = 0x12CU; } else { - player->nearestWaypointId = gNearestWaypointByPlayerId[playerId]; - if (player->nearestWaypointId < 0) { - player->nearestWaypointId = gWaypointCountByPathIndex[0] + player->nearestWaypointId; + player->nearestPathPointId = gNearestPathPointByPlayerId[playerId]; + if (player->nearestPathPointId < 0) { + player->nearestPathPointId = gPathCountByPathIndex[0] + player->nearestPathPointId; } } break; case COURSE_YOSHI_VALLEY: case COURSE_RAINBOW_ROAD: - player->nearestWaypointId = gCopyNearestWaypointByPlayerId[playerId]; + player->nearestPathPointId = gCopyNearestPathPointByPlayerId[playerId]; break; case COURSE_FRAPPE_SNOWLAND: - waypoint = gNearestWaypointByPlayerId[playerId]; + pathPoint = gNearestPathPointByPlayerId[playerId]; #ifdef VERSION_EU - if (((waypoint >= 0xF0) && (waypoint < 0x11E)) || ((gCopyNearestWaypointByPlayerId[playerId] >= 0xF0) && - (gCopyNearestWaypointByPlayerId[playerId] < 0x11E))) + if (((pathPoint >= 0xF0) && (pathPoint < 0x11E)) || ((gCopyNearestPathPointByPlayerId[playerId] >= 0xF0) && + (gCopyNearestPathPointByPlayerId[playerId] < 0x11E))) #else - if ((waypoint >= 0xF0) && (waypoint < 0x105)) + if ((pathPoint >= 0xF0) && (pathPoint < 0x105)) #endif { - player->nearestWaypointId = 0xF0U; + player->nearestPathPointId = 0xF0U; } else { - player->nearestWaypointId = gCopyNearestWaypointByPlayerId[playerId]; - if (player->nearestWaypointId < 0) { - player->nearestWaypointId = gWaypointCountByPathIndex[0] + player->nearestWaypointId; + player->nearestPathPointId = gCopyNearestPathPointByPlayerId[playerId]; + if (player->nearestPathPointId < 0) { + player->nearestPathPointId = gPathCountByPathIndex[0] + player->nearestPathPointId; } } break; case COURSE_ROYAL_RACEWAY: - waypoint = gNearestWaypointByPlayerId[playerId]; - if ((waypoint >= 0x258) && (waypoint < 0x2A4)) { - player->nearestWaypointId = 0x258U; + pathPoint = gNearestPathPointByPlayerId[playerId]; + if ((pathPoint >= 0x258) && (pathPoint < 0x2A4)) { + player->nearestPathPointId = 0x258U; } else { - player->nearestWaypointId = gCopyNearestWaypointByPlayerId[playerId]; - if (player->nearestWaypointId < 0) { - player->nearestWaypointId = gWaypointCountByPathIndex[0] + player->nearestWaypointId; + player->nearestPathPointId = gCopyNearestPathPointByPlayerId[playerId]; + if (player->nearestPathPointId < 0) { + player->nearestPathPointId = gPathCountByPathIndex[0] + player->nearestPathPointId; } } break; case COURSE_DK_JUNGLE: - waypoint = gNearestWaypointByPlayerId[playerId]; - if ((waypoint >= 0xB9) && (waypoint < 0x119)) { - player->nearestWaypointId = 0xB9U; + pathPoint = gNearestPathPointByPlayerId[playerId]; + if ((pathPoint >= 0xB9) && (pathPoint < 0x119)) { + player->nearestPathPointId = 0xB9U; } else { - player->nearestWaypointId = gNearestWaypointByPlayerId[playerId]; - if (player->nearestWaypointId < 0) { - player->nearestWaypointId = gWaypointCountByPathIndex[0] + player->nearestWaypointId; + player->nearestPathPointId = gNearestPathPointByPlayerId[playerId]; + if (player->nearestPathPointId < 0) { + player->nearestPathPointId = gPathCountByPathIndex[0] + player->nearestPathPointId; } } break; @@ -1664,12 +1665,12 @@ void course_update_waypoint(Player* player, s8 playerId) { case COURSE_SKYSCRAPER: case COURSE_DOUBLE_DECK: case COURSE_BIG_DONUT: - player->nearestWaypointId = 0U; + player->nearestPathPointId = 0U; break; default: - player->nearestWaypointId = gNearestWaypointByPlayerId[playerId]; - if (player->nearestWaypointId < 0) { - player->nearestWaypointId = gWaypointCountByPathIndex[0] + player->nearestWaypointId; + player->nearestPathPointId = gNearestPathPointByPlayerId[playerId]; + if (player->nearestPathPointId < 0) { + player->nearestPathPointId = gPathCountByPathIndex[0] + player->nearestPathPointId; } break; } @@ -1680,7 +1681,7 @@ void course_update_waypoint(Player* player, s8 playerId) { void func_80090178(Player* player, s8 playerId, Vec3f arg2, Vec3f arg3) { u16 test; - TrackWaypoint* temp_v1; + TrackPathPoint* temp_v1; f32 spF8[4] = { 0.0f, 0.0f, -700.0f, 700.0f }; f32 spE8[4] = { 700.0f, -700.0f, 0.0f, 0.0f }; f32 spD8[4] = { 0.0f, 0.0f, -650.0f, 650.0f }; @@ -1700,14 +1701,14 @@ void func_80090178(Player* player, s8 playerId, Vec3f arg2, Vec3f arg3) { switch (gCurrentCourseId) { case COURSE_YOSHI_VALLEY: - test = player->nearestWaypointId; - temp_v1 = &D_80164550[gCopyPathIndexByPlayerId[playerId]][test]; + test = player->nearestPathPointId; + temp_v1 = &gTrackPaths[gCopyPathIndexByPlayerId[playerId]][test]; arg2[0] = temp_v1->posX; arg2[1] = temp_v1->posY; arg2[2] = temp_v1->posZ; - temp_v1 = &D_80164550[gCopyPathIndexByPlayerId[playerId]] - [(player->nearestWaypointId + 5) % - (gWaypointCountByPathIndex[gCopyPathIndexByPlayerId[playerId]] + 1)]; + temp_v1 = &gTrackPaths[gCopyPathIndexByPlayerId[playerId]] + [(player->nearestPathPointId + 5) % + (gPathCountByPathIndex[gCopyPathIndexByPlayerId[playerId]] + 1)]; arg3[0] = temp_v1->posX; arg3[1] = temp_v1->posY; arg3[2] = temp_v1->posZ; @@ -1745,12 +1746,12 @@ void func_80090178(Player* player, s8 playerId, Vec3f arg2, Vec3f arg3) { arg3[2] = sp08[playerId]; break; default: - test = player->nearestWaypointId; - temp_v1 = &D_80164550[0][test]; + test = player->nearestPathPointId; + temp_v1 = &gTrackPaths[0][test]; arg2[0] = temp_v1->posX; arg2[1] = temp_v1->posY; arg2[2] = temp_v1->posZ; - temp_v1 = &D_80164550[0][(player->nearestWaypointId + 5) % (gWaypointCountByPathIndex[0] + 1)]; + temp_v1 = &gTrackPaths[0][(player->nearestPathPointId + 5) % (gPathCountByPathIndex[0] + 1)]; arg3[0] = temp_v1->posX; arg3[1] = temp_v1->posY; arg3[2] = temp_v1->posZ; @@ -1801,7 +1802,7 @@ void func_80090868(Player* player) { player->unk_D98 = 1; player->unk_D9C = 0.0f; player->unk_DA0 = 0.5f; - course_update_waypoint(player, playerIndex); + course_update_path_point(player, playerIndex); player->unk_222 = 0; player->unk_0CA |= 2; player->unk_0C8 = 0; @@ -1825,7 +1826,7 @@ void func_80090970(Player* player, s8 playerId, s8 arg2) { UNUSED s32 stackPadding1; Vec3f sp44; Vec3f sp38; - TrackWaypoint* waypoint; + TrackPathPoint* pathPoint; UNUSED s32 stackPadding2; UNUSED s32 stackPadding3; @@ -1866,7 +1867,7 @@ void func_80090970(Player* player, s8 playerId, s8 arg2) { } break; case 1: - if (((player->type & PLAYER_HUMAN) == 0x4000) && ((player->type & PLAYER_KART_AI) == 0)) { + if (((player->type & PLAYER_HUMAN) == 0x4000) && ((player->type & PLAYER_CPU) == 0)) { func_8009E088(playerId, 0xA); } if ((player->unk_0CA & 1) == 1) { @@ -1898,7 +1899,7 @@ void func_80090970(Player* player, s8 playerId, s8 arg2) { break; case 3: D_80165330[playerId] = 0; - if (((player->type & PLAYER_HUMAN) == PLAYER_HUMAN) && ((player->type & PLAYER_KART_AI) == 0)) { + if (((player->type & PLAYER_HUMAN) == PLAYER_HUMAN) && ((player->type & PLAYER_CPU) == 0)) { func_8009E020(playerId, 0x14); } func_80090178(player, playerId, sp44, sp38); @@ -1921,10 +1922,10 @@ void func_80090970(Player* player, s8 playerId, s8 arg2) { player->pos[0] = player->pos[0] + sins(-player->rotation[1]) * -10.0f; } if (player->unk_0C8 == 0x00FC) { - waypoint = D_80164550[0]; - player->pos[0] = waypoint->posX; - player->pos[1] = waypoint->posY; - player->pos[2] = waypoint->posZ; + pathPoint = gTrackPaths[0]; + player->pos[0] = pathPoint->posX; + player->pos[1] = pathPoint->posY; + player->pos[2] = pathPoint->posZ; } move_f32_towards(&player->pos[1], (player->unk_074 + player->boundingBoxSize) - 2.0f, 0.04f); player->unk_0C8++; @@ -2080,7 +2081,7 @@ void func_80091298(Player* player, s8 arg1) { player->kartGravity = gKartGravityTable[player->characterId]; player->unk_0D4[0] = 0; player->type |= PLAYER_START_SEQUENCE; - player->unk_094 = 0.0f; + player->speed = 0.0f; player->unk_08C = 0.0f; player->currentSpeed = 0.0f; if (arg1 == 0) { diff --git a/src/effects.h b/src/effects.h index d4cadee2b4..8ade7f3cb0 100644 --- a/src/effects.h +++ b/src/effects.h @@ -106,7 +106,7 @@ void func_8008FDA8(Player*, s8); void func_8008FDF4(Player*, s8); void func_8008FE84(Player*, s8); void func_8008FEDC(Player*, s8); -void course_update_waypoint(Player*, s8); +void course_update_path_point(Player*, s8); void func_80090178(Player*, s8, Vec3f, Vec3f); void func_80090778(Player*); void func_80090868(Player*); diff --git a/src/ending/code_80281780.c b/src/ending/code_80281780.c index 3648169ae5..0f303fa474 100644 --- a/src/ending/code_80281780.c +++ b/src/ending/code_80281780.c @@ -13,7 +13,7 @@ #include "skybox_and_splitscreen.h" #include "code_8006E9C0.h" #include "podium_ceremony_actors.h" -#include "code_80005FD0.h" +#include "cpu_vehicles_camera_path.h" #include "collision.h" #include "code_80281C40.h" #include "code_800029B0.h" diff --git a/src/ending/podium_ceremony_actors.c b/src/ending/podium_ceremony_actors.c index 1e86047bf4..0667cf1e5b 100644 --- a/src/ending/podium_ceremony_actors.c +++ b/src/ending/podium_ceremony_actors.c @@ -13,7 +13,7 @@ #include "camera_junk.h" #include "player_controller.h" #include "code_80057C60.h" -#include "code_80005FD0.h" +#include "cpu_vehicles_camera_path.h" #include "code_80281C40.h" #include "math_util.h" diff --git a/src/math_util_2.h b/src/math_util_2.h index 3dc40c696c..591c6f2108 100644 --- a/src/math_util_2.h +++ b/src/math_util_2.h @@ -79,6 +79,8 @@ void rsp_set_matrix_transformation_inverted_x_y_orientation(Vec3f, Vec3su, f32); void rsp_set_matrix_transl_rot_scale(Vec3f, Vec3f, f32); void rsp_set_matrix_gObjectList(s32); +#define DEGREES_CONVERSION_FACTOR 182 + /* This is where I'd put my static data, if I had any */ extern s8 D_801658FE; diff --git a/src/menu_items.c b/src/menu_items.c index 1d3db1f76f..855a169a03 100644 --- a/src/menu_items.c +++ b/src/menu_items.c @@ -9,7 +9,7 @@ #include "code_800029B0.h" #include "menu_items.h" -#include "code_80005FD0.h" +#include "cpu_vehicles_camera_path.h" #include "code_8006E9C0.h" #include "menus.h" #include "save.h" @@ -7227,7 +7227,7 @@ void func_800A34A8(MenuItem* arg0) { var_v1 = 0; } else { var_v1 = 0x0000000D; - var_v0 = D_80164478[sp80[rank]]; + var_v0 = gGetPlayerByCharacterId[sp80[rank]]; } if (var_v0 < gPlayerCount) { var_a0 = (s32) gGlobalTimer % 3; @@ -7254,7 +7254,7 @@ void func_800A34A8(MenuItem* arg0) { if (arg0->state < 9) { var_v0 = gGPCurrentRacePlayerIdByRank[rank]; } else { - var_v0 = D_80164478[sp80[rank]]; + var_v0 = gGetPlayerByCharacterId[sp80[rank]]; } if (var_v0 < gPlayerCount) { var_a0 = (s32) gGlobalTimer % 3; @@ -7295,7 +7295,8 @@ void func_800A3A10(s8* arg0) { arg0[var_a1] = temp_a3; arg0[var_a1 - 1] = temp_t1; } else if (gGPPointsByCharacterId[temp_t1] == gGPPointsByCharacterId[temp_a3]) { - if ((D_80164478[temp_t1] < gPlayerCount) && (D_80164478[temp_t1] < D_80164478[temp_a3])) { + if ((gGetPlayerByCharacterId[temp_t1] < gPlayerCount) && + (gGetPlayerByCharacterId[temp_t1] < gGetPlayerByCharacterId[temp_a3])) { arg0[var_a1] = temp_a3; arg0[var_a1 - 1] = temp_t1; } else { @@ -10820,7 +10821,7 @@ void func_800AC458(MenuItem* arg0) { arg0->param1 = 0; if (gCourseIndexInCup == 3) { for (var_a1 = 0; var_a1 < 8; var_a1++) { - if (D_80164478[gCharacterIdByGPOverallRank[var_a1]] < gPlayerCount) { + if (gGetPlayerByCharacterId[gCharacterIdByGPOverallRank[var_a1]] < gPlayerCount) { func_800B536C(var_a1); break; } diff --git a/src/menu_items.h b/src/menu_items.h index 7f80c09d44..9444badc84 100644 --- a/src/menu_items.h +++ b/src/menu_items.h @@ -654,7 +654,7 @@ void tkmk00decode(u8*, u8*, u8*, s32); /* This is where I'd put my static data, if I had any */ extern s32 D_800DDB24; -extern s16 D_80164478[]; +extern s16 gGetPlayerByCharacterId[]; extern u16* gMenuTextureBuffer; extern u8* gMenuCompressedBuffer; diff --git a/src/menus.c b/src/menus.c index 6d59b432ec..629758223b 100644 --- a/src/menus.c +++ b/src/menus.c @@ -11,7 +11,7 @@ #include "actors.h" #include "audio/external.h" #include "code_800029B0.h" -#include "code_80005FD0.h" +#include "cpu_vehicles_camera_path.h" #include "menu_items.h" #include "code_800AF9B0.h" #include "save.h" diff --git a/src/player_controller.c b/src/player_controller.c index 0401988766..fe30bad174 100644 --- a/src/player_controller.c +++ b/src/player_controller.c @@ -12,182 +12,177 @@ #include "render_player.h" #include "effects.h" #include "collision.h" -#include "waypoints.h" +#include "path.h" #include "audio/external.h" #include "code_8003DC40.h" #include "main.h" #include "camera.h" #include "spawn_players.h" #include "code_80057C60.h" -#include "code_80005FD0.h" +#include "cpu_vehicles_camera_path.h" #include "sounds.h" extern s32 D_8018D168; -s16 gKartAIforMario[] = { LUIGI, YOSHI, TOAD, DK, WARIO, PEACH, BOWSER, 0 }; +s16 cpu_forMario[] = { LUIGI, YOSHI, TOAD, DK, WARIO, PEACH, BOWSER, 0 }; -s16 gKartAIforLuigi[] = { MARIO, YOSHI, TOAD, DK, WARIO, PEACH, BOWSER, 0 }; +s16 cpu_forLuigi[] = { MARIO, YOSHI, TOAD, DK, WARIO, PEACH, BOWSER, 0 }; -s16 gKartAIforYoshi[] = { MARIO, LUIGI, TOAD, DK, WARIO, PEACH, BOWSER, 0 }; +s16 cpu_forYoshi[] = { MARIO, LUIGI, TOAD, DK, WARIO, PEACH, BOWSER, 0 }; -s16 gKartAIforToad[] = { MARIO, LUIGI, YOSHI, DK, WARIO, PEACH, BOWSER, 0 }; +s16 cpu_forToad[] = { MARIO, LUIGI, YOSHI, DK, WARIO, PEACH, BOWSER, 0 }; -s16 gKartAIforDk[] = { MARIO, LUIGI, YOSHI, TOAD, WARIO, PEACH, BOWSER, 0 }; +s16 cpu_forDk[] = { MARIO, LUIGI, YOSHI, TOAD, WARIO, PEACH, BOWSER, 0 }; -s16 gKartAIforWario[] = { MARIO, LUIGI, YOSHI, TOAD, DK, PEACH, BOWSER, 0 }; +s16 cpu_forWario[] = { MARIO, LUIGI, YOSHI, TOAD, DK, PEACH, BOWSER, 0 }; -s16 gKartAIforPeach[] = { MARIO, LUIGI, YOSHI, TOAD, DK, WARIO, BOWSER, 0 }; +s16 cpu_forPeach[] = { MARIO, LUIGI, YOSHI, TOAD, DK, WARIO, BOWSER, 0 }; -s16 gKartAIforBowser[] = { MARIO, LUIGI, YOSHI, TOAD, DK, WARIO, PEACH, 0 }; +s16 cpu_forBowser[] = { MARIO, LUIGI, YOSHI, TOAD, DK, WARIO, PEACH, 0 }; -s16* gKartAIforPlayer[] = { gKartAIforMario, gKartAIforLuigi, gKartAIforYoshi, gKartAIforToad, - gKartAIforDk, gKartAIforWario, gKartAIforPeach, gKartAIforBowser }; +s16* cpu_forPlayer[] = { cpu_forMario, cpu_forLuigi, cpu_forYoshi, cpu_forToad, + cpu_forDk, cpu_forWario, cpu_forPeach, cpu_forBowser }; -s16 gKartAIforMarioAndLuigi[] = { YOSHI, TOAD, DK, WARIO, PEACH, BOWSER }; +s16 cpu_forMarioAndLuigi[] = { YOSHI, TOAD, DK, WARIO, PEACH, BOWSER }; -s16 gKartAIforMarioAndYoshi[] = { LUIGI, TOAD, DK, WARIO, PEACH, BOWSER }; +s16 cpu_forMarioAndYoshi[] = { LUIGI, TOAD, DK, WARIO, PEACH, BOWSER }; -s16 gKartAIforMarioAndToad[] = { LUIGI, YOSHI, DK, WARIO, PEACH, BOWSER }; +s16 cpu_forMarioAndToad[] = { LUIGI, YOSHI, DK, WARIO, PEACH, BOWSER }; -s16 gKartAIforMarioAndDk[] = { LUIGI, YOSHI, TOAD, WARIO, PEACH, BOWSER }; +s16 cpu_forMarioAndDk[] = { LUIGI, YOSHI, TOAD, WARIO, PEACH, BOWSER }; -s16 gKartAIforMarioAndWario[] = { LUIGI, YOSHI, TOAD, DK, PEACH, BOWSER }; +s16 cpu_forMarioAndWario[] = { LUIGI, YOSHI, TOAD, DK, PEACH, BOWSER }; -s16 gKartAIforMarioAndPeach[] = { LUIGI, YOSHI, TOAD, DK, WARIO, BOWSER }; +s16 cpu_forMarioAndPeach[] = { LUIGI, YOSHI, TOAD, DK, WARIO, BOWSER }; -s16 gKartAIforMarioAndBowser[] = { LUIGI, YOSHI, TOAD, DK, WARIO, PEACH }; +s16 cpu_forMarioAndBowser[] = { LUIGI, YOSHI, TOAD, DK, WARIO, PEACH }; -s16 gKartAIforLuigiAndMario[] = { YOSHI, TOAD, DK, WARIO, PEACH, BOWSER }; +s16 cpu_forLuigiAndMario[] = { YOSHI, TOAD, DK, WARIO, PEACH, BOWSER }; -s16 gKartAIforLuigiAndYoshi[] = { MARIO, TOAD, DK, WARIO, PEACH, BOWSER }; +s16 cpu_forLuigiAndYoshi[] = { MARIO, TOAD, DK, WARIO, PEACH, BOWSER }; -s16 gKartAIforLuigiAndToad[] = { MARIO, YOSHI, DK, WARIO, PEACH, BOWSER }; +s16 cpu_forLuigiAndToad[] = { MARIO, YOSHI, DK, WARIO, PEACH, BOWSER }; -s16 gKartAIforLuigiAndDk[] = { MARIO, YOSHI, TOAD, WARIO, PEACH, BOWSER }; +s16 cpu_forLuigiAndDk[] = { MARIO, YOSHI, TOAD, WARIO, PEACH, BOWSER }; -s16 gKartAIforLuigiAndWario[] = { MARIO, YOSHI, TOAD, DK, PEACH, BOWSER }; +s16 cpu_forLuigiAndWario[] = { MARIO, YOSHI, TOAD, DK, PEACH, BOWSER }; -s16 gKartAIforLuigiAndPeach[] = { MARIO, YOSHI, TOAD, DK, WARIO, BOWSER }; +s16 cpu_forLuigiAndPeach[] = { MARIO, YOSHI, TOAD, DK, WARIO, BOWSER }; -s16 gKartAIforLuigiAndBowser[] = { MARIO, YOSHI, TOAD, DK, WARIO, PEACH }; +s16 cpu_forLuigiAndBowser[] = { MARIO, YOSHI, TOAD, DK, WARIO, PEACH }; -s16 gKartAIforYoshiAndMario[] = { LUIGI, TOAD, DK, WARIO, PEACH, BOWSER }; +s16 cpu_forYoshiAndMario[] = { LUIGI, TOAD, DK, WARIO, PEACH, BOWSER }; -s16 gKartAIforYoshiAndLuigi[] = { MARIO, TOAD, DK, WARIO, PEACH, BOWSER }; +s16 cpu_forYoshiAndLuigi[] = { MARIO, TOAD, DK, WARIO, PEACH, BOWSER }; -s16 gKartAIforYoshiAndToad[] = { MARIO, LUIGI, DK, WARIO, PEACH, BOWSER }; +s16 cpu_forYoshiAndToad[] = { MARIO, LUIGI, DK, WARIO, PEACH, BOWSER }; -s16 gKartAIforYoshiAndDk[] = { MARIO, LUIGI, TOAD, WARIO, PEACH, BOWSER }; +s16 cpu_forYoshiAndDk[] = { MARIO, LUIGI, TOAD, WARIO, PEACH, BOWSER }; -s16 gKartAIforYoshiAndWario[] = { MARIO, LUIGI, TOAD, DK, PEACH, BOWSER }; +s16 cpu_forYoshiAndWario[] = { MARIO, LUIGI, TOAD, DK, PEACH, BOWSER }; -s16 gKartAIforYoshiAndPeach[] = { MARIO, LUIGI, TOAD, DK, WARIO, BOWSER }; +s16 cpu_forYoshiAndPeach[] = { MARIO, LUIGI, TOAD, DK, WARIO, BOWSER }; -s16 gKartAIforYoshiAndBowser[] = { MARIO, LUIGI, TOAD, DK, WARIO, PEACH }; +s16 cpu_forYoshiAndBowser[] = { MARIO, LUIGI, TOAD, DK, WARIO, PEACH }; -s16 gKartAIforToadAndMario[] = { LUIGI, YOSHI, DK, WARIO, PEACH, BOWSER }; +s16 cpu_forToadAndMario[] = { LUIGI, YOSHI, DK, WARIO, PEACH, BOWSER }; -s16 gKartAIforToadAndLuigi[] = { MARIO, YOSHI, DK, WARIO, PEACH, BOWSER }; +s16 cpu_forToadAndLuigi[] = { MARIO, YOSHI, DK, WARIO, PEACH, BOWSER }; -s16 gKartAIforToadAndYoshi[] = { MARIO, LUIGI, DK, WARIO, PEACH, BOWSER }; +s16 cpu_forToadAndYoshi[] = { MARIO, LUIGI, DK, WARIO, PEACH, BOWSER }; -s16 gKartAIforToadAndDk[] = { MARIO, LUIGI, YOSHI, WARIO, PEACH, BOWSER }; +s16 cpu_forToadAndDk[] = { MARIO, LUIGI, YOSHI, WARIO, PEACH, BOWSER }; -s16 gKartAIforToadAndWario[] = { MARIO, LUIGI, YOSHI, DK, PEACH, BOWSER }; +s16 cpu_forToadAndWario[] = { MARIO, LUIGI, YOSHI, DK, PEACH, BOWSER }; -s16 gKartAIforToadAndPeach[] = { MARIO, LUIGI, YOSHI, DK, WARIO, BOWSER }; +s16 cpu_forToadAndPeach[] = { MARIO, LUIGI, YOSHI, DK, WARIO, BOWSER }; -s16 gKartAIforToadAndBowser[] = { MARIO, LUIGI, YOSHI, DK, WARIO, PEACH }; +s16 cpu_forToadAndBowser[] = { MARIO, LUIGI, YOSHI, DK, WARIO, PEACH }; -s16 gKartAIforDkAndMario[] = { LUIGI, YOSHI, TOAD, WARIO, PEACH, BOWSER }; +s16 cpu_forDkAndMario[] = { LUIGI, YOSHI, TOAD, WARIO, PEACH, BOWSER }; -s16 gKartAIforDkAndLuigi[] = { MARIO, YOSHI, TOAD, WARIO, PEACH, BOWSER }; +s16 cpu_forDkAndLuigi[] = { MARIO, YOSHI, TOAD, WARIO, PEACH, BOWSER }; -s16 gKartAIforDkAndToad[] = { MARIO, LUIGI, TOAD, WARIO, PEACH, BOWSER }; +s16 cpu_forDkAndToad[] = { MARIO, LUIGI, TOAD, WARIO, PEACH, BOWSER }; -s16 gKartAIforDkAndYoshi[] = { MARIO, LUIGI, YOSHI, WARIO, PEACH, BOWSER }; +s16 cpu_forDkAndYoshi[] = { MARIO, LUIGI, YOSHI, WARIO, PEACH, BOWSER }; -s16 gKartAIforDkAndWario[] = { MARIO, LUIGI, YOSHI, TOAD, PEACH, BOWSER }; +s16 cpu_forDkAndWario[] = { MARIO, LUIGI, YOSHI, TOAD, PEACH, BOWSER }; -s16 gKartAIforDkAndPeach[] = { MARIO, LUIGI, YOSHI, TOAD, WARIO, BOWSER }; +s16 cpu_forDkAndPeach[] = { MARIO, LUIGI, YOSHI, TOAD, WARIO, BOWSER }; -s16 gKartAIforDkAndBowser[] = { MARIO, LUIGI, YOSHI, TOAD, WARIO, PEACH }; +s16 cpu_forDkAndBowser[] = { MARIO, LUIGI, YOSHI, TOAD, WARIO, PEACH }; -s16 gKartAIforWarioAndMario[] = { LUIGI, YOSHI, TOAD, DK, PEACH, BOWSER }; +s16 cpu_forWarioAndMario[] = { LUIGI, YOSHI, TOAD, DK, PEACH, BOWSER }; -s16 gKartAIforWarioAndLuigi[] = { MARIO, YOSHI, TOAD, DK, PEACH, BOWSER }; +s16 cpu_forWarioAndLuigi[] = { MARIO, YOSHI, TOAD, DK, PEACH, BOWSER }; -s16 gKartAIforWarioAndYoshi[] = { MARIO, LUIGI, TOAD, DK, PEACH, BOWSER }; +s16 cpu_forWarioAndYoshi[] = { MARIO, LUIGI, TOAD, DK, PEACH, BOWSER }; -s16 gKartAIforWarioAndDk[] = { MARIO, LUIGI, YOSHI, TOAD, PEACH, BOWSER }; +s16 cpu_forWarioAndDk[] = { MARIO, LUIGI, YOSHI, TOAD, PEACH, BOWSER }; -s16 gKartAIforWarioAndToad[] = { MARIO, LUIGI, YOSHI, DK, PEACH, BOWSER }; +s16 cpu_forWarioAndToad[] = { MARIO, LUIGI, YOSHI, DK, PEACH, BOWSER }; -s16 gKartAIforWarioAndPeach[] = { MARIO, LUIGI, YOSHI, TOAD, DK, BOWSER }; +s16 cpu_forWarioAndPeach[] = { MARIO, LUIGI, YOSHI, TOAD, DK, BOWSER }; -s16 gKartAIforWarioAndBowser[] = { MARIO, LUIGI, YOSHI, TOAD, DK, PEACH }; +s16 cpu_forWarioAndBowser[] = { MARIO, LUIGI, YOSHI, TOAD, DK, PEACH }; -s16 gKartAIforPeachAndMario[] = { LUIGI, YOSHI, TOAD, DK, WARIO, BOWSER }; +s16 cpu_forPeachAndMario[] = { LUIGI, YOSHI, TOAD, DK, WARIO, BOWSER }; -s16 gKartAIforPeachAndLuigi[] = { MARIO, YOSHI, TOAD, DK, WARIO, BOWSER }; +s16 cpu_forPeachAndLuigi[] = { MARIO, YOSHI, TOAD, DK, WARIO, BOWSER }; -s16 gKartAIforPeachAndYoshi[] = { MARIO, LUIGI, TOAD, DK, WARIO, BOWSER }; +s16 cpu_forPeachAndYoshi[] = { MARIO, LUIGI, TOAD, DK, WARIO, BOWSER }; -s16 gKartAIforPeachAndDk[] = { MARIO, LUIGI, YOSHI, TOAD, WARIO, BOWSER }; +s16 cpu_forPeachAndDk[] = { MARIO, LUIGI, YOSHI, TOAD, WARIO, BOWSER }; -s16 gKartAIforPeachAndWario[] = { MARIO, LUIGI, YOSHI, TOAD, DK, BOWSER }; +s16 cpu_forPeachAndWario[] = { MARIO, LUIGI, YOSHI, TOAD, DK, BOWSER }; -s16 gKartAIforPeachAndToad[] = { MARIO, LUIGI, YOSHI, DK, WARIO, BOWSER }; +s16 cpu_forPeachAndToad[] = { MARIO, LUIGI, YOSHI, DK, WARIO, BOWSER }; -s16 gKartAIforPeachAndBowser[] = { MARIO, LUIGI, YOSHI, TOAD, DK, WARIO }; +s16 cpu_forPeachAndBowser[] = { MARIO, LUIGI, YOSHI, TOAD, DK, WARIO }; -s16 gKartAIforBowserAndMario[] = { LUIGI, YOSHI, TOAD, DK, WARIO, PEACH }; +s16 cpu_forBowserAndMario[] = { LUIGI, YOSHI, TOAD, DK, WARIO, PEACH }; -s16 gKartAIforBowserAndLuigi[] = { MARIO, YOSHI, TOAD, DK, WARIO, PEACH }; +s16 cpu_forBowserAndLuigi[] = { MARIO, YOSHI, TOAD, DK, WARIO, PEACH }; -s16 gKartAIforBowserAndYoshi[] = { MARIO, LUIGI, TOAD, DK, WARIO, PEACH }; +s16 cpu_forBowserAndYoshi[] = { MARIO, LUIGI, TOAD, DK, WARIO, PEACH }; -s16 gKartAIforBowserAndDk[] = { MARIO, LUIGI, YOSHI, TOAD, WARIO, PEACH }; +s16 cpu_forBowserAndDk[] = { MARIO, LUIGI, YOSHI, TOAD, WARIO, PEACH }; -s16 gKartAIforBowserAndWario[] = { MARIO, LUIGI, YOSHI, TOAD, DK, PEACH }; +s16 cpu_forBowserAndWario[] = { MARIO, LUIGI, YOSHI, TOAD, DK, PEACH }; -s16 gKartAIforBowserAndToad[] = { MARIO, LUIGI, YOSHI, DK, WARIO, PEACH }; +s16 cpu_forBowserAndToad[] = { MARIO, LUIGI, YOSHI, DK, WARIO, PEACH }; -s16 gKartAIforBowserAndPeach[] = { MARIO, LUIGI, YOSHI, TOAD, DK, WARIO }; +s16 cpu_forBowserAndPeach[] = { MARIO, LUIGI, YOSHI, TOAD, DK, WARIO }; -s16* gListKartAIforMario[] = { gKartAIforMarioAndLuigi, gKartAIforMarioAndLuigi, gKartAIforMarioAndYoshi, - gKartAIforMarioAndToad, gKartAIforMarioAndDk, gKartAIforMarioAndWario, - gKartAIforMarioAndPeach, gKartAIforMarioAndBowser }; +s16* gListCPUforMario[] = { cpu_forMarioAndLuigi, cpu_forMarioAndLuigi, cpu_forMarioAndYoshi, cpu_forMarioAndToad, + cpu_forMarioAndDk, cpu_forMarioAndWario, cpu_forMarioAndPeach, cpu_forMarioAndBowser }; -s16* gListKartAIforLuigi[] = { gKartAIforLuigiAndMario, gKartAIforLuigiAndMario, gKartAIforLuigiAndYoshi, - gKartAIforLuigiAndToad, gKartAIforLuigiAndDk, gKartAIforLuigiAndWario, - gKartAIforLuigiAndPeach, gKartAIforLuigiAndBowser }; +s16* gListCPUforLuigi[] = { cpu_forLuigiAndMario, cpu_forLuigiAndMario, cpu_forLuigiAndYoshi, cpu_forLuigiAndToad, + cpu_forLuigiAndDk, cpu_forLuigiAndWario, cpu_forLuigiAndPeach, cpu_forLuigiAndBowser }; -s16* gListKartAIforYoshi[] = { gKartAIforYoshiAndMario, gKartAIforYoshiAndLuigi, gKartAIforYoshiAndLuigi, - gKartAIforYoshiAndToad, gKartAIforYoshiAndDk, gKartAIforYoshiAndWario, - gKartAIforYoshiAndPeach, gKartAIforYoshiAndBowser }; +s16* gListCPUforYoshi[] = { cpu_forYoshiAndMario, cpu_forYoshiAndLuigi, cpu_forYoshiAndLuigi, cpu_forYoshiAndToad, + cpu_forYoshiAndDk, cpu_forYoshiAndWario, cpu_forYoshiAndPeach, cpu_forYoshiAndBowser }; -s16* gListKartAIforToad[] = { gKartAIforToadAndMario, gKartAIforToadAndLuigi, gKartAIforToadAndYoshi, - gKartAIforToadAndYoshi, gKartAIforToadAndDk, gKartAIforToadAndWario, - gKartAIforToadAndPeach, gKartAIforToadAndBowser }; +s16* gListCPUforToad[] = { cpu_forToadAndMario, cpu_forToadAndLuigi, cpu_forToadAndYoshi, cpu_forToadAndYoshi, + cpu_forToadAndDk, cpu_forToadAndWario, cpu_forToadAndPeach, cpu_forToadAndBowser }; -s16* gListKartAIforDk[] = { gKartAIforDkAndMario, gKartAIforDkAndLuigi, gKartAIforDkAndToad, gKartAIforDkAndYoshi, - gKartAIforDkAndYoshi, gKartAIforDkAndWario, gKartAIforDkAndPeach, gKartAIforDkAndBowser }; +s16* gListCPUforDk[] = { cpu_forDkAndMario, cpu_forDkAndLuigi, cpu_forDkAndToad, cpu_forDkAndYoshi, + cpu_forDkAndYoshi, cpu_forDkAndWario, cpu_forDkAndPeach, cpu_forDkAndBowser }; -s16* gListKartAIforWario[] = { gKartAIforWarioAndMario, gKartAIforWarioAndLuigi, gKartAIforWarioAndYoshi, - gKartAIforWarioAndToad, gKartAIforWarioAndDk, gKartAIforWarioAndDk, - gKartAIforWarioAndPeach, gKartAIforWarioAndBowser }; +s16* gListCPUforWario[] = { cpu_forWarioAndMario, cpu_forWarioAndLuigi, cpu_forWarioAndYoshi, cpu_forWarioAndToad, + cpu_forWarioAndDk, cpu_forWarioAndDk, cpu_forWarioAndPeach, cpu_forWarioAndBowser }; -s16* gListKartAIforPeach[] = { gKartAIforPeachAndMario, gKartAIforPeachAndLuigi, gKartAIforPeachAndYoshi, - gKartAIforPeachAndToad, gKartAIforPeachAndDk, gKartAIforPeachAndWario, - gKartAIforPeachAndDk, gKartAIforPeachAndBowser }; +s16* gListCPUforPeach[] = { cpu_forPeachAndMario, cpu_forPeachAndLuigi, cpu_forPeachAndYoshi, cpu_forPeachAndToad, + cpu_forPeachAndDk, cpu_forPeachAndWario, cpu_forPeachAndDk, cpu_forPeachAndBowser }; -s16* gListKartAIforBowser[] = { gKartAIforBowserAndMario, gKartAIforBowserAndLuigi, gKartAIforBowserAndYoshi, - gKartAIforBowserAndToad, gKartAIforBowserAndDk, gKartAIforBowserAndWario, - gKartAIforBowserAndPeach, gKartAIforBowserAndPeach }; +s16* gListCPUforBowser[] = { + cpu_forBowserAndMario, cpu_forBowserAndLuigi, cpu_forBowserAndYoshi, cpu_forBowserAndToad, + cpu_forBowserAndDk, cpu_forBowserAndWario, cpu_forBowserAndPeach, cpu_forBowserAndPeach +}; -s16** gKartAIforTwoPlayer[] = { gListKartAIforMario, gListKartAIforLuigi, gListKartAIforYoshi, gListKartAIforToad, - gListKartAIforDk, gListKartAIforWario, gListKartAIforPeach, gListKartAIforBowser }; +s16** cpu_forTwoPlayer[] = { gListCPUforMario, gListCPUforLuigi, gListCPUforYoshi, gListCPUforToad, + gListCPUforDk, gListCPUforWario, gListCPUforPeach, gListCPUforBowser }; // func_80027D00 s32 get_player_index_for_player(Player* player) { @@ -223,7 +218,7 @@ s32 get_player_index_for_player(Player* player) { void func_80027DA8(Player* player, s8 playerId) { if (D_8015F890 != 1) { if ((player->type & 0x10) != 0x10) { - if (((D_8018D168 == 1) && ((player->type & 0x4000) == 0x4000)) && ((player->type & 0x100) != 0x100)) { + if (((D_8018D168 == 1) && ((player->type & PLAYER_HUMAN) == 0x4000)) && ((player->type & 0x100) != 0x100)) { func_800C94A4(playerId); player->type |= 0x10; } else if ((player->type & 0x2000) == 0) { @@ -250,8 +245,8 @@ void func_80027EDC(Player* player, s8 playerId) { #if !ENABLE_CUSTOM_COURSE_ENGINE switch (gCurrentCourseId) { case COURSE_MARIO_RACEWAY: - if (((s16) gNearestWaypointByPlayerId[playerId] >= 0x19B) && - ((s16) gNearestWaypointByPlayerId[playerId] < 0x1B9)) { + if (((s16) gNearestPathPointByPlayerId[playerId] >= 0x19B) && + ((s16) gNearestPathPointByPlayerId[playerId] < 0x1B9)) { if (D_80165300[playerId] != 1) { func_800CA288(playerId, 0x55); } @@ -264,8 +259,8 @@ void func_80027EDC(Player* player, s8 playerId) { } break; case COURSE_CHOCO_MOUNTAIN: - if (((s16) gNearestWaypointByPlayerId[playerId] >= 0xA0) && - ((s16) gNearestWaypointByPlayerId[playerId] < 0xB4)) { + if (((s16) gNearestPathPointByPlayerId[playerId] >= 0xA0) && + ((s16) gNearestPathPointByPlayerId[playerId] < 0xB4)) { if (D_80165300[playerId] != 1) { func_800CA288(playerId, 0x55); } @@ -278,8 +273,8 @@ void func_80027EDC(Player* player, s8 playerId) { } break; case COURSE_BOWSER_CASTLE: - if (((s16) gNearestWaypointByPlayerId[playerId] >= 0x29) && - ((s16) gNearestWaypointByPlayerId[playerId] < 0x1D2)) { + if (((s16) gNearestPathPointByPlayerId[playerId] >= 0x29) && + ((s16) gNearestPathPointByPlayerId[playerId] < 0x1D2)) { if (D_80165300[playerId] != 1) { func_800CA288(playerId, 0x41); } @@ -292,8 +287,8 @@ void func_80027EDC(Player* player, s8 playerId) { } break; case COURSE_BANSHEE_BOARDWALK: - if (((s16) gNearestWaypointByPlayerId[playerId] >= 0x180) && - ((s16) gNearestWaypointByPlayerId[playerId] < 0x1E1)) { + if (((s16) gNearestPathPointByPlayerId[playerId] >= 0x180) && + ((s16) gNearestPathPointByPlayerId[playerId] < 0x1E1)) { if (D_80165300[playerId] != 1) { func_800CA288(playerId, 0x41); } @@ -306,8 +301,8 @@ void func_80027EDC(Player* player, s8 playerId) { } break; case COURSE_LUIGI_RACEWAY: - if (((s16) gNearestWaypointByPlayerId[playerId] >= 0x145) && - ((s16) gNearestWaypointByPlayerId[playerId] < 0x18B)) { + if (((s16) gNearestPathPointByPlayerId[playerId] >= 0x145) && + ((s16) gNearestPathPointByPlayerId[playerId] < 0x18B)) { if (D_80165300[playerId] != 1) { func_800CA288(playerId, 0x55); } @@ -333,8 +328,8 @@ void func_80027EDC(Player* player, s8 playerId) { } break; case COURSE_SHERBET_LAND: - if (((s16) gNearestWaypointByPlayerId[playerId] >= 0x11C) && - ((s16) gNearestWaypointByPlayerId[playerId] < 0x209)) { + if (((s16) gNearestPathPointByPlayerId[playerId] >= 0x11C) && + ((s16) gNearestPathPointByPlayerId[playerId] < 0x209)) { if (D_80165300[playerId] != 1) { func_800CA288(playerId, 0x55); } @@ -347,17 +342,17 @@ void func_80027EDC(Player* player, s8 playerId) { } break; case COURSE_DK_JUNGLE: - if ((((s16) gNearestWaypointByPlayerId[playerId] >= 0) && - ((s16) gNearestWaypointByPlayerId[playerId] < 0x65)) || - (((s16) gNearestWaypointByPlayerId[playerId] >= 0x14A) && - ((s16) gNearestWaypointByPlayerId[playerId] < 0x21F))) { + if ((((s16) gNearestPathPointByPlayerId[playerId] >= 0) && + ((s16) gNearestPathPointByPlayerId[playerId] < 0x65)) || + (((s16) gNearestPathPointByPlayerId[playerId] >= 0x14A) && + ((s16) gNearestPathPointByPlayerId[playerId] < 0x21F))) { if (D_80165300[playerId] != 2) { func_800C8F80(playerId, 0x0170802D); } D_80165300[playerId] = 2; } else { - if (((s16) gNearestWaypointByPlayerId[playerId] >= 0x288) && - ((s16) gNearestWaypointByPlayerId[playerId] < 0x305)) { + if (((s16) gNearestPathPointByPlayerId[playerId] >= 0x288) && + ((s16) gNearestPathPointByPlayerId[playerId] < 0x305)) { if (D_80165300[playerId] != 1) { func_800CA288(playerId, 0x55); } @@ -385,8 +380,8 @@ void func_80027EDC(Player* player, s8 playerId) { #if !ENABLE_CUSTOM_COURSE_ENGINE switch (gCurrentCourseId) { case COURSE_MARIO_RACEWAY: - if (((s16) gNearestWaypointByPlayerId[playerId] >= 0x19B) && - ((s16) gNearestWaypointByPlayerId[playerId] < 0x1B9)) { + if (((s16) gNearestPathPointByPlayerId[playerId] >= 0x19B) && + ((s16) gNearestPathPointByPlayerId[playerId] < 0x1B9)) { if (D_80165300[playerId] != 1) { func_800CA2E4(playerId, 0x55); } @@ -399,8 +394,8 @@ void func_80027EDC(Player* player, s8 playerId) { } break; case COURSE_CHOCO_MOUNTAIN: - if (((s16) gNearestWaypointByPlayerId[playerId] >= 0xA0) && - ((s16) gNearestWaypointByPlayerId[playerId] < 0xB4)) { + if (((s16) gNearestPathPointByPlayerId[playerId] >= 0xA0) && + ((s16) gNearestPathPointByPlayerId[playerId] < 0xB4)) { if (D_80165300[playerId] != 1) { func_800CA2E4(playerId, 0x55); } @@ -413,8 +408,8 @@ void func_80027EDC(Player* player, s8 playerId) { } break; case COURSE_BOWSER_CASTLE: - if (((s16) gNearestWaypointByPlayerId[playerId] >= 0x29) && - ((s16) gNearestWaypointByPlayerId[playerId] < 0x1D2)) { + if (((s16) gNearestPathPointByPlayerId[playerId] >= 0x29) && + ((s16) gNearestPathPointByPlayerId[playerId] < 0x1D2)) { if (D_80165300[playerId] != 1) { func_800CA2E4(playerId, 0x41); } @@ -427,8 +422,8 @@ void func_80027EDC(Player* player, s8 playerId) { } break; case COURSE_BANSHEE_BOARDWALK: - if (((s16) gNearestWaypointByPlayerId[playerId] >= 0x180) && - ((s16) gNearestWaypointByPlayerId[playerId] < 0x1E1)) { + if (((s16) gNearestPathPointByPlayerId[playerId] >= 0x180) && + ((s16) gNearestPathPointByPlayerId[playerId] < 0x1E1)) { if (D_80165300[playerId] != 1) { func_800CA2E4(playerId, 0x41); } @@ -441,8 +436,8 @@ void func_80027EDC(Player* player, s8 playerId) { } break; case COURSE_LUIGI_RACEWAY: - if (((s16) gNearestWaypointByPlayerId[playerId] >= 0x145) && - ((s16) gNearestWaypointByPlayerId[playerId] < 0x18B)) { + if (((s16) gNearestPathPointByPlayerId[playerId] >= 0x145) && + ((s16) gNearestPathPointByPlayerId[playerId] < 0x18B)) { if (D_80165300[playerId] != 1) { func_800CA2E4(playerId, 0x55); } @@ -468,8 +463,8 @@ void func_80027EDC(Player* player, s8 playerId) { } break; case COURSE_SHERBET_LAND: - if (((s16) gNearestWaypointByPlayerId[playerId] >= 0x11C) && - ((s16) gNearestWaypointByPlayerId[playerId] < 0x209)) { + if (((s16) gNearestPathPointByPlayerId[playerId] >= 0x11C) && + ((s16) gNearestPathPointByPlayerId[playerId] < 0x209)) { if (D_80165300[playerId] != 1) { func_800CA2E4(playerId, 0x55); } @@ -482,8 +477,8 @@ void func_80027EDC(Player* player, s8 playerId) { } break; case COURSE_DK_JUNGLE: - if (((s16) gNearestWaypointByPlayerId[playerId] >= 0x288) && - ((s16) gNearestWaypointByPlayerId[playerId] < 0x305)) { + if (((s16) gNearestPathPointByPlayerId[playerId] >= 0x288) && + ((s16) gNearestPathPointByPlayerId[playerId] < 0x305)) { if (D_80165300[playerId] != 1) { func_800CA2E4(playerId, 0x55); } @@ -505,46 +500,46 @@ void func_80027EDC(Player* player, s8 playerId) { } void func_80028864(Player* player, Camera* camera, s8 playerId, s8 screenId) { - u16 sp1E; + u16 isVisible; if (!(player->type & PLAYER_START_SEQUENCE)) { switch (gActiveScreenMode) { case SCREEN_MODE_1P: - sp1E = check_player_camera_collision(player, camera1, (f32) D_8016557C, 0.0f); + isVisible = check_player_camera_collision(player, camera1, (f32) D_8016557C, 0.0f); break; case SCREEN_MODE_2P_SPLITSCREEN_HORIZONTAL: case SCREEN_MODE_2P_SPLITSCREEN_VERTICAL: - sp1E = check_player_camera_collision(player, camera1, (f32) D_8016557C, 0.0f); - if (sp1E == 1) { + isVisible = check_player_camera_collision(player, camera1, (f32) D_8016557C, 0.0f); + if (isVisible == true) { break; } - sp1E = check_player_camera_collision(player, camera2, (f32) D_8016557C, 0.0f); + isVisible = check_player_camera_collision(player, camera2, (f32) D_8016557C, 0.0f); break; case SCREEN_MODE_3P_4P_SPLITSCREEN: - sp1E = check_player_camera_collision(player, camera1, (f32) D_8016557C, 0.0f); - if (sp1E == 1) { + isVisible = check_player_camera_collision(player, camera1, (f32) D_8016557C, 0.0f); + if (isVisible == true) { break; } - sp1E = check_player_camera_collision(player, camera2, (f32) D_8016557C, 0.0f); - if (sp1E == 1) { + isVisible = check_player_camera_collision(player, camera2, (f32) D_8016557C, 0.0f); + if (isVisible == true) { break; } - sp1E = check_player_camera_collision(player, camera3, (f32) D_8016557C, 0.0f); - if (sp1E == 1) { + isVisible = check_player_camera_collision(player, camera3, (f32) D_8016557C, 0.0f); + if (isVisible == true) { break; } - sp1E = check_player_camera_collision(player, camera4, (f32) D_8016557C, 0.0f); + isVisible = check_player_camera_collision(player, camera4, (f32) D_8016557C, 0.0f); break; } - if ((sp1E == 1) || ((player->type & PLAYER_INVISIBLE_OR_BOMB) == PLAYER_INVISIBLE_OR_BOMB) || + if ((isVisible == 1) || ((player->type & PLAYER_INVISIBLE_OR_BOMB) == PLAYER_INVISIBLE_OR_BOMB) || (gModeSelection == BATTLE) || ((player->unk_0CA & 2) != 0) || (player->unk_0CA & 8) || //! @todo make a proper match ((*(D_801633F8 + (playerId))) == ((s16) 1U))) { - player->effects &= ~0x1000; + player->effects &= ~UNKNOWN_EFFECT_0x1000; if (((player->effects & 0x80) == 0x80) || ((player->effects & 0x40) == 0x40) || ((player->effects & 0x400) == 0x400) || ((player->effects & 0x4000) == 0x4000) || ((player->effects & 0x80000) == 0x80000) || ((player->effects & 0x800000) == 0x800000) || - ((player->effects & 0x01000000) == 0x01000000) || + ((player->effects & UNKNOWN_EFFECT_0x1000000) == UNKNOWN_EFFECT_0x1000000) || ((player->effects & HIT_BY_ITEM_EFFECT) == HIT_BY_ITEM_EFFECT) || ((player->effects & 0x20000) == 0x20000) || (player->unk_044 & 0x800)) { func_8002E594(player, camera, screenId, playerId); @@ -552,7 +547,7 @@ void func_80028864(Player* player, Camera* camera, s8 playerId, s8 screenId) { func_8002D268(player, camera, screenId, playerId); } } else { - control_kart_ai_movement(player, camera, screenId, playerId); + control_cpu_movement(player, camera, screenId, playerId); } } else if ((player->type & PLAYER_STAGING) == PLAYER_STAGING) { func_8002D028(player, playerId); @@ -569,11 +564,11 @@ void func_80028864(Player* player, Camera* camera, s8 playerId, s8 screenId) { void func_80028C44(Player* player, Camera* camera, s8 playerId, s8 screenId) { if ((player->type & PLAYER_START_SEQUENCE) == 0) { - player->effects &= ~0x1000; + player->effects &= ~UNKNOWN_EFFECT_0x1000; if (((player->effects & 0x80) == 0x80) || ((player->effects & 0x40) == 0x40) || ((player->effects & 0x400) == 0x400) || ((player->effects & 0x4000) == 0x4000) || ((player->effects & 0x80000) == 0x80000) || ((player->effects & 0x800000) == 0x800000) || - ((player->effects & 0x1000000) == 0x1000000) || + ((player->effects & UNKNOWN_EFFECT_0x1000000) == UNKNOWN_EFFECT_0x1000000) || ((player->effects & HIT_BY_ITEM_EFFECT) == HIT_BY_ITEM_EFFECT) || ((player->effects & 0x20000) == 0x20000) || ((player->unk_044 & 0x800) != 0)) { func_8002E594(player, camera, screenId, playerId); @@ -587,13 +582,15 @@ void func_80028C44(Player* player, Camera* camera, s8 playerId, s8 screenId) { void func_80028D3C(Player* player, Camera* camera, s8 playerId, s8 screenId) { if ((((player->type & PLAYER_START_SEQUENCE) == 0) && (D_800DC510 != 5)) || (player->unk_0CA & 2) != 0 || - (player->unk_0CA & 8) != 0 || (player->effects & 0x4F010CC0) != 0) { - player->effects &= ~0x1000; + (player->unk_0CA & 8) != 0 || + (player->effects & (0x40000000 | UNKNOWN_EFFECT_0x1000000 | 0x2000000 | 0x4000000 | 0x8000000 | + UNKNOWN_EFFECT_0x10000 | 0xC00 | 0xC0)) != 0) { + player->effects &= ~UNKNOWN_EFFECT_0x1000; if (((player->effects & 0x80) == 0x80) || ((player->effects & 0x40) == 0x40) || ((player->effects & 0x400) == 0x400) || ((player->effects & 0x4000) == 0x4000) || ((player->effects & 0x80000) == 0x80000) || ((player->effects & 0x800000) == 0x800000) || - ((player->effects & 0x1000000) == 0x1000000) || + ((player->effects & UNKNOWN_EFFECT_0x1000000) == UNKNOWN_EFFECT_0x1000000) || ((player->effects & HIT_BY_ITEM_EFFECT) == HIT_BY_ITEM_EFFECT) || ((player->effects & 0x20000) == 0x20000) || ((player->unk_044 & 0x800) != 0)) { func_8002E594(player, camera, screenId, playerId); @@ -822,8 +819,9 @@ void func_8002934C(Player* player, Camera* camera, s8 screenId, s8 playerId) { player->animGroupSelector[screenId] = 4; } - if (((player->effects & 0x400) == 0x400) || ((player->effects & 0x01000000) == 0x01000000) || - ((player->effects & HIT_BY_ITEM_EFFECT) == HIT_BY_ITEM_EFFECT) || (player->effects & 0x10000) || + if (((player->effects & 0x400) == 0x400) || + ((player->effects & UNKNOWN_EFFECT_0x1000000) == UNKNOWN_EFFECT_0x1000000) || + ((player->effects & HIT_BY_ITEM_EFFECT) == HIT_BY_ITEM_EFFECT) || (player->effects & UNKNOWN_EFFECT_0x10000) || (player->effects & 0x80) || (player->effects & 0x40)) { player->unk_002 |= 1 << (screenId * 4); @@ -1097,8 +1095,9 @@ void func_8002A704(Player* player, s8 arg1) { } void func_8002A79C(Player* player, s8 arg1) { - if (((player->effects & 0x100) != 0x100) && ((player->effects & 0x10) != 0x10) && (player->unk_22A >= 2)) { - player->effects |= 0x100; + if (((player->effects & UNKNOWN_EFFECT_0x100) != UNKNOWN_EFFECT_0x100) && + ((player->effects & UNKNOWN_EFFECT_0x10) != UNKNOWN_EFFECT_0x10) && (player->unk_22A >= 2)) { + player->effects |= UNKNOWN_EFFECT_0x100; player->unk_23A = 0; player->unk_22A = 0; player->unk_228 = 0; @@ -1109,7 +1108,7 @@ void func_8002A79C(Player* player, s8 arg1) { } else if (player == gPlayerOne) { func_800C9250(arg1); } - } else if ((player->effects & 0x100) == 0x100) { + } else if ((player->effects & UNKNOWN_EFFECT_0x100) == UNKNOWN_EFFECT_0x100) { player->unk_23A += 1; if (player->unk_23A >= 0x1F) { player->unk_23A = 0; @@ -1217,7 +1216,7 @@ void func_8002AB70(Player* player) { UNUSED s32 pad[2]; if (((player->effects & 8) != 8) && (player->unk_08C > 0.0f)) { if (((player->slopeAccel / 182) < -1) && ((player->slopeAccel / 182) >= -0x14) && - (((player->unk_094 / 18.0f) * 216.0f) >= 20.0f)) { + (((player->speed / 18.0f) * 216.0f) >= 20.0f)) { move_f32_towards(&player->kartGravity, 500.0f, 1.0f); move_f32_towards(&player->unk_DAC, 3.0f, 0.05f); } else { @@ -1255,7 +1254,7 @@ void func_8002AB70(Player* player) { if ((player->effects & 0x800000) == 0x800000) { player->kartGravity = 300.0f; } - if ((player->effects & 0x01000000) == 0x01000000) { + if ((player->effects & UNKNOWN_EFFECT_0x1000000) == UNKNOWN_EFFECT_0x1000000) { player->kartGravity = 550.0f; } if ((player->effects & HIT_BY_ITEM_EFFECT) == HIT_BY_ITEM_EFFECT) { @@ -1280,10 +1279,11 @@ void func_8002AE38(Player* player, s8 arg1, f32 arg2, f32 arg3, f32 arg4, f32 ar s16 temp_a0; s32 var_v1; - sp28 = (sins(-player->rotation[1]) * player->unk_094) + arg2; - temp_f16 = (coss(-player->rotation[1]) * player->unk_094) + arg3; - if (((player->effects & 0x800) != 0x800) && ((player->effects & 0x10) != 0x10) && !(player->unk_044 & 0x4000) && - ((((player->unk_094 / 18.0f) * 216.0f) <= 8.0f) || + sp28 = (sins(-player->rotation[1]) * player->speed) + arg2; + temp_f16 = (coss(-player->rotation[1]) * player->speed) + arg3; + if (((player->effects & 0x800) != 0x800) && ((player->effects & UNKNOWN_EFFECT_0x10) != UNKNOWN_EFFECT_0x10) && + !(player->unk_044 & 0x4000) && + ((((player->speed / 18.0f) * 216.0f) <= 8.0f) || (((player->unk_07C >> 0x10) < 5) && ((player->unk_07C >> 0x10) > -5)))) { if ((player->effects & 0x20) == 0x20) { player->unk_0C0 = (f32) (player->unk_0C0 - (player->unk_0C0 / 10)); @@ -1306,8 +1306,9 @@ void func_8002AE38(Player* player, s8 arg1, f32 arg2, f32 arg3, f32 arg4, f32 ar } else { player->unk_0C0 = (atan2s(arg2 - arg4, arg3 - arg5) - atan2s(arg2 - sp28, arg3 - temp_f16)) * 2; } - if (((player->effects & 0x10) != 0x10) && ((((player->unk_07C >> 0x10) > 0) && (player->unk_0C0 < 0)) || - (((player->unk_07C >> 0x10) < 0) && (player->unk_0C0 > 0)))) { + if (((player->effects & UNKNOWN_EFFECT_0x10) != UNKNOWN_EFFECT_0x10) && + ((((player->unk_07C >> 0x10) > 0) && (player->unk_0C0 < 0)) || + (((player->unk_07C >> 0x10) < 0) && (player->unk_0C0 > 0)))) { if (player->unk_0C0 > 0) { player->unk_0C0 = player->unk_078 * 0x14; } @@ -1336,7 +1337,7 @@ void func_8002B218(Player* player) { for (someIndex = 0; someIndex < 10; someIndex++) { if (player->unk_006 == sp38[someIndex]) { - player->effects |= 0x10; + player->effects |= UNKNOWN_EFFECT_0x10; kart_hop(player); player->unk_204 = 0; break; @@ -1431,7 +1432,7 @@ void func_8002B5C0(Player* player, UNUSED s8 playerId, UNUSED s8 screenId) { if ((player->effects & HIT_EFFECT) == HIT_EFFECT) { player->soundEffects &= 0xFE1D0578; } - if ((player->effects & 0x01000000) == 0x01000000) { + if ((player->effects & UNKNOWN_EFFECT_0x1000000) == UNKNOWN_EFFECT_0x1000000) { player->soundEffects &= 0xFE1D4478; } if ((player->effects & HIT_BY_ITEM_EFFECT) == HIT_BY_ITEM_EFFECT) { @@ -1443,7 +1444,7 @@ void func_8002B5C0(Player* player, UNUSED s8 playerId, UNUSED s8 screenId) { if ((player->effects & BOOST_RAMP_WOOD_EFFECT) == BOOST_RAMP_WOOD_EFFECT) { player->soundEffects &= 0xFE1D0478; } - if ((player->effects & 0x10000) == 0x10000) { + if ((player->effects & UNKNOWN_EFFECT_0x10000) == UNKNOWN_EFFECT_0x10000) { player->soundEffects &= 0xFE1D0478; } if ((player->effects & STAR_EFFECT) == STAR_EFFECT) { @@ -1656,7 +1657,7 @@ void func_8002BF4C(Player* player, s8 arg1) { var_a2 = 0; - if (((player->unk_094 / 18.0f) * 216.0f) < 50.0f) { + if (((player->speed / 18.0f) * 216.0f) < 50.0f) { player->unk_0E2 = 0; player->effects &= 0xFFDFFFFF; return; @@ -1669,7 +1670,8 @@ void func_8002BF4C(Player* player, s8 arg1) { } else { for (i = 0; i < NUM_PLAYERS; i++) { playerBorrow = &players[i]; - if (((player != playerBorrow) && ((playerBorrow->type & 0x100) == 0) && (playerBorrow->type & 0x8000)) && + if (((player != playerBorrow) && ((playerBorrow->type & PLAYER_INVISIBLE_OR_BOMB) == 0) && + (playerBorrow->type & PLAYER_EXISTS)) && ((var_a2 = func_8001FD78(player, playerBorrow->pos[0], playerBorrow->pos[1], playerBorrow->pos[2]), var_a2 == 1))) { player->unk_0E2 += 1; @@ -1695,7 +1697,7 @@ void func_8002BF4C(Player* player, s8 arg1) { } void func_8002C11C(Player* player) { - if ((player->effects & 0x10) == 0x10) { + if ((player->effects & UNKNOWN_EFFECT_0x10) == UNKNOWN_EFFECT_0x10) { player->unk_204 += 1; if (player->unk_204 >= 0x65) { player->unk_204 = 0x64; @@ -1713,10 +1715,10 @@ void func_8002C17C(Player* player, s8 playerId) { case COURSE_YOSHI_VALLEY: if ((player->collision.surfaceDistance[2] >= 600.0f) && (D_80165330[playerId] == 0)) { D_80165330[playerId] = 1; - gCopyNearestWaypointByPlayerId[playerId] = gNearestWaypointByPlayerId[playerId]; + gCopyNearestPathPointByPlayerId[playerId] = gNearestPathPointByPlayerId[playerId]; gCopyPathIndexByPlayerId[playerId] = gPathIndexByPlayerId[playerId]; } else if (D_80165330[playerId] == 0) { - gCopyNearestWaypointByPlayerId[playerId] = gNearestWaypointByPlayerId[playerId]; + gCopyNearestPathPointByPlayerId[playerId] = gNearestPathPointByPlayerId[playerId]; gCopyPathIndexByPlayerId[playerId] = gPathIndexByPlayerId[playerId]; } else if (!(player->effects & 8)) { if (func_802ABDF4(player->collision.meshIndexZX) == 0) { @@ -1727,32 +1729,32 @@ void func_8002C17C(Player* player, s8 playerId) { case COURSE_FRAPPE_SNOWLAND: if ((player->surfaceType == SNOW_OFFROAD) && (D_80165330[playerId] == 0)) { D_80165330[playerId] = 1; - gCopyNearestWaypointByPlayerId[playerId] = gNearestWaypointByPlayerId[playerId]; + gCopyNearestPathPointByPlayerId[playerId] = gNearestPathPointByPlayerId[playerId]; gCopyPathIndexByPlayerId[playerId] = gPathIndexByPlayerId[playerId]; } else if (player->surfaceType != SNOW_OFFROAD) { D_80165330[playerId] = 0; - gCopyNearestWaypointByPlayerId[playerId] = gNearestWaypointByPlayerId[playerId]; + gCopyNearestPathPointByPlayerId[playerId] = gNearestPathPointByPlayerId[playerId]; gCopyPathIndexByPlayerId[playerId] = gPathIndexByPlayerId[playerId]; } break; case COURSE_ROYAL_RACEWAY: if (((player->effects & BOOST_RAMP_ASPHALT_EFFECT) != 0) && (D_80165330[playerId] == 0)) { D_80165330[playerId] = 1; - gCopyNearestWaypointByPlayerId[playerId] = gNearestWaypointByPlayerId[playerId]; + gCopyNearestPathPointByPlayerId[playerId] = gNearestPathPointByPlayerId[playerId]; gCopyPathIndexByPlayerId[playerId] = gPathIndexByPlayerId[playerId]; } else if (((player->effects & BOOST_RAMP_ASPHALT_EFFECT) == 0) && !(player->effects & 8)) { D_80165330[playerId] = 0; - gCopyNearestWaypointByPlayerId[playerId] = gNearestWaypointByPlayerId[playerId]; + gCopyNearestPathPointByPlayerId[playerId] = gNearestPathPointByPlayerId[playerId]; gCopyPathIndexByPlayerId[playerId] = gPathIndexByPlayerId[playerId]; } break; case COURSE_RAINBOW_ROAD: if ((player->collision.surfaceDistance[2] >= 600.0f) && (D_80165330[playerId] == 0)) { D_80165330[playerId] = 1; - gCopyNearestWaypointByPlayerId[playerId] = gNearestWaypointByPlayerId[playerId]; + gCopyNearestPathPointByPlayerId[playerId] = gNearestPathPointByPlayerId[playerId]; gCopyPathIndexByPlayerId[playerId] = gPathIndexByPlayerId[playerId]; } else if (D_80165330[playerId] == 0) { - gCopyNearestWaypointByPlayerId[playerId] = gNearestWaypointByPlayerId[playerId]; + gCopyNearestPathPointByPlayerId[playerId] = gNearestPathPointByPlayerId[playerId]; gCopyPathIndexByPlayerId[playerId] = gPathIndexByPlayerId[playerId]; } else if (!((player->effects & 8) || (player->unk_0CA & 1))) { D_80165330[playerId] = 0; @@ -1805,14 +1807,13 @@ void func_8002C4F8(Player* player, s8 arg1) { } else if ((player->effects & 8) != 8) { player->unk_0CA &= ~0x0100; } - if ((player->type & PLAYER_KART_AI) && - ((func_802ABDF4(player->collision.meshIndexZX) != 0) || (player->unk_0CA & 1))) { - if (!(player->unk_0CA & 2) && !(player->unk_0CA & 8) && !(player->effects & 0x1000)) { + if ((player->type & PLAYER_CPU) && ((func_802ABDF4(player->collision.meshIndexZX) != 0) || (player->unk_0CA & 1))) { + if (!(player->unk_0CA & 2) && !(player->unk_0CA & 8) && !(player->effects & UNKNOWN_EFFECT_0x1000)) { func_80090778(player); func_80090868(player); } } - if ((player->type & PLAYER_KART_AI) && (player->surfaceType == OUT_OF_BOUNDS) && !(player->effects & 8)) { + if ((player->type & PLAYER_CPU) && (player->surfaceType == OUT_OF_BOUNDS) && !(player->effects & 8)) { func_80090778(player); func_80090868(player); } @@ -1867,11 +1868,11 @@ void func_8002C954(Player* player, s8 playerId, Vec3f arg2) { temp_f0 = player->pos[1] - player->unk_074; - if (((((player->effects & 0x10000) != 0x10000) && + if (((((player->effects & UNKNOWN_EFFECT_0x10000) != UNKNOWN_EFFECT_0x10000) && ((player->effects & BOOST_RAMP_ASPHALT_EFFECT) == BOOST_RAMP_ASPHALT_EFFECT)) || - ((((temp_f0 >= 20.0f) || (temp_f0 < (-1.0f))) && ((player->effects & 0x10000) == 0)) && + ((((temp_f0 >= 20.0f) || (temp_f0 < (-1.0f))) && ((player->effects & UNKNOWN_EFFECT_0x10000) == 0)) && (player->effects & 8)) || - ((player->collision.unk34 == 0) && ((player->effects & 0x10000) == 0))) && + ((player->collision.unk34 == 0) && ((player->effects & UNKNOWN_EFFECT_0x10000) == 0))) && (((player->unk_0CA & 2) == 0) || (!(player->unk_0CA & 8)))) { func_8008F494(player, playerId); } @@ -1881,7 +1882,7 @@ void func_8002C954(Player* player, s8 playerId, Vec3f arg2) { } player->unk_046 |= 0x20; } - if (((player->type & PLAYER_HUMAN) == PLAYER_HUMAN) && (((player->unk_094 / 18.0f) * 216.0f) > 30.0f)) { + if (((player->type & PLAYER_HUMAN) == PLAYER_HUMAN) && (((player->speed / 18.0f) * 216.0f) > 30.0f)) { func_8001CA24(player, 3.0f); } player->unk_046 |= 0x10; @@ -1889,8 +1890,8 @@ void func_8002C954(Player* player, s8 playerId, Vec3f arg2) { if (player->unk_256 >= 0xA) { player->unk_256 = 0; } - if ((player->slopeAccel >= 0) && (((player->unk_094 / 18.0f) * 216.0f) > 5.0f)) { - decelerate_ai_player(player, 18.0f); + if ((player->slopeAccel >= 0) && (((player->speed / 18.0f) * 216.0f) > 5.0f)) { + decelerate_player(player, 18.0f); } if ((player->type & PLAYER_HUMAN) == PLAYER_HUMAN) { xdist = D_80165070[playerId][0] - arg2[0]; @@ -1901,12 +1902,12 @@ void func_8002C954(Player* player, s8 playerId, Vec3f arg2) { if (var_f14 >= 1.0) { var_f14 = 1.0f; } - if ((var_f14 <= 0.6) && (((player->unk_094 / 18.0f) * 216.0f) >= 40.0f) && + if ((var_f14 <= 0.6) && (((player->speed / 18.0f) * 216.0f) >= 40.0f) && (!(player->type & PLAYER_INVISIBLE_OR_BOMB))) { func_800CAEC4(playerId, 0.6F); } else if (!(player->type & PLAYER_INVISIBLE_OR_BOMB)) { - if ((var_f14 <= 0.6) && (((player->unk_094 / 18.0f) * 216.0f) < 40.0f) && - (((player->unk_094 / 18.0f) * 216.0f) >= 10.0f)) { + if ((var_f14 <= 0.6) && (((player->speed / 18.0f) * 216.0f) < 40.0f) && + (((player->speed / 18.0f) * 216.0f) >= 10.0f)) { func_800CAEC4(playerId, 0.3F); } else { func_800CAEC4(playerId, var_f14); @@ -1944,7 +1945,7 @@ void apply_effect(Player* player, s8 arg1, s8 arg2) { if ((player->effects & LIGHTNING_EFFECT) == LIGHTNING_EFFECT) { apply_lightning_effect(player, arg1); } - if ((player->effects & 0x10000) == 0x10000) { + if ((player->effects & UNKNOWN_EFFECT_0x10000) == UNKNOWN_EFFECT_0x10000) { func_8008F3F4(player, arg1); } if ((player->effects & STAR_EFFECT) == STAR_EFFECT) { @@ -1954,7 +1955,7 @@ void apply_effect(Player* player, s8 arg1, s8 arg2) { apply_boo_effect(player, arg1); } if (((player->effects & 0x20000000) == 0x20000000) && (player->unk_228 >= 0x64)) { - decelerate_ai_player(player, 4.0f); + decelerate_player(player, 4.0f); } if (((player->effects & 0x80) == 0x80) || ((player->effects & 0x40) == 0x40)) { func_8008C9EC(player, arg1); @@ -1962,7 +1963,7 @@ void apply_effect(Player* player, s8 arg1, s8 arg2) { if ((player->effects & 0x400) == 0x400) { func_8008C62C(player, arg1); } - if ((player->effects & 0x01000000) == 0x01000000) { + if ((player->effects & UNKNOWN_EFFECT_0x1000000) == UNKNOWN_EFFECT_0x1000000) { func_8008E4A4(player, arg1); } if ((player->effects & HIT_BY_ITEM_EFFECT) == HIT_BY_ITEM_EFFECT) { @@ -1976,7 +1977,7 @@ void apply_effect(Player* player, s8 arg1, s8 arg2) { } if ((player->effects & 0x800000) == 0x800000) { func_8008D8B4(player, arg1); - decelerate_ai_player(player, 10.0f); + decelerate_player(player, 10.0f); } if (D_800DC510 != 5) { if (player->soundEffects & 0x04000000) { @@ -2018,7 +2019,7 @@ void func_8002D028(Player* player, s8 arg1) { } temp_t1 = (D_80165020[arg1] + ((s16) ((temp * 0x35) / (thing0 * 182)))) / 2; - func_8003680C(player, (s16) temp_t1); + apply_cpu_turn(player, (s16) temp_t1); D_80165020[arg1] = (s16) temp_t1; temp_f18 = sqrtf((sp4C[0] - player->pos[0]) * (sp4C[0] - player->pos[0]) + @@ -2029,7 +2030,7 @@ void func_8002D028(Player* player, s8 arg1) { player->type &= ~0x0200; } player->unk_08C = 0; - player->unk_094 = 0; + player->speed = 0; player->unk_104 = 0; player->unk_240 = 0; player->unk_07C = 0; @@ -2101,7 +2102,7 @@ void func_8002D268(Player* player, UNUSED Camera* camera, s8 screenId, s8 player spAC = (-1 * (player->unk_064[2] + sp16C[2])) + ((-player->collision.orientationVector[2] * player->kartGravity) * 0.925); } else { - temp3 = (((player->unk_094 / 18.0f) * 216.0f) / 10.0f); + temp3 = (((player->speed / 18.0f) * 216.0f) / 10.0f); if (temp3 >= 10) { temp3 = 10; } @@ -2241,8 +2242,7 @@ void func_8002D268(Player* player, UNUSED Camera* camera, s8 screenId, s8 player player->unk_044 |= 0x100; } } - if (((player->unk_0C2 < 0x23) && (player->unk_0C2 >= 0x1C)) && - (((player->unk_094 / 18.0f) * 216.0f) >= 20.0f)) { + if (((player->unk_0C2 < 0x23) && (player->unk_0C2 >= 0x1C)) && (((player->speed / 18.0f) * 216.0f) >= 20.0f)) { player->unk_DB4.unkC = 2.8f; player->unk_DB4.unk18 = 0; if (((player->type & PLAYER_HUMAN) == PLAYER_HUMAN) && @@ -2253,7 +2253,7 @@ void func_8002D268(Player* player, UNUSED Camera* camera, s8 screenId, s8 player player->unk_044 |= 0x100; } } - if (((player->unk_0C2 < 0x1C) && (player->unk_0C2 >= 4)) && (((player->unk_094 / 18.0f) * 216.0f) >= 20.0f)) { + if (((player->unk_0C2 < 0x1C) && (player->unk_0C2 >= 4)) && (((player->speed / 18.0f) * 216.0f) >= 20.0f)) { player->unk_DB4.unk18 = 0; player->unk_DB4.unkC = 1.5f; if (((player->type & PLAYER_HUMAN) == PLAYER_HUMAN) && @@ -2296,12 +2296,12 @@ void func_8002D268(Player* player, UNUSED Camera* camera, s8 screenId, s8 player } } if (((!(player->effects & 8)) && (func_802ABDB8(player->collision.meshIndexZX) != 0)) && - ((player->effects & 0x10000) != 0x10000)) { + ((player->effects & UNKNOWN_EFFECT_0x10000) != UNKNOWN_EFFECT_0x10000)) { if ((!(player->unk_0CA & 2)) || (!(player->unk_0CA & 8))) { func_8008F494(player, playerId); } } else if (((!(player->effects & 8)) && (func_802ABDB8(player->collision.meshIndexZX) == 0)) && - (player->effects & 0x10000)) { + (player->effects & UNKNOWN_EFFECT_0x10000)) { func_8008F5A4(player, playerId); } player->unk_074 = calculate_surface_height(nextX, nextY, nextZ, player->collision.meshIndexZX); @@ -2315,10 +2315,10 @@ void func_8002D268(Player* player, UNUSED Camera* camera, s8 screenId, s8 player func_8002AE38(player, playerId, posX, posZ, nextX, nextZ); temp2 = (sp98[0] * sp98[0]) + (sp98[2] * sp98[2]); - player->unk_22C = player->unk_094; - player->unk_094 = sqrtf(temp2); + player->previousSpeed = player->speed; + player->speed = sqrtf(temp2); - if ((player->unk_08C <= 0.0f) && (player->unk_094 <= 0.08) && (D_8018CE10[playerId].unk_04[0] == 0.0f) && + if ((player->unk_08C <= 0.0f) && (player->speed <= 0.08) && (D_8018CE10[playerId].unk_04[0] == 0.0f) && (D_8018CE10[playerId].unk_04[2] == 0.0f)) { sp98[0] = sp98[0] + (-1 * sp98[0]); sp98[2] = sp98[2] + (-1 * sp98[2]); @@ -2327,7 +2327,7 @@ void func_8002D268(Player* player, UNUSED Camera* camera, s8 screenId, s8 player player->pos[2] = nextZ; } player->pos[1] = nextY; - if ((player->type & PLAYER_HUMAN) && (!(player->type & PLAYER_KART_AI))) { + if ((player->type & PLAYER_HUMAN) && (!(player->type & PLAYER_CPU))) { func_8002BB9C(player, &nextX, &nextZ, screenId, playerId, sp98); } player->unk_064[0] = sp178[0]; @@ -2339,21 +2339,21 @@ void func_8002D268(Player* player, UNUSED Camera* camera, s8 screenId, s8 player D_80165070[playerId][1] = sp98[1]; D_80165070[playerId][2] = sp98[2]; if ((player->type & PLAYER_HUMAN) == PLAYER_HUMAN) { - if (gKartTopSpeedTable[player->characterId] < player->unk_094) { - temp = gKartTopSpeedTable[player->characterId] / player->unk_094; + if (gKartTopSpeedTable[player->characterId] < player->speed) { + temp = gKartTopSpeedTable[player->characterId] / player->speed; player->velocity[0] *= temp; player->velocity[1] *= temp; player->velocity[2] *= temp; - player->unk_094 = gKartTopSpeedTable[player->characterId]; + player->speed = gKartTopSpeedTable[player->characterId]; } } if ((player->unk_044 & 1) == 1) { - if (player->unk_094 > 1) { - temp = 1 / player->unk_094; + if (player->speed > 1) { + temp = 1 / player->speed; player->velocity[0] *= temp; player->velocity[1] *= temp; player->velocity[2] *= temp; - player->unk_094 = 1; + player->speed = 1; } } if (player->collision.surfaceDistance[2] >= 500.0f) { @@ -2369,10 +2369,10 @@ void func_8002E4C4(Player* player) { player->kartHopJerk = 0.0f; player->kartHopAcceleration = 0.0f; player->kartHopVelocity = 0.0f; - player->pos[1] = - get_surface_height(player->pos[0], D_80164510[player_index] + 10.0f, player->pos[2]) + player->boundingBoxSize; - if (((player->pos[1] - D_80164510[player_index]) > 1200.0f) || - ((player->pos[1] - D_80164510[player_index]) < -1200.0f)) { + player->pos[1] = get_surface_height(player->pos[0], gPlayerPathY[player_index] + 10.0f, player->pos[2]) + + player->boundingBoxSize; + if (((player->pos[1] - gPlayerPathY[player_index]) > 1200.0f) || + ((player->pos[1] - gPlayerPathY[player_index]) < -1200.0f)) { player->pos[1] = player->oldPos[1]; } player->velocity[1] = 0.0f; @@ -2444,7 +2444,7 @@ void func_8002E594(Player* player, UNUSED Camera* camera, s8 screenId, s8 player sp54[1] = player->velocity[1]; sp54[2] = player->velocity[2]; if ((player->unk_10C < 3) && ((player->unk_256) < 3) && ((player->effects & 0x400) != 0x400) && - ((player->effects & 0x01000000) != 0x01000000) && + ((player->effects & UNKNOWN_EFFECT_0x1000000) != UNKNOWN_EFFECT_0x1000000) && ((player->effects & HIT_BY_ITEM_EFFECT) != HIT_BY_ITEM_EFFECT)) { sp54[0] += (((((spEC[0] + sp80) + spD4[0])) - (sp54[0] * (0.12 * player->kartFriction))) / 6000) / ((player->unk_20C * 5.0f) + 1.0f); @@ -2487,7 +2487,8 @@ void func_8002E594(Player* player, UNUSED Camera* camera, s8 screenId, s8 player if (sp74 <= 0.0f) { player->effects &= ~2; player->effects &= ~8; - if ((((player->effects & 0x400) != 0x400) && ((player->effects & 0x01000000) != 0x01000000)) && + if ((((player->effects & 0x400) != 0x400) && + ((player->effects & UNKNOWN_EFFECT_0x1000000) != UNKNOWN_EFFECT_0x1000000)) && ((player->effects & HIT_BY_ITEM_EFFECT) != HIT_BY_ITEM_EFFECT)) { if (player->unk_0C2 >= 0x1C) { if (player->unk_0C2 >= 0x32) { @@ -2505,7 +2506,7 @@ void func_8002E594(Player* player, UNUSED Camera* camera, s8 screenId, s8 player } } if (((player->unk_0C2 < 0x1C) && (player->unk_0C2 >= 0xA)) && - (((player->unk_094 / 18.0f) * 216.0f) >= 20.0f)) { + (((player->speed / 18.0f) * 216.0f) >= 20.0f)) { player->unk_DB4.unkC = 2.0f; player->unk_DB4.unk18 = 0; if (((player->type & PLAYER_HUMAN) == PLAYER_HUMAN) && @@ -2555,13 +2556,13 @@ void func_8002E594(Player* player, UNUSED Camera* camera, s8 screenId, s8 player if (sp74 < 0.0f) { func_8003F734(player, sp48, sp54, &sp74, &spD0, &spCC, &spC8); func_8002C954(player, playerId, sp54); - decelerate_ai_player(player, 6.0f); + decelerate_player(player, 6.0f); } sp74 = player->collision.surfaceDistance[1]; if (sp74 < 0.0f) { func_8003FBAC(player, sp48, sp54, &sp74, &spD0, &spCC, &spC8); func_8002C954(player, playerId, sp54); - decelerate_ai_player(player, 6.0f); + decelerate_player(player, 6.0f); } sp74 = player->collision.surfaceDistance[0]; if (sp74 >= 0.0f) { @@ -2576,13 +2577,14 @@ void func_8002E594(Player* player, UNUSED Camera* camera, s8 screenId, s8 player } } } - if (((func_802ABDB8(player->collision.meshIndexZX) != 0) && ((player->effects & 0x10000) != 0x10000)) && - (((player->unk_094 / 18.0f) * 216.0f) >= 20.0f)) { + if (((func_802ABDB8(player->collision.meshIndexZX) != 0) && + ((player->effects & UNKNOWN_EFFECT_0x10000) != UNKNOWN_EFFECT_0x10000)) && + (((player->speed / 18.0f) * 216.0f) >= 20.0f)) { if ((!(player->unk_0CA & 2)) || (!(player->unk_0CA & 8))) { func_8008F494(player, playerId); } } else if (((!(player->effects & 8)) && (func_802ABDB8(player->collision.meshIndexZX) == 0)) && - (player->effects & 0x10000)) { + (player->effects & UNKNOWN_EFFECT_0x10000)) { func_8008F5A4(player, playerId); } player->unk_074 = calculate_surface_height(spD0, spCC, spC8, player->collision.meshIndexZX); @@ -2595,10 +2597,10 @@ void func_8002E594(Player* player, UNUSED Camera* camera, s8 screenId, s8 player } func_8002AE38(player, playerId, posX, posZ, spD0, spC8); temp = (sp54[0] * sp54[0]) + (sp54[2] * sp54[2]); - player->unk_22C = player->unk_094; - player->unk_094 = sqrtf(temp); - if ((((player->effects & 0x400) != 0x400) && (player->unk_08C <= 0) && (player->unk_094 < 0.13)) || - (((player->effects & 0x400) != 0x400) && (player->unk_08C <= 0) && (player->unk_094 < 0.20) && + player->previousSpeed = player->speed; + player->speed = sqrtf(temp); + if ((((player->effects & 0x400) != 0x400) && (player->unk_08C <= 0) && (player->speed < 0.13)) || + (((player->effects & 0x400) != 0x400) && (player->unk_08C <= 0) && (player->speed < 0.20) && ((player->effects & 1) == 1))) { sp54[0] = sp54[0] + (-1 * sp54[0]); sp54[2] = sp54[2] + (-1 * sp54[2]); @@ -2613,18 +2615,18 @@ void func_8002E594(Player* player, UNUSED Camera* camera, s8 screenId, s8 player player->velocity[1] = sp54[1]; player->velocity[2] = sp54[2]; if ((player->type & PLAYER_HUMAN) == PLAYER_HUMAN) { - if (gKartTopSpeedTable[player->characterId] < player->unk_094) { - temp_f0_6 = gKartTopSpeedTable[player->characterId] / player->unk_094; + if (gKartTopSpeedTable[player->characterId] < player->speed) { + temp_f0_6 = gKartTopSpeedTable[player->characterId] / player->speed; player->velocity[0] *= temp_f0_6; player->velocity[1] *= temp_f0_6; player->velocity[2] *= temp_f0_6; - player->unk_094 = gKartTopSpeedTable[player->characterId]; + player->speed = gKartTopSpeedTable[player->characterId]; } } func_8002C4F8(player, playerId); } -void control_kart_ai_movement(Player* player, UNUSED Camera* camera, s8 arg2, s8 playerId) { +void control_cpu_movement(Player* player, UNUSED Camera* camera, s8 arg2, s8 playerId) { Vec3f spF4 = { 0.0f, 0.0f, 1.0f }; UNUSED Vec3f spE8 = { 0.0f, 0.0f, 0.0f }; Vec3f spDC = { 0.0f, 0.0f, 0.0f }; @@ -2642,9 +2644,9 @@ void control_kart_ai_movement(Player* player, UNUSED Camera* camera, s8 arg2, s8 f32 toSqrt; f32 temp_f0_2; f32 test; - player->effects |= 0x1000; + player->effects |= UNKNOWN_EFFECT_0x1000; player->unk_044 |= 0x10; - test = D_80164510[playerId]; + test = gPlayerPathY[playerId]; player->unk_204 = 0; player->effects &= ~0x10; func_8002B830(player, playerId, arg2); @@ -2678,8 +2680,8 @@ void control_kart_ai_movement(Player* player, UNUSED Camera* camera, s8 arg2, s8 player->slopeAccel = 0; player->unk_206 = 0; toSqrt = (sp68[0] * sp68[0]) + (sp68[2] * sp68[2]); - player->unk_22C = player->unk_094; - player->unk_094 = sqrtf(toSqrt); + player->previousSpeed = player->speed; + player->speed = sqrtf(toSqrt); player->pos[0] = spCC; player->pos[2] = spC4; player->pos[1] = test; @@ -2691,12 +2693,12 @@ void control_kart_ai_movement(Player* player, UNUSED Camera* camera, s8 arg2, s8 D_80165070[playerId][0] = sp68[0]; D_80165070[playerId][1] = sp68[1]; D_80165070[playerId][2] = sp68[2]; - if (gKartTopSpeedTable[player->characterId] < player->unk_094) { - temp_f0_2 = gKartTopSpeedTable[player->characterId] / player->unk_094; + if (gKartTopSpeedTable[player->characterId] < player->speed) { + temp_f0_2 = gKartTopSpeedTable[player->characterId] / player->speed; player->velocity[0] *= temp_f0_2; player->velocity[1] *= temp_f0_2; player->velocity[2] *= temp_f0_2; - player->unk_094 = gKartTopSpeedTable[player->characterId]; + player->speed = gKartTopSpeedTable[player->characterId]; } } @@ -2775,10 +2777,10 @@ void func_8002F730(Player* player, UNUSED Camera* camera, UNUSED s8 screenId, s8 } func_8002AE38(player, playerId, spC0, spB8, spCC, spC4); sqrt = (sp68[0] * sp68[0]) + (sp68[1] * sp68[1]) + (sp68[2] * sp68[2]); - player->unk_22C = player->unk_094; - player->unk_094 = sqrtf(sqrt); - if (((player->unk_08C <= 0.0f) && ((f64) player->unk_094 < 0.13)) || - ((player->unk_08C <= 0.0f) && ((f64) player->unk_094 < 0.2) && ((player->effects & 1) == 1))) { + player->previousSpeed = player->speed; + player->speed = sqrtf(sqrt); + if (((player->unk_08C <= 0.0f) && ((f64) player->speed < 0.13)) || + ((player->unk_08C <= 0.0f) && ((f64) player->speed < 0.2) && ((player->effects & 1) == 1))) { sp68[0] = sp68[0] + (sp68[0] * -1.0f); sp68[2] = sp68[2] + (sp68[2] * -1.0f); } else { @@ -2799,12 +2801,12 @@ void func_8002F730(Player* player, UNUSED Camera* camera, UNUSED s8 screenId, s8 D_80165070[playerId][2] = sp68[2]; if ((player->type & PLAYER_HUMAN) == PLAYER_HUMAN) { - if (gKartTopSpeedTable[player->characterId] < player->unk_094) { - temp_f0_2 = gKartTopSpeedTable[player->characterId] / player->unk_094; + if (gKartTopSpeedTable[player->characterId] < player->speed) { + temp_f0_2 = gKartTopSpeedTable[player->characterId] / player->speed; player->velocity[0] *= temp_f0_2; player->velocity[1] *= temp_f0_2; player->velocity[2] *= temp_f0_2; - player->unk_094 = gKartTopSpeedTable[player->characterId]; + player->speed = gKartTopSpeedTable[player->characterId]; } } } @@ -2907,7 +2909,7 @@ f32 func_80030150(Player* player, s8 arg1) { s32 var_v0; var_f0 = 0.0f; - var_f2 = (player->unk_094 / 18.0f) * 216.0f; + var_f2 = (player->speed / 18.0f) * 216.0f; if (var_f2 >= 8.0f) { if ((player->effects & STAR_EFFECT) != STAR_EFFECT) { if ((s32) player->tyres[BACK_RIGHT].surfaceType >= 0xF) { @@ -2943,7 +2945,7 @@ f32 func_80030150(Player* player, s8 arg1) { var_f0 += -0.55; } } - if (((player->effects & 0x10) == 0x10) || (player->unk_204 > 0)) { + if (((player->effects & UNKNOWN_EFFECT_0x10) == UNKNOWN_EFFECT_0x10) || (player->unk_204 > 0)) { var_v0 = (s16) player->unk_0C0 / 182; if (var_v0 < 0) { var_f0 += -var_v0 * 0.004; @@ -3003,7 +3005,8 @@ f32 func_80030150(Player* player, s8 arg1) { } } if ((player->type & PLAYER_HUMAN) == PLAYER_HUMAN) { - if (((player->effects & 0x100) == 0x100) && ((player->effects & 0x10) != 0x10)) { + if (((player->effects & UNKNOWN_EFFECT_0x100) == UNKNOWN_EFFECT_0x100) && + ((player->effects & UNKNOWN_EFFECT_0x10) != UNKNOWN_EFFECT_0x10)) { move_f32_towards(&player->unk_0E8, 580.0f, 0.2f); } else { move_f32_towards(&player->unk_0E8, 0.0f, 0.01f); @@ -3024,7 +3027,7 @@ f32 func_80030150(Player* player, s8 arg1) { return (1.0f - player->unk_104) * var_f2; } if (((player->effects & 0x80) == 0x80) || ((player->effects & 0x40) == 0x40) || - ((player->effects & 0x01000000) == 0x01000000) || + ((player->effects & UNKNOWN_EFFECT_0x1000000) == UNKNOWN_EFFECT_0x1000000) || ((player->effects & HIT_BY_ITEM_EFFECT) == HIT_BY_ITEM_EFFECT)) { return (1.0f - player->unk_104) * var_f2; } @@ -3044,7 +3047,7 @@ void func_80030A34(Player* player) { f32 var_f2; if (((player->unk_0CA & 2) != 2) && ((player->unk_0CA & 8) != 8)) { - if ((((player->unk_094 / 18.0f) * 216.0f) >= 8.0f) && (player->unk_DB4.unkC < 1.0f)) { + if ((((player->speed / 18.0f) * 216.0f) >= 8.0f) && (player->unk_DB4.unkC < 1.0f)) { switch (player->surfaceType) { /* irregular */ case ASPHALT: if (random_int(0x000AU) != 8) { @@ -3208,7 +3211,7 @@ void detect_triple_a_combo_a_pressed(Player* player) { } } -void player_speed(Player* player) { +void player_accelerate(Player* player) { s32 player_index; player_index = get_player_index_for_player(player); @@ -3321,7 +3324,7 @@ void player_speed(Player* player) { } } -void decelerate_ai_player(Player* player, f32 speed) { +void decelerate_player(Player* player, f32 speed) { s32 player_index; player_index = get_player_index_for_player(player); @@ -3329,7 +3332,7 @@ void decelerate_ai_player(Player* player, f32 speed) { if (player->currentSpeed <= 0.0f) { player->currentSpeed = 0.0f; } - if (player->unk_094 < 0.2) { + if (player->speed < 0.2) { player->unk_08C = 0.0f; } if (player->topSpeed <= player->currentSpeed) { @@ -3500,7 +3503,7 @@ void func_800323E4(Player* player) { player->effects |= 1; // This check will never be true, why is it here? if ((player->effects & 0x20) == 0x20) { - decelerate_ai_player(player, 1.0f); + decelerate_player(player, 1.0f); player->unk_20C = var_f2; } else { if ((s32) player->tyres[BACK_RIGHT].surfaceType < 0xF) { @@ -3509,7 +3512,7 @@ void func_800323E4(Player* player) { if ((s32) player->tyres[BACK_LEFT].surfaceType < 0xF) { var_f2 += D_800E3210[player->characterId][player->tyres[BACK_LEFT].surfaceType]; } - test = player->unk_22C - player->unk_094; + test = player->previousSpeed - player->speed; if (test <= 0.0f) { player->unk_20C = 0.0f; } else { @@ -3520,18 +3523,18 @@ void func_800323E4(Player* player) { } if (gIsPlayerTripleBButtonCombo[var_v1] == true) { if (player->unk_20C >= 2.0f) { - decelerate_ai_player(player, (1.0f - var_f2) * 5.0f); + decelerate_player(player, (1.0f - var_f2) * 5.0f); } else { - decelerate_ai_player(player, (1.0f - var_f2) * 3.0f); + decelerate_player(player, (1.0f - var_f2) * 3.0f); } } else { - if (((player->unk_094 / 18.0f) * 216.0f) <= 20.0f) { - decelerate_ai_player(player, (1.0f - var_f2) * 4.0f); + if (((player->speed / 18.0f) * 216.0f) <= 20.0f) { + decelerate_player(player, (1.0f - var_f2) * 4.0f); } if (player->unk_20C >= 2.0f) { - decelerate_ai_player(player, (1.0f - var_f2) * 2.5); + decelerate_player(player, (1.0f - var_f2) * 2.5); } else { - decelerate_ai_player(player, (1.0f - var_f2) * 1.2); + decelerate_player(player, (1.0f - var_f2) * 1.2); } } } @@ -3598,7 +3601,7 @@ void func_80032CB0(Player* player, f32 arg1) { if (player->currentSpeed <= 0.0f) { player->currentSpeed = 0.0f; } - if (player->unk_094 < 0.2) { + if (player->speed < 0.2) { player->unk_08C = 0.0f; } if (player->topSpeed <= player->currentSpeed) { @@ -3822,7 +3825,7 @@ void func_80033AE0(Player* player, struct Controller* controller, s8 arg2) { if (((((player->effects & 2) != 2) && ((((player->unk_0C0 / 182) <= 6) && ((player->unk_0C0 / 182) >= (-6))) || ((controller->button & R_TRIG) != R_TRIG))) || - (((player->unk_094 / 18.0f) * 216.0f) <= 20.0f)) || + (((player->speed / 18.0f) * 216.0f) <= 20.0f)) || ((player->effects & 0x8000) == 0x8000)) { func_80036CB4(player); } @@ -3838,7 +3841,7 @@ void func_80033AE0(Player* player, struct Controller* controller, s8 arg2) { player->unk_044 &= 0xFFF9; D_801652C0[arg2] = 0; } - if (((player->effects & 2) == 2) || ((player->effects & 0x10) == 0x10)) { + if (((player->effects & 2) == 2) || ((player->effects & UNKNOWN_EFFECT_0x10) == UNKNOWN_EFFECT_0x10)) { player->unk_044 &= 0xFFF9; } sp2E4 = player->unk_07C; @@ -3851,9 +3854,10 @@ void func_80033AE0(Player* player, struct Controller* controller, s8 arg2) { sp2D0 = sp2D0 >> 16; player->unk_0FA = (s16) sp2D0; if (((sp2D0 >= 0x5A) || (sp2D0 < (-0x59))) && (!(player->unk_044 & 0x4000))) { - if ((((((!(player->effects & 0x10)) && (gCCSelection == CC_150)) && (gModeSelection != BATTLE)) && + if ((((((!(player->effects & UNKNOWN_EFFECT_0x10)) && (gCCSelection == CC_150)) && + (gModeSelection != BATTLE)) && (!(player->effects & 8))) && - (((player->unk_094 / 18.0f) * 216.0f) >= 40.0f)) && + (((player->speed / 18.0f) * 216.0f) >= 40.0f)) && (player->unk_204 == 0)) { player->soundEffects |= 0x80; } @@ -3868,12 +3872,12 @@ void func_80033AE0(Player* player, struct Controller* controller, s8 arg2) { sp2C8 = 10; sp2CC = 10; } else { - if (((player->effects & 0x10) == 0x10) && ((player->effects & 2) != 2)) { + if (((player->effects & UNKNOWN_EFFECT_0x10) == UNKNOWN_EFFECT_0x10) && ((player->effects & 2) != 2)) { var_a0 = 3; } else { var_a0 = 0; } - if (((player->unk_094 / 18.0f) * 216.0f) >= 15.0f) { + if (((player->speed / 18.0f) * 216.0f) >= 15.0f) { if ((player->unk_044 & 2) == 2) { if ((sp2D0 < 36) && (sp2D0 >= 0)) { sp2C8 = @@ -4007,9 +4011,9 @@ void func_80033AE0(Player* player, struct Controller* controller, s8 arg2) { 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); - if ((player->effects & 0x10) == 0x10) { + if ((player->effects & UNKNOWN_EFFECT_0x10) == UNKNOWN_EFFECT_0x10) { var_f2_2 = (f32) (((s32) (sp2E4 >> 16)) / 8); - } else if (((player->unk_094 / 18.0f) * 216.0f) <= 25.0f) { + } else if (((player->speed / 18.0f) * 216.0f) <= 25.0f) { var_f2_2 = (f32) ((sp2E4 >> 16) / 12); } else { var_f2_2 = ((f32) (sp2E4 >> 0x10)) / (8.0f + (player->currentSpeed / 50.0f)); @@ -4018,11 +4022,11 @@ void func_80033AE0(Player* player, struct Controller* controller, s8 arg2) { var_f2_2 = -var_f2_2; } if ((player->effects & 0x20) == 0x20) { - var_f2_2 = var_f2_2 * (sp44[((s16) ((player->unk_094 / 18.0f) * 216.0f)) + 10] * 1.5f); - } else if ((player->effects & 0x10) == 0x10) { - var_f2_2 = var_f2_2 * sp44[(s16) ((player->unk_094 / 18.0f) * 216.0f)]; + var_f2_2 = var_f2_2 * (sp44[((s16) ((player->speed / 18.0f) * 216.0f)) + 10] * 1.5f); + } else if ((player->effects & UNKNOWN_EFFECT_0x10) == UNKNOWN_EFFECT_0x10) { + var_f2_2 = var_f2_2 * sp44[(s16) ((player->speed / 18.0f) * 216.0f)]; } else { - var_f2_2 = var_f2_2 * (sp44[(s16) ((player->unk_094 / 18.0f) * 216.0f)] * 1.5f); + var_f2_2 = var_f2_2 * (sp44[(s16) ((player->speed / 18.0f) * 216.0f)] * 1.5f); } player->unk_07C = sp2E4; if (player->unk_10C != 0) { @@ -4037,11 +4041,11 @@ void func_80033AE0(Player* player, struct Controller* controller, s8 arg2) { if (((s32) player->tyres[BACK_LEFT].surfaceType) < 0xF) { var_f12 += D_800E3410[player->characterId][player->tyres[BACK_LEFT].surfaceType]; } - if (((player->effects & 2) != 2) && ((player->effects & 0x10) != 0x10)) { + if (((player->effects & 2) != 2) && ((player->effects & UNKNOWN_EFFECT_0x10) != UNKNOWN_EFFECT_0x10)) { if ((player->effects & 0x20) == 0x20) { player->unk_078 = (s16) ((s32) (((f32) ((((s32) player->unk_07C) >> 0x10) * 5)) * var_f2_2)); } else { - if ((player->effects & 0x1) != 0x1) { + if ((player->effects & UNKNOWN_EFFECT_0x1) != UNKNOWN_EFFECT_0x1) { if (((player->unk_07C >> 16) >= 45) || ((player->unk_07C >> 16) <= (-45))) { player->unk_078 = ((player->unk_07C >> 16) * (var_f2_2 + (var_f2_2 * var_f12))) * (0.15 + gKartHandlingTable[player->characterId]); @@ -4050,13 +4054,13 @@ void func_80033AE0(Player* player, struct Controller* controller, s8 arg2) { gKartHandlingTable[player->characterId]; } } else { - if ((((player->unk_094 / 18.0f) * 216.0f) >= 0.0f) && (((player->unk_094 / 18.0f) * 216.0f) < 8.0f)) { + if ((((player->speed / 18.0f) * 216.0f) >= 0.0f) && (((player->speed / 18.0f) * 216.0f) < 8.0f)) { player->unk_078 = (player->unk_07C >> 16) * (var_f2_2 + (var_f2_2 * var_f12)); } - if ((((player->unk_094 / 18.0f) * 216.0f) >= 8.0f) && (((player->unk_094 / 18.0f) * 216.0f) < 65.0f)) { + if ((((player->speed / 18.0f) * 216.0f) >= 8.0f) && (((player->speed / 18.0f) * 216.0f) < 65.0f)) { player->unk_078 = (player->unk_07C >> 16) * ((var_f2_2 + 1.5) + (var_f2_2 * var_f12)); } - if (((player->unk_094 / 18.0f) * 216.0f) >= 65.0f) { + if (((player->speed / 18.0f) * 216.0f) >= 65.0f) { player->unk_078 = (player->unk_07C >> 16) * ((var_f2_2 + 1.6) + (var_f2_2 * var_f12)); } } @@ -4085,13 +4089,13 @@ void func_80033AE0(Player* player, struct Controller* controller, s8 arg2) { } func_8002A8A4(player, arg2); } - if ((((player->unk_094 / 18.0f) * 216.0f) >= 0.0f) && (((player->unk_094 / 18.0f) * 216.0f) < 8.0f)) { + if ((((player->speed / 18.0f) * 216.0f) >= 0.0f) && (((player->speed / 18.0f) * 216.0f) < 8.0f)) { player->unk_078 = (s16) ((s32) (var_s1_2 * ((var_f2_2 + 2.0f) + (var_f2_2 * var_f12)))); } - if ((((player->unk_094 / 18.0f) * 216.0f) >= 8.0f) && (((player->unk_094 / 18.0f) * 216.0f) < 65.0f)) { + if ((((player->speed / 18.0f) * 216.0f) >= 8.0f) && (((player->speed / 18.0f) * 216.0f) < 65.0f)) { player->unk_078 = var_s1_2 * ((var_f2_2 + 3) + (var_f2_2 * var_f12)); } - if (((player->unk_094 / 18.0f) * 216.0f) >= 65.0f) { + if (((player->speed / 18.0f) * 216.0f) >= 65.0f) { player->unk_078 = var_s1_2 * ((((f64) var_f2_2) + 3.5) + (var_f2_2 * var_f12)); } if ((player->effects & 0x20000000) == 0x20000000) { @@ -4104,7 +4108,7 @@ void func_80033AE0(Player* player, struct Controller* controller, s8 arg2) { if (temp_v0_3 == 0) { var_s1_2 = 0; } - if (((player->unk_094 / 18.0f) * 216.0f) <= 5.0f) { + if (((player->speed / 18.0f) * 216.0f) <= 5.0f) { player->unk_078 = (s16) ((s32) (((f32) var_s1_2) * (var_f2_2 + 6.0f))); } else { player->unk_078 = ((s16) var_s1_2) * (var_f2_2 + 1.5f); @@ -4115,12 +4119,12 @@ void func_80033AE0(Player* player, struct Controller* controller, s8 arg2) { } } -void func_8003680C(Player* player, s16 arg1) { +void apply_cpu_turn(Player* player, s16 targetAngle) { s32 sp304 = 0; UNUSED f32 pad[6]; f32 var_f0; s16 var_v0; - f32 sp44[168] = { + f32 speedTurn[168] = { 0.0f, 0.1f, 0.1f, 0.2f, 0.3f, 0.4f, 0.5f, 0.6f, 0.6f, 0.6f, 0.6f, 0.6f, 0.7f, 0.7f, 0.7f, 0.7f, 0.7f, 0.7f, 0.7f, 0.6f, 0.5f, 0.4f, 0.4f, 0.4f, 0.4f, 0.4f, 0.4f, 0.4f, 0.4f, 0.4f, 0.4f, 0.4f, 0.4f, 0.4f, 0.4f, 0.4f, 0.5f, 0.5f, 0.5f, 0.5f, 0.6f, 0.6f, 0.6f, 0.6f, 0.6f, 0.6f, 0.6f, 0.6f, 0.6f, 0.6f, 0.7f, @@ -4132,21 +4136,22 @@ void func_8003680C(Player* player, s16 arg1) { 0.6f, 0.6f, 0.6f, 0.6f, 0.6f, 0.6f, 0.6f, 0.6f, 0.6f, 0.6f, 0.6f, 0.6f, 0.6f, 0.6f, 0.6f, 0.6f, 0.6f, 0.6f, 0.6f, 0.6f, 0.6f, 0.6f, 0.6f, 0.6f, 0.6f, 0.6f, 0.6f, 0.6f, 0.6f, 0.6f, 0.6f, 0.6f, }; - f32 sp24[8] = { + f32 characterTurn[8] = { 3.0f, 3.0f, 3.0f, 3.0f, 3.0f, 3.0f, 3.0f, 3.0f, }; if (!((player->effects & 0x80) || (player->effects & 0x40) || (player->effects & 0x400) || - (player->effects & 0x10000) || (player->effects & 0x20000) || (player->effects & 0x01000000) || - (player->effects & HIT_BY_ITEM_EFFECT) || (player->effects & HIT_EFFECT))) { - if (!(((player->unk_094 / 18.0f) * 216.0f) >= 110.0f)) { + (player->effects & UNKNOWN_EFFECT_0x10000) || (player->effects & 0x20000) || + (player->effects & UNKNOWN_EFFECT_0x1000000) || (player->effects & HIT_BY_ITEM_EFFECT) || + (player->effects & HIT_EFFECT))) { + if (!(((player->speed / 18.0f) * 216.0f) >= 110.0f)) { player->effects &= ~0x20000000; player->unk_228 = 0; if (!(player->effects & 0x80) && !(player->effects & 0x40)) { sp304 = (s32) player->unk_07C >> 0x10; - move_s32_towards(&sp304, (s32) arg1, 0.35f); + move_s32_towards(&sp304, (s32) targetAngle, 0.35f); sp304 <<= 0x10; - if ((player->effects & 0x10) == 0x10) { + if ((player->effects & UNKNOWN_EFFECT_0x10) == UNKNOWN_EFFECT_0x10) { var_f0 = (sp304 >> 0x10) / 5; } else { var_f0 = (f32) (sp304 >> 0x10) / (8.0f + (player->currentSpeed / 50.0f)); @@ -4154,13 +4159,16 @@ void func_8003680C(Player* player, s16 arg1) { if (var_f0 < 0.0f) { var_f0 = -var_f0; } - if ((player->effects & 0x10) == 0x10) { - var_f0 = sp44[(s16) ((player->unk_094 / 18.0f) * 216.0f)] * var_f0; + + // Apply speed and character multipliers + if ((player->effects & UNKNOWN_EFFECT_0x10) == UNKNOWN_EFFECT_0x10) { + var_f0 = speedTurn[(s16) ((player->speed / 18.0f) * 216.0f)] * var_f0; } else { - var_f0 = sp44[(s16) ((player->unk_094 / 18.0f) * 216.0f)] * sp24[player->characterId] * var_f0; + var_f0 = speedTurn[(s16) ((player->speed / 18.0f) * 216.0f)] * characterTurn[player->characterId] * + var_f0; } player->unk_07C = sp304; - if (((player->effects & 2) != 2) && ((player->effects & 0x10) != 0x10)) { + if (((player->effects & 2) != 2) && ((player->effects & UNKNOWN_EFFECT_0x10) != UNKNOWN_EFFECT_0x10)) { if ((player->effects & 1) != 1) { player->unk_078 = (player->unk_07C >> 0x10) * var_f0; } else { @@ -4176,13 +4184,13 @@ void func_8003680C(Player* player, s16 arg1) { player->unk_078 *= 0.8; } else { var_v0 = (s16) ((s32) player->unk_07C >> 0x10); - if (arg1 == 0) { + if (targetAngle == 0) { var_v0 = 0; } player->unk_078 = var_v0 * var_f0; } if ((((player->effects & 2) != 2) && (player->unk_0C0 < 0x3D) && (player->unk_0C0 > -0x3D)) || - (((player->unk_094 / 18.0f) * 216.0f) <= 20.0f) || ((player->effects & 0x8000) == 0x8000)) { + (((player->speed / 18.0f) * 216.0f) <= 20.0f) || ((player->effects & 0x8000) == 0x8000)) { func_80036CB4(player); } } @@ -4191,9 +4199,9 @@ void func_8003680C(Player* player, s16 arg1) { } void func_80036C5C(Player* arg0) { - if (((arg0->unk_094 / 18.0f) * 216.0f) > 20.0f) { + if (((arg0->speed / 18.0f) * 216.0f) > 20.0f) { arg0->unk_204 = 0; - arg0->effects |= 0x10; + arg0->effects |= UNKNOWN_EFFECT_0x10; arg0->unk_0B6 |= 0x800; } } @@ -4201,7 +4209,8 @@ void func_80036C5C(Player* arg0) { void func_80036CB4(Player* player) { s32 test; - if (((player->effects & 0x10) == 0x10) && ((player->type & PLAYER_HUMAN) == PLAYER_HUMAN)) { + if (((player->effects & UNKNOWN_EFFECT_0x10) == UNKNOWN_EFFECT_0x10) && + ((player->type & PLAYER_HUMAN) == PLAYER_HUMAN)) { if ((player->unk_0C0 / 182) > 0) { test = ((((player->unk_07C >> 0x10) * 0xD) + 0x2B1) / 106) + 0x28; player->unk_07C = test << 0x10; @@ -4212,7 +4221,8 @@ void func_80036CB4(Player* player) { } player->effects &= ~0x10; } - if (((player->effects & 0x10) == 0x10) && ((player->type & PLAYER_HUMAN) != PLAYER_HUMAN)) { + if (((player->effects & UNKNOWN_EFFECT_0x10) == UNKNOWN_EFFECT_0x10) && + ((player->type & PLAYER_HUMAN) != PLAYER_HUMAN)) { player->effects &= ~0x10; } } @@ -4224,14 +4234,14 @@ void func_80036DB4(Player* player, Vec3f arg1, Vec3f arg2) { f32 var_f18; s32 temp_t6; - if (((player->effects & 0x1000) == 0x1000) || ((player->effects & 0x20) == 0x20)) { + if (((player->effects & UNKNOWN_EFFECT_0x1000) == UNKNOWN_EFFECT_0x1000) || ((player->effects & 0x20) == 0x20)) { arg1[0] = 0.0f; arg1[1] = 0.0f; arg1[2] = 0.0f; mtxf_translate_vec3f_mat3(arg1, player->orientationMatrix); } else { - if (((player->effects & 0x10) == 0x10) && ((player->effects & 2) != 2)) { - var_f18 = player->unk_208 + ((-(player->unk_094 / 18.0f) * 216.0f) * 3.0f) + (-player->unk_20C * 10.0f); + if (((player->effects & UNKNOWN_EFFECT_0x10) == UNKNOWN_EFFECT_0x10) && ((player->effects & 2) != 2)) { + var_f18 = player->unk_208 + ((-(player->speed / 18.0f) * 216.0f) * 3.0f) + (-player->unk_20C * 10.0f); sp20 = player->unk_084 * 3.0f; } else if (!(player->effects & 0x800) && !(player->unk_044 & 0x4000)) { thing = player->unk_0FA; @@ -4241,34 +4251,34 @@ void func_80036DB4(Player* player, Vec3f arg1, Vec3f arg2) { temp_t6 = player->unk_07C >> 0x10; if ((temp_t6 < 0x15) && (temp_t6 >= -0x14)) { if (thing < 0x14) { - var_f18 = (player->unk_208 + ((-(player->unk_094 / 18.0f) * 216.0f) / 3.0f)) + + var_f18 = (player->unk_208 + ((-(player->speed / 18.0f) * 216.0f) / 3.0f)) + (-player->currentSpeed * 0.02) + (-player->unk_20C * 50.0f); } else { - var_f18 = (player->unk_208 + ((-(player->unk_094 / 18.0f) * 216.0f) / 3.0f)) + + var_f18 = (player->unk_208 + ((-(player->speed / 18.0f) * 216.0f) / 3.0f)) + ((temp_t6 * 0.01) + (-player->currentSpeed * 0.05)) + (-player->unk_20C * 50.0f); } } else { - var_f18 = (player->unk_208 + ((-(player->unk_094 / 18.0f) * 216.0f) / 3.0f)) + + var_f18 = (player->unk_208 + ((-(player->speed / 18.0f) * 216.0f) / 3.0f)) + ((temp_t6 * 0.1) + (-player->currentSpeed * 0.15)) + (-player->unk_20C * 50.0f); } sp20 = player->unk_084; } else { - var_f18 = player->unk_208 + ((-(player->unk_094 / 18.0f) * 216.0f) * 1.5) + + var_f18 = player->unk_208 + ((-(player->speed / 18.0f) * 216.0f) * 1.5) + (((player->unk_07C >> 0x10) * 0.1) + (-player->currentSpeed * 0.05)) + (-player->unk_20C * 50.0f); sp20 = player->unk_084; } if ((player->effects & STAR_EFFECT) == STAR_EFFECT) { - if (((player->effects & 0x10) == 0x10) && ((player->effects & 2) != 2)) { - var_f18 = player->unk_208 + ((-(player->unk_094 / 18.0f) * 216.0f) * 3.0f) + (-player->unk_20C * 10.0f); + if (((player->effects & UNKNOWN_EFFECT_0x10) == UNKNOWN_EFFECT_0x10) && ((player->effects & 2) != 2)) { + var_f18 = player->unk_208 + ((-(player->speed / 18.0f) * 216.0f) * 3.0f) + (-player->unk_20C * 10.0f); sp20 = player->unk_084 * 3.0f; } else { - var_f18 = player->unk_208 + ((-(player->unk_094 / 18.0f) * 216.0f) / 3.0f); + var_f18 = player->unk_208 + ((-(player->speed / 18.0f) * 216.0f) / 3.0f); sp20 = player->unk_084; } } - arg1[0] = (player->unk_090 + var_f18) * player->unk_094; + arg1[0] = (player->unk_090 + var_f18) * player->speed; arg1[1] = 0.0f; - arg1[2] = player->unk_094 * sp20; + arg1[2] = player->speed * sp20; mtxf_translate_vec3f_mat3(arg1, player->orientationMatrix); } arg2[0] = arg1[0]; @@ -4282,14 +4292,14 @@ void func_800371F4(Player* player, Vec3f arg1, Vec3f arg2) { f32 var_f18; s32 temp_t6; - if (((player->effects & 0x1000) == 0x1000) || ((player->effects & 0x20) == 0x20)) { + if (((player->effects & UNKNOWN_EFFECT_0x1000) == UNKNOWN_EFFECT_0x1000) || ((player->effects & 0x20) == 0x20)) { arg1[0] = 0.0f; arg1[1] = 0.0f; arg1[2] = 0.0f; mtxf_translate_vec3f_mat3(arg1, player->orientationMatrix); } else { - if (((player->effects & 0x10) == 0x10) && ((player->effects & 2) != 2)) { - var_f18 = player->unk_208 + ((-(player->unk_094 / 18.0f) * 216.0f) * 3.0f) + (-player->unk_20C * 50.0f); + if (((player->effects & UNKNOWN_EFFECT_0x10) == UNKNOWN_EFFECT_0x10) && ((player->effects & 2) != 2)) { + var_f18 = player->unk_208 + ((-(player->speed / 18.0f) * 216.0f) * 3.0f) + (-player->unk_20C * 50.0f); sp20 = player->unk_084 * 3.0f; } else if (!(player->effects & 0x800) && !(player->unk_044 & 0x4000)) { var_v0 = player->unk_0FA; @@ -4299,37 +4309,37 @@ void func_800371F4(Player* player, Vec3f arg1, Vec3f arg2) { temp_t6 = (s32) player->unk_07C >> 0x10; if ((temp_t6 < 0x15) && (temp_t6 >= -0x14)) { if (var_v0 < 0x14) { - var_f18 = (player->unk_208 + ((-(player->unk_094 / 18.0f) * 216.0f) / 3.0f)) + + var_f18 = (player->unk_208 + ((-(player->speed / 18.0f) * 216.0f) / 3.0f)) + (-player->currentSpeed * 0.02) + (-player->unk_20C * 50.0f); } else { - var_f18 = ((player->unk_208 + ((-(player->unk_094 / 18.0f) * 216.0f) / 3.0f)) - + var_f18 = ((player->unk_208 + ((-(player->speed / 18.0f) * 216.0f) / 3.0f)) - ((temp_t6 * 0.01) + (player->currentSpeed * 0.05))) + (-player->unk_20C * 50.0f); } } else { - var_f18 = ((player->unk_208 + ((-(player->unk_094 / 18.0f) * 216.0f) / 3.0f)) - + var_f18 = ((player->unk_208 + ((-(player->speed / 18.0f) * 216.0f) / 3.0f)) - ((temp_t6 * 0.1) + (player->currentSpeed * 0.15))) + (-player->unk_20C * 50.0f); } sp20 = player->unk_084; } else { - var_f18 = ((player->unk_208 + ((f64) (-(player->unk_094 / 18.0f) * 216.0f) * 1.5)) - + var_f18 = ((player->unk_208 + ((f64) (-(player->speed / 18.0f) * 216.0f) * 1.5)) - (((player->unk_07C >> 0x10) * 0.1) + (player->currentSpeed * 0.05))) + (-player->unk_20C * 50.0f); sp20 = player->unk_084; } if ((player->effects & STAR_EFFECT) == STAR_EFFECT) { - if (((player->effects & 0x10) == 0x10) && ((player->effects & 2) != 2)) { - var_f18 = player->unk_208 + ((-(player->unk_094 / 18.0f) * 216.0f) * 3.0f) + (-player->unk_20C * 50.0f); + if (((player->effects & UNKNOWN_EFFECT_0x10) == UNKNOWN_EFFECT_0x10) && ((player->effects & 2) != 2)) { + var_f18 = player->unk_208 + ((-(player->speed / 18.0f) * 216.0f) * 3.0f) + (-player->unk_20C * 50.0f); sp20 = player->unk_084 * 3.0f; } else { - var_f18 = player->unk_208 + ((-(player->unk_094 / 18.0f) * 216.0f) / 3.0f); + var_f18 = player->unk_208 + ((-(player->speed / 18.0f) * 216.0f) / 3.0f); sp20 = player->unk_084; } } - arg1[0] = -(player->unk_090 + var_f18) * player->unk_094; + arg1[0] = -(player->unk_090 + var_f18) * player->speed; arg1[1] = 0.0f; - arg1[2] = player->unk_094 * sp20; + arg1[2] = player->speed * sp20; mtxf_translate_vec3f_mat3(arg1, player->orientationMatrix); } arg2[0] = arg1[0]; @@ -4341,22 +4351,22 @@ void func_80037614(Player* player, Vec3f arg1, Vec3f arg2) { f32 var_f12; f32 var_f2; - if (((player->effects & 0x1000) == 0x1000) || ((player->effects & 0x20) == 0x20)) { + if (((player->effects & UNKNOWN_EFFECT_0x1000) == UNKNOWN_EFFECT_0x1000) || ((player->effects & 0x20) == 0x20)) { arg1[0] = 0.0f; arg1[1] = 0.0f; arg1[2] = 0.0f; mtxf_translate_vec3f_mat3(arg1, player->orientationMatrix); } else { - if (((player->effects & 0x10) == 0x10) && ((player->effects & 2) != 2)) { - var_f2 = ((-(player->unk_094 / 18.0f) * 216.0f) * 2) + -80.0f; + if (((player->effects & UNKNOWN_EFFECT_0x10) == UNKNOWN_EFFECT_0x10) && ((player->effects & 2) != 2)) { + var_f2 = ((-(player->speed / 18.0f) * 216.0f) * 2) + -80.0f; var_f12 = -80.0f; } else { - var_f2 = ((-(player->unk_094 / 18.0f) * 216.0f) / 2) + -20.0f; + var_f2 = ((-(player->speed / 18.0f) * 216.0f) / 2) + -20.0f; var_f12 = -40.0f; } - arg1[0] = (var_f2 + 28.0f) * player->unk_094; + arg1[0] = (var_f2 + 28.0f) * player->speed; arg1[1] = 0.0f; - arg1[2] = var_f12 * player->unk_094; + arg1[2] = var_f12 * player->speed; mtxf_translate_vec3f_mat3(arg1, player->orientationMatrix); } arg2[0] = arg1[0]; @@ -4368,22 +4378,22 @@ void func_8003777C(Player* player, Vec3f arg1, Vec3f arg2) { f32 var_f12; f32 var_f2; - if (((player->effects & 0x1000) == 0x1000) || ((player->effects & 0x20) == 0x20)) { + if (((player->effects & UNKNOWN_EFFECT_0x1000) == UNKNOWN_EFFECT_0x1000) || ((player->effects & 0x20) == 0x20)) { arg1[0] = 0.0f; arg1[1] = 0.0f; arg1[2] = 0.0f; mtxf_translate_vec3f_mat3(arg1, player->orientationMatrix); } else { - if (((player->effects & 0x10) == 0x10) && ((player->effects & 2) != 2)) { - var_f2 = ((-(player->unk_094 / 18.0f) * 216.0f) * 2) + -80.0f; + if (((player->effects & UNKNOWN_EFFECT_0x10) == UNKNOWN_EFFECT_0x10) && ((player->effects & 2) != 2)) { + var_f2 = ((-(player->speed / 18.0f) * 216.0f) * 2) + -80.0f; var_f12 = -80.0f; } else { - var_f2 = ((-(player->unk_094 / 18.0f) * 216.0f) / 2) + -20.0f; + var_f2 = ((-(player->speed / 18.0f) * 216.0f) / 2) + -20.0f; var_f12 = -40.0f; } - arg1[0] = -(var_f2 + 28.0f) * player->unk_094; + arg1[0] = -(var_f2 + 28.0f) * player->speed; arg1[1] = 0.0f; - arg1[2] = var_f12 * player->unk_094; + arg1[2] = var_f12 * player->speed; mtxf_translate_vec3f_mat3(arg1, player->orientationMatrix); } arg2[0] = arg1[0]; @@ -4401,16 +4411,16 @@ void func_800378E8(Player* player, Vec3f arg1, Vec3f arg2) { arg1[2] = 0.0f; mtxf_translate_vec3f_mat3(arg1, player->orientationMatrix); } else { - if ((player->effects & 0x10) == 0x10) { - var_f2 = player->unk_208 + (-(player->unk_094 / 18.0f) * 216.0f * 5.0f) + (-player->unk_20C * 10.0f); + if ((player->effects & UNKNOWN_EFFECT_0x10) == UNKNOWN_EFFECT_0x10) { + var_f2 = player->unk_208 + (-(player->speed / 18.0f) * 216.0f * 5.0f) + (-player->unk_20C * 10.0f); var_f12 = -100.0f; } else { - var_f2 = player->unk_208 + ((-(player->unk_094 / 18.0f) * 216.0f) / 40.0f) + (-player->unk_20C * 50.0f); + var_f2 = player->unk_208 + ((-(player->speed / 18.0f) * 216.0f) / 40.0f) + (-player->unk_20C * 50.0f); var_f12 = player->unk_084; } - arg1[0] = (player->unk_090 + var_f2) * player->unk_094; + arg1[0] = (player->unk_090 + var_f2) * player->speed; arg1[1] = 0.0f; - arg1[2] = player->unk_094 * var_f12; + arg1[2] = player->speed * var_f12; mtxf_translate_vec3f_mat3(arg1, player->orientationMatrix); } arg2[0] = arg1[0]; @@ -4428,16 +4438,16 @@ void func_80037A4C(Player* player, Vec3f arg1, Vec3f arg2) { arg1[2] = 0.0f; mtxf_translate_vec3f_mat3(arg1, player->orientationMatrix); } else { - if ((player->effects & 0x10) == 0x10) { - var_f2 = player->unk_208 + (-(player->unk_094 / 18.0f) * 216.0f * 5.0f) + (-player->unk_20C * 50.0f); + if ((player->effects & UNKNOWN_EFFECT_0x10) == UNKNOWN_EFFECT_0x10) { + var_f2 = player->unk_208 + (-(player->speed / 18.0f) * 216.0f * 5.0f) + (-player->unk_20C * 50.0f); var_f12 = -100.0f; } else { - var_f2 = player->unk_208 + ((-(player->unk_094 / 18.0f) * 216.0f) / 40.0f) + (-player->unk_20C * 50.0f); + var_f2 = player->unk_208 + ((-(player->speed / 18.0f) * 216.0f) / 40.0f) + (-player->unk_20C * 50.0f); var_f12 = player->unk_084; } - arg1[0] = -(player->unk_090 + var_f2) * player->unk_094; + arg1[0] = -(player->unk_090 + var_f2) * player->speed; arg1[1] = 0.0f; - arg1[2] = player->unk_094 * var_f12; + arg1[2] = player->speed * var_f12; mtxf_translate_vec3f_mat3(arg1, player->orientationMatrix); } arg2[0] = arg1[0]; @@ -4458,7 +4468,7 @@ void func_80037BB4(Player* player, Vec3f arg1) { if (((player->effects & 0x20000000) != 0x20000000) || (player->unk_228 >= 0x64)) { player->rotation[1] += player->unk_078; } - if (!(player->type & PLAYER_KART_AI)) { + if (!(player->type & PLAYER_CPU)) { if (gModeSelection == BATTLE) { func_800378E8(player, sp20, arg1); } else { @@ -4471,7 +4481,7 @@ void func_80037BB4(Player* player, Vec3f arg1) { if (((player->effects & 0x20000000) != 0x20000000) || (player->unk_228 >= 0x64)) { player->rotation[1] += player->unk_078; } - if (!(player->type & PLAYER_KART_AI)) { + if (!(player->type & PLAYER_CPU)) { if (gModeSelection == BATTLE) { func_80037A4C(player, sp20, arg1); } else { @@ -4487,11 +4497,12 @@ void func_80037BB4(Player* player, Vec3f arg1) { void func_80037CFC(Player* player, struct Controller* controller, s8 arg2) { if (((player->effects & 0x80) != 0x80) && ((player->effects & 0x40) != 0x40) && ((player->effects & 0x400) != 0x400) && ((player->effects & 0x4000) != 0x4000) && - ((player->effects & 0x01000000) != 0x01000000) && - ((player->effects & HIT_BY_ITEM_EFFECT) != HIT_BY_ITEM_EFFECT) && ((player->effects & 0x10000) != 0x10000) && + ((player->effects & UNKNOWN_EFFECT_0x1000000) != UNKNOWN_EFFECT_0x1000000) && + ((player->effects & HIT_BY_ITEM_EFFECT) != HIT_BY_ITEM_EFFECT) && + ((player->effects & UNKNOWN_EFFECT_0x10000) != UNKNOWN_EFFECT_0x10000) && ((player->effects & 0x20000) != 0x20000)) { if (((player->effects & HIT_EFFECT) != HIT_EFFECT) && ((player->effects & 8) != 8) && - ((player->effects & 2) != 2) && ((player->effects & 0x10) != 0x10) && + ((player->effects & 2) != 2) && ((player->effects & UNKNOWN_EFFECT_0x10) != UNKNOWN_EFFECT_0x10) && (controller->buttonPressed & R_TRIG)) { kart_hop(player); if (((player->type & PLAYER_HUMAN) == PLAYER_HUMAN) && @@ -4506,7 +4517,7 @@ void func_80037CFC(Player* player, struct Controller* controller, s8 arg2) { } player->effects &= ~1; if ((!(player->effects & BOOST_RAMP_ASPHALT_EFFECT)) && (!(player->effects & BOOST_RAMP_WOOD_EFFECT))) { - if (((player->unk_094 / 18.0f) * 216.0f) <= 12.0f) { + if (((player->speed / 18.0f) * 216.0f) <= 12.0f) { if (controller->button & A_BUTTON) { if (controller->button & B_BUTTON) { player->effects |= 0x20; @@ -4523,13 +4534,13 @@ void func_80037CFC(Player* player, struct Controller* controller, s8 arg2) { } if ((player->unk_044 & 1) != 1) { if (controller->button & A_BUTTON) { - player_speed(player); + player_accelerate(player); detect_triple_a_combo_a_pressed(player); } else { if (gModeSelection == BATTLE) { - decelerate_ai_player(player, 2.0f); + decelerate_player(player, 2.0f); } else { - decelerate_ai_player(player, 1.0f); + decelerate_player(player, 1.0f); } detect_triple_a_combo_a_released(player); } @@ -4542,7 +4553,7 @@ void func_80037CFC(Player* player, struct Controller* controller, s8 arg2) { } } if ((!(player->effects & BOOST_RAMP_ASPHALT_EFFECT)) && (!(player->effects & 4))) { - if (((func_800388B0(controller) < (-0x31)) && (((player->unk_094 / 18.0f) * 216.0f) <= 5.0f)) && + if (((func_800388B0(controller) < (-0x31)) && (((player->speed / 18.0f) * 216.0f) <= 5.0f)) && (controller->button & B_BUTTON)) { player->currentSpeed = 140.0f; player->unk_044 |= 1; @@ -4559,13 +4570,13 @@ void func_80037CFC(Player* player, struct Controller* controller, s8 arg2) { } else { if ((player->effects & 0x4000) == 0x4000) { if (controller->button & A_BUTTON) { - player_speed(player); + player_accelerate(player); } else { - decelerate_ai_player(player, 5.0f); + decelerate_player(player, 5.0f); } } if (((((player->effects & 0x80) == 0x80) || ((player->effects & 0x40) == 0x40)) || - ((player->effects & 0x01000000) == 0x01000000)) || + ((player->effects & UNKNOWN_EFFECT_0x1000000) == UNKNOWN_EFFECT_0x1000000)) || ((player->effects & HIT_BY_ITEM_EFFECT) == HIT_BY_ITEM_EFFECT)) { if (controller->button & A_BUTTON) { detect_triple_a_combo_a_pressed(player); @@ -4580,7 +4591,7 @@ void func_80037CFC(Player* player, struct Controller* controller, s8 arg2) { void func_800381AC(Player* player, struct Controller* controller, s8 arg2) { if (((player->type & PLAYER_EXISTS) == PLAYER_EXISTS) && ((player->type & PLAYER_HUMAN) == PLAYER_HUMAN) && - ((player->type & PLAYER_KART_AI) != PLAYER_KART_AI)) { + ((player->type & PLAYER_CPU) != PLAYER_CPU)) { if ((player->type & PLAYER_START_SEQUENCE) != PLAYER_START_SEQUENCE) { if (((player->unk_0CA & 2) == 2) || ((player->unk_0CA & 8) == 8)) { if (controller->button & A_BUTTON) { @@ -4896,8 +4907,8 @@ void func_80038C6C(Player* player, UNUSED Camera* camera, s8 arg2, s8 playerId) func_80029B4C(player, spEC, spE8, spE4); func_8002AE38(player, playerId, posX, posZ, spEC, spE4); sqrt = (sp88[0] * sp88[0]) + (sp88[2] * sp88[2]); - player->unk_22C = player->unk_094; - player->unk_094 = sqrtf(sqrt); + player->previousSpeed = player->speed; + player->speed = sqrtf(sqrt); player->pos[0] = spEC; player->pos[2] = spE4; @@ -4915,20 +4926,20 @@ void func_80038C6C(Player* player, UNUSED Camera* camera, s8 arg2, s8 playerId) D_80165070[playerId][2] = sp88[2]; if ((player->type & PLAYER_HUMAN) == PLAYER_HUMAN) { - if (gKartTopSpeedTable[player->characterId] < player->unk_094) { - divOptimize = gKartTopSpeedTable[player->characterId] / player->unk_094; + if (gKartTopSpeedTable[player->characterId] < player->speed) { + divOptimize = gKartTopSpeedTable[player->characterId] / player->speed; player->velocity[0] *= divOptimize; player->velocity[1] *= divOptimize; player->velocity[2] *= divOptimize; - player->unk_094 = gKartTopSpeedTable[player->characterId]; + player->speed = gKartTopSpeedTable[player->characterId]; } } if ((player->unk_044 & 1) == 1) { - if (player->unk_094 > 1.0f) { - player->velocity[0] *= 1.0f / player->unk_094; - player->velocity[1] *= 1.0f / player->unk_094; - player->velocity[2] *= 1.0f / player->unk_094; - player->unk_094 = 1.0f; + if (player->speed > 1.0f) { + player->velocity[0] *= 1.0f / player->speed; + player->velocity[1] *= 1.0f / player->speed; + player->velocity[2] *= 1.0f / player->speed; + player->speed = 1.0f; } } if (player->collision.surfaceDistance[2] >= 500.0f) { diff --git a/src/player_controller.h b/src/player_controller.h index d5436d696d..7bf233e550 100644 --- a/src/player_controller.h +++ b/src/player_controller.h @@ -64,7 +64,7 @@ void func_8002D028(Player*, s8); void func_8002D268(Player*, Camera*, s8, s8); void func_8002E4C4(Player*); -void control_kart_ai_movement(Player*, Camera*, s8, s8); +void control_cpu_movement(Player*, Camera*, s8, s8); void func_8002FCA8(Player*, s8); void func_8002FE84(Player*, f32); @@ -73,8 +73,8 @@ f32 func_80030150(Player*, s8); void func_80030A34(Player*); void detect_triple_a_combo_a_released(Player*); void detect_triple_a_combo_a_pressed(Player*); -void player_speed(Player*); -void decelerate_ai_player(Player*, f32); +void player_accelerate(Player*); +void decelerate_player(Player*, f32); void detect_triple_b_combo_b_released(Player*); void detect_triple_b_combo_b_pressed(Player*); void func_800323E4(Player*); @@ -91,7 +91,7 @@ void func_800339C4(Player*, s32*, s32, s32, f32); void func_80033A40(Player*, s32*, s32*, s32, s32, s32, f32); void func_80033AE0(Player*, struct Controller*, s8); -void func_8003680C(Player*, s16); +void apply_cpu_turn(Player*, s16); void func_80036C5C(Player*); void func_80036CB4(Player*); void func_80036DB4(Player*, Vec3f, Vec3f); @@ -113,81 +113,81 @@ void func_80038C6C(Player*, Camera*, s8, s8); /* This is where I'd put my static data, if I had any */ -extern s16 gKartAIforMario[]; -extern s16 gKartAIforLuigi[]; -extern s16 gKartAIforYoshi[]; -extern s16 gKartAIforToad[]; -extern s16 gKartAIforDk[]; -extern s16 gKartAIforWario[]; -extern s16 gKartAIforPeach[]; -extern s16 gKartAIforBowser[]; -extern s16* gKartAIforPlayer[]; - -extern s16 gKartAIforMarioAndLuigi[]; -extern s16 gKartAIforMarioAndYoshi[]; -extern s16 gKartAIforMarioAndToad[]; -extern s16 gKartAIforMarioAndDk[]; -extern s16 gKartAIforMarioAndWario[]; -extern s16 gKartAIforMarioAndPeach[]; -extern s16 gKartAIforMarioAndBowser[]; -extern s16 gKartAIforLuigiAndMario[]; -extern s16 gKartAIforLuigiAndYoshi[]; -extern s16 gKartAIforLuigiAndToad[]; -extern s16 gKartAIforLuigiAndDk[]; -extern s16 gKartAIforLuigiAndWario[]; -extern s16 gKartAIforLuigiAndPeach[]; -extern s16 gKartAIforLuigiAndBowser[]; -extern s16 gKartAIforYoshiAndMario[]; -extern s16 gKartAIforYoshiAndLuigi[]; -extern s16 gKartAIforYoshiAndToad[]; -extern s16 gKartAIforYoshiAndDk[]; -extern s16 gKartAIforYoshiAndWario[]; -extern s16 gKartAIforYoshiAndPeach[]; -extern s16 gKartAIforYoshiAndBowser[]; -extern s16 gKartAIforToadAndMario[]; -extern s16 gKartAIforToadAndLuigi[]; -extern s16 gKartAIforToadAndYoshi[]; -extern s16 gKartAIforToadAndDk[]; -extern s16 gKartAIforToadAndWario[]; -extern s16 gKartAIforToadAndPeach[]; -extern s16 gKartAIforToadAndBowser[]; -extern s16 gKartAIforDkAndMario[]; -extern s16 gKartAIforDkAndLuigi[]; -extern s16 gKartAIforDkAndToad[]; -extern s16 gKartAIforDkAndYoshi[]; -extern s16 gKartAIforDkAndWario[]; -extern s16 gKartAIforDkAndPeach[]; -extern s16 gKartAIforDkAndBowser[]; -extern s16 gKartAIforWarioAndMario[]; -extern s16 gKartAIforWarioAndLuigi[]; -extern s16 gKartAIforWarioAndYoshi[]; -extern s16 gKartAIforWarioAndDk[]; -extern s16 gKartAIforWarioAndToad[]; -extern s16 gKartAIforWarioAndPeach[]; -extern s16 gKartAIforWarioAndBowser[]; -extern s16 gKartAIforPeachAndMario[]; -extern s16 gKartAIforPeachAndLuigi[]; -extern s16 gKartAIforPeachAndYoshi[]; -extern s16 gKartAIforPeachAndDk[]; -extern s16 gKartAIforPeachAndWario[]; -extern s16 gKartAIforPeachAndToad[]; -extern s16 gKartAIforPeachAndBowser[]; -extern s16 gKartAIforBowserAndMario[]; -extern s16 gKartAIforBowserAndLuigi[]; -extern s16 gKartAIforBowserAndYoshi[]; -extern s16 gKartAIforBowserAndDk[]; -extern s16 gKartAIforBowserAndWario[]; -extern s16 gKartAIforBowserAndToad[]; -extern s16 gKartAIforBowserAndPeach[]; -extern s16* gListKartAIforMario[]; -extern s16* gListKartAIforLuigi[]; -extern s16* gListKartAIforYoshi[]; -extern s16* gListKartAIforToad[]; -extern s16* gListKartAIforDk[]; -extern s16* gListKartAIforWario[]; -extern s16* gListKartAIforPeach[]; -extern s16* gListKartAIforBowser[]; -extern s16** gKartAIforTwoPlayer[]; +extern s16 cpu_forMario[]; +extern s16 cpu_forLuigi[]; +extern s16 cpu_forYoshi[]; +extern s16 cpu_forToad[]; +extern s16 cpu_forDk[]; +extern s16 cpu_forWario[]; +extern s16 cpu_forPeach[]; +extern s16 cpu_forBowser[]; +extern s16* cpu_forPlayer[]; + +extern s16 cpu_forMarioAndLuigi[]; +extern s16 cpu_forMarioAndYoshi[]; +extern s16 cpu_forMarioAndToad[]; +extern s16 cpu_forMarioAndDk[]; +extern s16 cpu_forMarioAndWario[]; +extern s16 cpu_forMarioAndPeach[]; +extern s16 cpu_forMarioAndBowser[]; +extern s16 cpu_forLuigiAndMario[]; +extern s16 cpu_forLuigiAndYoshi[]; +extern s16 cpu_forLuigiAndToad[]; +extern s16 cpu_forLuigiAndDk[]; +extern s16 cpu_forLuigiAndWario[]; +extern s16 cpu_forLuigiAndPeach[]; +extern s16 cpu_forLuigiAndBowser[]; +extern s16 cpu_forYoshiAndMario[]; +extern s16 cpu_forYoshiAndLuigi[]; +extern s16 cpu_forYoshiAndToad[]; +extern s16 cpu_forYoshiAndDk[]; +extern s16 cpu_forYoshiAndWario[]; +extern s16 cpu_forYoshiAndPeach[]; +extern s16 cpu_forYoshiAndBowser[]; +extern s16 cpu_forToadAndMario[]; +extern s16 cpu_forToadAndLuigi[]; +extern s16 cpu_forToadAndYoshi[]; +extern s16 cpu_forToadAndDk[]; +extern s16 cpu_forToadAndWario[]; +extern s16 cpu_forToadAndPeach[]; +extern s16 cpu_forToadAndBowser[]; +extern s16 cpu_forDkAndMario[]; +extern s16 cpu_forDkAndLuigi[]; +extern s16 cpu_forDkAndToad[]; +extern s16 cpu_forDkAndYoshi[]; +extern s16 cpu_forDkAndWario[]; +extern s16 cpu_forDkAndPeach[]; +extern s16 cpu_forDkAndBowser[]; +extern s16 cpu_forWarioAndMario[]; +extern s16 cpu_forWarioAndLuigi[]; +extern s16 cpu_forWarioAndYoshi[]; +extern s16 cpu_forWarioAndDk[]; +extern s16 cpu_forWarioAndToad[]; +extern s16 cpu_forWarioAndPeach[]; +extern s16 cpu_forWarioAndBowser[]; +extern s16 cpu_forPeachAndMario[]; +extern s16 cpu_forPeachAndLuigi[]; +extern s16 cpu_forPeachAndYoshi[]; +extern s16 cpu_forPeachAndDk[]; +extern s16 cpu_forPeachAndWario[]; +extern s16 cpu_forPeachAndToad[]; +extern s16 cpu_forPeachAndBowser[]; +extern s16 cpu_forBowserAndMario[]; +extern s16 cpu_forBowserAndLuigi[]; +extern s16 cpu_forBowserAndYoshi[]; +extern s16 cpu_forBowserAndDk[]; +extern s16 cpu_forBowserAndWario[]; +extern s16 cpu_forBowserAndToad[]; +extern s16 cpu_forBowserAndPeach[]; +extern s16* gListCPUforMario[]; +extern s16* gListCPUforLuigi[]; +extern s16* gListCPUforYoshi[]; +extern s16* gListCPUforToad[]; +extern s16* gListCPUforDk[]; +extern s16* gListCPUforWario[]; +extern s16* gListCPUforPeach[]; +extern s16* gListCPUforBowser[]; +extern s16** cpu_forTwoPlayer[]; extern s16 D_801656F0; diff --git a/src/racing/actors.c b/src/racing/actors.c index e602490239..bf4669827f 100644 --- a/src/racing/actors.c +++ b/src/racing/actors.c @@ -14,9 +14,9 @@ #include "memory.h" #include "actors_extended.h" #include "actors.h" -#include "waypoints.h" +#include "path.h" #include "macros.h" -#include "code_80005FD0.h" +#include "cpu_vehicles_camera_path.h" #include "update_objects.h" #include "effects.h" #include "collision.h" @@ -1659,7 +1659,7 @@ bool collision_yoshi_egg(Player* player, struct YoshiValleyEgg* egg) { func_800C90F4(player - gPlayerOne, (player->characterId * 0x10) + SOUND_ARG_LOAD(0x29, 0x00, 0x80, 0x0D)); } else { apply_hit_sound_effect(player, player - gPlayerOne); - if ((gModeSelection == TIME_TRIALS) && ((player->type & PLAYER_KART_AI) == 0)) { + if ((gModeSelection == TIME_TRIALS) && ((player->type & PLAYER_CPU) == 0)) { D_80162DF8 = 1; } } @@ -1736,7 +1736,7 @@ bool collision_tree(Player* player, struct Actor* actor) { actorPos[2] = actor->pos[2]; if (((gCurrentCourseId == COURSE_MARIO_RACEWAY) || (gCurrentCourseId == COURSE_YOSHI_VALLEY) || (gCurrentCourseId == COURSE_ROYAL_RACEWAY) || (gCurrentCourseId == COURSE_LUIGI_RACEWAY)) && - (player->unk_094 > 1.0f)) { + (player->speed > 1.0f)) { spawn_leaf(actorPos, 0); } if (xz_dist < 0.1f) { @@ -2148,7 +2148,7 @@ void evaluate_collision_between_player_actor(Player* player, struct Actor* actor break; case ACTOR_RED_SHELL: temp_v1 = actor->rot[2]; - if (player->effects & 0x01000000) { + if (player->effects & UNKNOWN_EFFECT_0x1000000) { break; } if (player->soundEffects & 2) { @@ -2199,7 +2199,7 @@ void evaluate_collision_between_player_actor(Player* player, struct Actor* actor if (!(player->effects & BOO_EFFECT) && !(player->type & PLAYER_INVISIBLE_OR_BOMB)) { if (query_collision_player_vs_actor_item(player, actor) == COLLISION) { func_800C98B8(actor->pos, actor->velocity, SOUND_ACTION_EXPLOSION); - if ((gModeSelection == TIME_TRIALS) && !(player->type & PLAYER_KART_AI)) { + if ((gModeSelection == TIME_TRIALS) && !(player->type & PLAYER_CPU)) { D_80162DF8 = 1; } if (player->effects & STAR_EFFECT) { @@ -2281,7 +2281,7 @@ void evaluate_collision_for_players_and_actors(void) { for (i = 0; i < NUM_PLAYERS; i++) { phi_s1 = &gPlayers[i]; - if (((phi_s1->type & 0x8000) != 0) && ((phi_s1->effects & 0x4000000) == 0)) { + if (((phi_s1->type & PLAYER_EXISTS) != 0) && ((phi_s1->effects & 0x4000000) == 0)) { func_802977E4(phi_s1); for (j = 0; j < ACTOR_LIST_SIZE; j++) { temp_a1 = &gActorList[j]; @@ -2376,7 +2376,7 @@ void evaluate_collision_for_destructible_actors(void) { void func_802A1064(struct FakeItemBox* fake_item_box) { if ((u32) (fake_item_box - (struct FakeItemBox*) gActorList) <= (u32) ACTOR_LIST_SIZE) { if (((fake_item_box->flags & 0x8000) != 0) && (fake_item_box->type == ACTOR_FAKE_ITEM_BOX)) { - fake_item_box->state = 1; + fake_item_box->state = FAKE_ITEM_BOX_ON_GROUND; fake_item_box->targetY = func_802ABEAC(&fake_item_box->unk30, fake_item_box->pos) + 8.66f; fake_item_box->someTimer = 100; } diff --git a/src/racing/actors_extended.c b/src/racing/actors_extended.c index 9bc0a62159..29419c63c9 100644 --- a/src/racing/actors_extended.c +++ b/src/racing/actors_extended.c @@ -5,8 +5,8 @@ #include "code_800029B0.h" #include "math_util.h" #include "memory.h" -#include "waypoints.h" -#include "code_80005FD0.h" +#include "path.h" +#include "cpu_vehicles_camera_path.h" #include "menu_items.h" #include "collision.h" #include "actors.h" @@ -116,7 +116,7 @@ void destroy_banana_in_banana_bunch(struct BananaActor* banana) { } // Drop a banana from a banana bunch? -void func_802B0648(struct BananaBunchParent* banana_bunch) { +void drop_banana_in_banana_bunch(struct BananaBunchParent* banana_bunch) { s16 elderIndex; struct BananaActor* banana; @@ -185,12 +185,12 @@ void func_802B0788(s16 rawStickY, struct BananaBunchParent* banana_bunch, Player elderBanana = (struct BananaActor*) &gActorList[banana->elderIndex]; elderBanana->youngerIndex = -1; } - if (player->unk_094 < 2.0f) { + if (player->speed < 2.0f) { var_f0 = ((rawStickY - 30.0f) / 20.0f) + 1.5f; var_f12 = 4.0f; } else { var_f0 = ((rawStickY - 30.0f) / 20.0f) + 1.5f; - var_f12 = (player->unk_094 * 0.75f) + 4.5f + var_f0; + var_f12 = (player->speed * 0.75f) + 4.5f + var_f0; } vec3f_set(velocity, 0.0f, var_f0, var_f12); func_802B64C4(velocity, player->rotation[1] + player->unk_0C0); @@ -303,7 +303,7 @@ void update_actor_banana_bunch(struct BananaBunchParent* banana_bunch) { ((controller->rawStickX < 0x28) && (controller->rawStickX >= -0x27))) { func_802B0788(controller->rawStickY, banana_bunch, owner); } else { - func_802B0648(banana_bunch); + drop_banana_in_banana_bunch(banana_bunch); } } } diff --git a/src/racing/actors_extended.h b/src/racing/actors_extended.h index 457106de63..e054ce12a9 100644 --- a/src/racing/actors_extended.h +++ b/src/racing/actors_extended.h @@ -12,7 +12,7 @@ void func_802B039C(struct BananaActor*); void func_802B0464(s16); void func_802B04E8(struct BananaActor*, s16); void destroy_banana_in_banana_bunch(struct BananaActor*); -void func_802B0648(struct BananaBunchParent*); +void drop_banana_in_banana_bunch(struct BananaBunchParent*); void func_802B0788(s16, struct BananaBunchParent*, Player*); s32 func_802B09C0(s16); void update_actor_banana_bunch(struct BananaBunchParent*); diff --git a/src/racing/race_logic.c b/src/racing/race_logic.c index b38291876f..f5bc9aa7b9 100644 --- a/src/racing/race_logic.c +++ b/src/racing/race_logic.c @@ -7,14 +7,14 @@ #include #include "camera.h" -#include "waypoints.h" +#include "path.h" #include "staff_ghosts.h" #include "main.h" #include "code_800029B0.h" #include "code_80057C60.h" #include "update_objects.h" #include "menu_items.h" -#include "code_80005FD0.h" +#include "cpu_vehicles_camera_path.h" #include "spawn_players.h" #include "audio/external.h" #include "race_logic.h" @@ -40,7 +40,7 @@ u16 D_802BA032; float D_802BA034; -s32 D_802BA038; +s32 gDemoTimer; UNUSED s32 D_802BA03C; s16 D_802BA040[4]; @@ -81,7 +81,7 @@ void func_8028E028(void) { } func_800CA118((u8) gPlayerWinningIndex); D_800DC510 = 5; - D_802BA038 = 10; + gDemoTimer = 10; } void update_player_battle_status(void) { @@ -132,14 +132,14 @@ void func_8028E298(void) { } temp_a2 = gPathIndexByPlayerId[i]; - temp_v0 = ((2 - gPlayers[i].lapCount) * gWaypointCountByPathIndex[temp_a2]); - temp_v0 += gWaypointCountByPathIndex[temp_a2] * (1.0f - gLapCompletionPercentByPlayerId[i]); + temp_v0 = ((2 - gPlayers[i].lapCount) * gPathCountByPathIndex[temp_a2]); + temp_v0 += gPathCountByPathIndex[temp_a2] * (1.0f - gLapCompletionPercentByPlayerId[i]); temp_v0 /= 15.0f; gTimePlayerLastTouchedFinishLine[i] = gCourseTimer + temp_v0; } D_8016348C = 1; - func_800070F4(); + update_player_rankings(); } void func_8028E3A0(void) { @@ -404,7 +404,7 @@ void func_8028E678(void) { } } -void func_8028EC38(s32 arg0) { +UNUSED void func_8028EC38(s32 arg0) { gGotoMode = arg0; D_800DC510 = 6; func_800CA330(25); @@ -412,7 +412,7 @@ void func_8028EC38(s32 arg0) { D_800DC5B4 = 1; D_800DC5B0 = 1; D_800DC5B8 = 0; - D_802BA038 = 5; + gDemoTimer = 5; } void func_8028EC98(s32 arg0) { @@ -529,7 +529,7 @@ void func_8028EF28(void) { func_8028EEF0(i); currentPosition = gPlayers[i].currentRank; - gPlayers[i].type |= PLAYER_KART_AI; + gPlayers[i].type |= PLAYER_CPU; if (currentPosition < 4) { D_80150120 = 1; @@ -551,7 +551,7 @@ void func_8028EF28(void) { } if (gModeSelection == VERSUS) { - D_802BA038 = 180; + gDemoTimer = 180; if (currentPosition == 0) { gPlayerWinningIndex = i; } @@ -566,7 +566,7 @@ void func_8028EF28(void) { D_800DC510 = 5; i = gPlayerPositionLUT[1]; gPlayers[i].soundEffects |= 0x200000; - gPlayers[i].type |= PLAYER_KART_AI; + gPlayers[i].type |= PLAYER_CPU; func_800CA118((u8) i); break; case 3: @@ -584,7 +584,7 @@ void func_8028EF28(void) { *(gNmiUnknown2 + i * 3 + 2) = 99; } gPlayers[i].soundEffects |= 0x200000; - gPlayers[i].type |= PLAYER_KART_AI; + gPlayers[i].type |= PLAYER_CPU; func_800CA118((u8) i); } break; @@ -599,7 +599,7 @@ void func_8028EF28(void) { D_800DC510 = 5; i = gPlayerPositionLUT[3]; gPlayers[i].soundEffects |= 0x200000; - gPlayers[i].type |= PLAYER_KART_AI; + gPlayers[i].type |= PLAYER_CPU; func_800CA118((u8) i); } break; @@ -625,7 +625,7 @@ void func_8028EF28(void) { } if ((D_802BA048 != 0) && (D_802BA048 != 100)) { D_802BA048 = 100; - func_800074D4(); + set_places_end_course_with_time(); } } @@ -656,7 +656,7 @@ void func_8028F474(void) { case 5: case 7: for (i = 0; i < NUM_PLAYERS; i++) { - func_80009B60(i); + update_player(i); } case 1: case 2: @@ -677,7 +677,7 @@ void func_8028F4E8(void) { D_800DC5B4 = 1; D_800DC5B0 = 1; D_800DC5B8 = 0; - D_802BA038 = 5; + gDemoTimer = 5; } } } @@ -791,7 +791,7 @@ void func_8028F970(void) { if (!(player->type & PLAYER_HUMAN)) { continue; } - if (player->type & PLAYER_KART_AI) { + if (player->type & PLAYER_CPU) { continue; } @@ -862,27 +862,27 @@ void func_8028FBD4(void) { D_800DC5B4 = 1; D_800DC5B0 = 1; D_800DC5B8 = 0; - D_802BA038 = 5; + gDemoTimer = 5; } #ifdef VERSION_EU -#define D_802BA038_SIZE 1600 +#define gDemoTimer_SIZE 1600 #else -#define D_802BA038_SIZE 1920 +#define gDemoTimer_SIZE 1920 #endif -void func_8028FC34(void) { - if (D_802BA038 < 0) { - D_802BA038 = D_802BA038_SIZE; +void end_demo_update(void) { + if (gDemoTimer < 0) { + gDemoTimer = gDemoTimer_SIZE; return; } - D_802BA038--; + gDemoTimer--; if (gControllerFive->buttonPressed != 0) { func_8028FBD4(); gMenuSelection = START_MENU; return; } - if (D_802BA038 == 0) { + if (gDemoTimer == 0) { func_8028FBD4(); gMenuSelection = LOGO_INTRO_MENU; } @@ -894,7 +894,7 @@ void func_8028FCBC(void) { u32 phi_v0_4; if (gDemoUseController) { - func_8028FC34(); + end_demo_update(); } switch (D_800DC510) { case 0: @@ -991,7 +991,7 @@ void func_8028FCBC(void) { switch (gScreenModeSelection) { case SCREEN_MODE_1P: - D_802BA038 = 690; + gDemoTimer = 690; D_800DC510 = 5; func_8028E298(); break; @@ -1007,7 +1007,7 @@ void func_8028FCBC(void) { } func_8028E298(); - D_802BA038 = 600; + gDemoTimer = 600; D_800DC510 = 5; } break; @@ -1020,7 +1020,7 @@ void func_8028FCBC(void) { func_8028F970(); break; case TIME_TRIALS: - D_802BA038 = 360; + gDemoTimer = 360; if (D_8015F890 != 0) { D_800DC510 = 7; } else { @@ -1030,8 +1030,8 @@ void func_8028FCBC(void) { } break; case 5: - if (D_802BA038 != 0) { - D_802BA038--; + if (gDemoTimer != 0) { + gDemoTimer--; } else { switch (gModeSelection) { case GRAND_PRIX: diff --git a/src/racing/race_logic.h b/src/racing/race_logic.h index 16b363e13a..1c5ded8958 100644 --- a/src/racing/race_logic.h +++ b/src/racing/race_logic.h @@ -27,7 +27,7 @@ void func_8028F8BC(void); void func_8028F914(void); void func_8028F970(void); void func_8028FBD4(void); -void func_8028FC34(void); +void end_demo_update(void); void func_8028FCBC(void); void func_80290314(void); void func_80290338(void); diff --git a/src/render_objects.c b/src/render_objects.c index 3e0c78688d..bb35f3b960 100644 --- a/src/render_objects.c +++ b/src/render_objects.c @@ -15,12 +15,12 @@ #include "math_util.h" #include "math_util_2.h" #include "objects.h" -#include "waypoints.h" +#include "path.h" #include "bomb_kart.h" #include #include "render_player.h" #include "animation.h" -#include "code_80005FD0.h" +#include "cpu_vehicles_camera_path.h" #include "code_80057C60.h" #include "code_8006E9C0.h" #include "render_objects.h" @@ -1736,12 +1736,12 @@ void draw_hud_2d_texture(s32 x, s32 y, u32 width, u32 height, u8* texture) { gSPDisplayList(gDisplayListHead++, D_0D007EB8); } -void func_8004C450(s32 arg0, s32 arg1, u32 arg2, u32 arg3, u8* texture) { +void func_8004C450(s32 x, s32 y, u32 width, u32 height, u8* texture) { gSPDisplayList(gDisplayListHead++, D_0D007F38); func_8004B614(D_801656C0, D_801656D0, D_801656E0, 0x80, 0x80, 0x80, 0xFF); - load_texture_block_rgba16_mirror(texture, arg2, arg3); - func_8004B97C(arg0 - (arg2 >> 1), arg1 - (arg3 >> 1), arg2, arg3, 1); + load_texture_block_rgba16_mirror(texture, width, height); + func_8004B97C(x - (width >> 1), y - (height >> 1), width, height, 1); gSPDisplayList(gDisplayListHead++, D_0D007EB8); } @@ -2475,52 +2475,52 @@ void render_mini_map_finish_line(s32 arg0) { * characterId of 8 appears to be a type of null check or control flow alteration. */ #define EXPLICIT_AND 1 -void func_8004F168(s32 arg0, s32 playerId, s32 characterId) { +void draw_minimap_character(s32 arg0, s32 playerId, s32 characterId) { f32 thing0; f32 thing1; - s16 temp_a0; - s16 temp_a1; + s16 x; + s16 y; Player* player = &gPlayerOne[playerId]; if (player->type & (1 << 15)) { thing0 = player->pos[0] * gMiniMapMarkerScale; thing1 = player->pos[2] * gMiniMapMarkerScale; - temp_a0 = ((gMiniMapFinishLineX[arg0] + D_8018D2F0) - (D_8018D2B0 / 2)) + gMiniMapX + (s16) (thing0); - temp_a1 = ((gMiniMapFinishLineY[arg0] + D_8018D2F8) - (D_8018D2B8 / 2)) + gMiniMapY + (s16) (thing1); + x = ((gMiniMapFinishLineX[arg0] + D_8018D2F0) - (D_8018D2B0 / 2)) + gMiniMapX + (s16) (thing0); + y = ((gMiniMapFinishLineY[arg0] + D_8018D2F8) - (D_8018D2B8 / 2)) + gMiniMapY + (s16) (thing1); if (characterId != 8) { if ((gGPCurrentRaceRankByPlayerId[playerId] == 0) && (gModeSelection != 3) && (gModeSelection != 1)) { #if EXPLICIT_AND == 1 - func_80046424(temp_a0, temp_a1, (player->rotation[1] + 0x8000) & 0xFFFF, 1.0f, + func_80046424(x, y, (player->rotation[1] + 0x8000) & 0xFFFF, 1.0f, (u8*) common_texture_minimap_kart_character[characterId], common_vtx_player_minimap_icon, 8, 8, 8, 8); #else - func_80046424(temp_a0, temp_a1, player->rotation[1] + 0x8000, 1.0f, + func_80046424(x, y, player->rotation[1] + 0x8000, 1.0f, (u8*) common_texture_minimap_kart_character[characterId], common_vtx_player_minimap_icon, 8, 8, 8, 8); #endif } else { #if EXPLICIT_AND == 1 - func_800463B0(temp_a0, temp_a1, (player->rotation[1] + 0x8000) & 0xFFFF, 1.0f, + func_800463B0(x, y, (player->rotation[1] + 0x8000) & 0xFFFF, 1.0f, (u8*) common_texture_minimap_kart_character[characterId], common_vtx_player_minimap_icon, 8, 8, 8, 8); #else - func_800463B0(temp_a0, temp_a1, player->rotation[1] + 0x8000, 1.0f, + func_800463B0(x, y, player->rotation[1] + 0x8000, 1.0f, (u8*) common_texture_minimap_kart_character[characterId], common_vtx_player_minimap_icon, 8, 8, 8, 8); #endif } } else { if (gGPCurrentRaceRankByPlayerId[playerId] == 0) { - func_8004C450(temp_a0, temp_a1, 8, 8, (u8*) common_texture_minimap_progress_dot); + func_8004C450(x, y, 8, 8, (u8*) common_texture_minimap_progress_dot); } else { - draw_hud_2d_texture(temp_a0, temp_a1, 8, 8, (u8*) common_texture_minimap_progress_dot); + draw_hud_2d_texture(x, y, 8, 8, (u8*) common_texture_minimap_progress_dot); } } } } #undef EXPLICIT_AND #else -GLOBAL_ASM("asm/non_matchings/render_objects/func_8004F168.s") +GLOBAL_ASM("asm/non_matchings/render_objects/draw_minimap_character.s") #endif // WTF is up with the gPlayerOne access in this function? @@ -2533,35 +2533,35 @@ void func_8004F3E4(s32 arg0) { case GRAND_PRIX: for (idx = D_8018D158 - 1; idx >= 0; idx--) { playerId = gGPCurrentRacePlayerIdByRank[idx]; - if ((gPlayerOne + playerId)->type & PLAYER_KART_AI) { - func_8004F168(arg0, playerId, 8); + if ((gPlayerOne + playerId)->type & PLAYER_CPU) { + draw_minimap_character(arg0, playerId, 8); } } for (idx = D_8018D158 - 1; idx >= 0; idx--) { playerId = gGPCurrentRacePlayerIdByRank[idx]; - if (((gPlayerOne + playerId)->type & PLAYER_KART_AI) != PLAYER_KART_AI) { - func_8004F168(arg0, playerId, (gPlayerOne + playerId)->characterId); + if (((gPlayerOne + playerId)->type & PLAYER_CPU) != PLAYER_CPU) { + draw_minimap_character(arg0, playerId, (gPlayerOne + playerId)->characterId); } } break; case TIME_TRIALS: for (idx = 0; idx < 8; idx++) { if (((gPlayerOne + idx)->type & PLAYER_INVISIBLE_OR_BOMB) == PLAYER_INVISIBLE_OR_BOMB) { - func_8004F168(arg0, idx, 8); + draw_minimap_character(arg0, idx, 8); } } - func_8004F168(arg0, 0, gPlayerOne->characterId); + draw_minimap_character(arg0, 0, gPlayerOne->characterId); break; case VERSUS: for (idx = gPlayerCountSelection1 - 1; idx >= 0; idx--) { playerId = gGPCurrentRacePlayerIdByRank[idx]; - func_8004F168(arg0, playerId, (gPlayerOne + playerId)->characterId); + draw_minimap_character(arg0, playerId, (gPlayerOne + playerId)->characterId); } break; case BATTLE: for (idx = 0; idx < gPlayerCountSelection1; idx++) { if (!((gPlayerOne + idx)->type & PLAYER_UNKNOWN_0x40)) { - func_8004F168(arg0, idx, (gPlayerOne + idx)->characterId); + draw_minimap_character(arg0, idx, (gPlayerOne + idx)->characterId); } } break; @@ -2843,11 +2843,11 @@ s32 func_80050644(u16 arg0, s32* arg1, s32* arg2) { } void func_800507D8(u16 bombIndex, s32* arg1, s32* arg2) { - s32 temp_v0 = gBombKarts[bombIndex].waypointIndex; + s32 temp_v0 = gBombKarts[bombIndex].pathPointIndex; s32 var_v1 = 0; if (temp_v0 != 0) { - var_v1 = (s32) (temp_v0 * 0x3A0) / (s32) D_80164430; + var_v1 = (s32) (temp_v0 * 0x3A0) / (s32) gSelectedPathCount; } if (var_v1 < 0x104) { *arg1 = var_v1; @@ -3073,12 +3073,12 @@ void func_800514BC(void) { for (var_s0 = var_s3 - 1, var_s1 = 0; var_s1 < var_s3; var_s1++, var_s0--) { temp_a0 = gGPCurrentRacePlayerIdByRank[var_s0]; player = &gPlayerOne[temp_a0]; - if ((player->type & 0x8000) && ((temp_a0 != 0) || (gPlayerCountSelection1 != 1))) { + if ((player->type & PLAYER_EXISTS) && ((temp_a0 != 0) || (gPlayerCountSelection1 != 1))) { func_80050E34(temp_a0, var_s0); } } if (gModeSelection == 1) { - func_80050E34(0, D_80164408[0]); + func_80050E34(0, gGPCurrentRaceRankByPlayerIdDup[0]); } else if (gPlayerCountSelection1 == 1) { func_80050E34(0, gGPCurrentRaceRankByPlayerId[0]); } @@ -3745,7 +3745,7 @@ void func_80053D74(s32 objectIndex, UNUSED s32 arg1, s32 vertexIndex) { } } -void func_80053E6C(s32 arg0) { +void render_object_grand_prix_balloons(s32 arg0) { s32 var_s1; s32 objectIndex; @@ -3761,7 +3761,7 @@ void func_80053E6C(s32 arg0) { func_80053D74(objectIndex, arg0, 0); } } - rsp_load_texture(D_8018D4C0, 0x40, 0x20); + rsp_load_texture(D_8018D4C0, 64, 32); for (var_s1 = 0; var_s1 < D_80165738; var_s1++) { objectIndex = gObjectParticle3[var_s1]; if ((objectIndex != NULL_OBJECT_ID) && (gObjectList[objectIndex].state >= 2)) { diff --git a/src/render_objects.h b/src/render_objects.h index 9069fb76d6..24fd02f847 100644 --- a/src/render_objects.h +++ b/src/render_objects.h @@ -295,7 +295,7 @@ void func_8004EE54(s32); void func_8004EF9C(s32); void render_mini_map_finish_line(s32); -void func_8004F168(s32, s32, s32); +void draw_minimap_character(s32, s32, s32); void func_8004F3E4(s32); s32 func_8004F674(s32*, s32); void print_timer(s32, s32, s32); @@ -346,7 +346,7 @@ void func_800534E8(s32); void render_object_thwomps_model(s32); void render_object_thwomps(s32); void func_80053D74(s32, s32, s32); -void func_80053E6C(s32); +void render_object_grand_prix_balloons(s32); void render_object_train_smoke_particle(s32, s32); void render_object_trains_smoke_particles(s32); diff --git a/src/render_player.c b/src/render_player.c index 5624ac9996..0147e67d95 100644 --- a/src/render_player.c +++ b/src/render_player.c @@ -17,7 +17,7 @@ #include "code_80057C60.h" #include "effects.h" #include "buffers.h" -#include "waypoints.h" +#include "path.h" #include "player_controller.h" #include "render_objects.h" #include @@ -1091,12 +1091,12 @@ void change_player_color_effect_cmy(UNUSED Player* player, s8 arg1, s32 arg2, f3 bool is_player_under_light_luigi_raceway(Player* player, s8 arg1) { switch (gCurrentCourseId) { case COURSE_LUIGI_RACEWAY: - if (((gNearestWaypointByPlayerId[arg1] >= 0x14F) && (gNearestWaypointByPlayerId[arg1] < 0x158)) || - ((gNearestWaypointByPlayerId[arg1] >= 0x15E) && (gNearestWaypointByPlayerId[arg1] < 0x164)) || - ((gNearestWaypointByPlayerId[arg1] >= 0x169) && (gNearestWaypointByPlayerId[arg1] < 0x170)) || - ((gNearestWaypointByPlayerId[arg1] >= 0x174) && (gNearestWaypointByPlayerId[arg1] < 0x17A)) || - ((gNearestWaypointByPlayerId[arg1] >= 0x17E) && - (gNearestWaypointByPlayerId[arg1] < 0x184))) { // under a light in the tunnel + if (((gNearestPathPointByPlayerId[arg1] >= 0x14F) && (gNearestPathPointByPlayerId[arg1] < 0x158)) || + ((gNearestPathPointByPlayerId[arg1] >= 0x15E) && (gNearestPathPointByPlayerId[arg1] < 0x164)) || + ((gNearestPathPointByPlayerId[arg1] >= 0x169) && (gNearestPathPointByPlayerId[arg1] < 0x170)) || + ((gNearestPathPointByPlayerId[arg1] >= 0x174) && (gNearestPathPointByPlayerId[arg1] < 0x17A)) || + ((gNearestPathPointByPlayerId[arg1] >= 0x17E) && + (gNearestPathPointByPlayerId[arg1] < 0x184))) { // under a light in the tunnel change_player_color_effect_rgb(player, arg1, COLOR_LIGHT, 0.3f); change_player_color_effect_cmy(player, arg1, 0xE0, 0.3f); D_80164B80[arg1] = 0; @@ -1112,20 +1112,20 @@ bool is_player_under_light_luigi_raceway(Player* player, s8 arg1) { void render_light_environment_on_player(Player* player, s8 arg1) { switch (gCurrentCourseId) { case COURSE_BOWSER_CASTLE: - if (((gNearestWaypointByPlayerId[arg1] >= 0x15) && (gNearestWaypointByPlayerId[arg1] < 0x2A)) || - ((gNearestWaypointByPlayerId[arg1] >= 0x14D) && (gNearestWaypointByPlayerId[arg1] < 0x15C)) || - ((gNearestWaypointByPlayerId[arg1] >= 0x1D1) && (gNearestWaypointByPlayerId[arg1] < 0x1E4)) || + if (((gNearestPathPointByPlayerId[arg1] >= 0x15) && (gNearestPathPointByPlayerId[arg1] < 0x2A)) || + ((gNearestPathPointByPlayerId[arg1] >= 0x14D) && (gNearestPathPointByPlayerId[arg1] < 0x15C)) || + ((gNearestPathPointByPlayerId[arg1] >= 0x1D1) && (gNearestPathPointByPlayerId[arg1] < 0x1E4)) || (player->collision.surfaceDistance[2] >= 500.0f)) { // over lava change_player_color_effect_rgb(player, arg1, COLOR_LAVA, 0.3f); change_player_color_effect_cmy(player, arg1, 0x004040, 0.3f); D_80164B80[arg1] = 0; - } else if (((gNearestWaypointByPlayerId[arg1] >= 0xF1) && (gNearestWaypointByPlayerId[arg1] < 0xF5)) || - ((gNearestWaypointByPlayerId[arg1] >= 0xFB) && (gNearestWaypointByPlayerId[arg1] < 0xFF)) || - ((gNearestWaypointByPlayerId[arg1] >= 0x105) && (gNearestWaypointByPlayerId[arg1] < 0x109)) || - ((gNearestWaypointByPlayerId[arg1] >= 0x10F) && (gNearestWaypointByPlayerId[arg1] < 0x113)) || - ((gNearestWaypointByPlayerId[arg1] >= 0x145) && (gNearestWaypointByPlayerId[arg1] < 0x14A)) || - ((gNearestWaypointByPlayerId[arg1] >= 0x15E) && - (gNearestWaypointByPlayerId[arg1] < 0x163))) { // under a lamp + } else if (((gNearestPathPointByPlayerId[arg1] >= 0xF1) && (gNearestPathPointByPlayerId[arg1] < 0xF5)) || + ((gNearestPathPointByPlayerId[arg1] >= 0xFB) && (gNearestPathPointByPlayerId[arg1] < 0xFF)) || + ((gNearestPathPointByPlayerId[arg1] >= 0x105) && (gNearestPathPointByPlayerId[arg1] < 0x109)) || + ((gNearestPathPointByPlayerId[arg1] >= 0x10F) && (gNearestPathPointByPlayerId[arg1] < 0x113)) || + ((gNearestPathPointByPlayerId[arg1] >= 0x145) && (gNearestPathPointByPlayerId[arg1] < 0x14A)) || + ((gNearestPathPointByPlayerId[arg1] >= 0x15E) && + (gNearestPathPointByPlayerId[arg1] < 0x163))) { // under a lamp change_player_color_effect_rgb(player, arg1, COLOR_LIGHT, 0.3f); change_player_color_effect_cmy(player, arg1, 0xE0, 0.3f); D_80164B80[arg1] = 0; @@ -1136,25 +1136,25 @@ void render_light_environment_on_player(Player* player, s8 arg1) { } break; case COURSE_BANSHEE_BOARDWALK: - if (((gNearestWaypointByPlayerId[arg1] >= 0xD) && (gNearestWaypointByPlayerId[arg1] < 0x15)) || - ((gNearestWaypointByPlayerId[arg1] >= 0x29) && (gNearestWaypointByPlayerId[arg1] < 0x39)) || - ((gNearestWaypointByPlayerId[arg1] >= 0x46) && (gNearestWaypointByPlayerId[arg1] < 0x4E)) || - ((gNearestWaypointByPlayerId[arg1] >= 0x5F) && (gNearestWaypointByPlayerId[arg1] < 0x67)) || - ((gNearestWaypointByPlayerId[arg1] >= 0x7B) && (gNearestWaypointByPlayerId[arg1] < 0x86)) || - ((gNearestWaypointByPlayerId[arg1] >= 0x9D) && (gNearestWaypointByPlayerId[arg1] < 0xA6)) || - ((gNearestWaypointByPlayerId[arg1] >= 0xB9) && (gNearestWaypointByPlayerId[arg1] < 0xC3)) || - ((gNearestWaypointByPlayerId[arg1] >= 0xB9) && (gNearestWaypointByPlayerId[arg1] < 0xC3)) || - ((gNearestWaypointByPlayerId[arg1] >= 0xD7) && (gNearestWaypointByPlayerId[arg1] < 0xE1)) || - ((gNearestWaypointByPlayerId[arg1] >= 0x10E) && (gNearestWaypointByPlayerId[arg1] < 0x119)) || - ((gNearestWaypointByPlayerId[arg1] >= 0x154) && (gNearestWaypointByPlayerId[arg1] < 0x15F)) || - ((gNearestWaypointByPlayerId[arg1] >= 0x1EF) && (gNearestWaypointByPlayerId[arg1] < 0x1F7)) || - ((gNearestWaypointByPlayerId[arg1] >= 0x202) && (gNearestWaypointByPlayerId[arg1] < 0x209)) || - ((gNearestWaypointByPlayerId[arg1] >= 0x216) && (gNearestWaypointByPlayerId[arg1] < 0x21D)) || - ((gNearestWaypointByPlayerId[arg1] >= 0x230) && (gNearestWaypointByPlayerId[arg1] < 0x23A)) || - ((gNearestWaypointByPlayerId[arg1] >= 0x24C) && (gNearestWaypointByPlayerId[arg1] < 0x256)) || - ((gNearestWaypointByPlayerId[arg1] >= 0x288) && (gNearestWaypointByPlayerId[arg1] < 0x269)) || - ((gNearestWaypointByPlayerId[arg1] >= 0x274) && - (gNearestWaypointByPlayerId[arg1] < 0x27E))) { // under a lamp + if (((gNearestPathPointByPlayerId[arg1] >= 0xD) && (gNearestPathPointByPlayerId[arg1] < 0x15)) || + ((gNearestPathPointByPlayerId[arg1] >= 0x29) && (gNearestPathPointByPlayerId[arg1] < 0x39)) || + ((gNearestPathPointByPlayerId[arg1] >= 0x46) && (gNearestPathPointByPlayerId[arg1] < 0x4E)) || + ((gNearestPathPointByPlayerId[arg1] >= 0x5F) && (gNearestPathPointByPlayerId[arg1] < 0x67)) || + ((gNearestPathPointByPlayerId[arg1] >= 0x7B) && (gNearestPathPointByPlayerId[arg1] < 0x86)) || + ((gNearestPathPointByPlayerId[arg1] >= 0x9D) && (gNearestPathPointByPlayerId[arg1] < 0xA6)) || + ((gNearestPathPointByPlayerId[arg1] >= 0xB9) && (gNearestPathPointByPlayerId[arg1] < 0xC3)) || + ((gNearestPathPointByPlayerId[arg1] >= 0xB9) && (gNearestPathPointByPlayerId[arg1] < 0xC3)) || + ((gNearestPathPointByPlayerId[arg1] >= 0xD7) && (gNearestPathPointByPlayerId[arg1] < 0xE1)) || + ((gNearestPathPointByPlayerId[arg1] >= 0x10E) && (gNearestPathPointByPlayerId[arg1] < 0x119)) || + ((gNearestPathPointByPlayerId[arg1] >= 0x154) && (gNearestPathPointByPlayerId[arg1] < 0x15F)) || + ((gNearestPathPointByPlayerId[arg1] >= 0x1EF) && (gNearestPathPointByPlayerId[arg1] < 0x1F7)) || + ((gNearestPathPointByPlayerId[arg1] >= 0x202) && (gNearestPathPointByPlayerId[arg1] < 0x209)) || + ((gNearestPathPointByPlayerId[arg1] >= 0x216) && (gNearestPathPointByPlayerId[arg1] < 0x21D)) || + ((gNearestPathPointByPlayerId[arg1] >= 0x230) && (gNearestPathPointByPlayerId[arg1] < 0x23A)) || + ((gNearestPathPointByPlayerId[arg1] >= 0x24C) && (gNearestPathPointByPlayerId[arg1] < 0x256)) || + ((gNearestPathPointByPlayerId[arg1] >= 0x288) && (gNearestPathPointByPlayerId[arg1] < 0x269)) || + ((gNearestPathPointByPlayerId[arg1] >= 0x274) && + (gNearestPathPointByPlayerId[arg1] < 0x27E))) { // under a lamp change_player_color_effect_rgb(player, arg1, COLOR_LIGHT, 0.3f); change_player_color_effect_cmy(player, arg1, 0x0000E0, 0.3f); D_80164B80[arg1] = 0; @@ -1298,11 +1298,11 @@ void render_player_shadow(Player* player, s8 playerId, s8 screenId) { spB0 = -coss(temp_t9 << 7) * 2; spAC = -sins(temp_t9 << 7) * 2; - if (((player->effects & 0x01000000) == 0x01000000) || ((player->effects & 0x400) == 0x400) || - ((player->effects & 0x80000) == 0x80000) || ((player->effects & 0x800000) == 0x800000) || - ((player->effects & 0x400) == 0x400) || ((player->unk_0CA & 2) == 2) || - ((player->effects & HIT_BY_ITEM_EFFECT) == HIT_BY_ITEM_EFFECT) || ((player->effects & 0x10000) == 0x10000) || - ((player->effects & 8) == 8)) { + if (((player->effects & UNKNOWN_EFFECT_0x1000000) == UNKNOWN_EFFECT_0x1000000) || + ((player->effects & 0x400) == 0x400) || ((player->effects & 0x80000) == 0x80000) || + ((player->effects & 0x800000) == 0x800000) || ((player->effects & 0x400) == 0x400) || + ((player->unk_0CA & 2) == 2) || ((player->effects & HIT_BY_ITEM_EFFECT) == HIT_BY_ITEM_EFFECT) || + ((player->effects & UNKNOWN_EFFECT_0x10000) == UNKNOWN_EFFECT_0x10000) || ((player->effects & 8) == 8)) { var_f2 = (f32) (1.0 - ((f64) player->collision.surfaceDistance[2] * 0.02)); if (var_f2 < 0.0f) { @@ -1753,7 +1753,7 @@ void func_80026A48(Player* player, s8 arg1) { return; } - temp_f0 = ((player->unk_094 * (1.0f + player->unk_104)) / 18.0f) * 216.0f; + temp_f0 = ((player->speed * (1.0f + player->unk_104)) / 18.0f) * 216.0f; if ((temp_f0 <= 1.0f) || (gIsPlayerTripleBButtonCombo[arg1] == true)) { player->unk_240 = 0; } else { diff --git a/src/spawn_players.c b/src/spawn_players.c index b532c9d049..72b3a40ef5 100644 --- a/src/spawn_players.c +++ b/src/spawn_players.c @@ -6,7 +6,7 @@ #include "code_800029B0.h" #include "kart_attributes.h" #include "memory.h" -#include "waypoints.h" +#include "path.h" #include "buffers.h" #include "kart_dma.h" #include "camera.h" @@ -16,7 +16,7 @@ #include "collision.h" #include "render_courses.h" #include "staff_ghosts.h" -#include "code_80005FD0.h" +#include "cpu_vehicles_camera_path.h" #include "render_player.h" #include "podium_ceremony_actors.h" #include "main.h" @@ -37,8 +37,8 @@ s32 D_801652E0[8]; s16 D_80165300[8]; // Shadows values from gPathIndexByPlayerId, but is an array u16 gCopyPathIndexByPlayerId[8]; -// Shadows values from gNearestWaypointByPlayerId, but is an array -s16 gCopyNearestWaypointByPlayerId[8]; +// Shadows values from gNearestPathPointByPlayerId, but is an array +s16 gCopyNearestPathPointByPlayerId[8]; s16 D_80165330[8]; s16 D_80165340; UNUSED s32 D_80165348[29]; @@ -58,7 +58,7 @@ s32 gCountBChangement[8]; bool gIsPlayerTripleBButtonCombo[8]; s32 gTimerBoostTripleBCombo[8]; -s16 chooseKartAIPlayers[7]; +s16 cpu_chooseCharacters[7]; s16 D_8016556E; s16 D_80165570; @@ -118,7 +118,7 @@ void spawn_player(Player* player, s8 playerIndex, f32 startingRow, f32 startingC player->oldPos[0] = startingRow; player->oldPos[1] = ret; - D_80164510[playerIndex] = ret; + gPlayerPathY[playerIndex] = ret; player->rotation[0] = 0; player->oldPos[2] = startingColumn; @@ -141,7 +141,7 @@ void spawn_player(Player* player, s8 playerIndex, f32 startingRow, f32 startingC player->lapCount = -1; player->unk_08C = 0.0f; player->unk_090 = 0.0f; - player->unk_094 = 0.0f; + player->speed = 0.0f; player->unk_074 = 0.0f; player->type = playerType; player->unk_0CA = 0; @@ -193,7 +193,7 @@ void spawn_player(Player* player, s8 playerIndex, f32 startingRow, f32 startingC player->unk_10C = 0; player->unk_200 = 0; player->unk_204 = 0; - player->nearestWaypointId = 0; + player->nearestPathPointId = 0; player->unk_228 = 0; player->unk_22A = 0; player->unk_234 = 0; @@ -223,7 +223,7 @@ void spawn_player(Player* player, s8 playerIndex, f32 startingRow, f32 startingC player->unk_088 = 0.0f; player->unk_08C = 0.0f; player->unk_090 = 0.0f; - player->unk_094 = 0.0f; + player->speed = 0.0f; player->unk_098 = 0.0f; player->currentSpeed = 0.0f; player->unk_0A0 = 0.0f; @@ -243,7 +243,7 @@ void spawn_player(Player* player, s8 playerIndex, f32 startingRow, f32 startingC player->unk_210 = 0.0f; player->unk_218 = 0.0f; player->unk_21C = 0.0f; - player->unk_22C = 0.0f; + player->previousSpeed = 0.0f; player->unk_230 = 0.0f; player->unk_23C = 0.0f; @@ -494,16 +494,16 @@ void spawn_players_gp_one_player(f32* arg0, f32* arg1, f32 arg2) { } while (rand == gCharacterSelections[0]); // Randomize gPlayerTwo - chooseKartAIPlayers[0] = rand; + cpu_chooseCharacters[0] = rand; // Chooses arr[0] as a fallback to prevent duplicating characters. // If it doesn't find the if, it will grab the final index as a fallback. for (i = 1; i < 7; i++) { - u16* arr = (u16*) gKartAIforPlayer[gCharacterSelections[0]]; + u16* arr = (u16*) cpu_forPlayer[gCharacterSelections[0]]; if (rand == arr[i]) { - chooseKartAIPlayers[i] = arr[0]; + cpu_chooseCharacters[i] = arr[0]; } else { - chooseKartAIPlayers[i] = arr[i]; + cpu_chooseCharacters[i] = arr[i]; } } } @@ -511,39 +511,39 @@ void spawn_players_gp_one_player(f32* arg0, f32* arg1, f32 arg2) { D_8016556E = 0; if (gDemoMode == 1) { spawn_player(gPlayerOneCopy, 0, arg0[D_80165270[0]], arg1[D_80165270[0]], arg2, 32768.0f, - gCharacterSelections[0], PLAYER_HUMAN_AND_KART_AI); - spawn_player(gPlayerTwo, 1, arg0[D_80165270[1]], arg1[D_80165270[1]], arg2, 32768.0f, chooseKartAIPlayers[0], - PLAYER_EXISTS | PLAYER_KART_AI | PLAYER_START_SEQUENCE); - spawn_player(gPlayerThree, 2, arg0[D_80165270[2]], arg1[D_80165270[2]], arg2, 32768.0f, chooseKartAIPlayers[1], - PLAYER_EXISTS | PLAYER_KART_AI | PLAYER_START_SEQUENCE); - spawn_player(gPlayerFour, 3, arg0[D_80165270[3]], arg1[D_80165270[3]], arg2, 32768.0f, chooseKartAIPlayers[2], - PLAYER_EXISTS | PLAYER_KART_AI | PLAYER_START_SEQUENCE); - spawn_player(gPlayerFive, 4, arg0[D_80165270[4]], arg1[D_80165270[4]], arg2, 32768.0f, chooseKartAIPlayers[3], - PLAYER_EXISTS | PLAYER_KART_AI | PLAYER_START_SEQUENCE); - spawn_player(gPlayerSix, 5, arg0[D_80165270[5]], arg1[D_80165270[5]], arg2, 32768.0f, chooseKartAIPlayers[4], - PLAYER_EXISTS | PLAYER_KART_AI | PLAYER_START_SEQUENCE); - spawn_player(gPlayerSeven, 6, arg0[D_80165270[6]], arg1[D_80165270[6]], arg2, 32768.0f, chooseKartAIPlayers[5], - PLAYER_EXISTS | PLAYER_KART_AI | PLAYER_START_SEQUENCE); - spawn_player(gPlayerEight, 7, arg0[D_80165270[7]], arg1[D_80165270[7]], arg2, 32768.0f, chooseKartAIPlayers[6], - PLAYER_EXISTS | PLAYER_KART_AI | PLAYER_START_SEQUENCE); + gCharacterSelections[0], PLAYER_HUMAN_AND_CPU); + spawn_player(gPlayerTwo, 1, arg0[D_80165270[1]], arg1[D_80165270[1]], arg2, 32768.0f, cpu_chooseCharacters[0], + PLAYER_EXISTS | PLAYER_CPU | PLAYER_START_SEQUENCE); + spawn_player(gPlayerThree, 2, arg0[D_80165270[2]], arg1[D_80165270[2]], arg2, 32768.0f, cpu_chooseCharacters[1], + PLAYER_EXISTS | PLAYER_CPU | PLAYER_START_SEQUENCE); + spawn_player(gPlayerFour, 3, arg0[D_80165270[3]], arg1[D_80165270[3]], arg2, 32768.0f, cpu_chooseCharacters[2], + PLAYER_EXISTS | PLAYER_CPU | PLAYER_START_SEQUENCE); + spawn_player(gPlayerFive, 4, arg0[D_80165270[4]], arg1[D_80165270[4]], arg2, 32768.0f, cpu_chooseCharacters[3], + PLAYER_EXISTS | PLAYER_CPU | PLAYER_START_SEQUENCE); + spawn_player(gPlayerSix, 5, arg0[D_80165270[5]], arg1[D_80165270[5]], arg2, 32768.0f, cpu_chooseCharacters[4], + PLAYER_EXISTS | PLAYER_CPU | PLAYER_START_SEQUENCE); + spawn_player(gPlayerSeven, 6, arg0[D_80165270[6]], arg1[D_80165270[6]], arg2, 32768.0f, cpu_chooseCharacters[5], + PLAYER_EXISTS | PLAYER_CPU | PLAYER_START_SEQUENCE); + spawn_player(gPlayerEight, 7, arg0[D_80165270[7]], arg1[D_80165270[7]], arg2, 32768.0f, cpu_chooseCharacters[6], + PLAYER_EXISTS | PLAYER_CPU | PLAYER_START_SEQUENCE); D_80164A28 = 0; } else { spawn_player(gPlayerOneCopy, 0, arg0[D_80165270[0]], arg1[D_80165270[0]] + 250.0f, arg2, 32768.0f, gCharacterSelections[0], PLAYER_EXISTS | PLAYER_STAGING | PLAYER_START_SEQUENCE | PLAYER_HUMAN); spawn_player(gPlayerTwo, 1, arg0[D_80165270[1]], arg1[D_80165270[1]] + 250.0f, arg2, 32768.0f, - chooseKartAIPlayers[0], PLAYER_EXISTS | PLAYER_STAGING | PLAYER_START_SEQUENCE | PLAYER_KART_AI); + cpu_chooseCharacters[0], PLAYER_EXISTS | PLAYER_STAGING | PLAYER_START_SEQUENCE | PLAYER_CPU); spawn_player(gPlayerThree, 2, arg0[D_80165270[3]], arg1[D_80165270[2]] + 250.0f, arg2, 32768.0f, - chooseKartAIPlayers[1], PLAYER_EXISTS | PLAYER_STAGING | PLAYER_START_SEQUENCE | PLAYER_KART_AI); + cpu_chooseCharacters[1], PLAYER_EXISTS | PLAYER_STAGING | PLAYER_START_SEQUENCE | PLAYER_CPU); spawn_player(gPlayerFour, 3, arg0[D_80165270[2]], arg1[D_80165270[3]] + 250.0f, arg2, 32768.0f, - chooseKartAIPlayers[2], PLAYER_EXISTS | PLAYER_STAGING | PLAYER_START_SEQUENCE | PLAYER_KART_AI); + cpu_chooseCharacters[2], PLAYER_EXISTS | PLAYER_STAGING | PLAYER_START_SEQUENCE | PLAYER_CPU); spawn_player(gPlayerFive, 4, arg0[D_80165270[5]], arg1[D_80165270[4]] + 250.0f, arg2, 32768.0f, - chooseKartAIPlayers[3], PLAYER_EXISTS | PLAYER_STAGING | PLAYER_START_SEQUENCE | PLAYER_KART_AI); + cpu_chooseCharacters[3], PLAYER_EXISTS | PLAYER_STAGING | PLAYER_START_SEQUENCE | PLAYER_CPU); spawn_player(gPlayerSix, 5, arg0[D_80165270[4]], arg1[D_80165270[5]] + 250.0f, arg2, 32768.0f, - chooseKartAIPlayers[4], PLAYER_EXISTS | PLAYER_STAGING | PLAYER_START_SEQUENCE | PLAYER_KART_AI); + cpu_chooseCharacters[4], PLAYER_EXISTS | PLAYER_STAGING | PLAYER_START_SEQUENCE | PLAYER_CPU); spawn_player(gPlayerSeven, 6, arg0[D_80165270[7]], arg1[D_80165270[6]] + 250.0f, arg2, 32768.0f, - chooseKartAIPlayers[5], PLAYER_EXISTS | PLAYER_STAGING | PLAYER_START_SEQUENCE | PLAYER_KART_AI); + cpu_chooseCharacters[5], PLAYER_EXISTS | PLAYER_STAGING | PLAYER_START_SEQUENCE | PLAYER_CPU); spawn_player(gPlayerEight, 7, arg0[D_80165270[6]], arg1[D_80165270[7]] + 250.0f, arg2, 32768.0f, - chooseKartAIPlayers[6], PLAYER_EXISTS | PLAYER_STAGING | PLAYER_START_SEQUENCE | PLAYER_KART_AI); + cpu_chooseCharacters[6], PLAYER_EXISTS | PLAYER_STAGING | PLAYER_START_SEQUENCE | PLAYER_CPU); D_80164A28 = 1; } func_80039AE4(); @@ -551,22 +551,22 @@ void spawn_players_gp_one_player(f32* arg0, f32* arg1, f32 arg2) { void spawn_players_versus_one_player(f32* arg0, f32* arg1, f32 arg2) { spawn_player(gPlayerFour, 3, arg0[2], arg1[2], arg2, 32768.0f, gCharacterSelections[0], - PLAYER_START_SEQUENCE | PLAYER_KART_AI); + PLAYER_START_SEQUENCE | PLAYER_CPU); spawn_player(gPlayerFive, 4, arg0[3], arg1[3], arg2, 32768.0f, gCharacterSelections[0], - PLAYER_START_SEQUENCE | PLAYER_KART_AI); + PLAYER_START_SEQUENCE | PLAYER_CPU); spawn_player(gPlayerSix, 5, arg0[4], arg1[4], arg2, 32768.0f, gCharacterSelections[0], - PLAYER_START_SEQUENCE | PLAYER_KART_AI); + PLAYER_START_SEQUENCE | PLAYER_CPU); spawn_player(gPlayerSeven, 6, arg0[5], arg1[5], arg2, 32768.0f, gCharacterSelections[0], - PLAYER_START_SEQUENCE | PLAYER_KART_AI); + PLAYER_START_SEQUENCE | PLAYER_CPU); spawn_player(gPlayerEight, 7, arg0[6], arg1[6], arg2, 32768.0f, gCharacterSelections[0], - PLAYER_START_SEQUENCE | PLAYER_KART_AI); + PLAYER_START_SEQUENCE | PLAYER_CPU); if (gDemoMode == 1) { spawn_player(gPlayerOneCopy, 0, arg0[0], arg1[0], arg2, 32768.0f, gCharacterSelections[0], - PLAYER_HUMAN_AND_KART_AI); + PLAYER_HUMAN_AND_CPU); spawn_player(gPlayerTwo, 1, arg0[0], arg1[0], arg2, 32768.0f, gCharacterSelections[0], - PLAYER_START_SEQUENCE | PLAYER_KART_AI); + PLAYER_START_SEQUENCE | PLAYER_CPU); spawn_player(gPlayerThree, 2, arg0[1], arg1[1], arg2, 32768.0f, gCharacterSelections[0], - PLAYER_START_SEQUENCE | PLAYER_KART_AI); + PLAYER_START_SEQUENCE | PLAYER_CPU); } else if (D_8015F890 != 1) { spawn_player(gPlayerOneCopy, 0, arg0[0], arg1[0], arg2, 32768.0f, gCharacterSelections[0], PLAYER_EXISTS | PLAYER_START_SEQUENCE | PLAYER_HUMAN); @@ -575,14 +575,14 @@ void spawn_players_versus_one_player(f32* arg0, f32* arg1, f32 arg2) { PLAYER_EXISTS | PLAYER_HUMAN | PLAYER_START_SEQUENCE | PLAYER_INVISIBLE_OR_BOMB); } else { spawn_player(gPlayerTwo, 1, arg0[0], arg1[0], arg2, 32768.0f, gCharacterSelections[0], - PLAYER_START_SEQUENCE | PLAYER_KART_AI); + PLAYER_START_SEQUENCE | PLAYER_CPU); } if (D_80162DD6 == 0) { spawn_player(gPlayerThree, 2, arg0[0], arg1[0], arg2, 32768.0f, D_80162DE4, PLAYER_EXISTS | PLAYER_HUMAN | PLAYER_START_SEQUENCE | PLAYER_INVISIBLE_OR_BOMB); } else { spawn_player(gPlayerThree, 2, arg0[1], arg1[1], arg2, 32768.0f, gCharacterSelections[0], - PLAYER_START_SEQUENCE | PLAYER_KART_AI); + PLAYER_START_SEQUENCE | PLAYER_CPU); } } else { spawn_player(gPlayerOneCopy, 0, arg0[0], arg1[0], arg2, 32768.0f, D_80162DE8, @@ -592,14 +592,14 @@ void spawn_players_versus_one_player(f32* arg0, f32* arg1, f32 arg2) { PLAYER_EXISTS | PLAYER_HUMAN | PLAYER_START_SEQUENCE | PLAYER_INVISIBLE_OR_BOMB); } else { spawn_player(gPlayerTwo, 1, arg0[0], arg1[0], arg2, 32768.0f, gCharacterSelections[0], - PLAYER_START_SEQUENCE | PLAYER_KART_AI); + PLAYER_START_SEQUENCE | PLAYER_CPU); } if (D_80162DD6 == 0) { spawn_player(gPlayerThree, 2, arg0[0], arg1[0], arg2, 32768.0f, D_80162DE4, PLAYER_EXISTS | PLAYER_HUMAN | PLAYER_START_SEQUENCE | PLAYER_INVISIBLE_OR_BOMB); } else { spawn_player(gPlayerThree, 2, arg0[1], arg1[1], arg2, 32768.0f, gCharacterSelections[0], - PLAYER_START_SEQUENCE | PLAYER_KART_AI); + PLAYER_START_SEQUENCE | PLAYER_CPU); } } D_80164A28 = 0; @@ -622,41 +622,41 @@ void spawn_players_gp_two_player(f32* arg0, f32* arg1, f32 arg2) { goto getRand; } - chooseKartAIPlayers[0] = rand; + cpu_chooseCharacters[0] = rand; for (i = 1; i < 6; i++) { - u16* arr = (u16*) gKartAIforTwoPlayer[gCharacterSelections[0]][gCharacterSelections[1]]; + u16* arr = (u16*) cpu_forTwoPlayer[gCharacterSelections[0]][gCharacterSelections[1]]; if (rand == arr[i]) { - chooseKartAIPlayers[i] = arr[0]; + cpu_chooseCharacters[i] = arr[0]; } else { - chooseKartAIPlayers[i] = arr[i]; + cpu_chooseCharacters[i] = arr[i]; } } } - spawn_player(gPlayerThree, 2, arg0[D_80165270[2]], arg1[D_80165270[2]], arg2, 32768.0f, chooseKartAIPlayers[0], - PLAYER_EXISTS | PLAYER_KART_AI | PLAYER_START_SEQUENCE); - spawn_player(gPlayerFour, 3, arg0[D_80165270[3]], arg1[D_80165270[3]], arg2, 32768.0f, chooseKartAIPlayers[1], - PLAYER_EXISTS | PLAYER_KART_AI | PLAYER_START_SEQUENCE); - spawn_player(gPlayerFive, 4, arg0[D_80165270[4]], arg1[D_80165270[4]], arg2, 32768.0f, chooseKartAIPlayers[2], - PLAYER_EXISTS | PLAYER_KART_AI | PLAYER_START_SEQUENCE); - spawn_player(gPlayerSix, 5, arg0[D_80165270[5]], arg1[D_80165270[5]], arg2, 32768.0f, chooseKartAIPlayers[3], - PLAYER_EXISTS | PLAYER_KART_AI | PLAYER_START_SEQUENCE); - spawn_player(gPlayerSeven, 6, arg0[D_80165270[6]], arg1[D_80165270[6]], arg2, 32768.0f, chooseKartAIPlayers[4], - PLAYER_EXISTS | PLAYER_KART_AI | PLAYER_START_SEQUENCE); - spawn_player(gPlayerEight, 7, arg0[D_80165270[7]], arg1[D_80165270[7]], arg2, 32768.0f, chooseKartAIPlayers[5], - PLAYER_EXISTS | PLAYER_KART_AI | PLAYER_START_SEQUENCE); + spawn_player(gPlayerThree, 2, arg0[D_80165270[2]], arg1[D_80165270[2]], arg2, 32768.0f, cpu_chooseCharacters[0], + PLAYER_EXISTS | PLAYER_CPU | PLAYER_START_SEQUENCE); + spawn_player(gPlayerFour, 3, arg0[D_80165270[3]], arg1[D_80165270[3]], arg2, 32768.0f, cpu_chooseCharacters[1], + PLAYER_EXISTS | PLAYER_CPU | PLAYER_START_SEQUENCE); + spawn_player(gPlayerFive, 4, arg0[D_80165270[4]], arg1[D_80165270[4]], arg2, 32768.0f, cpu_chooseCharacters[2], + PLAYER_EXISTS | PLAYER_CPU | PLAYER_START_SEQUENCE); + spawn_player(gPlayerSix, 5, arg0[D_80165270[5]], arg1[D_80165270[5]], arg2, 32768.0f, cpu_chooseCharacters[3], + PLAYER_EXISTS | PLAYER_CPU | PLAYER_START_SEQUENCE); + spawn_player(gPlayerSeven, 6, arg0[D_80165270[6]], arg1[D_80165270[6]], arg2, 32768.0f, cpu_chooseCharacters[4], + PLAYER_EXISTS | PLAYER_CPU | PLAYER_START_SEQUENCE); + spawn_player(gPlayerEight, 7, arg0[D_80165270[7]], arg1[D_80165270[7]], arg2, 32768.0f, cpu_chooseCharacters[5], + PLAYER_EXISTS | PLAYER_CPU | PLAYER_START_SEQUENCE); if (gDemoMode == 1) { spawn_player(gPlayerOneCopy, 0, arg0[D_80165270[0]], arg1[D_80165270[0]], arg2, 32768.0f, - gCharacterSelections[0], PLAYER_HUMAN_AND_KART_AI); + gCharacterSelections[0], PLAYER_HUMAN_AND_CPU); } else { spawn_player(gPlayerOneCopy, 0, arg0[D_80165270[0]], arg1[D_80165270[0]], arg2, 32768.0f, gCharacterSelections[0], PLAYER_EXISTS | PLAYER_START_SEQUENCE | PLAYER_HUMAN); } if (gDemoMode == 1) { spawn_player(gPlayerTwo, 1, arg0[D_80165270[1]], arg1[D_80165270[1]], arg2, 32768.0f, gCharacterSelections[1], - PLAYER_EXISTS | PLAYER_KART_AI | PLAYER_START_SEQUENCE); + PLAYER_EXISTS | PLAYER_CPU | PLAYER_START_SEQUENCE); } else { spawn_player(gPlayerTwo, 1, arg0[D_80165270[1]], arg1[D_80165270[1]], arg2, 32768.0f, gCharacterSelections[1], PLAYER_EXISTS | PLAYER_START_SEQUENCE | PLAYER_HUMAN); @@ -668,27 +668,26 @@ void spawn_players_gp_two_player(f32* arg0, f32* arg1, f32 arg2) { void spawn_players_versus_two_player(f32* arg0, f32* arg1, f32 arg2) { spawn_player(gPlayerThree, 2, arg0[1], arg1[1], arg2, 32768.0f, gCharacterSelections[0], - PLAYER_START_SEQUENCE | PLAYER_KART_AI); + PLAYER_START_SEQUENCE | PLAYER_CPU); spawn_player(gPlayerFour, 3, arg0[2], arg1[2], arg2, 32768.0f, gCharacterSelections[0], - PLAYER_START_SEQUENCE | PLAYER_KART_AI); + PLAYER_START_SEQUENCE | PLAYER_CPU); spawn_player(gPlayerFive, 4, arg0[3], arg1[3], arg2, 32768.0f, gCharacterSelections[0], - PLAYER_START_SEQUENCE | PLAYER_KART_AI); + PLAYER_START_SEQUENCE | PLAYER_CPU); spawn_player(gPlayerSix, 5, arg0[4], arg1[4], arg2, 32768.0f, gCharacterSelections[0], - PLAYER_START_SEQUENCE | PLAYER_KART_AI); + PLAYER_START_SEQUENCE | PLAYER_CPU); spawn_player(gPlayerSeven, 6, arg0[5], arg1[5], arg2, 32768.0f, gCharacterSelections[0], - PLAYER_START_SEQUENCE | PLAYER_KART_AI); + PLAYER_START_SEQUENCE | PLAYER_CPU); spawn_player(gPlayerEight, 7, arg0[6], arg1[6], arg2, 32768.0f, gCharacterSelections[0], - PLAYER_START_SEQUENCE | PLAYER_KART_AI); + PLAYER_START_SEQUENCE | PLAYER_CPU); if (gDemoMode == 1) { spawn_player(gPlayerOneCopy, 0, arg0[0], arg1[0], arg2, 32768.0f, gCharacterSelections[0], - PLAYER_HUMAN_AND_KART_AI); + PLAYER_HUMAN_AND_CPU); } else { spawn_player(gPlayerOneCopy, 0, arg0[0], arg1[0], arg2, 32768.0f, gCharacterSelections[0], PLAYER_EXISTS | PLAYER_START_SEQUENCE | PLAYER_HUMAN); } if (gDemoMode == 1) { - spawn_player(gPlayerTwo, 1, arg0[1], arg1[1], arg2, 32768.0f, gCharacterSelections[1], - PLAYER_HUMAN_AND_KART_AI); + spawn_player(gPlayerTwo, 1, arg0[1], arg1[1], arg2, 32768.0f, gCharacterSelections[1], PLAYER_HUMAN_AND_CPU); } else { spawn_player(gPlayerTwo, 1, arg0[1], arg1[1], arg2, 32768.0f, gCharacterSelections[1], PLAYER_EXISTS | PLAYER_START_SEQUENCE | PLAYER_HUMAN); @@ -713,10 +712,10 @@ void spawn_players_2p_battle(f32* arg0, f32* arg1, f32 arg2) { PLAYER_START_SEQUENCE | PLAYER_HUMAN); spawn_player(gPlayerFour, 3, arg0[3], arg1[3], arg2, 32768.0f, gCharacterSelections[3], PLAYER_START_SEQUENCE | PLAYER_HUMAN); - spawn_player(gPlayerFive, 4, arg0[4], arg1[4], arg2, 32768.0f, 4, PLAYER_START_SEQUENCE | PLAYER_KART_AI); - spawn_player(gPlayerSix, 5, arg0[5], arg1[5], arg2, 32768.0f, 5, PLAYER_START_SEQUENCE | PLAYER_KART_AI); - spawn_player(gPlayerSeven, 6, arg0[6], arg1[6], arg2, 32768.0f, 6, PLAYER_START_SEQUENCE | PLAYER_KART_AI); - spawn_player(gPlayerEight, 7, arg0[0], arg1[0], arg2, 32768.0f, 7, PLAYER_START_SEQUENCE | PLAYER_KART_AI); + spawn_player(gPlayerFive, 4, arg0[4], arg1[4], arg2, 32768.0f, 4, PLAYER_START_SEQUENCE | PLAYER_CPU); + spawn_player(gPlayerSix, 5, arg0[5], arg1[5], arg2, 32768.0f, 5, PLAYER_START_SEQUENCE | PLAYER_CPU); + spawn_player(gPlayerSeven, 6, arg0[6], arg1[6], arg2, 32768.0f, 6, PLAYER_START_SEQUENCE | PLAYER_CPU); + spawn_player(gPlayerEight, 7, arg0[0], arg1[0], arg2, 32768.0f, 7, PLAYER_START_SEQUENCE | PLAYER_CPU); D_80164A28 = 0; func_80039AE4(); } @@ -729,19 +728,16 @@ void func_8003B318(f32* arg0, f32* arg1, f32 arg2) { spawn_player(gPlayerThree, 2, arg0[2], arg1[2], arg2, 32768.0f, gCharacterSelections[2], PLAYER_EXISTS | PLAYER_START_SEQUENCE | PLAYER_HUMAN); if (gDemoMode == 1) { - spawn_player(gPlayerOne, 0, arg0[0], arg1[0], arg2, 32768.0f, gCharacterSelections[0], - PLAYER_HUMAN_AND_KART_AI); - spawn_player(gPlayerTwo, 1, arg0[1], arg1[1], arg2, 32768.0f, gCharacterSelections[1], - PLAYER_HUMAN_AND_KART_AI); - spawn_player(gPlayerThree, 2, arg0[2], arg1[2], arg2, 32768.0f, gCharacterSelections[2], - PLAYER_HUMAN_AND_KART_AI); + spawn_player(gPlayerOne, 0, arg0[0], arg1[0], arg2, 32768.0f, gCharacterSelections[0], PLAYER_HUMAN_AND_CPU); + spawn_player(gPlayerTwo, 1, arg0[1], arg1[1], arg2, 32768.0f, gCharacterSelections[1], PLAYER_HUMAN_AND_CPU); + spawn_player(gPlayerThree, 2, arg0[2], arg1[2], arg2, 32768.0f, gCharacterSelections[2], PLAYER_HUMAN_AND_CPU); } - spawn_player(gPlayerFour, 3, arg0[3], arg1[3], arg2, 32768.0f, 3, PLAYER_START_SEQUENCE | PLAYER_KART_AI); - spawn_player(gPlayerFive, 4, arg0[4], arg1[4], arg2, 32768.0f, 4, PLAYER_START_SEQUENCE | PLAYER_KART_AI); - spawn_player(gPlayerSix, 5, arg0[5], arg1[5], arg2, 32768.0f, 5, PLAYER_START_SEQUENCE | PLAYER_KART_AI); - spawn_player(gPlayerSeven, 6, arg0[6], arg1[6], arg2, 32768.0f, 6, PLAYER_START_SEQUENCE | PLAYER_KART_AI); - spawn_player(gPlayerEight, 7, arg0[0], arg1[0], arg2, 32768.0f, 7, PLAYER_START_SEQUENCE | PLAYER_KART_AI); + spawn_player(gPlayerFour, 3, arg0[3], arg1[3], arg2, 32768.0f, 3, PLAYER_START_SEQUENCE | PLAYER_CPU); + spawn_player(gPlayerFive, 4, arg0[4], arg1[4], arg2, 32768.0f, 4, PLAYER_START_SEQUENCE | PLAYER_CPU); + spawn_player(gPlayerSix, 5, arg0[5], arg1[5], arg2, 32768.0f, 5, PLAYER_START_SEQUENCE | PLAYER_CPU); + spawn_player(gPlayerSeven, 6, arg0[6], arg1[6], arg2, 32768.0f, 6, PLAYER_START_SEQUENCE | PLAYER_CPU); + spawn_player(gPlayerEight, 7, arg0[0], arg1[0], arg2, 32768.0f, 7, PLAYER_START_SEQUENCE | PLAYER_CPU); D_80164A28 = 0; func_80039AE4(); } @@ -762,11 +758,11 @@ void spawn_players_3p_battle(f32* arg0, f32* arg1, f32 arg2) { spawn_player(gPlayerThree, 2, arg0[2], arg1[2], arg2, -16384.0f, gCharacterSelections[2], PLAYER_EXISTS | PLAYER_START_SEQUENCE | PLAYER_HUMAN); } - spawn_player(gPlayerFour, 3, arg0[3], arg1[3], arg2, 32768.0f, 3, PLAYER_START_SEQUENCE | PLAYER_KART_AI); - spawn_player(gPlayerFive, 4, arg0[4], arg1[4], arg2, 32768.0f, 4, PLAYER_START_SEQUENCE | PLAYER_KART_AI); - spawn_player(gPlayerSix, 5, arg0[5], arg1[5], arg2, 32768.0f, 5, PLAYER_START_SEQUENCE | PLAYER_KART_AI); - spawn_player(gPlayerSeven, 6, arg0[6], arg1[6], arg2, 32768.0f, 6, PLAYER_START_SEQUENCE | PLAYER_KART_AI); - spawn_player(gPlayerEight, 7, arg0[0], arg1[0], arg2, 32768.0f, 7, PLAYER_START_SEQUENCE | PLAYER_KART_AI); + spawn_player(gPlayerFour, 3, arg0[3], arg1[3], arg2, 32768.0f, 3, PLAYER_START_SEQUENCE | PLAYER_CPU); + spawn_player(gPlayerFive, 4, arg0[4], arg1[4], arg2, 32768.0f, 4, PLAYER_START_SEQUENCE | PLAYER_CPU); + spawn_player(gPlayerSix, 5, arg0[5], arg1[5], arg2, 32768.0f, 5, PLAYER_START_SEQUENCE | PLAYER_CPU); + spawn_player(gPlayerSeven, 6, arg0[6], arg1[6], arg2, 32768.0f, 6, PLAYER_START_SEQUENCE | PLAYER_CPU); + spawn_player(gPlayerEight, 7, arg0[0], arg1[0], arg2, 32768.0f, 7, PLAYER_START_SEQUENCE | PLAYER_CPU); D_80164A28 = 0; func_80039AE4(); } @@ -781,19 +777,15 @@ void func_8003B870(f32* arg0, f32* arg1, f32 arg2) { spawn_player(gPlayerFour, 3, arg0[3], arg1[3], arg2, 32768.0f, gCharacterSelections[3], PLAYER_EXISTS | PLAYER_START_SEQUENCE | PLAYER_HUMAN); if (gDemoMode == 1) { - spawn_player(gPlayerOne, 0, arg0[0], arg1[0], arg2, 32768.0f, gCharacterSelections[0], - PLAYER_HUMAN_AND_KART_AI); - spawn_player(gPlayerTwo, 1, arg0[1], arg1[1], arg2, 32768.0f, gCharacterSelections[1], - PLAYER_HUMAN_AND_KART_AI); - spawn_player(gPlayerThree, 2, arg0[2], arg1[2], arg2, 32768.0f, gCharacterSelections[2], - PLAYER_HUMAN_AND_KART_AI); - spawn_player(gPlayerFour, 3, arg0[3], arg1[3], arg2, 32768.0f, gCharacterSelections[3], - PLAYER_HUMAN_AND_KART_AI); + spawn_player(gPlayerOne, 0, arg0[0], arg1[0], arg2, 32768.0f, gCharacterSelections[0], PLAYER_HUMAN_AND_CPU); + spawn_player(gPlayerTwo, 1, arg0[1], arg1[1], arg2, 32768.0f, gCharacterSelections[1], PLAYER_HUMAN_AND_CPU); + spawn_player(gPlayerThree, 2, arg0[2], arg1[2], arg2, 32768.0f, gCharacterSelections[2], PLAYER_HUMAN_AND_CPU); + spawn_player(gPlayerFour, 3, arg0[3], arg1[3], arg2, 32768.0f, gCharacterSelections[3], PLAYER_HUMAN_AND_CPU); } - spawn_player(gPlayerFive, 4, arg0[4], arg1[4], arg2, 32768.0f, 4, PLAYER_START_SEQUENCE | PLAYER_KART_AI); - spawn_player(gPlayerSix, 5, arg0[5], arg1[5], arg2, 32768.0f, 5, PLAYER_START_SEQUENCE | PLAYER_KART_AI); - spawn_player(gPlayerSeven, 6, arg0[6], arg1[6], arg2, 32768.0f, 6, PLAYER_START_SEQUENCE | PLAYER_KART_AI); - spawn_player(gPlayerEight, 7, arg0[0], arg1[0], arg2, 32768.0f, 7, PLAYER_START_SEQUENCE | PLAYER_KART_AI); + spawn_player(gPlayerFive, 4, arg0[4], arg1[4], arg2, 32768.0f, 4, PLAYER_START_SEQUENCE | PLAYER_CPU); + spawn_player(gPlayerSix, 5, arg0[5], arg1[5], arg2, 32768.0f, 5, PLAYER_START_SEQUENCE | PLAYER_CPU); + spawn_player(gPlayerSeven, 6, arg0[6], arg1[6], arg2, 32768.0f, 6, PLAYER_START_SEQUENCE | PLAYER_CPU); + spawn_player(gPlayerEight, 7, arg0[0], arg1[0], arg2, 32768.0f, 7, PLAYER_START_SEQUENCE | PLAYER_CPU); D_80164A28 = 0; func_80039AE4(); } @@ -818,27 +810,27 @@ void spawn_players_4p_battle(f32* arg0, f32* arg1, f32 arg2) { spawn_player(gPlayerFour, 3, arg0[3], arg1[3], arg2, 16384.0f, gCharacterSelections[3], PLAYER_EXISTS | PLAYER_START_SEQUENCE | PLAYER_HUMAN); } - spawn_player(gPlayerFive, 4, arg0[4], arg1[4], arg2, 32768.0f, 4, PLAYER_START_SEQUENCE | PLAYER_KART_AI); - spawn_player(gPlayerSix, 5, arg0[5], arg1[5], arg2, 32768.0f, 5, PLAYER_START_SEQUENCE | PLAYER_KART_AI); - spawn_player(gPlayerSeven, 6, arg0[6], arg1[6], arg2, 32768.0f, 6, PLAYER_START_SEQUENCE | PLAYER_KART_AI); - spawn_player(gPlayerEight, 7, arg0[0], arg1[0], arg2, 32768.0f, 7, PLAYER_START_SEQUENCE | PLAYER_KART_AI); + spawn_player(gPlayerFive, 4, arg0[4], arg1[4], arg2, 32768.0f, 4, PLAYER_START_SEQUENCE | PLAYER_CPU); + spawn_player(gPlayerSix, 5, arg0[5], arg1[5], arg2, 32768.0f, 5, PLAYER_START_SEQUENCE | PLAYER_CPU); + spawn_player(gPlayerSeven, 6, arg0[6], arg1[6], arg2, 32768.0f, 6, PLAYER_START_SEQUENCE | PLAYER_CPU); + spawn_player(gPlayerEight, 7, arg0[0], arg1[0], arg2, 32768.0f, 7, PLAYER_START_SEQUENCE | PLAYER_CPU); D_80164A28 = 0; func_80039AE4(); } void func_8003BE30(void) { spawn_player(gPlayerOne, 0, -2770.774f, -345.187f, -34.6f, 0.0f, gCharacterIdByGPOverallRank[0], - PLAYER_EXISTS | PLAYER_KART_AI | PLAYER_START_SEQUENCE); + PLAYER_EXISTS | PLAYER_CPU | PLAYER_START_SEQUENCE); spawn_player(gPlayerTwo, 1, -3691.506f, -6.822f, -6.95f, 36400.0f, gCharacterIdByGPOverallRank[1], - PLAYER_EXISTS | PLAYER_KART_AI | PLAYER_START_SEQUENCE); + PLAYER_EXISTS | PLAYER_CPU | PLAYER_START_SEQUENCE); spawn_player(gPlayerThree, 2, -3475.028f, -998.485f, -8.059f, 45500.0f, gCharacterIdByGPOverallRank[2], - PLAYER_EXISTS | PLAYER_KART_AI | PLAYER_START_SEQUENCE); + PLAYER_EXISTS | PLAYER_CPU | PLAYER_START_SEQUENCE); if (D_802874D8.unk1D >= 3) { spawn_player(gPlayerFour, 3, -3025.772f, 110.039f, -23.224f, 28210.0f, D_802874D8.unk1E, - PLAYER_EXISTS | PLAYER_KART_AI | PLAYER_START_SEQUENCE); + PLAYER_EXISTS | PLAYER_CPU | PLAYER_START_SEQUENCE); } else { spawn_player(gPlayerFour, 3, -3025.772f, 110.039f, -23.224f, 28210.0f, gCharacterIdByGPOverallRank[3], - PLAYER_EXISTS | PLAYER_KART_AI | PLAYER_START_SEQUENCE); + PLAYER_EXISTS | PLAYER_CPU | PLAYER_START_SEQUENCE); } spawn_player(gPlayerFive, 4, -2770.774f, -345.187f, -34.6f, 0.0f, 0, 0x7000); spawn_player(gPlayerSix, 5, -3691.506f, -6.822f, -6.95f, 36400.0f, 0, 0x7000); @@ -871,10 +863,10 @@ void func_8003C0F0(void) { case COURSE_RAINBOW_ROAD: case COURSE_WARIO_STADIUM: case COURSE_DK_JUNGLE: - func_8000F2DC(); - sp5E = (f32) D_80164550[0][0].posX; - sp5C = (f32) D_80164550[0][0].posZ; - sp5A = (f32) D_80164550[0][0].posY; + init_course_path_point(); + sp5E = (f32) gTrackPaths[0][0].posX; + sp5C = (f32) gTrackPaths[0][0].posZ; + sp5A = (f32) gTrackPaths[0][0].posY; if (gCurrentCourseId == COURSE_TOADS_TURNPIKE) { sp5E = 0; } @@ -1143,25 +1135,25 @@ void func_8003C0F0(void) { spawn_player(gPlayerOneCopy, 0, D_80165210[0], D_80165230[0], sp5A, 32768.0f, gCharacterSelections[0], PLAYER_EXISTS | PLAYER_START_SEQUENCE | PLAYER_HUMAN); spawn_player(gPlayerTwo, 1, D_80165210[1], D_80165230[1], sp5A, 32768.0f, 1, - PLAYER_EXISTS | PLAYER_KART_AI | PLAYER_START_SEQUENCE); + PLAYER_EXISTS | PLAYER_CPU | PLAYER_START_SEQUENCE); spawn_player(gPlayerThree, 2, D_80165210[2], D_80165230[2], sp5A, 32768.0f, 2, - PLAYER_EXISTS | PLAYER_KART_AI | PLAYER_START_SEQUENCE); + PLAYER_EXISTS | PLAYER_CPU | PLAYER_START_SEQUENCE); spawn_player(gPlayerFour, 3, D_80165210[3], D_80165230[3], sp5A, 32768.0f, 3, - PLAYER_EXISTS | PLAYER_KART_AI | PLAYER_START_SEQUENCE); + PLAYER_EXISTS | PLAYER_CPU | PLAYER_START_SEQUENCE); spawn_player(gPlayerFive, 4, D_80165210[4], D_80165230[4], sp5A, 32768.0f, 4, - PLAYER_EXISTS | PLAYER_KART_AI | PLAYER_START_SEQUENCE); + PLAYER_EXISTS | PLAYER_CPU | PLAYER_START_SEQUENCE); spawn_player(gPlayerSix, 5, D_80165210[5], D_80165230[5], sp5A, 32768.0f, 5, - PLAYER_EXISTS | PLAYER_KART_AI | PLAYER_START_SEQUENCE); + PLAYER_EXISTS | PLAYER_CPU | PLAYER_START_SEQUENCE); spawn_player(gPlayerSeven, 6, D_80165210[6], D_80165230[6], sp5A, 32768.0f, 6, - PLAYER_EXISTS | PLAYER_KART_AI | PLAYER_START_SEQUENCE); + PLAYER_EXISTS | PLAYER_CPU | PLAYER_START_SEQUENCE); spawn_player(gPlayerEight, 7, D_80165210[7], D_80165230[7], sp5A, 32768.0f, 7, - PLAYER_EXISTS | PLAYER_KART_AI | PLAYER_START_SEQUENCE); + PLAYER_EXISTS | PLAYER_CPU | PLAYER_START_SEQUENCE); D_80164A28 = 0; break; } if (gModeSelection != BATTLE) { - func_8000F628(); + init_players(); } } diff --git a/src/spawn_players.h b/src/spawn_players.h index f921096907..9f83b20cb6 100644 --- a/src/spawn_players.h +++ b/src/spawn_players.h @@ -34,7 +34,7 @@ extern s32 D_801652C0[]; extern s32 D_801652E0[]; extern s16 D_80165300[]; extern u16 gCopyPathIndexByPlayerId[]; -extern s16 gCopyNearestWaypointByPlayerId[]; +extern s16 gCopyNearestPathPointByPlayerId[]; extern s16 D_80165330[]; extern s16 D_80165340; extern Player* D_801653C0[]; @@ -50,7 +50,7 @@ extern s32 gFrameSinceLastBCombo[]; extern s32 gCountBChangement[]; extern bool gIsPlayerTripleBButtonCombo[]; extern s32 gTimerBoostTripleBCombo[]; -extern s16 chooseKartAIPlayers[]; +extern s16 cpu_chooseCharacters[]; extern s16 D_8016556E; extern s16 D_80165570; extern s16 D_80165572; diff --git a/src/staff_ghosts.c b/src/staff_ghosts.c index 2ab47f7013..b4ed4ad722 100644 --- a/src/staff_ghosts.c +++ b/src/staff_ghosts.c @@ -243,7 +243,7 @@ void func_8000546C(void) { s16 phi_v0 = 0; if (D_80162DB0 >= 0x1000) { - gPlayerOne->type = PLAYER_CINEMATIC_MODE | PLAYER_START_SEQUENCE | PLAYER_KART_AI; + gPlayerOne->type = PLAYER_CINEMATIC_MODE | PLAYER_START_SEQUENCE | PLAYER_CPU; return; } @@ -473,7 +473,7 @@ void func_8000599C(void) { // sets player to AI? (unconfirmed) void func_80005AE8(Player* ply) { if (((ply->type & PLAYER_INVISIBLE_OR_BOMB) != 0) && (ply != gPlayerOne)) { - ply->type = PLAYER_CINEMATIC_MODE | PLAYER_START_SEQUENCE | PLAYER_KART_AI; + ply->type = PLAYER_CINEMATIC_MODE | PLAYER_START_SEQUENCE | PLAYER_CPU; } } diff --git a/src/update_objects.c b/src/update_objects.c index 1d9063018f..d8828d471d 100644 --- a/src/update_objects.c +++ b/src/update_objects.c @@ -12,9 +12,9 @@ #include "math_util_2.h" #include "render_objects.h" #include "objects.h" -#include "waypoints.h" +#include "path.h" #include "code_800029B0.h" -#include "code_80005FD0.h" +#include "cpu_vehicles_camera_path.h" #include "code_80057C60.h" #include "code_8006E9C0.h" #include "code_80086E70.h" @@ -205,7 +205,7 @@ void func_80072120(s32* arg0, s32 arg1) { void func_80072180(void) { if (gModeSelection == TIME_TRIALS) { if (((gPlayerOne->type & PLAYER_EXISTS) != 0) && - ((gPlayerOne->type & (PLAYER_INVISIBLE_OR_BOMB | PLAYER_KART_AI)) == 0)) { + ((gPlayerOne->type & (PLAYER_INVISIBLE_OR_BOMB | PLAYER_CPU)) == 0)) { D_80162DF8 = 1; } } @@ -2673,7 +2673,7 @@ void func_80078288(s32 objectIndex) { break; case 1: if (gGamestate != 9) { - sp3A = ((gPlayerOneCopy->unk_094 / 18) * 216) / 2; + sp3A = ((gPlayerOneCopy->speed / 18) * 216) / 2; sp3E = (random_int(0x000FU) - sp3A) + 0x2D; sp3C = random_int(0x012CU) + 0x1E; temp_t6 = camera1->rot[1] + ((s32) (random_int(0x3000U) - 0x1800) / (s16) ((sp3A / 15) + 1)); @@ -3698,7 +3698,7 @@ u8 gen_random_item(s16 rank, s16 isCpu) { if (isCpu == 0) { curve = segmented_to_virtual((void*) common_grand_prix_human_item_curve); } else { - curve = segmented_to_virtual((void*) common_grand_prix_kart_ai_item_curve); + curve = segmented_to_virtual((void*) common_grand_prix_cpu_item_curve); } randomItem = *((rank * 100) + curve + sRandomItemIndex); } @@ -3710,7 +3710,7 @@ u8 gen_random_item_human(UNUSED s16 arg0, s16 rank) { return gen_random_item(rank, false); } -u8 kart_ai_gen_random_item(UNUSED s32 arg0, s16 rank) { +u8 cpu_gen_random_item(UNUSED s32 arg0, s16 rank) { return gen_random_item(rank, true); } @@ -4050,8 +4050,8 @@ void func_8007BD04(s32 playerId) { objectIndex = indexObjectList2[0]; if (gObjectList[objectIndex].state == 0) { - if (((s32) gNearestWaypointByPlayerId[playerId] >= 0xA0) && - ((s32) gNearestWaypointByPlayerId[playerId] < 0xAB)) { + if (((s32) gNearestPathPointByPlayerId[playerId] >= 0xA0) && + ((s32) gNearestPathPointByPlayerId[playerId] < 0xAB)) { set_obj_origin_pos(objectIndex, xOrientation * -1650.0, -200.0f, -1650.0f); init_object(objectIndex, 1); } @@ -4398,14 +4398,14 @@ void func_8007CA70(void) { if (D_8018CFF0 == 0) { playerId = func_8007C9F8(); D_8018D018 = playerId; - test = &gNearestWaypointByPlayerId[playerId]; + test = &gNearestPathPointByPlayerId[playerId]; if ((*test >= 0xC9) && (*test < 0xD2)) { func_8007C7B4(0, (s32) playerId); } } if (D_8018CFF0 != 0) { playerId = D_8018D018; - test = &gNearestWaypointByPlayerId[playerId]; + test = &gNearestPathPointByPlayerId[playerId]; if ((*test >= 0xB5) && (*test < 0xBE)) { func_8007C91C(0); } @@ -4416,14 +4416,14 @@ void func_8007CA70(void) { if (D_8018D048 == 0) { playerId = func_8007C9F8(); D_8018D110 = playerId; - test = &gNearestWaypointByPlayerId[playerId]; + test = &gNearestPathPointByPlayerId[playerId]; if ((*test >= 0x1FF) && (*test < 0x208)) { func_8007C7B4(5, (s32) playerId); } } if (D_8018D048 != 0) { playerId = D_8018D110; - test = &gNearestWaypointByPlayerId[playerId]; + test = &gNearestPathPointByPlayerId[playerId]; if ((*test >= 0x1EB) && (*test < 0x1F4)) { func_8007C91C(5); } @@ -5490,11 +5490,11 @@ s32 func_8007F75C(s32 playerId) { s32 objectIndex; s32 temp_s7; s32 var_s6; - s32 waypoint; + s32 pathPoint; - waypoint = gNearestWaypointByPlayerId[playerId]; + pathPoint = gNearestPathPointByPlayerId[playerId]; var_s6 = 0; - if ((waypoint >= 0xAA) && (waypoint < 0xB5)) { + if ((pathPoint >= 0xAA) && (pathPoint < 0xB5)) { temp_s7 = random_int(0x0032U) + 0x32; for (someIndex = 0; someIndex < gNumActiveThwomps; someIndex++) { objectIndex = indexObjectList1[someIndex]; @@ -5503,7 +5503,7 @@ s32 func_8007F75C(s32 playerId) { func_8007F660(objectIndex, playerId, temp_s7); } } - } else if ((waypoint >= 0xD7) && (waypoint < 0xE2)) { + } else if ((pathPoint >= 0xD7) && (pathPoint < 0xE2)) { for (someIndex = 0; someIndex < gNumActiveThwomps; someIndex++) { objectIndex = indexObjectList1[someIndex]; if (gObjectList[objectIndex].unk_0D5 == 3) { @@ -5538,7 +5538,7 @@ void func_8007F8D8(void) { } if (var_s4 != 0) { for (var_s0 = 0; var_s0 < 4; var_s0++, player++) { - if ((player->type & PLAYER_EXISTS) && !(player->type & PLAYER_KART_AI)) { + if ((player->type & PLAYER_EXISTS) && !(player->type & PLAYER_CPU)) { if (func_8007F75C(var_s0) != 0) { break; } @@ -5591,7 +5591,7 @@ void func_8007FB48(s32 objectIndex) { func_80086FD4(objectIndex); break; case 2: - gObjectList[objectIndex].velocity[0] = player->unk_094 * xOrientation * 1.25; + gObjectList[objectIndex].velocity[0] = player->speed * xOrientation * 1.25; if (gObjectList[objectIndex].unk_048 >= gObjectList[objectIndex].unk_0B0) { if (gObjectList[objectIndex].unk_0B0 == gObjectList[objectIndex].unk_048) { if (D_8018D400 & 1) { @@ -5985,7 +5985,7 @@ void func_80080B28(s32 objectIndex, s32 playerId) { temp_f0 = func_80088F54(objectIndex, temp_s0); if ((temp_f0 <= 9.0) && !(temp_s0->effects & 0x04000000) && (has_collided_horizontally_with_player(objectIndex, temp_s0) != 0)) { - if ((temp_s0->type & 0x8000) && !(temp_s0->type & 0x100)) { + if ((temp_s0->type & PLAYER_EXISTS) && !(temp_s0->type & 0x100)) { if (!(temp_s0->effects & 0x200)) { func_80089474(objectIndex, playerId, 1.4f, 1.1f, SOUND_ARG_LOAD(0x19, 0x00, 0xA0, 0x4C)); } else if (func_80072354(objectIndex, 0x00000040) != 0) { @@ -6003,9 +6003,9 @@ void func_80080B28(s32 objectIndex, s32 playerId) { } } } else if ((temp_f0 <= 17.5) && (func_80072320(objectIndex, 1) != 0) && - (is_within_horizontal_distance_of_player(objectIndex, temp_s0, (temp_s0->unk_094 * 0.5) + 7.0) != + (is_within_horizontal_distance_of_player(objectIndex, temp_s0, (temp_s0->speed * 0.5) + 7.0) != 0)) { - if ((temp_s0->type & 0x8000) && !(temp_s0->type & 0x100)) { + if ((temp_s0->type & PLAYER_EXISTS) && !(temp_s0->type & 0x100)) { if (is_obj_flag_status_active(objectIndex, 0x04000000) != 0) { func_80072180(); } @@ -6396,7 +6396,7 @@ void func_80081D34(s32 objectIndex) { for (var_s2 = 0; var_s2 < D_8018D158; var_s2++, player++, var_s4++) { if ((is_obj_flag_status_active(objectIndex, 0x00000200) != 0) && !(player->effects & 0x80000000) && (has_collided_with_player(objectIndex, player) != 0)) { - if ((player->type & 0x8000) && !(player->type & 0x100)) { + if ((player->type & PLAYER_EXISTS) && !(player->type & 0x100)) { var_s5 = 1; object = &gObjectList[objectIndex]; if (is_obj_flag_status_active(objectIndex, 0x04000000) != 0) { @@ -6408,8 +6408,8 @@ void func_80081D34(s32 objectIndex) { player->soundEffects |= 2; } object->direction_angle[1] = var_s4->rot[1]; - object->velocity[1] = (player->unk_094 / 2) + 3.0; - object->unk_034 = player->unk_094 + 1.0; + object->velocity[1] = (player->speed / 2) + 3.0; + object->unk_034 = player->speed + 1.0; if (object->velocity[1] >= 5.0) { object->velocity[1] = 5.0f; } @@ -7656,7 +7656,7 @@ void update_hot_air_balloon(void) { } void func_80085878(s32 objectIndex, s32 arg1) { - TrackWaypoint* temp_v0; + TrackPathPoint* temp_v0; Object* object; object = &gObjectList[objectIndex]; @@ -7668,7 +7668,7 @@ void func_80085878(s32 objectIndex, s32 arg1) { set_object_flag_status_true(objectIndex, 0x04000200); object->unk_084[8] = (arg1 * 0x12C) + 0x1F4; set_obj_origin_pos(objectIndex, 0.0f, -15.0f, 0.0f); - temp_v0 = &D_80164490[(u16) object->unk_084[8]]; + temp_v0 = &gCurrentTrackPath[(u16) object->unk_084[8]]; set_obj_origin_offset(objectIndex, temp_v0->posX, temp_v0->posY, temp_v0->posZ); set_obj_direction_angle(objectIndex, 0U, 0U, 0U); object->unk_034 = 4.0f; diff --git a/src/update_objects.h b/src/update_objects.h index 94fc751265..f8ee438d62 100644 --- a/src/update_objects.h +++ b/src/update_objects.h @@ -204,7 +204,7 @@ void func_8007ABFC(s32, bool); void consume_item(s32); u8 gen_random_item(s16, s16); u8 gen_random_item_human(s16, s16); -u8 kart_ai_gen_random_item(s32, s16); +u8 cpu_gen_random_item(s32, s16); s16 func_8007AFB0(s32, s32); s32 func_8007B040(s32, s32); void func_8007B254(s32, s32); diff --git a/tools/torch b/tools/torch index 4d8ac381c0..6a2eb92148 160000 --- a/tools/torch +++ b/tools/torch @@ -1 +1 @@ -Subproject commit 4d8ac381c08fd30cc6a4f247576c7dbfe09dc708 +Subproject commit 6a2eb921482f2eb3b3cb5b675152d6d21d1a20ff diff --git a/yamls/courses/banshee_boardwalk_metadata.yml b/yamls/courses/banshee_boardwalk_metadata.yml index bbcfd560a0..8425e7d253 100644 --- a/yamls/courses/banshee_boardwalk_metadata.yml +++ b/yamls/courses/banshee_boardwalk_metadata.yml @@ -7,9 +7,9 @@ course: cup: SPECIAL_CUP cup_index: 2 course_length: 747m - kart_ai_behaviour_ptr: D_0D009058 - kart_ai_maximum_separation: 40.0f - kart_ai_minimum_separation: 0.4f + cpu_behaviour_ptr: D_0D009058 + cpu_maximum_separation: 40.0f + cpu_minimum_separation: 0.4f D_800DCBB4: D_800DCAF4 cpu_steering_sensitivity: 53 bomb_kart_spawns: # 7 bomb kart spawn locations @@ -23,16 +23,28 @@ course: path_sizes: [0x02EE, 0x0001, 0x0001, 0x0001, 0x0001, 0x0000, 0x0000, 0x0000] # unk common_textures data - D_0D009418: [4.1666665f, 5.5833334f, 6.1666665f, 6.75f] - D_0D009568: [3.75f, 5.1666665f, 5.75f, 6.3333334f] + cpu_CurveTargetSpeed: [4.1666665f, 5.5833334f, 6.1666665f, 6.75f] + cpu_NormalTargetSpeed: [3.75f, 5.1666665f, 5.75f, 6.3333334f] D_0D0096B8: [3.3333332f, 3.9166667f, 4.5f, 5.0833334f] - D_0D009808: [3.75f, 5.1666665f, 5.75f, 6.3333334f] + cpu_OffTrackTargetSpeed: [3.75f, 5.1666665f, 5.75f, 6.3333334f] - # Course waypoints - path_table: [d_course_banshee_boardwalk_track_waypoints, "&nullPath", "&nullPath", "&nullPath"] + # Course path + path_table: + [ + d_course_banshee_boardwalk_track_path, + "&nullPath", + "&nullPath", + "&nullPath", + ] # Unused except in podium ceremony - path_table_unknown: [d_course_banshee_boardwalk_unknown_waypoints, "&nullPath", "&nullPath", "&nullPath"] + path_table_unknown: + [ + d_course_banshee_boardwalk_unknown_path, + "&nullPath", + "&nullPath", + "&nullPath", + ] sky_colors: [0, 0, 0, 0, 0, 0] sky_colors2: [0, 0, 0, 0, 0, 0] diff --git a/yamls/courses/big_donut_metadata.yml b/yamls/courses/big_donut_metadata.yml index b959215548..20f0ed54bf 100644 --- a/yamls/courses/big_donut_metadata.yml +++ b/yamls/courses/big_donut_metadata.yml @@ -7,9 +7,9 @@ course: cup: BATTLE_CUP cup_index: 0 course_length: "" - kart_ai_behaviour_ptr: D_0D008F18 - kart_ai_maximum_separation: -1.0f - kart_ai_minimum_separation: 0.5f + cpu_behaviour_ptr: D_0D008F18 + cpu_maximum_separation: -1.0f + cpu_minimum_separation: 0.5f D_800DCBB4: D_800DCAF4 cpu_steering_sensitivity: 40 bomb_kart_spawns: # 7 bomb kart spawn locations @@ -23,16 +23,16 @@ course: path_sizes: [0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0000, 0x0000, 0x0000] # unk common_textures data - D_0D009418: [4.1666665f, 5.5833334f, 6.1666665f, 6.75f] - D_0D009568: [3.75f, 5.1666665f, 5.75f, 6.3333334f] + cpu_CurveTargetSpeed: [4.1666665f, 5.5833334f, 6.1666665f, 6.75f] + cpu_NormalTargetSpeed: [3.75f, 5.1666665f, 5.75f, 6.3333334f] D_0D0096B8: [3.3333332f, 3.9166667f, 4.5f, 5.0833334f] - D_0D009808: [3.75f, 5.1666665f, 5.75f, 6.3333334f] + cpu_OffTrackTargetSpeed: [3.75f, 5.1666665f, 5.75f, 6.3333334f] - # Course waypoints - path_table: ["&nullPath", "&nullPath", "&nullPath", "&nullPath"] + # Course path + path_table: ["&nullPath", "&nullPath", "&nullPath", "&nullPath"] # Unused except in podium ceremony - path_table_unknown: ["&nullPath", "&nullPath", "&nullPath", "&nullPath"] + path_table_unknown: ["&nullPath", "&nullPath", "&nullPath", "&nullPath"] sky_colors: [0, 0, 0, 0, 0, 0] sky_colors2: [0, 0, 0, 0, 0, 0] diff --git a/yamls/courses/block_fort_metadata.yml b/yamls/courses/block_fort_metadata.yml index 251e2ab2ec..81d510bc32 100644 --- a/yamls/courses/block_fort_metadata.yml +++ b/yamls/courses/block_fort_metadata.yml @@ -7,9 +7,9 @@ course: cup: BATTLE_CUP cup_index: 1 course_length: "" - kart_ai_behaviour_ptr: D_0D008F18 - kart_ai_maximum_separation: -1.0f - kart_ai_minimum_separation: 0.1f + cpu_behaviour_ptr: D_0D008F18 + cpu_maximum_separation: -1.0f + cpu_minimum_separation: 0.1f D_800DCBB4: D_800DCAF4 cpu_steering_sensitivity: 53 bomb_kart_spawns: # 7 bomb kart spawn locations @@ -23,16 +23,16 @@ course: path_sizes: [0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0000, 0x0000, 0x0000] # unk common_textures data - D_0D009418: [4.1666665f, 5.5833334f, 6.1666665f, 6.75f] - D_0D009568: [3.75f, 5.1666665f, 5.75f, 6.3333334f] + cpu_CurveTargetSpeed: [4.1666665f, 5.5833334f, 6.1666665f, 6.75f] + cpu_NormalTargetSpeed: [3.75f, 5.1666665f, 5.75f, 6.3333334f] D_0D0096B8: [3.3333332f, 3.9166667f, 4.5f, 5.0833334f] - D_0D009808: [3.75f, 5.1666665f, 5.75f, 6.3333334f] + cpu_OffTrackTargetSpeed: [3.75f, 5.1666665f, 5.75f, 6.3333334f] - # Course waypoints - path_table: ["&nullPath", "&nullPath", "&nullPath", "&nullPath"] + # Course path + path_table: ["&nullPath", "&nullPath", "&nullPath", "&nullPath"] # Unused except in podium ceremony - path_table_unknown: ["&nullPath", "&nullPath", "&nullPath", "&nullPath"] + path_table_unknown: ["&nullPath", "&nullPath", "&nullPath", "&nullPath"] sky_colors: [128, 4280, 6136, 216, 7144, 32248] sky_colors2: [216, 7144, 32248, 0, 0, 0] diff --git a/yamls/courses/bowsers_castle_metadata.yml b/yamls/courses/bowsers_castle_metadata.yml index efa7b730c9..c98310736a 100644 --- a/yamls/courses/bowsers_castle_metadata.yml +++ b/yamls/courses/bowsers_castle_metadata.yml @@ -7,9 +7,9 @@ course: cup: STAR_CUP cup_index: 3 course_length: 777m - kart_ai_behaviour_ptr: D_0D008FB8 - kart_ai_maximum_separation: 35.0f - kart_ai_minimum_separation: 0.2f + cpu_behaviour_ptr: D_0D008FB8 + cpu_maximum_separation: 35.0f + cpu_minimum_separation: 0.2f D_800DCBB4: D_800DCAF4 cpu_steering_sensitivity: 53 bomb_kart_spawns: # 7 bomb kart spawn locations @@ -23,16 +23,23 @@ course: path_sizes: [0x030C, 0x0001, 0x0001, 0x0001, 0x0001, 0x0000, 0x0000, 0x0000] # unk common_textures data - D_0D009418: [4.1666665f, 5.5833334f, 6.1666665f, 6.75f] - D_0D009568: [3.75f, 5.1666665f, 5.75f, 6.3333334f] + cpu_CurveTargetSpeed: [4.1666665f, 5.5833334f, 6.1666665f, 6.75f] + cpu_NormalTargetSpeed: [3.75f, 5.1666665f, 5.75f, 6.3333334f] D_0D0096B8: [3.3333332f, 3.9166667f, 4.5f, 5.0833334f] - D_0D009808: [3.75f, 5.1666665f, 5.75f, 6.3333334f] + cpu_OffTrackTargetSpeed: [3.75f, 5.1666665f, 5.75f, 6.3333334f] - # Course waypoints - path_table: [d_course_bowsers_castle_track_waypoints, "&nullPath", "&nullPath", "&nullPath"] + # Course path + path_table: + [d_course_bowsers_castle_track_path, "&nullPath", "&nullPath", "&nullPath"] # Unused except in podium ceremony - path_table_unknown: [d_course_bowsers_castle_unknown_waypoints, "&nullPath", "&nullPath", "&nullPath"] + path_table_unknown: + [ + d_course_bowsers_castle_unknown_path, + "&nullPath", + "&nullPath", + "&nullPath", + ] sky_colors: [48, 1544, 49528, 0, 0, 0] sky_colors2: [0, 0, 0, 0, 0, 0] diff --git a/yamls/courses/choco_mountain_metadata.yml b/yamls/courses/choco_mountain_metadata.yml index c47733a1f1..a0cd55dd66 100644 --- a/yamls/courses/choco_mountain_metadata.yml +++ b/yamls/courses/choco_mountain_metadata.yml @@ -7,9 +7,9 @@ course: cup: FLOWER_CUP cup_index: 2 course_length: 687m - kart_ai_behaviour_ptr: D_0D008F80 - kart_ai_maximum_separation: 35.0f - kart_ai_minimum_separation: 0.3f + cpu_behaviour_ptr: D_0D008F80 + cpu_maximum_separation: 35.0f + cpu_minimum_separation: 0.3f D_800DCBB4: D_800DCAF4 cpu_steering_sensitivity: 53 bomb_kart_spawns: # 7 bomb kart spawn locations @@ -23,16 +23,23 @@ course: path_sizes: [0x02BC, 0x0001, 0x0001, 0x0001, 0x0001, 0x0000, 0x0000, 0x0000] # unk common_textures data - D_0D009418: [4.1666665f, 5.5833334f, 6.1666665f, 6.75f] - D_0D009568: [3.75f, 5.1666665f, 5.75f, 6.3333334f] + cpu_CurveTargetSpeed: [4.1666665f, 5.5833334f, 6.1666665f, 6.75f] + cpu_NormalTargetSpeed: [3.75f, 5.1666665f, 5.75f, 6.3333334f] D_0D0096B8: [3.3333332f, 3.9166667f, 4.5f, 5.0833334f] - D_0D009808: [3.75f, 5.1666665f, 5.75f, 6.3333334f] + cpu_OffTrackTargetSpeed: [3.75f, 5.1666665f, 5.75f, 6.3333334f] - # Course waypoints - path_table: [d_course_choco_mountain_track_waypoints, "&nullPath", "&nullPath", "&nullPath"] + # Course path + path_table: + [d_course_choco_mountain_track_path, "&nullPath", "&nullPath", "&nullPath"] # Unused except in podium ceremony - path_table_unknown: [d_course_choco_mountain_unknown_waypoints, "&nullPath", "&nullPath", "&nullPath"] + path_table_unknown: + [ + d_course_choco_mountain_unknown_path, + "&nullPath", + "&nullPath", + "&nullPath", + ] sky_colors: [255, 255, 255, 255, 255, 255] sky_colors2: [255, 255, 255, 255, 255, 255] diff --git a/yamls/courses/dks_jungle_parkway_metadata.yml b/yamls/courses/dks_jungle_parkway_metadata.yml index dafe032341..fb22ad10be 100644 --- a/yamls/courses/dks_jungle_parkway_metadata.yml +++ b/yamls/courses/dks_jungle_parkway_metadata.yml @@ -7,9 +7,9 @@ course: cup: SPECIAL_CUP cup_index: 0 course_length: 893m - kart_ai_behaviour_ptr: D_0D0093C0 - kart_ai_maximum_separation: 40.0f - kart_ai_minimum_separation: 0.1f + cpu_behaviour_ptr: D_0D0093C0 + cpu_maximum_separation: 40.0f + cpu_minimum_separation: 0.1f D_800DCBB4: D_800DCAF4 cpu_steering_sensitivity: 53 bomb_kart_spawns: # 7 bomb kart spawn locations @@ -23,16 +23,28 @@ course: path_sizes: [0x0370, 0x0001, 0x0001, 0x0001, 0x01F4, 0x0000, 0x0000, 0x0000] # unk common_textures data - D_0D009418: [4.1666665f, 5.5833334f, 6.1666665f, 6.75f] - D_0D009568: [3.75f, 5.1666665f, 5.75f, 6.3333334f] + cpu_CurveTargetSpeed: [4.1666665f, 5.5833334f, 6.1666665f, 6.75f] + cpu_NormalTargetSpeed: [3.75f, 5.1666665f, 5.75f, 6.3333334f] D_0D0096B8: [3.3333332f, 3.9166667f, 4.5f, 5.0833334f] - D_0D009808: [3.75f, 5.1666665f, 5.75f, 6.3333334f] + cpu_OffTrackTargetSpeed: [3.75f, 5.1666665f, 5.75f, 6.3333334f] - # Course waypoints - path_table: [d_course_dks_jungle_parkway_track_waypoints, "&nullPath", "&nullPath", "&nullPath"] + # Course path + path_table: + [ + d_course_dks_jungle_parkway_track_path, + "&nullPath", + "&nullPath", + "&nullPath", + ] # Unused except in podium ceremony - path_table_unknown: [d_course_dks_jungle_parkway_unknown_waypoints, "&nullPath", "&nullPath", "&nullPath"] + path_table_unknown: + [ + d_course_dks_jungle_parkway_unknown_path, + "&nullPath", + "&nullPath", + "&nullPath", + ] sky_colors: [255, 174, 0, 255, 229, 124] sky_colors2: [22, 145, 22, 0, 0, 0] diff --git a/yamls/courses/double_deck_metadata.yml b/yamls/courses/double_deck_metadata.yml index 2ea7090b72..acd8dd9fa2 100644 --- a/yamls/courses/double_deck_metadata.yml +++ b/yamls/courses/double_deck_metadata.yml @@ -7,9 +7,9 @@ course: cup: BATTLE_CUP cup_index: 2 course_length: "" - kart_ai_behaviour_ptr: D_0D008F18 - kart_ai_maximum_separation: -1.0f - kart_ai_minimum_separation: 0.5f + cpu_behaviour_ptr: D_0D008F18 + cpu_maximum_separation: -1.0f + cpu_minimum_separation: 0.5f D_800DCBB4: D_800DCAF4 cpu_steering_sensitivity: 53 bomb_kart_spawns: # 7 bomb kart spawn locations @@ -23,16 +23,16 @@ course: path_sizes: [0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0000, 0x0000, 0x0000] # unk common_textures data - D_0D009418: [4.1666665f, 5.5833334f, 6.1666665f, 6.75f] - D_0D009568: [3.75f, 5.1666665f, 5.75f, 6.3333334f] + cpu_CurveTargetSpeed: [4.1666665f, 5.5833334f, 6.1666665f, 6.75f] + cpu_NormalTargetSpeed: [3.75f, 5.1666665f, 5.75f, 6.3333334f] D_0D0096B8: [3.3333332f, 3.9166667f, 4.5f, 5.0833334f] - D_0D009808: [3.75f, 5.1666665f, 5.75f, 6.3333334f] + cpu_OffTrackTargetSpeed: [3.75f, 5.1666665f, 5.75f, 6.3333334f] - # Course waypoints - path_table: ["&nullPath", "&nullPath", "&nullPath", "&nullPath"] + # Course path + path_table: ["&nullPath", "&nullPath", "&nullPath", "&nullPath"] # Unused except in podium ceremony - path_table_unknown: ["&nullPath", "&nullPath", "&nullPath", "&nullPath"] + path_table_unknown: ["&nullPath", "&nullPath", "&nullPath", "&nullPath"] sky_colors: [113, 70, 255, 255, 184, 99] sky_colors2: [255, 224, 240, 0, 0, 0] diff --git a/yamls/courses/frappe_snowland_metadata.yml b/yamls/courses/frappe_snowland_metadata.yml index 9a63755e1b..8212d46f28 100644 --- a/yamls/courses/frappe_snowland_metadata.yml +++ b/yamls/courses/frappe_snowland_metadata.yml @@ -7,9 +7,9 @@ course: cup: FLOWER_CUP cup_index: 1 course_length: 734m - kart_ai_behaviour_ptr: D_0D0090F8 - kart_ai_maximum_separation: 50.0f - kart_ai_minimum_separation: 0.3f + cpu_behaviour_ptr: D_0D0090F8 + cpu_maximum_separation: 50.0f + cpu_minimum_separation: 0.3f D_800DCBB4: D_800DCAF4 cpu_steering_sensitivity: 53 bomb_kart_spawns: # 7 bomb kart spawn locations @@ -23,16 +23,23 @@ course: path_sizes: [0x02EE, 0x0001, 0x0001, 0x0001, 0x0001, 0x0000, 0x0000, 0x0000] # unk common_textures data - D_0D009418: [4.1666665f, 5.5833334f, 6.1666665f, 6.75f] - D_0D009568: [3.75f, 5.1666665f, 5.75f, 6.3333334f] + cpu_CurveTargetSpeed: [4.1666665f, 5.5833334f, 6.1666665f, 6.75f] + cpu_NormalTargetSpeed: [3.75f, 5.1666665f, 5.75f, 6.3333334f] D_0D0096B8: [3.3333332f, 3.9166667f, 4.5f, 5.0833334f] - D_0D009808: [3.75f, 5.1666665f, 5.75f, 6.3333334f] + cpu_OffTrackTargetSpeed: [3.75f, 5.1666665f, 5.75f, 6.3333334f] - # Course waypoints - path_table: [d_course_frappe_snowland_track_waypoints, "&nullPath", "&nullPath", "&nullPath"] + # Course path + path_table: + [d_course_frappe_snowland_track_path, "&nullPath", "&nullPath", "&nullPath"] # Unused except in podium ceremony - path_table_unknown: [d_course_frappe_snowland_unknown_waypoints, "&nullPath", "&nullPath", "&nullPath"] + path_table_unknown: + [ + d_course_frappe_snowland_unknown_path, + "&nullPath", + "&nullPath", + "&nullPath", + ] sky_colors: [28, 11, 90, 0, 99, 164] sky_colors2: [0, 99, 164, 0, 0, 0] diff --git a/yamls/courses/kalimari_desert_metadata.yml b/yamls/courses/kalimari_desert_metadata.yml index e428cee117..d2a9f69861 100644 --- a/yamls/courses/kalimari_desert_metadata.yml +++ b/yamls/courses/kalimari_desert_metadata.yml @@ -7,9 +7,9 @@ course: cup: MUSHROOM_CUP cup_index: 3 course_length: 753m - kart_ai_behaviour_ptr: D_0D009260 - kart_ai_maximum_separation: 50.0f - kart_ai_minimum_separation: 0.3f + cpu_behaviour_ptr: D_0D009260 + cpu_maximum_separation: 50.0f + cpu_minimum_separation: 0.3f D_800DCBB4: D_800DCAF4 cpu_steering_sensitivity: 53 bomb_kart_spawns: # 7 bomb kart spawn locations @@ -23,16 +23,23 @@ course: path_sizes: [0x02BC, 0x0001, 0x0001, 0x0001, 0x0226, 0x0000, 0x0000, 0x0000] # unk common_textures data - D_0D009418: [4.1666665f, 5.5833334f, 6.1666665f, 6.75f] - D_0D009568: [3.75f, 5.1666665f, 5.75f, 6.3333334f] + cpu_CurveTargetSpeed: [4.1666665f, 5.5833334f, 6.1666665f, 6.75f] + cpu_NormalTargetSpeed: [3.75f, 5.1666665f, 5.75f, 6.3333334f] D_0D0096B8: [3.3333332f, 3.9166667f, 4.5f, 5.0833334f] - D_0D009808: [3.75f, 5.1666665f, 5.75f, 6.3333334f] + cpu_OffTrackTargetSpeed: [3.75f, 5.1666665f, 5.75f, 6.3333334f] - # Course waypoints - path_table: [d_course_kalimari_desert_track_waypoints, "&nullPath", "&nullPath", "&nullPath"] + # Course path + path_table: + [d_course_kalimari_desert_track_path, "&nullPath", "&nullPath", "&nullPath"] # Unused except in podium ceremony - path_table_unknown: [d_course_kalimari_desert_unknown_waypoints, "&nullPath", "&nullPath", "&nullPath"] + path_table_unknown: + [ + d_course_kalimari_desert_unknown_path, + "&nullPath", + "&nullPath", + "&nullPath", + ] sky_colors: [195, 231, 255, 255, 192, 0] sky_colors2: [255, 192, 0, 0, 0, 0] diff --git a/yamls/courses/koopa_beach_metadata.yml b/yamls/courses/koopa_beach_metadata.yml index 27576fb138..f7547febbb 100644 --- a/yamls/courses/koopa_beach_metadata.yml +++ b/yamls/courses/koopa_beach_metadata.yml @@ -7,9 +7,9 @@ course: cup: MUSHROOM_CUP cup_index: 2 course_length: 691m - kart_ai_behaviour_ptr: D_0D009158 - kart_ai_maximum_separation: 50.0f - kart_ai_minimum_separation: 0.5f + cpu_behaviour_ptr: D_0D009158 + cpu_maximum_separation: 50.0f + cpu_minimum_separation: 0.5f D_800DCBB4: D_800DCAF4 cpu_steering_sensitivity: 53 bomb_kart_spawns: # 7 bomb kart spawn locations @@ -23,16 +23,28 @@ course: path_sizes: [0x02BC, 0x0001, 0x0001, 0x0001, 0x0001, 0x0000, 0x0000, 0x0000] # unk common_textures data - D_0D009418: [4.1666665f, 5.5833334f, 6.1666665f, 6.75f] - D_0D009568: [3.75f, 5.1666665f, 5.75f, 6.3333334f] + cpu_CurveTargetSpeed: [4.1666665f, 5.5833334f, 6.1666665f, 6.75f] + cpu_NormalTargetSpeed: [3.75f, 5.1666665f, 5.75f, 6.3333334f] D_0D0096B8: [3.3333332f, 3.9166667f, 4.5f, 5.0833334f] - D_0D009808: [3.75f, 5.1666665f, 5.75f, 6.3333334f] + cpu_OffTrackTargetSpeed: [3.75f, 5.1666665f, 5.75f, 6.3333334f] - # Course waypoints - path_table: [d_course_koopa_troopa_beach_track_waypoints, "d_course_koopa_troopa_beach_track_waypoints_2", "&nullPath", "&nullPath"] + # Course path + path_table: + [ + d_course_koopa_troopa_beach_track_path, + "d_course_koopa_troopa_beach_track_path_2", + "&nullPath", + "&nullPath", + ] # Unused except in podium ceremony - path_table_unknown: [d_course_koopa_troopa_beach_unknown_waypoints, "&nullPath", "&nullPath", "&nullPath"] + path_table_unknown: + [ + d_course_koopa_troopa_beach_unknown_path, + "&nullPath", + "&nullPath", + "&nullPath", + ] sky_colors: [48, 1688, 54136, 216, 7144, 32248] sky_colors2: [48, 1688, 54136, 0, 0, 0] diff --git a/yamls/courses/luigi_raceway_metadata.yml b/yamls/courses/luigi_raceway_metadata.yml index 98b8b010a2..18907bdf34 100644 --- a/yamls/courses/luigi_raceway_metadata.yml +++ b/yamls/courses/luigi_raceway_metadata.yml @@ -7,9 +7,9 @@ course: cup: MUSHROOM_CUP cup_index: 0 course_length: 717m - kart_ai_behaviour_ptr: D_0D0091E8 - kart_ai_maximum_separation: 50.0f - kart_ai_minimum_separation: 0.7f + cpu_behaviour_ptr: D_0D0091E8 + cpu_maximum_separation: 50.0f + cpu_minimum_separation: 0.7f D_800DCBB4: D_800DCAF4 cpu_steering_sensitivity: 48 bomb_kart_spawns: # 7 bomb kart spawn locations @@ -23,16 +23,18 @@ course: path_sizes: [0x02DA, 0x0001, 0x0001, 0x0001, 0x0001, 0x0000, 0x0000, 0x0000] # unk common_textures data - D_0D009418: [4.1666665f, 5.5833334f, 6.1666665f, 6.75f] - D_0D009568: [3.75f, 5.1666665f, 5.75f, 6.3333334f] + cpu_CurveTargetSpeed: [4.1666665f, 5.5833334f, 6.1666665f, 6.75f] + cpu_NormalTargetSpeed: [3.75f, 5.1666665f, 5.75f, 6.3333334f] D_0D0096B8: [3.3333332f, 3.9166667f, 4.5f, 5.0833334f] - D_0D009808: [3.75f, 5.1666665f, 5.75f, 6.3333334f] + cpu_OffTrackTargetSpeed: [3.75f, 5.1666665f, 5.75f, 6.3333334f] - # Course waypoints - path_table: [d_course_luigi_raceway_track_waypoints, "&nullPath", "&nullPath", "&nullPath"] + # Course path + path_table: + [d_course_luigi_raceway_track_path, "&nullPath", "&nullPath", "&nullPath"] # Unused except in podium ceremony - path_table_unknown: [d_course_luigi_raceway_unknown_waypoints, "&nullPath", "&nullPath", "&nullPath"] + path_table_unknown: + [d_course_luigi_raceway_unknown_path, "&nullPath", "&nullPath", "&nullPath"] sky_colors: [128, 4280, 6136, 216, 7144, 32248] sky_colors2: [216, 7144, 32248, 0, 0, 0] diff --git a/yamls/courses/mario_raceway_metadata.yml b/yamls/courses/mario_raceway_metadata.yml index eab36113f5..6756070a71 100644 --- a/yamls/courses/mario_raceway_metadata.yml +++ b/yamls/courses/mario_raceway_metadata.yml @@ -7,9 +7,9 @@ course: cup: FLOWER_CUP cup_index: 3 course_length: 567m - kart_ai_behaviour_ptr: D_0D008F28 - kart_ai_maximum_separation: 50.0f - kart_ai_minimum_separation: 0.3f + cpu_behaviour_ptr: D_0D008F28 + cpu_maximum_separation: 50.0f + cpu_minimum_separation: 0.3f D_800DCBB4: D_800DCB34 cpu_steering_sensitivity: 48 bomb_kart_spawns: # 7 bomb kart spawn locations @@ -23,16 +23,18 @@ course: path_sizes: [0x0258, 0x0001, 0x0001, 0x0001, 0x0001, 0x0000, 0x0000, 0x0000] # unk common_textures data - D_0D009418: [4.1666665f, 5.5833334f, 6.1666665f, 6.75f] - D_0D009568: [3.75f, 5.1666665f, 5.75f, 6.3333334f] + cpu_CurveTargetSpeed: [4.1666665f, 5.5833334f, 6.1666665f, 6.75f] + cpu_NormalTargetSpeed: [3.75f, 5.1666665f, 5.75f, 6.3333334f] D_0D0096B8: [3.3333332f, 3.9166667f, 4.5f, 5.0833334f] - D_0D009808: [3.75f, 5.1666665f, 5.75f, 6.3333334f] + cpu_OffTrackTargetSpeed: [3.75f, 5.1666665f, 5.75f, 6.3333334f] - # Course waypoints - path_table: [d_course_mario_raceway_track_waypoints, "&nullPath", "&nullPath", "&nullPath"] + # Course path + path_table: + [d_course_mario_raceway_track_path, "&nullPath", "&nullPath", "&nullPath"] # Unused except in podium ceremony - path_table_unknown: [d_course_mario_raceway_unknown_waypoints, "&nullPath", "&nullPath", "&nullPath"] + path_table_unknown: + [d_course_mario_raceway_unknown_path, "&nullPath", "&nullPath", "&nullPath"] sky_colors: [128, 4280, 6136, 216, 7144, 32248] sky_colors2: [0, 0, 0, 0, 0, 0] diff --git a/yamls/courses/moo_moo_farm_metadata.yml b/yamls/courses/moo_moo_farm_metadata.yml index d156fd8621..d7a032fe19 100644 --- a/yamls/courses/moo_moo_farm_metadata.yml +++ b/yamls/courses/moo_moo_farm_metadata.yml @@ -7,9 +7,9 @@ course: cup: MUSHROOM_CUP cup_index: 1 course_length: 527m - kart_ai_behaviour_ptr: D_0D009210 - kart_ai_maximum_separation: 50.0f - kart_ai_minimum_separation: 0.5f + cpu_behaviour_ptr: D_0D009210 + cpu_maximum_separation: 50.0f + cpu_minimum_separation: 0.5f D_800DCBB4: D_800DCAF4 cpu_steering_sensitivity: 48 bomb_kart_spawns: # 7 bomb kart spawn locations @@ -23,16 +23,18 @@ course: path_sizes: [0x0230, 0x0001, 0x0001, 0x0001, 0x0001, 0x0000, 0x0000, 0x0000] # unk common_textures data - D_0D009418: [4.1666665f, 5.5833334f, 6.1666665f, 6.75f] - D_0D009568: [3.75f, 5.1666665f, 5.75f, 6.3333334f] + cpu_CurveTargetSpeed: [4.1666665f, 5.5833334f, 6.1666665f, 6.75f] + cpu_NormalTargetSpeed: [3.75f, 5.1666665f, 5.75f, 6.3333334f] D_0D0096B8: [3.3333332f, 3.9166667f, 4.5f, 5.0833334f] - D_0D009808: [3.75f, 5.1666665f, 5.75f, 6.3333334f] + cpu_OffTrackTargetSpeed: [3.75f, 5.1666665f, 5.75f, 6.3333334f] - # Course waypoints - path_table: [d_course_moo_moo_farm_track_waypoints, "&nullPath", "&nullPath", "&nullPath"] + # Course path + path_table: + [d_course_moo_moo_farm_track_path, "&nullPath", "&nullPath", "&nullPath"] # Unused except in podium ceremony - path_table_unknown: [d_course_moo_moo_farm_unknown_waypoints, "&nullPath", "&nullPath", "&nullPath"] + path_table_unknown: + [d_course_moo_moo_farm_unknown_path, "&nullPath", "&nullPath", "&nullPath"] sky_colors: [0, 18, 255, 197, 211, 255] sky_colors2: [255, 184, 99, 0, 0, 0] diff --git a/yamls/courses/podium_ceremony_metadata.yml b/yamls/courses/podium_ceremony_metadata.yml index 5df6a435a4..b7d4c1ff58 100644 --- a/yamls/courses/podium_ceremony_metadata.yml +++ b/yamls/courses/podium_ceremony_metadata.yml @@ -7,10 +7,10 @@ course: cup: null cup_index: -1 course_length: null - kart_ai_behaviour_ptr: D_0D008F18 - kart_ai_maximum_separation: 40.0f # entry - kart_ai_minimum_separation: 0.5f # entry - D_800DCBB4: D_800DCAF4 + cpu_behaviour_ptr: D_0D008F18 + cpu_maximum_separation: 40.0f # entry + cpu_minimum_separation: 0.5f # entry + D_800DCBB4: D_800DCAF4 cpu_steering_sensitivity: 53 # entry bomb_kart_spawns: # 7 bomb kart spawn locations - [0x0003, 0x0005, 1.25, 0.0, 0.0, 0.0, 0.0] @@ -23,16 +23,22 @@ course: path_sizes: [0x01F4, 0x01F4, 0x01F4, 0x01F4, 0x0001, 0x0000, 0x0000, 0x0000] # unk common_textures data - D_0D009418: [0.0f, 0.0f, 0.0f, 0.0f] - D_0D009568: [0.0f, 0.0f, 0.0f, 0.0f] + cpu_CurveTargetSpeed: [0.0f, 0.0f, 0.0f, 0.0f] + cpu_NormalTargetSpeed: [0.0f, 0.0f, 0.0f, 0.0f] D_0D0096B8: [0.0f, 0.0f, 0.0f, 0.0f] - D_0D009808: [0.0f, 0.0f, 0.0f, 0.0f] + cpu_OffTrackTargetSpeed: [0.0f, 0.0f, 0.0f, 0.0f] - # Course waypoints - path_table: ["&nullPath", "&nullPath", "&nullPath", "&nullPath"] + # Course path + path_table: ["&nullPath", "&nullPath", "&nullPath", "&nullPath"] # Unused except in podium ceremony - path_table_unknown: [podium_ceremony_path, podium_ceremony_path_2, podium_ceremony_path_3, podium_ceremony_path_4] + path_table_unknown: + [ + podium_ceremony_path, + podium_ceremony_path_2, + podium_ceremony_path_3, + podium_ceremony_path_4, + ] sky_colors: [238, 144, 255, 255, 224, 240] sky_colors2: [255, 224, 240, 0, 0, 0] diff --git a/yamls/courses/rainbow_road_metadata.yml b/yamls/courses/rainbow_road_metadata.yml index 66a9224ac5..14d7b264c9 100644 --- a/yamls/courses/rainbow_road_metadata.yml +++ b/yamls/courses/rainbow_road_metadata.yml @@ -7,9 +7,9 @@ course: cup: SPECIAL_CUP cup_index: 3 course_length: 2000m - kart_ai_behaviour_ptr: D_0D0092C8 - kart_ai_maximum_separation: 50.0f - kart_ai_minimum_separation: 0.4f + cpu_behaviour_ptr: D_0D0092C8 + cpu_maximum_separation: 50.0f + cpu_minimum_separation: 0.4f D_800DCBB4: D_800DCAF4 cpu_steering_sensitivity: 38 bomb_kart_spawns: # 7 bomb kart spawn locations @@ -23,16 +23,18 @@ course: path_sizes: [0x076C, 0x0001, 0x0001, 0x0001, 0x0001, 0x0000, 0x0000, 0x0000] # unk common_textures data - D_0D009418: [4.1666665f, 5.5833334f, 6.1666665f, 6.75f] - D_0D009568: [3.75f, 5.1666665f, 5.75f, 6.3333334f] + cpu_CurveTargetSpeed: [4.1666665f, 5.5833334f, 6.1666665f, 6.75f] + cpu_NormalTargetSpeed: [3.75f, 5.1666665f, 5.75f, 6.3333334f] D_0D0096B8: [3.3333332f, 3.9166667f, 4.5f, 5.0833334f] - D_0D009808: [3.75f, 5.1666665f, 5.75f, 6.3333334f] + cpu_OffTrackTargetSpeed: [3.75f, 5.1666665f, 5.75f, 6.3333334f] - # Course waypoints - path_table: [d_course_rainbow_road_track_waypoints, "&nullPath", "&nullPath", "&nullPath"] + # Course path + path_table: + [d_course_rainbow_road_track_path, "&nullPath", "&nullPath", "&nullPath"] # Unused except in podium ceremony - path_table_unknown: [d_course_rainbow_road_unknown_waypoints, "&nullPath", "&nullPath", "&nullPath"] + path_table_unknown: + [d_course_rainbow_road_unknown_path, "&nullPath", "&nullPath", "&nullPath"] sky_colors: [0, 0, 0, 0, 0, 0] sky_colors2: [0, 0, 0, 0, 0, 0] diff --git a/yamls/courses/royal_raceway_metadata.yml b/yamls/courses/royal_raceway_metadata.yml index 1b4fecf3a9..4d1efe634c 100644 --- a/yamls/courses/royal_raceway_metadata.yml +++ b/yamls/courses/royal_raceway_metadata.yml @@ -7,9 +7,9 @@ course: cup: STAR_CUP cup_index: 2 course_length: 1025m - kart_ai_behaviour_ptr: D_0D009188 - kart_ai_maximum_separation: 50.0f - kart_ai_minimum_separation: 0.4f + cpu_behaviour_ptr: D_0D009188 + cpu_maximum_separation: 50.0f + cpu_minimum_separation: 0.4f D_800DCBB4: D_800DCAF4 cpu_steering_sensitivity: 53 bomb_kart_spawns: # 7 bomb kart spawn locations @@ -23,16 +23,18 @@ course: path_sizes: [0x03E8, 0x0001, 0x0001, 0x0001, 0x0001, 0x0000, 0x0000, 0x0000] # unk common_textures data - D_0D009418: [4.1666665f, 5.5833334f, 6.1666665f, 6.75f] - D_0D009568: [3.75f, 5.1666665f, 5.75f, 6.3333334f] + cpu_CurveTargetSpeed: [4.1666665f, 5.5833334f, 6.1666665f, 6.75f] + cpu_NormalTargetSpeed: [3.75f, 5.1666665f, 5.75f, 6.3333334f] D_0D0096B8: [3.3333332f, 3.9166667f, 4.5f, 5.0833334f] - D_0D009808: [3.75f, 5.1666665f, 5.75f, 6.3333334f] + cpu_OffTrackTargetSpeed: [3.75f, 5.1666665f, 5.75f, 6.3333334f] - # Course waypoints - path_table: [d_course_royal_raceway_track_waypoints, "&nullPath", "&nullPath", "&nullPath"] + # Course path + path_table: + [d_course_royal_raceway_track_path, "&nullPath", "&nullPath", "&nullPath"] # Unused except in podium ceremony - path_table_unknown: [d_course_royal_raceway_unknown_waypoints, "&nullPath", "&nullPath", "&nullPath"] + path_table_unknown: + [d_course_royal_raceway_unknown_path, "&nullPath", "&nullPath", "&nullPath"] sky_colors: [238, 144, 255, 255, 224, 240] sky_colors2: [255, 224, 240, 0, 0, 0] diff --git a/yamls/courses/sherbet_land_metadata.yml b/yamls/courses/sherbet_land_metadata.yml index 2db2a434f6..ffce8e07ce 100644 --- a/yamls/courses/sherbet_land_metadata.yml +++ b/yamls/courses/sherbet_land_metadata.yml @@ -7,9 +7,9 @@ course: cup: STAR_CUP cup_index: 1 course_length: 756m - kart_ai_behaviour_ptr: D_0D009280 - kart_ai_maximum_separation: 50.0f - kart_ai_minimum_separation: 0.3f + cpu_behaviour_ptr: D_0D009280 + cpu_maximum_separation: 50.0f + cpu_minimum_separation: 0.3f D_800DCBB4: D_800DCAF4 cpu_steering_sensitivity: 53 bomb_kart_spawns: # 7 bomb kart spawn locations @@ -23,16 +23,18 @@ course: path_sizes: [0x02BC, 0x0001, 0x0001, 0x0001, 0x0001, 0x0000, 0x0000, 0x0000] # unk common_textures data - D_0D009418: [4.1666665f, 5.5833334f, 6.1666665f, 6.75f] - D_0D009568: [3.75f, 5.1666665f, 5.75f, 6.3333334f] + cpu_CurveTargetSpeed: [4.1666665f, 5.5833334f, 6.1666665f, 6.75f] + cpu_NormalTargetSpeed: [3.75f, 5.1666665f, 5.75f, 6.3333334f] D_0D0096B8: [3.3333332f, 3.9166667f, 4.5f, 5.0833334f] - D_0D009808: [3.75f, 5.1666665f, 5.75f, 6.3333334f] + cpu_OffTrackTargetSpeed: [3.75f, 5.1666665f, 5.75f, 6.3333334f] - # Course waypoints - path_table: [d_course_sherbet_land_track_waypoints, "&nullPath", "&nullPath", "&nullPath"] + # Course path + path_table: + [d_course_sherbet_land_track_path, "&nullPath", "&nullPath", "&nullPath"] # Unused except in podium ceremony - path_table_unknown: [d_course_sherbet_land_unknown_waypoints, "&nullPath", "&nullPath", "&nullPath"] + path_table_unknown: + [d_course_sherbet_land_unknown_path, "&nullPath", "&nullPath", "&nullPath"] sky_colors: [128, 4280, 6136, 216, 7144, 32248] sky_colors2: [216, 7144, 32248, 128, 4280, 6136] diff --git a/yamls/courses/skyscraper_metadata.yml b/yamls/courses/skyscraper_metadata.yml index 451405a911..4b89c88c98 100644 --- a/yamls/courses/skyscraper_metadata.yml +++ b/yamls/courses/skyscraper_metadata.yml @@ -7,9 +7,9 @@ course: cup: BATTLE_CUP cup_index: 3 course_length: "" - kart_ai_behaviour_ptr: D_0D008F18 - kart_ai_maximum_separation: -1.0f - kart_ai_minimum_separation: 0.5f + cpu_behaviour_ptr: D_0D008F18 + cpu_maximum_separation: -1.0f + cpu_minimum_separation: 0.5f D_800DCBB4: D_800DCAF4 cpu_steering_sensitivity: 53 bomb_kart_spawns: # 7 bomb kart spawn locations @@ -23,16 +23,16 @@ course: path_sizes: [0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0000, 0x0000, 0x0000] # unk common_textures data - D_0D009418: [4.1666665f, 5.5833334f, 6.1666665f, 6.75f] - D_0D009568: [3.75f, 5.1666665f, 5.75f, 6.3333334f] + cpu_CurveTargetSpeed: [4.1666665f, 5.5833334f, 6.1666665f, 6.75f] + cpu_NormalTargetSpeed: [3.75f, 5.1666665f, 5.75f, 6.3333334f] D_0D0096B8: [3.3333332f, 3.9166667f, 4.5f, 5.0833334f] - D_0D009808: [3.75f, 5.1666665f, 5.75f, 6.3333334f] + cpu_OffTrackTargetSpeed: [3.75f, 5.1666665f, 5.75f, 6.3333334f] - # Course waypoints - path_table: ["&nullPath", "&nullPath", "&nullPath", "&nullPath"] + # Course path + path_table: ["&nullPath", "&nullPath", "&nullPath", "&nullPath"] # Unused except in podium ceremony - path_table_unknown: ["&nullPath", "&nullPath", "&nullPath", "&nullPath"] + path_table_unknown: ["&nullPath", "&nullPath", "&nullPath", "&nullPath"] sky_colors: [0, 0, 0, 0, 0, 0] sky_colors2: [0, 0, 0, 0, 0, 0] diff --git a/yamls/courses/toads_turnpike_metadata.yml b/yamls/courses/toads_turnpike_metadata.yml index a72049b226..d212be04c0 100644 --- a/yamls/courses/toads_turnpike_metadata.yml +++ b/yamls/courses/toads_turnpike_metadata.yml @@ -7,9 +7,9 @@ course: cup: FLOWER_CUP cup_index: 0 course_length: 1036m - kart_ai_behaviour_ptr: D_0D009238 - kart_ai_maximum_separation: 50.0f - kart_ai_minimum_separation: 0.5f + cpu_behaviour_ptr: D_0D009238 + cpu_maximum_separation: 50.0f + cpu_minimum_separation: 0.5f D_800DCBB4: D_800DCAF4 cpu_steering_sensitivity: 40 bomb_kart_spawns: # 7 bomb kart spawn locations @@ -23,16 +23,23 @@ course: path_sizes: [0x03E8, 0x0001, 0x0001, 0x0001, 0x0001, 0x0000, 0x0000, 0x0000] # unk common_textures data - D_0D009418: [4.1666665f, 5.5833334f, 6.1666665f, 6.75f] - D_0D009568: [4.1666665f, 5.5833334f, 6.1666665f, 6.75f] + cpu_CurveTargetSpeed: [4.1666665f, 5.5833334f, 6.1666665f, 6.75f] + cpu_NormalTargetSpeed: [4.1666665f, 5.5833334f, 6.1666665f, 6.75f] D_0D0096B8: [3.3333332f, 3.9166667f, 4.5f, 5.0833334f] - D_0D009808: [3.75f, 5.1666665f, 5.75f, 6.3333334f] + cpu_OffTrackTargetSpeed: [3.75f, 5.1666665f, 5.75f, 6.3333334f] - # Course waypoints - path_table: [d_course_toads_turnpike_track_waypoints, "&nullPath", "&nullPath", "&nullPath"] + # Course path + path_table: + [d_course_toads_turnpike_track_path, "&nullPath", "&nullPath", "&nullPath"] # Unused except in podium ceremony - path_table_unknown: [d_course_toads_turnpike_unknown_waypoints, "&nullPath", "&nullPath", "&nullPath"] + path_table_unknown: + [ + d_course_toads_turnpike_unknown_path, + "&nullPath", + "&nullPath", + "&nullPath", + ] sky_colors: [0, 2, 94, 209, 65, 23] sky_colors2: [209, 65, 23, 0, 0, 0] diff --git a/yamls/courses/wario_stadium_metadata.yml b/yamls/courses/wario_stadium_metadata.yml index 0d994227d2..006f8f47a2 100644 --- a/yamls/courses/wario_stadium_metadata.yml +++ b/yamls/courses/wario_stadium_metadata.yml @@ -7,9 +7,9 @@ course: cup: STAR_CUP cup_index: 0 course_length: 1591m - kart_ai_behaviour_ptr: D_0D009310 - kart_ai_maximum_separation: 50.0f - kart_ai_minimum_separation: 0.6f + cpu_behaviour_ptr: D_0D009310 + cpu_maximum_separation: 50.0f + cpu_minimum_separation: 0.6f D_800DCBB4: D_800DCAF4 cpu_steering_sensitivity: 53 bomb_kart_spawns: # 7 bomb kart spawn locations @@ -23,16 +23,18 @@ course: path_sizes: [0x0640, 0x0001, 0x0001, 0x0001, 0x0001, 0x0000, 0x0000, 0x0000] # unk common_textures data - D_0D009418: [4.1666665f, 5.5833334f, 6.1666665f, 6.75f] - D_0D009568: [3.75f, 5.1666665f, 5.75f, 6.3333334f] + cpu_CurveTargetSpeed: [4.1666665f, 5.5833334f, 6.1666665f, 6.75f] + cpu_NormalTargetSpeed: [3.75f, 5.1666665f, 5.75f, 6.3333334f] D_0D0096B8: [3.3333332f, 3.9166667f, 4.5f, 5.0833334f] - D_0D009808: [3.75f, 5.1666665f, 5.75f, 6.3333334f] + cpu_OffTrackTargetSpeed: [3.75f, 5.1666665f, 5.75f, 6.3333334f] - # Course waypoints - path_table: [d_course_wario_stadium_track_waypoints, "&nullPath", "&nullPath", "&nullPath"] + # Course path + path_table: + [d_course_wario_stadium_track_path, "&nullPath", "&nullPath", "&nullPath"] # Unused except in podium ceremony - path_table_unknown: [d_course_wario_stadium_unknown_waypoints, "&nullPath", "&nullPath", "&nullPath"] + path_table_unknown: + [d_course_wario_stadium_unknown_path, "&nullPath", "&nullPath", "&nullPath"] sky_colors: [20, 30, 56, 40, 60, 110] sky_colors2: [0, 0, 0, 0, 0, 0] diff --git a/yamls/courses/yoshi_valley_metadata.yml b/yamls/courses/yoshi_valley_metadata.yml index 07448f07d5..d5b6548b46 100644 --- a/yamls/courses/yoshi_valley_metadata.yml +++ b/yamls/courses/yoshi_valley_metadata.yml @@ -7,9 +7,9 @@ course: cup: SPECIAL_CUP cup_index: 1 course_length: 772m - kart_ai_behaviour_ptr: D_0D0090B8 - kart_ai_maximum_separation: 35.0f - kart_ai_minimum_separation: 0.0f + cpu_behaviour_ptr: D_0D0090B8 + cpu_maximum_separation: 35.0f + cpu_minimum_separation: 0.0f D_800DCBB4: D_800DCAF4 cpu_steering_sensitivity: 53 bomb_kart_spawns: # 7 bomb kart spawn locations @@ -23,16 +23,28 @@ course: path_sizes: [0x02B2, 0x02A8, 0x02B2, 0x0320, 0x0001, 0x0000, 0x0000, 0x0000] # unk common_textures data - D_0D009418: [4.1666665f, 5.5833334f, 6.1666665f, 6.75f] - D_0D009568: [3.75f, 4.5833334f, 4.5833334f, 4.5833334f] + cpu_CurveTargetSpeed: [4.1666665f, 5.5833334f, 6.1666665f, 6.75f] + cpu_NormalTargetSpeed: [3.75f, 4.5833334f, 4.5833334f, 4.5833334f] D_0D0096B8: [3.3333332f, 3.3333332f, 3.3333332f, 3.3333332f] - D_0D009808: [2.9166667f, 3.75f, 3.75f, 3.75f] + cpu_OffTrackTargetSpeed: [2.9166667f, 3.75f, 3.75f, 3.75f] - # Course waypoints - path_table: [d_course_yoshi_valley_track_waypoints, "d_course_yoshi_valley_track_waypoints_2", "d_course_yoshi_valley_track_waypoints_3", "d_course_yoshi_valley_track_waypoints_4"] + # Course path + path_table: + [ + d_course_yoshi_valley_track_path, + "d_course_yoshi_valley_track_path_2", + "d_course_yoshi_valley_track_path_3", + "d_course_yoshi_valley_track_path_4", + ] # Unused except in podium ceremony - path_table_unknown: [d_course_yoshi_valley_unknown_waypoints, d_course_yoshi_valley_unknown_waypoints_2, d_course_yoshi_valley_unknown_waypoints_3, d_course_yoshi_valley_unknown_waypoints_4] + path_table_unknown: + [ + d_course_yoshi_valley_unknown_path, + d_course_yoshi_valley_unknown_path_2, + d_course_yoshi_valley_unknown_path_3, + d_course_yoshi_valley_unknown_path_4, + ] sky_colors: [113, 70, 255, 255, 184, 99] sky_colors2: [95, 40, 15, 0, 0, 0] diff --git a/yamls/us/ceremony_data.yml b/yamls/us/ceremony_data.yml index bc68825e66..9a3cb1cf0e 100644 --- a/yamls/us/ceremony_data.yml +++ b/yamls/us/ceremony_data.yml @@ -1,13 +1,13 @@ :config: segments: - [0x0B, 0x821D10] - header: + header: code: - - '#include ' + - "#include " header: - - '#include ' - - '#include ' - - '#include ' + - "#include " + - "#include " + - "#include " silver_trophy_dl: symbol: silver_trophy_dl @@ -219,21 +219,21 @@ podium3_dl4: offset: 0x8AA0 ending_sequence: symbol: podium_ceremony_path - type: mk64:track_waypoints + type: mk64:track_path offset: 0x8AA8 count: 24 ending_sequence2: symbol: podium_ceremony_path_2 - type: mk64:track_waypoints + type: mk64:track_path offset: 0x8B68 count: 23 ending_sequence3: symbol: podium_ceremony_path_3 - type: mk64:track_waypoints + type: mk64:track_path offset: 0x8C20 count: 24 ending_sequence4: symbol: podium_ceremony_path_4 - type: mk64:track_waypoints + type: mk64:track_path offset: 0x8CE0 count: 21 diff --git a/yamls/us/common_data.yml b/yamls/us/common_data.yml index 75f6e250c7..468579b29a 100644 --- a/yamls/us/common_data.yml +++ b/yamls/us/common_data.yml @@ -13,7 +13,7 @@ tables: common_grand_prix_human_item_curve: range: [0x8150, 0x840C] - common_grand_prix_kart_ai_item_curve: + common_grand_prix_cpu_item_curve: range: [0x8470, 0x872C] common_versus_2_player_item_curve: range: [0x8790, 0x87F4] @@ -883,36 +883,36 @@ common_grand_prix_human_item_curve8: symbol: common_grand_prix_human_item_curve8 type: mk64:item_curve offset: 0x840C -common_grand_prix_kart_ai_item_curve: - symbol: common_grand_prix_kart_ai_item_curve +common_grand_prix_cpu_item_curve: + symbol: common_grand_prix_cpu_item_curve type: mk64:item_curve offset: 0x8470 -common_grand_prix_kart_ai_item_curve2: - symbol: common_grand_prix_kart_ai_item_curve2 +common_grand_prix_cpu_item_curve2: + symbol: common_grand_prix_cpu_item_curve2 type: mk64:item_curve offset: 0x84D4 -common_grand_prix_kart_ai_item_curve3: - symbol: common_grand_prix_kart_ai_item_curve3 +common_grand_prix_cpu_item_curve3: + symbol: common_grand_prix_cpu_item_curve3 type: mk64:item_curve offset: 0x8538 -common_grand_prix_kart_ai_item_curve4: - symbol: common_grand_prix_kart_ai_item_curve4 +common_grand_prix_cpu_item_curve4: + symbol: common_grand_prix_cpu_item_curve4 type: mk64:item_curve offset: 0x859C -common_grand_prix_kart_ai_item_curve5: - symbol: common_grand_prix_kart_ai_item_curve5 +common_grand_prix_cpu_item_curve5: + symbol: common_grand_prix_cpu_item_curve5 type: mk64:item_curve offset: 0x8600 -common_grand_prix_kart_ai_item_curve6: - symbol: common_grand_prix_kart_ai_item_curve6 +common_grand_prix_cpu_item_curve6: + symbol: common_grand_prix_cpu_item_curve6 type: mk64:item_curve offset: 0x8664 -common_grand_prix_kart_ai_item_curve7: - symbol: common_grand_prix_kart_ai_item_curve7 +common_grand_prix_cpu_item_curve7: + symbol: common_grand_prix_cpu_item_curve7 type: mk64:item_curve offset: 0x86C8 -common_grand_prix_kart_ai_item_curve8: - symbol: common_grand_prix_kart_ai_item_curve8 +common_grand_prix_cpu_item_curve8: + symbol: common_grand_prix_cpu_item_curve8 type: mk64:item_curve offset: 0x872C common_versus_2_player_item_curve: @@ -1098,31 +1098,31 @@ D_0D0093C0: symbol: D_0D0093C0 type: mk64:driving_behaviour offset: 0x93C0 -D_0D009418: - symbol: D_0D009418 +cpu_CurveTargetSpeed: + symbol: cpu_CurveTargetSpeed type: inc offset: 0x9418 ctype: Vec4f offset: 0x9418 - file_path: "assets/course_metadata/D_0D009418.inc.c" -D_0D009568: - symbol: D_0D009568 + file_path: "assets/course_metadata/cpu_CurveTargetSpeed.inc.c" +cpu_NormalTargetSpeed: + symbol: cpu_NormalTargetSpeed type: inc offset: 0x9568 ctype: Vec4f - file_path: "assets/course_metadata/D_0D009568.inc.c" + file_path: "assets/course_metadata/cpu_NormalTargetSpeed.inc.c" D_0D0096B8: symbol: D_0D0096B8 type: inc offset: 0x96B8 ctype: Vec4f file_path: "assets/course_metadata/D_0D0096B8.inc.c" -D_0D009808: - symbol: D_0D009808 +cpu_OffTrackTargetSpeed: + symbol: cpu_OffTrackTargetSpeed type: inc offset: 0x9808 ctype: Vec4f - file_path: "assets/course_metadata/D_0D009808.inc.c" + file_path: "assets/course_metadata/cpu_OffTrackTargetSpeed.inc.c" common_texture_speedometer: symbol: common_texture_speedometer type: texture