diff --git a/README.md b/README.md index d5c470b2..253ff516 100755 --- a/README.md +++ b/README.md @@ -113,15 +113,15 @@ s32 is_drumstick_unlocked(void) { } ``` -As of April 29th, 2022, this is our current score: +As of May 23rd, 2022, this is our current score: ``` ======================================================= ADVENTURE ONE (ASM -> C Decompilation) ------------------- 24.58% Complete ------------------- - # Decompiled functions: 1137 + # Decompiled functions: 1136 # GLOBAL_ASM remaining: 642 - # NON_MATCHING functions: 8 - # NON_EQUIVALENT WIP functions: 106 + # NON_MATCHING functions: 9 + # NON_EQUIVALENT WIP functions: 105 --------------------- Game Status --------------------- Balloons: 12/47, Keys: 1/4, Trophies: 1/5 T.T. Amulets: 1/4, Wizpig Amulets: 1/4 @@ -129,9 +129,9 @@ As of April 29th, 2022, this is our current score: We are racing Taj in the Car Challenge. (Lap 1/3) ======================================================= ADVENTURE TWO (Cleanup & Documentation) - ------------------- 3.43% Complete ------------------- - # Documented functions: 152 - # Undocumented remaining: 1627 + ------------------- 3.89% Complete ------------------- + # Documented functions: 169 + # Undocumented remaining: 1609 --------------------- Game Status --------------------- Balloons: 2/47, Keys: 0/4, Trophies: 0/5 T.T. Amulets: 0/4, Wizpig Amulets: 0/4 diff --git a/asm/non_matchings/game_ui/func_8009ECF0.s b/asm/non_matchings/game_ui/func_8009ECF0.s index 6829b672..671c38f7 100644 --- a/asm/non_matchings/game_ui/func_8009ECF0.s +++ b/asm/non_matchings/game_ui/func_8009ECF0.s @@ -15,7 +15,7 @@ glabel func_8009ECF0 /* 09F924 8009ED24 0C01BAA4 */ jal get_settings /* 09F928 8009ED28 A0226D37 */ sb $v0, %lo(D_80126D37)($at) /* 09F92C 8009ED2C 3C018012 */ lui $at, %hi(D_80127184) # $at, 0x8012 -/* 09F930 8009ED30 0C003877 */ jal func_8000E1DC +/* 09F930 8009ED30 0C003877 */ jal check_if_silver_coin_race /* 09F934 8009ED34 AC227184 */ sw $v0, %lo(D_80127184)($at) /* 09F938 8009ED38 3C018012 */ lui $at, %hi(D_80127188) # $at, 0x8012 /* 09F93C 8009ED3C A0227188 */ sb $v0, %lo(D_80127188)($at) diff --git a/asm/non_matchings/game_ui/func_800AB4A8.s b/asm/non_matchings/game_ui/func_800AB4A8.s index 616a921f..d2809cae 100644 --- a/asm/non_matchings/game_ui/func_800AB4A8.s +++ b/asm/non_matchings/game_ui/func_800AB4A8.s @@ -11,7 +11,7 @@ glabel func_800AB4A8 /* 0AC0CC 800AB4CC 00A0A025 */ move $s4, $a1 /* 0AC0D0 800AB4D0 AFB60030 */ sw $s6, 0x30($sp) /* 0AC0D4 800AB4D4 AFB5002C */ sw $s5, 0x2c($sp) -/* 0AC0D8 800AB4D8 0C02ACD7 */ jal func_800AB35C +/* 0AC0D8 800AB4D8 0C02ACD7 */ jal free_weather_memory /* 0AC0DC 800AB4DC AFB30024 */ sw $s3, 0x24($sp) /* 0AC0E0 800AB4E0 3C028012 */ lui $v0, %hi(D_80127BB8) # $v0, 0x8012 /* 0AC0E4 800AB4E4 24427BB8 */ addiu $v0, %lo(D_80127BB8) # addiu $v0, $v0, 0x7bb8 diff --git a/asm/non_matchings/game_ui/func_800AC5A4.s b/asm/non_matchings/game_ui/func_800AC5A4.s index 7672e89a..ca6cc55c 100644 --- a/asm/non_matchings/game_ui/func_800AC5A4.s +++ b/asm/non_matchings/game_ui/func_800AC5A4.s @@ -26,8 +26,8 @@ glabel func_800AC5A4 /* 0AD204 800AC604 AEB80000 */ sw $t8, ($s5) /* 0AD208 800AC608 0C01A76C */ jal func_80069DB0 /* 0AD20C 800AC60C AFA00034 */ sw $zero, 0x34($sp) -/* 0AD210 800AC610 3C108012 */ lui $s0, %hi(D_80127C0C) # $s0, 0x8012 -/* 0AD214 800AC614 26107C0C */ addiu $s0, %lo(D_80127C0C) # addiu $s0, $s0, 0x7c0c +/* 0AD210 800AC610 3C108012 */ lui $s0, %hi(gWeatherDisplayListHead) # $s0, 0x8012 +/* 0AD214 800AC614 26107C0C */ addiu $s0, %lo(gWeatherDisplayListHead) # addiu $s0, $s0, 0x7c0c /* 0AD218 800AC618 8E030000 */ lw $v1, ($s0) /* 0AD21C 800AC61C 3C0B8000 */ lui $t3, 0x8000 /* 0AD220 800AC620 246E0008 */ addiu $t6, $v1, 8 diff --git a/asm/non_matchings/game_ui/func_800ADCBC.s b/asm/non_matchings/game_ui/render_rain_overlay.s similarity index 97% rename from asm/non_matchings/game_ui/func_800ADCBC.s rename to asm/non_matchings/game_ui/render_rain_overlay.s index 3e4a2a16..762cd851 100644 --- a/asm/non_matchings/game_ui/func_800ADCBC.s +++ b/asm/non_matchings/game_ui/render_rain_overlay.s @@ -1,4 +1,4 @@ -glabel func_800ADCBC +glabel render_rain_overlay /* 0AE8BC 800ADCBC 27BDFF60 */ addiu $sp, $sp, -0xa0 /* 0AE8C0 800ADCC0 AFBF0044 */ sw $ra, 0x44($sp) /* 0AE8C4 800ADCC4 AFB30040 */ sw $s3, 0x40($sp) @@ -65,8 +65,8 @@ glabel func_800ADCBC /* 0AE9B8 800ADDB8 00117A03 */ sra $t7, $s1, 8 /* 0AE9BC 800ADDBC 01E08825 */ move $s1, $t7 /* 0AE9C0 800ADDC0 03120019 */ multu $t8, $s2 -/* 0AE9C4 800ADDC4 3C0F800E */ lui $t7, %hi(D_800E2C60) # $t7, 0x800e -/* 0AE9C8 800ADDC8 8DEF2C60 */ lw $t7, %lo(D_800E2C60)($t7) +/* 0AE9C4 800ADDC4 3C0F800E */ lui $t7, %hi(gLightningFrequency) # $t7, 0x800e +/* 0AE9C8 800ADDC8 8DEF2C60 */ lw $t7, %lo(gLightningFrequency)($t7) /* 0AE9CC 800ADDCC 00009012 */ mflo $s2 /* 0AE9D0 800ADDD0 0012CA03 */ sra $t9, $s2, 8 /* 0AE9D4 800ADDD4 03209025 */ move $s2, $t9 @@ -209,7 +209,7 @@ glabel func_800ADCBC /* 0AEBF8 800ADFF8 440F5000 */ mfc1 $t7, $f10 /* 0AEBFC 800ADFFC 4600C102 */ mul.s $f4, $f24, $f0 /* 0AEC00 800AE000 A44F0016 */ sh $t7, 0x16($v0) -/* 0AEC04 800AE004 3C0F8012 */ lui $t7, %hi(D_80127C0C) # $t7, 0x8012 +/* 0AEC04 800AE004 3C0F8012 */ lui $t7, %hi(gWeatherDisplayListHead) # $t7, 0x8012 /* 0AEC08 800AE008 4602D182 */ mul.s $f6, $f26, $f2 /* 0AEC0C 800AE00C 46062201 */ sub.s $f8, $f4, $f6 /* 0AEC10 800AE010 4458F800 */ cfc1 $t8, $31 @@ -239,7 +239,7 @@ glabel func_800ADCBC /* 0AEC70 800AE070 440E5000 */ mfc1 $t6, $f10 /* 0AEC74 800AE074 44D9F800 */ ctc1 $t9, $31 /* 0AEC78 800AE078 A44E0020 */ sh $t6, 0x20($v0) -/* 0AEC7C 800AE07C 8DEF7C0C */ lw $t7, %lo(D_80127C0C)($t7) +/* 0AEC7C 800AE07C 8DEF7C0C */ lw $t7, %lo(gWeatherDisplayListHead)($t7) /* 0AEC80 800AE080 8D820000 */ lw $v0, ($t4) /* 0AEC84 800AE084 AFAF0068 */ sw $t7, 0x68($sp) /* 0AEC88 800AE088 AC580000 */ sw $t8, ($v0) @@ -317,7 +317,7 @@ glabel func_800ADCBC /* 0AEDA8 800AE1A8 35AF0050 */ ori $t7, $t5, 0x50 /* 0AEDAC 800AE1AC ACAF0000 */ sw $t7, ($a1) /* 0AEDB0 800AE1B0 8D380000 */ lw $t8, ($t1) -/* 0AEDB4 800AE1B4 3C018012 */ lui $at, %hi(D_80127C0C) # $at, 0x8012 +/* 0AEDB4 800AE1B4 3C018012 */ lui $at, %hi(gWeatherDisplayListHead) # $at, 0x8012 /* 0AEDB8 800AE1B8 030A0019 */ multu $t8, $t2 /* 0AEDBC 800AE1BC 00007012 */ mflo $t6 /* 0AEDC0 800AE1C0 016EC821 */ addu $t9, $t3, $t6 @@ -344,7 +344,7 @@ glabel func_800ADCBC /* 0AEE14 800AE214 272D0004 */ addiu $t5, $t9, 4 /* 0AEE18 800AE218 31AF000F */ andi $t7, $t5, 0xf /* 0AEE1C 800AE21C AD2F0000 */ sw $t7, ($t1) -/* 0AEE20 800AE220 AC387C0C */ sw $t8, %lo(D_80127C0C)($at) +/* 0AEE20 800AE220 AC387C0C */ sw $t8, %lo(gWeatherDisplayListHead)($at) /* 0AEE24 800AE224 AD820000 */ sw $v0, ($t4) .L800AE228: /* 0AEE28 800AE228 8FBF0044 */ lw $ra, 0x44($sp) diff --git a/asm/non_matchings/game_ui/func_800AD658.s b/asm/non_matchings/game_ui/render_rain_splashes.s similarity index 94% rename from asm/non_matchings/game_ui/func_800AD658.s rename to asm/non_matchings/game_ui/render_rain_splashes.s index cce9b1a5..65223117 100644 --- a/asm/non_matchings/game_ui/func_800AD658.s +++ b/asm/non_matchings/game_ui/render_rain_splashes.s @@ -1,7 +1,7 @@ -glabel func_800AD658 +glabel render_rain_splashes /* 0AE258 800AD658 27BDFF80 */ addiu $sp, $sp, -0x80 -/* 0AE25C 800AD65C 3C0E800E */ lui $t6, %hi(D_800E2C8C) # $t6, 0x800e -/* 0AE260 800AD660 8DCE2C8C */ lw $t6, %lo(D_800E2C8C)($t6) +/* 0AE25C 800AD65C 3C0E800E */ lui $t6, %hi(gRainSplashGfx) # $t6, 0x800e +/* 0AE260 800AD660 8DCE2C8C */ lw $t6, %lo(gRainSplashGfx)($t6) /* 0AE264 800AD664 AFB20028 */ sw $s2, 0x28($sp) /* 0AE268 800AD668 AFBF002C */ sw $ra, 0x2c($sp) /* 0AE26C 800AD66C AFB10024 */ sw $s1, 0x24($sp) @@ -11,8 +11,8 @@ glabel func_800AD658 /* 0AE27C 800AD67C 24120001 */ li $s2, 1 /* 0AE280 800AD680 3C0F800E */ lui $t7, %hi(D_800E2C6C) # $t7, 0x800e /* 0AE284 800AD684 8DEF2C6C */ lw $t7, %lo(D_800E2C6C)($t7) -/* 0AE288 800AD688 3C19800E */ lui $t9, %hi(D_800E2C60) # $t9, 0x800e -/* 0AE28C 800AD68C 8F392C60 */ lw $t9, %lo(D_800E2C60)($t9) +/* 0AE288 800AD688 3C19800E */ lui $t9, %hi(gLightningFrequency) # $t9, 0x800e +/* 0AE28C 800AD68C 8F392C60 */ lw $t9, %lo(gLightningFrequency)($t9) /* 0AE290 800AD690 000FC083 */ sra $t8, $t7, 2 /* 0AE294 800AD694 03190019 */ multu $t8, $t9 /* 0AE298 800AD698 00002025 */ move $a0, $zero @@ -223,8 +223,8 @@ glabel func_800AD658 /* 0AE5A8 800AD9A8 AC800000 */ sw $zero, ($a0) .L800AD9AC: /* 0AE5AC 800AD9AC 3C10800E */ lui $s0, %hi(D_800E2B4C) # $s0, 0x800e -/* 0AE5B0 800AD9B0 3C118012 */ lui $s1, %hi(D_80127C0C) # $s1, 0x8012 -/* 0AE5B4 800AD9B4 26317C0C */ addiu $s1, %lo(D_80127C0C) # addiu $s1, $s1, 0x7c0c +/* 0AE5B0 800AD9B0 3C118012 */ lui $s1, %hi(gWeatherDisplayListHead) # $s1, 0x8012 +/* 0AE5B4 800AD9B4 26317C0C */ addiu $s1, %lo(gWeatherDisplayListHead) # addiu $s1, $s1, 0x7c0c /* 0AE5B8 800AD9B8 26102B4C */ addiu $s0, %lo(D_800E2B4C) # addiu $s0, $s0, 0x2b4c .L800AD9BC: /* 0AE5BC 800AD9BC 86080006 */ lh $t0, 6($s0) @@ -260,11 +260,11 @@ glabel func_800AD658 /* 0AE62C 800ADA2C AE390000 */ sw $t9, ($s1) /* 0AE630 800ADA30 AC480000 */ sw $t0, ($v0) /* 0AE634 800ADA34 860A001A */ lh $t2, 0x1a($s0) -/* 0AE638 800ADA38 3C0C800E */ lui $t4, %hi(D_800E2C8C) # $t4, 0x800e +/* 0AE638 800ADA38 3C0C800E */ lui $t4, %hi(gRainSplashGfx) # $t4, 0x800e /* 0AE63C 800ADA3C 314900FF */ andi $t1, $t2, 0xff /* 0AE640 800ADA40 01215825 */ or $t3, $t1, $at /* 0AE644 800ADA44 AC4B0004 */ sw $t3, 4($v0) -/* 0AE648 800ADA48 8D8C2C8C */ lw $t4, %lo(D_800E2C8C)($t4) +/* 0AE648 800ADA48 8D8C2C8C */ lw $t4, %lo(gRainSplashGfx)($t4) /* 0AE64C 800ADA4C 3C058012 */ lui $a1, %hi(D_80127C10) # $a1, 0x8012 /* 0AE650 800ADA50 3C068012 */ lui $a2, %hi(D_80127C14) # $a2, 0x8012 /* 0AE654 800ADA54 240D010E */ li $t5, 270 @@ -275,8 +275,8 @@ glabel func_800AD658 /* 0AE668 800ADA68 0C01A145 */ jal func_80068514 /* 0AE66C 800ADA6C AFAC0010 */ sw $t4, 0x10($sp) .L800ADA70: -/* 0AE670 800ADA70 3C0E800E */ lui $t6, %hi(D_800E2C2C) # $t6, 0x800e -/* 0AE674 800ADA74 25CE2C2C */ addiu $t6, %lo(D_800E2C2C) # addiu $t6, $t6, 0x2c2c +/* 0AE670 800ADA70 3C0E800E */ lui $t6, %hi(gRainGfx) # $t6, 0x800e +/* 0AE674 800ADA74 25CE2C2C */ addiu $t6, %lo(gRainGfx) # addiu $t6, $t6, 0x2c2c /* 0AE678 800ADA78 2610001C */ addiu $s0, $s0, 0x1c /* 0AE67C 800ADA7C 160EFFCF */ bne $s0, $t6, .L800AD9BC /* 0AE680 800ADA80 00000000 */ nop diff --git a/asm/non_matchings/menu/tt_menu_loop.s b/asm/non_matchings/menu/tt_menu_loop.s index 05da17ed..1ce9afb3 100644 --- a/asm/non_matchings/menu/tt_menu_loop.s +++ b/asm/non_matchings/menu/tt_menu_loop.s @@ -156,7 +156,7 @@ glabel L8009DC60 /* 09E964 8009DD64 00000000 */ nop /* 09E968 8009DD68 14400003 */ bnez $v0, .L8009DD78 /* 09E96C 8009DD6C 24040231 */ li $a0, 561 -/* 09E970 8009DD70 0C00DAF3 */ jal func_80036BCC +/* 09E970 8009DD70 0C00DAF3 */ jal play_tt_voice_clip /* 09E974 8009DD74 24050001 */ li $a1, 1 .L8009DD78: /* 09E978 8009DD78 0C00392F */ jal set_time_trial_enabled @@ -171,7 +171,7 @@ glabel L8009DC60 /* 09E998 8009DD98 24010001 */ li $at, 1 /* 09E99C 8009DD9C 14410003 */ bne $v0, $at, .L8009DDAC /* 09E9A0 8009DDA0 24040230 */ li $a0, 560 -/* 09E9A4 8009DDA4 0C00DAF3 */ jal func_80036BCC +/* 09E9A4 8009DDA4 0C00DAF3 */ jal play_tt_voice_clip /* 09E9A8 8009DDA8 24050001 */ li $a1, 1 .L8009DDAC: /* 09E9AC 8009DDAC 0C00392F */ jal set_time_trial_enabled @@ -214,7 +214,7 @@ glabel L8009DC60 /* 09EA34 8009DE34 0C000741 */ jal play_sound_global /* 09EA38 8009DE38 00002825 */ move $a1, $zero /* 09EA3C 8009DE3C 2404022E */ li $a0, 558 -/* 09EA40 8009DE40 0C00DAF3 */ jal func_80036BCC +/* 09EA40 8009DE40 0C00DAF3 */ jal play_tt_voice_clip /* 09EA44 8009DE44 24050001 */ li $a1, 1 /* 09EA48 8009DE48 3C04800E */ lui $a0, %hi(D_800E1E2C) # $a0, 0x800e /* 09EA4C 8009DE4C 0C02719D */ jal func_8009C674 @@ -328,7 +328,7 @@ glabel L8009DFB0 /* 09EBC8 8009DFC8 0C02712A */ jal func_8009C4A8 /* 09EBCC 8009DFCC 24841E2C */ addiu $a0, %lo(D_800E1E2C) # addiu $a0, $a0, 0x1e2c /* 09EBD0 8009DFD0 2404022F */ li $a0, 559 -/* 09EBD4 8009DFD4 0C00DAF3 */ jal func_80036BCC +/* 09EBD4 8009DFD4 0C00DAF3 */ jal play_tt_voice_clip /* 09EBD8 8009DFD8 24050001 */ li $a1, 1 /* 09EBDC 8009DFDC 3C038012 */ lui $v1, %hi(sCurrentMenuID) # $v1, 0x8012 /* 09EBE0 8009DFE0 806364E2 */ lb $v1, %lo(sCurrentMenuID)($v1) diff --git a/asm/non_matchings/objects/func_8000CC7C.s b/asm/non_matchings/objects/func_8000CC7C.s index e38304ab..1ce7a094 100644 --- a/asm/non_matchings/objects/func_8000CC7C.s +++ b/asm/non_matchings/objects/func_8000CC7C.s @@ -545,13 +545,13 @@ glabel func_8000CC7C /* 00DFF8 8000D3F8 2419FFFF */ li $t9, -1 /* 00DFFC 8000D3FC 15C00004 */ bnez $t6, .L8000D410 /* 00E000 8000D400 3C038012 */ lui $v1, %hi(gObjectCount) # $v1, 0x8012 -/* 00E004 8000D404 3C018012 */ lui $at, %hi(D_8011AE02) # $at, 0x8012 +/* 00E004 8000D404 3C018012 */ lui $at, %hi(gIsNonCarRacers) # $at, 0x8012 /* 00E008 8000D408 10000004 */ b .L8000D41C -/* 00E00C 8000D40C A020AE02 */ sb $zero, %lo(D_8011AE02)($at) +/* 00E00C 8000D40C A020AE02 */ sb $zero, %lo(gIsNonCarRacers)($at) .L8000D410: /* 00E010 8000D410 240F0001 */ li $t7, 1 -/* 00E014 8000D414 3C018012 */ lui $at, %hi(D_8011AE02) # $at, 0x8012 -/* 00E018 8000D418 A02FAE02 */ sb $t7, %lo(D_8011AE02)($at) +/* 00E014 8000D414 3C018012 */ lui $at, %hi(gIsNonCarRacers) # $at, 0x8012 +/* 00E018 8000D418 A02FAE02 */ sb $t7, %lo(gIsNonCarRacers)($at) .L8000D41C: /* 00E01C 8000D41C 8FB80078 */ lw $t8, 0x78($sp) /* 00E020 8000D420 8C63AEF0 */ lw $v1, %lo(gObjectCount)($v1) @@ -840,8 +840,8 @@ glabel func_8000CC7C /* 00E424 8000D824 24010008 */ li $at, 8 /* 00E428 8000D828 14410002 */ bne $v0, $at, .L8000D834 .L8000D82C: -/* 00E42C 8000D82C 3C018012 */ lui $at, %hi(D_8011AE02) # $at, 0x8012 -/* 00E430 8000D830 A02FAE02 */ sb $t7, %lo(D_8011AE02)($at) +/* 00E42C 8000D82C 3C018012 */ lui $at, %hi(gIsNonCarRacers) # $at, 0x8012 +/* 00E430 8000D830 A02FAE02 */ sb $t7, %lo(gIsNonCarRacers)($at) .L8000D834: /* 00E434 8000D834 A27E01CB */ sb $fp, 0x1cb($s3) /* 00E438 8000D838 826201CB */ lb $v0, 0x1cb($s3) diff --git a/asm/non_matchings/objects/func_80016500.s b/asm/non_matchings/objects/func_80016500.s index ca0cc542..4fb1bc7c 100644 --- a/asm/non_matchings/objects/func_80016500.s +++ b/asm/non_matchings/objects/func_80016500.s @@ -114,7 +114,7 @@ glabel func_80016500 /* 0172A4 800166A4 240501C2 */ li $a1, 450 /* 0172A8 800166A8 8FA40040 */ lw $a0, 0x40($sp) /* 0172AC 800166AC 24060008 */ li $a2, 8 -/* 0172B0 800166B0 0C015C2E */ jal func_800570B8 +/* 0172B0 800166B0 0C015C2E */ jal play_random_character_voice /* 0172B4 800166B4 24070001 */ li $a3, 1 .L800166B8: /* 0172B8 800166B8 C7A40030 */ lwc1 $f4, 0x30($sp) diff --git a/asm/non_matchings/racer/func_80042D20.s b/asm/non_matchings/racer/func_80042D20.s index 070d0950..20ef5499 100644 --- a/asm/non_matchings/racer/func_80042D20.s +++ b/asm/non_matchings/racer/func_80042D20.s @@ -178,7 +178,7 @@ glabel func_80042D20 /* 043B40 80042F40 AFAA0060 */ sw $t2, 0x60($sp) /* 043B44 80042F44 AFAB0024 */ sw $t3, 0x24($sp) /* 043B48 80042F48 A7AC0034 */ sh $t4, 0x34($sp) -/* 043B4C 80042F4C 0C015C2E */ jal func_800570B8 +/* 043B4C 80042F4C 0C015C2E */ jal play_random_character_voice /* 043B50 80042F50 A7AD0078 */ sh $t5, 0x78($sp) /* 043B54 80042F54 87A80076 */ lh $t0, 0x76($sp) /* 043B58 80042F58 8FAA0060 */ lw $t2, 0x60($sp) @@ -213,7 +213,7 @@ glabel func_80042D20 /* 043BC4 80042FC4 A7A80076 */ sh $t0, 0x76($sp) /* 043BC8 80042FC8 24050162 */ li $a1, 354 /* 043BCC 80042FCC 24060008 */ li $a2, 8 -/* 043BD0 80042FD0 0C015C2E */ jal func_800570B8 +/* 043BD0 80042FD0 0C015C2E */ jal play_random_character_voice /* 043BD4 80042FD4 24070002 */ li $a3, 2 /* 043BD8 80042FD8 87A80076 */ lh $t0, 0x76($sp) /* 043BDC 80042FDC 8FAA0060 */ lw $t2, 0x60($sp) @@ -249,7 +249,7 @@ glabel func_80042D20 /* 043C4C 8004304C A7AD0078 */ sh $t5, 0x78($sp) /* 043C50 80043050 A7AC0034 */ sh $t4, 0x34($sp) /* 043C54 80043054 A7A80076 */ sh $t0, 0x76($sp) -/* 043C58 80043058 0C015C2E */ jal func_800570B8 +/* 043C58 80043058 0C015C2E */ jal play_random_character_voice /* 043C5C 8004305C 24070002 */ li $a3, 2 /* 043C60 80043060 87AF0070 */ lh $t7, 0x70($sp) /* 043C64 80043064 87A80076 */ lh $t0, 0x76($sp) @@ -262,7 +262,7 @@ glabel func_80042D20 /* 043C80 80043080 24070003 */ li $a3, 3 /* 043C84 80043084 A7A80076 */ sh $t0, 0x76($sp) /* 043C88 80043088 A7AC0034 */ sh $t4, 0x34($sp) -/* 043C8C 8004308C 0C015C2E */ jal func_800570B8 +/* 043C8C 8004308C 0C015C2E */ jal play_random_character_voice /* 043C90 80043090 A7AD0078 */ sh $t5, 0x78($sp) /* 043C94 80043094 87A80076 */ lh $t0, 0x76($sp) /* 043C98 80043098 87AC0034 */ lh $t4, 0x34($sp) diff --git a/asm/non_matchings/racer/func_80046524.s b/asm/non_matchings/racer/func_80046524.s index 29a1566c..2d1cd6db 100644 --- a/asm/non_matchings/racer/func_80046524.s +++ b/asm/non_matchings/racer/func_80046524.s @@ -469,7 +469,7 @@ glabel func_80046524 /* 047728 80046B28 02202025 */ move $a0, $s1 /* 04772C 80046B2C 24050162 */ li $a1, 354 /* 047730 80046B30 24060008 */ li $a2, 8 -/* 047734 80046B34 0C015C2E */ jal func_800570B8 +/* 047734 80046B34 0C015C2E */ jal play_random_character_voice /* 047738 80046B38 24070082 */ li $a3, 130 .L80046B3C: /* 04773C 80046B3C 0C00322D */ jal normalise_time @@ -1280,7 +1280,7 @@ glabel func_80046524 /* 048304 80047704 02202025 */ move $a0, $s1 /* 048308 80047708 24050162 */ li $a1, 354 /* 04830C 8004770C 24060008 */ li $a2, 8 -/* 048310 80047710 0C015C2E */ jal func_800570B8 +/* 048310 80047710 0C015C2E */ jal play_random_character_voice /* 048314 80047714 24070082 */ li $a3, 130 /* 048318 80047718 86040000 */ lh $a0, ($s0) /* 04831C 8004771C 0C01C8D2 */ jal func_80072348 diff --git a/asm/non_matchings/racer/func_80048C7C.s b/asm/non_matchings/racer/func_80048C7C.s index f48c9f44..c8194bf8 100644 --- a/asm/non_matchings/racer/func_80048C7C.s +++ b/asm/non_matchings/racer/func_80048C7C.s @@ -48,7 +48,7 @@ glabel func_80048C7C /* 0498F8 80048CF8 24060008 */ li $a2, 8 /* 0498FC 80048CFC 24070081 */ li $a3, 129 /* 049900 80048D00 A3A30027 */ sb $v1, 0x27($sp) -/* 049904 80048D04 0C015C2E */ jal func_800570B8 +/* 049904 80048D04 0C015C2E */ jal play_random_character_voice /* 049908 80048D08 AFA40028 */ sw $a0, 0x28($sp) /* 04990C 80048D0C 82180187 */ lb $t8, 0x187($s0) /* 049910 80048D10 83A30027 */ lb $v1, 0x27($sp) diff --git a/asm/non_matchings/racer/func_80049794.s b/asm/non_matchings/racer/func_80049794.s index 4bf42ac9..70d2f945 100644 --- a/asm/non_matchings/racer/func_80049794.s +++ b/asm/non_matchings/racer/func_80049794.s @@ -891,7 +891,7 @@ glabel func_80049794 /* 04AFD0 8004A3D0 02202025 */ move $a0, $s1 /* 04AFD4 8004A3D4 24050162 */ li $a1, 354 /* 04AFD8 8004A3D8 24060008 */ li $a2, 8 -/* 04AFDC 8004A3DC 0C015C2E */ jal func_800570B8 +/* 04AFDC 8004A3DC 0C015C2E */ jal play_random_character_voice /* 04AFE0 8004A3E0 24070082 */ li $a3, 130 /* 04AFE4 8004A3E4 86040000 */ lh $a0, ($s0) /* 04AFE8 8004A3E8 0C01C8D2 */ jal func_80072348 @@ -1152,7 +1152,7 @@ glabel func_80049794 /* 04B398 8004A798 02202025 */ move $a0, $s1 /* 04B39C 8004A79C 24050162 */ li $a1, 354 /* 04B3A0 8004A7A0 24060008 */ li $a2, 8 -/* 04B3A4 8004A7A4 0C015C2E */ jal func_800570B8 +/* 04B3A4 8004A7A4 0C015C2E */ jal play_random_character_voice /* 04B3A8 8004A7A8 24070082 */ li $a3, 130 /* 04B3AC 8004A7AC C7AE00DC */ lwc1 $f14, 0xdc($sp) /* 04B3B0 8004A7B0 00000000 */ nop diff --git a/asm/non_matchings/racer/func_80050A28.s b/asm/non_matchings/racer/func_80050A28.s index cf06caa1..b28d9dab 100644 --- a/asm/non_matchings/racer/func_80050A28.s +++ b/asm/non_matchings/racer/func_80050A28.s @@ -1073,7 +1073,7 @@ glabel func_80050A28 /* 052508 80051908 8FA40078 */ lw $a0, 0x78($sp) /* 05250C 8005190C 24050162 */ li $a1, 354 /* 052510 80051910 24060008 */ li $a2, 8 -/* 052514 80051914 0C015C2E */ jal func_800570B8 +/* 052514 80051914 0C015C2E */ jal play_random_character_voice /* 052518 80051918 24070082 */ li $a3, 130 /* 05251C 8005191C 821801D8 */ lb $t8, 0x1d8($s0) /* 052520 80051920 8FA90064 */ lw $t1, 0x64($sp) diff --git a/asm/non_matchings/racer/func_80053E9C.s b/asm/non_matchings/racer/func_80053E9C.s index c01ee348..6e9e7419 100644 --- a/asm/non_matchings/racer/func_80053E9C.s +++ b/asm/non_matchings/racer/func_80053E9C.s @@ -90,7 +90,7 @@ glabel func_80053E9C /* 054BAC 80053FAC 10200054 */ beqz $at, .L80054100 /* 054BB0 80053FB0 24060008 */ li $a2, 8 /* 054BB4 80053FB4 24070081 */ li $a3, 129 -/* 054BB8 80053FB8 0C015C2E */ jal func_800570B8 +/* 054BB8 80053FB8 0C015C2E */ jal play_random_character_voice /* 054BBC 80053FBC AFA40028 */ sw $a0, 0x28($sp) /* 054BC0 80053FC0 820E0187 */ lb $t6, 0x187($s0) /* 054BC4 80053FC4 8FA40028 */ lw $a0, 0x28($sp) diff --git a/asm/non_matchings/racer/func_80054FD0.s b/asm/non_matchings/racer/func_80054FD0.s index b06860f8..f0e71514 100644 --- a/asm/non_matchings/racer/func_80054FD0.s +++ b/asm/non_matchings/racer/func_80054FD0.s @@ -343,7 +343,7 @@ glabel func_80054FD0 /* 0560DC 800554DC 240501C2 */ li $a1, 450 /* 0560E0 800554E0 24060008 */ li $a2, 8 /* 0560E4 800554E4 24070082 */ li $a3, 130 -/* 0560E8 800554E8 0C015C2E */ jal func_800570B8 +/* 0560E8 800554E8 0C015C2E */ jal play_random_character_voice /* 0560EC 800554EC AFA9018C */ sw $t1, 0x18c($sp) /* 0560F0 800554F0 02202025 */ move $a0, $s1 /* 0560F4 800554F4 0C015C12 */ jal racer_play_sound diff --git a/asm/non_matchings/racer/func_80055EC0.s b/asm/non_matchings/racer/func_80055EC0.s index 1b877618..d722f2f9 100644 --- a/asm/non_matchings/racer/func_80055EC0.s +++ b/asm/non_matchings/racer/func_80055EC0.s @@ -536,7 +536,7 @@ glabel L80056620 /* 05723C 8005663C AFA20074 */ sw $v0, 0x74($sp) /* 057240 80056640 AFA8007C */ sw $t0, 0x7c($sp) /* 057244 80056644 AFAA006C */ sw $t2, 0x6c($sp) -/* 057248 80056648 0C015C2E */ jal func_800570B8 +/* 057248 80056648 0C015C2E */ jal play_random_character_voice /* 05724C 8005664C E7A00058 */ swc1 $f0, 0x58($sp) /* 057250 80056650 C60A0038 */ lwc1 $f10, 0x38($s0) /* 057254 80056654 C7B20064 */ lwc1 $f18, 0x64($sp) diff --git a/asm/non_matchings/unknown_0255E0/func_80024D54.s b/asm/non_matchings/unknown_0255E0/func_80024D54.s index a53579c5..bcff2db6 100644 --- a/asm/non_matchings/unknown_0255E0/func_80024D54.s +++ b/asm/non_matchings/unknown_0255E0/func_80024D54.s @@ -330,7 +330,7 @@ glabel func_80024D54 /* 025E24 80025224 24E7B0AC */ addiu $a3, %lo(D_8011B0AC) # addiu $a3, $a3, -0x4f54 /* 025E28 80025228 24C6B0A8 */ addiu $a2, %lo(D_8011B0A8) # addiu $a2, $a2, -0x4f58 /* 025E2C 8002522C 02402825 */ move $a1, $s2 -/* 025E30 80025230 0C02AF9A */ jal func_800ABE68 +/* 025E30 80025230 0C02AF9A */ jal process_weather /* 025E34 80025234 AFAF0010 */ sw $t7, 0x10($sp) .L80025238: /* 025E38 80025238 0C01A748 */ jal func_80069D20 diff --git a/asm/non_matchings/unknown_032760/obj_loop_parkwarden.s b/asm/non_matchings/unknown_032760/obj_loop_parkwarden.s index de50fde3..cfef002f 100644 --- a/asm/non_matchings/unknown_032760/obj_loop_parkwarden.s +++ b/asm/non_matchings/unknown_032760/obj_loop_parkwarden.s @@ -517,7 +517,7 @@ glabel L80039978 /* 03A648 80039A48 AE070078 */ sw $a3, 0x78($s0) /* 03A64C 80039A4C E62A0004 */ swc1 $f10, 4($s1) /* 03A650 80039A50 9484D4E2 */ lhu $a0, %lo(D_8011D4E2)($a0) -/* 03A654 80039A54 0C00EB0F */ jal func_8003AC3C +/* 03A654 80039A54 0C00EB0F */ jal play_taj_voice_clip /* 03A658 80039A58 24050001 */ li $a1, 1 /* 03A65C 80039A5C 2418010F */ li $t8, 271 /* 03A660 80039A60 3C018012 */ lui $at, %hi(D_8011D4E2) # $at, 0x8012 @@ -645,7 +645,7 @@ glabel L80039BB8 /* 03A81C 80039C1C E62A0004 */ swc1 $f10, 4($s1) /* 03A820 80039C20 A20F003B */ sb $t7, 0x3b($s0) /* 03A824 80039C24 A620001C */ sh $zero, 0x1c($s1) -/* 03A828 80039C28 0C00EB0F */ jal func_8003AC3C +/* 03A828 80039C28 0C00EB0F */ jal play_taj_voice_clip /* 03A82C 80039C2C 24050001 */ li $a1, 1 /* 03A830 80039C30 86380020 */ lh $t8, 0x20($s1) /* 03A834 80039C34 92250011 */ lbu $a1, 0x11($s1) @@ -699,7 +699,7 @@ glabel L80039BB8 /* 03A8F0 80039CF0 00000000 */ nop /* 03A8F4 80039CF4 24840235 */ addiu $a0, $a0, 0x235 /* 03A8F8 80039CF8 3089FFFF */ andi $t1, $a0, 0xffff -/* 03A8FC 80039CFC 0C00EB0F */ jal func_8003AC3C +/* 03A8FC 80039CFC 0C00EB0F */ jal play_taj_voice_clip /* 03A900 80039D00 01202025 */ move $a0, $t1 /* 03A904 80039D04 8FA6007C */ lw $a2, 0x7c($sp) /* 03A908 80039D08 10000005 */ b .L80039D20 @@ -734,7 +734,7 @@ glabel L80039BB8 /* 03A974 80039D74 00000000 */ nop /* 03A978 80039D78 24840235 */ addiu $a0, %lo(gGameSelectTextElemsNoAdv2+157) # addiu $a0, $a0, 0x235 /* 03A97C 80039D7C 3099FFFF */ andi $t9, $a0, 0xffff -/* 03A980 80039D80 0C00EB0F */ jal func_8003AC3C +/* 03A980 80039D80 0C00EB0F */ jal play_taj_voice_clip /* 03A984 80039D84 03202025 */ move $a0, $t9 /* 03A988 80039D88 1000035E */ b .L8003AB04 /* 03A98C 80039D8C C7B00098 */ lwc1 $f16, 0x98($sp) @@ -745,7 +745,7 @@ glabel L80039BB8 /* 03A99C 80039D9C 0C030076 */ jal func_800C01D8 /* 03A9A0 80039DA0 2484C978 */ addiu $a0, $a0, -0x3688 /* 03A9A4 80039DA4 24040110 */ li $a0, 272 -/* 03A9A8 80039DA8 0C00EB0F */ jal func_8003AC3C +/* 03A9A8 80039DA8 0C00EB0F */ jal play_taj_voice_clip /* 03A9AC 80039DAC 24050001 */ li $a1, 1 /* 03A9B0 80039DB0 44803000 */ mtc1 $zero, $f6 /* 03A9B4 80039DB4 00000000 */ nop diff --git a/asm/non_matchings/unknown_032760/obj_loop_stopwatchman.s b/asm/non_matchings/unknown_032760/obj_loop_stopwatchman.s index 68d63f73..587d6fb6 100644 --- a/asm/non_matchings/unknown_032760/obj_loop_stopwatchman.s +++ b/asm/non_matchings/unknown_032760/obj_loop_stopwatchman.s @@ -431,7 +431,7 @@ glabel obj_loop_stopwatchman /* 037400 80036800 24090003 */ li $t1, 3 /* 037404 80036804 AE090078 */ sw $t1, 0x78($s0) /* 037408 80036808 24040141 */ li $a0, 321 -/* 03740C 8003680C 0C00DAF3 */ jal func_80036BCC +/* 03740C 8003680C 0C00DAF3 */ jal play_tt_voice_clip /* 037410 80036810 24050001 */ li $a1, 1 /* 037414 80036814 C7A2007C */ lwc1 $f2, 0x7c($sp) /* 037418 80036818 00000000 */ nop @@ -484,12 +484,12 @@ glabel obj_loop_stopwatchman /* 0374CC 800368CC 10400006 */ beqz $v0, .L800368E8 /* 0374D0 800368D0 24040143 */ li $a0, 323 /* 0374D4 800368D4 24040142 */ li $a0, 322 -/* 0374D8 800368D8 0C00DAF3 */ jal func_80036BCC +/* 0374D8 800368D8 0C00DAF3 */ jal play_tt_voice_clip /* 0374DC 800368DC 24050001 */ li $a1, 1 /* 0374E0 800368E0 10000004 */ b .L800368F4 /* 0374E4 800368E4 862C0020 */ lh $t4, 0x20($s1) .L800368E8: -/* 0374E8 800368E8 0C00DAF3 */ jal func_80036BCC +/* 0374E8 800368E8 0C00DAF3 */ jal play_tt_voice_clip /* 0374EC 800368EC 24050001 */ li $a1, 1 /* 0374F0 800368F0 862C0020 */ lh $t4, 0x20($s1) .L800368F4: diff --git a/include/enums.h b/include/enums.h index e40cf813..9ce6b963 100644 --- a/include/enums.h +++ b/include/enums.h @@ -49,7 +49,7 @@ typedef enum RaceType { RACETYPE_CUTSCENE_1 = 6, // Not sure what the difference between these two are. RACETYPE_CUTSCENE_2 = 7, RACETYPE_BOSS = 8, - RACETYPE_CHALLENGE = 64, // For masking + RACETYPE_CHALLENGE = 64, // For masking RACETYPE_CHALLENGE_BATTLE = 64, RACETYPE_CHALLENGE_BANANAS = 65, RACETYPE_CHALLENGE_EGGS = 66 @@ -68,9 +68,9 @@ typedef enum VerticalAlignmentFlags { } VerticalAlignmentFlags; typedef enum AlignmentFlags { - ALIGN_TOP_LEFT = VERT_ALIGN_TOP | HORZ_ALIGN_LEFT, - ALIGN_TOP_CENTER = VERT_ALIGN_TOP | HORZ_ALIGN_CENTER, - ALIGN_TOP_RIGHT = VERT_ALIGN_TOP | HORZ_ALIGN_RIGHT, + ALIGN_TOP_LEFT = VERT_ALIGN_TOP | HORZ_ALIGN_LEFT, + ALIGN_TOP_CENTER = VERT_ALIGN_TOP | HORZ_ALIGN_CENTER, + ALIGN_TOP_RIGHT = VERT_ALIGN_TOP | HORZ_ALIGN_RIGHT, ALIGN_MIDDLE_LEFT = VERT_ALIGN_MIDDLE | HORZ_ALIGN_LEFT, ALIGN_MIDDLE_CENTER = VERT_ALIGN_MIDDLE | HORZ_ALIGN_CENTER, ALIGN_MIDDLE_RIGHT = VERT_ALIGN_MIDDLE | HORZ_ALIGN_RIGHT, diff --git a/include/sound_ids.h b/include/sound_ids.h index 6f23a0c5..446f0e17 100644 --- a/include/sound_ids.h +++ b/include/sound_ids.h @@ -588,7 +588,7 @@ enum SoundID { SOUND_WHOOSH5, SOUND_COLLECT_BALLOON, SOUND_RAIN, - SOUND_UNK575, // Might be thunder + SOUND_THUNDER, SOUND_ZAP4, SOUND_MENU_BACK3, SOUND_VOICE_BUBBLER_OW, diff --git a/include/structs.h b/include/structs.h index f44f4f57..bcf3a90c 100644 --- a/include/structs.h +++ b/include/structs.h @@ -255,13 +255,13 @@ typedef struct LevelHeader { /* 0x74 */ s8 *unk74[7]; // Weather related? - /* 0x90 */ s16 weather_enable; - /* 0x92 */ s16 unk92; - /* 0x94 */ u8 unk94; - /* 0x95 */ u8 unk95; - /* 0x96 */ s16 unk96; - /* 0x98 */ s16 unk98; - /* 0x9A */ s16 unk9A; + /* 0x90 */ s16 weatherEnable; + /* 0x92 */ s16 weatherType; + /* 0x94 */ u8 weatherIntensity; + /* 0x95 */ u8 weatherOpacity; + /* 0x96 */ s16 weatherVelX; + /* 0x98 */ s16 weatherVelY; + /* 0x9A */ s16 weatherVelZ; /* 0x9C */ s8 cameraFOV; // Must be a value within [0, 90] /* 0x9D */ u8 bgColorRed; @@ -691,7 +691,7 @@ typedef struct Object_CharacterFlag { typedef struct Object_Snowball { /* 0x00 */ u8 pad0[0x20]; - /* 0x20 */ u32 unk20; + /* 0x20 */ u32 soundMask; /* 0x24 */ s16 unk24; /* 0x28 */ u8 pad28[0x12]; /* 0x38 */ s8 unk38; @@ -815,8 +815,8 @@ typedef struct Object_Racer { /* 0x018 */ f32 unk18; /* 0x01C */ s32 unk1C; /* 0x020 */ s32 unk20; - /* 0x024 */ s32 unk24; - /* 0x028 */ u16 unk28; + /* 0x024 */ s32 soundMask; + /* 0x028 */ u16 lastSoundID; /* 0x02A */ u16 unk2A; /* 0x02C */ f32 velocity; /* 0x030 */ f32 lateral_velocity; diff --git a/src/audio.c b/src/audio.c index 4c73fbb0..0d02c3dc 100644 --- a/src/audio.c +++ b/src/audio.c @@ -89,7 +89,7 @@ u8 D_80115F78; u8 D_80115F79; s32 D_80115F7C; s32 D_80115F80; -u32 D_80115F84; +u32 gGlobalSoundMask; u32 D_80115F88; /******************************/ @@ -674,18 +674,22 @@ u16 func_80001CB8(u16 arg0) { return sSoundEffectsPool[arg0].unk6; } -//Play Sound effect? GLOBAL_ASM("asm/non_matchings/audio/play_sound_global.s") -void play_sound_spatial(u16 soundID, f32 x, f32 y, f32 z, s32 **arg4) { - if (arg4 == NULL) { - arg4 = &D_80115F84; +/** + * Creates a spatial audio reference, then plays a sound. + * This then makes the audio pan around in 3D space. + * If it is not given a mask, then it will use the global mask. + */ +void play_sound_spatial(u16 soundID, f32 x, f32 y, f32 z, s32 **soundMask) { + if (soundMask == NULL) { + soundMask = &gGlobalSoundMask; } - play_sound_global(soundID, arg4); + play_sound_global(soundID, soundMask); - if (*arg4 != NULL) { - func_80009B7C(*arg4, x, y, z); + if (*soundMask != NULL) { + func_80009B7C(*soundMask, x, y, z); } } diff --git a/src/audio.h b/src/audio.h index 80926b4b..9911711d 100644 --- a/src/audio.h +++ b/src/audio.h @@ -129,7 +129,7 @@ void func_80002570(ALSeqPlayer *seqp); void func_80002608(u8 arg0); u8 func_80002630(void); -void play_sound_global(u16 soundID, s32*); //Non matching. +void play_sound_global(u16 soundID, s32* soundMask); //Non matching. void func_8000232C(ALSeqPlayer *seqp, void *ptr, u8 *arg2, ALCSeq *seq); //Non Matching f32 func_800015F8(void); //Non Matching void func_80001FB8(u16 arg0); //Non Matching diff --git a/src/fade_transition.c b/src/fade_transition.c index 2d422846..3cd75bcf 100644 --- a/src/fade_transition.c +++ b/src/fade_transition.c @@ -221,10 +221,10 @@ void func_800C0180(void) { //@bug: This doesn't seem to guarantee a return. u32 func_800C018C(void) { - u32 phi_v0 = (sTransitionFadeTimer != 0); - if (phi_v0 == 0) { - phi_v0 = (sTransitionFlags != 0); - if (phi_v0 != 0) { + u32 isActive = (sTransitionFadeTimer != 0); + if (isActive == 0) { + isActive = (sTransitionFlags != 0); + if (isActive != 0) { return (D_800E31BC != 0); } } diff --git a/src/game.c b/src/game.c index f3f49016..67930b8e 100644 --- a/src/game.c +++ b/src/game.c @@ -574,15 +574,15 @@ void load_level(s32 levelId, s32 numberOfPlayers, s32 entranceId, s32 vehicleId, settings->worldId = gCurrentLevelHeader->world; } settings->courseId = levelId; - if (gCurrentLevelHeader->weather_enable > 0) { + if (gCurrentLevelHeader->weatherEnable > 0) { func_800AB4A8( - gCurrentLevelHeader->unk92, - gCurrentLevelHeader->weather_enable, - gCurrentLevelHeader->unk96 << 8, - gCurrentLevelHeader->unk98 << 8, - gCurrentLevelHeader->unk9A << 8, - gCurrentLevelHeader->unk94 * 0x101, - gCurrentLevelHeader->unk95 * 0x101); + gCurrentLevelHeader->weatherType, + gCurrentLevelHeader->weatherEnable, + gCurrentLevelHeader->weatherVelX << 8, + gCurrentLevelHeader->weatherVelY << 8, + gCurrentLevelHeader->weatherVelZ << 8, + gCurrentLevelHeader->weatherIntensity * 0x101, + gCurrentLevelHeader->weatherOpacity * 0x101); func_800AB308(-1, -0x200); } if (gCurrentLevelHeader->unk49 == -1) { @@ -680,8 +680,8 @@ void func_8006BEFC(void) { func_8002C7D4(); func_80008174(); func_80000968(0); - if (gCurrentLevelHeader->weather_enable > 0) { - func_800AB35C(); + if (gCurrentLevelHeader->weatherEnable > 0) { + free_weather_memory(); } //! @bug this will never be true because unk49 is signed. if (gCurrentLevelHeader->unk49 == 0xFF) { @@ -1032,6 +1032,7 @@ void load_level_2(s32 levelId, s32 numberOfPlayers, s32 entranceId, s32 vehicleI func_80072298(1); } +// Guessing this is the "unload everything ready for level swap" function. void func_8006CC14(void) { set_free_queue_state(0); if (D_800DD38C == 0) { diff --git a/src/menu.c b/src/menu.c index 69315fce..f2389d7d 100644 --- a/src/menu.c +++ b/src/menu.c @@ -2437,11 +2437,11 @@ s32 menu_options_loop(s32 arg0) { set_music_fade_timer(-128); gMenuDelay = -1; func_800C01D8(&sMenuTransitionFadeIn); - play_sound_global(SOUND_MENU_BACK3, 0); + play_sound_global(SOUND_MENU_BACK3, NULL); } else if ((buttonsPressed & (A_BUTTON | START_BUTTON)) && D_800DF460 >= 2) { // Go to a sub-menu gMenuDelay = 31; - play_sound_global(SOUND_SELECT2, 0); + play_sound_global(SOUND_SELECT2, NULL); } else if (D_800DF460 == 0 && analogX != 0) { // Change language s32 currentLang = get_language(); @@ -2450,7 +2450,7 @@ s32 menu_options_loop(s32 arg0) { } else { set_language(LANGUAGE_ENGLISH); } - play_sound_global(SOUND_MENU_PICK2, 0); + play_sound_global(SOUND_MENU_PICK2, NULL); } else if (D_800DF460 == 1 && analogX != 0) { // Enable/Disable subtitles. if (sEepromSettings & 0x2000000) { @@ -2459,7 +2459,7 @@ s32 menu_options_loop(s32 arg0) { func_800C2AF4(0); gOptionMenuStrings[1] = gMenuText[183]; } else { - play_sound_global(SOUND_MENU_PICK2, 0); + play_sound_global(SOUND_MENU_PICK2, NULL); set_eeprom_settings_value(0); func_800C2AF4(1); gOptionMenuStrings[1] = gMenuText[182]; @@ -2472,7 +2472,7 @@ s32 menu_options_loop(s32 arg0) { if (D_800DF460 >= 6) { D_800DF460 = 5; } - play_sound_global(SOUND_MENU_PICK2, 0); + play_sound_global(SOUND_MENU_PICK2, NULL); } if (analogY > 0) { // Scroll up the list. @@ -2480,7 +2480,7 @@ s32 menu_options_loop(s32 arg0) { if (D_800DF460 < 0) { D_800DF460 = 0; } - play_sound_global(SOUND_MENU_PICK2, 0); + play_sound_global(SOUND_MENU_PICK2, NULL); } } @@ -3972,7 +3972,7 @@ void menu_caution_init(void) { s32 menu_caution_loop(s32 updateRate) { if (gMenuDelay) { gMenuDelay += updateRate; - } else if (gIgnorePlayerInput <= 0 && (get_buttons_pressed_from_player(0) & (A_BUTTON | B_BUTTON | START_BUTTON))) { + } else if (gIgnorePlayerInput <= 0 && (get_buttons_pressed_from_player(PLAYER_ONE) & (A_BUTTON | B_BUTTON | START_BUTTON))) { play_sound_global(SOUND_SELECT2, NULL); gMenuDelay = 1; func_800C01D8(&sMenuTransitionFadeIn); @@ -4138,7 +4138,7 @@ s32 menu_game_select_loop(s32 arg0) { } else { func_8008C698(arg0); if ((gMenuDelay == 0) && (D_801263D8 == 0)) { - playerInputs = get_buttons_pressed_from_player(0); + playerInputs = get_buttons_pressed_from_player(PLAYER_ONE); playerYDir = gControllersYAxisDirection[0]; playerInputs = playerInputs; if (gNumberOfActivePlayers == 2) { @@ -4151,7 +4151,7 @@ s32 menu_game_select_loop(s32 arg0) { } func_800C01D8(&sMenuTransitionFadeIn); gMenuDelay = 1; - play_sound_global(SOUND_SELECT2, 0); + play_sound_global(SOUND_SELECT2, NULL); } else if (playerInputs & B_BUTTON) { func_800C01D8(&sMenuTransitionFadeIn); gMenuDelay = -1; @@ -4159,13 +4159,13 @@ s32 menu_game_select_loop(s32 arg0) { if (playerYDir < 0) { if (D_800DF460 < D_801263E0) { D_800DF460++; - play_sound_global(SOUND_MENU_PICK2, 0); + play_sound_global(SOUND_MENU_PICK2, NULL); } } if (playerYDir > 0) { if (D_800DF460 > 0) { D_800DF460--; - play_sound_global(SOUND_MENU_PICK2, 0); + play_sound_global(SOUND_MENU_PICK2, NULL); } } } @@ -4387,7 +4387,7 @@ void func_8008DC7C(UNUSED s32 arg0) { s32 controllerXAxisDirection; s32 temp; - buttonsPressed = get_buttons_pressed_from_player(0); + buttonsPressed = get_buttons_pressed_from_player(PLAYER_ONE); controllerXAxisDirection = gControllersXAxisDirection[0]; if (gNumberOfActivePlayers == 2) { @@ -5744,11 +5744,11 @@ s32 menu_ghost_data_loop(s32 updateRate) { case 0: if ((pressedButtons & (START_BUTTON | A_BUTTON)) && (D_801264D4 > 0)) { D_801263E0 = 2; - play_sound_global(SOUND_SELECT2, 0); + play_sound_global(SOUND_SELECT2, NULL); } else if ((pressedButtons & B_BUTTON) || ((pressedButtons & (START_BUTTON | A_BUTTON)) && (D_801264D4 == 0))) { gMenuDelay = 1; func_800C01D8(&sMenuTransitionFadeIn); - play_sound_global(SOUND_MENU_BACK3, 0); + play_sound_global(SOUND_MENU_BACK3, NULL); } else { temp = D_80126498; if (yStick < 0 && D_80126498 < (D_801264D4 - 1)) { @@ -5764,14 +5764,14 @@ s32 menu_ghost_data_loop(s32 updateRate) { } } if (temp != D_80126498) { - play_sound_global(SOUND_MENU_PICK2, 0); + play_sound_global(SOUND_MENU_PICK2, NULL); } } break; case 1: if (pressedButtons & B_BUTTON) { D_801263E0 = 0; - play_sound_global(SOUND_MENU_BACK3, 0); + play_sound_global(SOUND_MENU_BACK3, NULL); } else { if (pressedButtons & (START_BUTTON | A_BUTTON)) { if (func_800998E0(D_80126498) == 0) { @@ -5784,26 +5784,26 @@ s32 menu_ghost_data_loop(s32 updateRate) { if (D_80126498 < D_801263D8) { D_801263D8 = D_80126498; } - play_sound_global(SOUND_SELECT2, 0); + play_sound_global(SOUND_SELECT2, NULL); } else { gMenuDelay = 1; func_800C01D8(&sMenuTransitionFadeIn); - play_sound_global(SOUND_MENU_BACK3, 0); + play_sound_global(SOUND_MENU_BACK3, NULL); } D_801263E0 = 0; } else if (yStick < 0) { D_801263E0 = 2; - play_sound_global(SOUND_MENU_PICK2, 0); + play_sound_global(SOUND_MENU_PICK2, NULL); } } break; case 2: if (pressedButtons & (START_BUTTON | A_BUTTON | B_BUTTON)) { D_801263E0 = 0; - play_sound_global(SOUND_MENU_BACK3, 0); + play_sound_global(SOUND_MENU_BACK3, NULL); } else if (yStick > 0) { D_801263E0 = 1; - play_sound_global(SOUND_MENU_PICK2, 0); + play_sound_global(SOUND_MENU_PICK2, NULL); } break; } @@ -6483,7 +6483,7 @@ s32 taj_menu_loop(void) { set_dialogue_font(1, ASSET_FONTS_FUNFONT); } sp2C = 0; - buttonsPressed = get_buttons_pressed_from_player(0); + buttonsPressed = get_buttons_pressed_from_player(PLAYER_ONE); sDialogueOptionMax = 0; switch (sCurrentMenuID) { @@ -6534,14 +6534,14 @@ s32 taj_menu_loop(void) { handle_menu_joystick_input(); if (buttonsPressed & B_BUTTON) { sp2C = 3; - play_sound_global(SOUND_MENU_BACK3, 0); + play_sound_global(SOUND_MENU_BACK3, NULL); } else if (buttonsPressed & A_BUTTON) { - play_sound_global(SOUND_SELECT2, 0); + play_sound_global(SOUND_SELECT2, NULL); switch (D_80126516) { case 1: sCurrentMenuID = 3; sDialogueOption = 0; - func_8003AC3C(0x239, 1); + play_taj_voice_clip(SOUND_VOICE_TAJ_CHALLENGE_MENU, TRUE); break; case 2: sp2C = 3; @@ -6549,7 +6549,7 @@ s32 taj_menu_loop(void) { case 0: sCurrentMenuID = 2; sDialogueOption = 0; - func_8003AC3C(0x234, 1); + play_taj_voice_clip(SOUND_VOICE_TAJ_SELECT_VEHICLE, TRUE); break; } } @@ -6557,8 +6557,8 @@ s32 taj_menu_loop(void) { case 2: handle_menu_joystick_input(); if (buttonsPressed & B_BUTTON) { - play_sound_global(SOUND_MENU_BACK3, 0); - func_8003AC3C(0x238, 1); + play_sound_global(SOUND_MENU_BACK3, NULL); + play_taj_voice_clip(SOUND_VOICE_TAJ_MENUBACK, TRUE); sCurrentMenuID = 1; sDialogueOption = 0; } else if (buttonsPressed & A_BUTTON) { @@ -6568,20 +6568,20 @@ s32 taj_menu_loop(void) { } else { sCurrentMenuID = 1; sDialogueOption = 0; - func_8003AC3C(0x238, 1); + play_taj_voice_clip(SOUND_VOICE_TAJ_MENUBACK, TRUE); } } break; case 3: handle_menu_joystick_input(); if ((buttonsPressed & B_BUTTON) || ((buttonsPressed & A_BUTTON) && (D_80126516 == 3))) { - play_sound_global(SOUND_MENU_BACK3, 0); - func_8003AC3C(0x23A, 1); + play_sound_global(SOUND_MENU_BACK3, NULL); + play_taj_voice_clip(SOUND_VOICE_TAJ_MENUBACK2, TRUE); sCurrentMenuID = 1; sDialogueOption = 3; } else if (buttonsPressed & A_BUTTON) { sp2C = D_80126516 | 0x40; - play_sound_global(SOUND_SELECT2, 0); + play_sound_global(SOUND_SELECT2, NULL); sCurrentMenuID = 0x63; } break; @@ -6641,10 +6641,10 @@ s32 dialogue_race_defeat(void) { s32 state; s32 playerInput; - set_current_dialogue_box_coords(1, 0x18, 0x10, 0xB8, 0x87); + set_current_dialogue_box_coords(1, 24, 16, 184, 135); set_dialogue_font(1, ASSET_FONTS_FUNFONT); state = 0; - playerInput = get_buttons_pressed_from_player(0); + playerInput = get_buttons_pressed_from_player(PLAYER_ONE); sDialogueOptionMax = 0; D_800DF4DC = 0; render_dialogue_text(1, POS_CENTRED, 6, gMenuText[49], 1, 4); // BETTER LUCK @@ -6698,7 +6698,7 @@ s32 tt_menu_loop(void) { } set_dialogue_font(1, ASSET_FONTS_FUNFONT); currentOption = 0; - buttonsPressed = get_buttons_pressed_from_player(0); + buttonsPressed = get_buttons_pressed_from_player(PLAYER_ONE); sDialogueOptionMax = 0; gDialogueOptionYOffset = 32; switch (sCurrentMenuID) { @@ -6721,12 +6721,12 @@ s32 tt_menu_loop(void) { if (D_80126516 == 0) { if (gControllersXAxisDirection[0] > 0) { if (!is_time_trial_enabled()) { - func_80036BCC(0x231, 1); + play_tt_voice_clip(SOUND_VOICE_TT_TIME_TRIAL_ON, TRUE); } set_time_trial_enabled(TRUE); } else if (gControllersXAxisDirection[0] < 0) { if (is_time_trial_enabled() == 1) { - func_80036BCC(0x230, 1); + play_tt_voice_clip(SOUND_VOICE_TT_TIME_TRIAL_OFF, TRUE); } set_time_trial_enabled(FALSE); } @@ -6734,14 +6734,14 @@ s32 tt_menu_loop(void) { if ((buttonsPressed & A_BUTTON) && (sCurrentMenuID != TT_MENU_EXIT)) { switch (D_80126516) { case 1: - play_sound_global(SOUND_SELECT2, 0); + play_sound_global(SOUND_SELECT2, NULL); D_80126398 = 0; D_8012639C = TT_MENU_ROOT; sCurrentMenuID = TT_MENU_SAVE_GHOST; break; case 3: - play_sound_global(SOUND_SELECT2, 0); - func_80036BCC(0x22E, 1); + play_sound_global(SOUND_SELECT2, NULL); + play_tt_voice_clip(SOUND_VOICE_TT_GAME_STATUS, TRUE); func_8009C674(D_800E1E2C); allocate_menu_images(D_800E1E40); D_800E1E28 = 1; @@ -6750,7 +6750,7 @@ s32 tt_menu_loop(void) { } currentOption = D_80126516 + 1; } else if (buttonsPressed & B_BUTTON) { - play_sound_global(SOUND_MENU_BACK3, 0); + play_sound_global(SOUND_MENU_BACK3, NULL); currentOption = 3; } if (sCurrentMenuID == TT_MENU_GAME_STATUS) { @@ -6790,7 +6790,7 @@ s32 tt_menu_loop(void) { sCurrentMenuID = TT_MENU_ROOT; D_800E1E28 = 0; func_8009C4A8(D_800E1E2C); - func_80036BCC(0x22F, 1); + play_tt_voice_clip(SOUND_VOICE_TT_OKAY, TRUE); } break; case TT_MENU_INTRODUCTION: @@ -6812,12 +6812,12 @@ s32 tt_menu_loop(void) { render_dialogue_text(1, POS_CENTRED, 50, gMenuText[160], 1, 4); // the Controller Pak render_dialogue_text(1, POS_CENTRED, 66, gMenuText[162], 1, 4); // insert it now! if (buttonsPressed & (A_BUTTON | START_BUTTON)) { - play_sound_global(SOUND_SELECT2, 0); + play_sound_global(SOUND_SELECT2, NULL); D_80126398 = 0; D_8012639C = TT_MENU_INSERT_RUMBLE_PAK; sCurrentMenuID = TT_MENU_SAVE_GHOST; } else if (buttonsPressed & B_BUTTON) { - play_sound_global(SOUND_MENU_BACK3, 0); + play_sound_global(SOUND_MENU_BACK3, NULL); sCurrentMenuID = TT_MENU_ROOT; } break; @@ -6902,7 +6902,7 @@ s32 trophy_race_cabinet_menu_loop(void) { set_current_dialogue_box_coords(1, 0x18, 0x10, 0xB8, 0x78); set_dialogue_font(1, ASSET_FONTS_FUNFONT); currentOption = 0; - buttonsPressed = get_buttons_pressed_from_player(0); + buttonsPressed = get_buttons_pressed_from_player(PLAYER_ONE); render_dialogue_text(1, POS_CENTRED, 6, gMenuText[70], 1, 4); // TROPHY RACE if (gControllersYAxisDirection[0] < 0) { sDialogueOption++; @@ -7054,12 +7054,12 @@ s32 is_in_two_player_adventure(void) { * Returns 1 if T.T. is avaliable to use, or 0 if not. */ s32 is_tt_unlocked(void) { - return gActiveMagicCodes & 1; + return gActiveMagicCodes & CHEAT_CONTROL_TT; } /** * Returns 1 if Drumstick is avaliable to use, or 0 if not. */ s32 is_drumstick_unlocked(void) { - return gActiveMagicCodes & 2; + return gActiveMagicCodes & CHEAT_CONTROL_DRUMSTICK; } diff --git a/src/object_functions.c b/src/object_functions.c index a24e98e6..14bde344 100644 --- a/src/object_functions.c +++ b/src/object_functions.c @@ -117,8 +117,8 @@ VertexPosition D_800DCB28[6] = { /************ .bss ************/ f32 D_8011D4D0; -s32 D_8011D4D4; -s32 D_8011D4D8; +s32 gTajSoundMask; +s32 gTTSoundMask; s32 D_8011D4DC; s16 D_8011D4E0; s16 D_8011D4E2; @@ -621,7 +621,7 @@ void obj_loop_trophycab(Object *obj, s32 speed) { // A hit has been detected at this point. if (isTrophyRaceAvaliable) { obj->unk78 = 1; - play_sound_global(SOUND_VOICE_TT_TROPHY_RACE, 0); + play_sound_global(SOUND_VOICE_TT_TROPHY_RACE, NULL); func_800A3870(); } else @@ -743,7 +743,7 @@ void obj_loop_rocketsignpost(Object *obj, UNUSED s32 speed) { if (obj4C->unk13 < 0xC8) { if (playerObj == obj4C->unk0) { // Detect if the player honks or slams into the signpost. - if ((get_buttons_pressed_from_player(0) & Z_TRIG) || playerObj == obj->unk5C->unk100) { + if ((get_buttons_pressed_from_player(PLAYER_ONE) & Z_TRIG) || playerObj == obj->unk5C->unk100) { func_8006F29C(); } } @@ -787,7 +787,7 @@ void obj_loop_airzippers_waterzippers(Object *obj, UNUSED s32 speed) { Object** racerObjs; s32 i; - if (func_8000E1CC() == 0) { + if (find_non_car_racers() == FALSE) { obj->segment.trans.unk6 |= 0x4000; } else { obj->segment.trans.unk6 &= 0xBFFF; @@ -972,18 +972,22 @@ void obj_init_stopwatchman(Object *obj, UNUSED LevelObjectEntry_StopWatchMan *en temp = &obj->unk64->tt; temp->unkD = 0xFF; temp->unk0 = 0.0f; - D_8011D4D8 = 0; + gTTSoundMask = 0; } GLOBAL_ASM("asm/non_matchings/unknown_032760/obj_loop_stopwatchman.s") -void func_80036BCC(u16 arg0, s32 arg1) { - if ((D_8011D4D8 != 0) && (arg1 & 1)) { - func_8000488C(D_8011D4D8); //This is likely wrong and will need to be fixed - D_8011D4D8 = 0; +/** + * If TT is currently talking, clear the audio associated with gTTSoundMask, + * then play the new sound ID in its place. + */ +void play_tt_voice_clip(u16 soundID, s32 interrupt) { + if (gTTSoundMask && interrupt & 1) { + func_8000488C(gTTSoundMask); //This is likely wrong and will need to be fixed + gTTSoundMask = 0; } - if (D_8011D4D8 == 0) { - play_sound_global(arg0, &D_8011D4D8); + if (gTTSoundMask == 0) { + play_sound_global(soundID, &gTTSoundMask); } } @@ -1193,7 +1197,7 @@ void obj_init_animation(Object *obj, LevelObjectEntry_Animation *entry, s32 arg2 func_80011390(); obj->unk7C.word = entry->actorIndex; obj->unk78 = arg2; - if (arg2 != 0 && (get_buttons_pressed_from_player(0) & R_CBUTTONS)) { + if (arg2 != 0 && (get_buttons_pressed_from_player(PLAYER_ONE) & R_CBUTTONS)) { obj->unk78 = 2; } if (((func_8001E440() == entry->channel) || (entry->channel == 20)) && (obj->unk64 == NULL) && (entry->order == 0) && (entry->objectIdToSpawn != -1)) { @@ -1298,10 +1302,10 @@ void obj_loop_snowball(Object *obj, s32 speed) { } } if (obj64->unk24 != 0) { - if (obj64->unk20 == 0) { - func_80009558(obj64->unk24, obj->segment.trans.x_position, obj->segment.trans.y_position, obj->segment.trans.z_position, 1, &obj64->unk20); + if (obj64->soundMask == 0) { + func_80009558(obj64->unk24, obj->segment.trans.x_position, obj->segment.trans.y_position, obj->segment.trans.z_position, 1, &obj64->soundMask); } else { - func_800096D8(obj64->unk20, obj->segment.trans.x_position, obj->segment.trans.y_position, obj->segment.trans.z_position); + func_800096D8(obj64->soundMask, obj->segment.trans.x_position, obj->segment.trans.y_position, obj->segment.trans.z_position); } } func_8001F460(obj, speed, obj); @@ -1366,7 +1370,7 @@ void obj_init_infopoint(Object *obj, LevelObjectEntry_InfoPoint *entry) { } void obj_loop_infopoint(Object *obj, UNUSED s32 speed) { - s16 temp_a0; + s16 player; Object_4C *obj4C; Object *playerObj; @@ -1381,8 +1385,8 @@ void obj_loop_infopoint(Object *obj, UNUSED s32 speed) { playerObj = obj4C->unk0; if (playerObj->segment.header->behaviorId == 1) { Object_InfoPoint *playerObj64 = &playerObj->unk64->info_point; - temp_a0 = playerObj64->unk0; - if ((temp_a0 != -1) && (get_buttons_pressed_from_player(temp_a0) & Z_TRIG)) { + player = playerObj64->unk0; + if ((player != PLAYER_COMPUTER) && (get_buttons_pressed_from_player(player) & Z_TRIG)) { func_800C31EC(obj->unk78 & 0xFF); } } @@ -1468,7 +1472,7 @@ void obj_loop_teleport(Object *obj, UNUSED s32 speed) { if (obj->unk4C->unk13 < 0x78) { func_8006F338(temp->unk8); obj->unk78 = 0; - play_sound_global(SOUND_WHOOSH2, 0); + play_sound_global(SOUND_WHOOSH2, NULL); func_80000FDC(0x12A, 0, 1.0f); } } @@ -1586,7 +1590,7 @@ void obj_loop_dino_whale(Object *obj, s32 speed) { if (obj->unk4C->unk13 < 0xFF) { if (obj->unk78 == 0) { obj->unk78 = 0x3C; - func_80009558(571, obj->segment.trans.x_position, obj->segment.trans.y_position, obj->segment.trans.z_position, 4, NULL); + func_80009558(SOUND_VOICE_BRONTO_ROAR, obj->segment.trans.x_position, obj->segment.trans.y_position, obj->segment.trans.z_position, 4, NULL); } } } @@ -1604,7 +1608,7 @@ void obj_init_parkwarden(Object *obj, UNUSED LevelObjectEntry_Parkwarden *entry) temp->unk2C = 0; temp->unk34 = 0; temp->unk36 = 0; - D_8011D4D4 = 0; + gTajSoundMask = 0; D_8011D4E2 = 0x10F; } @@ -1614,13 +1618,17 @@ void func_80039320(s16 arg0) { GLOBAL_ASM("asm/non_matchings/unknown_032760/obj_loop_parkwarden.s") -void func_8003AC3C(u16 arg0, s32 arg1) { - if ((D_8011D4D4 != 0) && (arg1 & 1)) { - func_8000488C(D_8011D4D4); - D_8011D4D4 = 0; +/** + * If Taj is currently talking, clear the audio associated with gTajSoundMask, + * then play the new sound ID in its place. + */ +void play_taj_voice_clip(u16 soundID, s32 interrupt) { + if (gTajSoundMask && interrupt & 1) { + func_8000488C(gTajSoundMask); + gTajSoundMask = 0; } - if (D_8011D4D4 == 0) { - play_sound_global(arg0, &D_8011D4D4); + if (!gTajSoundMask) { + play_sound_global(soundID, &gTajSoundMask); } } @@ -2104,7 +2112,7 @@ void obj_init_silvercoin_adv2(Object *obj, UNUSED LevelObjectEntry_SilverCoinAdv obj->unk78 = 3; obj->unk7C.word = 16; if (!is_in_tracks_mode()) { - if (func_8000E1DC() && is_in_adventure_two()) { + if (check_if_silver_coin_race() && is_in_adventure_two()) { obj->unk78 = 0; } else { obj->unk78 = 3; @@ -2123,7 +2131,7 @@ void obj_init_silvercoin(Object *obj, UNUSED LevelObjectEntry_SilverCoin *entry) obj->unk78 = 3; obj->unk7C.word = 0; if (!is_in_tracks_mode()) { - if (func_8000E1DC() && !is_in_adventure_two()) { + if (check_if_silver_coin_race() && !is_in_adventure_two()) { obj->unk78 = 0; } else { obj->unk78 = 3; diff --git a/src/object_functions.h b/src/object_functions.h index 943b75f9..1da61e4b 100644 --- a/src/object_functions.h +++ b/src/object_functions.h @@ -268,7 +268,7 @@ void obj_loop_unknown58(Object *obj, s32 speed); void obj_init_characterflag(Object *obj, LevelObjectEntry_CharacterFlag *entry); void obj_loop_characterflag(Object *obj, s32 speed); void obj_init_stopwatchman(Object *obj, LevelObjectEntry_StopWatchMan *entry); -void func_80036BCC(u16 arg0, s32 arg1); +void play_tt_voice_clip(u16 soundID, s32 interrupt); void obj_init_lavaspurt(Object *obj, LevelObjectEntry_LavaSpurt *entry); void obj_init_posarrow(Object *obj, LevelObjectEntry_PosArrow *entry); void obj_init_animator(Object *obj, LevelObjectEntry_Animator *entry, s32 arg2); @@ -305,7 +305,7 @@ void obj_init_dino_whale(Object *obj, LevelObjectEntry_Dino_Whale *entry); void obj_loop_dino_whale(Object *obj, s32 speed); void obj_init_parkwarden(Object *obj, LevelObjectEntry_Parkwarden *entry); void func_80039320(s16 arg0); -void func_8003AC3C(u16 arg0, s32 arg1); +void play_taj_voice_clip(u16 soundID, s32 interrupt); void obj_loop_gbparkwarden(Object *obj, s32 speed); f32 func_8003ACAC(void); void obj_init_checkpoint(Object *obj, LevelObjectEntry_Checkpoint *entry, s32 arg2); diff --git a/src/objects.c b/src/objects.c index 235ca9bd..a7061a23 100644 --- a/src/objects.c +++ b/src/objects.c @@ -180,7 +180,7 @@ s8 D_8011ADD5; s32 D_8011ADD8[10]; s8 D_8011AE00; s8 D_8011AE01; -s8 D_8011AE02; +s8 gIsNonCarRacers; s8 gIsSilverCoinRace; u32 *D_8011AE08[16]; s32 (*D_8011AE48)[8]; // Unknown number of entries. @@ -589,11 +589,19 @@ void func_8000E1B8(void) { D_800DC740 = 0; } -s8 func_8000E1CC(void) { - return D_8011AE02; +/** + * Return true if there exist players piloting planes or hovercraft. + * Used to determine whether to use certain zippers. + */ +s8 find_non_car_racers(void) { + return gIsNonCarRacers; } -s8 func_8000E1DC() { +/** + * Return true if the silver coin race mode is active. + * Used to determine whether to spawn silver coins. + */ +s8 check_if_silver_coin_race() { return gIsSilverCoinRace; } @@ -874,7 +882,8 @@ s32 get_race_start_timer() { return gRaceStartCountdown; } -s32 func_800113BC() { +// Unused function, purpose currently unknown. +UNUSED s32 func_800113BC() { return D_8011ADBC; } diff --git a/src/objects.h b/src/objects.h index d180afff..be8dead2 100644 --- a/src/objects.h +++ b/src/objects.h @@ -141,8 +141,8 @@ s8 func_8000E158(void); s8 func_8000E184(); void func_8000E194(void); void func_8000E1B8(void); -s8 func_8000E1CC(void); -s8 func_8000E1DC(); +s8 find_non_car_racers(void); +s8 check_if_silver_coin_race(); void func_8000E1EC(Object *object, s32 arg1); void set_time_trial_enabled(s32 arg0); u8 is_time_trial_enabled(); diff --git a/src/racer.c b/src/racer.c index dd83d1f7..f2da6d18 100644 --- a/src/racer.c +++ b/src/racer.c @@ -146,14 +146,14 @@ f32 D_8011D4F0[2]; s32 D_8011D4F8[3]; s32 D_8011D504; ObjectCamera *gCameraObject; -s32 D_8011D50C; +UNUSED s32 D_8011D50C; ObjectTransform D_8011D510; s32 gCurrentCarInput; // Related to input of the car. s32 gActivePlayerButtonPress; s32 D_8011D530; s32 gCurrentStickX; s32 gCurrentStickY; -s32 D_8011D53C; +s32 D_8011D53C; // Set to 0 and only 0. Checked for being 1, but never true. s32 gRaceStartTimer; f32 D_8011D544; f32 D_8011D548; @@ -164,8 +164,8 @@ s8 D_8011D553; s32 gCurrentCarSteerVel; // Related to rotational velocity of the car. s32 D_8011D558; s32 D_8011D55C; -s16 D_8011D560; -s16 D_8011D562; +s16 D_8011D560; // Set, but never read. +UNUSED s16 D_8011D562; s32 D_8011D564; s32 D_8011D568; s32 D_8011D56C; @@ -481,7 +481,7 @@ void update_camera_hovercraft(f32 updateRate, Object *obj, Object_Racer *racer) yVel *= 0.5; } else { if (D_8011D53C == 1) { - yVel *= 0.5; + yVel *= 0.5; // Unreachable. D_8011D53C is never not 0. } else { yVel *= 0.25; } @@ -565,7 +565,7 @@ void func_8004C140(Object *obj, Object_Racer *racer) { racer->unk1C9 = 0; } if (racer->unk1D6 < 5) { - func_800570B8(obj, SOUND_VOICE_CHARACTER_NEGATIVE, 8, 129); + play_random_character_voice(obj, SOUND_VOICE_CHARACTER_NEGATIVE, 8, 129); switch (racer->unk187) { case 1: case 2: @@ -1524,7 +1524,7 @@ void func_80055A84(Object *obj, Object_Racer *racer, s32 updateRate) { s8 sp3F; s8 shouldSquish; - if (D_8011D4F0[0] < obj->segment.trans.y_position) { + if (obj->segment.trans.y_position > D_8011D4F0[0]) { obj->segment.trans.y_position = D_8011D4F0[0]; } temp_v0 =(f32 *) get_misc_asset(56); @@ -1609,7 +1609,7 @@ GLOBAL_ASM("asm/non_matchings/racer/func_80055EC0.s") void play_char_horn_sound(Object *obj, Object_Racer *racer) { if (get_filtered_cheats() & CHEAT_HORN_CHEAT) { // Play character voice instead of horn. - func_800570B8(obj, SOUND_VOICE_CHARACTER_POSITIVE, 8, 130); + play_random_character_voice(obj, SOUND_VOICE_CHARACTER_POSITIVE, 8, 130); } else { // Play character's horn sound racer_play_sound(obj, racer->characterId + SOUND_HORN_CHARACTER); @@ -1641,29 +1641,29 @@ void func_800570A4(Object *obj, s32 arg1, s32 arg2) { * acceptable offsets. Range will always be 8, because that's how many ID's for each * there are. */ -void func_800570B8(Object *obj, s32 soundID, s32 range, s32 arg3) { +void play_random_character_voice(Object *obj, s32 soundID, s32 range, s32 arg3) { s32 soundIndex; Object_64 *tempRacer; tempRacer = obj->unk64; if (tempRacer->racer.unk108 == 0 && ((!(arg3 & 0x80)) || D_8011D55C != -1)) { if (arg3 == 2) { - if ((tempRacer->racer.unk24 != 0) && (soundID != tempRacer->racer.unk2A)) { - func_800096F8(tempRacer->racer.unk24); - tempRacer->racer.unk24 = 0; + if ((tempRacer->racer.soundMask != 0) && (soundID != tempRacer->racer.unk2A)) { + func_800096F8(tempRacer->racer.soundMask); + tempRacer->racer.soundMask = 0; } } - if (tempRacer->racer.unk24 == 0 && (arg3 != 3 || get_random_number_from_range(0, 1))) { + if (tempRacer->racer.soundMask == 0 && (arg3 != 3 || get_random_number_from_range(0, 1))) { tempRacer->racer.unk2A = soundID; soundID += tempRacer->racer.characterId; soundIndex = (get_random_number_from_range(0, range - 1) * 12) + soundID; if (range - 1 > 0) { - while (soundIndex == tempRacer->racer.unk28) { + while (soundIndex == tempRacer->racer.lastSoundID) { soundIndex = (get_random_number_from_range(0, range - 1) * 12) + soundID; } } - func_80009558(soundIndex, obj->segment.trans.x_position, obj->segment.trans.y_position, obj->segment.trans.z_position, 4, &tempRacer->racer.unk24); - tempRacer->racer.unk28 = soundIndex; + func_80009558(soundIndex, obj->segment.trans.x_position, obj->segment.trans.y_position, obj->segment.trans.z_position, 4, &tempRacer->racer.soundMask); + tempRacer->racer.lastSoundID = soundIndex; } } } @@ -1748,7 +1748,7 @@ f32 handle_racer_top_speed(Object *obj, Object_Racer *racer) { if (!gRaceStartTimer) { if (racer->boost_sound & BOOST_RACE_START) { racer->boost_sound &= ~BOOST_RACE_START; - func_800570B8(obj, SOUND_VOICE_CHARACTER_POSITIVE, 8, 130); + play_random_character_voice(obj, SOUND_VOICE_CHARACTER_POSITIVE, 8, 130); racer_play_sound(obj, SOUND_NITRO_BOOST); } } @@ -1840,13 +1840,13 @@ void func_80057A40(Object *obj, Object_Racer *racer, f32 updateRate) { } switch (gCameraObject->zoom) { case ZOOM_MEDIUM: - play_sound_global(SOUND_MENU_BACK, 0); + play_sound_global(SOUND_MENU_BACK, NULL); break; case ZOOM_FAR: - play_sound_global(SOUND_MENU_BACK2, 0); + play_sound_global(SOUND_MENU_BACK2, NULL); break; default: - play_sound_global(SOUND_UNK106, 0); + play_sound_global(SOUND_UNK106, NULL); break; } } diff --git a/src/racer.h b/src/racer.h index b30137d5..0bff5c91 100644 --- a/src/racer.h +++ b/src/racer.h @@ -41,7 +41,7 @@ typedef enum BoostType { BOOST_UNK3, BOOST_SMALL_FAST, BOOST_MEDIUM_FAST, - BOOST_LARGE_FAST, + BOOST_LARGE_FAST } BoostType; typedef enum AISkill { @@ -205,7 +205,7 @@ s32 func_80052388(Object *obj1, Object_Racer *racer, Object *obj2, f32 distance) void func_80055A84(Object *obj, Object_Racer *racer, s32 arg2); void func_8005C270(Object_Racer *racer); f32 handle_racer_top_speed(Object *obj, Object_Racer *racer); -void func_800570B8(Object *obj, s32 soundID, s32 range, s32 arg3); +void play_random_character_voice(Object *obj, s32 soundID, s32 range, s32 arg3); void apply_vehicle_rotation_offset(Object_Racer *obj, s32 max, s16 yRotation, s16 xRotation, s16 zRotation); void func_80059080(Object *obj, Object_Racer *racer, f32 *velX, f32 *velY, f32 *velZ); void func_80054110(Object *obj, Object_Racer *racer, s32 updateRate, f32 updateRateF); diff --git a/src/unknown_003260.c b/src/unknown_003260.c index 3a44e997..d5291908 100644 --- a/src/unknown_003260.c +++ b/src/unknown_003260.c @@ -411,6 +411,7 @@ GLOBAL_ASM("asm/non_matchings/unknown_003260/func_80004668.s") #endif //input typing not right (some type of struct) +// 99% sure this function will clear the audio buffer associated with a given sound mask. void func_8000488C(u8 *arg0) { ALEvent sp_18; sp_18.type = 1024; diff --git a/src/weather.c b/src/weather.c index e1e99754..7d3b0a0e 100644 --- a/src/weather.c +++ b/src/weather.c @@ -116,26 +116,26 @@ unk800E2B4C D_800E2B4C[8] = { { 0, 0, 0, 1.0f, 0.0f, 0.0f, 0.0f, 0, 0 }, }; -unk800E2C2C D_800E2C2C[2] = { +unk800E2C2C gRainGfx[2] = { { 0, 0, 0x400, 0x400, 0x000A, 0xFFC4, NULL, 0x80, 0xFF, 0xFF, 0x80, 0x80, 0xFF, 0x80, 0x00 }, { 0, 0, 0x600, 0x600, 0x0020, 0xFF40, NULL, 0xFF, 0xFF, 0xFF, 0x00, 0x80, 0xFF, 0xFF, 0x00 } }; -s32 D_800E2C5C = 0; -s32 D_800E2C60 = 0x00010000; +s32 gWeatherType = WEATHER_SNOW; +s32 gLightningFrequency = 65536; s32 D_800E2C64 = 0; -s32 D_800E2C68 = 0x00010000; -s32 D_800E2C6C = 0x00010000; +s32 D_800E2C68 = 65536; +s32 D_800E2C6C = 65536; s32 D_800E2C70 = 0; -s32 D_800E2C74 = 0x00010000; +s32 D_800E2C74 = 65536; s32 D_800E2C78 = 0; -s32 D_800E2C7C = 0; -s32 D_800E2C80 = 0; +s32 gLightningTimer = 0; +s32 gThunderTimer = 0; s32 D_800E2C84 = 0; -s32 D_800E2C88 = 0; -Sprite *D_800E2C8C = 0; +s32 gRainOverlayUnusedValue = 0; // Set, but never read. +Sprite *gRainSplashGfx = 0; s32 D_800E2C90 = 0; -s32 D_800E2C94 = 0; +s32 gWeatherSoundMask = 0; FadeTransition D_800E2C98 = FADE_TRANSITION(0x40, FADE_COLOR_WHITE, 5, 2); @@ -151,7 +151,7 @@ unk80127BF8 D_80127BF8; s32 D_80127C00; s32 D_80127C04; s32 D_80127C08; -Gfx *D_80127C0C; +Gfx *gWeatherDisplayListHead; Mtx *D_80127C10; VertexList *D_80127C14; TriangleList *D_80127C18; @@ -183,7 +183,7 @@ void func_800AB1F0(void) { D_800E2A88 = 0; if (D_800E291C == NULL) { D_800E291C = (s32 *)load_asset_section_from_rom(ASSET_WEATHER_PARTICLES); - D_800E2920 = 0; + D_800E2920 = 0; while ((s32)D_800E291C[D_800E2920] != -1) { D_800E2920++; } @@ -215,7 +215,11 @@ void func_800AB308(s16 arg0, s16 arg1) { tex = NULL; \ } -void func_800AB35C(void) { +/** + * Free the weather assets from memory. + * If it's raining, then free those too. + */ +void free_weather_memory(void) { TextureHeader *tempTex; s32 *tempMem; @@ -230,8 +234,8 @@ void func_800AB35C(void) { D_800E2A88 = 0; D_800E2A80 = 0; D_800E2A84 = 1; - if (D_800E2C5C != 0) { - func_800AD220(); + if (gWeatherType != WEATHER_SNOW) { + free_rain_memory(); } } @@ -241,23 +245,23 @@ void func_800ABB34(void) { s32 temp_v0; s32 phi_s1; s32 i; - + temp_v0 = 0x10000 / D_800E28D8.unk4; phi_s1 = 0; - + for(i = 0; i < D_800E28D8.unk4; i++) { D_800E28D8.unk0[i].unk0 = func_8007082C(phi_s1 & 0xFFFF) << 3; D_800E28D8.unk0[i].unk4 = 0xFFFC0000; D_800E28D8.unk0[i].unk8 = func_80070830(phi_s1 & 0xFFFF) << 1; phi_s1 += temp_v0; } - + D_800E28D8.unk8 = load_texture(*D_800E291C); } void func_800ABC5C(s32 arg0, s32 arg1, s32 arg2, s32 arg3, s32 arg4, s32 arg5) { - if ((arg5 > 0) && ((arg0 != D_80127BB8[5]) || (arg1 != D_80127BB8[8]) || (arg2 != D_80127BB8[11]) + if ((arg5 > 0) && ((arg0 != D_80127BB8[5]) || (arg1 != D_80127BB8[8]) || (arg2 != D_80127BB8[11]) || (arg3 != D_80127BB8[0]) || (arg4 != D_80127BB8[12]))) { D_80127BB8[5] = arg0; D_80127BB8[8] = arg1; @@ -265,7 +269,7 @@ void func_800ABC5C(s32 arg0, s32 arg1, s32 arg2, s32 arg3, s32 arg4, s32 arg5) { D_80127BB8[4] = (s32) ((s32) (arg0 - D_80127BB8[3]) / arg5); D_80127BB8[7] = (s32) ((s32) (arg1 - D_80127BB8[6]) / arg5); D_80127BB8[10] = (s32) ((s32) (arg2 - D_80127BB8[9]) / arg5); - if (D_800E2C5C == 0) { + if (gWeatherType == WEATHER_SNOW) { D_80127BB8[1] = (s32) ((s32) (arg3 - D_80127BB8[0]) / arg5); D_80127BB8[13] = (s32) ((s32) (arg4 - D_80127BB8[12]) / arg5); D_80127BB8[2] = arg3; @@ -280,16 +284,20 @@ void func_800ABC5C(s32 arg0, s32 arg1, s32 arg2, s32 arg3, s32 arg4, s32 arg5) { } } -void func_800ABE68(Gfx **currDisplayList, Mtx **currHudMat, VertexList **currHudVerts, TriangleList **currHudTris, s32 updateRate) { +/** + * The root function for handling all weather. + * Decide whether to perform rain or snow logic, execute it, then set it to render right after. + */ +void process_weather(Gfx **currDisplayList, Mtx **currHudMat, VertexList **currHudVerts, TriangleList **currHudTris, s32 updateRate) { UNUSED s32 unused; - D_80127C0C = *currDisplayList; + gWeatherDisplayListHead = *currDisplayList; D_80127C10 = *currHudMat; D_80127C14 = *currHudVerts; D_80127C18 = *currHudTris; D_80127C1C = func_80069D20(); D_80127C20 = func_80069DBC(); - if (D_800E2C5C != 0) { - func_800AD4B8(updateRate); + if (gWeatherType != WEATHER_SNOW) { + handle_weather_rain(updateRate); } else { if (D_80127BB8[15] > 0) { if (updateRate < D_80127BB8[15]) { @@ -310,16 +318,16 @@ void func_800ABE68(Gfx **currDisplayList, Mtx **currHudMat, VertexList **currHud } D_80127BB4 = (D_80127BB0 * D_80127BB8[0]) >> (unused = 16); D_80127BF8.unk4 = (D_80127BF8.unk0 + ((D_80127BF8.unk2 - D_80127BF8.unk0) * D_80127BB8[12])) >> (unused = 16); - - func_800AC0C8(updateRate, &D_80127BF8); + + func_800AC0C8(updateRate, &D_80127BF8); // This is the snow physics that makes it move if ((D_80127BB4 > 0) && (D_80127BF8.unk4 < D_80127BF8.unk0)) { D_800E2904 = (s32) D_800E2914[D_80127C08]; - func_800AC21C(); + func_800AC21C(); // Both of these funcs are needed to render. func_800AC5A4(); D_80127C08 = 1 - D_80127C08; } } - *currDisplayList = D_80127C0C; + *currDisplayList = gWeatherDisplayListHead; *currHudMat = D_80127C10; *currHudVerts = D_80127C14; *currHudTris = D_80127C18; @@ -369,60 +377,64 @@ void func_800ACF98(Object* arg0) { GLOBAL_ASM("asm/non_matchings/game_ui/func_800AD030.s") void func_800AD144(s32 arg0, s32 arg1) { - D_800E2C60 = arg0; + gLightningFrequency = arg0; D_800E2C64 = 0; - D_800E2C68 = D_800E2C60; + D_800E2C68 = gLightningFrequency; D_800E2C6C = arg1; D_800E2C70 = 0; D_800E2C74 = D_800E2C6C; D_800E2C78 = 0; - D_800E2C7C = 0; - D_800E2C80 = 0; + gLightningTimer = 0; + gThunderTimer = 0; D_800E2C84 = 0; D_800E2C90 = 0; - D_800E2C2C[0].tex = load_texture(D_800E291C[1]); - D_800E2C2C[1].tex = load_texture(D_800E291C[1]); - D_800E2C8C = (Sprite *)func_8007C12C(D_800E291C[3], 0); - D_800E2C5C = 1; + gRainGfx[0].tex = load_texture(D_800E291C[1]); + gRainGfx[1].tex = load_texture(D_800E291C[1]); + gRainSplashGfx = (Sprite *)func_8007C12C(D_800E291C[3], 0); + gWeatherType = WEATHER_RAIN; } -void func_800AD220(void) { - if (D_800E2C2C[0].tex != NULL) { - free_texture(D_800E2C2C[0].tex); - D_800E2C88 = 0; +/** + * Free the rain overlay and splash asset data from memory. + * Clear the soundmask too, stopping any ongoing audio. + */ +void free_rain_memory(void) { + if (gRainGfx[0].tex != NULL) { + free_texture(gRainGfx[0].tex); + gRainOverlayUnusedValue = 0; } - if (D_800E2C2C[1].tex != NULL) { - free_texture(D_800E2C2C[1].tex); - D_800E2C88 = 0; + if (gRainGfx[1].tex != NULL) { + free_texture(gRainGfx[1].tex); + gRainOverlayUnusedValue = 0; } - if (D_800E2C8C != NULL) { - free_sprite(D_800E2C8C); - D_800E2C8C = 0; + if (gRainSplashGfx != NULL) { + free_sprite(gRainSplashGfx); + gRainSplashGfx = 0; } - if (D_800E2C94 != 0) { - func_800096F8(D_800E2C94); - D_800E2C94 = 0; + if (gWeatherSoundMask) { + func_800096F8(gWeatherSoundMask); + gWeatherSoundMask = 0; } - D_800E2C5C = 0; + gWeatherType = WEATHER_SNOW; } void func_800AD2C4(s32 arg0, s32 arg1, f32 arg2) { D_800E2C78 = osTvType == TV_TYPE_PAL ? 50.0 * arg2 : 60.0 * arg2; D_800E2C68 = arg0; - D_800E2C64 = (D_800E2C68 - D_800E2C60) / D_800E2C78; + D_800E2C64 = (D_800E2C68 - gLightningFrequency) / D_800E2C78; D_800E2C74 = arg1; D_800E2C70 = (D_800E2C74 - D_800E2C6C) / D_800E2C78; } void func_800AD40C(void) { s32 a, b; - if (D_800E2C5C && !get_viewport_count()) { - a = ((D_800E2C60 * -38) >> 16) + 0x3FA; - b = ((D_800E2C60 * -20) >> 16) + 0x3FF; + if (gWeatherType != WEATHER_SNOW && get_viewport_count() == VIEWPORTS_COUNT_1_PLAYER) { + a = ((gLightningFrequency * -38) >> 16) + 1018; + b = ((gLightningFrequency * -20) >> 16) + 1023; func_80030664(0, a, b, 0x1CU, 0xFU, 0x24U); } } @@ -432,79 +444,91 @@ void func_800AD4AC(s32 arg0) { D_800E2C6C = arg0; } -void func_800AD4B8(s32 arg0) { +/** + * When active, (Single player only) Call all the functions related to the behaviour and rendering of + * rain, and if necessary, thunder. + */ +void handle_weather_rain(s32 updateRate) { s32 i; - if ((get_viewport_count() == 0) && (D_800E2C5C != 0)) { + if ((get_viewport_count() == VIEWPORTS_COUNT_1_PLAYER) && (gWeatherType != WEATHER_SNOW)) { if (D_800E2C78 > 0) { - if (arg0 < D_800E2C78) { - D_800E2C78 -= arg0; - D_800E2C60 += D_800E2C64 * arg0; - D_800E2C6C += D_800E2C70 * arg0; + if (updateRate < D_800E2C78) { + D_800E2C78 -= updateRate; + gLightningFrequency += D_800E2C64 * updateRate; + D_800E2C6C += D_800E2C70 * updateRate; } else { D_800E2C78 = 0; - D_800E2C60 = D_800E2C68; + gLightningFrequency = D_800E2C68; D_800E2C6C = D_800E2C74; } } - func_800ADBC8(arg0); - func_800AD658(arg0); - func_800ADAB8(arg0); - if (D_800E2C60 >= 256) { - func_80067F2C(&D_80127C0C, &D_80127C10); + handle_rain_sound(updateRate); + render_rain_splashes(updateRate); + handle_rain_lightning(updateRate); + if (gLightningFrequency >= 256) { + func_80067F2C(&gWeatherDisplayListHead, &D_80127C10); for(i = 0; i < 2; i++) { - func_800ADCBC(&D_800E2C2C[i], arg0); + render_rain_overlay(&gRainGfx[i], updateRate); } - gDPSetPrimColor(D_80127C0C++, 0, 0, 255, 255, 255, 255); - gDPSetEnvColor(D_80127C0C++, 255, 255, 255, 0); - func_8007B3D0(&D_80127C0C); - func_800682AC(&D_80127C0C); + gDPSetPrimColor(gWeatherDisplayListHead++, 0, 0, 255, 255, 255, 255); + gDPSetEnvColor(gWeatherDisplayListHead++, 255, 255, 255, 0); + func_8007B3D0(&gWeatherDisplayListHead); // Pipesync and some stuff idk yet + func_800682AC(&gWeatherDisplayListHead); // Looks to create a viewport scissor. } } } -GLOBAL_ASM("asm/non_matchings/game_ui/func_800AD658.s") +GLOBAL_ASM("asm/non_matchings/game_ui/render_rain_splashes.s") -void func_800ADAB8(s32 arg0) { - if (D_800E2C80 > 0) { - D_800E2C80 -= arg0; - if (D_800E2C80 <= 0) { +/** + * On a randomly set timer, based on the weather intensity, count down and make the sound of thunder. + * Set a second timer, that then counts down to zero and creates a flash of lightning in the form of a screen transition. + * Afterwards, set the thunder timer back. + */ +void handle_rain_lightning(s32 updateRate) { + if (gThunderTimer > 0) { + gThunderTimer -= updateRate; + if (gThunderTimer <= 0) { if (D_800E2C6C >= 32769 && func_800C018C() == 0) { func_800C01D8(&D_800E2C98); } - play_sound_global(SOUND_LIGHTNING, 0); - D_800E2C80 = 0; + play_sound_global(SOUND_LIGHTNING, NULL); + gThunderTimer = 0; } - } else if (D_800E2C60 >= 48000) { - if (D_800E2C7C > 0) { - D_800E2C7C -= arg0; + } else if (gLightningFrequency >= 48000) { + if (gLightningTimer > 0) { + gLightningTimer -= updateRate; return; } - play_sound_global(SOUND_UNK575, 0); - D_800E2C80 = 600 - ((s32) (D_800E2C60 + -48000) >> 5); - D_800E2C7C = get_random_number_from_range(900, 1140) - ((s32) (D_800E2C60 + -48000) >> 5); + play_sound_global(SOUND_THUNDER, NULL); + gThunderTimer = 600 - ((s32) (gLightningFrequency + -48000) >> 5); + gLightningTimer = get_random_number_from_range(900, 1140) - ((s32) (gLightningFrequency + -48000) >> 5); } } -void func_800ADBC8(UNUSED s32 arg0) { - f32 temp_f14; - f32 temp_f16; - f32 temp_f18; - f32 sp28; - f32 sp24; - f32 temp_f2; +/** + * Emit looping rain sound, using the camera position and direction as reference. + */ +void handle_rain_sound(UNUSED s32 updateRate) { + f32 xPos; + f32 yPos; + f32 zPos; + f32 length; + f32 cosOffset; + f32 sineOffset; - sp28 = 1152.0f - (f32) (D_800E2C60 >> 6); - sp24 = cosine_s(D_80127C1C->trans.y_rotation) * sp28; - temp_f2 = sine_s(D_80127C1C->trans.y_rotation) * sp28; - temp_f14 = D_80127C1C->trans.x_position + (temp_f2 - sp24); - temp_f16 = D_80127C1C->trans.y_position; - temp_f18 = D_80127C1C->trans.z_position + (-temp_f2 - sp24); - if (D_800E2C94 != 0) { - func_800096D8(D_800E2C94, temp_f14, temp_f16, temp_f18); + length = 1152.0f - (f32) (gLightningFrequency >> 6); + cosOffset = cosine_s(D_80127C1C->trans.y_rotation) * length; + sineOffset = sine_s(D_80127C1C->trans.y_rotation) * length; + xPos = D_80127C1C->trans.x_position + (sineOffset - cosOffset); + yPos = D_80127C1C->trans.y_position; + zPos = D_80127C1C->trans.z_position + (-sineOffset - cosOffset); + if (gWeatherSoundMask) { + func_800096D8(gWeatherSoundMask, xPos, yPos, zPos); } else { - func_80009558(574, temp_f14, temp_f16, temp_f18, 1, &D_800E2C94); + func_80009558(SOUND_RAIN, xPos, yPos, zPos, 1, &gWeatherSoundMask); } } -GLOBAL_ASM("asm/non_matchings/game_ui/func_800ADCBC.s") +GLOBAL_ASM("asm/non_matchings/game_ui/render_rain_overlay.s") diff --git a/src/weather.h b/src/weather.h index 763e683f..e86bf97f 100644 --- a/src/weather.h +++ b/src/weather.h @@ -5,6 +5,11 @@ #include "textures_sprites.h" #include "audio.h" +typedef enum WeatherType { + WEATHER_SNOW, + WEATHER_RAIN +} WeatherType; + typedef struct unk800E2850_unk0 { s32 unk0; s32 unk4; @@ -81,21 +86,21 @@ extern u32 osTvType; void func_800AB308(s16 arg0, s16 arg1); void func_800AC880(s32 arg0); void func_800ACF60(Object *arg0); -void func_800AD220(void); +void free_rain_memory(void); void func_800AD2C4(s32 arg0, s32 arg1, f32 arg2); void func_800AD40C(void); -void func_800AD4B8(s32 arg0); -void func_800ADBC8(s32); -void func_800AD658(s32); -void func_800ADAB8(s32); -void func_800ADCBC(unk800E2C2C*, s32); -void func_800ABE68(Gfx **currDisplayList, Mtx **currHudMat, VertexList **currHudVerts, TriangleList **currHudTris, s32 updateRate); +void handle_weather_rain(s32 updateRate); +void handle_rain_sound(s32 updateRate); +void render_rain_splashes(s32 updateRate); +void handle_rain_lightning(s32 updateRate); +void render_rain_overlay(unk800E2C2C*, s32); +void process_weather(Gfx **currDisplayList, Mtx **currHudMat, VertexList **currHudVerts, TriangleList **currHudTris, s32 updateRate); f32 cosine_s(s16); f32 sine_s(s16); s32 func_8007082C(s16); s32 func_80070830(s16); -void func_800AB35C(void); +void free_weather_memory(void); void func_800AB1F0(void); s32 func_800AC0C8(s32, unk80127BF8 *); void func_8006F6EC(Matrix *arg0, Matrix *arg1, Matrix *arg2); diff --git a/tools/dkr_assets_tool_classes/builder/build_files/build_levelheader.cpp b/tools/dkr_assets_tool_classes/builder/build_files/build_levelheader.cpp index d121e87a..0f741f83 100644 --- a/tools/dkr_assets_tool_classes/builder/build_files/build_levelheader.cpp +++ b/tools/dkr_assets_tool_classes/builder/build_files/build_levelheader.cpp @@ -17,7 +17,7 @@ int get_bitfield_from_enum_values(std::string &srcPath, std::string propertyName BuildLevelHeader::BuildLevelHeader(std::string srcPath, std::string dstPath) { std::vector out(SIZEOF_LEVEL_HEADER); - + // World ID out[0] = get_enum_value_from_string("World", get_string_from_json(srcPath, "world")); @@ -77,13 +77,13 @@ BuildLevelHeader::BuildLevelHeader(std::string srcPath, std::string dstPath) { } // Weather values currently unknown. - write_big_endian_halfword(out, 0x90, get_int_from_json(srcPath, "unknown-data", "weather", "unk90")); - write_big_endian_halfword(out, 0x92, get_int_from_json(srcPath, "unknown-data", "weather", "unk92")); - out[0x94] = get_int_from_json(srcPath, "unknown-data", "weather", "unk94"); - out[0x95] = get_int_from_json(srcPath, "unknown-data", "weather", "unk95"); - write_big_endian_halfword(out, 0x96, get_int_from_json(srcPath, "unknown-data", "weather", "unk96")); - write_big_endian_halfword(out, 0x98, get_int_from_json(srcPath, "unknown-data", "weather", "unk98")); - write_big_endian_halfword(out, 0x9A, get_int_from_json(srcPath, "unknown-data", "weather", "unk9A")); + write_big_endian_halfword(out, 0x90, get_int_from_json(srcPath, "unknown-data", "weather", "particle-density")); + write_big_endian_halfword(out, 0x92, get_int_from_json(srcPath, "unknown-data", "weather", "type")); + out[0x94] = get_int_from_json(srcPath, "unknown-data", "weather", "intensity"); + out[0x95] = get_int_from_json(srcPath, "unknown-data", "weather", "opacity"); + write_big_endian_halfword(out, 0x96, get_int_from_json(srcPath, "unknown-data", "weather", "x-velocity")); + write_big_endian_halfword(out, 0x98, get_int_from_json(srcPath, "unknown-data", "weather", "y-velocity")); + write_big_endian_halfword(out, 0x9A, get_int_from_json(srcPath, "unknown-data", "weather", "z-velocity")); // Field of view out[0x9C] = get_int_from_json(srcPath, "fov"); @@ -107,10 +107,10 @@ BuildLevelHeader::BuildLevelHeader(std::string srcPath, std::string dstPath) { GET_UNKNOWN_VALUES(out, 0xB0, 0xC4, "unkB0"); write_big_endian_word(out, 0xC4, get_int_from_json(srcPath, "unknown-data", "unkC4")); - + write_binary_file(out, dstPath); } BuildLevelHeader::~BuildLevelHeader() { - + } diff --git a/tools/dkr_assets_tool_classes/extractor/extract/extract_levelheader.cpp b/tools/dkr_assets_tool_classes/extractor/extract/extract_levelheader.cpp index ea0cd7b4..53271eba 100644 --- a/tools/dkr_assets_tool_classes/extractor/extract/extract_levelheader.cpp +++ b/tools/dkr_assets_tool_classes/extractor/extract/extract_levelheader.cpp @@ -95,13 +95,13 @@ ExtractLevelHeader::ExtractLevelHeader(std::string key, std::vector dat out["unknown-data"]["unk74"].append(ptr); } out["unknown-data"]["weather"] = json::Object(); - out["unknown-data"]["weather"]["unk90"] = (int)get_big_endian_halfword(data, 0x90); - out["unknown-data"]["weather"]["unk92"] = (int)get_big_endian_halfword(data, 0x92); - out["unknown-data"]["weather"]["unk94"] = data[0x94]; - out["unknown-data"]["weather"]["unk95"] = data[0x95]; - out["unknown-data"]["weather"]["unk96"] = (int)get_big_endian_halfword(data, 0x96); - out["unknown-data"]["weather"]["unk98"] = (int)get_big_endian_halfword(data, 0x98); - out["unknown-data"]["weather"]["unk9A"] = (int)get_big_endian_halfword(data, 0x9A); + out["unknown-data"]["weather"]["particle-density"] = (int)get_big_endian_halfword(data, 0x90); + out["unknown-data"]["weather"]["type"] = (int)get_big_endian_halfword(data, 0x92); + out["unknown-data"]["weather"]["intensity"] = data[0x94]; + out["unknown-data"]["weather"]["opacity"] = data[0x95]; + out["unknown-data"]["weather"]["x-velocity"] = (int)get_big_endian_halfword(data, 0x96); + out["unknown-data"]["weather"]["y-velocity"] = (int)get_big_endian_halfword(data, 0x98); + out["unknown-data"]["weather"]["z-velocity"] = (int)get_big_endian_halfword(data, 0x9A); out["fov"] = data[0x9C]; out["background-colour"] = json::Object(); out["background-colour"]["red"] = data[0x9D];