From 7a0280f0e383ca6420b4bb69d28b5787e3b1ea7f Mon Sep 17 00:00:00 2001 From: Maciek Baron Date: Mon, 20 Dec 2021 11:22:04 +0000 Subject: [PATCH] Add gPlayerIsAccelerating, gPlayerBalloonCount and update related code (#105) * Add balloon count * Add gPlayerIsThrottleActive --- asm/bss_8001C4D0.s | 5 +- .../code_80027D00/func_80030C34.s | 12 ++-- .../code_80027D00/func_80030E00.s | 10 +-- .../code_80057C60/func_8006B7E4.s | 4 +- .../code_80057C60/func_8006B8B4.s | 6 +- .../code_80057C60/func_8006B974.s | 6 +- .../code_802B0210/func_802B3FD0.s | 10 +-- include/common_structs.h | 6 +- include/variables.h | 2 +- src/code_80027D00.c | 4 +- src/code_800393C0.c | 62 +++++++++---------- src/code_80057C60.c | 50 +++++++-------- src/code_8028DF00.c | 37 +++++------ src/code_802B0210.c | 4 +- 14 files changed, 110 insertions(+), 108 deletions(-) diff --git a/asm/bss_8001C4D0.s b/asm/bss_8001C4D0.s index ab7bff767..00826c5e3 100644 --- a/asm/bss_8001C4D0.s +++ b/asm/bss_8001C4D0.s @@ -163,7 +163,7 @@ glabel D_80165340 glabel D_801653C0 .skip 32 -glabel D_801653E0 +glabel gPlayerIsThrottleActive .skip 32 glabel D_80165400 @@ -1704,7 +1704,8 @@ glabel D_8018D860 glabel D_8018D890 .skip 48 -glabel D_8018D8C0 +# Indicates how many balloons each player has +glabel gPlayerBalloonCount .skip 16 glabel D_8018D8D0 diff --git a/asm/non_matchings/code_80027D00/func_80030C34.s b/asm/non_matchings/code_80027D00/func_80030C34.s index d5887f9c9..0daa95ab8 100644 --- a/asm/non_matchings/code_80027D00/func_80030C34.s +++ b/asm/non_matchings/code_80027D00/func_80030C34.s @@ -25,26 +25,26 @@ glabel func_80030C34 /* 031884 80030C84 3C0D8016 */ lui $t5, %hi(D_80165460) # $t5, 0x8016 /* 031888 80030C88 25AD5460 */ addiu $t5, %lo(D_80165460) # addiu $t5, $t5, 0x5460 /* 03188C 80030C8C 14990002 */ bne $a0, $t9, .L80030C98 -/* 031890 80030C90 00000000 */ nop +/* 031890 80030C90 00000000 */ nop /* 031894 80030C94 24020003 */ li $v0, 3 .L80030C98: /* 031898 80030C98 8D29C4EC */ lw $t1, %lo(D_800DC4EC)($t1) -/* 03189C 80030C9C 3C0F8016 */ lui $t7, %hi(D_801653E0) # $t7, 0x8016 -/* 0318A0 80030CA0 25EF53E0 */ addiu $t7, %lo(D_801653E0) # addiu $t7, $t7, 0x53e0 +/* 03189C 80030C9C 3C0F8016 */ lui $t7, %hi(gPlayerIsThrottleActive) # $t7, 0x8016 +/* 0318A0 80030CA0 25EF53E0 */ addiu $t7, %lo(gPlayerIsThrottleActive) # addiu $t7, $t7, 0x53e0 /* 0318A4 80030CA4 14890002 */ bne $a0, $t1, .L80030CB0 -/* 0318A8 80030CA8 00000000 */ nop +/* 0318A8 80030CA8 00000000 */ nop /* 0318AC 80030CAC 24020004 */ li $v0, 4 .L80030CB0: /* 0318B0 80030CB0 8D4AC4F0 */ lw $t2, %lo(D_800DC4F0)($t2) /* 0318B4 80030CB4 3C098016 */ lui $t1, %hi(D_80165420) # $t1, 0x8016 /* 0318B8 80030CB8 25295420 */ addiu $t1, %lo(D_80165420) # addiu $t1, $t1, 0x5420 /* 0318BC 80030CBC 148A0002 */ bne $a0, $t2, .L80030CC8 -/* 0318C0 80030CC0 00000000 */ nop +/* 0318C0 80030CC0 00000000 */ nop /* 0318C4 80030CC4 24020005 */ li $v0, 5 .L80030CC8: /* 0318C8 80030CC8 8D6BC4F4 */ lw $t3, %lo(D_800DC4F4)($t3) /* 0318CC 80030CCC 148B0002 */ bne $a0, $t3, .L80030CD8 -/* 0318D0 80030CD0 00000000 */ nop +/* 0318D0 80030CD0 00000000 */ nop /* 0318D4 80030CD4 24020006 */ li $v0, 6 .L80030CD8: /* 0318D8 80030CD8 8D8CC4F8 */ lw $t4, %lo(D_800DC4F8)($t4) diff --git a/asm/non_matchings/code_80027D00/func_80030E00.s b/asm/non_matchings/code_80027D00/func_80030E00.s index 57172e0bb..923a649c7 100644 --- a/asm/non_matchings/code_80027D00/func_80030E00.s +++ b/asm/non_matchings/code_80027D00/func_80030E00.s @@ -25,14 +25,14 @@ glabel func_80030E00 /* 031A50 80030E50 3C0D8016 */ lui $t5, %hi(D_80165460) # $t5, 0x8016 /* 031A54 80030E54 25AD5460 */ addiu $t5, %lo(D_80165460) # addiu $t5, $t5, 0x5460 /* 031A58 80030E58 14990002 */ bne $a0, $t9, .L80030E64 -/* 031A5C 80030E5C 00000000 */ nop +/* 031A5C 80030E5C 00000000 */ nop /* 031A60 80030E60 24020003 */ li $v0, 3 .L80030E64: /* 031A64 80030E64 8D29C4EC */ lw $t1, %lo(D_800DC4EC)($t1) -/* 031A68 80030E68 3C0F8016 */ lui $t7, %hi(D_801653E0) # $t7, 0x8016 -/* 031A6C 80030E6C 25EF53E0 */ addiu $t7, %lo(D_801653E0) # addiu $t7, $t7, 0x53e0 +/* 031A68 80030E68 3C0F8016 */ lui $t7, %hi(gPlayerIsThrottleActive) # $t7, 0x8016 +/* 031A6C 80030E6C 25EF53E0 */ addiu $t7, %lo(gPlayerIsThrottleActive) # addiu $t7, $t7, 0x53e0 /* 031A70 80030E70 14890002 */ bne $a0, $t1, .L80030E7C -/* 031A74 80030E74 00000000 */ nop +/* 031A74 80030E74 00000000 */ nop /* 031A78 80030E78 24020004 */ li $v0, 4 .L80030E7C: /* 031A7C 80030E7C 8D4AC4F0 */ lw $t2, %lo(D_800DC4F0)($t2) @@ -44,7 +44,7 @@ glabel func_80030E00 .L80030E94: /* 031A94 80030E94 8D6BC4F4 */ lw $t3, %lo(D_800DC4F4)($t3) /* 031A98 80030E98 148B0002 */ bne $a0, $t3, .L80030EA4 -/* 031A9C 80030E9C 00000000 */ nop +/* 031A9C 80030E9C 00000000 */ nop /* 031AA0 80030EA0 24020006 */ li $v0, 6 .L80030EA4: /* 031AA4 80030EA4 8D8CC4F8 */ lw $t4, %lo(D_800DC4F8)($t4) diff --git a/asm/non_matchings/code_80057C60/func_8006B7E4.s b/asm/non_matchings/code_80057C60/func_8006B7E4.s index b6de2ae54..2d84c1f2e 100644 --- a/asm/non_matchings/code_80057C60/func_8006B7E4.s +++ b/asm/non_matchings/code_80057C60/func_8006B7E4.s @@ -30,10 +30,10 @@ glabel func_8006B7E4 /* 06C454 8006B854 83A70027 */ lb $a3, 0x27($sp) /* 06C458 8006B858 83A90027 */ lb $t1, 0x27($sp) /* 06C45C 8006B85C 8FBF001C */ lw $ra, 0x1c($sp) -/* 06C460 8006B860 3C018019 */ lui $at, %hi(D_8018D8C0) +/* 06C460 8006B860 3C018019 */ lui $at, %hi(gPlayerBalloonCount) /* 06C464 8006B864 00095040 */ sll $t2, $t1, 1 /* 06C468 8006B868 002A0821 */ addu $at, $at, $t2 /* 06C46C 8006B86C 24080002 */ li $t0, 2 -/* 06C470 8006B870 A428D8C0 */ sh $t0, %lo(D_8018D8C0)($at) +/* 06C470 8006B870 A428D8C0 */ sh $t0, %lo(gPlayerBalloonCount)($at) /* 06C474 8006B874 03E00008 */ jr $ra /* 06C478 8006B878 27BD0020 */ addiu $sp, $sp, 0x20 diff --git a/asm/non_matchings/code_80057C60/func_8006B8B4.s b/asm/non_matchings/code_80057C60/func_8006B8B4.s index a2787387b..7207457c4 100644 --- a/asm/non_matchings/code_80057C60/func_8006B8B4.s +++ b/asm/non_matchings/code_80057C60/func_8006B8B4.s @@ -1,8 +1,8 @@ glabel func_8006B8B4 /* 06C4B4 8006B8B4 00053600 */ sll $a2, $a1, 0x18 /* 06C4B8 8006B8B8 00067603 */ sra $t6, $a2, 0x18 -/* 06C4BC 8006B8BC 3C188019 */ lui $t8, %hi(D_8018D8C0) # $t8, 0x8019 -/* 06C4C0 8006B8C0 2718D8C0 */ addiu $t8, %lo(D_8018D8C0) # addiu $t8, $t8, -0x2740 +/* 06C4BC 8006B8BC 3C188019 */ lui $t8, %hi(gPlayerBalloonCount) # $t8, 0x8019 +/* 06C4C0 8006B8C0 2718D8C0 */ addiu $t8, %lo(gPlayerBalloonCount) # addiu $t8, $t8, -0x2740 /* 06C4C4 8006B8C4 000E7840 */ sll $t7, $t6, 1 /* 06C4C8 8006B8C8 01F81821 */ addu $v1, $t7, $t8 /* 06C4CC 8006B8CC 84670000 */ lh $a3, ($v1) @@ -48,4 +48,4 @@ glabel func_8006B8B4 .L8006B968: /* 06C568 8006B968 27BD0020 */ addiu $sp, $sp, 0x20 /* 06C56C 8006B96C 03E00008 */ jr $ra -/* 06C570 8006B970 00000000 */ nop +/* 06C570 8006B970 00000000 */ nop diff --git a/asm/non_matchings/code_80057C60/func_8006B974.s b/asm/non_matchings/code_80057C60/func_8006B974.s index a804dd8b5..996416e72 100644 --- a/asm/non_matchings/code_80057C60/func_8006B974.s +++ b/asm/non_matchings/code_80057C60/func_8006B974.s @@ -2,9 +2,9 @@ glabel func_8006B974 /* 06C574 8006B974 00057600 */ sll $t6, $a1, 0x18 /* 06C578 8006B978 000E7E03 */ sra $t7, $t6, 0x18 /* 06C57C 8006B97C 000F4040 */ sll $t0, $t7, 1 -/* 06C580 8006B980 3C098019 */ lui $t1, %hi(D_8018D8C0) +/* 06C580 8006B980 3C098019 */ lui $t1, %hi(gPlayerBalloonCount) /* 06C584 8006B984 01284821 */ addu $t1, $t1, $t0 -/* 06C588 8006B988 8529D8C0 */ lh $t1, %lo(D_8018D8C0)($t1) +/* 06C588 8006B988 8529D8C0 */ lh $t1, %lo(gPlayerBalloonCount)($t1) /* 06C58C 8006B98C 0006C600 */ sll $t8, $a2, 0x18 /* 06C590 8006B990 0018CE03 */ sra $t9, $t8, 0x18 /* 06C594 8006B994 AFA40000 */ sw $a0, ($sp) @@ -21,4 +21,4 @@ glabel func_8006B974 /* 06C5C0 8006B9C0 A420D5F0 */ sh $zero, %lo(D_8018D5F0)($at) .L8006B9C4: /* 06C5C4 8006B9C4 03E00008 */ jr $ra -/* 06C5C8 8006B9C8 00000000 */ nop +/* 06C5C8 8006B9C8 00000000 */ nop diff --git a/asm/non_matchings/code_802B0210/func_802B3FD0.s b/asm/non_matchings/code_802B0210/func_802B3FD0.s index 876424931..388ae49c0 100644 --- a/asm/non_matchings/code_802B0210/func_802B3FD0.s +++ b/asm/non_matchings/code_802B0210/func_802B3FD0.s @@ -12,7 +12,7 @@ glabel func_802B3FD0 /* 11D608 802B3FF8 F7B40018 */ sdc1 $f20, 0x18($sp) /* 11D60C 802B3FFC 3C01802C */ lui $at, %hi(D_802B9F68) # $at, 0x802c /* 11D610 802B4000 3C10800F */ lui $s0, %hi(gPlayers) # $s0, 0x800f -/* 11D614 802B4004 3C158019 */ lui $s5, %hi(D_8018D8C0) # $s5, 0x8019 +/* 11D614 802B4004 3C158019 */ lui $s5, %hi(gPlayerBalloonCount) # $s5, 0x8019 /* 11D618 802B4008 3C16800E */ lui $s6, %hi(D_800DC4DC) # $s6, 0x800e /* 11D61C 802B400C 00809025 */ move $s2, $a0 /* 11D620 802B4010 00A09825 */ move $s3, $a1 @@ -20,7 +20,7 @@ glabel func_802B3FD0 /* 11D628 802B4018 241EFFFF */ li $fp, -1 /* 11D62C 802B401C C4349F68 */ lwc1 $f20, %lo(D_802B9F68)($at) /* 11D630 802B4020 26D6C4DC */ addiu $s6, %lo(D_800DC4DC) # addiu $s6, $s6, -0x3b24 -/* 11D634 802B4024 26B5D8C0 */ addiu $s5, %lo(D_8018D8C0) # addiu $s5, $s5, -0x2740 +/* 11D634 802B4024 26B5D8C0 */ addiu $s5, %lo(gPlayerBalloonCount) # addiu $s5, $s5, -0x2740 /* 11D638 802B4028 26106990 */ addiu $s0, %lo(gPlayers) # addiu $s0, $s0, 0x6990 /* 11D63C 802B402C 00008825 */ move $s1, $zero /* 11D640 802B4030 24140004 */ li $s4, 4 @@ -40,7 +40,7 @@ glabel func_802B3FD0 /* 11D674 802B4064 0C0AD47A */ jal func_802B51E8 /* 11D678 802B4068 26650018 */ addiu $a1, $s3, 0x18 /* 11D67C 802B406C 4614003C */ c.lt.s $f0, $f20 -/* 11D680 802B4070 00000000 */ nop +/* 11D680 802B4070 00000000 */ nop /* 11D684 802B4074 45020013 */ bc1fl .L802B40C4 /* 11D688 802B4078 26310001 */ addiu $s1, $s1, 1 /* 11D68C 802B407C 8EC90000 */ lw $t1, ($s6) @@ -52,14 +52,14 @@ glabel func_802B3FD0 /* 11D6A4 802B4094 000B6403 */ sra $t4, $t3, 0x10 /* 11D6A8 802B4098 0180F025 */ move $fp, $t4 /* 11D6AC 802B409C 16E00002 */ bnez $s7, .L802B40A8 -/* 11D6B0 802B40A0 00000000 */ nop +/* 11D6B0 802B40A0 00000000 */ nop /* 11D6B4 802B40A4 0007000D */ break 7 .L802B40A8: /* 11D6B8 802B40A8 2401FFFF */ li $at, -1 /* 11D6BC 802B40AC 16E10004 */ bne $s7, $at, .L802B40C0 /* 11D6C0 802B40B0 3C018000 */ lui $at, 0x8000 /* 11D6C4 802B40B4 15410002 */ bne $t2, $at, .L802B40C0 -/* 11D6C8 802B40B8 00000000 */ nop +/* 11D6C8 802B40B8 00000000 */ nop /* 11D6CC 802B40BC 0006000D */ break 6 .L802B40C0: /* 11D6D0 802B40C0 26310001 */ addiu $s1, $s1, 1 diff --git a/include/common_structs.h b/include/common_structs.h index 383d1e521..b84e7b587 100644 --- a/include/common_structs.h +++ b/include/common_structs.h @@ -54,7 +54,7 @@ typedef struct { s32 shellPos1; // BF8 = empty s32 shellPos2; // 422 full s32 shellPos3; // 422C full - + } Item; // Inventory? typedef struct { @@ -84,7 +84,7 @@ typedef struct { s32 unk12; // 0 u16 unk13; // 0x103F7 u16 unk13_and_a_half; - u16 unk14; // 0x05BC00## Surface camera is over? + u16 unk14; // 0x05BC00## Surface camera is over? u16 unk14_half; f32 collisionX; f32 collisionY; @@ -253,7 +253,7 @@ typedef struct { /* 0x01FC */ f32 unk_1FC; /* 0x0200 */ s32 unk_200; /* 0x0204 */ s16 unk_204; - /* 0x0206 */ s16 unk_206; + /* 0x0206 */ s16 unk_206; /* 0x0208 */ f32 unk_208; /* 0x020C */ f32 unk_20C; /* 0x0210 */ f32 unk_210; diff --git a/include/variables.h b/include/variables.h index c09f193ca..fdc018153 100644 --- a/include/variables.h +++ b/include/variables.h @@ -99,7 +99,7 @@ extern s16 D_80165020[]; extern Vec3f D_80165070[]; extern f32 D_80165280[]; extern f32 D_801652A0[]; -extern s32 D_801653E0[]; +extern s32 gPlayerIsThrottleActive[]; extern s32 D_80165400[]; extern s32 D_801654A0[]; extern s32 D_801654C0[]; diff --git a/src/code_80027D00.c b/src/code_80027D00.c index 2b0264b8f..24837c6f1 100644 --- a/src/code_80027D00.c +++ b/src/code_80027D00.c @@ -4683,7 +4683,7 @@ void func_80030C34(s32 arg0) { temp_a0 = &D_80165460[phi_v0]; temp_v0 = &D_80165480[phi_v0]; if (*temp_a0 == 0) { - temp_v0_2 = &D_801653E0[phi_v0]; + temp_v0_2 = &gPlayerIsThrottleActive[phi_v0]; if (*temp_v0_2 == 1) { temp_a1 = &D_80165420[phi_v0]; temp_a2 = *temp_a1; @@ -4775,7 +4775,7 @@ void func_80030E00(s32 arg0) { temp_a0 = &D_80165460[phi_v0]; temp_v0 = &D_80165480[phi_v0]; if (*temp_a0 == 0) { - temp_v0_2 = &D_801653E0[phi_v0]; + temp_v0_2 = &gPlayerIsThrottleActive[phi_v0]; temp_a1 = &D_80165420[phi_v0]; if (*temp_v0_2 == 0) { temp_a2 = *temp_a1; diff --git a/src/code_800393C0.c b/src/code_800393C0.c index 28eae48a7..a50c7c7e3 100644 --- a/src/code_800393C0.c +++ b/src/code_800393C0.c @@ -17,7 +17,7 @@ extern Camera *camera4; //GLOBAL_ASM("asm/non_matchings/code_800393C0/spawn_player.s") -void spawn_player(Player *player, s8 arg1, f32 arg2, f32 arg3, f32 arg4, f32 arg5, u16 arg6, s16 arg7) { +void spawn_player(Player *player, s8 playerIndex, f32 arg2, f32 arg3, f32 arg4, f32 arg5, u16 arg6, s16 arg7) { f32 ret; s8 idx; @@ -61,7 +61,7 @@ void spawn_player(Player *player, s8 arg1, f32 arg2, f32 arg3, f32 arg4, f32 arg player->rotX = arg2; player->rotY = ret; - D_80164510[arg1] = ret; + D_80164510[playerIndex] = ret; player->unk_02C = 0; @@ -76,7 +76,7 @@ void spawn_player(Player *player, s8 arg1, f32 arg2, f32 arg3, f32 arg4, f32 arg player->unk_030 = 0; player->unk_0FA = 0; player->unk_002 = 0; - + player->unk_0BC = 0; player->unk_0C0 = 0; player->unk_07C = 0; @@ -103,7 +103,7 @@ void spawn_player(Player *player, s8 arg1, f32 arg2, f32 arg3, f32 arg4, f32 arg player->unk_00C = 0; player->unk_0C6 = 0xFF; - + player->unk_206 = 0; player->unk_0C4 = 0; player->unk_D98 = 0; @@ -193,7 +193,7 @@ void spawn_player(Player *player, s8 arg1, f32 arg2, f32 arg3, f32 arg4, f32 arg player->unk_230 = 0.0f; player->unk_23C = 0.0f; - idx = arg1; + idx = playerIndex; D_801650D0[0][idx] = 0; D_801650D0[1][idx] = 0; @@ -219,21 +219,21 @@ void spawn_player(Player *player, s8 arg1, f32 arg2, f32 arg3, f32 arg4, f32 arg D_801654E0[idx] = 0; D_80165500[idx] = 0; D_80165520[idx] = 0; - D_80165540[arg1] = 0; + D_80165540[playerIndex] = 0; D_8018D900 = 0; - D_801652E0[arg1] = 0; - D_801652C0[arg1] = 0; - D_80165020[arg1] = 0; - D_80165070[arg1][0] = 0.0f; - D_80165070[arg1][1] = 0.0f; - D_80165070[arg1][2] = 0.0f; - D_80165280[arg1] = 0.0f; - D_801652A0[arg1] = 0.0f; - D_801653E0[arg1] = 0; - D_80165400[arg1] = 0; - D_801654A0[arg1] = 0; - D_801654C0[arg1] = 0; + D_801652E0[playerIndex] = 0; + D_801652C0[playerIndex] = 0; + D_80165020[playerIndex] = 0; + D_80165070[playerIndex][0] = 0.0f; + D_80165070[playerIndex][1] = 0.0f; + D_80165070[playerIndex][2] = 0.0f; + D_80165280[playerIndex] = 0.0f; + D_801652A0[playerIndex] = 0.0f; + gPlayerIsThrottleActive[playerIndex] = 0; + D_80165400[playerIndex] = 0; + D_801654A0[playerIndex] = 0; + D_801654C0[playerIndex] = 0; D_80165340 = 0; player->unk_1A4 = 0; @@ -287,14 +287,14 @@ void spawn_player(Player *player, s8 arg1, f32 arg2, f32 arg3, f32 arg4, f32 arg player->unk_144 = 0.0f; player->unk_148 = 0.0f; - D_80165300[arg1] = 0; - D_8018CE10[arg1].unk_04 = 0.0f; - D_8018CE10[arg1].unk_0C = 0.0f; - func_80295BF8(arg1); + D_80165300[playerIndex] = 0; + D_8018CE10[playerIndex].unk_04 = 0.0f; + D_8018CE10[playerIndex].unk_0C = 0.0f; + func_80295BF8(playerIndex); func_8005D6C0(player); - func_8006B87C(player, arg1); + func_8006B87C(player, playerIndex); if (gModeSelection == BATTLE) { - func_8006B7E4(player, arg1); + func_8006B7E4(player, playerIndex); } func_802B6540(player->unk_150, player->unk_058, player->unk_05C, player->unk_060, player->unk_02E); func_802B6540(player->unk_174, player->unk_058, player->unk_05C, player->unk_060, player->unk_02E); @@ -406,8 +406,8 @@ void func_80039DA4(void) { temp_80039DA4 sp2C = D_800E4360; temp_80039DA4 spC = D_800E4380; - if (((gCupCourseSelection == CUP_COURSE_ONE) && (D_8016556E == 0)) || - (D_800DC51C == 1) || + if (((gCupCourseSelection == CUP_COURSE_ONE) && (D_8016556E == 0)) || + (D_800DC51C == 1) || (D_8018EDEF == 0x40)) { for (i = 0; i < 8; i++) { D_80165270[i] = sp2C.unk00[i]; @@ -422,7 +422,7 @@ void func_80039DA4(void) { void func_80039F44(f32 *arg0, f32 *arg1, f32 arg2) { func_80039DA4(); if (((gCupCourseSelection == CUP_COURSE_ONE) && (D_8016556E == 0)) || - (D_800DC51C == 1) || + (D_800DC51C == 1) || (D_8018EDEF == 0x40)) { s16 rand; s16 i; @@ -538,7 +538,7 @@ getRand: spawn_player(D_800DC4F0, 5, arg0[D_80165270[5]], arg1[D_80165270[5]], arg2, 32768.0f, D_80165560[3], PLAYER_EXISTS | PLAYER_CPU | PLAYER_START_SEQUENCE); spawn_player(D_800DC4F4, 6, arg0[D_80165270[6]], arg1[D_80165270[6]], arg2, 32768.0f, D_80165560[4], PLAYER_EXISTS | PLAYER_CPU | PLAYER_START_SEQUENCE); spawn_player(D_800DC4F8, 7, arg0[D_80165270[7]], arg1[D_80165270[7]], arg2, 32768.0f, D_80165560[5], PLAYER_EXISTS | PLAYER_CPU | PLAYER_START_SEQUENCE); - + if (D_800DC51C == 1) { spawn_player(D_800DC4FC, 0, arg0[D_80165270[0]], arg1[D_80165270[0]], arg2, 32768.0f, D_800E86A8[0], PLAYER_HUMAN_AND_CPU); } else { @@ -836,7 +836,7 @@ void func_8003C0F0(void) { D_80165210[2] = D_80165210[4] = D_80165210[6] = sp5E - 0xA; D_80165210[3] = D_80165210[5] = D_80165210[7] = sp5E - 0x1E; D_80165210[1] = sp5E + 0xA; - + D_80165230[0] = sp5C + 0x1E; D_80165230[1] = sp5C + 0x1E; D_80165230[2] = sp5C + 0x1E; @@ -878,7 +878,7 @@ void func_8003C0F0(void) { }; D_80165210[2] = -200.0f; D_80165230[1] = -200.0f; - + D_80165210[0] = 0.0f; D_80165210[1] = 0.0f; D_80165230[2] = 0.0f; @@ -1239,7 +1239,7 @@ void func_8003DB5C(void) { func_8001C4D0(player->posX, player->posY, player->posZ, player->unk_02E, 3, 0); func_8001C4D0(player->posX, player->posY, player->posZ, player->unk_02E, 3, 1); - + for (i = 0; i < 8; i++, player++) { func_80027A20(player, i, 1, 0); func_80027A20(player, i, 1, 1); diff --git a/src/code_80057C60.c b/src/code_80057C60.c index 5ed10bae1..365ba40a9 100644 --- a/src/code_80057C60.c +++ b/src/code_80057C60.c @@ -458,12 +458,12 @@ void func_80058B58(s32 arg0) { //temp_v0 = gCurrentCourseId; if (gCurrentCourseId != COURSE_FRAPPE_SNOWLAND) { if (gCurrentCourseId != COURSE_SHERBET_LAND) { - + } else { func_80052C60(); } return;// Duplicate return node #9. Try simplifying control flow for better match - } + } if (D_800DC50C != 9) { if ((D_8015F894 == 0) && (gPlayerCountSelection1 == COURSE_CHOCO_MOUNTAIN)) { func_800517C8(); @@ -472,7 +472,7 @@ void func_80058B58(s32 arg0) { //return; } func_800517C8(); - + //return arg0; } #else @@ -482,7 +482,7 @@ GLOBAL_ASM("asm/non_matchings/code_80057C60/func_80058B58.s") extern u8 D_0D0076F8; void func_80058BF4(void) { - gSPDisplayList(gDisplayListHead++, &D_0D0076F8); + gSPDisplayList(gDisplayListHead++, &D_0D0076F8); } #ifdef MIPS_TO_C @@ -11067,13 +11067,13 @@ GLOBAL_ASM("asm/non_matchings/code_80057C60/func_8006AFD0.s") #ifdef MIPS_TO_C //generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307 ? func_8006A50C(Player *, Player *, s8, s32, s32, s32); // extern -extern ? D_8018D8C0; +extern ? gPlayerBalloonCount; void func_8006B7E4(Player *player, s32 arg1) { func_8006A50C(NULL, NULL, arg1, 0, 0); func_8006A50C(player, 0x3FC00000, 0x40000000, arg1, 1, 0x1C70); func_8006A50C(player, 0xBFC00000, 0x40000000, arg1, 2, -0x1C70); - *(&D_8018D8C0 + (arg1 * 2)) = 2; + *(&gPlayerBalloonCount + (arg1 * 2)) = 2; } #else GLOBAL_ASM("asm/non_matchings/code_80057C60/func_8006B7E4.s") @@ -11100,32 +11100,32 @@ GLOBAL_ASM("asm/non_matchings/code_80057C60/func_8006B87C.s") ? func_8008FD4C(s32, s8, s8); // extern ? func_800C9060(s32, ?, s8, s16); // extern extern ? D_8018D5F0; -extern ? D_8018D8C0; +extern ? gPlayerBalloonCount; -void func_8006B8B4(s32 arg0, s8 arg1) { +void func_8006B8B4(s32 arg0, s8 playerIndex) { s16 *sp1C; - s16 *temp_v1; - s16 temp_a3; + s16 *currentPlayerBalloonCount; + s16 playerBalloonCountValue; s32 temp_a0; - s8 temp_a2; + s8 playerIndexTemp; u16 *temp_v0; u16 temp_t5; - temp_v1 = (arg1 * 2) + &D_8018D8C0; - temp_a3 = *temp_v1; - temp_a2 = arg1; - if (temp_a3 >= 0) { - temp_v0 = (arg1 * 6) + (temp_a3 * 2) + &D_8018D5F0; + currentPlayerBalloonCount = (playerIndex * 2) + &gPlayerBalloonCount; + playerBalloonCountValue = *currentPlayerBalloonCount; + playerIndexTemp = playerIndex; + if (playerBalloonCountValue >= 0) { + temp_v0 = (playerIndex * 6) + (playerBalloonCountValue * 2) + &D_8018D5F0; temp_t5 = *temp_v0 & 0xFFFE; *temp_v0 = temp_t5; *temp_v0 = temp_t5 | 2; - *temp_v1 = temp_a3 - 1; - temp_a0 = temp_a2 & 0xFF; - sp1C = temp_v1; - arg1 = temp_a2; - func_800C9060(temp_a0, 0x19009051, temp_a2, temp_a3); - if (*temp_v1 < 0) { - func_8008FD4C(arg0, arg1, arg1); + *currentPlayerBalloonCount = playerBalloonCountValue - 1; + temp_a0 = playerIndexTemp & 0xFF; + sp1C = currentPlayerBalloonCount; + playerIndex = playerIndexTemp; + func_800C9060(temp_a0, 0x19009051, playerIndexTemp, playerBalloonCountValue); + if (*currentPlayerBalloonCount < 0) { + func_8008FD4C(arg0, playerIndex, playerIndex); } } } @@ -11136,10 +11136,10 @@ GLOBAL_ASM("asm/non_matchings/code_80057C60/func_8006B8B4.s") #ifdef MIPS_TO_C //generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307 extern ? D_8018D5F0; -extern ? D_8018D8C0; +extern ? gPlayerBalloonCount; void func_8006B974(s32 arg0, s8 arg1, s8 arg2) { - if (*(&D_8018D8C0 + (arg1 * 2)) >= 0) { + if (*(&gPlayerBalloonCount + (arg1 * 2)) >= 0) { *(&D_8018D5F0 + ((arg1 * 6) + (arg2 * 2))) = 0; } } diff --git a/src/code_8028DF00.c b/src/code_8028DF00.c index 33779427e..3b38a87de 100644 --- a/src/code_8028DF00.c +++ b/src/code_8028DF00.c @@ -37,7 +37,7 @@ extern u8 *D_8015F8C4; extern u8 *D_8015F8C8; extern u8 *D_8015F8CC; -extern s16 D_8018D8C0[]; +extern s16 gPlayerBalloonCount[]; extern s16 D_8016348C; extern s8 gCupCourseSelection; extern s32 D_800DC544; @@ -133,7 +133,7 @@ void func_8028DF00(void) { s32 i; for (i = 0; i < 4; i++) { D_802BA040[i] = controllers->button; - controllers++; + controllers++; } } @@ -168,14 +168,14 @@ void func_8028E028(void) { void func_8028E0F0(void) { Player *ply; - s32 i; + s32 playerIndex; s16 unk_arr2[4]; s16 unk_arr[4]; s16 phi_s1 = 0; s16 phi_s2 = 0; - - for(i = 0; i < 4; i++) { - ply = (Player *)&gPlayers[i]; + + for(playerIndex = 0; playerIndex < 4; playerIndex++) { + ply = (Player *)&gPlayers[playerIndex]; if (!(ply->unk_000 & PLAYER_EXISTS)) { continue; } @@ -183,11 +183,12 @@ void func_8028E0F0(void) { continue; } - if (D_8018D8C0[i] < 0) { + // If player has no balloons left + if (gPlayerBalloonCount[playerIndex] < 0) { ply->unk_000 |= PLAYER_CINEMATIC_MODE; unk_arr[phi_s2] = (s16) (ply - D_800DC4DC); phi_s2++; - func_800CA118((u8) i); + func_800CA118((u8) playerIndex); } else { unk_arr2[phi_s1] = (s16) (ply - D_800DC4DC); phi_s1++; @@ -217,7 +218,7 @@ void func_8028E298(void) { continue; } temp_a2 = D_801645B0[i]; - + temp_v0 = ((2 - gPlayers[i].unk_008) * D_801645C8[temp_a2]); temp_v0 += D_801645C8[temp_a2] * (1.0f - D_801644A8[i]); temp_v0 /= 15.0f; @@ -360,7 +361,7 @@ void func_8028E678(void) { D_800DC5EC->screenWidth = 160; phi_a0_10++; } - + if (D_800DC5F0->screenWidth < 160) { D_800DC5F0->screenWidth = 160; phi_a0_10++; @@ -556,7 +557,7 @@ void func_8028EC98(s32 arg0) { func_800C8EAC(25); break; } - + } void func_8028EDA8(void) { @@ -570,7 +571,7 @@ void func_8028EDA8(void) { if (D_800DC510 == 2) { D_800DC510 = 3; } - + for (i = 0; i < 8; i++) { if ((gPlayers[i].unk_000 & PLAYER_EXISTS) == 0) { @@ -580,9 +581,9 @@ void func_8028EDA8(void) { // Sets player to human. if (gPlayers[i].unk_000 & PLAYER_START_SEQUENCE) { gPlayers[i].unk_000 ^= PLAYER_START_SEQUENCE; - } + } } - + } f32 func_8028EE8C(s32 arg0) { @@ -613,7 +614,7 @@ void func_8028EF28(void) { if (lapCount[i] < gPlayers[i].unk_008) { gPlayers[i].unk_008--; } else if (lapCount[i] > gPlayers[i].unk_008) { - gPlayers[i].unk_008++; + gPlayers[i].unk_008++; if ((gPlayers[i].unk_000 & PLAYER_HUMAN) != 0) { if (gPlayers[i].unk_008 == 3) { @@ -630,7 +631,7 @@ void func_8028EF28(void) { if ((D_802BA032 & PLAYER_EXISTS) == 0) { D_802BA032 |= PLAYER_EXISTS; } - + if (gModeSelection == GRAND_PRIX && gPlayerCountSelection1 == 2 && D_802BA048 == 0) { D_802BA048 = 1; @@ -715,7 +716,7 @@ void func_8028EF28(void) { func_80005AE8(ply); } } - } + } } if ((D_802BA048 != 0) && (D_802BA048 != 100)) { D_802BA048 = 100; @@ -1157,7 +1158,7 @@ void func_8028FCBC(void) { case 1: case 2: if (((D_800DC4DC->unk_000 & PLAYER_CINEMATIC_MODE) != 0) && ((D_800DC4E0->unk_000 & PLAYER_CINEMATIC_MODE) != 0)) { - + if (D_800DC4DC->unk_004 < D_800DC4E0->unk_004) { D_800DC5E8 = 1; } else { diff --git a/src/code_802B0210.c b/src/code_802B0210.c index 5d550a1c9..1740fe2a6 100644 --- a/src/code_802B0210.c +++ b/src/code_802B0210.c @@ -2128,7 +2128,7 @@ GLOBAL_ASM("asm/non_matchings/code_802B0210/func_802B3E7C.s") #ifdef MIPS_TO_C //generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307 f32 func_802B51E8(void *, s32); // extern -extern ? D_8018D8C0; +extern ? gPlayerBalloonCount; extern f32 D_802B9F68; extern u16 gPlayers; @@ -2145,7 +2145,7 @@ s16 func_802B3FD0(s32 arg0, s32 arg1) { phi_f20 = D_802B9F68; phi_fp = -1; do { - if (((*phi_s0 & 0x8000) != 0) && (phi_s0 != arg0) && (*(&D_8018D8C0 + (phi_s1 * 2)) >= 0)) { + if (((*phi_s0 & 0x8000) != 0) && (phi_s0 != arg0) && (*(&gPlayerBalloonCount + (phi_s1 * 2)) >= 0)) { temp_f0 = func_802B51E8(phi_s0 + 0x14, arg1 + 0x18); if (temp_f0 < phi_f20) { phi_fp = (phi_s0 - D_800DC4DC) / 0xDD8;