From 73877245091fe36c5cc43a8cf08be058a713dd89 Mon Sep 17 00:00:00 2001 From: Tyler McGavran Date: Fri, 26 Nov 2021 19:22:39 -0500 Subject: [PATCH] Give names to some Grand Prix related variables (#67) * Give names to some Grand Prix related variables Namely variables related to points and standings Also added some observational comments to a function or two Signed-off-by: Taggerung * Add defines for character IDs Signed-off-by: Taggerung --- asm/bss_8001C4D0.s | 13 +- asm/bss_MainSeg.s | 2 + .../code_800431B0/func_80050320.s | 4 +- .../code_80057C60/func_80059C50.s | 4 +- .../code_80057C60/func_8005C980.s | 4 +- .../code_80091750/func_800A34A8.s | 4 +- .../code_80091750/func_800A3A10.s | 4 +- .../code_80091750/func_800A3ADC.s | 8 +- .../code_80091750/func_800AC458.s | 24 +- .../code_80091750/func_800AD2E8.s | 16 +- .../code_800AF9B0/func_800B3F74.s | 8 +- data/data_0DD0A0_3.s | 8 +- include/defines.h | 15 ++ include/variables.h | 2 +- src/code_800393C0.c | 8 +- src/code_800431B0.c | 29 +-- src/code_80057C60.c | 49 ++-- src/code_80091750.c | 234 +++++++++--------- src/code_800AF9B0.c | 50 +++- src/code_80281780.c | 4 +- src/code_80281780.h | 2 +- 21 files changed, 273 insertions(+), 219 deletions(-) diff --git a/asm/bss_8001C4D0.s b/asm/bss_8001C4D0.s index ae64ceab3..60046f627 100644 --- a/asm/bss_8001C4D0.s +++ b/asm/bss_8001C4D0.s @@ -1048,7 +1048,9 @@ glabel D_8018CF68 glabel D_8018CF78 .skip 8 -glabel D_8018CF80 +# List of half-word character IDs indicating each character's +# place in the current Grand Prix race's standings +glabel gGPCurrentRaceRanks .skip 16 glabel D_8018CF90 @@ -1741,10 +1743,15 @@ glabel D_8018D9BC glabel D_8018D9C0 .skip 8 -glabel D_8018D9C8 +# List of bytes indexed by character ID +# Indicates number of Grand Prix points that character +# has scored +glabel gGPCharacterPoints .skip 8 -glabel D_8018D9D0 +# List of character IDs indicating where each character +# is in the Grand Prix standings +glabel gGPOverallRanks .skip 1 glabel D_8018D9D1 diff --git a/asm/bss_MainSeg.s b/asm/bss_MainSeg.s index c33cae128..97bcb4f2b 100644 --- a/asm/bss_MainSeg.s +++ b/asm/bss_MainSeg.s @@ -170,6 +170,8 @@ glabel D_80164378 glabel D_80164386 .skip 10 +# List of s32's, seemingly indexed by player ID +# Indicates the number of completed laps for that player glabel lapCount .skip 2 diff --git a/asm/non_matchings/code_800431B0/func_80050320.s b/asm/non_matchings/code_800431B0/func_80050320.s index f9bf0653b..413b5f074 100644 --- a/asm/non_matchings/code_800431B0/func_80050320.s +++ b/asm/non_matchings/code_800431B0/func_80050320.s @@ -41,12 +41,12 @@ glabel func_80050320 /* 050FB8 800503B8 45020035 */ bc1fl .L80050490 /* 050FBC 800503BC 26100001 */ addiu $s0, $s0, 1 /* 050FC0 800503C0 C5240000 */ lwc1 $f4, ($t1) -/* 050FC4 800503C4 3C188019 */ lui $t8, %hi(D_8018CF80) # $t8, 0x8019 +/* 050FC4 800503C4 3C188019 */ lui $t8, %hi(gGPCurrentRaceRanks) # $t8, 0x8019 /* 050FC8 800503C8 3C198019 */ lui $t9, %hi(D_8018D028) # $t9, 0x8019 /* 050FCC 800503CC 460021A1 */ cvt.d.s $f6, $f4 /* 050FD0 800503D0 2739D028 */ addiu $t9, %lo(D_8018D028) # addiu $t9, $t9, -0x2fd8 /* 050FD4 800503D4 4634303C */ c.lt.d $f6, $f20 -/* 050FD8 800503D8 2718CF80 */ addiu $t8, %lo(D_8018CF80) # addiu $t8, $t8, -0x3080 +/* 050FD8 800503D8 2718CF80 */ addiu $t8, %lo(gGPCurrentRaceRanks) # addiu $t8, $t8, -0x3080 /* 050FDC 800503DC 00583821 */ addu $a3, $v0, $t8 /* 050FE0 800503E0 02394021 */ addu $t0, $s1, $t9 /* 050FE4 800503E4 45000002 */ bc1f .L800503F0 diff --git a/asm/non_matchings/code_80057C60/func_80059C50.s b/asm/non_matchings/code_80057C60/func_80059C50.s index 253981678..ef96d620a 100644 --- a/asm/non_matchings/code_80057C60/func_80059C50.s +++ b/asm/non_matchings/code_80057C60/func_80059C50.s @@ -4,12 +4,12 @@ glabel func_80059C50 /* 05A858 80059C58 0C0168F0 */ jal func_8005A3C0 /* 05A85C 80059C5C 00000000 */ nop /* 05A860 80059C60 3C048016 */ lui $a0, %hi(D_80164360) # $a0, 0x8016 -/* 05A864 80059C64 3C028019 */ lui $v0, %hi(D_8018CF80) # $v0, 0x8019 +/* 05A864 80059C64 3C028019 */ lui $v0, %hi(gGPCurrentRaceRanks) # $v0, 0x8019 /* 05A868 80059C68 3C07800E */ lui $a3, %hi(D_800DC4DC) # $a3, 0x800e /* 05A86C 80059C6C 3C068019 */ lui $a2, %hi(D_8018CF90) # $a2, 0x8019 /* 05A870 80059C70 24C6CF90 */ addiu $a2, %lo(D_8018CF90) # addiu $a2, $a2, -0x3070 /* 05A874 80059C74 8CE7C4DC */ lw $a3, %lo(D_800DC4DC)($a3) -/* 05A878 80059C78 2442CF80 */ addiu $v0, %lo(D_8018CF80) # addiu $v0, $v0, -0x3080 +/* 05A878 80059C78 2442CF80 */ addiu $v0, %lo(gGPCurrentRaceRanks) # addiu $v0, $v0, -0x3080 /* 05A87C 80059C7C 24844360 */ addiu $a0, %lo(D_80164360) # addiu $a0, $a0, 0x4360 /* 05A880 80059C80 24050DD8 */ li $a1, 3544 .L80059C84: diff --git a/asm/non_matchings/code_80057C60/func_8005C980.s b/asm/non_matchings/code_80057C60/func_8005C980.s index 80c0f1987..8d6abbf88 100644 --- a/asm/non_matchings/code_80057C60/func_8005C980.s +++ b/asm/non_matchings/code_80057C60/func_8005C980.s @@ -42,8 +42,8 @@ glabel func_8005C980 /* 05D614 8005CA14 3C048016 */ lui $a0, %hi(D_80164360) # $a0, 0x8016 /* 05D618 8005CA18 3C088019 */ lui $t0, %hi(D_8018CF50) # $t0, 0x8019 /* 05D61C 8005CA1C 3C0B8019 */ lui $t3, %hi(D_8018CF60) # $t3, 0x8019 -/* 05D620 8005CA20 3C098019 */ lui $t1, %hi(D_8018CF80) # $t1, 0x8019 -/* 05D624 8005CA24 2529CF80 */ addiu $t1, %lo(D_8018CF80) # addiu $t1, $t1, -0x3080 +/* 05D620 8005CA20 3C098019 */ lui $t1, %hi(gGPCurrentRaceRanks) # $t1, 0x8019 +/* 05D624 8005CA24 2529CF80 */ addiu $t1, %lo(gGPCurrentRaceRanks) # addiu $t1, $t1, -0x3080 /* 05D628 8005CA28 256BCF60 */ addiu $t3, %lo(D_8018CF60) # addiu $t3, $t3, -0x30a0 /* 05D62C 8005CA2C 2508CF50 */ addiu $t0, %lo(D_8018CF50) # addiu $t0, $t0, -0x30b0 /* 05D630 8005CA30 24844360 */ addiu $a0, %lo(D_80164360) # addiu $a0, $a0, 0x4360 diff --git a/asm/non_matchings/code_80091750/func_800A34A8.s b/asm/non_matchings/code_80091750/func_800A34A8.s index 8c89ffbad..e80a07364 100644 --- a/asm/non_matchings/code_80091750/func_800A34A8.s +++ b/asm/non_matchings/code_80091750/func_800A34A8.s @@ -56,9 +56,9 @@ glabel func_800A34A8 .L800A357C: /* 0A417C 800A357C 0C028E84 */ jal func_800A3A10 /* 0A4180 800A3580 27A40080 */ addiu $a0, $sp, 0x80 -/* 0A4184 800A3584 3C048019 */ lui $a0, %hi(D_8018D9D0) # $a0, 0x8019 +/* 0A4184 800A3584 3C048019 */ lui $a0, %hi(gGPOverallRanks) # $a0, 0x8019 /* 0A4188 800A3588 0C028E84 */ jal func_800A3A10 -/* 0A418C 800A358C 2484D9D0 */ addiu $a0, %lo(D_8018D9D0) # addiu $a0, $a0, -0x2630 +/* 0A418C 800A358C 2484D9D0 */ addiu $a0, %lo(gGPOverallRanks) # addiu $a0, $a0, -0x2630 .L800A3590: /* 0A4190 800A3590 0C024C36 */ jal set_text_color /* 0A4194 800A3594 24040004 */ li $a0, 4 diff --git a/asm/non_matchings/code_80091750/func_800A3A10.s b/asm/non_matchings/code_80091750/func_800A3A10.s index abf84923a..c8d9ca6e8 100644 --- a/asm/non_matchings/code_80091750/func_800A3A10.s +++ b/asm/non_matchings/code_80091750/func_800A3A10.s @@ -3,8 +3,8 @@ glabel func_800A3A10 /* 0A4614 800A3A14 AFB00004 */ sw $s0, 4($sp) /* 0A4618 800A3A18 3C108019 */ lui $s0, %hi(D_8018EDF3) # $s0, 0x8019 /* 0A461C 800A3A1C 3C0D8016 */ lui $t5, %hi(D_80164478) # $t5, 0x8016 -/* 0A4620 800A3A20 3C0B8019 */ lui $t3, %hi(D_8018D9C8) # $t3, 0x8019 -/* 0A4624 800A3A24 256BD9C8 */ addiu $t3, %lo(D_8018D9C8) # addiu $t3, $t3, -0x2638 +/* 0A4620 800A3A20 3C0B8019 */ lui $t3, %hi(gGPCharacterPoints) # $t3, 0x8019 +/* 0A4624 800A3A24 256BD9C8 */ addiu $t3, %lo(gGPCharacterPoints) # addiu $t3, $t3, -0x2638 /* 0A4628 800A3A28 25AD4478 */ addiu $t5, %lo(D_80164478) # addiu $t5, $t5, 0x4478 /* 0A462C 800A3A2C 2610EDF3 */ addiu $s0, %lo(D_8018EDF3) # addiu $s0, $s0, -0x120d /* 0A4630 800A3A30 00001025 */ move $v0, $zero diff --git a/asm/non_matchings/code_80091750/func_800A3ADC.s b/asm/non_matchings/code_80091750/func_800A3ADC.s index 980b52e69..87b78f9d1 100644 --- a/asm/non_matchings/code_80091750/func_800A3ADC.s +++ b/asm/non_matchings/code_80091750/func_800A3ADC.s @@ -21,8 +21,8 @@ glabel func_800A3ADC /* 0A4724 800A3B24 1B000010 */ blez $t8, .L800A3B68 /* 0A4728 800A3B28 03001825 */ move $v1, $t8 /* 0A472C 800A3B2C 8FB90054 */ lw $t9, 0x54($sp) -/* 0A4730 800A3B30 3C088019 */ lui $t0, %hi(D_8018D9C8) # $t0, 0x8019 -/* 0A4734 800A3B34 2508D9C8 */ addiu $t0, %lo(D_8018D9C8) # addiu $t0, $t0, -0x2638 +/* 0A4730 800A3B30 3C088019 */ lui $t0, %hi(gGPCharacterPoints) # $t0, 0x8019 +/* 0A4734 800A3B34 2508D9C8 */ addiu $t0, %lo(gGPCharacterPoints) # addiu $t0, $t0, -0x2638 /* 0A4738 800A3B38 03381021 */ addu $v0, $t9, $t8 .L800A3B3C: /* 0A473C 800A3B3C 80490000 */ lb $t1, ($v0) @@ -65,8 +65,8 @@ glabel func_800A3ADC /* 0A47C8 800A3BC8 0C024CC9 */ jal func_80093324 /* 0A47CC 800A3BCC 2484000A */ addiu $a0, $a0, 0xa /* 0A47D0 800A3BD0 8FA9004C */ lw $t1, 0x4c($sp) -/* 0A47D4 800A3BD4 3C088019 */ lui $t0, %hi(D_8018D9C8) # $t0, 0x8019 -/* 0A47D8 800A3BD8 2508D9C8 */ addiu $t0, %lo(D_8018D9C8) # addiu $t0, $t0, -0x2638 +/* 0A47D4 800A3BD4 3C088019 */ lui $t0, %hi(gGPCharacterPoints) # $t0, 0x8019 +/* 0A47D8 800A3BD8 2508D9C8 */ addiu $t0, %lo(gGPCharacterPoints) # addiu $t0, $t0, -0x2638 /* 0A47DC 800A3BDC 01095021 */ addu $t2, $t0, $t1 /* 0A47E0 800A3BE0 81440000 */ lb $a0, ($t2) /* 0A47E4 800A3BE4 0C029E25 */ jal func_800A7894 diff --git a/asm/non_matchings/code_80091750/func_800AC458.s b/asm/non_matchings/code_80091750/func_800AC458.s index cce8dd052..6493f8d3f 100644 --- a/asm/non_matchings/code_80091750/func_800AC458.s +++ b/asm/non_matchings/code_80091750/func_800AC458.s @@ -18,21 +18,21 @@ glabel L800AC488 /* 0AD094 800AC494 ACF80004 */ sw $t8, 4($a3) /* 0AD098 800AC498 3C028019 */ lui $v0, %hi(D_8018D9BC) # $v0, 0x8019 /* 0AD09C 800AC49C 2442D9BC */ addiu $v0, %lo(D_8018D9BC) # addiu $v0, $v0, -0x2644 -/* 0AD0A0 800AC4A0 3C19800F */ lui $t9, %hi(D_800F0B18) # $t9, 0x800f -/* 0AD0A4 800AC4A4 83390B18 */ lb $t9, %lo(D_800F0B18)($t9) +/* 0AD0A0 800AC4A0 3C19800F */ lui $t9, %hi(gGP1stPlaceReward) # $t9, 0x800f +/* 0AD0A4 800AC4A4 83390B18 */ lb $t9, %lo(gGP1stPlaceReward)($t9) /* 0AD0A8 800AC4A8 8C4A0000 */ lw $t2, ($v0) -/* 0AD0AC 800AC4AC 3C0B800F */ lui $t3, %hi(D_800F0B19) # $t3, 0x800f -/* 0AD0B0 800AC4B0 3C0D800F */ lui $t5, %hi(D_800F0B1A) # $t5, 0x800f +/* 0AD0AC 800AC4AC 3C0B800F */ lui $t3, %hi(gGP2ndPlaceReward) # $t3, 0x800f +/* 0AD0B0 800AC4B0 3C0D800F */ lui $t5, %hi(gGP3rdPlaceReward) # $t5, 0x800f /* 0AD0B4 800AC4B4 A1590000 */ sb $t9, ($t2) /* 0AD0B8 800AC4B8 8C4C0000 */ lw $t4, ($v0) -/* 0AD0BC 800AC4BC 816B0B19 */ lb $t3, %lo(D_800F0B19)($t3) -/* 0AD0C0 800AC4C0 3C0F800F */ lui $t7, %hi(D_800F0B1B) # $t7, 0x800f +/* 0AD0BC 800AC4BC 816B0B19 */ lb $t3, %lo(gGP2ndPlaceReward)($t3) +/* 0AD0C0 800AC4C0 3C0F800F */ lui $t7, %hi(gGP4thPlaceReward) # $t7, 0x800f /* 0AD0C4 800AC4C4 A18B0001 */ sb $t3, 1($t4) /* 0AD0C8 800AC4C8 8C4E0000 */ lw $t6, ($v0) -/* 0AD0CC 800AC4CC 81AD0B1A */ lb $t5, %lo(D_800F0B1A)($t5) +/* 0AD0CC 800AC4CC 81AD0B1A */ lb $t5, %lo(gGP3rdPlaceReward)($t5) /* 0AD0D0 800AC4D0 A1CD0002 */ sb $t5, 2($t6) /* 0AD0D4 800AC4D4 8C580000 */ lw $t8, ($v0) -/* 0AD0D8 800AC4D8 81EF0B1B */ lb $t7, %lo(D_800F0B1B)($t7) +/* 0AD0D8 800AC4D8 81EF0B1B */ lb $t7, %lo(gGP4thPlaceReward)($t7) /* 0AD0DC 800AC4DC A30F0003 */ sb $t7, 3($t8) /* 0AD0E0 800AC4E0 8CF9000C */ lw $t9, 0xc($a3) /* 0AD0E4 800AC4E4 10000120 */ b .L800AC968 @@ -126,8 +126,8 @@ glabel L800AC5D0 /* 0AD228 800AC628 2518FFFF */ addiu $t8, $t0, -1 /* 0AD22C 800AC62C A0D80000 */ sb $t8, ($a2) /* 0AD230 800AC630 854A4360 */ lh $t2, %lo(D_80164360)($t2) # 0x4360($t2) -/* 0AD234 800AC634 3C0D8019 */ lui $t5, %hi(D_8018D9C8) # $t5, 0x8019 -/* 0AD238 800AC638 25ADD9C8 */ addiu $t5, %lo(D_8018D9C8) # addiu $t5, $t5, -0x2638 +/* 0AD234 800AC634 3C0D8019 */ lui $t5, %hi(gGPCharacterPoints) # $t5, 0x8019 +/* 0AD238 800AC638 25ADD9C8 */ addiu $t5, %lo(gGPCharacterPoints) # addiu $t5, $t5, -0x2638 /* 0AD23C 800AC63C 000A58C0 */ sll $t3, $t2, 3 /* 0AD240 800AC640 016A5823 */ subu $t3, $t3, $t2 /* 0AD244 800AC644 000B5900 */ sll $t3, $t3, 4 @@ -259,12 +259,12 @@ glabel L800AC7CC /* 0AD410 800AC810 24010003 */ li $at, 3 /* 0AD414 800AC814 00002825 */ move $a1, $zero /* 0AD418 800AC818 15A10053 */ bne $t5, $at, .L800AC968 -/* 0AD41C 800AC81C 3C028019 */ lui $v0, %hi(D_8018D9D0) # $v0, 0x8019 +/* 0AD41C 800AC81C 3C028019 */ lui $v0, %hi(gGPOverallRanks) # $v0, 0x8019 /* 0AD420 800AC820 3C038019 */ lui $v1, %hi(D_8018EDF3) # $v1, 0x8019 /* 0AD424 800AC824 3C048016 */ lui $a0, %hi(D_80164478) # $a0, 0x8016 /* 0AD428 800AC828 24844478 */ addiu $a0, %lo(D_80164478) # addiu $a0, $a0, 0x4478 /* 0AD42C 800AC82C 8063EDF3 */ lb $v1, %lo(D_8018EDF3)($v1) -/* 0AD430 800AC830 2442D9D0 */ addiu $v0, %lo(D_8018D9D0) # addiu $v0, $v0, -0x2630 +/* 0AD430 800AC830 2442D9D0 */ addiu $v0, %lo(gGPOverallRanks) # addiu $v0, $v0, -0x2630 /* 0AD434 800AC834 24060008 */ li $a2, 8 .L800AC838: /* 0AD438 800AC838 804E0000 */ lb $t6, ($v0) diff --git a/asm/non_matchings/code_80091750/func_800AD2E8.s b/asm/non_matchings/code_80091750/func_800AD2E8.s index 3e7380bb6..b0bd03498 100644 --- a/asm/non_matchings/code_80091750/func_800AD2E8.s +++ b/asm/non_matchings/code_80091750/func_800AD2E8.s @@ -19,21 +19,21 @@ glabel L800AD31C /* 0ADF28 800AD328 AE180004 */ sw $t8, 4($s0) /* 0ADF2C 800AD32C 3C028019 */ lui $v0, %hi(D_8018D9BC) # $v0, 0x8019 /* 0ADF30 800AD330 2442D9BC */ addiu $v0, %lo(D_8018D9BC) # addiu $v0, $v0, -0x2644 -/* 0ADF34 800AD334 3C19800F */ lui $t9, %hi(D_800F0B18) # $t9, 0x800f -/* 0ADF38 800AD338 83390B18 */ lb $t9, %lo(D_800F0B18)($t9) +/* 0ADF34 800AD334 3C19800F */ lui $t9, %hi(gGP1stPlaceReward) # $t9, 0x800f +/* 0ADF38 800AD338 83390B18 */ lb $t9, %lo(gGP1stPlaceReward)($t9) /* 0ADF3C 800AD33C 8C480000 */ lw $t0, ($v0) -/* 0ADF40 800AD340 3C09800F */ lui $t1, %hi(D_800F0B19) # $t1, 0x800f -/* 0ADF44 800AD344 3C0B800F */ lui $t3, %hi(D_800F0B1A) # $t3, 0x800f +/* 0ADF40 800AD340 3C09800F */ lui $t1, %hi(gGP2ndPlaceReward) # $t1, 0x800f +/* 0ADF44 800AD344 3C0B800F */ lui $t3, %hi(gGP3rdPlaceReward) # $t3, 0x800f /* 0ADF48 800AD348 A1190000 */ sb $t9, ($t0) /* 0ADF4C 800AD34C 8C4A0000 */ lw $t2, ($v0) -/* 0ADF50 800AD350 81290B19 */ lb $t1, %lo(D_800F0B19)($t1) -/* 0ADF54 800AD354 3C0D800F */ lui $t5, %hi(D_800F0B1B) # $t5, 0x800f +/* 0ADF50 800AD350 81290B19 */ lb $t1, %lo(gGP2ndPlaceReward)($t1) +/* 0ADF54 800AD354 3C0D800F */ lui $t5, %hi(gGP4thPlaceReward) # $t5, 0x800f /* 0ADF58 800AD358 A1490001 */ sb $t1, 1($t2) /* 0ADF5C 800AD35C 8C4C0000 */ lw $t4, ($v0) -/* 0ADF60 800AD360 816B0B1A */ lb $t3, %lo(D_800F0B1A)($t3) +/* 0ADF60 800AD360 816B0B1A */ lb $t3, %lo(gGP3rdPlaceReward)($t3) /* 0ADF64 800AD364 A18B0002 */ sb $t3, 2($t4) /* 0ADF68 800AD368 8C4E0000 */ lw $t6, ($v0) -/* 0ADF6C 800AD36C 81AD0B1B */ lb $t5, %lo(D_800F0B1B)($t5) +/* 0ADF6C 800AD36C 81AD0B1B */ lb $t5, %lo(gGP4thPlaceReward)($t5) /* 0ADF70 800AD370 A1CD0003 */ sb $t5, 3($t6) /* 0ADF74 800AD374 8E0F000C */ lw $t7, 0xc($s0) /* 0ADF78 800AD378 100002EE */ b .L800ADF34 diff --git a/asm/non_matchings/code_800AF9B0/func_800B3F74.s b/asm/non_matchings/code_800AF9B0/func_800B3F74.s index f0e18bab0..3fb35a140 100644 --- a/asm/non_matchings/code_800AF9B0/func_800B3F74.s +++ b/asm/non_matchings/code_800AF9B0/func_800B3F74.s @@ -350,13 +350,13 @@ glabel L800B43B0 /* 0B5058 800B4458 3C018019 */ lui $at, %hi(D_8018EE0A) # $at, 0x8019 /* 0B505C 800B445C A020EE0A */ sb $zero, %lo(D_8018EE0A)($at) /* 0B5060 800B4460 15C00003 */ bnez $t6, .L800B4470 -/* 0B5064 800B4464 3C028019 */ lui $v0, %hi(D_8018D9C8) # $v0, 0x8019 +/* 0B5064 800B4464 3C028019 */ lui $v0, %hi(gGPCharacterPoints) # $v0, 0x8019 /* 0B5068 800B4468 3C018019 */ lui $at, %hi(gCourseSelection) # $at, 0x8019 /* 0B506C 800B446C A020EE0B */ sb $zero, %lo(gCourseSelection)($at) .L800B4470: -/* 0B5070 800B4470 3C038019 */ lui $v1, %hi(D_8018D9D0) # $v1, 0x8019 -/* 0B5074 800B4474 2463D9D0 */ addiu $v1, %lo(D_8018D9D0) # addiu $v1, $v1, -0x2630 -/* 0B5078 800B4478 2442D9C8 */ addiu $v0, %lo(D_8018D9C8) # addiu $v0, $v0, -0x2638 +/* 0B5070 800B4470 3C038019 */ lui $v1, %hi(gGPOverallRanks) # $v1, 0x8019 +/* 0B5074 800B4474 2463D9D0 */ addiu $v1, %lo(gGPOverallRanks) # addiu $v1, $v1, -0x2630 +/* 0B5078 800B4478 2442D9C8 */ addiu $v0, %lo(gGPCharacterPoints) # addiu $v0, $v0, -0x2638 .L800B447C: /* 0B507C 800B447C 24420004 */ addiu $v0, $v0, 4 /* 0B5080 800B4480 A040FFFD */ sb $zero, -3($v0) diff --git a/data/data_0DD0A0_3.s b/data/data_0DD0A0_3.s index 5199424ac..ab105c114 100644 --- a/data/data_0DD0A0_3.s +++ b/data/data_0DD0A0_3.s @@ -5380,13 +5380,13 @@ glabel D_800F0B10 .asciiz " th" .balign 4 -glabel D_800F0B18 +glabel gGP1stPlaceReward .byte 0x09 -glabel D_800F0B19 +glabel gGP2ndPlaceReward .byte 0x06 -glabel D_800F0B1A +glabel gGP3rdPlaceReward .byte 0x03 -glabel D_800F0B1B +glabel gGP4thPlaceReward .byte 0x01 glabel D_800F0B1C diff --git a/include/defines.h b/include/defines.h index 3a59bc635..93b7424d4 100644 --- a/include/defines.h +++ b/include/defines.h @@ -55,4 +55,19 @@ #define SPECIAL_CUP 3 #define BATTLE_CUP 4 +/** + * Character IDs + * Note that these are not the same as the values + * found in gCharacterSelections as those are more + * akin to indexes than IDs +**/ +#define MARIO 0 +#define LUIGI 1 +#define YOSHI 2 +#define TOAD 3 +#define DK 4 +#define WARIO 5 +#define PEACH 6 +#define BOWSER 7 + #endif // DEFINES_H diff --git a/include/variables.h b/include/variables.h index c9e81fa8d..8f53d6d01 100644 --- a/include/variables.h +++ b/include/variables.h @@ -33,7 +33,7 @@ extern s16 D_80165572; extern s16 D_80165580; extern s16 D_80165582; extern s8 D_800E86A8[4]; -extern s8 D_8018D9D0[4]; +extern s8 gGPOverallRanks[8]; extern s16 D_80165270[8]; extern Player* D_800DC4DC; extern Player* D_800DC4E0; diff --git a/src/code_800393C0.c b/src/code_800393C0.c index fb69f2ff2..d2809b7b5 100644 --- a/src/code_800393C0.c +++ b/src/code_800393C0.c @@ -689,13 +689,13 @@ extern f32 D_800EDE58; extern f32 D_800EDE5C; void func_8003BE30(void) { - spawn_player(D_800DC4DC, 0, -2770.774f, -345.187f, D_800EDE20, 0.0f, D_8018D9D0[0], PLAYER_EXISTS | PLAYER_CPU | PLAYER_START_SEQUENCE); - spawn_player(D_800DC4E0, 1, -3691.506f, -6.822f, D_800EDE24, D_800EDE28, D_8018D9D0[1], PLAYER_EXISTS | PLAYER_CPU | PLAYER_START_SEQUENCE); - spawn_player(D_800DC4E4, 2, -3475.028f, -998.485f, D_800EDE2C, D_800EDE30, D_8018D9D0[2], PLAYER_EXISTS | PLAYER_CPU | PLAYER_START_SEQUENCE); + spawn_player(D_800DC4DC, 0, -2770.774f, -345.187f, D_800EDE20, 0.0f, gGPOverallRanks[0], PLAYER_EXISTS | PLAYER_CPU | PLAYER_START_SEQUENCE); + spawn_player(D_800DC4E0, 1, -3691.506f, -6.822f, D_800EDE24, D_800EDE28, gGPOverallRanks[1], PLAYER_EXISTS | PLAYER_CPU | PLAYER_START_SEQUENCE); + spawn_player(D_800DC4E4, 2, -3475.028f, -998.485f, D_800EDE2C, D_800EDE30, gGPOverallRanks[2], PLAYER_EXISTS | PLAYER_CPU | PLAYER_START_SEQUENCE); if (D_802874D8.unk_1D >= 3) { spawn_player(D_800DC4E8, 3, -3025.772f, 110.039f, D_800EDE34, D_800EDE38, D_802874D8.unk_1E, PLAYER_EXISTS | PLAYER_CPU | PLAYER_START_SEQUENCE); } else { - spawn_player(D_800DC4E8, 3, -3025.772f, 110.039f, D_800EDE3C, D_800EDE40, D_8018D9D0[3], PLAYER_EXISTS | PLAYER_CPU | PLAYER_START_SEQUENCE); + spawn_player(D_800DC4E8, 3, -3025.772f, 110.039f, D_800EDE3C, D_800EDE40, gGPOverallRanks[3], PLAYER_EXISTS | PLAYER_CPU | PLAYER_START_SEQUENCE); } spawn_player(D_800DC4EC, 4, -2770.774f, -345.187f, D_800EDE44, 0.0f, 0, 0x7000); spawn_player(D_800DC4F0, 5, -3691.506f, -6.822f, D_800EDE48, D_800EDE4C, 0, 0x7000); diff --git a/src/code_800431B0.c b/src/code_800431B0.c index 88da8f657..ccdcb3e7b 100644 --- a/src/code_800431B0.c +++ b/src/code_800431B0.c @@ -5991,32 +5991,28 @@ GLOBAL_ASM("asm/non_matchings/code_800431B0/func_8004FDB4.s") #endif #ifdef MIPS_TO_C -//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307 -? func_8004FDB4(f32, f32, s32, s32, s16, s16, s32, s32, s32, s32, s32); // extern +//generated by mips_to_c commit bd0364fa19633bd6201f8007e2d0a7ed87825909 +? func_8004FDB4(f32, f32, s32, s32, s16, s16, s32, s32, s32, s32, s32); /* extern */ extern ? D_80164360; extern s8 D_801657E2; -extern ? D_8018CF80; extern ? D_8018D028; extern f32 D_8018D050; extern ? D_8018D078; extern s32 D_8018D3E0; -extern void *gDisplayListHead; -extern ? lapCount; void func_80050320(void) { + Gfx *temp_v1_3; f32 *temp_t0; f32 *temp_t0_2; f32 temp_f14; f32 temp_f14_2; s16 temp_s0; s16 temp_s0_2; - s16 temp_v0_2; + s16 temp_v0; s16 temp_v1; s16 temp_v1_2; s32 temp_a1; s32 temp_a1_2; - s32 temp_v0; - void *temp_v1_3; f32 *phi_s2; s32 phi_s1; s16 phi_s0; @@ -6032,15 +6028,14 @@ void func_80050320(void) { phi_s0 = 0; do { temp_f14 = *phi_s2; - temp_v0 = phi_s0 * 2; phi_a0 = 0; if (temp_f14 >= 0.0f) { temp_t0 = phi_s1 + &D_8018D028; if (*(&D_8018D078 + phi_s1) < 0.0) { phi_a0 = 1; } - temp_v1 = *(temp_v0 + &D_8018CF80); - temp_a1 = *(&lapCount + (*(temp_v0 + &D_80164360) * 4)); + temp_v1 = gGPCurrentRaceRanks[phi_s0]; + temp_a1 = lapCount[*((phi_s0 * 2) + &D_80164360)]; if (temp_v1 == D_800DC4DC->characterId) { func_8004FDB4(*temp_t0, temp_f14, phi_a0, temp_a1, phi_s0, temp_a1, temp_v1, 0xFF, 1, phi_a0, 0); } else { @@ -6064,10 +6059,10 @@ void func_80050320(void) { if (*(&D_8018D078 + phi_s1_2) <= 0.0) { phi_a0_2 = 1; } - temp_v0_2 = *((phi_s0_2 * 2) + &D_80164360); - temp_a1_2 = *(&lapCount + (temp_v0_2 * 4)); - temp_v1_2 = D_800DC4DC[temp_v0_2].characterId; - if (temp_v0_2 == 0) { + temp_v0 = *((phi_s0_2 * 2) + &D_80164360); + temp_a1_2 = lapCount[temp_v0]; + temp_v1_2 = D_800DC4DC[temp_v0].characterId; + if (temp_v0 == 0) { func_8004FDB4(*temp_t0_2, temp_f14_2, phi_a0_2, temp_a1_2, phi_s0_2, temp_a1_2, temp_v1_2, 0xFF, 1, phi_a0_2, 1); } else { func_8004FDB4(*temp_t0_2, temp_f14_2, phi_a0_2, temp_a1_2, phi_s0_2, temp_a1_2, temp_v1_2, 0xFF, 0, phi_a0_2, 1); @@ -6081,8 +6076,8 @@ void func_80050320(void) { } temp_v1_3 = gDisplayListHead; gDisplayListHead = temp_v1_3 + 8; - temp_v1_3->unk0 = 0xBB000000; - temp_v1_3->unk4 = 0x10001; + temp_v1_3->words.w0 = 0xBB000000; + temp_v1_3->words.w1 = 0x10001; } #else GLOBAL_ASM("asm/non_matchings/code_800431B0/func_80050320.s") diff --git a/src/code_80057C60.c b/src/code_80057C60.c index 4418f48b6..5b287bfc5 100644 --- a/src/code_80057C60.c +++ b/src/code_80057C60.c @@ -1349,33 +1349,33 @@ GLOBAL_ASM("asm/non_matchings/code_80057C60/func_80059AC8.s") #endif #ifdef MIPS_TO_C -//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307 -? func_8005A3C0(); // extern +//generated by mips_to_c commit bd0364fa19633bd6201f8007e2d0a7ed87825909 +? func_8005A3C0(); /* extern */ extern s16 D_80164360; +extern ? D_801643B8; extern ? D_801643D8; -extern ? D_8018CF80; extern ? D_8018CF90; extern ? D_8018CF98; void func_80059C50(void) { + ? *temp_v0_2; ? *temp_v1; - s32 *temp_v0_2; u32 temp_v0; s16 *phi_a0; - ? *phi_v0; - s32 *phi_v0_2; + s16 *phi_v0; + ? *phi_v0_2; ? *phi_v1; func_8005A3C0(); phi_a0 = &D_80164360; - phi_v0 = &D_8018CF80; + phi_v0 = gGPCurrentRaceRanks; do { temp_v0 = phi_v0 + 2; temp_v0->unk-2 = D_800DC4DC[*phi_a0].characterId; phi_a0 += 2; phi_v0 = temp_v0; } while (temp_v0 < &D_8018CF90); - phi_v0_2 = D_801643B8; + phi_v0_2 = &D_801643B8; phi_v1 = &D_8018CF98; do { temp_v0_2 = phi_v0_2 + 0x10; @@ -1678,11 +1678,10 @@ GLOBAL_ASM("asm/non_matchings/code_80057C60/func_8005A380.s") #endif #ifdef MIPS_TO_C -//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307 -? func_8006F824(?, s8, s32); // extern -extern void *D_800DC4C0; -extern void *D_800DC4C4; -extern void *D_800DC4C8; +//generated by mips_to_c commit bd0364fa19633bd6201f8007e2d0a7ed87825909 +? func_8006F824(?, s8, s32); /* extern */ +extern s32 D_800DC50C; +extern u16 D_800DC51C; extern s8 D_801657E4; extern s8 D_801657E6; extern s8 D_801657E8; @@ -1708,7 +1707,7 @@ void func_8005A3C0(s32 arg2) { if (temp_v0_2 != 3) { if (temp_v0_2 != 4) { phi_a2 = 3; - } else if (((D_800DC4BC->buttonPressed & 1) != 0) || ((D_800DC4C0->unk6 & 1) != 0) || ((D_800DC4C4->unk6 & 1) != 0) || (phi_a2 = 3, ((D_800DC4C8->unk6 & 1) != 0))) { + } else if (((D_800DC4BC->buttonPressed & 1) != 0) || ((D_800DC4C0->buttonPressed & 1) != 0) || ((D_800DC4C4->buttonPressed & 1) != 0) || (phi_a2 = 3, ((D_800DC4C8->buttonPressed & 1) != 0))) { D_801657E4 = (D_801657E4 + 1) & 1; D_801657F8 = (D_801657F8 + 1) & 1; D_80165800.unk0 = (D_80165800.unk0 + 1) & 1; @@ -1720,7 +1719,7 @@ void func_8005A3C0(s32 arg2) { phi_a2 = 3; } } - } else if (((D_800DC4BC->buttonPressed & 1) != 0) || ((D_800DC4C0->unk6 & 1) != 0) || (phi_a2 = 3, ((D_800DC4C4->unk6 & 1) != 0))) { + } else if (((D_800DC4BC->buttonPressed & 1) != 0) || ((D_800DC4C0->buttonPressed & 1) != 0) || (phi_a2 = 3, ((D_800DC4C4->buttonPressed & 1) != 0))) { if (gModeSelection != BATTLE) { D_801657F0 = (D_801657F0 + 1) & 1; } @@ -1735,7 +1734,7 @@ void func_8005A3C0(s32 arg2) { D_80165800.unk0 = (D_80165800.unk0 + 1) & 1; phi_a1 = 1; } - if ((D_800DC4C0->unk6 & 1) != 0) { + if ((D_800DC4C0->buttonPressed & 1) != 0) { D_80165800.unk1 = (D_80165800.unk1 + 1) & 1; phi_a1 = 1; } @@ -1752,7 +1751,7 @@ void func_8005A3C0(s32 arg2) { } } } else if ((D_800DC4BC->buttonPressed & 1) != 0) { - D_801657E4 = D_801657E4 + 1; + D_801657E4 += 1; if (D_801657E4 >= 3) { D_801657E4 = 0; } @@ -3051,15 +3050,14 @@ GLOBAL_ASM("asm/non_matchings/code_80057C60/func_8005C728.s") #endif #ifdef MIPS_TO_C -//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307 -extern ? D_800E55D0; +//generated by mips_to_c commit bd0364fa19633bd6201f8007e2d0a7ed87825909 extern ? D_80164360; +extern s32 D_801643B8; extern s32 D_80165590; extern s16 D_80165794; extern ? D_8018CF28; extern ? D_8018CF50; extern ? D_8018CF60; -extern ? D_8018CF80; extern ? D_8018CF98; extern s32 D_8018D314; extern s32 D_8018D3E4; @@ -3067,6 +3065,7 @@ extern s32 D_8018D3E8; extern s32 D_8018D3EC; extern s32 D_8018D3F4; extern s32 D_8018D3F8; +static ? D_800E55D0; /* unable to generate initializer; const */ void func_8005C980(void) { ? *temp_t0; @@ -3090,7 +3089,7 @@ void func_8005C980(void) { temp_a3 = D_800DC4DC; temp_a1 = D_80165590; - phi_a0 = D_801643B8; + phi_a0 = &D_801643B8; phi_v0 = 0; do { temp_v1 = *phi_a0; @@ -3112,23 +3111,23 @@ void func_8005C980(void) { temp_v0_2 = phi_a0_2->unk0; phi_t0->unk0 = temp_v0_2; if (temp_a1 == 0) { - *(&D_8018CF80 + phi_v1) = temp_a3[temp_v0_2].characterId; + *(gGPCurrentRaceRanks + phi_v1) = temp_a3[temp_v0_2].characterId; } temp_a2 = phi_a0_2->unk2; phi_t0->unk2 = temp_a2; if (temp_a1 == 0) { - (&D_8018CF80 + phi_v1)->unk2 = temp_a3[temp_a2].characterId; + (gGPCurrentRaceRanks + phi_v1)->unk2 = temp_a3[temp_a2].characterId; } temp_a2_2 = phi_a0_2->unk4; phi_t0->unk4 = temp_a2_2; if (temp_a1 == 0) { - (&D_8018CF80 + phi_v1)->unk4 = temp_a3[temp_a2_2].characterId; + (gGPCurrentRaceRanks + phi_v1)->unk4 = temp_a3[temp_a2_2].characterId; } temp_a2_3 = phi_a0_2->unk6; phi_t0->unk6 = temp_a2_3; phi_a0_2 += 8; if (temp_a1 == 0) { - (&D_8018CF80 + phi_v1)->unk6 = temp_a3[temp_a2_3].characterId; + (gGPCurrentRaceRanks + phi_v1)->unk6 = temp_a3[temp_a2_3].characterId; } temp_t0 = phi_t0 + 8; phi_t0 = temp_t0; diff --git a/src/code_80091750.c b/src/code_80091750.c index 23481a40d..8899067d5 100644 --- a/src/code_80091750.c +++ b/src/code_80091750.c @@ -10772,33 +10772,23 @@ GLOBAL_ASM("asm/non_matchings/code_80091750/func_800A32B4.s") #endif #ifdef MIPS_TO_C -//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307 -? draw_text(s32, s32, s32, ?, f32, f32); // extern -s32 func_80093034(s32); // extern -? func_80093324(s32, s32, ? *, ?, f32, f32); // extern -? func_800A3A10(s8 *); // extern -? func_800A3ADC(void *, s32, s32, s8, s32, s8 *); // extern -? func_800A7894(s32, ? *); // extern -? set_text_color(s32); // extern +//generated by mips_to_c commit bd0364fa19633bd6201f8007e2d0a7ed87825909 +? draw_text(s32, s32, s32, ?, f32, f32); /* extern */ +s32 func_80093034(s32); /* extern */ +? func_80093324(s32, s32, ? *, ?, f32, f32); /* extern */ +? func_800A3A10(s8 *); /* extern */ +? func_800A3ADC(void *, s32, s32, s8, s32, s8 *); /* extern */ +? func_800A7894(s32, ? *); /* extern */ +? set_text_color(s32); /* extern */ extern s32 D_800DC540; -extern ? D_800E7500; -extern ? D_800E76CC; -extern ? D_800E86AB; -extern ? D_800E86AD; -extern ? D_800F0C34; -extern ? D_800F0C44; -extern f32 D_800F1CAC; -extern f32 D_800F1CB0; -extern f32 D_800F1CB4; -extern f32 D_800F1CB8; -extern f32 D_800F1CBC; -extern f32 D_800F1CC0; extern ? D_80164360; extern ? D_80164370; extern ? D_80164478; -extern s8 gCupSelection; -extern s32 gGlobalTimer; -extern ? gPlayers; +extern s8 D_8018EDF3; +static ? D_800E7500; /* unable to generate initializer; const */ +static ? D_800E76CC; /* unable to generate initializer; const */ +static ? D_800E86AB; /* unable to generate initializer; const */ +static ? D_800E86AD; /* unable to generate initializer; const */ void func_800A34A8(void *arg0) { s8 sp80; @@ -10806,20 +10796,13 @@ void func_800A34A8(void *arg0) { ? sp78; s32 sp68; ? *temp_a0; - f32 temp_f0; - f32 temp_f0_2; - f32 temp_f0_3; - f32 temp_f0_4; - f32 temp_f0_5; - s32 temp_s0_4; + s32 temp_s0_2; s32 temp_s1; s32 temp_s1_2; s32 temp_v1; s32 temp_v1_2; s32 temp_v1_3; s8 *temp_s0; - s8 *temp_s0_2; - s8 *temp_s0_3; s8 temp_v0; ? *phi_a0; s8 *phi_s0; @@ -10841,26 +10824,23 @@ void func_800A34A8(void *arg0) { do { temp_a0 = phi_a0 + 8; temp_s0 = phi_s0 + 4; - temp_s0->unk-4 = (&gPlayers + (phi_a0->unk0 * 0xDD8))->unk254; - temp_s0->unk-3 = (&gPlayers + (phi_a0->unk2 * 0xDD8))->unk254; - temp_s0->unk-2 = (&gPlayers + (phi_a0->unk4 * 0xDD8))->unk254; - temp_s0->unk-1 = (&gPlayers + (temp_a0->unk-2 * 0xDD8))->unk254; + temp_s0->unk-4 = gPlayers[phi_a0->unk0].characterId; + temp_s0->unk-3 = gPlayers[phi_a0->unk2].characterId; + temp_s0->unk-2 = gPlayers[phi_a0->unk4].characterId; + temp_s0->unk-1 = gPlayers[temp_a0->unk-2].characterId; phi_a0 = temp_a0; phi_s0 = temp_s0; } while (temp_a0 != &D_80164370); } else { func_800A3A10(&sp80); - func_800A3A10(D_8018D9D0); + func_800A3A10(gGPOverallRanks); } set_text_color(4); - temp_f0 = D_800F1CAC; - func_80093324(arg0->unkC + 0x19, 0x19 - arg0->unk10, &D_800F0C34, 0, temp_f0, temp_f0); + func_80093324(arg0->unkC + 0x19, 0x19 - arg0->unk10, "driver's points", 0, 0.8f, 0.8f); set_text_color(5); - temp_f0_2 = D_800F1CB0; - func_80093324(arg0->unkC + 0x36, 0x28 - arg0->unk10, &D_800F0C44, 0, temp_f0_2, temp_f0_2); + func_80093324(arg0->unkC + 0x36, 0x28 - arg0->unk10, "round", 0, 0.7f, 0.7f); func_800A7894(gCourseSelection + 1, &sp78); - temp_f0_3 = D_800F1CB4; - func_80093324(arg0->unkC + 0x61, 0x28 - arg0->unk10, &sp79, 0, temp_f0_3, temp_f0_3); + func_80093324(arg0->unkC + 0x61, 0x28 - arg0->unk10, &sp79, 0, 0.7f, 0.7f); phi_s1 = 0; do { temp_v1_2 = arg0->unk4; @@ -10873,12 +10853,11 @@ void func_800A34A8(void *arg0) { } } if (phi_v0 == 0) { - temp_s0_2 = &(&sp80)[phi_s1]; if (temp_v1_2 < 9) { phi_v0_2 = *(&D_80164360 + (phi_s1 * 2)); phi_v1 = 0; } else { - phi_v0_2 = *(&D_80164478 + (*temp_s0_2 * 2)); + phi_v0_2 = *(&D_80164478 + ((&sp80)[phi_s1] * 2)); phi_v1 = 0xD; } if (phi_v0_2 < D_8018EDF3) { @@ -10888,7 +10867,7 @@ void func_800A34A8(void *arg0) { } sp68 = phi_v1; set_text_color(phi_a0_2); - func_800A3ADC(arg0, arg0->unkC + phi_v1 + 0x1C, ((phi_s1 * 0x10) - arg0->unk10) + 0x38, *temp_s0_2, phi_s1, &sp80); + func_800A3ADC(arg0, arg0->unkC + phi_v1 + 0x1C, ((phi_s1 * 0x10) - arg0->unk10) + 0x38, (&sp80)[phi_s1], phi_s1, &sp80); } temp_s1 = phi_s1 + 1; phi_s1 = temp_s1; @@ -10896,7 +10875,6 @@ void func_800A34A8(void *arg0) { phi_s1_2 = 4; do { temp_v1_3 = arg0->unk4; - temp_s0_3 = &(&sp80)[phi_s1_2]; if ((temp_v1_3 != 8) && (temp_v1_3 != 9)) { phi_v0_3 = 0; } else { @@ -10909,7 +10887,7 @@ void func_800A34A8(void *arg0) { if (temp_v1_3 < 9) { phi_v0_4 = *(&D_80164360 + (phi_s1_2 * 2)); } else { - phi_v0_4 = *(&D_80164478 + (*temp_s0_3 * 2)); + phi_v0_4 = *(&D_80164478 + ((&sp80)[phi_s1_2] * 2)); } if (phi_v0_4 < D_8018EDF3) { phi_a0_3 = gGlobalTimer % 3; @@ -10917,18 +10895,16 @@ void func_800A34A8(void *arg0) { phi_a0_3 = 3; } set_text_color(phi_a0_3); - func_800A3ADC(arg0, 0xBE - arg0->unkC, arg0->unk10 + (phi_s1_2 * 0x10) + 0x5A, *temp_s0_3, phi_s1_2, &sp80); + func_800A3ADC(arg0, 0xBE - arg0->unkC, arg0->unk10 + (phi_s1_2 * 0x10) + 0x5A, (&sp80)[phi_s1_2], phi_s1_2, &sp80); } temp_s1_2 = phi_s1_2 + 1; phi_s1_2 = temp_s1_2; } while (temp_s1_2 != 8); set_text_color(5); - temp_s0_4 = ((func_80093034(*(&D_800E7500 + (gCupSelection * 4))) + 8) * D_800F1CB8) / 2.0f; - temp_f0_4 = D_800F1CBC; - draw_text((-(((func_80093034(*(&D_800E76CC + (gCCSelection * 4))) + 8) * temp_f0_4) / 2.0f) - arg0->unkC) + 0xE6, arg0->unk10 + 0xE1, *(&D_800E7500 + (D_800DC540 * 4)), 0, temp_f0_4, temp_f0_4); + temp_s0_2 = ((func_80093034(*(&D_800E7500 + (gCupSelection * 4))) + 8) * 0.6f) / 2.0f; + draw_text((-(((func_80093034(*(&D_800E76CC + (gCCSelection * 4))) + 8) * 0.6f) / 2.0f) - arg0->unkC) + 0xE6, arg0->unk10 + 0xE1, *(&D_800E7500 + (D_800DC540 * 4)), 0, 0.6f, 0.6f); temp_v0 = D_8018EDF3; - temp_f0_5 = D_800F1CC0; - draw_text((temp_s0_4 - arg0->unkC) + 0xE6, arg0->unk10 + 0xE1, *(&D_800E76CC + (*(&D_800E86AD + ((temp_v0 * 3) + *(&D_800E86AB + temp_v0))) * 4)), 0, temp_f0_5, temp_f0_5); + draw_text((temp_s0_2 - arg0->unkC) + 0xE6, arg0->unk10 + 0xE1, *(&D_800E76CC + (*(&D_800E86AD + ((temp_v0 * 3) + *(&D_800E86AB + temp_v0))) * 4)), 0, 0.6f, 0.6f); } } #else @@ -10936,9 +10912,9 @@ GLOBAL_ASM("asm/non_matchings/code_80091750/func_800A34A8.s") #endif #ifdef MIPS_TO_C -//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307 +//generated by mips_to_c commit bd0364fa19633bd6201f8007e2d0a7ed87825909 extern ? D_80164478; -extern ? D_8018D9C8; +extern s8 D_8018EDF3; void func_800A3A10(s8 *arg0) { s16 temp_t0_2; @@ -10950,7 +10926,7 @@ void func_800A3A10(s8 *arg0) { s8 temp_v0; s8 phi_v0; s8 *phi_v1; - void *phi_a2; + s8 *phi_a2; s8 phi_a1; phi_v0 = 0; @@ -10959,13 +10935,13 @@ void func_800A3A10(s8 *arg0) { *phi_v1 = phi_v0; phi_a1 = phi_v0; if (phi_v0 > 0) { - phi_a2 = arg0 + phi_v0; + phi_a2 = &arg0[phi_v0]; loop_3: temp_a3 = phi_a2->unk-1; temp_t1 = phi_a2->unk0; temp_a1 = phi_a1 - 1; - temp_t2 = *(&D_8018D9C8 + temp_t1); - temp_t0 = *(&D_8018D9C8 + temp_a3); + temp_t2 = gGPCharacterPoints[temp_t1]; + temp_t0 = gGPCharacterPoints[temp_a3]; phi_a1 = temp_a1; if (temp_t0 < temp_t2) { phi_a2->unk0 = temp_a3; @@ -10994,21 +10970,18 @@ GLOBAL_ASM("asm/non_matchings/code_80091750/func_800A3A10.s") #endif #ifdef MIPS_TO_C -//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307 -? func_80093324(s32, s32, s8 *, ?, f32, f32); // extern -? func_800939C8(s32, s32, s8 *, ?, f32, f32); // extern -? func_800A7894(s8, s8 *); // extern -extern ? D_800E76A8; -extern f32 D_800F1CC4; +//generated by mips_to_c commit bd0364fa19633bd6201f8007e2d0a7ed87825909 +? func_80093324(s32, s32, s8 *, ?, f32, f32); /* extern */ +? func_800939C8(s32, s32, s8 *, ?, f32, f32); /* extern */ +? func_800A7894(s8, s8 *); /* extern */ extern s32 D_8018D9BC; -extern ? D_8018D9C8; +static ? D_800E76A8; /* unable to generate initializer; const */ void func_800A3ADC(void *arg0, s32 arg1, s32 arg2, s32 arg3, s32 arg4, s32 arg5) { s8 sp37; s8 sp36; s8 sp35; s8 sp34; - f32 temp_f20; s32 temp_v1; void *phi_v0; s32 phi_v1; @@ -11023,7 +10996,7 @@ void func_800A3ADC(void *arg0, s32 arg1, s32 arg2, s32 arg3, s32 arg4, s32 arg5) phi_v0 = arg5 + arg4; loop_4: phi_v1_2 = phi_v1; - if (*(&D_8018D9C8 + phi_v0->unk0) == *(&D_8018D9C8 + phi_v0->unk-1)) { + if (gGPCharacterPoints[phi_v0->unk0] == gGPCharacterPoints[phi_v0->unk-1]) { temp_v1 = phi_v1 - 1; phi_v0 += -1; phi_v1 = temp_v1; @@ -11035,17 +11008,16 @@ loop_4: } func_800A7894(phi_v1_2 + 1, &sp34); } - temp_f20 = D_800F1CC4; sp36 = 0x2E; sp37 = 0; - func_800939C8(arg1, arg2, &sp35, -4, temp_f20, temp_f20); - func_80093324(arg1 + 0xA, arg2, *(&D_800E76A8 + (arg3 * 4)), 0, temp_f20, temp_f20); - func_800A7894(*(&D_8018D9C8 + arg3), &sp34); - func_800939C8(arg1 + 0x47, arg2, &sp34, 0, temp_f20, temp_f20); + func_800939C8(arg1, arg2, &sp35, -4, 0.7f, 0.7f); + func_80093324(arg1 + 0xA, arg2, *(&D_800E76A8 + (arg3 * 4)), 0, 0.7f, 0.7f); + func_800A7894(gGPCharacterPoints[arg3], &sp34); + func_800939C8(arg1 + 0x47, arg2, &sp34, 0, 0.7f, 0.7f); if ((arg4 < 4) && (arg0->unk4 < 9)) { func_800A7894(*(D_8018D9BC + arg4), &sp34); sp34 = 0x2B; - func_80093324(arg1 + 0x5A, arg2, &sp34, 0, temp_f20, temp_f20); + func_80093324(arg1 + 0x5A, arg2, &sp34, 0, 0.7f, 0.7f); } } #else @@ -16392,19 +16364,31 @@ GLOBAL_ASM("asm/non_matchings/code_80091750/func_800AC324.s") #ifdef MIPS_TO_C //generated by mips_to_c commit bd0364fa19633bd6201f8007e2d0a7ed87825909 -void *func_800921B4(); /* extern */ -void *func_800B536C(s32, s32, s32, void *); /* extern */ -void **func_800CA330(?, s32); /* extern */ -void *play_sound2(?, s32, u8 *, void *); /* extern */ -extern void *D_800DC5EC; +s8 *func_800921B4(); /* extern */ +s8 *func_800B536C(s32, s32, s32, void *); /* extern */ +s8 *func_800CA330(?, s32); /* extern */ +s8 *play_sound2(?, s32, u8 *, void *); /* extern */ +extern s8 D_800DC5EC; +extern void *D_800DC5F0; +extern s16 D_8015F894; extern ? D_80164360; extern ? D_80164478; -extern void *D_8018D9BC; -extern ? D_8018D9C8; -extern void *D_8018D9D0; +extern s8 D_8018D9BC; +extern s8 D_8018D9D8; +extern s8 D_8018EDF3; +static s32 D_800DDB24 = 1; +static s8 gGP1stPlaceReward = 9; /* const */ +static s8 gGP2ndPlaceReward = 6; /* const */ +static s8 gGP3rdPlaceReward = 3; /* const */ +static s8 gGP4thPlaceReward = 1; /* const */ -void *func_800AC458(void *arg0) { - s32 sp1C; + +//Something related to the point allotment screens at the end of a grand prix race +// Its unclear what exactly arg0 is, although unk4 of that struct(?) appears to be +// a form of a "current state" tracker. Each time this function runs it +// advances which "state" its in +s8 *func_800AC458(void *arg0) { + s32 place; s32 sp18; s32 temp_a1; s32 temp_a1_2; @@ -16419,22 +16403,22 @@ void *func_800AC458(void *arg0) { s32 temp_t8; s32 temp_v0_3; s32 temp_v0_6; - s8 *temp_v1_2; + s8 *temp_v0; + s8 *temp_v0_4; + s8 *temp_v0_5; + u16 temp_t4; u32 temp_v0_2; u8 *temp_a2_2; u8 temp_t0; - void **temp_v0_4; void *temp_a3; - void *temp_v0; - void *temp_v0_5; void *temp_v1; - void *temp_v1_3; + void *temp_v1_2; s32 phi_a0; void *phi_a3; s32 phi_t1; - void **phi_v0; + s8 *phi_v0; s32 phi_a1; - void **phi_v0_2; + s8 *phi_v0_2; temp_v0_2 = arg0->unk4; temp_a3 = arg0; @@ -16444,10 +16428,11 @@ void *func_800AC458(void *arg0) { case 0: temp_a3->unkC = -0xA0; temp_a3->unk4 = 1; - D_8018D9BC->unk0 = D_800F0B18; - D_8018D9BC->unk1 = D_800F0B19; - D_8018D9BC->unk2 = D_800F0B1A; - D_8018D9BC->unk3 = D_800F0B1B; + // Copy point rewards from data to some temp memory + D_8018D9BC->unk0 = gGP1stPlaceReward; + D_8018D9BC->unk1 = gGP2ndPlaceReward; + D_8018D9BC->unk2 = gGP3rdPlaceReward; + D_8018D9BC->unk3 = gGP4thPlaceReward; temp_a3->unk20 = temp_a3->unkC; return &D_8018D9BC; case 1: @@ -16485,11 +16470,14 @@ void *func_800AC458(void *arg0) { } default: return phi_v0_2; + // Allocating point rewards for the players that finished the race + // in 1st, 2nd, 3rd and 4th place case 3: case 4: case 5: case 6: temp_t3 = temp_a3->unk1C + 1; + // Using the "state" variable to deduce which player we're allocating points for temp_a1_2 = temp_v0_2 - 3; temp_a3->unk1C = temp_t3; if (((temp_t3 % 3) == 0) || (D_8018D9D8 != 0)) { @@ -16497,11 +16485,11 @@ void *func_800AC458(void *arg0) { temp_t0 = *temp_a2_2; if (temp_t0 > 0) { *temp_a2_2 = temp_t0 - 1; - temp_v1_2 = *(&gPlayers->characterId + (*(&D_80164360 + (temp_a1_2 * 2)) * 0xDD8)) + &D_8018D9C8; + temp_t4 = *(&gPlayers->characterId + (*(&D_80164360 + (temp_a1_2 * 2)) * 0xDD8)); sp18 = 0; arg0 = temp_a3; - *temp_v1_2 += 1; - sp1C = temp_a1_2; + gGPCharacterPoints[temp_t4] += 1; + place = temp_a1_2; play_sound2(0x49008017, temp_a1_2, temp_a2_2, temp_a3); phi_a3 = arg0; if ((*(D_8018D9BC + temp_a1_2) == 0) && (arg0->unk20 == 0)) { @@ -16519,6 +16507,7 @@ void *func_800AC458(void *arg0) { temp_v0_3 = phi_a3->unk4; phi_a3->unk20 = 0; phi_a3->unk1C = 0; + // If not done alloting points if (temp_v0_3 < 6) { phi_a3->unk4 = temp_v0_3 + 1; return temp_v0_3; @@ -16556,8 +16545,8 @@ void *func_800AC458(void *arg0) { if (D_8018D9D8 != 0) { temp_a3->unk1C = temp_t7 - 5; } - if ((temp_a3->unk1C <= 0) && (temp_a3->unk4 = 0xA, temp_a3->unk1C = 0, phi_a1 = 0, phi_v0_2 = &D_8018D9D0, (gCourseSelection == 3))) { - phi_v0 = &D_8018D9D0; + if ((temp_a3->unk1C <= 0) && (temp_a3->unk4 = 0xA, temp_a3->unk1C = 0, phi_a1 = 0, phi_v0_2 = gGPOverallRanks, (gCourseSelection == COURSE_BANSHEE_BOARDWALK))) { + phi_v0 = gGPOverallRanks; loop_41: if (*(&D_80164478 + (*phi_v0 * 2)) < D_8018EDF3) { return func_800B536C(phi_a1, phi_a1, 8, temp_a3); @@ -16598,8 +16587,8 @@ loop_41: temp_a3->unk20 = temp_a1_4 + 0x10; temp_v0_5 = D_800DC5EC; temp_v0_5->unk32 = temp_v0_5->unk32 + 0x10; - temp_v1_3 = D_800DC5F0; - temp_v1_3->unk32 = temp_v1_3->unk32 - 0x10; + temp_v1_2 = D_800DC5F0; + temp_v1_2->unk32 = temp_v1_2->unk32 - 0x10; return temp_v0_5; } temp_a3->unk20 = 0; @@ -17082,14 +17071,29 @@ GLOBAL_ASM("asm/non_matchings/code_80091750/func_800AD1A4.s") #ifdef MIPS_TO_C //generated by mips_to_c commit bd0364fa19633bd6201f8007e2d0a7ed87825909 +s32 func_800B4520(); /* extern */ +s32 func_800B5F30(); /* extern */ +s32 func_800B6348(s32); /* extern */ ? func_800B6708(); /* extern */ s32 osPfsFindFile(? *, u16, s32, ? *, ? *, ? *); /* extern */ ? play_sound2(?, u16); /* extern */ +extern void *D_800DC5EC; +extern void *D_800DC5F0; +extern u16 D_80162DD4; +extern s32 D_80162DF8; +extern void *D_8018D9BC; +extern s8 D_8018D9D8; extern ? D_8018E868; +extern s32 D_8018EB78; +extern s32 D_8018EB7C; +extern s32 D_8018EB80; extern ? D_8018EB84; +extern s8 D_8018EDF5; +static u16 D_800E86F0; /* type too large by 2; unable to generate initializer; const */ +static s32 D_800E86F4 = 0x4E4B544A; /* const */ +static s8 D_800E86F8 = 0; /* const */ static ? D_800F2E64; /* unable to generate initializer; const */ static ? D_800F2E74; /* unable to generate initializer; const */ -u16 D_800E86F0; /* unable to generate initializer; const */ void func_800AD2E8(void *arg0) { s32 sp28; @@ -17103,6 +17107,8 @@ void func_800AD2E8(void *arg0) { s32 temp_v0_7; s32 temp_v0_8; s8 temp_t3; + struct Controller *temp_t6; + struct Controller *temp_v1_2; u16 temp_a1; u16 temp_a1_2; u32 temp_t2; @@ -17112,10 +17118,8 @@ void func_800AD2E8(void *arg0) { u32 temp_v0_4; u32 temp_v0_5; u32 temp_v0_6; - void *temp_t6; void *temp_v0_2; void *temp_v1; - void *temp_v1_2; s32 phi_a1; s32 phi_a0; u16 phi_a1_2; @@ -17129,10 +17133,10 @@ void func_800AD2E8(void *arg0) { case 0: /* switch 1 */ arg0->unkC = -0xA0; arg0->unk4 = 1; - D_8018D9BC->unk0 = D_800F0B18; - D_8018D9BC->unk1 = D_800F0B19; - D_8018D9BC->unk2 = D_800F0B1A; - D_8018D9BC->unk3 = D_800F0B1B; + D_8018D9BC->unk0 = gGP1stPlaceReward; + D_8018D9BC->unk1 = gGP2ndPlaceReward; + D_8018D9BC->unk2 = gGP3rdPlaceReward; + D_8018D9BC->unk3 = gGP4thPlaceReward; arg0->unk20 = arg0->unkC; return; case 1: /* switch 1 */ @@ -17169,8 +17173,8 @@ void func_800AD2E8(void *arg0) { case 10: /* switch 1 */ if (func_800B4520() == 0) { temp_v1_2 = D_800DC4BC; - temp_a1 = temp_v1_2->unk6; - temp_a0_2 = temp_a1 | temp_v1_2->unkC; + temp_a1 = temp_v1_2->buttonPressed; + temp_a0_2 = temp_a1 | temp_v1_2->stickPressed; phi_a0 = temp_a0_2; phi_a1_2 = temp_a1; if ((temp_a0_2 & 0x800) != 0) { @@ -17188,8 +17192,8 @@ void func_800AD2E8(void *arg0) { } arg0->unk8 = -1; temp_t6 = D_800DC4BC; - temp_a1_2 = temp_t6->unk6; - phi_a0 = temp_a1_2 | temp_t6->unkC; + temp_a1_2 = temp_t6->buttonPressed; + phi_a0 = temp_a1_2 | temp_t6->stickPressed; phi_a1_2 = temp_a1_2; } } @@ -17205,7 +17209,7 @@ void func_800AD2E8(void *arg0) { temp_v0_5 = arg0->unk4; if ((temp_v0_5 == 0xA) && (D_80162DD4 != 0)) { arg0->unk4 = temp_v0_5 - 2; - phi_a1_3 = D_800DC4BC->unk6; + phi_a1_3 = D_800DC4BC->buttonPressed; } else { play_sound2(0x49008000, phi_a1_2); temp_f0_2 = arg0->unk24; @@ -17213,7 +17217,7 @@ void func_800AD2E8(void *arg0) { arg0->unk24 = temp_f0_2 + 4.0; } arg0->unk8 = 1; - phi_a1_3 = D_800DC4BC->unk6; + phi_a1_3 = D_800DC4BC->buttonPressed; } } } diff --git a/src/code_800AF9B0.c b/src/code_800AF9B0.c index 899faeb7f..47184c64d 100644 --- a/src/code_800AF9B0.c +++ b/src/code_800AF9B0.c @@ -2530,17 +2530,49 @@ GLOBAL_ASM("asm/non_matchings/code_800AF9B0/func_800B3B58.s") ? func_800CA008(?, ?, s32); /* extern */ ? func_800CB2C4(); /* extern */ ? play_sound2(?, s8 *, s8 *, s8); /* extern */ -extern ? D_8018D9C8; -extern ? D_8018D9D0; +extern s32 D_800DC50C; +extern s32 D_800DC524; +extern s32 D_800DC530; +extern s32 D_800DC540; +extern s16 D_8015F890; +extern s16 D_8015F892; +extern s32 D_80162DC8; +extern s32 D_80162DCC; +extern s16 D_80162DD4; +extern s16 D_80162DD8; +extern s32 D_80162E00; +extern s16 D_8016556E; +extern s32 D_8018EDE0; +extern s8 D_8018EDE8; +extern s8 D_8018EDE9; +extern s8 D_8018EDEA; +extern s8 D_8018EDEB; +extern s8 D_8018EDEC; +extern s8 D_8018EDED; +extern s8 D_8018EDEE; +extern s8 D_8018EDEF; +extern s8 D_8018EDF1; +extern s8 D_8018EDF3; +extern s8 D_8018EDF7; +extern s8 D_8018EDFA; +extern s8 D_8018EDFB; +extern s8 D_8018EDFC; +extern s32 D_8018EE00; +extern s32 D_8018EE04; +extern s8 D_8018EE08; +extern s8 D_8018EE0A; +extern s16 gEnableDebugMode; +static s8 D_800E86A8 = 0; /* const */ static ? D_800F2BDF; /* unable to generate initializer; const */ +s32 gIsMirrorMode = 0; void func_800B3F74(u32 arg0) { - ? *temp_v0_5; s32 temp_v0; s32 temp_v0_3; s32 temp_v0_4; s8 *temp_a1; s8 *temp_a2; + s8 *temp_v0_5; s8 temp_a0; s8 temp_a3; s8 temp_a3_2; @@ -2551,7 +2583,7 @@ void func_800B3F74(u32 arg0) { s8 *phi_a2; s8 *phi_a1; s32 phi_a0; - ? *phi_v0_2; + s8 *phi_v0_2; D_8018EDEF = 1; D_8018EE00 = 0; @@ -2589,7 +2621,7 @@ void func_800B3F74(u32 arg0) { gIsMirrorMode = 0; gEnableDebugMode = 0; gCupSelection = MUSHROOM_CUP; - gCourseSelection = 0; + gCourseSelection = COURSE_MARIO_RACEWAY; D_8018EDF7 = 0; if (D_8018EDF3 <= 0) { D_8018EDF3 = 1; @@ -2721,7 +2753,7 @@ void func_800B3F74(u32 arg0) { case 3: case 13: if (gModeSelection == BATTLE) { - gCupSelection = 4; + gCupSelection = BATTLE_CUP; D_800DC540 = 4; D_8018EDEC = 4; } else { @@ -2740,9 +2772,9 @@ void func_800B3F74(u32 arg0) { play_sound2(0x49009013); D_8018EE0A = 0; if (gModeSelection == GRAND_PRIX) { - gCourseSelection = 0; + gCourseSelection = COURSE_MARIO_RACEWAY; } - phi_v0_2 = &D_8018D9C8; + phi_v0_2 = gGPCharacterPoints; do { temp_v0_5 = phi_v0_2 + 4; temp_v0_5->unk-3 = 0; @@ -2750,7 +2782,7 @@ void func_800B3F74(u32 arg0) { temp_v0_5->unk-1 = 0; temp_v0_5->unk-4 = 0; phi_v0_2 = temp_v0_5; - } while (temp_v0_5 != &D_8018D9D0); + } while (temp_v0_5 != gGPOverallRanks); break; } func_800B44AC(); diff --git a/src/code_80281780.c b/src/code_80281780.c index 17767063d..d6f82242f 100644 --- a/src/code_80281780.c +++ b/src/code_80281780.c @@ -37,7 +37,7 @@ void func_80281780(void) { } else { D_800E86A8[0] = 0; } - bcopy(&D_80284ED0, &D_8018D9D0, 8); + bcopy(&D_80284ED0, &gGPOverallRanks, 8); } } } @@ -45,7 +45,7 @@ void func_80281780(void) { s32 func_80281880(s32 arg0) { s32 i; for (i = 0; i < 8; i++) { - if (D_8018D9D0[i] == D_800E86A8[arg0]) break; + if (gGPOverallRanks[i] == D_800E86A8[arg0]) break; } return i; } diff --git a/src/code_80281780.h b/src/code_80281780.h index 728cee504..b51805157 100644 --- a/src/code_80281780.h +++ b/src/code_80281780.h @@ -67,7 +67,7 @@ extern s8 D_800E86A8[]; extern u16 gEnableDebugMode; extern void *D_80284ED0; -extern s8 D_8018D9D0[]; +extern s8 gGPOverallRanks[8]; extern s8 D_8018EDF3; extern s32 _data_821D10SegmentRomStart;