From 7042a3eab57b6c02b5f1bc84cb1ca32a305cbd5d Mon Sep 17 00:00:00 2001 From: MegaMech Date: Fri, 15 Jul 2022 01:44:33 -0600 Subject: [PATCH] Document game state related logic (#244) * Document game state logic * More namings --- asm/non_matchings/actors/func_80298D7C.s | 4 +- asm/non_matchings/actors/place_segment_06.s | 4 +- .../code_8001F980/func_80021B0C.s | 4 +- .../code_80027D00/func_80028E70.s | 4 +- .../code_800431B0/func_80053870.s | 4 +- .../code_800431B0/func_80055E68.s | 4 +- .../code_800431B0/func_80057114.s | 8 +- .../code_80057C60/func_80059AC8.s | 4 +- .../code_80057C60/func_8005A3C0.s | 4 +- .../code_80057C60/func_8005A74C.s | 32 ++-- .../code_8006E9C0/func_80070780.s | 40 ++--- .../code_80071F00/func_80078288.s | 4 +- .../code_80071F00/func_80078838.s | 4 +- .../code_80071F00/func_80080524.s | 4 +- .../code_80071F00/func_800808CC.s | 4 +- .../code_80071F00/func_8008241C.s | 4 +- .../code_80071F00/func_80082870.s | 8 +- .../code_80071F00/func_800845C8.s | 4 +- .../code_80071F00/func_800853DC.s | 4 +- .../code_80086E70/func_80087E08.s | 4 +- .../code_80091750/func_80099AEC.s | 4 +- .../code_80091750/func_8009CBE4.s | 4 +- .../code_80091750/func_8009CE64.s | 24 +-- .../code_80091750/func_800A474C.s | 4 +- .../code_80281FA0/func_8028336C.s | 4 +- .../code_80281FA0/func_80283430.s | 4 +- .../code_80281FA0/func_80283648.s | 4 +- asm/non_matchings/memory/load_course.s | 8 +- asm/non_matchings/menus/func_800B6178.s | 4 +- .../{func_800B29D8.s => main_menu_act.s} | 2 +- .../{func_800B053C.s => options_menu_act.s} | 2 +- ...nc_800B3554.s => player_select_menu_act.s} | 2 +- .../render_courses/func_8029122C.s | 2 +- asm/non_matchings/skybox/func_802A4A0C.s | 2 +- asm/non_matchings/skybox/func_802A4D18.s | 4 +- include/defines.h | 5 + include/variables.h | 2 +- src/actors.c | 112 ++++++------ src/actors.h | 6 +- src/camera_junk.c | 2 +- src/code_800029B0.c | 12 +- src/code_8001F980.c | 2 +- src/code_80027D00.c | 2 +- src/code_800431B0.c | 8 +- src/code_80057C60.c | 54 +++--- src/code_8006E9C0.c | 20 +-- src/code_80071F00.c | 18 +- src/code_80091750.c | 29 +-- src/code_800B45E0.c | 4 +- src/code_80280000.c | 25 +-- src/code_80280650.c | 7 +- src/code_80281C40.c | 6 +- src/code_80281FA0.c | 6 +- src/main.c | 169 +++++++++++------- src/main.h | 12 +- src/memory.c | 4 +- src/menus.c | 100 ++++++----- src/menus.h | 2 +- src/race_logic.c | 4 +- src/render_courses.c | 8 +- src/skybox_and_splitscreen.c | 94 +++++----- src/spawn_players.c | 4 +- src/staff_ghosts.c | 4 +- 63 files changed, 500 insertions(+), 447 deletions(-) rename asm/non_matchings/menus/{func_800B29D8.s => main_menu_act.s} (99%) rename asm/non_matchings/menus/{func_800B053C.s => options_menu_act.s} (99%) rename asm/non_matchings/menus/{func_800B3554.s => player_select_menu_act.s} (99%) diff --git a/asm/non_matchings/actors/func_80298D7C.s b/asm/non_matchings/actors/func_80298D7C.s index ba9f1ff60..b27a53218 100644 --- a/asm/non_matchings/actors/func_80298D7C.s +++ b/asm/non_matchings/actors/func_80298D7C.s @@ -30,13 +30,13 @@ glabel func_80298D7C /* 1023FC 80298DEC 252987E0 */ addiu $t1, %lo(D_802B87E0) # addiu $t1, $t1, -0x7820 /* 102400 80298DF0 8D210000 */ lw $at, ($t1) /* 102404 80298DF4 27A80088 */ addiu $t0, $sp, 0x88 -/* 102408 80298DF8 3C0D800E */ lui $t5, %hi(D_800DC50C) # $t5, 0x800e +/* 102408 80298DF8 3C0D800E */ lui $t5, %hi(gGamestate) # $t5, 0x800e /* 10240C 80298DFC AD010000 */ sw $at, ($t0) /* 102410 80298E00 95210004 */ lhu $at, 4($t1) /* 102414 80298E04 3C128015 */ lui $s2, %hi(gDisplayListHead) # $s2, 0x8015 /* 102418 80298E08 0080A025 */ move $s4, $a0 /* 10241C 80298E0C A5010004 */ sh $at, 4($t0) -/* 102420 80298E10 8DADC50C */ lw $t5, %lo(D_800DC50C)($t5) +/* 102420 80298E10 8DADC50C */ lw $t5, %lo(gGamestate)($t5) /* 102424 80298E14 24010009 */ li $at, 9 /* 102428 80298E18 00A0A825 */ move $s5, $a1 /* 10242C 80298E1C 15A10004 */ bne $t5, $at, .L80298E30 diff --git a/asm/non_matchings/actors/place_segment_06.s b/asm/non_matchings/actors/place_segment_06.s index e500f02aa..46ff05a0e 100644 --- a/asm/non_matchings/actors/place_segment_06.s +++ b/asm/non_matchings/actors/place_segment_06.s @@ -132,8 +132,8 @@ glabel L8029D73C /* 106D5C 8029D74C 27A50078 */ addiu $a1, $sp, 0x78 /* 106D60 8029D750 0C0A7B22 */ jal func_8029EC88 /* 106D64 8029D754 27A60080 */ addiu $a2, $sp, 0x80 -/* 106D68 8029D758 3C0E800E */ lui $t6, %hi(D_800DC50C) # $t6, 0x800e -/* 106D6C 8029D75C 8DCEC50C */ lw $t6, %lo(D_800DC50C)($t6) +/* 106D68 8029D758 3C0E800E */ lui $t6, %hi(gGamestate) # $t6, 0x800e +/* 106D6C 8029D75C 8DCEC50C */ lw $t6, %lo(gGamestate)($t6) /* 106D70 8029D760 000268C0 */ sll $t5, $v0, 3 /* 106D74 8029D764 01A26823 */ subu $t5, $t5, $v0 /* 106D78 8029D768 000D6900 */ sll $t5, $t5, 4 diff --git a/asm/non_matchings/code_8001F980/func_80021B0C.s b/asm/non_matchings/code_8001F980/func_80021B0C.s index 2cb7ebf9c..0eb35afa3 100644 --- a/asm/non_matchings/code_8001F980/func_80021B0C.s +++ b/asm/non_matchings/code_8001F980/func_80021B0C.s @@ -46,8 +46,8 @@ glabel func_80021B0C /* 0227BC 80021BBC 0C01B9F3 */ jal func_8006E7CC /* 0227C0 80021BC0 00003025 */ move $a2, $zero .L80021BC4: -/* 0227C4 80021BC4 3C0F800E */ lui $t7, %hi(D_800DC50C) # $t7, 0x800e -/* 0227C8 80021BC8 8DEFC50C */ lw $t7, %lo(D_800DC50C)($t7) +/* 0227C4 80021BC4 3C0F800E */ lui $t7, %hi(gGamestate) # $t7, 0x800e +/* 0227C8 80021BC8 8DEFC50C */ lw $t7, %lo(gGamestate)($t7) /* 0227CC 80021BCC 24010005 */ li $at, 5 /* 0227D0 80021BD0 3C04800E */ lui $a0, %hi(gPlayerOne) # $a0, 0x800e /* 0227D4 80021BD4 55E10025 */ bnel $t7, $at, .L80021C6C diff --git a/asm/non_matchings/code_80027D00/func_80028E70.s b/asm/non_matchings/code_80027D00/func_80028E70.s index 532537c7e..496bfb2ff 100644 --- a/asm/non_matchings/code_80027D00/func_80028E70.s +++ b/asm/non_matchings/code_80027D00/func_80028E70.s @@ -6,11 +6,11 @@ glabel func_80028E70 /* 029A80 80028E80 AFA70024 */ sw $a3, 0x24($sp) /* 029A84 80028E84 94820000 */ lhu $v0, ($a0) /* 029A88 80028E88 34018000 */ li $at, 32768 -/* 029A8C 80028E8C 3C0F800E */ lui $t7, %hi(D_800DC50C) # $t7, 0x800e +/* 029A8C 80028E8C 3C0F800E */ lui $t7, %hi(gGamestate) # $t7, 0x800e /* 029A90 80028E90 304E8000 */ andi $t6, $v0, 0x8000 /* 029A94 80028E94 55C1002E */ bnel $t6, $at, .L80028F50 /* 029A98 80028E98 8FBF0014 */ lw $ra, 0x14($sp) -/* 029A9C 80028E9C 8DEFC50C */ lw $t7, %lo(D_800DC50C)($t7) +/* 029A9C 80028E9C 8DEFC50C */ lw $t7, %lo(gGamestate)($t7) /* 029AA0 80028EA0 24010005 */ li $at, 5 /* 029AA4 80028EA4 30582000 */ andi $t8, $v0, 0x2000 /* 029AA8 80028EA8 55E1000D */ bnel $t7, $at, .L80028EE0 diff --git a/asm/non_matchings/code_800431B0/func_80053870.s b/asm/non_matchings/code_800431B0/func_80053870.s index bb31d33f2..508944ad6 100644 --- a/asm/non_matchings/code_800431B0/func_80053870.s +++ b/asm/non_matchings/code_800431B0/func_80053870.s @@ -57,8 +57,8 @@ glabel func_80053870 /* 054544 80053944 241E00E0 */ li $fp, 224 /* 054548 80053948 3C178016 */ lui $s7, %hi(D_80165C18) # $s7, 0x8016 /* 05454C 8005394C 3C148019 */ lui $s4, %hi(D_8018CF68) # $s4, 0x8019 -/* 054550 80053950 3C13800E */ lui $s3, %hi(D_800DC50C) # $s3, 0x800e -/* 054554 80053954 2673C50C */ addiu $s3, %lo(D_800DC50C) # addiu $s3, $s3, -0x3af4 +/* 054550 80053950 3C13800E */ lui $s3, %hi(gGamestate) # $s3, 0x800e +/* 054554 80053954 2673C50C */ addiu $s3, %lo(gGamestate) # addiu $s3, $s3, -0x3af4 /* 054558 80053958 2694CF68 */ addiu $s4, %lo(D_8018CF68) # addiu $s4, $s4, -0x3098 /* 05455C 8005395C 26F75C18 */ addiu $s7, %lo(D_80165C18) # addiu $s7, $s7, 0x5c18 /* 054560 80053960 24120009 */ li $s2, 9 diff --git a/asm/non_matchings/code_800431B0/func_80055E68.s b/asm/non_matchings/code_800431B0/func_80055E68.s index a6b795c4f..41881fff7 100644 --- a/asm/non_matchings/code_800431B0/func_80055E68.s +++ b/asm/non_matchings/code_800431B0/func_80055E68.s @@ -1,6 +1,6 @@ glabel func_80055E68 -/* 056A68 80055E68 3C0E800E */ lui $t6, %hi(D_800DC50C) # $t6, 0x800e -/* 056A6C 80055E6C 8DCEC50C */ lw $t6, %lo(D_800DC50C)($t6) +/* 056A68 80055E68 3C0E800E */ lui $t6, %hi(gGamestate) # $t6, 0x800e +/* 056A6C 80055E6C 8DCEC50C */ lw $t6, %lo(gGamestate)($t6) /* 056A70 80055E70 27BDFFE0 */ addiu $sp, $sp, -0x20 /* 056A74 80055E74 AFB00018 */ sw $s0, 0x18($sp) /* 056A78 80055E78 3C108018 */ lui $s0, %hi(D_80183EA0) # $s0, 0x8018 diff --git a/asm/non_matchings/code_800431B0/func_80057114.s b/asm/non_matchings/code_800431B0/func_80057114.s index c9647480d..bcc1f898d 100644 --- a/asm/non_matchings/code_800431B0/func_80057114.s +++ b/asm/non_matchings/code_800431B0/func_80057114.s @@ -1,7 +1,7 @@ glabel func_80057114 /* 057D14 80057114 27BDFFC0 */ addiu $sp, $sp, -0x40 -/* 057D18 80057118 3C0E800E */ lui $t6, %hi(D_800DC50C) # $t6, 0x800e -/* 057D1C 8005711C 8DCEC50C */ lw $t6, %lo(D_800DC50C)($t6) +/* 057D18 80057118 3C0E800E */ lui $t6, %hi(gGamestate) # $t6, 0x800e +/* 057D1C 8005711C 8DCEC50C */ lw $t6, %lo(gGamestate)($t6) /* 057D20 80057120 AFBE0038 */ sw $fp, 0x38($sp) /* 057D24 80057124 24010005 */ li $at, 5 /* 057D28 80057128 0080F025 */ move $fp, $a0 @@ -47,8 +47,8 @@ glabel func_80057114 /* 057DC0 800571C0 1000000A */ b .L800571EC /* 057DC4 800571C4 A500004A */ sh $zero, 0x4a($t0) .L800571C8: -/* 057DC8 800571C8 3C09800E */ lui $t1, %hi(D_800DC50C) # $t1, 0x800e -/* 057DCC 800571CC 8D29C50C */ lw $t1, %lo(D_800DC50C)($t1) +/* 057DC8 800571C8 3C09800E */ lui $t1, %hi(gGamestate) # $t1, 0x800e +/* 057DCC 800571CC 8D29C50C */ lw $t1, %lo(gGamestate)($t1) /* 057DD0 800571D0 24010005 */ li $at, 5 /* 057DD4 800571D4 11210005 */ beq $t1, $at, .L800571EC /* 057DD8 800571D8 00000000 */ nop diff --git a/asm/non_matchings/code_80057C60/func_80059AC8.s b/asm/non_matchings/code_80057C60/func_80059AC8.s index 60001e819..69e9ef65d 100644 --- a/asm/non_matchings/code_80057C60/func_80059AC8.s +++ b/asm/non_matchings/code_80057C60/func_80059AC8.s @@ -38,7 +38,7 @@ glabel func_80059AC8 /* 05A754 80059B54 3C02800E */ lui $v0, %hi(gScreenModeSelection) # $v0, 0x800e /* 05A758 80059B58 8C42C530 */ lw $v0, %lo(gScreenModeSelection)($v0) /* 05A75C 80059B5C 24010001 */ li $at, 1 -/* 05A760 80059B60 3C08800E */ lui $t0, %hi(D_800DC50C) # $t0, 0x800e +/* 05A760 80059B60 3C08800E */ lui $t0, %hi(gGamestate) # $t0, 0x800e /* 05A764 80059B64 10400009 */ beqz $v0, .L80059B8C /* 05A768 80059B68 00000000 */ nop /* 05A76C 80059B6C 10410020 */ beq $v0, $at, .L80059BF0 @@ -50,7 +50,7 @@ glabel func_80059AC8 /* 05A784 80059B84 10000028 */ b .L80059C28 /* 05A788 80059B88 00000000 */ nop .L80059B8C: -/* 05A78C 80059B8C 8D08C50C */ lw $t0, %lo(D_800DC50C)($t0) +/* 05A78C 80059B8C 8D08C50C */ lw $t0, %lo(gGamestate)($t0) /* 05A790 80059B90 24010009 */ li $at, 9 /* 05A794 80059B94 1101000C */ beq $t0, $at, .L80059BC8 /* 05A798 80059B98 00000000 */ nop diff --git a/asm/non_matchings/code_80057C60/func_8005A3C0.s b/asm/non_matchings/code_80057C60/func_8005A3C0.s index a2c120303..6cf331b51 100644 --- a/asm/non_matchings/code_80057C60/func_8005A3C0.s +++ b/asm/non_matchings/code_80057C60/func_8005A3C0.s @@ -1,6 +1,6 @@ glabel func_8005A3C0 -/* 05AFC0 8005A3C0 3C02800E */ lui $v0, %hi(D_800DC50C) # $v0, 0x800e -/* 05AFC4 8005A3C4 8C42C50C */ lw $v0, %lo(D_800DC50C)($v0) +/* 05AFC0 8005A3C0 3C02800E */ lui $v0, %hi(gGamestate) # $v0, 0x800e +/* 05AFC4 8005A3C4 8C42C50C */ lw $v0, %lo(gGamestate)($v0) /* 05AFC8 8005A3C8 27BDFFE8 */ addiu $sp, $sp, -0x18 /* 05AFCC 8005A3CC 24010005 */ li $at, 5 /* 05AFD0 8005A3D0 AFBF0014 */ sw $ra, 0x14($sp) diff --git a/asm/non_matchings/code_80057C60/func_8005A74C.s b/asm/non_matchings/code_80057C60/func_8005A74C.s index c64f893b7..0f130acb2 100644 --- a/asm/non_matchings/code_80057C60/func_8005A74C.s +++ b/asm/non_matchings/code_80057C60/func_8005A74C.s @@ -19,8 +19,8 @@ glabel L8005A77C /* 05B38C 8005A78C 10000070 */ b .L8005A950 /* 05B390 8005A790 00000000 */ nop glabel L8005A794 -/* 05B394 8005A794 3C0F800E */ lui $t7, %hi(D_800DC50C) # $t7, 0x800e -/* 05B398 8005A798 8DEFC50C */ lw $t7, %lo(D_800DC50C)($t7) +/* 05B394 8005A794 3C0F800E */ lui $t7, %hi(gGamestate) # $t7, 0x800e +/* 05B398 8005A798 8DEFC50C */ lw $t7, %lo(gGamestate)($t7) /* 05B39C 8005A79C 24010009 */ li $at, 9 /* 05B3A0 8005A7A0 11E1006B */ beq $t7, $at, .L8005A950 /* 05B3A4 8005A7A4 00000000 */ nop @@ -45,8 +45,8 @@ glabel L8005A794 glabel L8005A7EC /* 05B3EC 8005A7EC 0C020C20 */ jal func_80083080 /* 05B3F0 8005A7F0 00000000 */ nop -/* 05B3F4 8005A7F4 3C19800E */ lui $t9, %hi(D_800DC50C) # $t9, 0x800e -/* 05B3F8 8005A7F8 8F39C50C */ lw $t9, %lo(D_800DC50C)($t9) +/* 05B3F4 8005A7F4 3C19800E */ lui $t9, %hi(gGamestate) # $t9, 0x800e +/* 05B3F8 8005A7F8 8F39C50C */ lw $t9, %lo(gGamestate)($t9) /* 05B3FC 8005A7FC 24010009 */ li $at, 9 /* 05B400 8005A800 13210053 */ beq $t9, $at, .L8005A950 /* 05B404 8005A804 00000000 */ nop @@ -55,8 +55,8 @@ glabel L8005A7EC /* 05B410 8005A810 1000004F */ b .L8005A950 /* 05B414 8005A814 00000000 */ nop glabel L8005A818 -/* 05B418 8005A818 3C08800E */ lui $t0, %hi(D_800DC50C) # $t0, 0x800e -/* 05B41C 8005A81C 8D08C50C */ lw $t0, %lo(D_800DC50C)($t0) +/* 05B418 8005A818 3C08800E */ lui $t0, %hi(gGamestate) # $t0, 0x800e +/* 05B41C 8005A81C 8D08C50C */ lw $t0, %lo(gGamestate)($t0) /* 05B420 8005A820 24010009 */ li $at, 9 /* 05B424 8005A824 11010003 */ beq $t0, $at, .L8005A834 /* 05B428 8005A828 00000000 */ nop @@ -68,8 +68,8 @@ glabel L8005A818 /* 05B43C 8005A83C 10000044 */ b .L8005A950 /* 05B440 8005A840 00000000 */ nop glabel L8005A844 -/* 05B444 8005A844 3C09800E */ lui $t1, %hi(D_800DC50C) # $t1, 0x800e -/* 05B448 8005A848 8D29C50C */ lw $t1, %lo(D_800DC50C)($t1) +/* 05B444 8005A844 3C09800E */ lui $t1, %hi(gGamestate) # $t1, 0x800e +/* 05B448 8005A848 8D29C50C */ lw $t1, %lo(gGamestate)($t1) /* 05B44C 8005A84C 24010009 */ li $at, 9 /* 05B450 8005A850 11210003 */ beq $t1, $at, .L8005A860 /* 05B454 8005A854 00000000 */ nop @@ -82,8 +82,8 @@ glabel L8005A844 /* 05B46C 8005A86C 10410007 */ beq $v0, $at, .L8005A88C /* 05B470 8005A870 24010002 */ li $at, 2 /* 05B474 8005A874 10410005 */ beq $v0, $at, .L8005A88C -/* 05B478 8005A878 3C0A800E */ lui $t2, %hi(D_800DC50C) # $t2, 0x800e -/* 05B47C 8005A87C 8D4AC50C */ lw $t2, %lo(D_800DC50C)($t2) +/* 05B478 8005A878 3C0A800E */ lui $t2, %hi(gGamestate) # $t2, 0x800e +/* 05B47C 8005A87C 8D4AC50C */ lw $t2, %lo(gGamestate)($t2) /* 05B480 8005A880 24010009 */ li $at, 9 /* 05B484 8005A884 15410032 */ bne $t2, $at, .L8005A950 /* 05B488 8005A888 00000000 */ nop @@ -102,8 +102,8 @@ glabel L8005A89C /* 05B4B4 8005A8B4 10000026 */ b .L8005A950 /* 05B4B8 8005A8B8 00000000 */ nop glabel L8005A8BC -/* 05B4BC 8005A8BC 3C0C800E */ lui $t4, %hi(D_800DC50C) # $t4, 0x800e -/* 05B4C0 8005A8C0 8D8CC50C */ lw $t4, %lo(D_800DC50C)($t4) +/* 05B4BC 8005A8BC 3C0C800E */ lui $t4, %hi(gGamestate) # $t4, 0x800e +/* 05B4C0 8005A8C0 8D8CC50C */ lw $t4, %lo(gGamestate)($t4) /* 05B4C4 8005A8C4 24010009 */ li $at, 9 /* 05B4C8 8005A8C8 11810021 */ beq $t4, $at, .L8005A950 /* 05B4CC 8005A8CC 00000000 */ nop @@ -117,8 +117,8 @@ glabel L8005A8E0 /* 05B4E8 8005A8E8 10000019 */ b .L8005A950 /* 05B4EC 8005A8EC 00000000 */ nop glabel L8005A8F0 -/* 05B4F0 8005A8F0 3C0D800E */ lui $t5, %hi(D_800DC50C) # $t5, 0x800e -/* 05B4F4 8005A8F4 8DADC50C */ lw $t5, %lo(D_800DC50C)($t5) +/* 05B4F0 8005A8F0 3C0D800E */ lui $t5, %hi(gGamestate) # $t5, 0x800e +/* 05B4F4 8005A8F4 8DADC50C */ lw $t5, %lo(gGamestate)($t5) /* 05B4F8 8005A8F8 24010009 */ li $at, 9 /* 05B4FC 8005A8FC 11A10003 */ beq $t5, $at, .L8005A90C /* 05B500 8005A900 00000000 */ nop @@ -130,8 +130,8 @@ glabel L8005A8F0 /* 05B514 8005A914 1000000E */ b .L8005A950 /* 05B518 8005A918 00000000 */ nop glabel L8005A91C -/* 05B51C 8005A91C 3C0E800E */ lui $t6, %hi(D_800DC50C) # $t6, 0x800e -/* 05B520 8005A920 8DCEC50C */ lw $t6, %lo(D_800DC50C)($t6) +/* 05B51C 8005A91C 3C0E800E */ lui $t6, %hi(gGamestate) # $t6, 0x800e +/* 05B520 8005A920 8DCEC50C */ lw $t6, %lo(gGamestate)($t6) /* 05B524 8005A924 24010009 */ li $at, 9 /* 05B528 8005A928 11C10009 */ beq $t6, $at, .L8005A950 /* 05B52C 8005A92C 00000000 */ nop diff --git a/asm/non_matchings/code_8006E9C0/func_80070780.s b/asm/non_matchings/code_8006E9C0/func_80070780.s index d9188e4a4..1769a044b 100644 --- a/asm/non_matchings/code_8006E9C0/func_80070780.s +++ b/asm/non_matchings/code_8006E9C0/func_80070780.s @@ -19,8 +19,8 @@ glabel func_80070780 /* 0713C4 800707C4 01C00008 */ jr $t6 /* 0713C8 800707C8 00000000 */ nop glabel L800707CC -/* 0713CC 800707CC 3C0F800E */ lui $t7, %hi(D_800DC50C) # $t7, 0x800e -/* 0713D0 800707D0 8DEFC50C */ lw $t7, %lo(D_800DC50C)($t7) +/* 0713CC 800707CC 3C0F800E */ lui $t7, %hi(gGamestate) # $t7, 0x800e +/* 0713D0 800707D0 8DEFC50C */ lw $t7, %lo(gGamestate)($t7) /* 0713D4 800707D4 24010009 */ li $at, 9 /* 0713D8 800707D8 3C18800E */ lui $t8, %hi(gModeSelection) # $t8, 0x800e /* 0713DC 800707DC 51E10309 */ beql $t7, $at, .L80071404 @@ -215,8 +215,8 @@ glabel L80070848 /* 0716A0 80070AA0 10000258 */ b .L80071404 /* 0716A4 80070AA4 8FBF003C */ lw $ra, 0x3c($sp) glabel L80070AA8 -/* 0716A8 80070AA8 3C0A800E */ lui $t2, %hi(D_800DC50C) # $t2, 0x800e -/* 0716AC 80070AAC 8D4AC50C */ lw $t2, %lo(D_800DC50C)($t2) +/* 0716A8 80070AA8 3C0A800E */ lui $t2, %hi(gGamestate) # $t2, 0x800e +/* 0716AC 80070AAC 8D4AC50C */ lw $t2, %lo(gGamestate)($t2) /* 0716B0 80070AB0 24010009 */ li $at, 9 /* 0716B4 80070AB4 3C118018 */ lui $s1, %hi(D_80183EA0) # $s1, 0x8018 /* 0716B8 80070AB8 11410251 */ beq $t2, $at, .L80071400 @@ -262,8 +262,8 @@ glabel L80070B30 /* 071750 80070B50 0230082B */ sltu $at, $s1, $s0 /* 071754 80070B54 5420FFFB */ bnel $at, $zero, .L80070B44 /* 071758 80070B58 8E240000 */ lw $a0, ($s1) -/* 07175C 80070B5C 3C0E800E */ lui $t6, %hi(D_800DC50C) # $t6, 0x800e -/* 071760 80070B60 8DCEC50C */ lw $t6, %lo(D_800DC50C)($t6) +/* 07175C 80070B5C 3C0E800E */ lui $t6, %hi(gGamestate) # $t6, 0x800e +/* 071760 80070B60 8DCEC50C */ lw $t6, %lo(gGamestate)($t6) /* 071764 80070B64 24010009 */ li $at, 9 /* 071768 80070B68 3C128018 */ lui $s2, %hi(D_80183F28) # $s2, 0x8018 /* 07176C 80070B6C 11C10224 */ beq $t6, $at, .L80071400 @@ -340,8 +340,8 @@ glabel L80070C60 /* 07187C 80070C7C 0230082B */ sltu $at, $s1, $s0 /* 071880 80070C80 1420FFFB */ bnez $at, .L80070C70 /* 071884 80070C84 00000000 */ nop -/* 071888 80070C88 3C0E800E */ lui $t6, %hi(D_800DC50C) # $t6, 0x800e -/* 07188C 80070C8C 8DCEC50C */ lw $t6, %lo(D_800DC50C)($t6) +/* 071888 80070C88 3C0E800E */ lui $t6, %hi(gGamestate) # $t6, 0x800e +/* 07188C 80070C8C 8DCEC50C */ lw $t6, %lo(gGamestate)($t6) /* 071890 80070C90 24010009 */ li $at, 9 /* 071894 80070C94 3C118018 */ lui $s1, %hi(D_80183EA0) # $s1, 0x8018 /* 071898 80070C98 11C101D9 */ beq $t6, $at, .L80071400 @@ -426,8 +426,8 @@ glabel L80070C60 /* 0719D0 80070DD0 1000018C */ b .L80071404 /* 0719D4 80070DD4 8FBF003C */ lw $ra, 0x3c($sp) glabel L80070DD8 -/* 0719D8 80070DD8 3C0E800E */ lui $t6, %hi(D_800DC50C) # $t6, 0x800e -/* 0719DC 80070DDC 8DCEC50C */ lw $t6, %lo(D_800DC50C)($t6) +/* 0719D8 80070DD8 3C0E800E */ lui $t6, %hi(gGamestate) # $t6, 0x800e +/* 0719DC 80070DDC 8DCEC50C */ lw $t6, %lo(gGamestate)($t6) /* 0719E0 80070DE0 24010009 */ li $at, 9 /* 0719E4 80070DE4 3C118018 */ lui $s1, %hi(D_80183EA0) # $s1, 0x8018 /* 0719E8 80070DE8 11C1002B */ beq $t6, $at, .L80070E98 @@ -510,8 +510,8 @@ glabel L80070DD8 /* 071B08 80070F08 1000013E */ b .L80071404 /* 071B0C 80070F0C 8FBF003C */ lw $ra, 0x3c($sp) glabel L80070F10 -/* 071B10 80070F10 3C0E800E */ lui $t6, %hi(D_800DC50C) # $t6, 0x800e -/* 071B14 80070F14 8DCEC50C */ lw $t6, %lo(D_800DC50C)($t6) +/* 071B10 80070F10 3C0E800E */ lui $t6, %hi(gGamestate) # $t6, 0x800e +/* 071B14 80070F14 8DCEC50C */ lw $t6, %lo(gGamestate)($t6) /* 071B18 80070F18 24010009 */ li $at, 9 /* 071B1C 80070F1C 3C0F800E */ lui $t7, %hi(gModeSelection) # $t7, 0x800e /* 071B20 80070F20 51C10138 */ beql $t6, $at, .L80071404 @@ -544,8 +544,8 @@ glabel L80070F10 /* 071B84 80070F84 1000011F */ b .L80071404 /* 071B88 80070F88 8FBF003C */ lw $ra, 0x3c($sp) glabel L80070F8C -/* 071B8C 80070F8C 3C08800E */ lui $t0, %hi(D_800DC50C) # $t0, 0x800e -/* 071B90 80070F90 8D08C50C */ lw $t0, %lo(D_800DC50C)($t0) +/* 071B8C 80070F8C 3C08800E */ lui $t0, %hi(gGamestate) # $t0, 0x800e +/* 071B90 80070F90 8D08C50C */ lw $t0, %lo(gGamestate)($t0) /* 071B94 80070F94 24010009 */ li $at, 9 /* 071B98 80070F98 3C09800E */ lui $t1, %hi(gModeSelection) # $t1, 0x800e /* 071B9C 80070F9C 51010119 */ beql $t0, $at, .L80071404 @@ -585,8 +585,8 @@ glabel L80070F8C /* 071C1C 8007101C 100000F9 */ b .L80071404 /* 071C20 80071020 8FBF003C */ lw $ra, 0x3c($sp) glabel L80071024 -/* 071C24 80071024 3C0C800E */ lui $t4, %hi(D_800DC50C) # $t4, 0x800e -/* 071C28 80071028 8D8CC50C */ lw $t4, %lo(D_800DC50C)($t4) +/* 071C24 80071024 3C0C800E */ lui $t4, %hi(gGamestate) # $t4, 0x800e +/* 071C28 80071028 8D8CC50C */ lw $t4, %lo(gGamestate)($t4) /* 071C2C 8007102C 24010009 */ li $at, 9 /* 071C30 80071030 3C028019 */ lui $v0, %hi(D_8018EDF3) # $v0, 0x8019 /* 071C34 80071034 118100F2 */ beq $t4, $at, .L80071400 @@ -757,8 +757,8 @@ glabel L80071024 /* 071E98 80071298 1000005A */ b .L80071404 /* 071E9C 8007129C 8FBF003C */ lw $ra, 0x3c($sp) glabel L800712A0 -/* 071EA0 800712A0 3C0D800E */ lui $t5, %hi(D_800DC50C) # $t5, 0x800e -/* 071EA4 800712A4 8DADC50C */ lw $t5, %lo(D_800DC50C)($t5) +/* 071EA0 800712A0 3C0D800E */ lui $t5, %hi(gGamestate) # $t5, 0x800e +/* 071EA4 800712A4 8DADC50C */ lw $t5, %lo(gGamestate)($t5) /* 071EA8 800712A8 24010009 */ li $at, 9 /* 071EAC 800712AC 3C118019 */ lui $s1, %hi(D_8018CF10) # $s1, 0x8019 /* 071EB0 800712B0 11A10053 */ beq $t5, $at, .L80071400 @@ -817,8 +817,8 @@ glabel L80071348 /* 071F70 80071370 10000024 */ b .L80071404 /* 071F74 80071374 8FBF003C */ lw $ra, 0x3c($sp) glabel L80071378 -/* 071F78 80071378 3C0E800E */ lui $t6, %hi(D_800DC50C) # $t6, 0x800e -/* 071F7C 8007137C 8DCEC50C */ lw $t6, %lo(D_800DC50C)($t6) +/* 071F78 80071378 3C0E800E */ lui $t6, %hi(gGamestate) # $t6, 0x800e +/* 071F7C 8007137C 8DCEC50C */ lw $t6, %lo(gGamestate)($t6) /* 071F80 80071380 24010009 */ li $at, 9 /* 071F84 80071384 3C118018 */ lui $s1, %hi(D_80183EA0) # $s1, 0x8018 /* 071F88 80071388 11C1001D */ beq $t6, $at, .L80071400 diff --git a/asm/non_matchings/code_80071F00/func_80078288.s b/asm/non_matchings/code_80071F00/func_80078288.s index b62d87b3e..ca1216f94 100644 --- a/asm/non_matchings/code_80071F00/func_80078288.s +++ b/asm/non_matchings/code_80071F00/func_80078288.s @@ -13,7 +13,7 @@ glabel func_80078288 /* 078EB4 800782B4 10400108 */ beqz $v0, .L800786D8 /* 078EB8 800782B8 24010001 */ li $at, 1 /* 078EBC 800782BC 10410008 */ beq $v0, $at, .L800782E0 -/* 078EC0 800782C0 3C19800E */ lui $t9, %hi(D_800DC50C) # $t9, 0x800e +/* 078EC0 800782C0 3C19800E */ lui $t9, %hi(gGamestate) # $t9, 0x800e /* 078EC4 800782C4 24010002 */ li $at, 2 /* 078EC8 800782C8 104100E4 */ beq $v0, $at, .L8007865C /* 078ECC 800782CC 24010003 */ li $at, 3 @@ -22,7 +22,7 @@ glabel func_80078288 /* 078ED8 800782D8 10000100 */ b .L800786DC /* 078EDC 800782DC 8FBF001C */ lw $ra, 0x1c($sp) .L800782E0: -/* 078EE0 800782E0 8F39C50C */ lw $t9, %lo(D_800DC50C)($t9) +/* 078EE0 800782E0 8F39C50C */ lw $t9, %lo(gGamestate)($t9) /* 078EE4 800782E4 24010009 */ li $at, 9 /* 078EE8 800782E8 13210081 */ beq $t9, $at, .L800784F0 /* 078EEC 800782EC 3C08800E */ lui $t0, %hi(gPlayerOneCopy) # $t0, 0x800e diff --git a/asm/non_matchings/code_80071F00/func_80078838.s b/asm/non_matchings/code_80071F00/func_80078838.s index 94e23310b..bb5df8b6e 100644 --- a/asm/non_matchings/code_80071F00/func_80078838.s +++ b/asm/non_matchings/code_80071F00/func_80078838.s @@ -1,7 +1,7 @@ glabel func_80078838 /* 079438 80078838 27BDFFD8 */ addiu $sp, $sp, -0x28 -/* 07943C 8007883C 3C0E800E */ lui $t6, %hi(D_800DC50C) # $t6, 0x800e -/* 079440 80078840 8DCEC50C */ lw $t6, %lo(D_800DC50C)($t6) +/* 07943C 8007883C 3C0E800E */ lui $t6, %hi(gGamestate) # $t6, 0x800e +/* 079440 80078840 8DCEC50C */ lw $t6, %lo(gGamestate)($t6) /* 079444 80078844 24010009 */ li $at, 9 /* 079448 80078848 AFBF0024 */ sw $ra, 0x24($sp) /* 07944C 8007884C AFB30020 */ sw $s3, 0x20($sp) diff --git a/asm/non_matchings/code_80071F00/func_80080524.s b/asm/non_matchings/code_80071F00/func_80080524.s index 68f683560..d94d27393 100644 --- a/asm/non_matchings/code_80071F00/func_80080524.s +++ b/asm/non_matchings/code_80071F00/func_80080524.s @@ -56,11 +56,11 @@ glabel func_80080524 /* 0811FC 800805FC E6000020 */ swc1 $f0, 0x20($s0) /* 081200 80080600 3C0A800E */ lui $t2, %hi(gIsMirrorMode) # $t2, 0x800e /* 081204 80080604 8D4AC604 */ lw $t2, %lo(gIsMirrorMode)($t2) -/* 081208 80080608 3C0B800E */ lui $t3, %hi(D_800DC50C) # $t3, 0x800e +/* 081208 80080608 3C0B800E */ lui $t3, %hi(gGamestate) # $t3, 0x800e /* 08120C 8008060C 02202025 */ move $a0, $s1 /* 081210 80080610 15400006 */ bnez $t2, .L8008062C /* 081214 80080614 00002825 */ move $a1, $zero -/* 081218 80080618 8D6BC50C */ lw $t3, %lo(D_800DC50C)($t3) +/* 081218 80080618 8D6BC50C */ lw $t3, %lo(gGamestate)($t3) /* 08121C 8008061C 24010009 */ li $at, 9 /* 081220 80080620 24064000 */ li $a2, 16384 /* 081224 80080624 15610006 */ bne $t3, $at, .L80080640 diff --git a/asm/non_matchings/code_80071F00/func_800808CC.s b/asm/non_matchings/code_80071F00/func_800808CC.s index 8ba25f793..97f58fa2d 100644 --- a/asm/non_matchings/code_80071F00/func_800808CC.s +++ b/asm/non_matchings/code_80071F00/func_800808CC.s @@ -48,8 +48,8 @@ glabel func_800808CC /* 081574 80080974 8FA40028 */ lw $a0, 0x28($sp) /* 081578 80080978 0C01CD45 */ jal func_80073514 /* 08157C 8008097C 8FA40028 */ lw $a0, 0x28($sp) -/* 081580 80080980 3C0A800E */ lui $t2, %hi(D_800DC50C) # $t2, 0x800e -/* 081584 80080984 8D4AC50C */ lw $t2, %lo(D_800DC50C)($t2) +/* 081580 80080980 3C0A800E */ lui $t2, %hi(gGamestate) # $t2, 0x800e +/* 081584 80080984 8D4AC50C */ lw $t2, %lo(gGamestate)($t2) /* 081588 80080988 24010009 */ li $at, 9 /* 08158C 8008098C 8FA80020 */ lw $t0, 0x20($sp) /* 081590 80080990 1141000F */ beq $t2, $at, .L800809D0 diff --git a/asm/non_matchings/code_80071F00/func_8008241C.s b/asm/non_matchings/code_80071F00/func_8008241C.s index 8ebffde07..45311e1e7 100644 --- a/asm/non_matchings/code_80071F00/func_8008241C.s +++ b/asm/non_matchings/code_80071F00/func_8008241C.s @@ -60,8 +60,8 @@ glabel func_8008241C /* 0830FC 800824FC 3C01C059 */ li $at, 0xC0590000 # -3.390625 /* 083100 80082500 44818800 */ mtc1 $at, $f17 /* 083104 80082504 44808000 */ mtc1 $zero, $f16 -/* 083108 80082508 3C19800E */ lui $t9, %hi(D_800DC50C) # $t9, 0x800e -/* 08310C 8008250C 8F39C50C */ lw $t9, %lo(D_800DC50C)($t9) +/* 083108 80082508 3C19800E */ lui $t9, %hi(gGamestate) # $t9, 0x800e +/* 08310C 8008250C 8F39C50C */ lw $t9, %lo(gGamestate)($t9) /* 083110 80082510 46305480 */ add.d $f18, $f10, $f16 /* 083114 80082514 24010009 */ li $at, 9 /* 083118 80082518 4620910D */ trunc.w.d $f4, $f18 diff --git a/asm/non_matchings/code_80071F00/func_80082870.s b/asm/non_matchings/code_80071F00/func_80082870.s index 9c78b73c7..474c76451 100644 --- a/asm/non_matchings/code_80071F00/func_80082870.s +++ b/asm/non_matchings/code_80071F00/func_80082870.s @@ -45,14 +45,14 @@ glabel func_80082870 /* 083518 80082918 0C01C8B3 */ jal func_800722CC /* 08351C 8008291C 24050002 */ li $a1, 2 /* 083520 80082920 83D80000 */ lb $t8, ($fp) -/* 083524 80082924 3C19800E */ lui $t9, %hi(D_800DC50C) # $t9, 0x800e +/* 083524 80082924 3C19800E */ lui $t9, %hi(gGamestate) # $t9, 0x800e /* 083528 80082928 5300001D */ beql $t8, $zero, .L800829A0 /* 08352C 8008292C 26730001 */ addiu $s3, $s3, 1 /* 083530 80082930 A3C00000 */ sb $zero, ($fp) /* 083534 80082934 E6540000 */ swc1 $f20, ($s2) /* 083538 80082938 E6540004 */ swc1 $f20, 4($s2) /* 08353C 8008293C E6540008 */ swc1 $f20, 8($s2) -/* 083540 80082940 8F39C50C */ lw $t9, %lo(D_800DC50C)($t9) +/* 083540 80082940 8F39C50C */ lw $t9, %lo(gGamestate)($t9) /* 083544 80082944 24010009 */ li $at, 9 /* 083548 80082948 26240004 */ addiu $a0, $s1, 4 /* 08354C 8008294C 13210006 */ beq $t9, $at, .L80082968 @@ -85,14 +85,14 @@ glabel func_80082870 /* 0835AC 800829AC 3C038016 */ lui $v1, %hi(D_80165900) # $v1, 0x8016 /* 0835B0 800829B0 24635900 */ addiu $v1, %lo(D_80165900) # addiu $v1, $v1, 0x5900 /* 0835B4 800829B4 84620000 */ lh $v0, ($v1) -/* 0835B8 800829B8 3C0B800E */ lui $t3, %hi(D_800DC50C) # $t3, 0x800e +/* 0835B8 800829B8 3C0B800E */ lui $t3, %hi(gGamestate) # $t3, 0x800e /* 0835BC 800829BC 3C0E8016 */ lui $t6, %hi(D_80165908) # $t6, 0x8016 /* 0835C0 800829C0 10400003 */ beqz $v0, .L800829D0 /* 0835C4 800829C4 244AFFFF */ addiu $t2, $v0, -1 /* 0835C8 800829C8 10000011 */ b .L80082A10 /* 0835CC 800829CC A46A0000 */ sh $t2, ($v1) .L800829D0: -/* 0835D0 800829D0 8D6BC50C */ lw $t3, %lo(D_800DC50C)($t3) +/* 0835D0 800829D0 8D6BC50C */ lw $t3, %lo(gGamestate)($t3) /* 0835D4 800829D4 24010009 */ li $at, 9 /* 0835D8 800829D8 240C003C */ li $t4, 60 /* 0835DC 800829DC 11610003 */ beq $t3, $at, .L800829EC diff --git a/asm/non_matchings/code_80071F00/func_800845C8.s b/asm/non_matchings/code_80071F00/func_800845C8.s index 53a7d8ab0..17479fb96 100644 --- a/asm/non_matchings/code_80071F00/func_800845C8.s +++ b/asm/non_matchings/code_80071F00/func_800845C8.s @@ -169,8 +169,8 @@ glabel func_800845C8 /* 085440 80084840 03200008 */ jr $t9 /* 085444 80084844 00000000 */ nop glabel L80084848 -/* 085448 80084848 3C08800E */ lui $t0, %hi(D_800DC50C) # $t0, 0x800e -/* 08544C 8008484C 8D08C50C */ lw $t0, %lo(D_800DC50C)($t0) +/* 085448 80084848 3C08800E */ lui $t0, %hi(gGamestate) # $t0, 0x800e +/* 08544C 8008484C 8D08C50C */ lw $t0, %lo(gGamestate)($t0) /* 085450 80084850 24010009 */ li $at, 9 /* 085454 80084854 1101000F */ beq $t0, $at, .L80084894 /* 085458 80084858 3C018019 */ lui $at, %hi(D_8018D01C) # $at, 0x8019 diff --git a/asm/non_matchings/code_80071F00/func_800853DC.s b/asm/non_matchings/code_80071F00/func_800853DC.s index faf317075..ddef95aee 100644 --- a/asm/non_matchings/code_80071F00/func_800853DC.s +++ b/asm/non_matchings/code_80071F00/func_800853DC.s @@ -10,9 +10,9 @@ glabel func_800853DC /* 085FFC 800853FC 3C180601 */ lui $t8, %hi(D_0600F960) # $t8, 0x601 /* 086000 80085400 2718F960 */ addiu $t8, %lo(D_0600F960) # addiu $t8, $t8, -0x6a0 /* 086004 80085404 AC580070 */ sw $t8, 0x70($v0) -/* 086008 80085408 3C19800E */ lui $t9, %hi(D_800DC50C) # $t9, 0x800e +/* 086008 80085408 3C19800E */ lui $t9, %hi(gGamestate) # $t9, 0x800e /* 08600C 8008540C E4440000 */ swc1 $f4, ($v0) -/* 086010 80085410 8F39C50C */ lw $t9, %lo(D_800DC50C)($t9) +/* 086010 80085410 8F39C50C */ lw $t9, %lo(gGamestate)($t9) /* 086014 80085414 27BDFFD0 */ addiu $sp, $sp, -0x30 /* 086018 80085418 AFB00020 */ sw $s0, 0x20($sp) /* 08601C 8008541C 24010009 */ li $at, 9 diff --git a/asm/non_matchings/code_80086E70/func_80087E08.s b/asm/non_matchings/code_80086E70/func_80087E08.s index 191c16842..dea6646bf 100644 --- a/asm/non_matchings/code_80086E70/func_80087E08.s +++ b/asm/non_matchings/code_80086E70/func_80087E08.s @@ -103,8 +103,8 @@ glabel func_80087E08 /* 088B8C 80087F8C E446003C */ swc1 $f6, 0x3c($v0) /* 088B90 80087F90 0C021D47 */ jal func_8008751C /* 088B94 80087F94 A45800C0 */ sh $t8, 0xc0($v0) -/* 088B98 80087F98 3C01800E */ lui $at, %hi(D_800DC594) # $at, 0x800e -/* 088B9C 80087F9C C428C594 */ lwc1 $f8, %lo(D_800DC594)($at) +/* 088B98 80087F98 3C01800E */ lui $at, %hi(gVBlankTimer) # $at, 0x800e +/* 088B9C 80087F9C C428C594 */ lwc1 $f8, %lo(gVBlankTimer)($at) /* 088BA0 80087FA0 8FA20024 */ lw $v0, 0x24($sp) /* 088BA4 80087FA4 4600428D */ trunc.w.s $f10, $f8 /* 088BA8 80087FA8 44085000 */ mfc1 $t0, $f10 diff --git a/asm/non_matchings/code_80091750/func_80099AEC.s b/asm/non_matchings/code_80091750/func_80099AEC.s index 70288ee74..6ed12c8e4 100644 --- a/asm/non_matchings/code_80091750/func_80099AEC.s +++ b/asm/non_matchings/code_80091750/func_80099AEC.s @@ -1,7 +1,7 @@ glabel func_80099AEC /* 09A6EC 80099AEC 27BDFF68 */ addiu $sp, $sp, -0x98 -/* 09A6F0 80099AF0 3C0E800E */ lui $t6, %hi(D_800DC50C) # $t6, 0x800e -/* 09A6F4 80099AF4 8DCEC50C */ lw $t6, %lo(D_800DC50C)($t6) +/* 09A6F0 80099AF0 3C0E800E */ lui $t6, %hi(gGamestate) # $t6, 0x800e +/* 09A6F4 80099AF4 8DCEC50C */ lw $t6, %lo(gGamestate)($t6) /* 09A6F8 80099AF8 24010004 */ li $at, 4 /* 09A6FC 80099AFC AFBF004C */ sw $ra, 0x4c($sp) /* 09A700 80099B00 AFBE0048 */ sw $fp, 0x48($sp) diff --git a/asm/non_matchings/code_80091750/func_8009CBE4.s b/asm/non_matchings/code_80091750/func_8009CBE4.s index f4b502117..4cac21fcb 100644 --- a/asm/non_matchings/code_80091750/func_8009CBE4.s +++ b/asm/non_matchings/code_80091750/func_8009CBE4.s @@ -113,8 +113,8 @@ glabel func_8009CBE4 /* 09D984 8009CD84 8F380000 */ lw $t8, ($t9) /* 09D988 8009CD88 01D8082B */ sltu $at, $t6, $t8 /* 09D98C 8009CD8C 1420000E */ bnez $at, .L8009CDC8 -/* 09D990 8009CD90 3C0E800E */ lui $t6, %hi(D_800DC50C) # $t6, 0x800e -/* 09D994 8009CD94 8DCEC50C */ lw $t6, %lo(D_800DC50C)($t6) +/* 09D990 8009CD90 3C0E800E */ lui $t6, %hi(gGamestate) # $t6, 0x800e +/* 09D994 8009CD94 8DCEC50C */ lw $t6, %lo(gGamestate)($t6) /* 09D998 8009CD98 24010004 */ li $at, 4 /* 09D99C 8009CD9C 24190006 */ li $t9, 6 /* 09D9A0 8009CDA0 15C10004 */ bne $t6, $at, .L8009CDB4 diff --git a/asm/non_matchings/code_80091750/func_8009CE64.s b/asm/non_matchings/code_80091750/func_8009CE64.s index 195676f43..4851d1480 100644 --- a/asm/non_matchings/code_80091750/func_8009CE64.s +++ b/asm/non_matchings/code_80091750/func_8009CE64.s @@ -1,6 +1,6 @@ glabel func_8009CE64 -/* 09DA64 8009CE64 3C02800E */ lui $v0, %hi(D_800DC50C) # $v0, 0x800e -/* 09DA68 8009CE68 8C42C50C */ lw $v0, %lo(D_800DC50C)($v0) +/* 09DA64 8009CE64 3C02800E */ lui $v0, %hi(gGamestate) # $v0, 0x800e +/* 09DA68 8009CE68 8C42C50C */ lw $v0, %lo(gGamestate)($v0) /* 09DA6C 8009CE6C 27BDFFD0 */ addiu $sp, $sp, -0x30 /* 09DA70 8009CE70 24080005 */ li $t0, 5 /* 09DA74 8009CE74 AFBF0014 */ sw $ra, 0x14($sp) @@ -279,8 +279,8 @@ glabel L8009D22C /* 09DE38 8009D238 24050001 */ li $a1, 1 /* 09DE3C 8009D23C 3C018019 */ lui $at, %hi(D_8018EE08) # $at, 0x8019 /* 09DE40 8009D240 A025EE08 */ sb $a1, %lo(D_8018EE08)($at) -/* 09DE44 8009D244 3C01800E */ lui $at, %hi(D_800DC524) # $at, 0x800e -/* 09DE48 8009D248 AC29C524 */ sw $t1, %lo(D_800DC524)($at) +/* 09DE44 8009D244 3C01800E */ lui $at, %hi(gGamestateNext) # $at, 0x800e +/* 09DE48 8009D248 AC29C524 */ sw $t1, %lo(gGamestateNext)($at) /* 09DE4C 8009D24C 3C04800F */ lui $a0, %hi(gNextDemoId) # $a0, 0x800f /* 09DE50 8009D250 3C01800E */ lui $at, %hi(gCCSelection) # $at, 0x800e /* 09DE54 8009D254 248486BC */ addiu $a0, %lo(gNextDemoId) # addiu $a0, $a0, -0x7944 @@ -494,8 +494,8 @@ glabel L8009D50C .L8009D564: /* 09E164 8009D564 2841000E */ slti $at, $v0, 0xe /* 09E168 8009D568 14200009 */ bnez $at, .L8009D590 -/* 09E16C 8009D56C 3C01800E */ lui $at, %hi(D_800DC524) # $at, 0x800e -/* 09E170 8009D570 AC29C524 */ sw $t1, %lo(D_800DC524)($at) +/* 09E16C 8009D56C 3C01800E */ lui $at, %hi(gGamestateNext) # $at, 0x800e +/* 09E170 8009D570 AC29C524 */ sw $t1, %lo(gGamestateNext)($at) /* 09E174 8009D574 8D990000 */ lw $t9, ($t4) /* 09E178 8009D578 3C018019 */ lui $at, %hi(D_8018EDFB) # $at, 0x8019 /* 09E17C 8009D57C 14B90002 */ bne $a1, $t9, .L8009D588 @@ -514,7 +514,7 @@ glabel L8009D50C /* 09E1A4 8009D5A4 24050001 */ li $a1, 1 /* 09E1A8 8009D5A8 24060002 */ li $a2, 2 /* 09E1AC 8009D5AC 10650008 */ beq $v1, $a1, .L8009D5D0 -/* 09E1B0 8009D5B0 3C01800E */ lui $at, %hi(D_800DC524) # $at, 0x800e +/* 09E1B0 8009D5B0 3C01800E */ lui $at, %hi(gGamestateNext) # $at, 0x800e /* 09E1B4 8009D5B4 10660008 */ beq $v1, $a2, .L8009D5D8 /* 09E1B8 8009D5B8 240E0009 */ li $t6, 9 /* 09E1BC 8009D5BC 24070003 */ li $a3, 3 @@ -524,17 +524,17 @@ glabel L8009D50C /* 09E1CC 8009D5CC 258CC53C */ addiu $t4, %lo(gModeSelection) # addiu $t4, $t4, -0x3ac4 .L8009D5D0: /* 09E1D0 8009D5D0 1000000E */ b .L8009D60C -/* 09E1D4 8009D5D4 AC28C524 */ sw $t0, %lo(D_800DC524)($at) +/* 09E1D4 8009D5D4 AC28C524 */ sw $t0, %lo(gGamestateNext)($at) .L8009D5D8: -/* 09E1D8 8009D5D8 3C01800E */ lui $at, %hi(D_800DC524) # $at, 0x800e -/* 09E1DC 8009D5DC AC2EC524 */ sw $t6, %lo(D_800DC524)($at) +/* 09E1D8 8009D5D8 3C01800E */ lui $at, %hi(gGamestateNext) # $at, 0x800e +/* 09E1DC 8009D5DC AC2EC524 */ sw $t6, %lo(gGamestateNext)($at) /* 09E1E0 8009D5E0 3C01800E */ lui $at, %hi(gCreditsCourseId) # $at, 0x800e /* 09E1E4 8009D5E4 240F0008 */ li $t7, 8 /* 09E1E8 8009D5E8 10000008 */ b .L8009D60C /* 09E1EC 8009D5EC A42FC644 */ sh $t7, %lo(gCreditsCourseId)($at) .L8009D5F0: -/* 09E1F0 8009D5F0 3C01800E */ lui $at, %hi(D_800DC524) # $at, 0x800e -/* 09E1F4 8009D5F4 AC29C524 */ sw $t1, %lo(D_800DC524)($at) +/* 09E1F0 8009D5F0 3C01800E */ lui $at, %hi(gGamestateNext) # $at, 0x800e +/* 09E1F4 8009D5F4 AC29C524 */ sw $t1, %lo(gGamestateNext)($at) /* 09E1F8 8009D5F8 8D980000 */ lw $t8, ($t4) /* 09E1FC 8009D5FC 3C018019 */ lui $at, %hi(D_8018EDFB) # $at, 0x8019 /* 09E200 8009D600 14B80002 */ bne $a1, $t8, .L8009D60C diff --git a/asm/non_matchings/code_80091750/func_800A474C.s b/asm/non_matchings/code_80091750/func_800A474C.s index d9d28aa2a..4b5dbcc75 100644 --- a/asm/non_matchings/code_80091750/func_800A474C.s +++ b/asm/non_matchings/code_80091750/func_800A474C.s @@ -1,7 +1,7 @@ glabel func_800A474C /* 0A534C 800A474C 27BDFFB0 */ addiu $sp, $sp, -0x50 -/* 0A5350 800A4750 3C0E800E */ lui $t6, %hi(D_800DC50C) # $t6, 0x800e -/* 0A5354 800A4754 8DCEC50C */ lw $t6, %lo(D_800DC50C)($t6) +/* 0A5350 800A4750 3C0E800E */ lui $t6, %hi(gGamestate) # $t6, 0x800e +/* 0A5354 800A4754 8DCEC50C */ lw $t6, %lo(gGamestate)($t6) /* 0A5358 800A4758 24010004 */ li $at, 4 /* 0A535C 800A475C AFBF0024 */ sw $ra, 0x24($sp) /* 0A5360 800A4760 F7B40018 */ sdc1 $f20, 0x18($sp) diff --git a/asm/non_matchings/code_80281FA0/func_8028336C.s b/asm/non_matchings/code_80281FA0/func_8028336C.s index 1cb280a5e..718bcb707 100644 --- a/asm/non_matchings/code_80281FA0/func_8028336C.s +++ b/asm/non_matchings/code_80281FA0/func_8028336C.s @@ -17,8 +17,8 @@ glabel func_8028336C /* 1269E8 802833A8 1000001B */ b .L80283418 /* 1269EC 802833AC 00601025 */ move $v0, $v1 .L802833B0: -/* 1269F0 802833B0 3C03800E */ lui $v1, %hi(D_800DC50C) # $v1, 0x800e -/* 1269F4 802833B4 8C63C50C */ lw $v1, %lo(D_800DC50C)($v1) +/* 1269F0 802833B0 3C03800E */ lui $v1, %hi(gGamestate) # $v1, 0x800e +/* 1269F4 802833B4 8C63C50C */ lw $v1, %lo(gGamestate)($v1) /* 1269F8 802833B8 24010005 */ li $at, 5 /* 1269FC 802833BC 3C088028 */ lui $t0, %hi(D_802874F5) # $t0, 0x8028 /* 126A00 802833C0 10610006 */ beq $v1, $at, .L802833DC diff --git a/asm/non_matchings/code_80281FA0/func_80283430.s b/asm/non_matchings/code_80281FA0/func_80283430.s index 0dad203cb..57868aadb 100644 --- a/asm/non_matchings/code_80281FA0/func_80283430.s +++ b/asm/non_matchings/code_80281FA0/func_80283430.s @@ -99,8 +99,8 @@ glabel func_80283430 /* 126BEC 802835AC 26100014 */ addiu $s0, $s0, 0x14 /* 126BF0 802835B0 1612FFFA */ bne $s0, $s2, .L8028359C /* 126BF4 802835B4 26310014 */ addiu $s1, $s1, 0x14 -/* 126BF8 802835B8 3C0F800E */ lui $t7, %hi(D_800DC50C) # $t7, 0x800e -/* 126BFC 802835BC 8DEFC50C */ lw $t7, %lo(D_800DC50C)($t7) +/* 126BF8 802835B8 3C0F800E */ lui $t7, %hi(gGamestate) # $t7, 0x800e +/* 126BFC 802835BC 8DEFC50C */ lw $t7, %lo(gGamestate)($t7) /* 126C00 802835C0 3C018028 */ lui $at, %hi(D_802856C0) # $at, 0x8028 /* 126C04 802835C4 E43456C0 */ swc1 $f20, %lo(D_802856C0)($at) /* 126C08 802835C8 24010005 */ li $at, 5 diff --git a/asm/non_matchings/code_80281FA0/func_80283648.s b/asm/non_matchings/code_80281FA0/func_80283648.s index e0babac5c..fb86bc03f 100644 --- a/asm/non_matchings/code_80281FA0/func_80283648.s +++ b/asm/non_matchings/code_80281FA0/func_80283648.s @@ -161,8 +161,8 @@ glabel func_80283648 /* 126EDC 8028389C 24A576E0 */ addiu $a1, %lo(D_802876E0) # addiu $a1, $a1, 0x76e0 /* 126EE0 802838A0 0C0A0802 */ jal vec3f_copy_dupe /* 126EE4 802838A4 8FA40034 */ lw $a0, 0x34($sp) -/* 126EE8 802838A8 3C08800E */ lui $t0, %hi(D_800DC50C) # $t0, 0x800e -/* 126EEC 802838AC 8D08C50C */ lw $t0, %lo(D_800DC50C)($t0) +/* 126EE8 802838A8 3C08800E */ lui $t0, %hi(gGamestate) # $t0, 0x800e +/* 126EEC 802838AC 8D08C50C */ lw $t0, %lo(gGamestate)($t0) /* 126EF0 802838B0 24010009 */ li $at, 9 /* 126EF4 802838B4 3C09800E */ lui $t1, %hi(gIsMirrorMode) # $t1, 0x800e /* 126EF8 802838B8 1501000A */ bne $t0, $at, .L802838E4 diff --git a/asm/non_matchings/memory/load_course.s b/asm/non_matchings/memory/load_course.s index 7bd360d47..919cae264 100644 --- a/asm/non_matchings/memory/load_course.s +++ b/asm/non_matchings/memory/load_course.s @@ -6,8 +6,8 @@ glabel load_course /* 113F38 802AA928 000E7100 */ sll $t6, $t6, 4 /* 113F3C 802AA92C 01CF1021 */ addu $v0, $t6, $t7 /* 113F40 802AA930 27BDFFA0 */ addiu $sp, $sp, -0x60 -/* 113F44 802AA934 3C03800E */ lui $v1, %hi(D_800DC50C) # $v1, 0x800e -/* 113F48 802AA938 8C63C50C */ lw $v1, %lo(D_800DC50C)($v1) +/* 113F44 802AA934 3C03800E */ lui $v1, %hi(gGamestate) # $v1, 0x800e +/* 113F48 802AA938 8C63C50C */ lw $v1, %lo(gGamestate)($v1) /* 113F4C 802AA93C 8C580000 */ lw $t8, ($v0) /* 113F50 802AA940 8C590004 */ lw $t9, 4($v0) /* 113F54 802AA944 8C480008 */ lw $t0, 8($v0) @@ -51,8 +51,8 @@ glabel load_course /* 113FE0 802AA9D0 24040009 */ li $a0, 9 /* 113FE4 802AA9D4 0C0A9EE5 */ jal set_segment_base_addr /* 113FE8 802AA9D8 00402825 */ move $a1, $v0 -/* 113FEC 802AA9DC 3C08800E */ lui $t0, %hi(D_800DC50C) # $t0, 0x800e -/* 113FF0 802AA9E0 8D08C50C */ lw $t0, %lo(D_800DC50C)($t0) +/* 113FEC 802AA9DC 3C08800E */ lui $t0, %hi(gGamestate) # $t0, 0x800e +/* 113FF0 802AA9E0 8D08C50C */ lw $t0, %lo(gGamestate)($t0) /* 113FF4 802AA9E4 24010005 */ li $at, 5 /* 113FF8 802AA9E8 8FA40048 */ lw $a0, 0x48($sp) /* 113FFC 802AA9EC 11010006 */ beq $t0, $at, .L802AAA08 diff --git a/asm/non_matchings/menus/func_800B6178.s b/asm/non_matchings/menus/func_800B6178.s index f542cad2c..3603f9bb9 100644 --- a/asm/non_matchings/menus/func_800B6178.s +++ b/asm/non_matchings/menus/func_800B6178.s @@ -12,8 +12,8 @@ glabel func_800B6178 /* 0B6DA0 800B61A0 10000062 */ b .L800B632C /* 0B6DA4 800B61A4 2402FFFF */ li $v0, -1 .L800B61A8: -/* 0B6DA8 800B61A8 3C11800E */ lui $s1, %hi(D_800DC50C) # $s1, 0x800e -/* 0B6DAC 800B61AC 2631C50C */ addiu $s1, %lo(D_800DC50C) # addiu $s1, $s1, -0x3af4 +/* 0B6DA8 800B61A8 3C11800E */ lui $s1, %hi(gGamestate) # $s1, 0x800e +/* 0B6DAC 800B61AC 2631C50C */ addiu $s1, %lo(gGamestate) # addiu $s1, $s1, -0x3af4 /* 0B6DB0 800B61B0 8E2E0000 */ lw $t6, ($s1) /* 0B6DB4 800B61B4 24100004 */ li $s0, 4 /* 0B6DB8 800B61B8 AFA40030 */ sw $a0, 0x30($sp) diff --git a/asm/non_matchings/menus/func_800B29D8.s b/asm/non_matchings/menus/main_menu_act.s similarity index 99% rename from asm/non_matchings/menus/func_800B29D8.s rename to asm/non_matchings/menus/main_menu_act.s index 4f6119039..7746f6b0d 100644 --- a/asm/non_matchings/menus/func_800B29D8.s +++ b/asm/non_matchings/menus/main_menu_act.s @@ -6,7 +6,7 @@ glabel jpt_800F2DFC .word L800B32B4, L800B2F70 .section .text -glabel func_800B29D8 +glabel main_menu_act /* 0B35D8 800B29D8 27BDFFD0 */ addiu $sp, $sp, -0x30 /* 0B35DC 800B29DC AFBF0014 */ sw $ra, 0x14($sp) /* 0B35E0 800B29E0 AFA50034 */ sw $a1, 0x34($sp) diff --git a/asm/non_matchings/menus/func_800B053C.s b/asm/non_matchings/menus/options_menu_act.s similarity index 99% rename from asm/non_matchings/menus/func_800B053C.s rename to asm/non_matchings/menus/options_menu_act.s index 7c383d13c..2e0616c0e 100644 --- a/asm/non_matchings/menus/func_800B053C.s +++ b/asm/non_matchings/menus/options_menu_act.s @@ -52,7 +52,7 @@ glabel D_800F2D88 .double 4.2 .section .text -glabel func_800B053C +glabel options_menu_act /* 0B113C 800B053C 27BDFFC0 */ addiu $sp, $sp, -0x40 /* 0B1140 800B0540 AFBF001C */ sw $ra, 0x1c($sp) /* 0B1144 800B0544 AFA50044 */ sw $a1, 0x44($sp) diff --git a/asm/non_matchings/menus/func_800B3554.s b/asm/non_matchings/menus/player_select_menu_act.s similarity index 99% rename from asm/non_matchings/menus/func_800B3554.s rename to asm/non_matchings/menus/player_select_menu_act.s index a00cee842..6684b4a0d 100644 --- a/asm/non_matchings/menus/func_800B3554.s +++ b/asm/non_matchings/menus/player_select_menu_act.s @@ -1,4 +1,4 @@ -glabel func_800B3554 +glabel player_select_menu_act /* 0B4154 800B3554 27BDFFC0 */ addiu $sp, $sp, -0x40 /* 0B4158 800B3558 AFBF001C */ sw $ra, 0x1c($sp) /* 0B415C 800B355C AFB00018 */ sw $s0, 0x18($sp) diff --git a/asm/non_matchings/render_courses/func_8029122C.s b/asm/non_matchings/render_courses/func_8029122C.s index 57ae34b38..dba895068 100644 --- a/asm/non_matchings/render_courses/func_8029122C.s +++ b/asm/non_matchings/render_courses/func_8029122C.s @@ -4,7 +4,7 @@ glabel func_8029122C /* 0FA844 80291234 AFA40270 */ sw $a0, 0x270($sp) /* 0FA848 80291238 8C8F0008 */ lw $t7, 8($a0) /* 0FA84C 8029123C AFA50274 */ sw $a1, 0x274($sp) -/* 0FA850 80291240 0C0A8F8F */ jal func_802A3E3C +/* 0FA850 80291240 0C0A8F8F */ jal init_rdp /* 0FA854 80291244 AFAF0268 */ sw $t7, 0x268($sp) /* 0FA858 80291248 8FA80270 */ lw $t0, 0x270($sp) /* 0FA85C 8029124C 8FA50274 */ lw $a1, 0x274($sp) diff --git a/asm/non_matchings/skybox/func_802A4A0C.s b/asm/non_matchings/skybox/func_802A4A0C.s index 0adf97bb2..0b7f9c6b8 100644 --- a/asm/non_matchings/skybox/func_802A4A0C.s +++ b/asm/non_matchings/skybox/func_802A4A0C.s @@ -88,7 +88,7 @@ glabel func_802A4A0C /* 10E174 802A4B64 A60D0012 */ sh $t5, 0x12($s0) /* 10E178 802A4B68 A60D0022 */ sh $t5, 0x22($s0) /* 10E17C 802A4B6C A60D0042 */ sh $t5, 0x42($s0) -/* 10E180 802A4B70 0C0A8F8F */ jal func_802A3E3C +/* 10E180 802A4B70 0C0A8F8F */ jal init_rdp /* 10E184 802A4B74 A60D0072 */ sh $t5, 0x72($s0) /* 10E188 802A4B78 3C038015 */ lui $v1, %hi(gDisplayListHead) # $v1, 0x8015 /* 10E18C 802A4B7C 24630298 */ addiu $v1, %lo(gDisplayListHead) # addiu $v1, $v1, 0x298 diff --git a/asm/non_matchings/skybox/func_802A4D18.s b/asm/non_matchings/skybox/func_802A4D18.s index 403698446..55c4855cb 100644 --- a/asm/non_matchings/skybox/func_802A4D18.s +++ b/asm/non_matchings/skybox/func_802A4D18.s @@ -1,6 +1,6 @@ glabel func_802A4D18 -/* 10E328 802A4D18 3C0E800E */ lui $t6, %hi(D_800DC50C) # $t6, 0x800e -/* 10E32C 802A4D1C 8DCEC50C */ lw $t6, %lo(D_800DC50C)($t6) +/* 10E328 802A4D18 3C0E800E */ lui $t6, %hi(gGamestate) # $t6, 0x800e +/* 10E32C 802A4D1C 8DCEC50C */ lw $t6, %lo(gGamestate)($t6) /* 10E330 802A4D20 24010004 */ li $at, 4 /* 10E334 802A4D24 3C0F800E */ lui $t7, %hi(gCurrentCourseId) # $t7, 0x800e /* 10E338 802A4D28 11C10009 */ beq $t6, $at, .L802A4D50 diff --git a/include/defines.h b/include/defines.h index 92942154c..3a55604b0 100644 --- a/include/defines.h +++ b/include/defines.h @@ -28,6 +28,11 @@ #define FOUR_PLAYERS_SELECTED 4 #define SELECTED_PLAYER_DEFINES_TOTAL 5 +#define PLAYER_ONE 0 +#define PLAYER_TWO 1 +#define PLAYER_THREE 2 +#define PLAYER_FOUR 3 + // 2P Game has Grand Prix, VS, and Battle as available game types #define MAX_NUM_MAIN_MENU_GAME_TYPES 3 diff --git a/include/variables.h b/include/variables.h index 7210c8a60..84a7ebc1f 100644 --- a/include/variables.h +++ b/include/variables.h @@ -105,7 +105,7 @@ extern Vp D_802B8880[]; extern Gfx D_0D0077A0[]; -extern s32 D_800DC50C; +extern s32 gGamestate; extern u16 D_800DC51C; extern s32 D_800DC540; extern u16 D_800DC5FC; diff --git a/src/actors.c b/src/actors.c index 75bfa69d1..be1d77542 100644 --- a/src/actors.c +++ b/src/actors.c @@ -400,7 +400,7 @@ void func_80297340(Camera *arg0) { Mat4 sp38; s16 temp = D_8015F8D0[2]; - if (D_800DC50C == CREDITS_SEQUENCE) { return; } + if (gGamestate == CREDITS_SEQUENCE) { return; } mtxf_translate(sp38, D_8015F8D0); @@ -715,8 +715,8 @@ void update_obj_train_engine(struct TrainCar *arg0) { } // wheels -void update_obj_train_car1(struct TrainCar *arg0) { - arg0->wheelRot -= 0x4FA; +void update_obj_train_car1(struct TrainCar *tender) { + tender->wheelRot -= 0x4FA; } // wheels @@ -1128,7 +1128,7 @@ void func_80298D7C(Camera *camera, f32 (*arg1)[4], struct Actor *arg2) { sp88.unk0 = (s32) D_802B87E0.unk0; sp88.unk4 = (u16) D_802B87E0.unk4; phi_s1 = temp_s1; - if (D_800DC50C == 9) { + if (gGamestate == 9) { phi_f22 = D_802B9650; } else { phi_f22 = D_802B9654; @@ -1614,18 +1614,18 @@ void update_obj_wario_stadium_sign(struct Actor *arg0) { /** * If train close activate bell sound according to timing **/ -void update_obj_railroad_crossing(struct RailroadCrossing *arg0) { +void update_obj_railroad_crossing(struct RailroadCrossing *crossing) { // If train close? - if (D_801637B8[arg0->crossingId] != 0) { + if (D_801637B8[crossing->crossingId] != 0) { // Timer++ - arg0->someTimer++; + crossing->someTimer++; // Reset timer - if (arg0->someTimer > 40) { - arg0->someTimer = 1; + if (crossing->someTimer > 40) { + crossing->someTimer = 1; } // Play Bell sound when timer hits 20 or 1. - if ((arg0->someTimer == 1) || (arg0->someTimer == 20)) { - func_800C98B8(arg0->pos, arg0->velocity, 0x19017016); + if ((crossing->someTimer == 1) || (crossing->someTimer == 20)) { + func_800C98B8(crossing->pos, crossing->velocity, 0x19017016); } } } @@ -2491,7 +2491,7 @@ void place_segment_06(u32 arg0) { break; } temp_s0 = &gActorList[func_8029EC88(&sp8C, &sp78, &sp80, var_s2)]; - if (D_800DC50C == 9) { + if (gGamestate == 9) { func_802976D8(temp_s0->rot); } else { temp_s1 = &temp_s0->unk30; @@ -2825,8 +2825,6 @@ static ? gTextureShrub; /* unable to generate initia s16 gCurrentCourseId; /* unable to generate initializer */ void func_8029E158(void) { - u16 temp_t6; - set_segment_base_addr(3, gPrevLoadedAddress); D_802BA050 = func_802A84F4((s32) &D_0F04CBE0, 0x00000257U, 0x00000400U); func_802A84F4((s32) &D_0F04CE30, 0x00000242U, 0x00000400U); @@ -2854,8 +2852,8 @@ void func_8029E158(void) { func_802A84F4((s32) &D_0F0561AC, 0x0000025BU, 0x00000800U); func_802A84F4((s32) &gTexture671A88, 0x00000400U, 0x00000800U); func_802A84F4((s32) &gTexture6774D8, 0x00000400U, 0x00000800U); - temp_t6 = (u16) gCurrentCourseId; - switch (temp_t6) { + + switch (gCurrentCourseId) { case 0: func_802A84F4((s32) &D_0F04F45C, 0x0000035BU, 0x00000800U); D_802BA058 = func_802A84F4((s32) &D_0F056408, 0x000003E8U, 0x00000800U); @@ -4100,7 +4098,7 @@ block_89: GLOBAL_ASM("asm/non_matchings/actors/func_802A0450.s") #endif -void func_802A0D54(void) { +void evaluate_player_collision(void) { struct Actor *temp_a1; s32 i, j; Player *phi_s1; @@ -4973,7 +4971,7 @@ void func_802A27A0(Camera *arg0, Mat4 arg1, struct YoshiValleyEgg *egg, u16 arg3 Vec3f sp54; f32 temp_f0; - if (D_800DC50C != CREDITS_SEQUENCE) { + if (gGamestate != CREDITS_SEQUENCE) { temp_f0 = func_802B80D0(arg0->pos, egg->pos, arg0->rot[1], 200.0f, D_80150130[arg0 - camera1], D_802B9A2C); if (temp_f0 < 0.0f) { return; @@ -5139,7 +5137,7 @@ void func_802A3008(struct UnkStruct_800DC5EC *arg0) { s32 pad[12]; s32 i; - struct Actor *phi_s0; + struct Actor *actor; Vec3f sp4C = {0.0f, 5.0f, 10.0f}; f32 sp48 = sins(temp_s1->rot[1] - 0x8000); // unk26; f32 temp_f0 = coss(temp_s1->rot[1] - 0x8000); @@ -5170,119 +5168,119 @@ void func_802A3008(struct UnkStruct_800DC5EC *arg0) { D_8015F8E0 = 0; for (i = 0; i < ACTOR_LIST_SIZE; i++) { - phi_s0 = &gActorList[i]; + actor = &gActorList[i]; - if (phi_s0->flags == 0) { + if (actor->flags == 0) { continue; } - switch (phi_s0->type) { + switch (actor->type) { case 2: - func_80299144(temp_s1, D_801502C0, phi_s0); + func_80299144(temp_s1, D_801502C0, actor); break; case 3: - func_8029930C(temp_s1, D_801502C0, phi_s0); + func_8029930C(temp_s1, D_801502C0, actor); break; case 4: - func_802994D4(temp_s1, D_801502C0, phi_s0); + func_802994D4(temp_s1, D_801502C0, actor); break; case 19: - func_8029969C(temp_s1, D_801502C0, phi_s0); + func_8029969C(temp_s1, D_801502C0, actor); break; case 26: - func_80299864(temp_s1, D_801502C0, phi_s0); + func_80299864(temp_s1, D_801502C0, actor); break; case 28: - func_80299A2C(temp_s1, D_801502C0, phi_s0); + func_80299A2C(temp_s1, D_801502C0, actor); break; case 33: - func_80299BF4(temp_s1, D_801502C0, phi_s0); + func_80299BF4(temp_s1, D_801502C0, actor); break; case 29: - func_80299DBC(temp_s1, D_801502C0, phi_s0); + func_80299DBC(temp_s1, D_801502C0, actor); break; case 30: - func_80299EDC(temp_s1, D_801502C0, phi_s0); + func_80299EDC(temp_s1, D_801502C0, actor); break; case 31: - func_80299FFC(temp_s1, D_801502C0, phi_s0); + func_80299FFC(temp_s1, D_801502C0, actor); break; case 32: - func_8029A11C(temp_s1, D_801502C0, phi_s0); + func_8029A11C(temp_s1, D_801502C0, actor); break; case ACTOR_FALLING_ROCK: - func_8029CA90(temp_s1, (struct FallingRock *) phi_s0); + func_8029CA90(temp_s1, (struct FallingRock *) actor); break; case ACTOR_KIWANO_FRUIT: - func_8029A23C(temp_s1, D_801502C0, phi_s0); + func_8029A23C(temp_s1, D_801502C0, actor); break; case ACTOR_BANANA: - func_8029A8F4(temp_s1, D_801502C0, phi_s0); + func_8029A8F4(temp_s1, D_801502C0, actor); break; case ACTOR_GREEN_SHELL: - func_8029A690(temp_s1, D_801502C0, (struct ShellActor *) phi_s0); + func_8029A690(temp_s1, D_801502C0, (struct ShellActor *) actor); break; case ACTOR_RED_SHELL: - func_8029A75C(temp_s1, D_801502C0, (struct ShellActor *) phi_s0); + func_8029A75C(temp_s1, D_801502C0, (struct ShellActor *) actor); break; case ACTOR_BLUE_SPINY_SHELL: - func_8029A828(temp_s1, D_801502C0, (struct ShellActor *) phi_s0); + func_8029A828(temp_s1, D_801502C0, (struct ShellActor *) actor); break; case ACTOR_PIRANHA_PLANT: - func_80298328(temp_s1, D_801502C0, phi_s0); + func_80298328(temp_s1, D_801502C0, actor); break; case ACTOR_TRAIN_ENGINE: - func_8029B8E8(temp_s1, (struct TrainCar *) phi_s0); + func_8029B8E8(temp_s1, (struct TrainCar *) actor); break; case ACTOR_TRAIN_TENDER: - func_8029BFB0(temp_s1, (struct TrainCar *) phi_s0); + func_8029BFB0(temp_s1, (struct TrainCar *) actor); break; case ACTOR_TRAIN_PASSENGER_CAR: - func_8029C3CC(temp_s1, (struct TrainCar *) phi_s0); + func_8029C3CC(temp_s1, (struct TrainCar *) actor); break; case 18: - func_80297A50(temp_s1, D_801502C0, phi_s0); + func_80297A50(temp_s1, D_801502C0, actor); break; case 20: - func_8029AC18(temp_s1, D_801502C0, phi_s0); + func_8029AC18(temp_s1, D_801502C0, actor); break; case ACTOR_MARIO_RACEWAY_SIGN: - func_802A29BC(temp_s1, D_801502C0, phi_s0); + func_802A29BC(temp_s1, D_801502C0, actor); break; case ACTOR_WARIO_STADIUM_SIGN: - func_802A269C(temp_s1, phi_s0); + func_802A269C(temp_s1, actor); break; case 25: - func_802A2C78(temp_s1, D_801502C0, phi_s0); + func_802A2C78(temp_s1, D_801502C0, actor); break; case ACTOR_PADDLE_WHEEL_BOAT: - func_8029AE1C(temp_s1, phi_s0, D_801502C0, sp92); + func_8029AE1C(temp_s1, actor, D_801502C0, sp92); break; case 37: - func_8029B06C(temp_s1, phi_s0); + func_8029B06C(temp_s1, actor); break; case 40: - func_8029B2E4(temp_s1, phi_s0); + func_8029B2E4(temp_s1, actor); break; case 41: - func_8029B6EC(temp_s1, phi_s0); + func_8029B6EC(temp_s1, actor); break; case 44: - func_8029B4E0(temp_s1, phi_s0); + func_8029B4E0(temp_s1, actor); break; case 39: - func_802A2AD0(temp_s1, phi_s0); + func_802A2AD0(temp_s1, actor); break; case ACTOR_YOSHI_VALLEY_EGG: - func_802A27A0(temp_s1, D_801502C0, phi_s0, sp92); + func_802A27A0(temp_s1, D_801502C0, actor, sp92); break; } } switch (gCurrentCourseId) { case COURSE_MOO_MOO_FARM: - func_802986B4(temp_s1, D_801502C0, phi_s0); + func_802986B4(temp_s1, D_801502C0, actor); break; case COURSE_DK_JUNGLE: - func_80298D7C(temp_s1, D_801502C0, phi_s0); + func_80298D7C(temp_s1, D_801502C0, actor); break; } } diff --git a/src/actors.h b/src/actors.h index f9ea53e5f..3b02ca16b 100644 --- a/src/actors.h +++ b/src/actors.h @@ -85,7 +85,7 @@ void func_8029FDC8(struct Actor*); void func_802A00E8(struct Actor*, struct Actor*); void func_802A0350(struct Actor*, struct Actor*); void func_802A0450(Player*, struct Actor*); -void func_802A0D54(); +void evaluate_player_collision(); void func_802A0E44(); void func_802A1064(struct FakeItemBox*); void update_obj_fake_item_box(struct FakeItemBox*); @@ -267,8 +267,8 @@ extern Mat4 D_801502C0; extern s16 D_8015F6EC; extern s16 D_8015F6EE; -extern s32 D_800DC50C; -extern s32 D_800DC50C; +extern s32 gGamestate; +extern s32 gGamestate; extern s32 D_8015F8DC; extern s32 D_8015F8E0; extern s32 D_801625EC; diff --git a/src/camera_junk.c b/src/camera_junk.c index 6141292a2..bc25bbfe9 100644 --- a/src/camera_junk.c +++ b/src/camera_junk.c @@ -8,7 +8,7 @@ extern f32 D_80150148, D_8015014C, D_80150150; extern f32 D_80150130[]; -void func_80281610(void) { +void setup_camera_ending_sequence(void) { Camera *camera; f32 x_dist; f32 y_dist; diff --git a/src/code_800029B0.c b/src/code_800029B0.c index 7a097396a..2bd23a0aa 100644 --- a/src/code_800029B0.c +++ b/src/code_800029B0.c @@ -111,15 +111,15 @@ void func_800029B0(void) { } } -void func_80002A18(void) { +void setup_race(void) { struct Controller *controller; - int tmp; + int i; gPlayerCountSelection1 = D_8018EDF3; - if (D_800DC50C != RACING) { + if (gGamestate != RACING) { gIsMirrorMode = 0; } - if (gIsMirrorMode != 0) { + if (gIsMirrorMode) { gCourseDirection = -1.0f; } else { gCourseDirection = 1.0f; @@ -175,7 +175,7 @@ void func_80002A18(void) { controller = *gControllerOne; - for (tmp = 0; tmp < 7; tmp++, controller++){ + for (i = 0; i < 7; i++, controller++){ controller->rawStickX = 0; controller->rawStickY = 0; controller->buttonPressed = 0; @@ -244,7 +244,7 @@ void func_80003040(void) { gCourseDirection = 1.0f; gPlayerCountSelection1 = 1; - set_segment_base_addr(0x03, (gPrevLoadedAddress + 0xFFFF7000)); + set_segment_base_addr(3, (gPrevLoadedAddress + 0xFFFF7000)); destroy_all_actors(); switch (gCurrentCourseId) { case COURSE_MARIO_RACEWAY: diff --git a/src/code_8001F980.c b/src/code_8001F980.c index c4329997f..7c726d86a 100644 --- a/src/code_8001F980.c +++ b/src/code_8001F980.c @@ -818,7 +818,7 @@ void func_80021B0C(void) { func_8006E7CC(gPlayerSeven, 6, 0); func_8006E7CC(gPlayerEight, 7, 0); } - if (D_800DC50C == ENDING_SEQUENCE) { + if (gGamestate == ENDING_SEQUENCE) { temp_a0 = gPlayerOne; if ((temp_a0->unk_044 & 0x2000) != 0) { func_80024374(temp_a0, 0, 0); diff --git a/src/code_80027D00.c b/src/code_80027D00.c index 36c662f5e..fba965a62 100644 --- a/src/code_80027D00.c +++ b/src/code_80027D00.c @@ -731,7 +731,7 @@ void func_80028E70(void *arg0, s32 arg1, s8 arg2, s8 arg3) { temp_v0 = arg0->unk0; if ((temp_v0 & 0x8000) == 0x8000) { - if (D_800DC50C == ENDING_SEQUENCE) { + if (gGamestate == ENDING_SEQUENCE) { if ((temp_v0 & 0x2000) == 0) { func_80038C6C(arg3, arg2); return; diff --git a/src/code_800431B0.c b/src/code_800431B0.c index 6687d3ccc..a2a7be395 100644 --- a/src/code_800431B0.c +++ b/src/code_800431B0.c @@ -7684,7 +7684,7 @@ void func_80053870(s32 arg0) { do { temp_s1_2 = *phi_s0_2; temp_v0 = (&D_80165C18 + (temp_s1_2 * 0xE0))->unkDF; - if (D_800DC50C != CREDITS_SEQUENCE) { + if (gGamestate != CREDITS_SEQUENCE) { temp_v0_2 = *(&D_8018CF68 + (arg0 * 2)); if ((temp_v0_2 >= (temp_v0 - 1)) && ((temp_v0 + 1) >= temp_v0_2) && (func_8008A140(temp_s1_2, sp84, 0x8000) != 0)) { func_800536C8(temp_s1_2); @@ -9085,7 +9085,7 @@ void func_80055E68(s32 arg0) { s32 temp_s0; temp_s0 = D_80183EA0; - if (D_800DC50C != CREDITS_SEQUENCE) { + if (gGamestate != CREDITS_SEQUENCE) { func_8008A1D0(temp_s0, arg0, 0x5DC, 0xBB8); if (func_8007223C(temp_s0, 0x40000) != 0) { func_80055CCC(temp_s0, arg0); @@ -9683,7 +9683,7 @@ void func_80057114(s32 arg0) { s32 phi_s2_2; phi_fp = arg0; - if (D_800DC50C == ENDING_SEQUENCE) { + if (gGamestate == ENDING_SEQUENCE) { phi_fp = 0; } temp_s7 = (phi_fp * 0xB8) + camera1; @@ -9694,7 +9694,7 @@ void func_80057114(s32 arg0) { temp_s0 = *phi_s1; if (func_8007223C(temp_s0, 0x200000) != 0) { (&D_80163DE8 + (phi_s2 * 0x54))->unk4A = 0; - } else if (D_800DC50C != ENDING_SEQUENCE) { + } else if (gGamestate != ENDING_SEQUENCE) { (&D_80163DE8 + (phi_s2 * 0x54))->unk4A = 1; } func_800721E8(temp_s0, 0x200000); diff --git a/src/code_80057C60.c b/src/code_80057C60.c index ed225306a..e187c8c19 100644 --- a/src/code_80057C60.c +++ b/src/code_80057C60.c @@ -163,7 +163,7 @@ void func_80058090(u32 arg0) { } void func_8005217C(s32); -extern s32 D_800DC50C; +extern s32 gGamestate; extern u16 D_800DC51C; void func_800581C8(void) { @@ -172,7 +172,7 @@ void func_800581C8(void) { gSPMatrix(gDisplayListHead++, VIRTUAL_TO_PHYSICAL(&gGfxPool->mtxPool[7]), G_MTX_NOPUSH | G_MTX_MUL | G_MTX_PROJECTION); func_8001C3C4(0); - if (D_800DC50C == ENDING_SEQUENCE) { + if (gGamestate == ENDING_SEQUENCE) { func_80055F48(0); func_80056160(0); func_8005217C(0); @@ -267,7 +267,7 @@ void func_80058640(void) { gDPSetTexturePersp(gDisplayListHead++, G_TP_PERSP); gSPMatrix(gDisplayListHead++, VIRTUAL_TO_PHYSICAL(&gGfxPool->mtxPool[1]), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION); gSPMatrix(gDisplayListHead++, VIRTUAL_TO_PHYSICAL(&gGfxPool->mtxPool[7]), G_MTX_NOPUSH | G_MTX_MUL | G_MTX_PROJECTION); - if (D_800DC50C != ENDING_SEQUENCE) { + if (gGamestate != ENDING_SEQUENCE) { func_80058B58(0); } } @@ -332,7 +332,7 @@ void func_800588F4(s32 arg0) { func_80054664(arg0); break; case COURSE_BANSHEE_BOARDWALK: - if (D_800DC50C != CREDITS_SEQUENCE) { + if (gGamestate != CREDITS_SEQUENCE) { func_800527D8(arg0); func_80052590(arg0); func_8005217C(arg0); @@ -341,20 +341,20 @@ void func_800588F4(s32 arg0) { break; case COURSE_YOSHI_VALLEY: func_80055228(arg0); - if (D_800DC50C != CREDITS_SEQUENCE) { + if (gGamestate != CREDITS_SEQUENCE) { func_8005568C(arg0); } break; case COURSE_FRAPPE_SNOWLAND: - if (D_800DC50C != CREDITS_SEQUENCE) { + if (gGamestate != CREDITS_SEQUENCE) { func_8005327C(arg0); } break; case COURSE_KOOPA_BEACH: - if (D_800DC50C != CREDITS_SEQUENCE) { + if (gGamestate != CREDITS_SEQUENCE) { func_80055528(arg0); } - if (D_800DC50C != CREDITS_SEQUENCE) { + if (gGamestate != CREDITS_SEQUENCE) { if ((D_8018EDF3 == 1) || (D_8018EDF3 == 2)) { func_80055380(arg0); @@ -371,7 +371,7 @@ void func_800588F4(s32 arg0) { } break; case COURSE_MOO_MOO_FARM: - if (D_800DC50C != CREDITS_SEQUENCE) { + if (gGamestate != CREDITS_SEQUENCE) { func_800550A4(arg0); } break; @@ -381,13 +381,13 @@ void func_800588F4(s32 arg0) { func_800541BC(arg0); break; case COURSE_SHERBET_LAND: - if (D_800DC50C != CREDITS_SEQUENCE) { + if (gGamestate != CREDITS_SEQUENCE) { func_80052E30(arg0); } func_8005592C(arg0); break; case COURSE_RAINBOW_ROAD: - if (D_800DC50C != CREDITS_SEQUENCE) { + if (gGamestate != CREDITS_SEQUENCE) { func_80056188(arg0); func_80055C38(arg0); } @@ -401,7 +401,7 @@ void func_800588F4(s32 arg0) { case COURSE_DOUBLE_DECK: break; case COURSE_DK_JUNGLE: - if (D_800DC50C != CREDITS_SEQUENCE) { + if (gGamestate != CREDITS_SEQUENCE) { func_80054414(arg0); } break; @@ -423,7 +423,7 @@ extern u16 D_8015F894; void func_80058B58() { switch(gCurrentCourseId) { case 5: - if (D_800DC50C != 9) { + if (gGamestate != 9) { if ((D_8015F894 == 0) && (gPlayerCountSelection1 == COURSE_CHOCO_MOUNTAIN)) { func_800517C8(); } @@ -1044,7 +1044,7 @@ void func_80059AC8(void) { switch (gScreenModeSelection) { case SCREEN_MODE_1P: - if (D_800DC50C != 9) { + if (gGamestate != 9) { func_80059A88(0); if (gModeSelection == 1) { func_8005995C(); @@ -1231,12 +1231,12 @@ void func_8005A070(void) { func_80041D34(); if (D_800DC5FC == 0) { func_8005C728(); - if (D_800DC50C == ENDING_SEQUENCE) { + if (gGamestate == ENDING_SEQUENCE) { func_80086604(); func_80086D80(); func_8007C2F8(1); func_80077640(); - } else if (D_800DC50C == CREDITS_SEQUENCE) { + } else if (gGamestate == CREDITS_SEQUENCE) { func_80059820(0); func_80078C70(0); func_8005A74C(); @@ -1342,7 +1342,7 @@ void func_8005A380(void) { #ifdef MIPS_TO_C //generated by mips_to_c commit bd0364fa19633bd6201f8007e2d0a7ed87825909 ? func_8006F824(?, s8, s32); /* extern */ -extern s32 D_800DC50C; +extern s32 gGamestate; extern u16 D_800DC51C; extern s8 D_801657E4; extern s8 D_801657E6; @@ -1358,7 +1358,7 @@ void func_8005A3C0(s32 arg2) { s8 phi_a1; s32 phi_a2; - temp_v0 = D_800DC50C; + temp_v0 = gGamestate; phi_a1 = 0; phi_a2 = arg2; phi_a1 = 0; @@ -1488,7 +1488,7 @@ void func_8005A74C(void) { func_80076B84(); break; case 3: - if (D_800DC50C != CREDITS_SEQUENCE) { + if (gGamestate != CREDITS_SEQUENCE) { func_8007E1AC(); func_8007E4C4(); if (gModeSelection != TIME_TRIALS) { @@ -1500,22 +1500,22 @@ void func_8005A74C(void) { break; case 4: func_80083080(); - if (D_800DC50C != CREDITS_SEQUENCE) { + if (gGamestate != CREDITS_SEQUENCE) { func_800834B8(); } break; case 5: - if (D_800DC50C != CREDITS_SEQUENCE) { + if (gGamestate != CREDITS_SEQUENCE) { func_80083D60(); } func_80078838(); break; case 6: - if (D_800DC50C != CREDITS_SEQUENCE) { + if (gGamestate != CREDITS_SEQUENCE) { func_80082E5C(); } temp_v0 = D_8018EDF3; - if ((temp_v0 == 1) || (temp_v0 == 2) || (D_800DC50C == CREDITS_SEQUENCE)) { + if ((temp_v0 == 1) || (temp_v0 == 2) || (gGamestate == CREDITS_SEQUENCE)) { func_80082870(); } break; @@ -1525,7 +1525,7 @@ void func_8005A74C(void) { } break; case 9: - if (D_800DC50C != CREDITS_SEQUENCE) { + if (gGamestate != CREDITS_SEQUENCE) { func_800821FC(); } break; @@ -1533,13 +1533,13 @@ void func_8005A74C(void) { func_80075838(); break; case 12: - if (D_800DC50C != CREDITS_SEQUENCE) { + if (gGamestate != CREDITS_SEQUENCE) { func_800842C8(); } func_80085214(); break; case 13: - if (D_800DC50C != CREDITS_SEQUENCE) { + if (gGamestate != CREDITS_SEQUENCE) { func_800861E0(); func_80085AA8(); } @@ -11508,7 +11508,7 @@ void func_8006E420(Player* player, s8 arg1, s8 arg2) { for (temp_s0 = 0; temp_s0 < 10; ++temp_s0) { func_8006CEC0(player, temp_s0, arg1, arg2); - if (((player->unk_000 & 0x4000) == 0x4000) || (D_800DC50C == ENDING_SEQUENCE)) { + if (((player->unk_000 & 0x4000) == 0x4000) || (gGamestate == ENDING_SEQUENCE)) { func_8006C9B8(player, temp_s0, arg1, arg2); } func_8006C6AC(player, temp_s0, arg1, arg2); diff --git a/src/code_8006E9C0.c b/src/code_8006E9C0.c index 2ecac2fe9..6f51191f5 100644 --- a/src/code_8006E9C0.c +++ b/src/code_8006E9C0.c @@ -1462,7 +1462,7 @@ void func_80070780(void) { temp_t6 = gCurrentCourseId; switch (temp_t6) { case 0: - if (D_800DC50C != CREDITS_SEQUENCE) { + if (gGamestate != CREDITS_SEQUENCE) { if (gModeSelection == GRAND_PRIX) { func_80070714(); } @@ -1553,7 +1553,7 @@ void func_80070780(void) { } while (temp_s0_4 != &D_8018C0B0); return; case 3: - if (D_800DC50C != CREDITS_SEQUENCE) { + if (gGamestate != CREDITS_SEQUENCE) { temp_s0_5 = D_80183EA0.unk0; func_80073444(temp_s0_5, &D_06007BB8, &D_06007DB8, 0x20, 0x40); temp_v0_5 = &D_80165C18 + (temp_s0_5 * 0xE0); @@ -1574,7 +1574,7 @@ void func_80070780(void) { phi_s1_3 = temp_s1; } while (temp_s1 < &D_80183EB0); phi_s2_3 = &D_80183F28; - if (D_800DC50C != CREDITS_SEQUENCE) { + if (gGamestate != CREDITS_SEQUENCE) { phi_v1 = D_800E5E8C; phi_s1_4 = &D_800E5E14; do { @@ -1612,7 +1612,7 @@ void func_80070780(void) { phi_s1_5 = temp_s1_2; } while (temp_s1_2 < &D_8018C278); phi_s1_6 = &D_80183EA0; - if (D_800DC50C != CREDITS_SEQUENCE) { + if (gGamestate != CREDITS_SEQUENCE) { phi_v1_2 = &D_800E5EE8; phi_s2_4 = &D_80183F28; do { @@ -1641,7 +1641,7 @@ void func_80070780(void) { return; case 6: phi_s1_7 = &D_80183EA0; - if (D_800DC50C != CREDITS_SEQUENCE) { + if (gGamestate != CREDITS_SEQUENCE) { phi_v1_3 = D_800E5F80; do { temp_s0_9 = *phi_s1_7; @@ -1676,7 +1676,7 @@ void func_80070780(void) { } while (temp_s2 != &D_80183F50); return; case 7: - if (D_800DC50C != CREDITS_SEQUENCE) { + if (gGamestate != CREDITS_SEQUENCE) { if (gModeSelection == GRAND_PRIX) { func_80070714(); } @@ -1698,7 +1698,7 @@ void func_80070780(void) { /* Duplicate return node #106. Try simplifying control flow for better match */ return; case 8: - if (D_800DC50C != CREDITS_SEQUENCE) { + if (gGamestate != CREDITS_SEQUENCE) { if (gModeSelection == GRAND_PRIX) { func_80070714(); } @@ -1722,7 +1722,7 @@ void func_80070780(void) { /* Duplicate return node #106. Try simplifying control flow for better match */ return; case 9: - if (D_800DC50C != CREDITS_SEQUENCE) { + if (gGamestate != CREDITS_SEQUENCE) { temp_v0_10 = D_8018EDF3; phi_s1_8 = &D_80183EA0; if ((temp_v0_10 == ONE_PLAYERS_SELECTED) || ((temp_v0_10 == TWO_PLAYERS_SELECTED) && (gModeSelection == VERSUS))) { @@ -1811,7 +1811,7 @@ block_75: /* Duplicate return node #106. Try simplifying control flow for better match */ return; case 11: - if (D_800DC50C != CREDITS_SEQUENCE) { + if (gGamestate != CREDITS_SEQUENCE) { find_unused_obj_index(&D_8018CF10); func_800723A4(D_8018CF10, 0); phi_s1_12 = &D_8018C1B0; @@ -1846,7 +1846,7 @@ block_75: return; case 13: phi_s1_14 = &D_80183EA0; - if (D_800DC50C != CREDITS_SEQUENCE) { + if (gGamestate != CREDITS_SEQUENCE) { do { func_800723A4(*phi_s1_14, 0); temp_s1_5 = phi_s1_14 + 4; diff --git a/src/code_80071F00.c b/src/code_80071F00.c index 56d9eab0f..7178168eb 100644 --- a/src/code_80071F00.c +++ b/src/code_80071F00.c @@ -3783,7 +3783,7 @@ void func_80078288(s32 arg0) { temp_s0->unkB4 = func_800872D8(arg0, camera1); return; } - if (D_800DC50C != CREDITS_SEQUENCE) { + if (gGamestate != CREDITS_SEQUENCE) { sp3A = ((gPlayerOneCopy->unk_094 / 18.0f) * 216.0f) / 2.0f; sp3E = (random_int(0xF) - sp3A) + 0x2D; sp3C = random_int(0x12C) + 0x1E; @@ -3941,7 +3941,7 @@ void func_80078838(void) { s32 temp_a0; s32 *phi_s0; - if (D_800DC50C != CREDITS_SEQUENCE) { + if (gGamestate != CREDITS_SEQUENCE) { func_80078790(); } else { func_80078790(); @@ -9099,7 +9099,7 @@ void func_80080524(s32 arg0) { temp_s0->unk14 = 70.0f; temp_s0->unk20 = 0.0f; func_8008B888(arg0, 0, 0, 0); - if ((gIsMirrorMode != 0) || (D_800DC50C == CREDITS_SEQUENCE)) { + if ((gIsMirrorMode != 0) || (gGamestate == CREDITS_SEQUENCE)) { func_8008B8BC(arg0, 0, 0xC000, 0); } else { func_8008B8BC(arg0, 0, 0x4000, 0); @@ -9285,7 +9285,7 @@ block_6: func_8007E63C(arg0); func_8008085C(arg0); func_80073514(arg0); - if (D_800DC50C != CREDITS_SEQUENCE) { + if (gGamestate != CREDITS_SEQUENCE) { if ((D_8018D40C == 0) && (phi_t0->unkA6 == 2)) { func_800C98B8(phi_t0 + 4, phi_t0 + 0x38, 0x19036045); return; @@ -10481,7 +10481,7 @@ void func_8008241C(s32 arg0, s32 arg1) { phi_f10 = temp_f10 + 4294967296.0; } temp_f4 = phi_f10 + -100.0; - if (D_800DC50C == CREDITS_SEQUENCE) { + if (gGamestate == CREDITS_SEQUENCE) { func_8008B7D4(arg0, sp22 + D_800EF170, sp20 + 60.0, temp_f4 + D_800EF178); } else if (temp_s0->unkD5 != 0) { func_8008B7D4(arg0, (sp22 + D_800EF180) * D_8018D01C, sp20 + 20.0, temp_f4 + D_800EF188); @@ -10602,7 +10602,7 @@ void func_80082870(void) { D_80183E40.unk0 = 0.0f; D_80183E40.unk4 = 0.0f; D_80183E40.unk8 = 0.0f; - if (D_800DC50C != CREDITS_SEQUENCE) { + if (gGamestate != CREDITS_SEQUENCE) { func_800C98B8(temp_s1 + 4, &D_80183E40, 0x19017043); } else if (D_802876D2 < 0x97) { func_800C98B8(&D_80165C18 + (D_80183F2C * 0xE0) + 4, &D_80183E40, 0x19017043); @@ -10618,7 +10618,7 @@ void func_80082870(void) { if (temp_v0 != 0) { D_80165900 = temp_v0 - 1; } else { - if (D_800DC50C != CREDITS_SEQUENCE) { + if (gGamestate != CREDITS_SEQUENCE) { D_80165900 = 0x3C; } else { D_80165900 = 0xF; @@ -11812,7 +11812,7 @@ block_14: } else if ((arg1 >= 9) && (arg1 < 0xF)) { switch (arg1) { case 9: - if (D_800DC50C != CREDITS_SEQUENCE) { + if (gGamestate != CREDITS_SEQUENCE) { func_8008B7D4(arg0, D_8018D01C * 146.0, 0, 0xC3BE0000); } else { func_8008B7D4(arg0, D_8018D01C * 380.0, 0, 0xC405C000); @@ -12226,7 +12226,7 @@ void func_800853DC(s32 arg0) { temp_v0 = (arg0 * 0xE0) + &D_80165C18; temp_v0->unk70 = &D_0600F960; temp_v0->unk0 = 1.0f; - if (D_800DC50C != CREDITS_SEQUENCE) { + if (gGamestate != CREDITS_SEQUENCE) { sp2C = temp_v0; func_8008B7D4(D_8018D01C * -176.0, 0.0f, -2323.0f); func_8008B80C(arg0, 0.0f, 0x43960000, 0.0f); diff --git a/src/code_80091750.c b/src/code_80091750.c index 0542f27a8..11634e065 100644 --- a/src/code_80091750.c +++ b/src/code_80091750.c @@ -271,7 +271,7 @@ void func_80091B78(void) { var_s0_2 += 1; } while (var_s0_2 != 8); func_800B44BC(); - osViSetSpecialFeatures(0x00000040U); + osViSetSpecialFeatures(OS_VI_DITHER_FILTER_ON); } #else GLOBAL_ASM("asm/non_matchings/code_80091750/func_80091B78.s") @@ -1491,7 +1491,8 @@ void func_800947B4(struct GfxPool *arg0, s32 unused) { #ifdef NEEDS_RODATA // Non-matching due to .rodata diffs resulting from the switch/case // jump table -void func_80094A64(Mtx *arg0) { +// Renders menu graphics? +void func_80094A64(GfxPool *arg0) { D_8018D120 = 0; D_80164AF0 = 0; gSPViewport(gDisplayListHead++, VIRTUAL_TO_PHYSICAL(&D_802B8880)); @@ -4127,7 +4128,7 @@ void func_80099AEC(void) { void *temp_v0; void *temp_v0_2; - if (D_800DC50C == 4) { + if (gGamestate == 4) { sp60 = 0x00000500; } else { sp60 = 0x00001000; @@ -5819,7 +5820,7 @@ void func_8009CBE4(s32 arg0, s32 arg1, s32 arg2) { sp40 = temp_t4; gDisplayListHead = draw_box(gDisplayListHead, phi_t2 - temp_v1_3, phi_t3 - temp_t0, temp_v1_3 + phi_t2, temp_t0 + phi_t3, temp_v0_5->unk0, temp_v0_5->unk2, temp_v0_5->unk4, 0xFF - ((*temp_t4 * 0xFF) / *temp_t9)); if ((arg1 == 0) && (temp_t6 = *temp_t4 + 1, *temp_t4 = temp_t6, ((temp_t6 < *sp3C) == 0))) { - if (D_800DC50C == RACING) { + if (gGamestate == RACING) { *(&D_8018E7AC + arg0) = 6; return; } @@ -5856,7 +5857,7 @@ void func_8009CE1C(void) { ? func_80290360(); /* extern */ ? func_80290388(); /* extern */ ? func_802903B0(); /* extern */ -extern s32 D_800DC524; +extern s32 gGamestateNext; extern s32 D_800E86A4; extern s16 D_8015F892; extern ? D_8018E7AC; @@ -5906,7 +5907,7 @@ void func_8009CE64(s32 *arg0, s32 arg2, s32 arg3) { var_a0 = arg0; var_a2 = arg3; - temp_v0 = D_800DC50C; + temp_v0 = gGamestate; var_a1 = 0; if (temp_v0 == (s32) 5) { temp_v1 = gCCSelection; @@ -5917,7 +5918,7 @@ void func_8009CE64(s32 *arg0, s32 arg2, s32 arg3) { } if (var_a1 != 0) { gMenuSelectionFromEndingSequence = 9; - gCreditsCourseId = 8; + gCreditsCourseId = COURSE_LUIGI_RACEWAY; return; } gMenuSelectionFromEndingSequence = 1; @@ -6065,7 +6066,7 @@ block_74: case 2: /* switch 3 */ D_800DC51C = 1; D_8018EE08 = 1; - D_800DC524 = 4; + gGamestateNext = 4; gCCSelection = (s32) 1; temp_v1_4 = (s8) gNextDemoId; switch (temp_v1_4) { /* switch 4 */ @@ -6165,7 +6166,7 @@ block_74: D_800E86A4 = 1; } if (gMenuSelection >= 0xE) { - D_800DC524 = 4; + gGamestateNext = 4; if (gModeSelection == 1) { D_8018EDFB = (s8) 1; } @@ -6177,15 +6178,15 @@ block_74: temp_v1_7 = gDebugGotoScene; switch (temp_v1_7) { /* switch 5; irregular */ case 1: /* switch 5 */ - D_800DC524 = (s32) 5; + gGamestateNext = (s32) 5; break; case 2: /* switch 5 */ case 3: /* switch 5 */ - D_800DC524 = 9; - gCreditsCourseId = 8; + gGamestateNext = 9; + gCreditsCourseId = COURSE_LUIGI_RACEWAY; break; default: /* switch 5 */ - D_800DC524 = 4; + gGamestateNext = 4; if (gModeSelection == (s32) 1) { D_8018EDFB = 1; } @@ -10492,7 +10493,7 @@ void func_800A474C(s32 recordType, s32 column, s32 row) { u32 phi_v0_2; u32 phi_v0_3; - if (D_800DC50C == 4) { + if (gGamestate == 4) { sp30 = 0; } else { sp30 = 1; diff --git a/src/code_800B45E0.c b/src/code_800B45E0.c index cac9682eb..6f080404e 100644 --- a/src/code_800B45E0.c +++ b/src/code_800B45E0.c @@ -1038,7 +1038,7 @@ s32 func_800B6178(s32 arg0) { if ((arg0 != 0) && (arg0 != 1)) { return -1; } - if (D_800DC50C == RACING) { + if (gGamestate == RACING) { func_800051C4(); } temp_s3 = (arg0 << 7) + &D_8018EE10; @@ -1065,7 +1065,7 @@ s32 func_800B6178(s32 arg0) { phi_v1 = temp_v0_2; if (temp_v0_2 == 0) { temp_s3->unk4 = 1; - if (D_800DC50C == RACING) { + if (gGamestate == RACING) { temp_s3->unk5 = (gCupSelection * 4) + gCupCourseSelection; } temp_s3->unk0 = D_80162DFC; diff --git a/src/code_80280000.c b/src/code_80280000.c index 83430580e..74aa18900 100644 --- a/src/code_80280000.c +++ b/src/code_80280000.c @@ -7,6 +7,7 @@ #include "types.h" #include "camera.h" #include "code_80281780.h" +#include extern Gfx *gDisplayListHead; @@ -26,7 +27,7 @@ extern s32 D_802874A0; extern u16 atan2s(f32, f32); extern u16 D_80164714, D_80164716, D_80164718; extern u16 D_800DC5E4; -extern u32 D_800DC50C; +extern u32 gGamestate; extern u32 D_802874FC; extern u16 D_800DC518; @@ -45,9 +46,9 @@ void func_80280038(void) { D_80150112 = 0; D_80164AF0 = 0; D_8018D120 = 0; - func_802A3E3C(); + init_rdp(); func_802A53A4(); - func_802A3E3C(); + init_rdp(); func_80057FC4(0); gSPSetGeometryMode(gDisplayListHead++, G_ZBUFFER | G_SHADE | G_CULL_BACK | G_SHADING_SMOOTH); guPerspective(&gGfxPool->mtxPool[1], &sp44[37], D_80150130[0], D_80150148, D_80150150, D_8015014C, 1.0f); @@ -64,9 +65,9 @@ void func_80280038(void) { func_80058538(0); func_80284CC0(); func_80281C40(); - func_802A3E3C(); + init_rdp(); func_80093F10(); - func_802A3E3C(); + init_rdp(); } void func_80280268(s32 arg0) { @@ -79,7 +80,7 @@ void func_80280268(s32 arg0) { gCreditsCourseId = arg0; } -void func_802802AC(void) { +void credits_loop(void) { Camera *camera = &cameras[0]; f32 temp_f12; @@ -87,12 +88,12 @@ void func_802802AC(void) { f32 temp_f14; D_802874A0 = 0; - if (gIsInQuitToMenuTransition != 0) { + if (gIsInQuitToMenuTransition) { gQuitToMenuTransitionCounter--; if (gQuitToMenuTransitionCounter == 0) { gIsInQuitToMenuTransition = 0; - D_800DC524 = CREDITS_SEQUENCE; - D_800DC50C = 255; + gGamestateNext = CREDITS_SEQUENCE; + gGamestate = 255; } } else { @@ -115,7 +116,7 @@ void func_802802AC(void) { } } -void func_80280420(void) { +void load_credits(void) { Camera *camera = &cameras[0]; gCurrentCourseId = gCreditsCourseId; @@ -125,8 +126,8 @@ void func_80280420(void) { func_802A74BC(); camera->unk_B4 = 60.0f; D_80150130[0] = 60.0f; - D_800DC5EC->screenWidth = 320; - D_800DC5EC->screenHeight = 240; + D_800DC5EC->screenWidth = SCREEN_WIDTH; + D_800DC5EC->screenHeight = SCREEN_HEIGHT; D_800DC5EC->screenStartX = 160; D_800DC5EC->screenStartY = 120; gScreenModeSelection = SCREEN_MODE_1P; diff --git a/src/code_80280650.c b/src/code_80280650.c index e94d72c2f..0957e2c0a 100644 --- a/src/code_80280650.c +++ b/src/code_80280650.c @@ -600,13 +600,10 @@ void func_80281540(void) { extern s16 D_80150112; extern s32 D_802874FC; -void func_80281548(void) { - void *temp_v0; - void *temp_v0_2; - +void ending_sequence_loop(void) { D_80150112 = 0; D_802874FC = 0; - func_80281610(); + setup_camera_ending_sequence(); func_80028F70(); func_80022744(); func_80059AC8(); diff --git a/src/code_80281C40.c b/src/code_80281C40.c index 01c2f7bea..708b2869a 100644 --- a/src/code_80281C40.c +++ b/src/code_80281C40.c @@ -49,12 +49,12 @@ void func_80281D00(void) { u16 sp64[46]; func_802A53A4(); - func_802A3E3C(); + init_rdp(); if (gMenuSelectionFromEndingSequence != 0xFFFF) { clear_framebuffer(0); if (D_80287554 >= 4) { gIsInQuitToMenuTransition = 0; - D_800DC524 = gMenuSelectionFromEndingSequence; + gGamestateNext = gMenuSelectionFromEndingSequence; } D_80287554++; return; @@ -78,5 +78,5 @@ void func_80281D00(void) { func_80093F10(); func_80284CC0(); func_80281C40(); - func_802A3E3C(); + init_rdp(); } diff --git a/src/code_80281FA0.c b/src/code_80281FA0.c index 72f0c80a0..8d319d16c 100644 --- a/src/code_80281FA0.c +++ b/src/code_80281FA0.c @@ -584,7 +584,7 @@ s32 func_8028336C(s32 arg0, Camera *camera) { if (temp_v1 != 0) { return temp_v1; } - temp_v1_2 = D_800DC50C; + temp_v1_2 = gGamestate; switch (temp_v1_2) { /* irregular */ case 5: D_802876D8 = (s32) *(&sp20 + D_802874F5); @@ -675,7 +675,7 @@ void func_80283430(void) { var_s1 += 0x14; } while (var_s0 != &D_80287824); D_802856C0 = 0.0f; - if (D_800DC50C == 5) { + if (gGamestate == 5) { D_802856B0 = 120.0f; D_802856B4 = 12.0f; D_802856B8 = 120.0f; @@ -768,7 +768,7 @@ s32 func_80283648(Camera *camera) { camera->angleZ = sins((u16) sp6C) * -sp38; vec3f_copy_dupe(camera->pos, &D_802876EC); vec3f_copy_dupe(sp34, (f32 *) &D_802876E0); - if ((D_800DC50C == 9) && (gIsMirrorMode != 0)) { + if ((gGamestate == 9) && (gIsMirrorMode != 0)) { camera->pos[0] = -camera->pos[0]; camera->unk = -camera->unk; } diff --git a/src/main.c b/src/main.c index 697cca724..b5f25963b 100644 --- a/src/main.c +++ b/src/main.c @@ -17,10 +17,10 @@ void func_8008C214(void); void func_80091B78(void); void func_802A4D18(void); -void func_802A3E3C(void); -void func_802A4160(void); -void func_802A41D4(void); -void func_802A3CB0(void); +void init_rdp(void); +void set_viewport(void); +void select_framebuffer(void); +void init_z_buffer(void); void audio_init(); void profiler_log_gfx_time(enum ProfilerGfxEvent eventID); void profiler_log_vblank_time(void); @@ -150,13 +150,13 @@ u32 gGfxSPTaskStack[256]; OSMesg gPIMesgBuf[32]; OSMesgQueue gPIMesgQueue; -s32 D_800DC50C = 0xFFFF; +s32 gGamestate = 0xFFFF; u16 D_800DC510 = 0; u16 D_800DC514 = 0; u16 D_800DC518 = 0; u16 D_800DC51C = 0; u16 gEnableDebugMode = 0; -s32 D_800DC524 = 7; // = COURSE_DATA_MENU?; +s32 gGamestateNext = 7; // = COURSE_DATA_MENU?; UNUSED s32 D_800DC528 = 1; s32 gActiveScreenMode = SCREEN_MODE_1P; s32 gScreenModeSelection = 0; @@ -179,7 +179,7 @@ s32 D_800DC568 = 0; s32 D_800DC56C[8] = {0}; s16 sNumVBlanks = 0; UNUSED s16 D_800DC590 = 0; -f32 D_800DC594 = 0.0f; +f32 gVBlankTimer = 0.0f; f32 gCourseTimer = 0.0f; @@ -298,7 +298,7 @@ void create_gfx_task_structure(void) { gGfxSPTask->task.t.flags = (1 << 1); gGfxSPTask->task.t.ucode_boot = rspbootTextStart; gGfxSPTask->task.t.ucode_boot_size = ((u8 *) rspbootTextEnd - (u8 *) rspbootTextStart); - if (D_800DC50C != RACING || gPlayerCountSelection1 - 1 == 0) { + if (gGamestate != RACING || gPlayerCountSelection1 - 1 == 0) { gGfxSPTask->task.t.ucode = gspF3DEXTextStart; gGfxSPTask->task.t.ucode_data = gspF3DEXDataStart; } else { @@ -407,12 +407,15 @@ void exec_display_list(struct SPTask *spTask) { } } -void func_80000CA8(void) { +/** + * Set default RCP (Reality Co-Processor) settings. + */ +void init_rcp(void) { move_segment_table_to_dmem(); - func_802A3E3C(); - func_802A4160(); - func_802A41D4(); - func_802A3CB0(); + init_rdp(); + set_viewport(); + select_framebuffer(); + init_z_buffer(); } /** @@ -446,7 +449,7 @@ void rendering_init(void) { set_segment_base_addr(1, gGfxPool); gGfxSPTask = &gGfxPool->spTask; gDisplayListHead = gGfxPool->gfxPool; - func_80000CA8(); + init_rcp(); clear_framebuffer(0); end_master_display_list(); exec_display_list(&gGfxPool->spTask); @@ -518,8 +521,10 @@ void dma_copy(u8 *dest, u8 *arg1, u32 size) { } } -// Resembles setup_game_memory from SM64 -void init_game(void) { +/** + * Setup main segments and framebuffers. + */ +void setup_game_memory(void) { UNUSED u32 pad[2]; u32 sp2C; u32 sp40; @@ -552,15 +557,19 @@ void init_game(void) { D_8015F734 = gPrevLoadedAddress; } -void func_80001404(void) { - D_800DC524 = 0; // = START_MENU_FROM_QUIT? +/** + * @brief + * + */ +void game_init_clear_framebuffer(void) { + gGamestateNext = 0; // = START_MENU_FROM_QUIT? clear_framebuffer(0); } -void func_8000142C(void) { +void race_logic_loop(void) { s16 i; s32 pad; - u16 temp_v0; + u16 rotY; f32 pad2 = 0; D_80150112 = 0; @@ -581,9 +590,9 @@ void func_8000142C(void) { func_802A4EF4(); switch(gActiveScreenMode) { - case 0: + case SCREEN_MODE_1P: D_80150114 = 2; - func_80005F44(); + staff_ghosts_loop(); if (D_800DC5FC == 0) { for (i = 0; i < D_80150114; i++) { @@ -591,7 +600,7 @@ void func_8000142C(void) { gCourseTimer += 0.01666666; } func_802909F0(); - func_802A0D54(); + evaluate_player_collision(); func_800382DC(); func_8001EE98(gPlayerOneCopy, camera1, 0); func_80028F70(); @@ -620,15 +629,15 @@ void func_8000142C(void) { D_800DC514 = 0; } - temp_v0 = camera1->rot[1]; + rotY = camera1->rot[1]; D_801625E8 = D_800DC5EC->pathCounter; - if (temp_v0 < 0x2000) { + if (rotY < 0x2000) { func_80057A50(40, 100, "SOUTH ", D_801625E8); - } else if (temp_v0 < 0x6000) { + } else if (rotY < 0x6000) { func_80057A50(40, 100, "EAST ", D_801625E8); - } else if (temp_v0 < 0xA000) { + } else if (rotY < 0xA000) { func_80057A50(40, 100, "NORTH ", D_801625E8); - } else if (temp_v0 < 0xE000) { + } else if (rotY < 0xE000) { func_80057A50(40, 100, "WEST ", D_801625E8); } else { func_80057A50(40, 100, "SOUTH ", D_801625E8); @@ -644,7 +653,7 @@ void func_8000142C(void) { } break; - case 2: + case SCREEN_MODE_2P_SPLITSCREEN_VERTICAL: if (gCurrentCourseId == COURSE_DK_JUNGLE) { D_80150114 = 3; } else { @@ -656,7 +665,7 @@ void func_8000142C(void) { gCourseTimer += 0.01666666; } func_802909F0(); - func_802A0D54(); + evaluate_player_collision(); func_800382DC(); func_8001EE98(gPlayerOneCopy, camera1, 0); func_80029060(); @@ -674,9 +683,9 @@ void func_8000142C(void) { profiler_log_thread5_time(LEVEL_SCRIPT_EXECUTE); sNumVBlanks = 0; move_segment_table_to_dmem(); - func_802A3E3C(); + init_rdp(); if (D_800DC5B0 != 0) { - func_802A41D4(); + select_framebuffer(); } D_8015F788 = 0; if (gPlayerWinningIndex == 0) { @@ -688,7 +697,7 @@ void func_8000142C(void) { } break; - case 1: + case SCREEN_MODE_2P_SPLITSCREEN_HORIZONTAL: if (gCurrentCourseId == COURSE_DK_JUNGLE) { D_80150114 = 3; @@ -702,7 +711,7 @@ void func_8000142C(void) { gCourseTimer += 0.01666666; } func_802909F0(); - func_802A0D54(); + evaluate_player_collision(); func_800382DC(); func_8001EE98(gPlayerOneCopy, camera1, 0); func_80029060(); @@ -720,9 +729,9 @@ void func_8000142C(void) { sNumVBlanks = (u16)0; func_8005A070(); move_segment_table_to_dmem(); - func_802A3E3C(); + init_rdp(); if (D_800DC5B0 != 0) { - func_802A41D4(); + select_framebuffer(); } D_8015F788 = 0; if (gPlayerWinningIndex == 0) { @@ -735,7 +744,7 @@ void func_8000142C(void) { break; - case 3: + case SCREEN_MODE_3P_4P_SPLITSCREEN: if (gPlayerCountSelection1 == 3) { switch(gCurrentCourseId) { case COURSE_BOWSER_CASTLE: @@ -749,6 +758,7 @@ void func_8000142C(void) { break; } } else { + // Four players switch(gCurrentCourseId) { case COURSE_BLOCK_FORT: case COURSE_DOUBLE_DECK: @@ -769,7 +779,7 @@ void func_8000142C(void) { gCourseTimer += 0.01666666; } func_802909F0(); - func_802A0D54(); + evaluate_player_collision(); func_800382DC(); func_8001EE98(gPlayerOneCopy, camera1, 0); func_80029158(); @@ -791,9 +801,9 @@ void func_8000142C(void) { sNumVBlanks = 0; profiler_log_thread5_time(LEVEL_SCRIPT_EXECUTE); move_segment_table_to_dmem(); - func_802A3E3C(); + init_rdp(); if (D_800DC5B0 != 0) { - func_802A41D4(); + select_framebuffer(); } D_8015F788 = 0; if (gPlayerWinningIndex == 0) { @@ -845,29 +855,42 @@ void func_8000142C(void) { gSPEndDisplayList(gDisplayListHead++); } -void func_80001ECC(void) { - - switch (D_800DC50C) { +/** + * mk64's game loop depends on a series of states. + * It runs a wide branching series of code based on these states. + * State 1) Clear framebuffer + * State 2) Run menus + * State 3) Process race related logic + * State 4) Ending sequence + * State 5) Credits + * + * Note that the state doesn't flip-flop at random but is permanent + * until the state changes (ie. Exit menus and start a race). + */ +void game_state_handler(void) { + switch (gGamestate) { case 7: - func_80001404(); + game_init_clear_framebuffer(); break; - case 0: - case 1: - case 2: - case 3: + case START_MENU_FROM_QUIT: + case MAIN_MENU_FROM_QUIT: + case PLAYER_SELECT_MENU_FROM_QUIT: + case COURSE_SELECT_MENU_FROM_QUIT: + // Display black osViBlack(0); - func_800B0350(); - func_80000CA8(); - func_80094A64(gGfxPool); + update_menus(); + init_rcp(); + // gGfxPool->mtxPool->m or gGfxPool? + func_80094A64(gGfxPool->mtxPool->m); break; - case 4: - func_8000142C(); + case RACING: + race_logic_loop(); break; - case 5: - func_80281548(); + case ENDING_SEQUENCE: + ending_sequence_loop(); break; - case 9: - func_802802AC(); + case CREDITS_SEQUENCE: + credits_loop(); break; } } @@ -927,7 +950,7 @@ void start_gfx_sptask(void) { } void handle_vblank(void) { - D_800DC594 += 0.01666666; + gVBlankTimer += 0.01666666; sNumVBlanks++; receive_new_tasks(); @@ -1035,9 +1058,11 @@ void thread3_video(UNUSED void *arg0) { } setup_mesg_queues(); - init_game(); + setup_game_memory(); + create_thread(&gAudioThread, 4, &thread4_audio, 0, gAudioThreadStack + ARRAY_COUNT(gAudioThreadStack), 20); osStartThread(&gAudioThread); + create_thread(&gGameLoopThread, 5, &thread5_game_loop, 0, gGameLoopThreadStack + ARRAY_COUNT(gGameLoopThreadStack), 10); osStartThread(&gGameLoopThread); @@ -1084,8 +1109,13 @@ void func_80002658(void) { func_802A4D18(); } -void func_80002684(void) { - switch (D_800DC50C) { +/** + * Sets courseId to NULL if + * + * + */ +void update_gamestate(void) { + switch (gGamestate) { case START_MENU_FROM_QUIT: func_80002658(); gCurrentlyLoadedCourseId = COURSE_NULL; @@ -1104,7 +1134,7 @@ void func_80002684(void) { break; case RACING: init_seg_8028DF00(); - func_80002A18(); + setup_race(); break; case ENDING_SEQUENCE: gCurrentlyLoadedCourseId = COURSE_NULL; @@ -1115,7 +1145,7 @@ void func_80002684(void) { gCurrentlyLoadedCourseId = COURSE_NULL; init_seg_8028DF00(); init_seg_80280000(); - func_80280420(); + load_credits(); break; } } @@ -1128,7 +1158,8 @@ void thread5_game_loop(UNUSED void *arg) { clear_nmi_buffer(); } set_vblank_handler(2, &gGameVblankHandler, &gGameVblankQueue, (OSMesg) OS_EVENT_SW2); - // Potentially unused? + // These variables track stats such as player wins. + // In the event of a console reset, it remembers them. gNmiUnknown1 = (s32) pAppNmiBuffer; gNmiUnknown2 = (s32) pAppNmiBuffer + 2; gNmiUnknown3 = (s32) pAppNmiBuffer + 11; @@ -1141,14 +1172,16 @@ void thread5_game_loop(UNUSED void *arg) { while(TRUE) { func_800CB2C4(); - if (D_800DC524 != D_800DC50C) { - D_800DC50C = (s32) D_800DC524; - func_80002684(); + + // Update the gamestate if it has changed. + if (gGamestateNext != gGamestate) { + gGamestate = gGamestateNext; + update_gamestate(); } profiler_log_thread5_time(THREAD5_START); config_gfx_pool(); read_controllers(); - func_80001ECC(); + game_state_handler(); end_master_display_list(); display_and_vsync(); } diff --git a/src/main.h b/src/main.h index 0b04ba4a5..ff92c4197 100644 --- a/src/main.h +++ b/src/main.h @@ -30,7 +30,7 @@ void read_controllers(); void func_80000BEC(); void dispatch_audio_sptask(struct SPTask*); void exec_display_list(struct SPTask*); -void func_80000CA8(); +void init_rcp(); void end_master_display_list(); void *clear_framebuffer(s32); void rendering_init(); @@ -39,8 +39,8 @@ void display_and_vsync(); void init_seg_80280000(); void init_seg_8028DF00(); void dma_copy(u8*, u8*, u32); -void init_game(); -void func_80001ECC(); +void setup_game_memory(); +void game_state_handler(); void interrupt_gfx_sptask(); void receive_new_tasks(); void set_vblank_handler(s32, struct VblankHandler*, OSMesgQueue*, OSMesg*); @@ -53,7 +53,7 @@ void func_800025D4(); void func_80002600(); void func_8000262C(); void func_80002658(); -void func_80002684(); +void update_gamestate(); void thread5_game_loop(void*); void thread4_audio(void*); @@ -64,9 +64,9 @@ extern struct Controller gControllers[8]; extern OSIoMesg gDmaIoMesg; extern OSMesg gMainReceivedMesg; extern OSMesgQueue gDmaMesgQueue; -extern s32 D_800DC524; +extern s32 gGamestateNext; extern s32 gActiveScreenMode; -extern f32 D_800DC594; +extern f32 gVBlankTimer; extern uintptr_t pAppNmiBuffer; extern s32 gNmiUnknown1, gNmiUnknown2, gNmiUnknown3, gNmiUnknown4, gNmiUnknown5, gNmiUnknown6; extern s32 gScreenModeSelection; diff --git a/src/memory.c b/src/memory.c index 3d956ef79..ef2341beb 100644 --- a/src/memory.c +++ b/src/memory.c @@ -1526,7 +1526,7 @@ void load_course(s32 arg0) { u32 *temp_a2; temp_v0 = &gCourseTable[arg0]; - temp_v1 = D_800DC50C; + temp_v1 = gGamestate; temp_a2 = temp_v0->offsetRomStart; sp48 = temp_v0->dlRomStart; sp44 = temp_v0->dlRomEnd; @@ -1544,7 +1544,7 @@ void load_course(s32 arg0) { gHeapEndPtr = 0x8028DF00; } set_segment_base_addr(9, func_802A7D70(temp_a2, temp_v0->offsetRomEnd, temp_a2)); - if (D_800DC50C != ENDING_SEQUENCE) { + if (gGamestate != ENDING_SEQUENCE) { set_segment_base_addr(6, func_802AA88C(sp48, sp44)); } sp18 = gPrevLoadedAddress; diff --git a/src/menus.c b/src/menus.c index f1568b243..20b07e8ad 100644 --- a/src/menus.c +++ b/src/menus.c @@ -148,24 +148,29 @@ union GameModePack { const union GameModePack D_800F2BE4 = { {0, 1, 2, 3} }; /** forward decs **/ -void func_800B053C(struct Controller *, u16); -void func_800B13B0(struct Controller *, u16); -void func_800B15AC(struct Controller *, u16); -void func_800B1C40(struct Controller *, u16); -void func_800B1C90(struct Controller *, u16); -void func_800B20F4(struct Controller *, u16); -void func_800B29D8(struct Controller *, u16); -void func_800B3554(struct Controller *, u16); -void func_800B3B58(struct Controller *, u16); +void options_menu_act(struct Controller *, u16); +void data_menu_act(struct Controller *, u16); +void course_data_menu_act(struct Controller *, u16); +void logo_intro_menu_act(struct Controller *, u16); +void controller_pak_menu_act(struct Controller *, u16); +void splash_menu_act(struct Controller *, u16); +void main_menu_act(struct Controller *, u16); +void player_select_menu_act(struct Controller *, u16); +void course_select_menu_act(struct Controller *, u16); void func_800B44AC(void); /**************************/ -void func_800B0350(void) { +/** + * Includes opening logo and splash screens + */ +void update_menus(void) { u16 controllerIdx; if (D_800E86A4 == 0) { for (controllerIdx = 0; controllerIdx < 4; controllerIdx++) { - if ((func_800B4520() == 0) && (gEnableDebugMode != 0) && ((gControllers[controllerIdx].buttonPressed & 0x1000) != 0)) { + + // Quick jump through menus using the start button. + if ((func_800B4520() == 0) && (gEnableDebugMode) && ((gControllers[controllerIdx].buttonPressed & START_BUTTON) != 0)) { // this is certainly a way to write these... switch (gMenuSelection) { case COURSE_SELECT_MENU: @@ -188,37 +193,37 @@ void func_800B0350(void) { osViSetSpecialFeatures(sVIGammaOffDitherOn); switch (gMenuSelection) { case OPTIONS_MENU: - func_800B053C(&gControllers[controllerIdx], controllerIdx); + options_menu_act(&gControllers[controllerIdx], controllerIdx); break; case DATA_MENU: - func_800B13B0(&gControllers[controllerIdx], controllerIdx); + data_menu_act(&gControllers[controllerIdx], controllerIdx); break; case COURSE_DATA_MENU: - func_800B15AC(&gControllers[controllerIdx], controllerIdx); + course_data_menu_act(&gControllers[controllerIdx], controllerIdx); break; case LOGO_INTRO_MENU: - func_800B1C40(&gControllers[controllerIdx], controllerIdx); + logo_intro_menu_act(&gControllers[controllerIdx], controllerIdx); break; case CONTROLLER_PAK_MENU: - if (controllerIdx == 0) { - func_800B1C90(&gControllers[controllerIdx], controllerIdx); + if (controllerIdx == PLAYER_ONE) { + controller_pak_menu_act(&gControllers[controllerIdx], controllerIdx); } break; case START_MENU_FROM_QUIT: case START_MENU: - func_800B20F4(&gControllers[controllerIdx], controllerIdx); + splash_menu_act(&gControllers[controllerIdx], controllerIdx); break; case MAIN_MENU_FROM_QUIT: case MAIN_MENU: - func_800B29D8(&gControllers[controllerIdx], controllerIdx); + main_menu_act(&gControllers[controllerIdx], controllerIdx); break; case PLAYER_SELECT_MENU_FROM_QUIT: case PLAYER_SELECT_MENU: - func_800B3554(&gControllers[controllerIdx], controllerIdx); + player_select_menu_act(&gControllers[controllerIdx], controllerIdx); break; case COURSE_SELECT_MENU_FROM_QUIT: case COURSE_SELECT_MENU: - func_800B3B58(&gControllers[controllerIdx], controllerIdx); + course_select_menu_act(&gControllers[controllerIdx], controllerIdx); break; } } @@ -234,7 +239,7 @@ enum MenuOptionsCursorPositions { }; // navigation of the options menu -void func_800B053C(struct Controller *controller, u16 arg1) { +void options_menu_act(struct Controller *controller, u16 arg1) { u16 btnAndStick; // sp3E struct_8018D9E0_entry *sp38; s32 res; @@ -648,11 +653,11 @@ void func_800B053C(struct Controller *controller, u16 arg1) { // L800B13A0 return } #else -GLOBAL_ASM("asm/non_matchings/menus/func_800B053C.s") +GLOBAL_ASM("asm/non_matchings/menus/options_menu_act.s") #endif // Handle navigating the data menu interface -void func_800B13B0(struct Controller *controller, UNUSED u16 arg1) { +void data_menu_act(struct Controller *controller, UNUSED u16 arg1) { u16 buttonAndStickPress = (controller->buttonPressed | controller->stickPressed); // Make pressing Start have the same effect as pressing A @@ -712,7 +717,7 @@ void func_800B13B0(struct Controller *controller, UNUSED u16 arg1) { } } -void func_800B15AC(struct Controller *controller, UNUSED u16 arg1) { +void course_data_menu_act(struct Controller *controller, UNUSED u16 arg1) { u16 btnAndStick; // sp2E struct_8018D9E0_entry *sp28; CourseTimeTrialRecords *sp24; @@ -874,17 +879,21 @@ void func_800B15AC(struct Controller *controller, UNUSED u16 arg1) { } } -// Handle controller input during the logo screen -void func_800B1C40(struct Controller *arg0, UNUSED u16 arg1) { - u16 sp1E = arg0->buttonPressed | arg0->stickPressed; +/** + * On input skip logo screen + **/ +void logo_intro_menu_act(struct Controller *arg0, UNUSED u16 arg1) { + u16 anyInput = arg0->buttonPressed | arg0->stickPressed; - if ((func_800B4520() == 0) && (sp1E != 0)) { + if ((func_800B4520() == 0) && (anyInput)) { + // Audio related func_800CA388(0x3C); + func_8009E1E4(); } } -void func_800B1C90(struct Controller* controller, UNUSED u16 arg1) { +void controller_pak_menu_act(struct Controller* controller, UNUSED u16 arg1) { u16 buttonAndStickPress; OSPfsState* osPfsState; s32 selectedTableRow; @@ -1026,7 +1035,7 @@ void func_800B1C90(struct Controller* controller, UNUSED u16 arg1) { } } -void func_800B20F4(struct Controller *controller, u16 arg1) { +void splash_menu_act(struct Controller *controller, u16 arg1) { u16 btnAndStick; u16 i; s32 sp28; @@ -1279,7 +1288,7 @@ void func_800B28C8(void) { #ifdef NON_MATCHING // nonmatching: regalloc; arg1 is not AND-ed back into $a1, reg chaos follows -void func_800B29D8(struct Controller *controller, u16 arg1) { +void main_menu_act(struct Controller *controller, u16 arg1) { u16 btnAndStick; // sp2E s32 sp28; s32 sp24; @@ -1514,7 +1523,7 @@ void func_800B29D8(struct Controller *controller, u16 arg1) { } } #else -GLOBAL_ASM("asm/non_matchings/menus/func_800B29D8.s") +GLOBAL_ASM("asm/non_matchings/menus/main_menu_act.s") #endif // check if there is no currently selected and/or hovered character at grid position `gridId` @@ -1531,7 +1540,7 @@ s32 is_character_spot_free(s32 gridId) { #ifdef NON_MATCHING // grid positions are from right to left, then top to bottom // nonmatching: the gCharacterGridSelections pointer is not promoted to $s0 -void func_800B3554(struct Controller *controller, u16 arg1) { +void player_select_menu_act(struct Controller *controller, u16 arg1) { u16 btnAndStick; // sp36 s8 selected; s8 i; @@ -1698,11 +1707,11 @@ void func_800B3554(struct Controller *controller, u16 arg1) { // L800B3B44 } #else -GLOBAL_ASM("asm/non_matchings/menus/func_800B3554.s") +GLOBAL_ASM("asm/non_matchings/menus/player_select_menu_act.s") #endif // Handle navigating the course menu interface -void func_800B3B58(struct Controller *arg0, u16 arg1) { +void course_select_menu_act(struct Controller *arg0, u16 arg1) { u16 buttonAndStickPress = (arg0->buttonPressed | arg0->stickPressed); if ((gEnableDebugMode == 0) && ((buttonAndStickPress & 0x1000) != 0)) { @@ -1868,11 +1877,11 @@ void func_800B3F74(s32 menuSelection) { func_800B5F30(); func_8000F0E0(); - if (D_800DC50C != 0) { + if (gGamestate != 0) { func_800CA008(0, 0); func_800CB2C4(); - D_800DC50C = 0; - D_800DC524 = 0; + gGamestate = 0; + gGamestateNext = 0; func_800C8EAC(2); } @@ -1921,7 +1930,7 @@ void func_800B3F74(s32 menuSelection) { case 0: { D_8018EDEE = 1; - if (D_800DC50C == 0) { + if (gGamestate == 0) { for (i = 0; i < 4; i++) { if (i < D_8018EDF3) { gCharacterGridSelections[i] = i + 1; @@ -1935,8 +1944,8 @@ void func_800B3F74(s32 menuSelection) { } else { func_800CA008(0, 0); func_800CB2C4(); - D_800DC50C = 0; - D_800DC524 = 0; + gGamestate = 0; + gGamestateNext = 0; func_800C8EAC(2); for (i = 0; i < ARRAY_COUNT(D_8018EDE8); i++) { D_8018EDE8[i] = FALSE; @@ -1972,11 +1981,11 @@ void func_800B3F74(s32 menuSelection) { } D_8018EDEC = 1; } - if (D_800DC50C != 0) { + if (gGamestate != 0) { func_800CA008(0, 0); func_800CB2C4(); - D_800DC50C = 0; - D_800DC524 = 0; + gGamestate = 0; + gGamestateNext = 0; func_800C8EAC(2); } play_sound2(0x49009013); @@ -2008,6 +2017,7 @@ void func_800B44BC(void) { } } +// Likely checks that the user is actually in the menus and not racing. s32 func_800B4520(void) { if ((D_8018E7B0 == 2) || (D_8018E7B0 == 3) || (D_8018E7B0 == 4) || (D_8018E7B0 == 7)) { diff --git a/src/menus.h b/src/menus.h index df72744c5..5fb386a4c 100644 --- a/src/menus.h +++ b/src/menus.h @@ -7,7 +7,7 @@ #include /* functions */ -void func_800B0350(void); +void update_menus(void); void func_800B3F74(s32 menuSelection); void func_800B44BC(void); s32 func_800B4520(void); diff --git a/src/race_logic.c b/src/race_logic.c index 65957d134..76c1627c6 100644 --- a/src/race_logic.c +++ b/src/race_logic.c @@ -61,7 +61,7 @@ extern f32 D_80150118; extern u16 D_800DC518; extern u16 D_8015011E; extern float gCourseTimer; -extern float D_800DC594; +extern float gVBlankTimer; extern s32 gScreenModeSelection; extern s32 D_8018D2AC; extern s32 gActiveScreenMode; @@ -1071,7 +1071,7 @@ void func_8028FCBC(void) { D_802BA032 = 0; D_8015011E = 0; gCourseTimer = 0.0f; - D_800DC594 = 0.0f; + gVBlankTimer = 0.0f; D_800DC5B0 = 1; D_800DC5B4 = 1; D_802BA034 = 0.008f; diff --git a/src/render_courses.c b/src/render_courses.c index a9a64b46f..c60669c2f 100644 --- a/src/render_courses.c +++ b/src/render_courses.c @@ -230,7 +230,7 @@ void func_802911C4(void) { #ifdef MIPS_TO_C //generated by mips_to_c commit bd0364fa19633bd6201f8007e2d0a7ed87825909 -? func_802A3E3C(); /* extern */ +? init_rdp(); /* extern */ ? func_802B4FF8(? *, ?); /* extern */ ? mtxf_identity(? *, s32 *, Gfx **); /* extern */ ? mtxf_translate(? *, f32 *, Gfx **); /* extern */ @@ -385,7 +385,7 @@ void func_8029122C(void *arg0, s32 *arg1) { Gfx *phi_v1_3; sp268 = arg0->unk8; - func_802A3E3C(); + init_rdp(); sp21A = arg0->unk38; sp218 = arg0->unk4->unk26; temp_t3 = arg0->unk36; @@ -2010,7 +2010,7 @@ extern Gfx D_06023B68[]; extern Vec3f D_8015F590; extern u16 D_800DC5BC; /* unable to generate initializer */ extern s16 D_800DC5C8; /* unable to generate initializer */ -extern s32 D_800DC50C; +extern s32 gGamestate; extern s32 gModeSelection; extern u16 gNumActors; extern s16 D_8015F6EC; @@ -2150,7 +2150,7 @@ void func_80295D88(void) { func_802AF8BC(0x07002068, -0x6A, 255, 255, 255); func_802AF8BC(0x07001E18, -0x6A, 255, 255, 255); func_802AF8BC(0x07001318, 255, 255, 255, 0); - if (D_800DC50C != CREDITS_SEQUENCE) { + if (gGamestate != CREDITS_SEQUENCE) { func_802AF8BC(0x07001FB8, -0x6A, 255, 255, 255); } break; diff --git a/src/skybox_and_splitscreen.c b/src/skybox_and_splitscreen.c index 64864488d..0cb16c23a 100644 --- a/src/skybox_and_splitscreen.c +++ b/src/skybox_and_splitscreen.c @@ -8,7 +8,7 @@ #include #include "camera.h" -void func_802A41D4(); +void select_framebuffer(); extern Gfx *gDisplayListHead; @@ -19,8 +19,8 @@ extern struct UnkStruct_800DC5EC *D_800DC5F8; extern u16 D_800DC5B0; -void func_802A3E3C(); -extern s32 D_800DC524; +void init_rdp(); +extern s32 gGamestateNext; extern s16 gIsInQuitToMenuTransition; extern u16 gQuitToMenuTransitionCounter; extern s32 gMenuSelection; @@ -133,8 +133,8 @@ void func_802A38B4(void) { void *temp_v0; void *temp_v0_2; - func_802A3E3C(); - func_802A41D4(); + init_rdp(); + select_framebuffer(); gDPFullSync(gDisplayListHead++); gSPEndDisplayList(gDisplayListHead++); @@ -143,8 +143,8 @@ void func_802A38B4(void) { gQuitToMenuTransitionCounter--; return; } - D_800DC524 = gMenuSelectionFromQuit; - D_800DC50C = 255; + gGamestateNext = gMenuSelectionFromQuit; + gGamestate = 255; gIsInQuitToMenuTransition = 0; gQuitToMenuTransitionCounter = 0; D_800E86A4 = 1; @@ -208,7 +208,10 @@ void func_802A39E0(struct UnkStruct_800DC5EC *arg0) { gDPSetDepthSource(gDisplayListHead++, G_ZS_PIXEL); } -void func_802A3CB0(void) { +/** + * Initialize the z-buffer for the current frame. + */ +void init_z_buffer(void) { gDPPipeSync(gDisplayListHead++); gDPSetCycleType(gDisplayListHead++, G_CYC_FILL); gDPSetDepthImage(gDisplayListHead++, D_801502B4); @@ -223,8 +226,10 @@ void func_802A3CB0(void) { gDPSetDepthSource(gDisplayListHead++, G_ZS_PIXEL); } -void func_802A3E3C(void) { - +/** + * Sets the initial RDP (Reality Display Processor) rendering settings. + **/ +void init_rdp(void) { gDPPipeSync(gDisplayListHead++); gDPPipelineMode(gDisplayListHead++, G_PM_1PRIMITIVE); gDPSetScissor(gDisplayListHead++, G_SC_NON_INTERLACE, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT); @@ -242,7 +247,7 @@ void func_802A3E3C(void) { gDPSetColorDither(gDisplayListHead++, G_CD_DISABLE); gDPPipeSync(gDisplayListHead++); gSPClipRatio(gDisplayListHead++); - // FRUSTRATIO_1 + // F3DEX2 may need FRUSTRATIO_1 as an argument to clip ratio. } UNUSED void func_802A40A4(void) {} @@ -254,26 +259,29 @@ UNUSED void func_802A40CC(void) {} UNUSED void func_802A40D4(void) {} UNUSED void func_802A40DC(void) {} -UNUSED s32 func_802A40E4(void) { +#define G_CLEAR_ALL_MODES 0xFFFFFFFF + +UNUSED s32 set_viewport2(void) { gSPViewport(gDisplayListHead++, VIRTUAL_TO_PHYSICAL(&D_800DC5EC->viewport)); - gSPClearGeometryMode(gDisplayListHead++, 0xFFFFFFFF); + gSPClearGeometryMode(gDisplayListHead++, G_CLEAR_ALL_MODES); gSPSetGeometryMode(gDisplayListHead++, G_ZBUFFER | G_SHADE | G_CULL_BACK | G_LIGHTING | G_SHADING_SMOOTH | G_CLIPPING); } -void func_802A4160(void) { +void set_viewport(void) { gSPViewport(gDisplayListHead++, VIRTUAL_TO_PHYSICAL(&D_802B8880)); - gSPClearGeometryMode(gDisplayListHead++, 0xFFFFFFFF); + gSPClearGeometryMode(gDisplayListHead++, G_CLEAR_ALL_MODES); gSPSetGeometryMode(gDisplayListHead++, G_SHADE | G_CULL_BACK | G_SHADING_SMOOTH); - } extern s32 D_800DC5D0; extern s32 D_800DC5D4; extern s32 D_800DC5D8; - -void func_802A41D4(void) { +/** + * Tells the RDP which of the three framebuffers it shall draw to. + */ +void select_framebuffer(void) { gDPSetColorImage(gDisplayListHead++, G_IM_FMT_RGBA, G_IM_SIZ_16b, SCREEN_WIDTH, VIRTUAL_TO_PHYSICAL(gPhysicalFramebuffers[sRenderingFramebuffer])); gDPSetFillColor(gDisplayListHead++, ((D_800DC5D0 << 8 & 0xF800 | (D_800DC5D4 * 8) & 0x7C0 | D_800DC5D8 >> 2 & 0x3E | 1) << 16) | (D_800DC5D0 << 8 & 0xF800 | (D_800DC5D4 * 8) & 0x7C0 | (D_800DC5D8 >> 2) & 0x3E | 1)); @@ -456,7 +464,7 @@ extern struct GfxPool *gGfxPool; void func_802A487C(Vtx *arg0, UNUSED s32 arg1, UNUSED s32 arg2, UNUSED s32 arg3, UNUSED s32 arg4) { - func_802A3E3C(); + init_rdp(); if (gCurrentCourseId != COURSE_RAINBOW_ROAD) { gDPSetRenderMode(gDisplayListHead++, G_RM_OPA_SURF, G_RM_OPA_SURF2); @@ -472,7 +480,7 @@ void func_802A487C(Vtx *arg0, UNUSED s32 arg1, UNUSED s32 arg2, UNUSED s32 arg3, #ifdef MIPS_TO_C //generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307 -//? func_802A3E3C(); // extern +//? init_rdp(); // extern //? func_802A450C(); // extern //? func_802B5564(? *, ? *, s32, s32, f32, f32, f32); // extern //? func_802B5794(? *, void *, void *); // extern @@ -527,7 +535,7 @@ void func_802A4A0C(Vtx *arg0, struct UnkStruct_800DC5EC *arg1, s32 arg2, s32 arg arg0->v.ob[1] = temp_t5; // = temp_t5; //unk22 arg0->v.ob[4] = temp_t5;//unk42 = temp_t5; arg0->v.ob[7] = temp_t5;//unk72 = temp_t5; - func_802A3E3C(); + init_rdp(); gDPSetRenderMode(gDisplayListHead++, G_RM_OPA_SURF, G_RM_OPA_SURF2); gSPClearGeometryMode(gDisplayListHead++, G_ZBUFFER | G_LIGHTING); @@ -586,7 +594,7 @@ extern s32 gScreenModeSelection; void func_802A4D18(void) { f32 phi_f10; - if (D_800DC50C != RACING) { + if (gGamestate != RACING) { D_8015014C = 6800.0f; // D_802B9BB4 D_80150150 = 3.0f; } else { @@ -692,7 +700,7 @@ extern u16 D_800DC5B4; void func_802A5004(void) { - func_802A3E3C(); + init_rdp(); func_802A3730(D_800DC5F0); gSPClearGeometryMode(gDisplayListHead++, 0xFFFFFFFF); @@ -710,7 +718,7 @@ void func_802A5004(void) { void func_802A50EC(void) { - func_802A3E3C(); + init_rdp(); func_802A3730(D_800DC5EC); gSPClearGeometryMode(gDisplayListHead++, 0xFFFFFFFF); @@ -727,7 +735,7 @@ void func_802A50EC(void) { void func_802A51D4(void) { - func_802A3E3C(); + init_rdp(); func_802A39E0(D_800DC5EC); func_802A3730(D_800DC5EC); @@ -744,7 +752,7 @@ void func_802A51D4(void) { void func_802A52BC(void) { - func_802A3E3C(); + init_rdp(); func_802A39E0(D_800DC5F0); func_802A3730(D_800DC5F0); @@ -762,17 +770,17 @@ void func_802A52BC(void) { void func_802A53A4(void) { move_segment_table_to_dmem(); - func_802A3E3C(); + init_rdp(); func_802A3730(D_800DC5EC); gSPClearGeometryMode(gDisplayListHead++, 0xFFFFFFFF); gSPSetGeometryMode(gDisplayListHead++, G_SHADE | G_SHADING_SMOOTH | G_CLIPPING); - func_802A3CB0(); - func_802A41D4(); + init_z_buffer(); + select_framebuffer(); if (D_800DC5B4 != 0) { func_802A4A0C(&D_802B8890, D_800DC5EC, 0x140, 0xF0, &D_80150130[0]); - if (D_800DC50C != CREDITS_SEQUENCE) { + if (gGamestate != CREDITS_SEQUENCE) { func_80057FC4(0); } func_802A487C(&D_802B8890, D_800DC5EC, 0x140, 0xF0, &D_80150130[0]); @@ -782,7 +790,7 @@ void func_802A53A4(void) { void func_802A54A8(void) { - func_802A3E3C(); + init_rdp(); func_802A39E0(D_800DC5EC); func_802A3730(D_800DC5EC); @@ -799,7 +807,7 @@ void func_802A54A8(void) { void func_802A5590(void) { - func_802A3E3C(); + init_rdp(); func_802A39E0(D_800DC5F0); func_802A3730(D_800DC5F0); @@ -816,7 +824,7 @@ void func_802A5590(void) { void func_802A5678(void) { - func_802A3E3C(); + init_rdp(); func_802A39E0(D_800DC5F4); func_802A3730(D_800DC5F4); @@ -835,7 +843,7 @@ void func_802A5678(void) { void func_802A5760(void) { - func_802A3E3C(); + init_rdp(); gSPClearGeometryMode(gDisplayListHead++, 0xFFFFFFFF); gSPSetGeometryMode(gDisplayListHead++, G_SHADE | G_SHADING_SMOOTH | G_CLIPPING); @@ -883,7 +891,7 @@ void func_802A59A4(void) { s32 sp5C[8]; func_802A53A4(); - func_802A3E3C(); + init_rdp(); func_802A3730(D_800DC5EC); gSPSetGeometryMode(gDisplayListHead++, G_ZBUFFER | G_SHADE | G_CULL_BACK | G_LIGHTING | G_SHADING_SMOOTH); @@ -933,7 +941,7 @@ void func_802A5CB4(void) { s32 sp58[8]; func_802A50EC(); - func_802A3E3C(); + init_rdp(); func_802A3730(D_800DC5EC); @@ -983,7 +991,7 @@ void func_802A5FAC(void) { s32 sp58[8]; func_802A5004(); - func_802A3E3C(); + init_rdp(); func_802A3730(D_800DC5F0); gSPSetGeometryMode(gDisplayListHead++, G_ZBUFFER | G_SHADE | G_CULL_BACK | G_SHADING_SMOOTH); @@ -1032,7 +1040,7 @@ void func_802A62A4(void) { func_802A51D4(); gSPSetGeometryMode(gDisplayListHead++, G_SHADE | G_CULL_BACK | G_LIGHTING | G_SHADING_SMOOTH); - func_802A3E3C(); + init_rdp(); func_802A3730(D_800DC5EC); gSPSetGeometryMode(gDisplayListHead++, G_ZBUFFER | G_SHADE | G_CULL_BACK | G_SHADING_SMOOTH); guPerspective(&gGfxPool->mtxPool[1], &sp9A[17], D_80150130[0], D_80150148, D_80150150, D_8015014C, 1.0f); @@ -1080,7 +1088,7 @@ void func_802A65B8(void) { func_802A52BC(); gSPSetGeometryMode(gDisplayListHead++, G_SHADE | G_CULL_BACK | G_LIGHTING | G_SHADING_SMOOTH); - func_802A3E3C(); + init_rdp(); func_802A3730(D_800DC5F0); gSPSetGeometryMode(gDisplayListHead++, G_ZBUFFER | G_SHADE | G_CULL_BACK | G_SHADING_SMOOTH); guPerspective(&gGfxPool->mtxPool[2], &sp9A[17], D_80150130[1], D_80150148, D_80150150, D_8015014C, 1.0f); @@ -1125,7 +1133,7 @@ void func_802A68CC(void) { s32 sp58[8]; func_802A54A8(); - func_802A3E3C(); + init_rdp(); func_802A3730(D_800DC5EC); gSPSetGeometryMode(gDisplayListHead++, G_ZBUFFER | G_SHADE | G_CULL_BACK | G_SHADING_SMOOTH); @@ -1171,7 +1179,7 @@ void func_802A6BB0(void) { s32 sp58[8]; func_802A5590(); - func_802A3E3C(); + init_rdp(); func_802A3730(D_800DC5F0); gSPSetGeometryMode(gDisplayListHead++, G_ZBUFFER | G_SHADE | G_CULL_BACK | G_SHADING_SMOOTH); @@ -1217,7 +1225,7 @@ void func_802A6E94(void) { s32 sp58[8]; func_802A5678(); - func_802A3E3C(); + init_rdp(); func_802A3730(D_800DC5F4); gSPSetGeometryMode(gDisplayListHead++, G_ZBUFFER | G_SHADE | G_CULL_BACK | G_SHADING_SMOOTH); guPerspective(&gGfxPool->mtxPool[3], &sp9A[17], D_80150130[2], D_80150148, D_80150150, D_8015014C, 1.0f); @@ -1271,7 +1279,7 @@ void func_802A7178(void) { return; } - func_802A3E3C(); + init_rdp(); func_802A3730(D_800DC5F8); gSPSetGeometryMode(gDisplayListHead++, G_ZBUFFER | G_SHADE | G_CULL_BACK | G_SHADING_SMOOTH); diff --git a/src/spawn_players.c b/src/spawn_players.c index 811f2e582..d159d8812 100644 --- a/src/spawn_players.c +++ b/src/spawn_players.c @@ -310,7 +310,7 @@ void spawn_player(Player *player, s8 playerIndex, f32 arg2, f32 arg3, f32 arg4, void func_80039AE4(void) { switch (gActiveScreenMode) { case SCREEN_MODE_1P: - if (D_800DC50C == ENDING_SEQUENCE) { + if (gGamestate == ENDING_SEQUENCE) { D_80165578 = 0x898; D_8016557A = 0; D_8016557C = 0x384; @@ -1041,7 +1041,7 @@ void func_8003D080(void) { Player* ptr = &gPlayers[0]; func_8005D290(); - if (D_800DC50C == 5) { + if (gGamestate == 5) { func_8003CD78(); } else { func_8003C0F0(); diff --git a/src/staff_ghosts.c b/src/staff_ghosts.c index 861809390..cfcf1202b 100644 --- a/src/staff_ghosts.c +++ b/src/staff_ghosts.c @@ -587,12 +587,12 @@ void func_80005E6C(void) { } } -void func_80005F44(void) { +void staff_ghosts_loop(void) { if (D_8015F890 == 1) { func_80005E6C(); return; } - if (D_80162DF0 == 0) { + if (!D_80162DF0) { func_80005B18(); return; }