From a2500be835bafef9560211245420fa7306cec37c Mon Sep 17 00:00:00 2001 From: David Benepe Date: Fri, 4 Jun 2021 20:31:02 -0500 Subject: [PATCH] Split unknown_066AA0.c into unknown_06B2B0.c and moved the rest of the rodata --- .../unknown_066AA0/func_80065EA0.s | 5 + .../unknown_066AA0/func_80069F28.s | 23 + .../unknown_066AA0/func_8006CCF0.s | 49 +- .../unknown_066AA0/func_8006DCF8.s | 15 +- asm/unknown_070110.s | 2 +- src/unknown_066AA0.c | 3254 +++++------------ src/unknown_06B2B0.c | 1324 +++++++ 7 files changed, 2365 insertions(+), 2307 deletions(-) create mode 100644 src/unknown_06B2B0.c diff --git a/asm/non_matchings/unknown_066AA0/func_80065EA0.s b/asm/non_matchings/unknown_066AA0/func_80065EA0.s index 7d5d58ec..bbd88892 100644 --- a/asm/non_matchings/unknown_066AA0/func_80065EA0.s +++ b/asm/non_matchings/unknown_066AA0/func_80065EA0.s @@ -1,3 +1,8 @@ +.late_rodata +glabel D_800E709C +.float 15000.0 + +.text glabel func_80065EA0 /* 066AA0 80065EA0 3C048012 */ lui $a0, %hi(D_80120DA0) # $a0, 0x8012 /* 066AA4 80065EA4 24030001 */ li $v1, 1 diff --git a/asm/non_matchings/unknown_066AA0/func_80069F28.s b/asm/non_matchings/unknown_066AA0/func_80069F28.s index f2628b53..71355d63 100644 --- a/asm/non_matchings/unknown_066AA0/func_80069F28.s +++ b/asm/non_matchings/unknown_066AA0/func_80069F28.s @@ -1,3 +1,26 @@ +.rdata +glabel D_800E7078 +.asciz "%x." +glabel D_800E707C +.asciz "%x " +.ascii "\0\0\0" # padding +glabel D_800E7084 +.asciz "\n" +.ascii "\0\0" # padding +glabel D_800E7088 +.asciz "\n" +.ascii "\0\0" # padding +glabel D_800E708C +.asciz "%f " +.ascii "\0\0\0" # padding +glabel D_800E7094 +.asciz "\n" +.ascii "\0\0" # padding +glabel D_800E7098 +.asciz "\n" +.ascii "\0\0" # padding + +.text glabel func_80069F28 /* 06AB28 80069F28 3C038012 */ lui $v1, %hi(D_80120CE0) # $v1, 0x8012 /* 06AB2C 80069F2C 8C630CE0 */ lw $v1, %lo(D_80120CE0)($v1) diff --git a/asm/non_matchings/unknown_066AA0/func_8006CCF0.s b/asm/non_matchings/unknown_066AA0/func_8006CCF0.s index 58553169..362f0859 100644 --- a/asm/non_matchings/unknown_066AA0/func_8006CCF0.s +++ b/asm/non_matchings/unknown_066AA0/func_8006CCF0.s @@ -1,3 +1,12 @@ +.late_rodata +glabel jpt_800E7154 +.word L8006CF68, L8006CF5C, L8006D024, L8006CF80, L8006CF9C, L8006D024, L8006D024, L8006CFB0, L8006CFC4, L8006CFD8, L8006CFEC, L8006D000, L8006D014 +glabel jpt_800E7188 +.word L8006D0B8, L8006D0C4, L8006D108, L8006D19C, L8006D14C, L8006D17C, L8006D188, L8006D1C0, L8006D1C0, L8006D1C0, L8006D1C0, L8006D164 +glabel jpt_800E71B8 +.word L8006D5FC, L8006D614, L8006D62C, L8006D644, L8006D65C, L8006D674, L8006D6D4, L8006D6F4 + +.text glabel func_8006CCF0 /* 06D8F0 8006CCF0 27BDFFB0 */ addiu $sp, $sp, -0x50 /* 06D8F4 8006CCF4 AFBF0024 */ sw $ra, 0x24($sp) @@ -158,21 +167,24 @@ glabel func_8006CCF0 /* 06DB38 8006CF38 1020003A */ beqz $at, .L8006D024 /* 06DB3C 8006CF3C AFA20044 */ sw $v0, 0x44($sp) /* 06DB40 8006CF40 000C6080 */ sll $t4, $t4, 2 -/* 06DB44 8006CF44 3C01800E */ lui $at, %hi(D_800E7154) # $at, 0x800e +/* 06DB44 8006CF44 3C01800E */ lui $at, %hi(jpt_800E7154) # $at, 0x800e /* 06DB48 8006CF48 002C0821 */ addu $at, $at, $t4 -/* 06DB4C 8006CF4C 8C2C7154 */ lw $t4, %lo(D_800E7154)($at) +/* 06DB4C 8006CF4C 8C2C7154 */ lw $t4, %lo(jpt_800E7154)($at) /* 06DB50 8006CF50 00000000 */ nop /* 06DB54 8006CF54 01800008 */ jr $t4 /* 06DB58 8006CF58 00000000 */ nop +glabel L8006CF5C /* 06DB5C 8006CF5C 360D2020 */ ori $t5, $s0, 0x2020 /* 06DB60 8006CF60 10000030 */ b .L8006D024 /* 06DB64 8006CF64 01A08025 */ move $s0, $t5 +glabel L8006CF68 /* 06DB68 8006CF68 3C018012 */ lui $at, %hi(D_80123516) # $at, 0x8012 /* 06DB6C 8006CF6C A0203516 */ sb $zero, %lo(D_80123516)($at) /* 06DB70 8006CF70 0C01B63C */ jal func_8006D8F0 /* 06DB74 8006CF74 2404FFFF */ li $a0, -1 /* 06DB78 8006CF78 1000002B */ b .L8006D028 /* 06DB7C 8006CF7C 8FA40050 */ lw $a0, 0x50($sp) +glabel L8006CF80 /* 06DB80 8006CF80 0C01B0B9 */ jal func_8006C2E4 /* 06DB84 8006CF84 00000000 */ nop /* 06DB88 8006CF88 3C01800E */ lui $at, %hi(D_800DD390) # $at, 0x800e @@ -180,41 +192,49 @@ glabel func_8006CCF0 /* 06DB90 8006CF90 A020D390 */ sb $zero, %lo(D_800DD390)($at) /* 06DB94 8006CF94 10000023 */ b .L8006D024 /* 06DB98 8006CF98 01C08025 */ move $s0, $t6 +glabel L8006CF9C /* 06DB9C 8006CF9C 360F0020 */ ori $t7, $s0, 0x20 /* 06DBA0 8006CFA0 24180001 */ li $t8, 1 /* 06DBA4 8006CFA4 AFB80040 */ sw $t8, 0x40($sp) /* 06DBA8 8006CFA8 1000001E */ b .L8006D024 /* 06DBAC 8006CFAC 01E08025 */ move $s0, $t7 +glabel L8006CFB0 /* 06DBB0 8006CFB0 36190020 */ ori $t9, $s0, 0x20 /* 06DBB4 8006CFB4 24090002 */ li $t1, 2 /* 06DBB8 8006CFB8 AFA90040 */ sw $t1, 0x40($sp) /* 06DBBC 8006CFBC 10000019 */ b .L8006D024 /* 06DBC0 8006CFC0 03208025 */ move $s0, $t9 +glabel L8006CFC4 /* 06DBC4 8006CFC4 360A0020 */ ori $t2, $s0, 0x20 /* 06DBC8 8006CFC8 240B0003 */ li $t3, 3 /* 06DBCC 8006CFCC AFAB0040 */ sw $t3, 0x40($sp) /* 06DBD0 8006CFD0 10000014 */ b .L8006D024 /* 06DBD4 8006CFD4 01408025 */ move $s0, $t2 +glabel L8006CFD8 /* 06DBD8 8006CFD8 360C0020 */ ori $t4, $s0, 0x20 /* 06DBDC 8006CFDC 240D0004 */ li $t5, 4 /* 06DBE0 8006CFE0 AFAD0040 */ sw $t5, 0x40($sp) /* 06DBE4 8006CFE4 1000000F */ b .L8006D024 /* 06DBE8 8006CFE8 01808025 */ move $s0, $t4 +glabel L8006CFEC /* 06DBEC 8006CFEC 360E0020 */ ori $t6, $s0, 0x20 /* 06DBF0 8006CFF0 240F0005 */ li $t7, 5 /* 06DBF4 8006CFF4 AFAF0040 */ sw $t7, 0x40($sp) /* 06DBF8 8006CFF8 1000000A */ b .L8006D024 /* 06DBFC 8006CFFC 01C08025 */ move $s0, $t6 +glabel L8006D000 /* 06DC00 8006D000 36180020 */ ori $t8, $s0, 0x20 /* 06DC04 8006D004 24190006 */ li $t9, 6 /* 06DC08 8006D008 AFB90040 */ sw $t9, 0x40($sp) /* 06DC0C 8006D00C 10000005 */ b .L8006D024 /* 06DC10 8006D010 03008025 */ move $s0, $t8 +glabel L8006D014 /* 06DC14 8006D014 36090020 */ ori $t1, $s0, 0x20 /* 06DC18 8006D018 240A0007 */ li $t2, 7 /* 06DC1C 8006D01C AFAA0040 */ sw $t2, 0x40($sp) /* 06DC20 8006D020 01208025 */ move $s0, $t1 .L8006D024: +glabel L8006D024 /* 06DC24 8006D024 8FA40050 */ lw $a0, 0x50($sp) .L8006D028: /* 06DC28 8006D028 0C030D10 */ jal func_800C3440 @@ -249,15 +269,17 @@ glabel func_8006CCF0 /* 06DC94 8006D094 1020004A */ beqz $at, .L8006D1C0 /* 06DC98 8006D098 AFA20044 */ sw $v0, 0x44($sp) /* 06DC9C 8006D09C 000D6880 */ sll $t5, $t5, 2 -/* 06DCA0 8006D0A0 3C01800E */ lui $at, %hi(D_800E7188) # $at, 0x800e +/* 06DCA0 8006D0A0 3C01800E */ lui $at, %hi(jpt_800E7188) # $at, 0x800e /* 06DCA4 8006D0A4 002D0821 */ addu $at, $at, $t5 -/* 06DCA8 8006D0A8 8C2D7188 */ lw $t5, %lo(D_800E7188)($at) +/* 06DCA8 8006D0A8 8C2D7188 */ lw $t5, %lo(jpt_800E7188)($at) /* 06DCAC 8006D0AC 00000000 */ nop /* 06DCB0 8006D0B0 01A00008 */ jr $t5 /* 06DCB4 8006D0B4 00000000 */ nop +glabel L8006D0B8 /* 06DCB8 8006D0B8 3C018012 */ lui $at, %hi(gIsPaused) # $at, 0x8012 /* 06DCBC 8006D0BC 10000040 */ b .L8006D1C0 /* 06DCC0 8006D0C0 A0203515 */ sb $zero, %lo(gIsPaused)($at) +glabel L8006D0C4 /* 06DCC4 8006D0C4 0C000414 */ jal func_80001050 /* 06DCC8 8006D0C8 00000000 */ nop /* 06DCCC 8006D0CC 0C030C53 */ jal func_800C314C @@ -276,6 +298,7 @@ glabel func_8006CCF0 .L8006D100: /* 06DD00 8006D100 1000002F */ b .L8006D1C0 /* 06DD04 8006D104 01C08025 */ move $s0, $t6 +glabel L8006D108 /* 06DD08 8006D108 0C000414 */ jal func_80001050 /* 06DD0C 8006D10C 00000000 */ nop /* 06DD10 8006D110 0C030C53 */ jal func_800C314C @@ -294,26 +317,31 @@ glabel func_8006CCF0 .L8006D144: /* 06DD44 8006D144 1000001E */ b .L8006D1C0 /* 06DD48 8006D148 01E08025 */ move $s0, $t7 +glabel L8006D14C /* 06DD4C 8006D14C 24180001 */ li $t8, 1 /* 06DD50 8006D150 0C030C53 */ jal func_800C314C /* 06DD54 8006D154 AFB80040 */ sw $t8, 0x40($sp) /* 06DD58 8006D158 36190020 */ ori $t9, $s0, 0x20 /* 06DD5C 8006D15C 10000018 */ b .L8006D1C0 /* 06DD60 8006D160 03208025 */ move $s0, $t9 +glabel L8006D164 /* 06DD64 8006D164 24090006 */ li $t1, 6 /* 06DD68 8006D168 0C030C53 */ jal func_800C314C /* 06DD6C 8006D16C AFA90040 */ sw $t1, 0x40($sp) /* 06DD70 8006D170 360A0020 */ ori $t2, $s0, 0x20 /* 06DD74 8006D174 10000012 */ b .L8006D1C0 /* 06DD78 8006D178 01408025 */ move $s0, $t2 +glabel L8006D17C /* 06DD7C 8006D17C 3C018012 */ lui $at, %hi(gIsPaused) # $at, 0x8012 /* 06DD80 8006D180 1000000F */ b .L8006D1C0 /* 06DD84 8006D184 A0203515 */ sb $zero, %lo(gIsPaused)($at) +glabel L8006D188 /* 06DD88 8006D188 0C008B86 */ jal func_80022E18 /* 06DD8C 8006D18C 24040001 */ li $a0, 1 /* 06DD90 8006D190 3C018012 */ lui $at, %hi(gIsPaused) # $at, 0x8012 /* 06DD94 8006D194 1000000A */ b .L8006D1C0 /* 06DD98 8006D198 A0203515 */ sb $zero, %lo(gIsPaused)($at) +glabel L8006D19C /* 06DD9C 8006D19C 3C01800E */ lui $at, %hi(D_800DD390) # $at, 0x800e /* 06DDA0 8006D1A0 0C000414 */ jal func_80001050 /* 06DDA4 8006D1A4 A020D390 */ sb $zero, %lo(D_800DD390)($at) @@ -324,6 +352,7 @@ glabel func_8006CCF0 /* 06DDB8 8006D1B8 360B0030 */ ori $t3, $s0, 0x30 /* 06DDBC 8006D1BC 01608025 */ move $s0, $t3 .L8006D1C0: +glabel L8006D1C0 /* 06DDC0 8006D1C0 3C048012 */ lui $a0, %hi(D_801211F8) # $a0, 0x8012 /* 06DDC4 8006D1C4 0C01E015 */ jal func_80078054 /* 06DDC8 8006D1C8 248411F8 */ addiu $a0, %lo(D_801211F8) # addiu $a0, $a0, 0x11f8 @@ -612,42 +641,48 @@ glabel func_8006CCF0 /* 06E1D8 8006D5D8 10200095 */ beqz $at, .L8006D830 /* 06E1DC 8006D5DC A2000000 */ sb $zero, ($s0) /* 06E1E0 8006D5E0 0019C880 */ sll $t9, $t9, 2 -/* 06E1E4 8006D5E4 3C01800E */ lui $at, %hi(D_800E71B8) # $at, 0x800e +/* 06E1E4 8006D5E4 3C01800E */ lui $at, %hi(jpt_800E71B8) # $at, 0x800e /* 06E1E8 8006D5E8 00390821 */ addu $at, $at, $t9 -/* 06E1EC 8006D5EC 8C3971B8 */ lw $t9, %lo(D_800E71B8)($at) +/* 06E1EC 8006D5EC 8C3971B8 */ lw $t9, %lo(jpt_800E71B8)($at) /* 06E1F0 8006D5F0 00000000 */ nop /* 06E1F4 8006D5F4 03200008 */ jr $t9 /* 06E1F8 8006D5F8 00000000 */ nop +glabel L8006D5FC /* 06E1FC 8006D5FC 2404000F */ li $a0, 15 /* 06E200 8006D600 2405FFFF */ li $a1, -1 /* 06E204 8006D604 0C01B68A */ jal func_8006DA28 /* 06E208 8006D608 24060001 */ li $a2, 1 /* 06E20C 8006D60C 10000088 */ b .L8006D830 /* 06E210 8006D610 00000000 */ nop +glabel L8006D614 /* 06E214 8006D614 24040011 */ li $a0, 17 /* 06E218 8006D618 24050022 */ li $a1, 34 /* 06E21C 8006D61C 0C01B68A */ jal func_8006DA28 /* 06E220 8006D620 00003025 */ move $a2, $zero /* 06E224 8006D624 10000082 */ b .L8006D830 /* 06E228 8006D628 00000000 */ nop +glabel L8006D62C /* 06E22C 8006D62C 24040014 */ li $a0, 20 /* 06E230 8006D630 24050022 */ li $a1, 34 /* 06E234 8006D634 0C01B68A */ jal func_8006DA28 /* 06E238 8006D638 00003025 */ move $a2, $zero /* 06E23C 8006D63C 1000007C */ b .L8006D830 /* 06E240 8006D640 00000000 */ nop +glabel L8006D644 /* 06E244 8006D644 24040015 */ li $a0, 21 /* 06E248 8006D648 24050022 */ li $a1, 34 /* 06E24C 8006D64C 0C01B68A */ jal func_8006DA28 /* 06E250 8006D650 00003025 */ move $a2, $zero /* 06E254 8006D654 10000076 */ b .L8006D830 /* 06E258 8006D658 00000000 */ nop +glabel L8006D65C /* 06E25C 8006D65C 24040016 */ li $a0, 22 /* 06E260 8006D660 24050022 */ li $a1, 34 /* 06E264 8006D664 0C01B68A */ jal func_8006DA28 /* 06E268 8006D668 00003025 */ move $a2, $zero /* 06E26C 8006D66C 10000070 */ b .L8006D830 /* 06E270 8006D670 00000000 */ nop +glabel L8006D674 /* 06E274 8006D674 0C027B34 */ jal is_drumstick_unlocked /* 06E278 8006D678 AFA00044 */ sw $zero, 0x44($sp) /* 06E27C 8006D67C 10400005 */ beqz $v0, .L8006D694 @@ -674,6 +709,7 @@ glabel func_8006CCF0 /* 06E2C8 8006D6C8 24050016 */ li $a1, 22 /* 06E2CC 8006D6CC 10000058 */ b .L8006D830 /* 06E2D0 8006D6D0 00000000 */ nop +glabel L8006D6D4 /* 06E2D4 8006D6D4 240D0001 */ li $t5, 1 /* 06E2D8 8006D6D8 A20D0000 */ sb $t5, ($s0) /* 06E2DC 8006D6DC 24040017 */ li $a0, 23 @@ -682,6 +718,7 @@ glabel func_8006CCF0 /* 06E2E8 8006D6E8 00003025 */ move $a2, $zero /* 06E2EC 8006D6EC 10000050 */ b .L8006D830 /* 06E2F0 8006D6F0 A2000000 */ sb $zero, ($s0) +glabel L8006D6F4 /* 06E2F4 8006D6F4 24040019 */ li $a0, 25 /* 06E2F8 8006D6F8 2405FFFF */ li $a1, -1 /* 06E2FC 8006D6FC 0C01B68A */ jal func_8006DA28 diff --git a/asm/non_matchings/unknown_066AA0/func_8006DCF8.s b/asm/non_matchings/unknown_066AA0/func_8006DCF8.s index 5d7a9d0b..64b369a1 100644 --- a/asm/non_matchings/unknown_066AA0/func_8006DCF8.s +++ b/asm/non_matchings/unknown_066AA0/func_8006DCF8.s @@ -1,3 +1,8 @@ +.late_rodata +glabel jpt_800E71D8 +.word L8006DF70, L8006E00C, L8006E054, L8006E0E0, L8006DEE8, L8006E0E0, L8006E0E0, L8006E0E0, L8006E0E0, L8006E0E0, L8006E0E0, L8006E0E0, L8006E0E0, L8006DF00 + +.text glabel func_8006DCF8 /* 06E8F8 8006DCF8 3C018012 */ lui $at, %hi(gIsPaused) # $at, 0x8012 /* 06E8FC 8006DCFC 3C0E8012 */ lui $t6, %hi(D_80123514) # $t6, 0x8012 @@ -121,18 +126,20 @@ glabel func_8006DCF8 /* 06EAC4 8006DEC4 2DC1000E */ sltiu $at, $t6, 0xe /* 06EAC8 8006DEC8 10200085 */ beqz $at, .L8006E0E0 /* 06EACC 8006DECC 000E7080 */ sll $t6, $t6, 2 -/* 06EAD0 8006DED0 3C01800E */ lui $at, %hi(D_800E71D8) # $at, 0x800e +/* 06EAD0 8006DED0 3C01800E */ lui $at, %hi(jpt_800E71D8) # $at, 0x800e /* 06EAD4 8006DED4 002E0821 */ addu $at, $at, $t6 -/* 06EAD8 8006DED8 8C2E71D8 */ lw $t6, %lo(D_800E71D8)($at) +/* 06EAD8 8006DED8 8C2E71D8 */ lw $t6, %lo(jpt_800E71D8)($at) /* 06EADC 8006DEDC 00000000 */ nop /* 06EAE0 8006DEE0 01C00008 */ jr $t6 /* 06EAE4 8006DEE4 00000000 */ nop +glabel L8006DEE8 /* 06EAE8 8006DEE8 2404000F */ li $a0, 15 /* 06EAEC 8006DEEC 2405FFFF */ li $a1, -1 /* 06EAF0 8006DEF0 0C01B68A */ jal func_8006DA28 /* 06EAF4 8006DEF4 24060001 */ li $a2, 1 /* 06EAF8 8006DEF8 100000F8 */ b .L8006E2DC /* 06EAFC 8006DEFC 8FBF0024 */ lw $ra, 0x24($sp) +glabel L8006DF00 /* 06EB00 8006DF00 3C088012 */ lui $t0, %hi(D_801234F4) # $t0, 0x8012 /* 06EB04 8006DF04 3C098012 */ lui $t1, %hi(D_80123504) # $t1, 0x8012 /* 06EB08 8006DF08 3C0B8012 */ lui $t3, %hi(D_80123508) # $t3, 0x8012 @@ -161,6 +168,7 @@ glabel func_8006DCF8 /* 06EB64 8006DF64 00402025 */ move $a0, $v0 /* 06EB68 8006DF68 100000DC */ b .L8006E2DC /* 06EB6C 8006DF6C 8FBF0024 */ lw $ra, 0x24($sp) +glabel L8006DF70 /* 06EB70 8006DF70 3C058012 */ lui $a1, %hi(D_80121250) # $a1, 0x8012 /* 06EB74 8006DF74 24A51250 */ addiu $a1, %lo(D_80121250) # addiu $a1, $a1, 0x1250 /* 06EB78 8006DF78 80B80000 */ lb $t8, ($a1) @@ -202,6 +210,7 @@ glabel func_8006DCF8 /* 06EC00 8006E000 00402025 */ move $a0, $v0 /* 06EC04 8006E004 100000B5 */ b .L8006E2DC /* 06EC08 8006E008 8FBF0024 */ lw $ra, 0x24($sp) +glabel L8006E00C /* 06EC0C 8006E00C 3C018012 */ lui $at, %hi(D_801234EC) # $at, 0x8012 /* 06EC10 8006E010 AC2034EC */ sw $zero, %lo(D_801234EC)($at) /* 06EC14 8006E014 3C038012 */ lui $v1, %hi(D_80123500) # $v1, 0x8012 @@ -220,6 +229,7 @@ glabel func_8006DCF8 /* 06EC48 8006E048 00000000 */ nop /* 06EC4C 8006E04C 100000A3 */ b .L8006E2DC /* 06EC50 8006E050 8FBF0024 */ lw $ra, 0x24($sp) +glabel L8006E054 /* 06EC54 8006E054 3C058012 */ lui $a1, %hi(D_80121250) # $a1, 0x8012 /* 06EC58 8006E058 3C018012 */ lui $at, %hi(D_801234EC) # $at, 0x8012 /* 06EC5C 8006E05C 24A51250 */ addiu $a1, %lo(D_80121250) # addiu $a1, $a1, 0x1250 @@ -256,6 +266,7 @@ glabel func_8006DCF8 /* 06ECD8 8006E0D8 10000080 */ b .L8006E2DC /* 06ECDC 8006E0DC 8FBF0024 */ lw $ra, 0x24($sp) .L8006E0E0: +glabel L8006E0E0 /* 06ECE0 8006E0E0 00002025 */ move $a0, $zero /* 06ECE4 8006E0E4 2405FFFF */ li $a1, -1 /* 06ECE8 8006E0E8 0C01B68A */ jal func_8006DA28 diff --git a/asm/unknown_070110.s b/asm/unknown_070110.s index 81043f7b..77e33d0f 100644 --- a/asm/unknown_070110.s +++ b/asm/unknown_070110.s @@ -1,5 +1,5 @@ /* The comment below is needed for this file to be picked up by generate_ld */ -/* RAM_POS: 0x80065F10 */ +/* RAM_POS: 0x8006F510 */ .section .text diff --git a/src/unknown_066AA0.c b/src/unknown_066AA0.c index a216afb4..efec9482 100644 --- a/src/unknown_066AA0.c +++ b/src/unknown_066AA0.c @@ -1,2298 +1,956 @@ -/* The comment below is needed for this file to be picked up by generate_ld */ -/* RAM_POS: 0x80065EA0 */ - -#include "types.h" -#include "macros.h" -#include "structs.h" -#include "fast3d.h" - -extern u32 osTvType; - -/************ .rodata ************/ - -const char D_800E6F00[] = "Camera Error: Illegal mode!\n"; -const char D_800E6F20[] = "Camera Error: Illegal player no!\n"; -const char D_800E6F34[] = "cameraPushSprMtx: model stack overflow!!\n"; -const char D_800E6F70[] = "\nCam do 2D sprite called with NULL pointer!"; -const char D_800E6F9C[] = "CamDo2DSprite FrameNo Overflow !!!\n"; -const char D_800E6FC0[] = "cameraPushModelMtx: model stack overflow!!\n"; -const char D_800E6FEC[] = "camPushModelMtx: bsp stack overflow!!\n"; -const char D_800E7010[] = "camPopModelMtx: model stack negative overflow!!\n"; -const char D_800E7048[] = "camPopModelMtx: bsp stack negative overflow!!\n"; - -const char D_800E7078[] = "%x."; -const char D_800E707C[] = "%x "; -const char D_800E7084[] = "\n"; -const char D_800E7088[] = "\n"; -const char D_800E708C[] = "%f "; -const char D_800E7094[] = "\n"; -const char D_800E7098[] = "\n"; - -const FloatLiteral D_800E709C = { 15000.0f }; -const FloatLiteral D_800E70A0 = { 15000.0f }; -const FloatLiteral D_800E70A4 = { 15000.0f }; - -// This is probably a file boundary. -const DoubleLiteral D_800E70A8 = { 0.0 }; - -const char D_800E70B0[] = "LOADLEVEL Error: Level out of range\n"; -const char D_800E70D8[] = "BossLev problem\n"; -const char D_800E70EC[] = "AITABLE Error: Table out of range\n"; -const char D_800E7110[] = "1.1605"; -const char D_800E7118[] = "02/10/97 16:03"; -const char D_800E7128[] = "pmountain"; - -const char D_800E7134[] = "BBB\n"; -const char D_800E713C[] = "CAR"; -const char D_800E7140[] = "HOV"; -const char D_800E7144[] = "PLN"; -const char D_800E7148[] = "Swapping\n"; - -// Jump table in func_8006CCF0 -const u32 D_800E7154[] = { - 0x8006CF68, 0x8006CF5C, 0x8006D024, 0x8006CF80, - 0x8006CF9C, 0x8006D024, 0x8006D024, 0x8006CFB0, - 0x8006CFC4, 0x8006CFD8, 0x8006CFEC, 0x8006D000, - 0x8006D014 -}; - -// Jump table in func_8006CCF0 -const u32 D_800E7188[] = { - 0x8006D0B8, 0x8006D0C4, 0x8006D108, 0x8006D19C, - 0x8006D14C, 0x8006D17C, 0x8006D188, 0x8006D1C0, - 0x8006D1C0, 0x8006D1C0, 0x8006D1C0, 0x8006D164 -}; - -// Jump table in func_8006CCF0 -const u32 D_800E71B8[] = { - 0x8006D5FC, 0x8006D614, 0x8006D62C, 0x8006D644, - 0x8006D65C, 0x8006D674, 0x8006D6D4, 0x8006D6F4, - 0x8006DF70, 0x8006E00C, 0x8006E054, 0x8006E0E0 -}; - -// Jump table in func_8006DCF8 -const u32 D_800E71D8[] = { - 0x8006DEE8, 0x8006E0E0, 0x8006E0E0, 0x8006E0E0, - 0x8006E0E0, 0x8006E0E0, 0x8006E0E0, 0x8006E0E0, - 0x8006E0E0, 0x8006DF00 -}; - - -/*********************************/ - -/************ .data ************/ - -s32 D_800DD060 = 0; // Currently unknown, might be a different type. - -/* Size: 0x34 bytes. */ -typedef struct unk800DD064 { - s32 unk0; - s32 unk4; - s32 unk8; - s32 unkC; - s32 unk10; - s32 unk14; - s32 unk18; - s32 unk1C; - s32 unk20; - s32 unk24; - s32 unk28; - s32 unk2C; - s32 unk30; -} unk800DD064; - -unk800DD064 D_800DD064[4] = { - { - 0x00, 0x00, 0x140, 0xF0, - 0xA0, 0x78, 0x140, 0xF0, - 0x00, 0x00, 0x13F, 0xEF, 0x00 - }, - { - 0x00, 0x00, 0x140, 0xF0, - 0xA0, 0x78, 0x140, 0xF0, - 0x00, 0x00, 0x13F, 0xEF, 0x00 - }, - { - 0x00, 0x00, 0x140, 0xF0, - 0xA0, 0x78, 0x140, 0xF0, - 0x00, 0x00, 0x13F, 0xEF, 0x00 - }, - { - 0x00, 0x00, 0x140, 0xF0, - 0xA0, 0x78, 0x140, 0xF0, - 0x00, 0x00, 0x13F, 0xEF, 0x00 - } -}; - -// Not sure about the typing here -s16 D_800DD134[10] = { - 0, 0, 0, 0, - 0, -1, -1, 0, - 0, 0 -}; - -// Not sure about the typing here -u16 D_800DD148[160] = { - 0, 0, 0x01FF, 0, - 0, 0, 0x01FF, 0, - 0, 0, 0x01FF, 0, - 0, 0, 0x01FF, 0, - 0, 0, 0x01FF, 0, - 0, 0, 0x01FF, 0, - 0, 0, 0x01FF, 0, - 0, 0, 0x01FF, 0, - 0, 0, 0x01FF, 0, - 0, 0, 0x01FF, 0, - 0, 0, 0x01FF, 0, - 0, 0, 0x01FF, 0, - 0, 0, 0x01FF, 0, - 0, 0, 0x01FF, 0, - 0, 0, 0x01FF, 0, - 0, 0, 0x01FF, 0, - 0, 0, 0x01FF, 0, - 0, 0, 0x01FF, 0, - 0, 0, 0x01FF, 0, - 0, 0, 0x01FF, 0, - 0, 0, 0x01FF, 0, - 0, 0, 0x01FF, 0, - 0, 0, 0x01FF, 0, - 0, 0, 0x01FF, 0, - 0, 0, 0x01FF, 0, - 0, 0, 0x01FF, 0, - 0, 0, 0x01FF, 0, - 0, 0, 0x01FF, 0, - 0, 0, 0x01FF, 0, - 0, 0, 0x01FF, 0, - 0, 0, 0x01FF, 0, - 0, 0, 0x01FF, 0, - 0, 0, 0x01FF, 0, - 0, 0, 0x01FF, 0, - 0, 0, 0x01FF, 0, - 0, 0, 0x01FF, 0, - 0, 0, 0x01FF, 0, - 0, 0, 0x01FF, 0, - 0, 0, 0x01FF, 0, - 0, 0, 0x01FF, 0 -}; - -f32 D_800DD288[6] = { - 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, -281.0f -}; - -f32 D_800DD2A0[6] = { - 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f -}; - -f32 D_800DD2B8[5] = { - 1.0f, 0.0f, 0.0f, 0.0f, 0.0f -}; - -f32 D_800DD2CC[11] = { - 1.0f, 0.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 160.0f -}; - -u8 D_800DD2F8[8] = { - 0, 0, 0, 0, 0, 0, 0, 0 -}; - -s32 D_800DD300 = 0; // Currently unknown, might be a different type. - -s16 D_800DD304 = -1; - -// Remove this when unknown_066AA0 is split. -s32 __FILE_BOUNDARY_PADDING[2] = {0, 0}; - -/** File boundary! The following variables belong to the next file when unknown_066AA0 is split **/ - -s8 D_800DD310 = 0; // Currently unknown, might be a different type. -s8 D_800DD314 = -1; -s8 D_800DD318 = 0; -s32 D_800DD31C = 0; -s32 D_800DD320 = 0x585E; -s32 D_800DD324 = 0x154; -s16 D_800DD328 = 0; -s16 D_800DD32C = 0; - -s8 D_800DD330 = 0; - -// Unused? -char *D_800DD334[6] = { - NULL, NULL, NULL, // These also could just be regular zeroes and not pointers. - D_800E7110, D_800E7118, D_800E7128 -}; - -// Unused? -char gBuildString[40] = "Version 7.7 29/09/97 15.00 L.Schuneman"; - -s8 D_800DD374 = 0; -s32 D_800DD378 = 1; -s32 D_800DD37C = 0; -s32 D_800DD380 = 0; // Currently unknown, might be a different type. -s32 D_800DD384 = 0; -s32 D_800DD388 = 0; // Currently unknown, might be a different type. -s8 D_800DD38C = 0; -u8 D_800DD390 = 0; -s16 D_800DD394 = 0; -u8 D_800DD398 = 0; -s32 D_800DD39C = 0; // Currently unknown, might be a different type. -s8 D_800DD3A0 = 0; -s32 D_800DD3A4 = 0; // Currently unknown, might be a different type. -s32 D_800DD3A8 = 0; // Currently unknown, might be a different type. -s32 D_800DD3AC = 0; // Currently unknown, might be a different type. -s32 D_800DD3B0 = 0x1194; -s32 D_800DD3B4 = 0x1B58; -s32 D_800DD3B8 = 0x2AF8; -s32 D_800DD3BC = 0x2AF8; -s32 D_800DD3C0 = 0x12C; -s32 D_800DD3C4 = 0x258; -s32 D_800DD3C8 = 0x352; -s32 D_800DD3CC = 0x384; -s32 D_800DD3D0 = 0x12C; -s32 D_800DD3D4 = 0x190; -s32 D_800DD3D8 = 0x226; -s32 D_800DD3DC = 0x258; -s32 D_800DD3E0 = 0x14; -s32 D_800DD3E4 = 0x1E; -s32 D_800DD3E8 = 0x28; -s32 D_800DD3EC = 0x32; - -s8 D_800DD3F0 = 0; -s16 D_800DD3F4[8] = { - -32768, 0, 20, 0, - 255, -1, 20, -1 -}; -s32 D_800DD404 = 12; -s32 D_800DD408 = 0x00FFFFFF; -s32 D_800DD40C = 0x001EFFFF; // Unused? - -// Unused? -char *D_800DD410[3] = { - D_800E713C, D_800E7140, D_800E7144 -}; - -// Not sure if this is an array or a struct. -s32 D_800DD41C[2] = { - 0, 0x001EFFFF -}; - -s32 D_800DD424[2] = { - 0, 0x0104FFFF -}; -extern s32 D_800DFD94; - -/*******************************/ - -/* Size: 0x44 bytes */ -typedef struct unk80120AC0 { - s16 unk0; - s16 unk2; - s16 unk4; - u8 pad6[6]; - f32 x_position; - f32 y_position; - f32 z_position; - f32 pad18; - f32 unk1C; - f32 pad20; - f32 unk24; - f32 unk28; - f32 unk2C; - f32 unk30; - s16 unk34; - s16 pad36; - s16 unk38; - s8 pad3A; - s8 unk3B; - u8 pad3C[8]; -} unk80120AC0; - -extern unk80120AC0 D_80120AC0[4]; // Unknown number of entries. -extern unk80120AC0 D_80120AFB[4]; // Unknown number of entries. -extern unk80120AC0 D_80120BD0[4]; // Unknown number of entries. -extern s32 D_80120CE0; -extern s32 D_80120CE4; -extern s32 D_80120CE8; -extern s32 D_80120D08; -extern s32 D_80120D0C; -extern f32 D_80120D10; -extern s8 D_80120D14; -extern u8 D_80120D15; -extern s32 D_80120D18; -extern s32 D_80120D1C; -extern s32 D_80120D6C; -extern s32 D_80120D70[6]; -extern s32 D_80120D88[6]; // Unknown number of entries. -extern s32 D_80120EE0; -extern s32 D_80120F20; -extern s32 D_80120F60; -extern s32 D_80120FE0; -extern s32 D_80120FA0; -extern s32 D_80121060; -extern s32 D_801210A0; -extern s32 D_801210E0; - -/* Size: 5 bytes */ -typedef struct unk80121110 { - u16 unk0; - s8 unk2; - s8 unk3; - s8 unk4; -} unk80121110; -extern unk80121110 D_80121110[2]; // Unknown number of entries -extern u16 D_80121140[2]; // Unknown number of entries. -extern u16 D_80121148[2]; // Unknown number of entries. -extern u8 D_80121150[8]; // Unknown number of entries. -extern s32 D_80121164; - -extern LevelHeader* D_80121168; - -extern s32 D_80121170; -extern s32 D_80121174; - -// Size: 6 bytes -typedef struct unk8012117C { - s8 unk0; - s8 unk1; - s8 unk2; - s8 pad3[3]; -} unk8012117C; -extern unk8012117C *D_8012117C[2]; // Unknown number of entries - -extern s32 D_801211C0; -extern s16 D_801211C8[8]; // Unknown number of entries -extern Gfx *D_801211F0[3]; // Unknown number of entries. -extern Gfx *D_801211F8; -extern s32 D_80121208; -extern s32 D_80121218; -extern s32 D_80121228; -extern s8 D_80121250[16]; // Unknown number of entries -extern s32 D_801234E8; -extern s32 D_801234EC; -extern s32 D_801234F0; -extern s32 D_801234F4; -extern s32 D_801234F8; -extern s32 D_801234FC; -extern s32 D_80123500; -extern s32 D_80123504; -extern s32 D_80123508; -extern Settings *gSettingsPtr; -extern s8 D_80123514; -extern s8 gIsPaused; -extern s8 D_80123516; -extern s32 D_80123518; -extern s32 D_8012351C; -extern s32 D_80123520; -extern u8 D_80123524; -extern u8 D_80123525; -extern u8 D_80123526; -extern s32* D_80123548; // This is actually an OSMesgQueue pointer. -extern s32 D_80123560; - -extern s32 D_A4000000; -extern s32 SP_IMEM; - -void func_800014BC(f32 arg0); -s8* func_8001E29C(s32 arg0); -s32 func_8006A624(s8 arg0); -void func_8006F64C(s32*, f32, f32, f32, f32*, f32*, f32*); -void guPerspectiveF(s32*, s32*, f32, f32, f32, f32, f32); -void func_8006F870(s32*, s32*); -s16 func_80029F18(f32, f32, f32); -void func_8006A50C(void); -void func_8006CB58(s32 arg0, s32 arg1, s32 arg2, s32 arg3); -void func_8006C164(void); -void func_8000E194(void); -f32 sqrtf(f32); -void osSetTime(u64); -unk80120AC0 *func_80069D20(void); -void func_800665E8(s32 arg0); -void func_8001D5E0(f32 arg0, f32 arg1, f32 arg2); -void func_800705F8(s32, f32, f32, f32); -void func_8006ECFC(s32 arg0); - -GLOBAL_ASM("asm/non_matchings/unknown_066AA0/func_80065EA0.s") - -void func_80066060(s32 arg0, s32 arg1) { - if (arg0 >= 0 && arg0 < 4) { - D_800DD2F8[arg0] = arg1; - D_80120AC0[arg0].unk3B = arg1; - } -} - -void func_80066098(s8 arg0) { - s8 temp = (arg0 << 24) >> 24; - if (!osTvType) { - D_80120D15 = temp; - } -} -void func_800660C0(void) { - D_80120D18 = 1; -} -void func_800660D0(void) { - D_80120D18 = 0; -} -/* Unused? */ -f32 func_800660DC(void) { - return D_80120D10; -} - -void func_800660EC(f32 arg0) { - if (0.0f < arg0 && arg0 < 90.0f && arg0 != D_80120D10) { - D_80120D10 = arg0; - guPerspectiveF(&D_80120EE0, &D_80120D6C, arg0, 1.33333333f, 10.0f, D_800E70A0.floatLiteral, 1.0f); - func_8006F870(&D_80120EE0, &D_80120FE0); - } -} - -void func_80066194(void) { - guPerspectiveF(&D_80120EE0, &D_80120D6C, 60.0f, 1.33333333f, 10.0f, D_800E70A4.floatLiteral, 1.0f); - func_8006F870(&D_80120EE0, &D_80120FE0); -} - -/* Unused? */ -s32* func_80066204(void) { - return &D_801210A0; -} - -s32 func_80066210(void) { - return D_80120CE0; -} - -s32 func_80066220(void) { - return D_80120CE4; -} - -void func_80066230(s32 arg0, s32 arg1) { - unk80120AC0 *someStruct; - s16 sp2A; - s16 sp28; - s16 sp26; - s16 sp24; - f32 sp20; - f32 sp1C; - f32 sp18; - - func_8006652C(0); - func_800665E8(0); - someStruct = func_80069D20(); - sp2A = someStruct->unk0; - sp28 = someStruct->unk2; - sp26 = someStruct->unk4; - sp20 = someStruct->x_position; - sp1C = someStruct->y_position; - sp18 = someStruct->z_position; - sp24 = someStruct->unk38; - someStruct->unk4 = 0; - someStruct->unk2 = 0; - someStruct->unk0 = -0x8000; - someStruct->unk38 = 0; - someStruct->x_position = 0.0f; - someStruct->y_position = 0.0f; - someStruct->z_position = 0.0f; - func_8001D5E0(0.0f, 0.0f, -1.0f); - func_80066CDC(arg0, arg1); - someStruct->unk38 = sp24; - someStruct->unk0 = sp2A; - someStruct->unk2 = sp28; - someStruct->unk4 = sp26; - someStruct->x_position = sp20; - someStruct->y_position = sp1C; - someStruct->z_position = sp18; -} - -f32 func_80066348(f32 arg0, f32 arg1, f32 arg2) { - s32 phi_v1; - f32 temp_f2, temp_f0, temp_f14; - - phi_v1 = D_80120CE4; - - if (D_80120D14 != 0) { - phi_v1 += 4; - } - - temp_f0 = arg2 - D_80120AC0[phi_v1].z_position; - temp_f2 = arg0 - D_80120AC0[phi_v1].x_position; - temp_f14 = arg1 - D_80120AC0[phi_v1].y_position; - return sqrtf((temp_f0 * temp_f0) + ((temp_f2 * temp_f2) + (temp_f14 * temp_f14))); -} - -void func_800663DC(s32 x_pos, s32 y_pos, s32 z_pos, s32 arg3, s32 arg4, s32 arg5) { - D_80120AC0[D_80120CE4].unk4 = (s16) (arg3 * 0xB6); - D_80120AC0[D_80120CE4].x_position = (f32) x_pos; - D_80120AC0[D_80120CE4].y_position = (f32) y_pos; - D_80120AC0[D_80120CE4].z_position = (f32) z_pos; - D_80120AC0[D_80120CE4].unk2 = (s16) (arg4 * 0xB6); - D_80120AC0[D_80120CE4].unk38 = (u16)0; - D_80120AC0[D_80120CE4].unk24 = 0.0f; - D_80120AC0[D_80120CE4].unk28 = 0.0f; - D_80120AC0[D_80120CE4].unk2C = 0.0f; - D_80120AC0[D_80120CE4].unk30 = 0.0f; - D_80120AC0[D_80120CE4].unk1C = 160.0f; - D_80120AC0[D_80120CE4].unk0 = (s16) (arg5 * 0xB6); - D_80120AC0[D_80120CE4].unk3B = D_800DD2F8[D_80120CE4]; -} - -void func_80066488(s32 arg0, f32 arg1, f32 arg2, f32 arg3, s16 arg4, s16 arg5, s16 arg6) { - arg0 += 4; - D_80120AC0[arg0].unk38 = 0; - D_80120AC0[arg0].x_position = arg1; - D_80120AC0[arg0].y_position = arg2; - D_80120AC0[arg0].z_position = arg3; - D_80120AC0[arg0].unk0 = arg4; - D_80120AC0[arg0].unk2 = arg5; - D_80120AC0[arg0].unk4 = arg6; - D_80120AC0[arg0].unk34 = func_80029F18(arg1, arg2, arg3); - D_80120D14 = 1; -} - -s8 func_80066510(void) { - return D_80120D14; -} - -void func_80066520(void) { - D_80120D14 = 0; -} - -s32 func_8006652C(s32 arg0) { - if ((arg0 >= 0) && (arg0 < 4)) { - D_80120CE0 = arg0; - } else { - D_80120CE0 = 0; - } - switch(D_80120CE0) { - case 0: - D_80120CE8 = 1; - break; - case 1: - D_80120CE8 = 2; - break; - case 2: - D_80120CE8 = 3; - break; - case 3: - D_80120CE8 = 4; - break; - } - if (D_80120CE4 >= D_80120CE8) { - D_80120CE4 = 0; - } - return D_80120CE8; -} - -void func_800665E8(s32 arg0) { - if (arg0 >= 0 && arg0 < 4) { - D_80120CE4 = arg0; - } else { - D_80120CE4 = 0; - } -} - -GLOBAL_ASM("asm/non_matchings/unknown_066AA0/func_80066610.s") - -void func_80066818(s32 arg0, s32 arg1) { - if (arg1 != 0) { - D_800DD064[arg0].unk30 |= 1; - } else { - D_800DD064[arg0].unk30 |= 2; - } - D_800DD064[arg0].unk30 &= -5; -} - -void func_80066894(s32 arg0, s32 arg1) { - if (arg1 != 0) { - D_800DD064[arg0].unk30 &= -2; - } else { - D_800DD064[arg0].unk30 |= 4; - } - D_800DD064[arg0].unk30 &= -3; -} - -s32 func_80066910(s32 arg0) { - return D_800DD064[arg0].unk30 & 0x1; -} - -GLOBAL_ASM("asm/non_matchings/unknown_066AA0/func_80066940.s") - -void func_80066AA8(s32 arg0, s32 arg1, s32 arg2, s32 arg3, s32 arg4) { - if (arg1 != 0x8000) { - D_800DD064[arg0].unk10 = arg1; - D_800DD064[arg0].unk30 |= 8; - } else { - D_800DD064[arg0].unk30 &= 0xFFFFFFF7; - } - if (arg2 != 0x8000) { - D_800DD064[arg0].unk10 = arg2; - D_800DD064[arg0].unk30 |= 0x10; - } else { - D_800DD064[arg0].unk30 &= 0xFFFFFFEF; - } - if (arg3 != 0x8000) { - D_800DD064[arg0].unk18 = arg3; - D_800DD064[arg0].unk30 |= 0x20; - } else { - D_800DD064[arg0].unk30 &= 0xFFFFFFDF; - } - if (arg4 != 0x8000) { - D_800DD064[arg0].unk1C = arg4; - D_800DD064[arg0].unk30 |= 0x40; - return; - } - D_800DD064[arg0].unk30 &= 0xFFFFFFBF; -} - -s32 func_80066BA8(s32 arg0, s32 *arg1, s32 *arg2, s32 *arg3, s32 *arg4) { - *arg1 = D_800DD064[arg0].unk20; - *arg3 = D_800DD064[arg0].unk28; - *arg2 = D_800DD064[arg0].unk24; - *arg4 = D_800DD064[arg0].unk2C; - if ((*arg1 | *arg3 | *arg2 | *arg4) == 0) { - return 0; - } - return 1; -} - -void func_80066C2C(s32 arg0, s32 *arg1, s32 *arg2, s32 *arg3, s32 *arg4) { - *arg1 = D_800DD064[arg0].unk0; - *arg2 = D_800DD064[arg0].unk4; - *arg3 = D_800DD064[arg0].unk8; - *arg4 = D_800DD064[arg0].unkC; -} - -// Unused? -void func_80066C80(s32 *arg0, s32 *arg1, s32 *arg2, s32 *arg3) { - u32 temp_v0 = func_8007A520(); - *arg0 = 0; - *arg1 = 0; - *arg2 = temp_v0 & 0xFFFF; - *arg3 = (u32) (temp_v0 >> 0x10); -} - - -#if 1 -GLOBAL_ASM("asm/non_matchings/unknown_066AA0/func_80066CDC.s") -#else -// Work in progress! - -void func_80066CDC(Gfx **dlist, s32 *arg1) { - u32 sp58; - u32 sp54; - u32 sp50; - u32 sp4C; - s32 sp34; - s32 sp2C; - u32 temp_a0; - u32 temp_a0_3; - u32 temp_a0_4; - u32 temp_a2; - u32 temp_a3; - u32 temp_a3_2; - u32 temp_t0; - u32 temp_t1_2; - u32 temp_v0; - u32 temp_v0_3; - u32 temp_v0_4; - u32 temp_v1_10; - u32 temp_v1_3; - u32 temp_v1_4; - s32 phi_t1; - s32 phi_v1; - f32 phi_f6; - f32 phi_f18; - f32 phi_f16; - f32 phi_f8; - f32 phi_f6_2; - f32 phi_f18_2; - f32 phi_f8_2; - f32 phi_f16_2; - u32 phi_a1; - f32 phi_f8_3; - f32 phi_f16_3; - f32 phi_f16_4; - u32 phi_t3; - u32 phi_a3_2; - u32 phi_t5; - u32 phi_t4; - - sp34 = D_80120CE4; - phi_t1 = D_80120CE4; - if (func_8000E184() && D_80120CE0 == 0) { - D_80120CE4 = 1; - phi_t1 = 0; - } - temp_v0 = func_8007A520(); - temp_t0 = temp_v0 >> 0x10; - temp_a3 = temp_t0 >> 1; - - if (D_800DD064[phi_t1].unk30 & 1) { - sp2C = D_80120CE4; - D_80120CE4 = phi_t1; - fast3d_cmd( - (*dlist)++, - ((((s32)(D_800DD064[D_80120CE4].unk24 * 4.0f)) & 0xFFF) | 0xED000000) | (((s32)(D_800DD064[D_80120CE4].unk20 * 4.0f)) & 0xFFF) << 0xC, - (((s32)(D_800DD064[D_80120CE4].unk2C * 4.0f)) & 0xFFF) | (((s32)(D_800DD064[D_80120CE4].unk28 * 4.0f)) & 0xFFF) << 0xC - ) - func_80068158(dlist, 0, 0, 0, 0); - D_80120CE4 = sp2C; - if (arg1 != 0) { - func_80067D3C(dlist, arg1); - } - D_80120CE4 = sp34; - return; - } - temp_t1_2 = temp_v0 & 0xFFFF; - phi_v1 = D_80120CE0; - if (D_80120CE0 == 2) { - phi_v1 = 3; - } - temp_a2 = temp_t1_2 >> 1; - sp54 = temp_a2; - sp58 = temp_a3; - if (osTvType == 0) { - sp58 = 0x91; - } - - switch(phi_v1) { - case 0: - phi_t3 = sp58; - if (osTvType == 0) { - phi_t3 = sp58 - 0x12; - } - phi_f16_4 = temp_t0; - if (temp_t0 < 0) { - phi_f16_4 = temp_t0 + 4294967296.0f; - } - fast3d_cmd( - (*dlist)++, - 0xED000000, - ((((s32)(temp_t1_2 * 4.0f)) & 0xFFF) << 0xC) | (((s32)(phi_f16_4 * 4.0f)) & 0xFFF) - ) - sp4C = temp_a2; - phi_a3_2 = temp_a2; - break; - case 1: - if (D_80120CE4 == 0) { - temp_v0_4 = temp_t0 >> 2; - phi_t3 = temp_v0_4; - if (osTvType == 0) { - phi_t3 = temp_v0_4 - 0xC; - } - phi_f8_3 = temp_a3 - (temp_t0 >> 7); - if (phi_f8_3 < 0) { - phi_f8_3 += 4294967296.0f; - } - fast3d_cmd( - (*dlist)++, - 0xED000000, - ((((s32)(temp_t1_2 * 4.0f)) & 0xFFF) << 0xC) | (((s32)(phi_f8_3 * 4.0f)) & 0xFFF) - ) - } else { - temp_v1_10 = temp_t0 >> 7; - phi_f16_3 = temp_t0 - temp_v1_10; - if (phi_f16_3 < 0) { - phi_f16_3 += 4294967296.0f; - } - fast3d_cmd( - (*dlist)++, - (((s32)((temp_a3 + temp_v1_10) * 4.0f)) & 0xFFF) | 0xED000000, - ((((s32)(temp_t1_2 * 4.0f)) & 0xFFF) << 0xC) | (((s32)(phi_f16_3 * 4.0f)) & 0xFFF) - ) - phi_t3 = temp_a3 + (temp_t0 >> 2); - } - sp4C = temp_a2; - phi_a3_2 = temp_a2; - break; - case 2: - if (D_80120CE4 == 0) { - phi_f8_2 = temp_t0; - if (temp_t0 < 0) { - phi_f8_2 = temp_t0 + 4294967296.0f; - } - fast3d_cmd( - (*dlist)++, - 0xED000000, - ((((s32)((temp_a2 - (temp_t1_2 >> 8)) * 4.0f)) & 0xFFF) << 0xC) | (((s32)(phi_f8_2 * 4.0f)) & 0xFFF) - ) - phi_a1 = temp_t1_2 >> 2; - } else { - temp_a0_4 = temp_t1_2 >> 8; - phi_f16_2 = temp_t0; - if (temp_t0 < 0) { - phi_f16_2 = temp_t0 + 4294967296.0f; - } - fast3d_cmd( - (*dlist)++, - (((s32)((temp_a2 + temp_a0_4) * 4.0f) & 0xFFF) << 0xC) | 0xED000000, - (((s32)((temp_t1_2 - temp_a0_4) * 4.0f) & 0xFFF) << 0xC) | (((s32)(phi_f16_2 * 4.0f)) & 0xFFF) - ) - phi_a1 = temp_a2 + (temp_t1_2 >> 2); - } - sp4C = phi_a1; - phi_t3 = sp58; - phi_a3_2 = phi_a1; - break; - case 3: - switch(D_80120CE4) { - case 0: - phi_f6_2 = temp_a2 - (temp_t1_2 >> 8); - if (phi_f6_2 < 0) { - phi_f6_2 += 4294967296.0f; - } - phi_f18_2 = temp_a3 - (temp_t0 >> 7); - if (phi_f18_2 < 0) { - phi_f18_2 += 4294967296.0f; - } - fast3d_cmd( - (*dlist)++, - ((((s32)(0U * 4.0f) & 0xFFF) << 0xC) | 0xED000000) | (((s32)(0U * 4.0f)) & 0xFFF), - (((s32)(phi_f6_2 * 4.0f) & 0xFFF) << 0xC) | (((s32)(phi_f18_2 * 4.0f)) & 0xFFF) - ) - phi_t5 = 0U; - phi_t4 = 0U; - break; - case 1: - temp_a0_3 = temp_t1_2 >> 8; - phi_f8 = temp_a3 - (temp_t0 >> 7); - if (phi_f8 < 0) { - phi_f8 += 4294967296.0f; - } - fast3d_cmd( - (*dlist)++, - ((((s32)((temp_a2 + temp_a0_3) * 4.0f)) & 0xFFF) << 0xC) | 0xED000000, - ((((s32)(((temp_a2 * 2) - temp_a0_3) * 4.0f)) & 0xFFF) << 0xC) | (((s32)(phi_f8 * 4.0f)) & 0xFFF) - ) - phi_t5 = 0U; - phi_t4 = temp_a2; - break; - case 2: - temp_v1_4 = temp_t0 >> 7; - phi_f16 = (temp_a3 * 2) - temp_v1_4; - if (phi_f16 < 0) { - phi_f16 += 4294967296.0f; - } - fast3d_cmd( - (*dlist)++, - (((s32)((temp_a3 + temp_v1_4) * 4.0f)) & 0xFFF) | 0xED000000, - ((((s32)((temp_a2 - (temp_t1_2 >> 8)) * 4.0f)) & 0xFFF) << 0xC) | (((s32)(phi_f16 * 4.0f)) & 0xFFF) - ) - phi_t5 = temp_a3; - phi_t4 = 0U; - break; - case 3: - temp_a0 = temp_t1_2 >> 8; - temp_v1_3 = temp_t0 >> 7; - phi_f6 = (temp_a2 * 2) - temp_a0; - if (phi_f6 < 0) { - phi_f6 += 4294967296.0f; - } - phi_f18 = (temp_a3 * 2) - temp_v1_3; - if (phi_f18 < 0) { - phi_f18 += 4294967296.0f; - } - fast3d_cmd( - (*dlist)++, - (((((s32)((temp_a2 + temp_a0) * 4.0f)) & 0xFFF) << 0xC) | 0xED000000) | (((s32)((temp_a3 + temp_v1_3) * 4.0f)) & 0xFFF), - ((((s32)(phi_f6 * 4.0f) & 0xFFF)) << 0xC) | (((s32)(phi_f18 * 4.0f)) & 0xFFF) - ) - phi_t5 = temp_a3; - phi_t4 = temp_a2; - break; - default: - phi_t5 = 0; - phi_t4 = 0; - break; - } - temp_v0_3 = phi_t5 + sp58; - temp_a3_2 = phi_t4 + sp54; - phi_t3 = temp_v0_3; - phi_a3_2 = temp_a3_2; - if (osTvType == 0) { - phi_t3 = temp_v0_3 - 6; - phi_a3_2 = temp_a3_2; - if (D_80120CE4 < 2) { - phi_t3 = temp_v0_3 - 0x14; - phi_a3_2 = temp_a3_2; - } - } - break; - default: - phi_t3 = sp50; - phi_a3_2 = sp4C; - break; - } - - if (osTvType == 0) { - phi_a3_2 -= 4; - } - func_80068158(dlist, sp54, sp58, phi_a3_2, phi_t3); - if (arg1 != 0) { - func_80067D3C(dlist, arg1); - } - D_80120CE4 = sp34; -} -#endif - -GLOBAL_ASM("asm/non_matchings/unknown_066AA0/func_80067A3C.s") -GLOBAL_ASM("asm/non_matchings/unknown_066AA0/func_80067D3C.s") - -void func_80067F20(f32 arg0) { - D_800DD2CC[0] = arg0; -} - -GLOBAL_ASM("asm/non_matchings/unknown_066AA0/func_80067F2C.s") - -void func_8006807C(Gfx **dlist, s32 *arg1) { - func_8006FE74(&D_80121060, &D_800DD288); - func_8006F768(&D_80121060, &D_80120EE0, &D_80120F20); - func_8006FE74(D_80120D70[0], &D_800DD2A0); - func_8006F768(D_80120D70[0], &D_80120F20, &D_80121060); - func_8006F870(&D_80121060, (s32*)*arg1); // This doesn't look right. Need to check this! - fast3d_cmd((*dlist)++, 0x1000040, (u32)(*arg1 + 0x80000000)) - *arg1 += 0x40; - D_80120D1C = 0; - D_80120D08 = 0; -} - -GLOBAL_ASM("asm/non_matchings/unknown_066AA0/func_80068158.s") -GLOBAL_ASM("asm/non_matchings/unknown_066AA0/func_800682AC.s") - -void func_80068408(Gfx **dlist, s32 *arg1) { - func_800705F8(D_80120D70[D_80120D1C], 0.0f, 0.0f, 0.0f); - func_8006F768(D_80120D70[D_80120D1C], &D_80120F20, &D_80121060); - func_8006F870(&D_80121060, (s32*)*arg1); // This doesn't look right. Need to check this! - D_80120D88[D_80120D1C] = *arg1; - - fast3d_cmd((*dlist)++, ((((D_80120D08 << 6) & 0xFF) << 0x10) | 0x1000000) | 0x40, (u32)(*arg1 + 0x80000000)) - - *arg1 += 0x40; -} - -void func_80068508(s32 arg0) { - D_80120D0C = arg0; -} - -GLOBAL_ASM("asm/non_matchings/unknown_066AA0/func_80068514.s") -GLOBAL_ASM("asm/non_matchings/unknown_066AA0/func_80068BF4.s") -GLOBAL_ASM("asm/non_matchings/unknown_066AA0/func_80068FA8.s") -GLOBAL_ASM("asm/non_matchings/unknown_066AA0/func_80069484.s") -GLOBAL_ASM("asm/non_matchings/unknown_066AA0/func_80069790.s") -GLOBAL_ASM("asm/non_matchings/unknown_066AA0/func_80069A40.s") - -unk80120AC0 *func_80069CFC(void) { - return &D_80120AC0[D_80120CE4]; -} - -unk80120AC0 *func_80069D20(void) { - if (D_80120D14 != 0) { - return &D_80120AC0[D_80120CE4 + 4]; - } - return &D_80120AC0[D_80120CE4]; -} - -unk80120AC0 *func_80069D7C(void) { - if (D_80120D14 != 0) { - return D_80120BD0; - } - return D_80120AC0; -} - -s32* func_80069DA4(void) { - return &D_80120FA0; -} - -s32* func_80069DB0(void) { - return &D_80120FE0; -} - -s32* func_80069DBC(void) { - return &D_80120F60; -} - -f32 func_80069DC8(f32 arg0, f32 arg1, f32 arg2) { - f32 sp34; - f32 sp30; - f32 returnVal; - func_8006F64C(&D_80120F60, arg0, arg1, arg2, &sp34, &sp30, &returnVal); - return returnVal; -} - -void func_80069E14(f32 arg0, f32 arg1, f32 arg2, f32 arg3, f32 arg4) { - f32 temp_f0; - f32 temp_f0_2; - f32 temp_f14; - f32 temp_f2; - s32 i; - - for (i = 0; i <= D_80120CE0; i++) { - temp_f0 = arg0 - D_80120AC0[i].x_position; - temp_f2 = arg1 - D_80120AC0[i].y_position; - temp_f14 = arg2 - D_80120AC0[i].z_position; - temp_f0_2 = sqrtf(((temp_f0 * temp_f0) + (temp_f2 * temp_f2)) + (temp_f14 * temp_f14)); - if (temp_f0_2 < arg3) { - D_80120AC0[i].unk30 = ((arg3 - temp_f0_2) * arg4) / arg3; - } - } -} - -GLOBAL_ASM("asm/non_matchings/unknown_066AA0/func_80069F28.s") - -s32* func_8006A100(void) { - return &D_801210E0; -} - -#if 1 -GLOBAL_ASM("asm/non_matchings/unknown_066AA0/func_8006A10C.s") -#else - -extern s32 D_800DD300; -extern s32 D_801210F8; -extern s32 D_801210FC; -extern s8 D_80121100; -extern u8 D_80121103; - -// Has regalloc & stack issues. -s32 func_8006A10C(void) { - u8 sp23; - osCreateMesgQueue(&D_801210E0, &D_801210F8, 1); - osSetEventMesg(5, &D_801210E0, D_801210FC); - func_800CCC20(&D_801210E0, &sp23, &D_80121100); - func_800CCFE0(&D_801210E0); - func_8006A434(); - D_800DD300 = 0; - if ((sp23 & 1) && !(D_80121103 & 8)) { - return 0; - } - D_800DD300 = 1; - return -1; -} -#endif - -GLOBAL_ASM("asm/non_matchings/unknown_066AA0/func_8006A1C4.s") -GLOBAL_ASM("asm/non_matchings/unknown_066AA0/func_8006A434.s") - -void func_8006A458(s8 *activePlayers) { - s32 i; - s32 temp = 0; - for(i = 0; i < 4; i++) { - if (activePlayers[i]) { - D_80121150[temp++] = i; - } - } - for(i = 0; i < 4; i++) { - if (!activePlayers[i]) { - D_80121150[temp++] = i; - } - } -} - -u8 func_8006A4F8(s32 arg0) { - return D_80121150[arg0]; -} - -void func_8006A50C(void) { - u8 temp = D_80121150[0]; - D_80121150[0] = D_80121150[1]; - D_80121150[1] = temp; -} - -u16 func_8006A528(s32 arg0) { - return D_80121110[D_80121150[arg0]].unk0; -} - -u16 func_8006A554(s32 arg0) { - return D_80121140[D_80121150[arg0]]; -} - -u16 func_8006A578(s32 arg0) { - return D_80121148[D_80121150[arg0]]; -} - -s32 func_8006A59C(s32 arg0) { - func_8006A624(D_80121110[D_80121150[arg0]].unk2); -} - -s32 func_8006A5E0(s32 arg0) { - func_8006A624(D_80121110[D_80121150[arg0]].unk3); -} - -s32 func_8006A624(s8 arg0) { - if (arg0 < 8 && arg0 >= -7) { - return 0; - } - if (arg0 > 0) { - arg0 -= 8; - if (arg0 >= 0x47) { - arg0 = 0x46; - } - } else { - arg0 += 8; - if (arg0 < -0x46) { - arg0 = -0x46; - } - } - return arg0; -} - -#if 1 -GLOBAL_ASM("asm/non_matchings/unknown_066AA0/func_8006A6A0.s") -#else -void func_8006A6A0(void) { - D_800DD304 = 0; -} -#endif - -/*!!! FILE BOUNDARY !!!*/ - -GLOBAL_ASM("asm/non_matchings/unknown_066AA0/func_8006A6B0.s") - -s32 func_8006B0AC(s32 arg0) { - if (arg0 > 0 && arg0 < D_80121170) { - return (*D_8012117C)[arg0].unk2 & 0xF; - } - return 0; -} - -s32 func_8006B0F8(s32 arg0) { - if (arg0 > 0 && arg0 < D_80121170) { - s32 temp = (*D_8012117C)[arg0].unk2; - if(temp != 0) { - return (temp >> 4) & 0xF; - } - } - return 1; -} - -s8 func_8006B14C(s32 arg0) { - if (arg0 >= 0 && arg0 < D_80121170) { - return (*D_8012117C)[arg0].unk1; - } - return -1; -} - -s8 func_8006B190(s32 arg0) { - if (arg0 >= 0 && arg0 < D_80121170) { - return (*D_8012117C)[arg0].unk0; - } - return 0; -} - -s32 func_8006B1D4(s32 arg0) { - s8* temp; - - if (arg0 < 0 || arg0 >= D_80121174) { - arg0 = 0; - } - temp = func_8001E29C(0x1B); - - return temp[arg0]; -} - -void func_8006B224(s32* arg0, s32* arg1) { - *arg0 = D_80121170; - *arg1 = D_80121174; -} - -s32 func_8006B240(void) { - return D_800DD31C; -} - -#if 1 -GLOBAL_ASM("asm/non_matchings/unknown_066AA0/func_8006B250.s") -#else - -extern s32 *D_80121160; -extern s32 D_800DD314; - -Settings *get_settings(void); -s32 *func_80076C58(s32); -LevelHeader *func_80070C9C(s32, s32); -void func_8006C1AC(s32 arg0, s32 arg1, s32 arg2, s32 arg3); -void func_8006C2E4(void); -s16 func_8006C2F0(void); -void func_8006DB20(s32 arg0); -void func_80072708(void); - -// load_level(levelID, numOfPlayers, entrance, vehicle, ???); -void func_8006B250(s32 arg0, s32 arg1, s32 arg2, s32 arg3, s32 arg4) { - s32 sp48; - s32 sp44; - Settings *settings; - s32 temp_s0_2; - s32 temp_s0_5; - s32 temp_t8_3; - s32 temp_v0_5; - s8 *temp_v0_4; - s32 phi_v1; - s32 phi_v1_2; - s32 phi_v0_2; - s32 phi_s0; - s32 phi_v1_5; - s8 phi_s0_2; - s32 phi_at; - s32 phi_s0_3; - s32 phi_s0_5; - s32 phi_v1_9; - s32 temp, temp2; - - func_80072708(); - if (arg4 == -1) { - arg4 = 0; - } - if (arg1 == -1) { - sp48 = 1; - arg1 = 0; - } else { - sp48 = 0; - } - if (arg1 == 0) { - func_8000318C(0x8); - } else if (arg1 == 1) { - func_8000318C(0xC); - } else { - func_8000318C(0x10); - } - - settings = get_settings(); - D_80121160 = func_80076C58(0x16); - phi_v1 = 0; - while (-1 != D_80121160[phi_v1]) { - phi_v1++; - } - phi_v1--; - if (arg0 >= phi_v1) { - arg0 = 0; - } - temp2 = D_80121160[arg0]; - temp = D_80121160[arg0 + 1] - temp2; - D_80121168 = func_80070C9C(temp, 0xFFFF00FF); - func_80076E68(0x17, D_80121168, temp2, temp); - D_800DD330 = 0; - sp44 = arg0; - if (D_80121168->race_type == 0) { - func_8006C2E4(); - } - if (func_8006C2F0() == 0) { - if (D_800DD32C == 0) { - if (D_80121168->race_type == 8) { - phi_v1_2 = settings->courseFlagsPtr[temp2] & 1; - phi_v0_2 = 0; - if (D_80121168->world == 0 || D_80121168->world == 5) { - phi_v0_2 = 1; - } - if (phi_v1_2 == 0 || phi_v0_2 != 0) { - func_8006C1AC(arg0, arg2, arg3, arg4); - if ((settings->bosses & (1 << settings->worldId)) != 0) { - arg4 = 7; - } else { - arg4 = 3; - } - if (phi_v0_2 != 0) { - arg4 = 0; - if (phi_v1_2 != 0) { - D_800DD330 = (u8)2; - } - } - temp_v0_4 = func_8001E29C(0x43); - phi_s0 = 0; - while(arg0 != temp_v0_4[phi_s0 + 1]) { - phi_s0++; - } - arg0 = temp_v0_4[phi_s0 + 1]; - arg2 = arg4; - } - - } - if (D_80121168->race_type == 5) { - if (D_80121168->world > 0 && D_80121168->world < 5) { - if ((settings->keys & (1 << D_80121168->world)) != 0) { - temp_v0_5 = 0x4000 << (D_80121168->world + 0x1F); - if ((settings->cutsceneFlags & temp_v0_5) == 0) { - func_8006C1AC(arg0, arg2, arg3, arg4); - settings->cutsceneFlags |= temp_v0_5; - arg2 = 0; - arg4 = 5; - arg0 = func_8001E29C(0x44)[D_80121168->world - 1]; - } - } - } - } - if (D_80121168->race_type == 5 && D_80121168->world == 0 && (settings->cutsceneFlags & 0x2000) == 0 && settings->wizpigAmulet >= 4) { - s32 temp_a1 = arg2; - s32 temp_a3 = arg4; - arg4 = 0; - arg2 = 0; - func_8006C1AC(arg0, temp_a1, arg3, temp_a3); - settings->cutsceneFlags |= 0x2000; - arg0 = (s32) func_8001E29C(0x44)[1]; - } - } - } - D_800DD32C = 0; - if (sp44 != arg0) { - func_80071140(D_80121168); - temp2 = D_80121160[arg0]; - temp = D_80121160[arg0 + 1] - temp2; - D_80121168 = func_80070C9C(temp, 0xFFFF00FF); - func_80076E68(0x17, D_80121168, temp2, temp); - } - func_80071140(D_80121160); - func_8006BFC8(&D_80121168->unk20); - func_8000CBC0(); - D_80121164 = arg0; - for (phi_v1_5 = 0; phi_v1_5 < 7; phi_v1_5++) { - if ((s32)D_80121168->unk74[phi_v1_5] != -1) { - D_80121168->unk74[phi_v1_5] = func_8001E29C((s32)D_80121168->unk74[phi_v1_5]); - func_8007F1E8(D_80121168->unk74[phi_v1_5]); - } - } - if (arg4 == 0x64) { - if(get_trophy_race_world_id() != 0 && D_80121168->race_type == 0) { - arg4 = 0; - } else if(is_in_tracks_mode() == 1 && D_80121168->race_type == 0) { - arg4 = 0; - } - } - if (D_80121168->race_type == 0 || D_80121168->race_type == 8) { - D_800DD31C = 1; - } else { - D_800DD31C = 0; - } - if (sp48 != 0 && D_80121168->race_type != 7) { - D_80121168->race_type = 6; - } - func_80000BE0(D_80121168->unkB3); - func_80000CBC(); - func_80031BB8(0x20); - phi_s0_2 = (u8)0; - if (arg3 >= 0 && arg3 < 3) { - phi_s0_2 = D_80121168->unk4F[arg3]; - } - func_80017E74(phi_s0_2); - settings->courseId = arg0; - if (D_80121168->world != -1) { - settings->worldId = D_80121168->world; - } - if (settings->worldId == 0 && settings->worldId > 0) { - D_800DD314 = func_8006DB2C(); - } - if (settings->worldId == 0 && settings->worldId > 0 && D_800DD314 != -1) { - arg3 = D_800DD314; - } - func_8006DB20(arg3); - if (D_80121168->race_type == 5) { - if (settings->worldId > 0) { - temp_s0_5 = 8 << (settings->worldId + 31); - if (settings->worldId == 5) { - if (settings->balloonsPtr[0] >= 47) { - if (settings->ttAmulet >= 4) { - if ((settings->cutsceneFlags & temp_s0_5) == 0) { - settings->cutsceneFlags |= temp_s0_5; - arg4 = 5; - } - } - } - } else { - if (settings->balloonsPtr[settings->worldId] >= 4) { - if ((settings->cutsceneFlags & temp_s0_5) == 0) { - settings->cutsceneFlags |= temp_s0_5; - arg4 = 5; - } - } - temp_t8_3 = temp_s0_5 << 5; - if (settings->balloonsPtr[settings->worldId] >= 8) { - if ((settings->cutsceneFlags & temp_t8_3) == 0) { - settings->cutsceneFlags |= temp_t8_3; - arg4 = 5; - } - } - } - } - } - if (arg1 != 0 && D_80121168->race_type == 0) { - arg4 = 0x64; - } - if (D_80121168->race_type == 0 || ((D_80121168->race_type & 0x40) != 0 && is_in_two_player_adventure(D_80121168->race_type) != 0)) { - D_800DD318 = (u8)1; - arg4 = 0x64; - } else { - D_800DD318 = (u8)0; - } - if (D_80121168->race_type == 0 && sp48 == 0 && func_8000E4C8(arg4) != 0) { - arg4 = 0x64; - } - func_8001E450(arg4); - func_800249F0(D_80121168->geometry, D_80121168->skybox, arg1, arg3, arg2, D_80121168->collectables, D_80121168->unkBA); - if (D_80121168->unk3A == 0 && D_80121168->unk3C == 0 && D_80121168->fogR == 0 && D_80121168->fogG == 0 && D_80121168->fogB == 0) { - phi_s0_3 = 0; - while(phi_s0_3 < 4) { - func_800307BC(phi_s0_3); - phi_s0_3++; - } - } else { - phi_s0_3 = 0; - while(phi_s0_3 < 4) { - func_80030664(phi_s0_3, D_80121168->unk3A, D_80121168->unk3C, (u8)D_80121168->fogR, D_80121168->fogG, D_80121168->fogB); - phi_s0_3++; - } - } - settings = get_settings(); - if (D_80121168->world != -1) { - settings->worldId = D_80121168->world; - } - settings->courseId = arg0; - if (D_80121168->weather_enable > 0) { - func_800AB4A8( - D_80121168->unk92, - D_80121168->weather_enable, - D_80121168->unk96 << 8, - D_80121168->unk98 << 8, - D_80121168->unk9A << 8, - D_80121168->unk94 * 0x101, - D_80121168->unk95 * 0x101 - ); - func_800AB308(-1, -0x200); - } - if (D_80121168->unk49 == -1) { - D_80121168->unkA4 = func_8007AE74(D_80121168->unkA4); - D_80121168->unkA8 = (u16)0; - D_80121168->unkAA = (u16)0; - } - if ((s32)D_80121168->unkAC != -1) { - D_80121168->unkAC = func_8001E29C((s32)D_80121168->unkAC); - func_8007F414(D_80121168->unkAC); - } - func_800660EC((f32)D_80121168->unk9C); - func_80077B34(D_80121168->unk9D, D_80121168->unk9E, D_80121168->unk9F); - func_8007A974(); - func_8007AB24(D_80121168->unk4[arg1]); -} -#endif - -void func_8006BD10(f32 arg0) { - if (D_80121168->music != 0) { - func_800012E8(); - func_80000B34(D_80121168->music); - func_800014BC(arg0); - func_80001074(D_80121168->instruments); - } -} - -s32 func_8006BD88(void) { - return D_80121164; -} - -u8 func_8006BD98(void) { - return D_80121168->race_type; -} - -LevelHeader* func_8006BDB0(void) { - return D_80121168; -} - -/* Unused? */ -u8 func_8006BDC0(void) { - return D_80121170 - 1; -} - -GLOBAL_ASM("asm/non_matchings/unknown_066AA0/func_8006BDDC.s") - -void func_8006BEFC(void) { - func_8006C164(); - func_80077B34(0, 0, 0); - func_80071140(D_80121168); - func_800049D8(); - func_80001844(); - func_800018E0(); - func_800012E8(); - func_80031B60(); - func_8002C7D4(); - func_80008174(); - func_80000968(0); - if (D_80121168->weather_enable > 0) { - func_800AB35C(); - } - if (D_80121168->unk49 == 0xFF) { - func_8007B2BC(D_80121168->unkA4); - } -} - -extern s32 *D_80121160; -Settings *get_settings(void); -s32 *func_80076C58(s32); - -#if 1 -GLOBAL_ASM("asm/non_matchings/unknown_066AA0/func_8006BFC8.s") -#else -void func_8006BFC8(s8 *arg0) { - s32 temp, temp2; - s16 phi_v1; - s8 phi_s0 = 0; - - if (!is_in_tracks_mode()) { - Settings *settings = get_settings(); - // Regalloc issue: temp3 should be a3, not v1. - s32 temp3 = settings->courseFlagsPtr[settings->courseId]; - if (temp3 & 2) { - phi_s0 = 1; - } - if (temp3 & 4) { - phi_s0 = 2; - } - } else { - phi_s0 = 3; - } - - if (get_trophy_race_world_id() != 0) { - phi_s0 = 4; - } - - if(is_in_adventure_two()){ - phi_s0 += 5; - } - - phi_s0 = arg0[phi_s0]; - - if ((func_8009C30C() << 6) < 0) { - phi_s0 = 9; - } - if (func_8006DA0C() == 1) { - phi_s0 = 5; - } - D_80121160 = func_80076C58(1); - phi_v1 = 0; - while (-1 != (s32)D_80121160[phi_v1]) { - phi_v1++; - } - phi_v1--; - if (phi_s0 >= phi_v1) { - phi_s0 = 0; - } - temp2 = D_80121160[phi_s0]; - temp = D_80121160[phi_s0 + 1] - temp2; - D_801211C0 = func_80070C9C(temp, 0xFFFF00FF, D_80121160); - func_80076E68(0, D_801211C0, temp2, temp); - func_80071140(D_80121160); -} -#endif - -void func_8006C164(void) { - func_80071140(D_801211C0); -} - -s32 func_8006C18C(void) { - return D_801211C0; -} - -s8 func_8006C19C(void) { - return D_800DD318; -} - -void func_8006C1AC(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { - D_801211C8[D_800DD328++] = arg0; - D_801211C8[D_800DD328++] = arg1; - D_801211C8[D_800DD328++] = arg2; - D_801211C8[D_800DD328++] = arg3; -} - -void func_8006C22C(s32 *arg0, s32 *arg1, s32 *arg2, s32 *arg3) { - s16 temp_v1; - - D_800DD328--; - *arg3 = D_801211C8[D_800DD328]; - D_800DD328--; - temp_v1 = D_801211C8[D_800DD328]; - D_800DD328--; - *arg1 = D_801211C8[D_800DD328]; - D_800DD328--; - *arg0 = D_801211C8[D_800DD328]; - - if (temp_v1 != -1) { - *arg2 = temp_v1; - } - - D_800DD32C = 1; -} - - -void func_8006C2E4(void) { - D_800DD328 = 0; -} - -s16 func_8006C2F0(void) { - return D_800DD328; -} - -s32 func_8006C300(void) { - if (D_800DD330 >= 2) { - D_800DD330 = 1; - return 0; - } else { - return D_800DD330; - } -} - -#if 1 -GLOBAL_ASM("asm/non_matchings/unknown_066AA0/D_8006C330.s") -#else -void func_8006C330(s32 arg0) { - func_8006C3E0(); - D_800DD37C = func_8006A1C4(D_800DD37C, 0); - D_80123520 = 0; - D_801234EC = -1; - while(1) { - if (func_8006EAC0() != 0) { - func_80072708(); - audioStopThread(); - func_800C73BC(); - __osSpSetStatus(0xAAAA82); - func_800CD250(0x1D6); - while(1); // Infinite loop - } - func_8006C60C(); - func_80065E30(); - } - // This infinite loop creates too many nops! Needs to be 0x10 aligned, not 0x20 aligned. -} -#endif - -#if 1 -GLOBAL_ASM("asm/non_matchings/unknown_066AA0/func_8006C3E0.s") -#else -extern Gfx *D_801211F0; -extern u8 D_800DD374; -extern u8 D_800DD3A0; -extern u16 D_80121260; -extern u8 D_80123538; - -extern s32 D_80123544; -extern s32 D_801234E8; - -void osCreateScheduler(u16*, s32*, s32, u8, s32); -void osScAddClient(u16*, u8*, s32**, s32); - -void func_8006C3E0(void) { - s32 sp24; - - func_80070B30(); - func_800C6170(); - D_800DD374 = 1; - if (func_8006F4EC() != 0) { - D_800DD374 = 0; - } - D_80123514 = 0; - D_80123518 = 0; - - if (osTvType == 0) { - sp24 = 0xE; - } else if (osTvType == 1) { - sp24 = 0; - } else if (osTvType == 2) { - sp24 = 0x1C; - } - - osCreateScheduler(&D_80121260, &D_801234E8, 0xD, sp24, 1); - D_800DD3A0 = 0; - if (func_8006EFB8() == 0) { - D_800DD3A0 = 1; - } - func_8007A310(1, &D_80121260); - func_80076BA0(); - func_80078100(&D_80121260); - audio_init(&D_80121260); - func_80008040(); - D_800DD384 = func_8006A10C(); - func_8007AC70(); - func_8005F850(); - func_8000BF8C(); - func_800B5E88(); - func_800598D0(); - func_800AE530(); - func_800AB1F0(); - func_8006E3BC(); - func_8006EFDC(); - func_800C3C00(); - func_80075B18(); - func_80081218(); - func_800C7350(); - osCreateMesgQueue(&D_80123548, &D_80123544, 1); - osScAddClient(&D_80121260, &D_80123538, &D_80123548, 3); - D_80123560 = 0; - D_80123504 = 0; - D_80123508 = 0; - D_801234E8 = 0; - - // ??? - D_801211F8 = D_801211F0; - fast3d_cmd(D_801211F8++, 0xE9000000, 0x00000000) - fast3d_cmd(D_801211F8++, 0xB8000000, 0x00000000) - - osSetTime(0); -} -#endif - -GLOBAL_ASM("asm/non_matchings/unknown_066AA0/func_8006C60C.s") - -void func_8006CAE4(s32 arg0, s32 arg1, s32 arg2) { - D_80123500 = arg0 - 1; - if (arg1 == -1) { - D_801234F4 = func_8009C1B0(); - } else { - D_801234F4 = arg1; - } - func_8006CB58(D_801234F4, D_80123500, D_80123504, arg2); -} - -void func_8006CB58(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { - func_8006ECFC(arg1); - func_800710B0(0); - func_80065EA0(); - func_800C3048(); - func_8006B250(arg0, arg1, arg2, arg3, D_80123508); - func_8009ECF0(func_80066210()); - func_800AE728(8, 0x10, 0x96, 0x64, 0x32, 0); - func_8001BF20(); - osSetTime(0); - func_800710B0(2); - func_80072298(1); -} - -void func_8006CC14(void) { - func_800710B0(0); - if (D_800DD38C == 0) { - if (D_800DD3F0 != 1) { - func_80077A54(); - } - D_800DD38C = 1; - } - func_8006BEFC(); - func_800C01D8(&D_800DD3F4); - func_800AE270(); - func_800A003C(); - func_800C30CC(); - D_801211F8 = D_801211F0[D_801234E8]; - fast3d_cmd(D_801211F8++, 0xE9000000, 0x00000000) - fast3d_cmd(D_801211F8++, 0xB8000000, 0x00000000) - func_800710B0(2); -} - -// Has a jump table -GLOBAL_ASM("asm/non_matchings/unknown_066AA0/func_8006CCF0.s") - -void func_8006D8A4(void) { - D_800DD390 = 0x2C; - gIsPaused = 0; - func_800945E4(); - func_800C01D8(&D_800DD408); -} - -void func_8006D8E0(s32 arg0) { - D_80123516 = arg0 + 1; -} - -void func_8006D8F0(s32 arg0) { - s32 temp; - if (D_801234EC != 4) { - D_801234F4 = D_80121250[0]; - D_80123504 = 0; - D_80123508 = 0x64; - temp = D_80121250[1]; - if (D_80121250[15] >= 0) { - D_80123504 = D_80121250[15]; - } - if (D_80121250[temp + 8] >= 0) { - D_80123508 = D_80121250[temp + 8]; - } - D_801234F8 = 1; - } -} - -void func_8006D968(s8 *arg0) { - s32 i; - if (D_801234EC != 4) { - D_80121250[0] = D_801234F4; - for(i = 0; i < 2; i++) { - D_80121250[i + 2] = arg0[i + 8]; - D_80121250[i + 4] = arg0[i + 10]; - D_80121250[i + 6] = arg0[i + 12]; - D_80121250[i + 8] = arg0[i + 14]; - D_80121250[i + 10] = arg0[i + 18]; - D_80121250[i + 12] = arg0[i + 20]; - } - D_80121250[14] = arg0[22]; - D_80121250[15] = arg0[23]; - D_801234FC = 1; - } -} - -s32 func_8006DA0C(void) { - return D_801234EC; -} - -/* Unused? */ -void func_8006DA1C(s32 arg0) { - D_801234EC = arg0; -} - -#if 1 -GLOBAL_ASM("asm/non_matchings/unknown_066AA0/func_8006DA28.s") -#else - -// For some reason this function is storing arg0 in s0. - -void func_8006DB3C(s32 arg0, s32 arg1, s32 arg2, s32 arg3, s32 arg4); -void func_800813C0(s32); -void func_80004A60(s32, s32); -void MenuInit(s32); - -void func_8006DA28(s32 arg0, s32 arg1, s32 arg2) { - func_8006ECFC(0); - D_801234EC = 1; - D_801234F0 = 1; - func_80004A60(0, 0x7FFF); - func_80004A60(1, 0x7FFF); - func_80004A60(2, 0x7FFF); - func_80065EA0(); - - if (D_80123514 == 0) { - D_80123514 = 0; // Someone at rare: "I know I just checked if this was zero, but I need to be sure!" - if (arg1 < 0) { - D_80123514 = 1; - } else { - func_8006DB3C(arg1, -1, 0, 2, arg2); - } - } - if (arg0 == 0 || arg0 == 1 || arg0 == 2) { - func_800813C0(arg0); - } - MenuInit(arg0); - D_80123504 = 0; -} -#endif - -void func_8006DB14(s32 arg0) { - D_80123518 = arg0; -} - -void func_8006DB20(s32 arg0) { - D_8012351C = arg0; -} - -s32 func_8006DB2C(void) { - return D_80123518; -} - -void func_8006DB3C(s32 arg0, s32 arg1, s32 arg2, s32 arg3, s32 arg4) { - func_800710B0(0); - func_80065EA0(); - func_800C3048(); - func_8006B250(arg0, arg1, arg2, arg3, arg4); - func_8009ECF0(func_80066210()); - func_800AE728(4, 4, 0x6E, 0x30, 0x20, 0); - func_8001BF20(); - osSetTime(0); - func_800710B0(2); -} - -void func_8006DBE4(void) { - if (D_80123514 == 0) { - D_80123514 = 1; - func_800710B0(0); - func_8006BEFC(); - func_800C01D8(&D_800DD3F4); - func_800AE270(); - func_800A003C(); - func_800C30CC(); - func_800710B0(2); - } - D_80123514 = 0; -} - -void func_8006DC58(s32 arg0) { - if (func_800C73E0() == 0) { - func_80010994(arg0); - particlePtrList_flush(); - func_8001BF20(); - D_80024D54(&D_801211F8, &D_80121208, &D_80121218, &D_80121228, arg0); - func_800C3440(arg0); - func_80078054(&D_801211F8); - func_80077050(&D_801211F8); - func_80077268(&D_801211F8); - } -} - -// Has a jump table -GLOBAL_ASM("asm/non_matchings/unknown_066AA0/func_8006DCF8.s") - -void func_8006E2E8(s32 arg0, s32 arg1, s32 arg2) { - if (D_80123514 == 0) { - func_8006DBE4(); - if (func_800C73E0() == 0) { - D_801211F8 = D_801211F0[D_801234E8]; - fast3d_cmd(D_801211F8++, 0xE9000000, 0x00000000) - fast3d_cmd(D_801211F8++, 0xB8000000, 0x00000000) - } - } - if (arg0 != -1) { - func_8006DB3C(arg0, arg1, 0, 2, arg2); - D_80123514 = (u8)0; - return; - } - D_80123514 = (u8)1; -} - -GLOBAL_ASM("asm/non_matchings/unknown_066AA0/func_8006E3BC.s") - -void func_8006E5BC(void) { - s32 i, j; - gSettingsPtr->playerCount = func_8009C3C8(); - for (i = 0; i < 8; i++) { - gSettingsPtr->racers[i].best_times = 0; - gSettingsPtr->racers[i].character = func_8009C228(i); - if (gSettingsPtr->playerCount >= 2) { - gSettingsPtr->racers[i].starting_position = i; - } else if (is_in_two_player_adventure()) { - gSettingsPtr->racers[i].starting_position = 5 - i; - } else { - gSettingsPtr->racers[i].starting_position = 7 - i; - } - gSettingsPtr->racers[i].unk7 = 0; - for(j = 0; j < 4; j++) { - gSettingsPtr->racers[i].placements[j] = 0; - } - gSettingsPtr->racers[i].course_time = 0; - for(j = 0; j < 3; j++) { - gSettingsPtr->racers[i].lap_times[j] = 0; - } - } - gSettingsPtr->timeTrialRacer = 0; - gSettingsPtr->unk115[0] = 0; - gSettingsPtr->unk115[1] = 0; - gSettingsPtr->display_times = 0; - gSettingsPtr->worldId = 0; - gSettingsPtr->courseId = 0; -} - -GLOBAL_ASM("asm/non_matchings/unknown_066AA0/func_8006E770.s") - -void func_8006E994(Settings* settings) { - s32 i; - s32 sp20; - s32 sp1C; - - func_8006B224(&sp1C, &sp20); - settings->newGame = 1; - - for (i = 0; i < sp20; i++) { - settings->balloonsPtr[i] = 0; - } - for(i = 0; i < sp1C; i++) { - settings->courseFlagsPtr[i] = 0; - } - - settings->keys = 0; - settings->unkA = 0; - settings->bosses = 0; - settings->trophies = 0; - settings->cutsceneFlags = 0; - settings->tajFlags = 0; - settings->ttAmulet = 0; - settings->wizpigAmulet = 0; -} - -// Unused? -void func_8006EA58(void) { - func_8006E770(gSettingsPtr, 3); - func_8006E994(gSettingsPtr); -} - -Settings* get_settings(void) { - return gSettingsPtr; -} - -s8 func_8006EAA0(void) { - return gIsPaused; -} - -s8 func_8006EAB0(void) { - return D_80123516; -} - -s32 func_8006EAC0(void) { - if (D_80123560 == 0) { - D_80123560 = (s32) ((osRecvMesg(&D_80123548, NULL, 0) + 1) != 0); - } - return D_80123560; -} - -s32 func_8006EB14(void) { - return D_801234F4; -} - -/* Unused? */ -void func_8006EB24(void) { - D_800DD37C |= 0x01; -} - -/* Unused? */ -void func_8006EB40(void) { - D_800DD37C |= 0x02; -} - -void func_8006EB5C(void) { - D_800DD37C |= 0x03; -} - -void func_8006EB78(s32 arg0) { - D_800DD37C &= -0x301; - D_800DD37C |= (0x04 | ((arg0 & 3) << 8)); -} - -void func_8006EBA8(void) { - D_800DD37C |= 0x08; -} - -void func_8006EBC4(void) { - D_800DD37C |= 0x10; -} - -void func_8006EBE0(void) { - D_800DD37C |= 0x20; -} - -void func_8006EBFC(void) { - D_800DD37C |= 0x30; -} - -void func_8006EC18(s32 arg0) { - D_800DD37C &= -0xC01; - D_800DD37C |= (0x40 | ((arg0 & 3) << 0xA)); -} - -void func_8006EC48(s32 arg0) { - if (D_801234EC == 0 && !is_in_tracks_mode()) { - D_800DD37C &= -0xC01; - D_800DD37C |= (0x40 | ((arg0 & 3) << 0xA)); - } -} - -void func_8006ECAC(s32 arg0) { - D_800DD37C = ((arg0 & 0x03) << 10) | 0x80; -} - -/* Unused? */ -void func_8006ECC4(void) { - D_800DD37C |= 0x100; -} - -void func_8006ECE0(void) { - D_800DD37C |= 0x200; -} - -GLOBAL_ASM("asm/non_matchings/unknown_066AA0/func_8006ECFC.s") - -#if 1 -GLOBAL_ASM("asm/non_matchings/unknown_066AA0/func_8006EFB8.s") -#else -s32 func_8006EFB8(void) { - if (D_A4000000 != -1) { // regalloc issue with D_A4000000 - return 0; - } - return 1; -} -#endif - -#if 1 -GLOBAL_ASM("asm/non_matchings/unknown_066AA0/func_8006EFDC.s") -#else - -/* Size: 0x40 bytes, I think this might be a 4x4 matrix. */ -typedef struct unk80121200 { - u8 pad0[0x40]; -} unk80121200; - -/* Size: 10 bytes */ -typedef struct unk80121210 { - u8 pad0[10]; -} unk80121210; - -/* Size: 16 bytes */ -typedef struct unk80121220 { - u8 pad0[16]; -} unk80121220; - -extern s32 D_8012350C; - -extern s32 D_800DD3BC; -extern s32 D_800DD3CC; -extern s32 D_800DD3DC; -extern s32 D_800DD3EC; - -extern s32 D_80123528; -extern s32 D_8012352C; -extern s32 D_80123530; -extern s32 D_80123534; - -extern unk80121200 *D_80121200[3]; -extern unk80121210 *D_80121210[3]; -extern unk80121220 *D_80121220[3]; - -void *func_80070C9C(s32, s32); // Allocates memory? - -void func_8006EFDC(void) { - s32 size; - s8* current; - - D_8012350C = 3; - - size = (D_800DD3EC * sizeof(unk80121220)) + - (D_800DD3BC * sizeof(Gfx)) + - (D_800DD3DC * sizeof(unk80121200)) + - (D_800DD3CC * sizeof(unk80121210)); - - current = (s8*)func_80070C9C(size, 0xFF0000FF); - D_801211F0[0] = (Gfx*)current; - current += (D_800DD3BC * sizeof(Gfx)); - D_80121200[0] = (unk80121200*)current; - current += (D_800DD3DC * sizeof(unk80121200)); - D_80121210[0] = (unk80121210*)current; - current += (D_800DD3CC * sizeof(unk80121210)); - D_80121220[0] = (unk80121220*)current; - - current = (s8*)func_80070C9C(size, 0xFFFF00FF); - D_801211F0[1] = (Gfx*)current; - current += (D_800DD3BC * sizeof(Gfx)); - D_80121200[1] = (unk80121200*)current; - current += (D_800DD3DC * sizeof(unk80121200)); - D_80121210[1] = (unk80121210*)current; - current += (D_800DD3CC * sizeof(unk80121210)); - D_80121220[1] = (unk80121220*)current; - - D_80123528 = D_800DD3BC; - D_8012352C = D_800DD3DC; - D_80123530 = D_800DD3EC; - D_80123534 = D_800DD3CC; -} -#endif - -void func_8006F140(s32 arg0) { - if (D_800DD394 == 0) { - D_800DD394 = 0x28; - D_80123524 = 0; - D_80123526 = 0; - if (arg0 == 1) { - func_800C01D8(&D_800DD41C); - } - if (arg0 == 3) { - D_800DD394 = 0x11A; - func_800C01D8(&D_800DD424); - } - if (arg0 == 4) { - D_800DD394 = 0x168; - func_800C01D8(&D_800DD424); - } - if (arg0 == 0) { - D_800DD394 = 2; - } - } -} - -// Unused? -void func_8006F20C(void) { - if (D_800DD394 == 0) { - func_800C01D8(&D_800DD41C); - D_800DD394 = 0x28; - D_80123524 = 1; - } -} - -void func_8006F254(void) { - if (D_800DD394 == 0) { - func_800C01D8(&D_800DD41C); - D_800DD394 = 0x28; - D_80123524 = 2; - } -} - -void func_8006F29C(void) { - if (D_800DD394 == 0) { - if ((gSettingsPtr->trophies & 0xFF) == 0xFF && !(gSettingsPtr->cutsceneFlags & 1) && gSettingsPtr->bosses & 1) { - gSettingsPtr->cutsceneFlags |= 1; - func_800C01D8(&D_800DD41C); - D_800DD394 = 0x28; - D_80123525 = 0x2D; - D_80123524 = 3; - } - } -} - -void func_8006F338(s32 arg0) { - if (D_800DD394 == 0) { - D_80123525 = arg0; - func_800C01D8(&D_800DD41C); - D_800DD394 = 0x28; - D_80123524 = 4; - } -} - -void func_8006F388(u8 arg0) { - D_800DD398 = arg0; -} - -void func_8006F398(void) { - s32 i; - u8 temp; - u8 *first_racer_data; - u8 *second_racer_data; - - func_8006A50C(); - func_8000E194(); - - first_racer_data = (u8*)(gSettingsPtr->racers); - second_racer_data = (u8*)(gSettingsPtr->racers + 1); - - for(i = 0; i < sizeof(Racer); i++) { - temp = first_racer_data[i]; - first_racer_data[i] = second_racer_data[i]; - second_racer_data[i] = temp; - } -} - -void func_8006F42C(void) { - D_800DD3F0 = 2; -} - -void func_8006F43C(void) { - s32 phi_s1 = 0; - s32 phi_s0 = 0; - while(phi_s0 != 4) { - phi_s1 |= func_8006A528(phi_s0); - phi_s0++; - } - if (phi_s1 & 0x1000) { - D_800DFD94 = 1; - } - D_80123520++; - if (D_80123520 >= 8) { - func_8006DA28(0x1A, 0x27, 2); - } -} - -s32 func_8006F4C8(void) { - if (D_800DD384 == -1) { - return 1; - } else { - return 0; - } -} - -#if 1 -GLOBAL_ASM("asm/non_matchings/unknown_066AA0/func_8006F4EC.s") -#else -s32 func_8006F4EC(void) { - if (SP_IMEM != 0x17D7) { // Same regalloc issue as func_8006EFB8 - return 0; - } - return 1; -} -#endif +/* The comment below is needed for this file to be picked up by generate_ld */ +/* RAM_POS: 0x80065EA0 */ + +#include "types.h" +#include "macros.h" +#include "structs.h" +#include "fast3d.h" + +extern u32 osTvType; + +/************ .rodata ************/ + +const char D_800E6F00[] = "Camera Error: Illegal mode!\n"; +const char D_800E6F20[] = "Camera Error: Illegal player no!\n"; +const char D_800E6F34[] = "cameraPushSprMtx: model stack overflow!!\n"; +const char D_800E6F70[] = "\nCam do 2D sprite called with NULL pointer!"; +const char D_800E6F9C[] = "CamDo2DSprite FrameNo Overflow !!!\n"; +const char D_800E6FC0[] = "cameraPushModelMtx: model stack overflow!!\n"; +const char D_800E6FEC[] = "camPushModelMtx: bsp stack overflow!!\n"; +const char D_800E7010[] = "camPopModelMtx: model stack negative overflow!!\n"; +const char D_800E7048[] = "camPopModelMtx: bsp stack negative overflow!!\n"; + +/*********************************/ + +/************ .data ************/ + +s32 D_800DD060 = 0; // Currently unknown, might be a different type. + +/* Size: 0x34 bytes. */ +typedef struct unk800DD064 { + s32 unk0; + s32 unk4; + s32 unk8; + s32 unkC; + s32 unk10; + s32 unk14; + s32 unk18; + s32 unk1C; + s32 unk20; + s32 unk24; + s32 unk28; + s32 unk2C; + s32 unk30; +} unk800DD064; + +unk800DD064 D_800DD064[4] = { + { + 0x00, 0x00, 0x140, 0xF0, + 0xA0, 0x78, 0x140, 0xF0, + 0x00, 0x00, 0x13F, 0xEF, 0x00 + }, + { + 0x00, 0x00, 0x140, 0xF0, + 0xA0, 0x78, 0x140, 0xF0, + 0x00, 0x00, 0x13F, 0xEF, 0x00 + }, + { + 0x00, 0x00, 0x140, 0xF0, + 0xA0, 0x78, 0x140, 0xF0, + 0x00, 0x00, 0x13F, 0xEF, 0x00 + }, + { + 0x00, 0x00, 0x140, 0xF0, + 0xA0, 0x78, 0x140, 0xF0, + 0x00, 0x00, 0x13F, 0xEF, 0x00 + } +}; + +// Not sure about the typing here +s16 D_800DD134[10] = { + 0, 0, 0, 0, + 0, -1, -1, 0, + 0, 0 +}; + +// Not sure about the typing here +u16 D_800DD148[160] = { + 0, 0, 0x01FF, 0, + 0, 0, 0x01FF, 0, + 0, 0, 0x01FF, 0, + 0, 0, 0x01FF, 0, + 0, 0, 0x01FF, 0, + 0, 0, 0x01FF, 0, + 0, 0, 0x01FF, 0, + 0, 0, 0x01FF, 0, + 0, 0, 0x01FF, 0, + 0, 0, 0x01FF, 0, + 0, 0, 0x01FF, 0, + 0, 0, 0x01FF, 0, + 0, 0, 0x01FF, 0, + 0, 0, 0x01FF, 0, + 0, 0, 0x01FF, 0, + 0, 0, 0x01FF, 0, + 0, 0, 0x01FF, 0, + 0, 0, 0x01FF, 0, + 0, 0, 0x01FF, 0, + 0, 0, 0x01FF, 0, + 0, 0, 0x01FF, 0, + 0, 0, 0x01FF, 0, + 0, 0, 0x01FF, 0, + 0, 0, 0x01FF, 0, + 0, 0, 0x01FF, 0, + 0, 0, 0x01FF, 0, + 0, 0, 0x01FF, 0, + 0, 0, 0x01FF, 0, + 0, 0, 0x01FF, 0, + 0, 0, 0x01FF, 0, + 0, 0, 0x01FF, 0, + 0, 0, 0x01FF, 0, + 0, 0, 0x01FF, 0, + 0, 0, 0x01FF, 0, + 0, 0, 0x01FF, 0, + 0, 0, 0x01FF, 0, + 0, 0, 0x01FF, 0, + 0, 0, 0x01FF, 0, + 0, 0, 0x01FF, 0, + 0, 0, 0x01FF, 0 +}; + +f32 D_800DD288[6] = { + 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, -281.0f +}; + +f32 D_800DD2A0[6] = { + 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f +}; + +f32 D_800DD2B8[5] = { + 1.0f, 0.0f, 0.0f, 0.0f, 0.0f +}; + +f32 D_800DD2CC[11] = { + 1.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 160.0f +}; + +u8 D_800DD2F8[8] = { + 0, 0, 0, 0, 0, 0, 0, 0 +}; + +s32 D_800DD300 = 0; // Currently unknown, might be a different type. + +s16 D_800DD304 = -1; + +/*******************************/ + +/* Size: 0x44 bytes */ +typedef struct unk80120AC0 { + s16 unk0; + s16 unk2; + s16 unk4; + u8 pad6[6]; + f32 x_position; + f32 y_position; + f32 z_position; + f32 pad18; + f32 unk1C; + f32 pad20; + f32 unk24; + f32 unk28; + f32 unk2C; + f32 unk30; + s16 unk34; + s16 pad36; + s16 unk38; + s8 pad3A; + s8 unk3B; + u8 pad3C[8]; +} unk80120AC0; + +extern unk80120AC0 D_80120AC0[4]; // Unknown number of entries. +extern unk80120AC0 D_80120AFB[4]; // Unknown number of entries. +extern unk80120AC0 D_80120BD0[4]; // Unknown number of entries. +extern s32 D_80120CE0; +extern s32 D_80120CE4; +extern s32 D_80120CE8; +extern s32 D_80120D08; +extern s32 D_80120D0C; +extern f32 D_80120D10; +extern s8 D_80120D14; +extern u8 D_80120D15; +extern s32 D_80120D18; +extern s32 D_80120D1C; +extern s32 D_80120D6C; +extern s32 D_80120D70[6]; +extern s32 D_80120D88[6]; // Unknown number of entries. +extern s32 D_80120EE0; +extern s32 D_80120F20; +extern s32 D_80120F60; +extern s32 D_80120FE0; +extern s32 D_80120FA0; +extern s32 D_80121060; +extern s32 D_801210A0; +extern s32 D_801210E0; + +/* Size: 5 bytes */ +typedef struct unk80121110 { + u16 unk0; + s8 unk2; + s8 unk3; + s8 unk4; +} unk80121110; +extern unk80121110 D_80121110[2]; // Unknown number of entries +extern u16 D_80121140[2]; // Unknown number of entries. +extern u16 D_80121148[2]; // Unknown number of entries. +extern u8 D_80121150[8]; // Unknown number of entries. + +extern s32 D_A4000000; +extern s32 SP_IMEM; + +unk80120AC0 *func_80069D20(void); +void func_800014BC(f32 arg0); +s8* func_8001E29C(s32 arg0); +s32 func_8006A624(s8 arg0); +void func_8006F64C(s32*, f32, f32, f32, f32*, f32*, f32*); +void guPerspectiveF(s32*, s32*, f32, f32, f32, f32, f32); +void func_8006F870(s32*, s32*); +s16 func_80029F18(f32, f32, f32); +void func_8006A50C(void); +void func_800665E8(s32 arg0); +void func_8006CB58(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +void func_8006C164(void); +void func_8000E194(void); +f32 sqrtf(f32); +void osSetTime(u64); +void func_8001D5E0(f32 arg0, f32 arg1, f32 arg2); +void func_800705F8(s32, f32, f32, f32); +void func_8006ECFC(s32 arg0); + + +GLOBAL_ASM("asm/non_matchings/unknown_066AA0/func_80065EA0.s") + +void func_80066060(s32 arg0, s32 arg1) { + if (arg0 >= 0 && arg0 < 4) { + D_800DD2F8[arg0] = arg1; + D_80120AC0[arg0].unk3B = arg1; + } +} + +void func_80066098(s8 arg0) { + s8 temp = (arg0 << 24) >> 24; + if (!osTvType) { + D_80120D15 = temp; + } +} +void func_800660C0(void) { + D_80120D18 = 1; +} +void func_800660D0(void) { + D_80120D18 = 0; +} +/* Unused? */ +f32 func_800660DC(void) { + return D_80120D10; +} + +void func_800660EC(f32 arg0) { + if (0.0f < arg0 && arg0 < 90.0f && arg0 != D_80120D10) { + D_80120D10 = arg0; + guPerspectiveF(&D_80120EE0, &D_80120D6C, arg0, 1.33333333f, 10.0f, 15000.0f, 1.0f); + func_8006F870(&D_80120EE0, &D_80120FE0); + } +} + +void func_80066194(void) { + guPerspectiveF(&D_80120EE0, &D_80120D6C, 60.0f, 1.33333333f, 10.0f, 15000.0f, 1.0f); + func_8006F870(&D_80120EE0, &D_80120FE0); +} + +/* Unused? */ +s32* func_80066204(void) { + return &D_801210A0; +} + +s32 func_80066210(void) { + return D_80120CE0; +} + +s32 func_80066220(void) { + return D_80120CE4; +} + +void func_80066230(s32 arg0, s32 arg1) { + unk80120AC0 *someStruct; + s16 sp2A; + s16 sp28; + s16 sp26; + s16 sp24; + f32 sp20; + f32 sp1C; + f32 sp18; + + func_8006652C(0); + func_800665E8(0); + someStruct = func_80069D20(); + sp2A = someStruct->unk0; + sp28 = someStruct->unk2; + sp26 = someStruct->unk4; + sp20 = someStruct->x_position; + sp1C = someStruct->y_position; + sp18 = someStruct->z_position; + sp24 = someStruct->unk38; + someStruct->unk4 = 0; + someStruct->unk2 = 0; + someStruct->unk0 = -0x8000; + someStruct->unk38 = 0; + someStruct->x_position = 0.0f; + someStruct->y_position = 0.0f; + someStruct->z_position = 0.0f; + func_8001D5E0(0.0f, 0.0f, -1.0f); + func_80066CDC(arg0, arg1); + someStruct->unk38 = sp24; + someStruct->unk0 = sp2A; + someStruct->unk2 = sp28; + someStruct->unk4 = sp26; + someStruct->x_position = sp20; + someStruct->y_position = sp1C; + someStruct->z_position = sp18; +} + +f32 func_80066348(f32 arg0, f32 arg1, f32 arg2) { + s32 phi_v1; + f32 temp_f2, temp_f0, temp_f14; + + phi_v1 = D_80120CE4; + + if (D_80120D14 != 0) { + phi_v1 += 4; + } + + temp_f0 = arg2 - D_80120AC0[phi_v1].z_position; + temp_f2 = arg0 - D_80120AC0[phi_v1].x_position; + temp_f14 = arg1 - D_80120AC0[phi_v1].y_position; + return sqrtf((temp_f0 * temp_f0) + ((temp_f2 * temp_f2) + (temp_f14 * temp_f14))); +} + +void func_800663DC(s32 x_pos, s32 y_pos, s32 z_pos, s32 arg3, s32 arg4, s32 arg5) { + D_80120AC0[D_80120CE4].unk4 = (s16) (arg3 * 0xB6); + D_80120AC0[D_80120CE4].x_position = (f32) x_pos; + D_80120AC0[D_80120CE4].y_position = (f32) y_pos; + D_80120AC0[D_80120CE4].z_position = (f32) z_pos; + D_80120AC0[D_80120CE4].unk2 = (s16) (arg4 * 0xB6); + D_80120AC0[D_80120CE4].unk38 = (u16)0; + D_80120AC0[D_80120CE4].unk24 = 0.0f; + D_80120AC0[D_80120CE4].unk28 = 0.0f; + D_80120AC0[D_80120CE4].unk2C = 0.0f; + D_80120AC0[D_80120CE4].unk30 = 0.0f; + D_80120AC0[D_80120CE4].unk1C = 160.0f; + D_80120AC0[D_80120CE4].unk0 = (s16) (arg5 * 0xB6); + D_80120AC0[D_80120CE4].unk3B = D_800DD2F8[D_80120CE4]; +} + +void func_80066488(s32 arg0, f32 arg1, f32 arg2, f32 arg3, s16 arg4, s16 arg5, s16 arg6) { + arg0 += 4; + D_80120AC0[arg0].unk38 = 0; + D_80120AC0[arg0].x_position = arg1; + D_80120AC0[arg0].y_position = arg2; + D_80120AC0[arg0].z_position = arg3; + D_80120AC0[arg0].unk0 = arg4; + D_80120AC0[arg0].unk2 = arg5; + D_80120AC0[arg0].unk4 = arg6; + D_80120AC0[arg0].unk34 = func_80029F18(arg1, arg2, arg3); + D_80120D14 = 1; +} + +s8 func_80066510(void) { + return D_80120D14; +} + +void func_80066520(void) { + D_80120D14 = 0; +} + +s32 func_8006652C(s32 arg0) { + if ((arg0 >= 0) && (arg0 < 4)) { + D_80120CE0 = arg0; + } else { + D_80120CE0 = 0; + } + switch(D_80120CE0) { + case 0: + D_80120CE8 = 1; + break; + case 1: + D_80120CE8 = 2; + break; + case 2: + D_80120CE8 = 3; + break; + case 3: + D_80120CE8 = 4; + break; + } + if (D_80120CE4 >= D_80120CE8) { + D_80120CE4 = 0; + } + return D_80120CE8; +} + +void func_800665E8(s32 arg0) { + if (arg0 >= 0 && arg0 < 4) { + D_80120CE4 = arg0; + } else { + D_80120CE4 = 0; + } +} + +GLOBAL_ASM("asm/non_matchings/unknown_066AA0/func_80066610.s") + +void func_80066818(s32 arg0, s32 arg1) { + if (arg1 != 0) { + D_800DD064[arg0].unk30 |= 1; + } else { + D_800DD064[arg0].unk30 |= 2; + } + D_800DD064[arg0].unk30 &= -5; +} + +void func_80066894(s32 arg0, s32 arg1) { + if (arg1 != 0) { + D_800DD064[arg0].unk30 &= -2; + } else { + D_800DD064[arg0].unk30 |= 4; + } + D_800DD064[arg0].unk30 &= -3; +} + +s32 func_80066910(s32 arg0) { + return D_800DD064[arg0].unk30 & 0x1; +} + +GLOBAL_ASM("asm/non_matchings/unknown_066AA0/func_80066940.s") + +void func_80066AA8(s32 arg0, s32 arg1, s32 arg2, s32 arg3, s32 arg4) { + if (arg1 != 0x8000) { + D_800DD064[arg0].unk10 = arg1; + D_800DD064[arg0].unk30 |= 8; + } else { + D_800DD064[arg0].unk30 &= 0xFFFFFFF7; + } + if (arg2 != 0x8000) { + D_800DD064[arg0].unk10 = arg2; + D_800DD064[arg0].unk30 |= 0x10; + } else { + D_800DD064[arg0].unk30 &= 0xFFFFFFEF; + } + if (arg3 != 0x8000) { + D_800DD064[arg0].unk18 = arg3; + D_800DD064[arg0].unk30 |= 0x20; + } else { + D_800DD064[arg0].unk30 &= 0xFFFFFFDF; + } + if (arg4 != 0x8000) { + D_800DD064[arg0].unk1C = arg4; + D_800DD064[arg0].unk30 |= 0x40; + return; + } + D_800DD064[arg0].unk30 &= 0xFFFFFFBF; +} + +s32 func_80066BA8(s32 arg0, s32 *arg1, s32 *arg2, s32 *arg3, s32 *arg4) { + *arg1 = D_800DD064[arg0].unk20; + *arg3 = D_800DD064[arg0].unk28; + *arg2 = D_800DD064[arg0].unk24; + *arg4 = D_800DD064[arg0].unk2C; + if ((*arg1 | *arg3 | *arg2 | *arg4) == 0) { + return 0; + } + return 1; +} + +void func_80066C2C(s32 arg0, s32 *arg1, s32 *arg2, s32 *arg3, s32 *arg4) { + *arg1 = D_800DD064[arg0].unk0; + *arg2 = D_800DD064[arg0].unk4; + *arg3 = D_800DD064[arg0].unk8; + *arg4 = D_800DD064[arg0].unkC; +} + +// Unused? +void func_80066C80(s32 *arg0, s32 *arg1, s32 *arg2, s32 *arg3) { + u32 temp_v0 = func_8007A520(); + *arg0 = 0; + *arg1 = 0; + *arg2 = temp_v0 & 0xFFFF; + *arg3 = (u32) (temp_v0 >> 0x10); +} + + +#if 1 +GLOBAL_ASM("asm/non_matchings/unknown_066AA0/func_80066CDC.s") +#else +// Work in progress! + +void func_80066CDC(Gfx **dlist, s32 *arg1) { + u32 sp58; + u32 sp54; + u32 sp50; + u32 sp4C; + s32 sp34; + s32 sp2C; + u32 temp_a0; + u32 temp_a0_3; + u32 temp_a0_4; + u32 temp_a2; + u32 temp_a3; + u32 temp_a3_2; + u32 temp_t0; + u32 temp_t1_2; + u32 temp_v0; + u32 temp_v0_3; + u32 temp_v0_4; + u32 temp_v1_10; + u32 temp_v1_3; + u32 temp_v1_4; + s32 phi_t1; + s32 phi_v1; + f32 phi_f6; + f32 phi_f18; + f32 phi_f16; + f32 phi_f8; + f32 phi_f6_2; + f32 phi_f18_2; + f32 phi_f8_2; + f32 phi_f16_2; + u32 phi_a1; + f32 phi_f8_3; + f32 phi_f16_3; + f32 phi_f16_4; + u32 phi_t3; + u32 phi_a3_2; + u32 phi_t5; + u32 phi_t4; + + sp34 = D_80120CE4; + phi_t1 = D_80120CE4; + if (func_8000E184() && D_80120CE0 == 0) { + D_80120CE4 = 1; + phi_t1 = 0; + } + temp_v0 = func_8007A520(); + temp_t0 = temp_v0 >> 0x10; + temp_a3 = temp_t0 >> 1; + + if (D_800DD064[phi_t1].unk30 & 1) { + sp2C = D_80120CE4; + D_80120CE4 = phi_t1; + fast3d_cmd( + (*dlist)++, + ((((s32)(D_800DD064[D_80120CE4].unk24 * 4.0f)) & 0xFFF) | 0xED000000) | (((s32)(D_800DD064[D_80120CE4].unk20 * 4.0f)) & 0xFFF) << 0xC, + (((s32)(D_800DD064[D_80120CE4].unk2C * 4.0f)) & 0xFFF) | (((s32)(D_800DD064[D_80120CE4].unk28 * 4.0f)) & 0xFFF) << 0xC + ) + func_80068158(dlist, 0, 0, 0, 0); + D_80120CE4 = sp2C; + if (arg1 != 0) { + func_80067D3C(dlist, arg1); + } + D_80120CE4 = sp34; + return; + } + temp_t1_2 = temp_v0 & 0xFFFF; + phi_v1 = D_80120CE0; + if (D_80120CE0 == 2) { + phi_v1 = 3; + } + temp_a2 = temp_t1_2 >> 1; + sp54 = temp_a2; + sp58 = temp_a3; + if (osTvType == 0) { + sp58 = 0x91; + } + + switch(phi_v1) { + case 0: + phi_t3 = sp58; + if (osTvType == 0) { + phi_t3 = sp58 - 0x12; + } + phi_f16_4 = temp_t0; + if (temp_t0 < 0) { + phi_f16_4 = temp_t0 + 4294967296.0f; + } + fast3d_cmd( + (*dlist)++, + 0xED000000, + ((((s32)(temp_t1_2 * 4.0f)) & 0xFFF) << 0xC) | (((s32)(phi_f16_4 * 4.0f)) & 0xFFF) + ) + sp4C = temp_a2; + phi_a3_2 = temp_a2; + break; + case 1: + if (D_80120CE4 == 0) { + temp_v0_4 = temp_t0 >> 2; + phi_t3 = temp_v0_4; + if (osTvType == 0) { + phi_t3 = temp_v0_4 - 0xC; + } + phi_f8_3 = temp_a3 - (temp_t0 >> 7); + if (phi_f8_3 < 0) { + phi_f8_3 += 4294967296.0f; + } + fast3d_cmd( + (*dlist)++, + 0xED000000, + ((((s32)(temp_t1_2 * 4.0f)) & 0xFFF) << 0xC) | (((s32)(phi_f8_3 * 4.0f)) & 0xFFF) + ) + } else { + temp_v1_10 = temp_t0 >> 7; + phi_f16_3 = temp_t0 - temp_v1_10; + if (phi_f16_3 < 0) { + phi_f16_3 += 4294967296.0f; + } + fast3d_cmd( + (*dlist)++, + (((s32)((temp_a3 + temp_v1_10) * 4.0f)) & 0xFFF) | 0xED000000, + ((((s32)(temp_t1_2 * 4.0f)) & 0xFFF) << 0xC) | (((s32)(phi_f16_3 * 4.0f)) & 0xFFF) + ) + phi_t3 = temp_a3 + (temp_t0 >> 2); + } + sp4C = temp_a2; + phi_a3_2 = temp_a2; + break; + case 2: + if (D_80120CE4 == 0) { + phi_f8_2 = temp_t0; + if (temp_t0 < 0) { + phi_f8_2 = temp_t0 + 4294967296.0f; + } + fast3d_cmd( + (*dlist)++, + 0xED000000, + ((((s32)((temp_a2 - (temp_t1_2 >> 8)) * 4.0f)) & 0xFFF) << 0xC) | (((s32)(phi_f8_2 * 4.0f)) & 0xFFF) + ) + phi_a1 = temp_t1_2 >> 2; + } else { + temp_a0_4 = temp_t1_2 >> 8; + phi_f16_2 = temp_t0; + if (temp_t0 < 0) { + phi_f16_2 = temp_t0 + 4294967296.0f; + } + fast3d_cmd( + (*dlist)++, + (((s32)((temp_a2 + temp_a0_4) * 4.0f) & 0xFFF) << 0xC) | 0xED000000, + (((s32)((temp_t1_2 - temp_a0_4) * 4.0f) & 0xFFF) << 0xC) | (((s32)(phi_f16_2 * 4.0f)) & 0xFFF) + ) + phi_a1 = temp_a2 + (temp_t1_2 >> 2); + } + sp4C = phi_a1; + phi_t3 = sp58; + phi_a3_2 = phi_a1; + break; + case 3: + switch(D_80120CE4) { + case 0: + phi_f6_2 = temp_a2 - (temp_t1_2 >> 8); + if (phi_f6_2 < 0) { + phi_f6_2 += 4294967296.0f; + } + phi_f18_2 = temp_a3 - (temp_t0 >> 7); + if (phi_f18_2 < 0) { + phi_f18_2 += 4294967296.0f; + } + fast3d_cmd( + (*dlist)++, + ((((s32)(0U * 4.0f) & 0xFFF) << 0xC) | 0xED000000) | (((s32)(0U * 4.0f)) & 0xFFF), + (((s32)(phi_f6_2 * 4.0f) & 0xFFF) << 0xC) | (((s32)(phi_f18_2 * 4.0f)) & 0xFFF) + ) + phi_t5 = 0U; + phi_t4 = 0U; + break; + case 1: + temp_a0_3 = temp_t1_2 >> 8; + phi_f8 = temp_a3 - (temp_t0 >> 7); + if (phi_f8 < 0) { + phi_f8 += 4294967296.0f; + } + fast3d_cmd( + (*dlist)++, + ((((s32)((temp_a2 + temp_a0_3) * 4.0f)) & 0xFFF) << 0xC) | 0xED000000, + ((((s32)(((temp_a2 * 2) - temp_a0_3) * 4.0f)) & 0xFFF) << 0xC) | (((s32)(phi_f8 * 4.0f)) & 0xFFF) + ) + phi_t5 = 0U; + phi_t4 = temp_a2; + break; + case 2: + temp_v1_4 = temp_t0 >> 7; + phi_f16 = (temp_a3 * 2) - temp_v1_4; + if (phi_f16 < 0) { + phi_f16 += 4294967296.0f; + } + fast3d_cmd( + (*dlist)++, + (((s32)((temp_a3 + temp_v1_4) * 4.0f)) & 0xFFF) | 0xED000000, + ((((s32)((temp_a2 - (temp_t1_2 >> 8)) * 4.0f)) & 0xFFF) << 0xC) | (((s32)(phi_f16 * 4.0f)) & 0xFFF) + ) + phi_t5 = temp_a3; + phi_t4 = 0U; + break; + case 3: + temp_a0 = temp_t1_2 >> 8; + temp_v1_3 = temp_t0 >> 7; + phi_f6 = (temp_a2 * 2) - temp_a0; + if (phi_f6 < 0) { + phi_f6 += 4294967296.0f; + } + phi_f18 = (temp_a3 * 2) - temp_v1_3; + if (phi_f18 < 0) { + phi_f18 += 4294967296.0f; + } + fast3d_cmd( + (*dlist)++, + (((((s32)((temp_a2 + temp_a0) * 4.0f)) & 0xFFF) << 0xC) | 0xED000000) | (((s32)((temp_a3 + temp_v1_3) * 4.0f)) & 0xFFF), + ((((s32)(phi_f6 * 4.0f) & 0xFFF)) << 0xC) | (((s32)(phi_f18 * 4.0f)) & 0xFFF) + ) + phi_t5 = temp_a3; + phi_t4 = temp_a2; + break; + default: + phi_t5 = 0; + phi_t4 = 0; + break; + } + temp_v0_3 = phi_t5 + sp58; + temp_a3_2 = phi_t4 + sp54; + phi_t3 = temp_v0_3; + phi_a3_2 = temp_a3_2; + if (osTvType == 0) { + phi_t3 = temp_v0_3 - 6; + phi_a3_2 = temp_a3_2; + if (D_80120CE4 < 2) { + phi_t3 = temp_v0_3 - 0x14; + phi_a3_2 = temp_a3_2; + } + } + break; + default: + phi_t3 = sp50; + phi_a3_2 = sp4C; + break; + } + + if (osTvType == 0) { + phi_a3_2 -= 4; + } + func_80068158(dlist, sp54, sp58, phi_a3_2, phi_t3); + if (arg1 != 0) { + func_80067D3C(dlist, arg1); + } + D_80120CE4 = sp34; +} +#endif + +GLOBAL_ASM("asm/non_matchings/unknown_066AA0/func_80067A3C.s") +GLOBAL_ASM("asm/non_matchings/unknown_066AA0/func_80067D3C.s") + +void func_80067F20(f32 arg0) { + D_800DD2CC[0] = arg0; +} + +GLOBAL_ASM("asm/non_matchings/unknown_066AA0/func_80067F2C.s") + +void func_8006807C(Gfx **dlist, s32 *arg1) { + func_8006FE74(&D_80121060, &D_800DD288); + func_8006F768(&D_80121060, &D_80120EE0, &D_80120F20); + func_8006FE74(D_80120D70[0], &D_800DD2A0); + func_8006F768(D_80120D70[0], &D_80120F20, &D_80121060); + func_8006F870(&D_80121060, (s32*)*arg1); // This doesn't look right. Need to check this! + fast3d_cmd((*dlist)++, 0x1000040, (u32)(*arg1 + 0x80000000)) + *arg1 += 0x40; + D_80120D1C = 0; + D_80120D08 = 0; +} + +GLOBAL_ASM("asm/non_matchings/unknown_066AA0/func_80068158.s") +GLOBAL_ASM("asm/non_matchings/unknown_066AA0/func_800682AC.s") + +void func_80068408(Gfx **dlist, s32 *arg1) { + func_800705F8(D_80120D70[D_80120D1C], 0.0f, 0.0f, 0.0f); + func_8006F768(D_80120D70[D_80120D1C], &D_80120F20, &D_80121060); + func_8006F870(&D_80121060, (s32*)*arg1); // This doesn't look right. Need to check this! + D_80120D88[D_80120D1C] = *arg1; + + fast3d_cmd((*dlist)++, ((((D_80120D08 << 6) & 0xFF) << 0x10) | 0x1000000) | 0x40, (u32)(*arg1 + 0x80000000)) + + *arg1 += 0x40; +} + +void func_80068508(s32 arg0) { + D_80120D0C = arg0; +} + +GLOBAL_ASM("asm/non_matchings/unknown_066AA0/func_80068514.s") +GLOBAL_ASM("asm/non_matchings/unknown_066AA0/func_80068BF4.s") +GLOBAL_ASM("asm/non_matchings/unknown_066AA0/func_80068FA8.s") +GLOBAL_ASM("asm/non_matchings/unknown_066AA0/func_80069484.s") +GLOBAL_ASM("asm/non_matchings/unknown_066AA0/func_80069790.s") +GLOBAL_ASM("asm/non_matchings/unknown_066AA0/func_80069A40.s") + +unk80120AC0 *func_80069CFC(void) { + return &D_80120AC0[D_80120CE4]; +} + +unk80120AC0 *func_80069D20(void) { + if (D_80120D14 != 0) { + return &D_80120AC0[D_80120CE4 + 4]; + } + return &D_80120AC0[D_80120CE4]; +} + +unk80120AC0 *func_80069D7C(void) { + if (D_80120D14 != 0) { + return D_80120BD0; + } + return D_80120AC0; +} + +s32* func_80069DA4(void) { + return &D_80120FA0; +} + +s32* func_80069DB0(void) { + return &D_80120FE0; +} + +s32* func_80069DBC(void) { + return &D_80120F60; +} + +f32 func_80069DC8(f32 arg0, f32 arg1, f32 arg2) { + f32 sp34; + f32 sp30; + f32 returnVal; + func_8006F64C(&D_80120F60, arg0, arg1, arg2, &sp34, &sp30, &returnVal); + return returnVal; +} + +void func_80069E14(f32 arg0, f32 arg1, f32 arg2, f32 arg3, f32 arg4) { + f32 temp_f0; + f32 temp_f0_2; + f32 temp_f14; + f32 temp_f2; + s32 i; + + for (i = 0; i <= D_80120CE0; i++) { + temp_f0 = arg0 - D_80120AC0[i].x_position; + temp_f2 = arg1 - D_80120AC0[i].y_position; + temp_f14 = arg2 - D_80120AC0[i].z_position; + temp_f0_2 = sqrtf(((temp_f0 * temp_f0) + (temp_f2 * temp_f2)) + (temp_f14 * temp_f14)); + if (temp_f0_2 < arg3) { + D_80120AC0[i].unk30 = ((arg3 - temp_f0_2) * arg4) / arg3; + } + } +} + +GLOBAL_ASM("asm/non_matchings/unknown_066AA0/func_80069F28.s") + +s32* func_8006A100(void) { + return &D_801210E0; +} + +#if 1 +GLOBAL_ASM("asm/non_matchings/unknown_066AA0/func_8006A10C.s") +#else + +extern s32 D_800DD300; +extern s32 D_801210F8; +extern s32 D_801210FC; +extern s8 D_80121100; +extern u8 D_80121103; + +// Has regalloc & stack issues. +s32 func_8006A10C(void) { + u8 sp23; + osCreateMesgQueue(&D_801210E0, &D_801210F8, 1); + osSetEventMesg(5, &D_801210E0, D_801210FC); + func_800CCC20(&D_801210E0, &sp23, &D_80121100); + func_800CCFE0(&D_801210E0); + func_8006A434(); + D_800DD300 = 0; + if ((sp23 & 1) && !(D_80121103 & 8)) { + return 0; + } + D_800DD300 = 1; + return -1; +} +#endif + +GLOBAL_ASM("asm/non_matchings/unknown_066AA0/func_8006A1C4.s") +GLOBAL_ASM("asm/non_matchings/unknown_066AA0/func_8006A434.s") + +void func_8006A458(s8 *activePlayers) { + s32 i; + s32 temp = 0; + for(i = 0; i < 4; i++) { + if (activePlayers[i]) { + D_80121150[temp++] = i; + } + } + for(i = 0; i < 4; i++) { + if (!activePlayers[i]) { + D_80121150[temp++] = i; + } + } +} + +u8 func_8006A4F8(s32 arg0) { + return D_80121150[arg0]; +} + +void func_8006A50C(void) { + u8 temp = D_80121150[0]; + D_80121150[0] = D_80121150[1]; + D_80121150[1] = temp; +} + +u16 func_8006A528(s32 arg0) { + return D_80121110[D_80121150[arg0]].unk0; +} + +u16 func_8006A554(s32 arg0) { + return D_80121140[D_80121150[arg0]]; +} + +u16 func_8006A578(s32 arg0) { + return D_80121148[D_80121150[arg0]]; +} + +s32 func_8006A59C(s32 arg0) { + func_8006A624(D_80121110[D_80121150[arg0]].unk2); +} + +s32 func_8006A5E0(s32 arg0) { + func_8006A624(D_80121110[D_80121150[arg0]].unk3); +} + +s32 func_8006A624(s8 arg0) { + if (arg0 < 8 && arg0 >= -7) { + return 0; + } + if (arg0 > 0) { + arg0 -= 8; + if (arg0 >= 0x47) { + arg0 = 0x46; + } + } else { + arg0 += 8; + if (arg0 < -0x46) { + arg0 = -0x46; + } + } + return arg0; +} + +void func_8006A6A0(void) { + D_800DD304 = 0; +} diff --git a/src/unknown_06B2B0.c b/src/unknown_06B2B0.c new file mode 100644 index 00000000..a6001659 --- /dev/null +++ b/src/unknown_06B2B0.c @@ -0,0 +1,1324 @@ +/* The comment below is needed for this file to be picked up by generate_ld */ +/* RAM_POS: 0x8006A6B0 */ + +#include "types.h" +#include "macros.h" +#include "structs.h" +#include "fast3d.h" + +/************ .rodata ************/ + +const char D_800E70B0[] = "LOADLEVEL Error: Level out of range\n"; +const char D_800E70D8[] = "BossLev problem\n"; +const char D_800E70EC[] = "AITABLE Error: Table out of range\n"; +const char D_800E7110[] = "1.1605"; +const char D_800E7118[] = "02/10/97 16:03"; +const char D_800E7128[] = "pmountain"; + +const char D_800E7134[] = "BBB\n"; +const char D_800E713C[] = "CAR"; +const char D_800E7140[] = "HOV"; +const char D_800E7144[] = "PLN"; +const char D_800E7148[] = "Swapping\n"; + +/*********************************/ + +/************ .data ************/ + +s8 D_800DD310 = 0; // Currently unknown, might be a different type. +s8 D_800DD314 = -1; +s8 D_800DD318 = 0; +s32 D_800DD31C = 0; +s32 D_800DD320 = 0x585E; +s32 D_800DD324 = 0x154; +s16 D_800DD328 = 0; +s16 D_800DD32C = 0; + +s8 D_800DD330 = 0; + +// Unused? +char *D_800DD334[6] = { + NULL, NULL, NULL, // These could be a file boundary. + D_800E7110, D_800E7118, D_800E7128 +}; + +// Unused? +char gBuildString[40] = "Version 7.7 29/09/97 15.00 L.Schuneman"; + +s8 D_800DD374 = 0; +s32 D_800DD378 = 1; +s32 D_800DD37C = 0; +s32 D_800DD380 = 0; // Currently unknown, might be a different type. +s32 D_800DD384 = 0; +s32 D_800DD388 = 0; // Currently unknown, might be a different type. +s8 D_800DD38C = 0; +u8 D_800DD390 = 0; +s16 D_800DD394 = 0; +u8 D_800DD398 = 0; +s32 D_800DD39C = 0; // Currently unknown, might be a different type. +s8 D_800DD3A0 = 0; +s32 D_800DD3A4 = 0; // Currently unknown, might be a different type. +s32 D_800DD3A8 = 0; // Currently unknown, might be a different type. +s32 D_800DD3AC = 0; // Currently unknown, might be a different type. +s32 D_800DD3B0 = 0x1194; +s32 D_800DD3B4 = 0x1B58; +s32 D_800DD3B8 = 0x2AF8; +s32 D_800DD3BC = 0x2AF8; +s32 D_800DD3C0 = 0x12C; +s32 D_800DD3C4 = 0x258; +s32 D_800DD3C8 = 0x352; +s32 D_800DD3CC = 0x384; +s32 D_800DD3D0 = 0x12C; +s32 D_800DD3D4 = 0x190; +s32 D_800DD3D8 = 0x226; +s32 D_800DD3DC = 0x258; +s32 D_800DD3E0 = 0x14; +s32 D_800DD3E4 = 0x1E; +s32 D_800DD3E8 = 0x28; +s32 D_800DD3EC = 0x32; + +s8 D_800DD3F0 = 0; +s16 D_800DD3F4[8] = { + -32768, 0, 20, 0, + 255, -1, 20, -1 +}; +s32 D_800DD404 = 12; +s32 D_800DD408 = 0x00FFFFFF; +s32 D_800DD40C = 0x001EFFFF; // Unused? + +// Unused? +char *D_800DD410[3] = { + D_800E713C, D_800E7140, D_800E7144 +}; + +// Not sure if this is an array or a struct. +s32 D_800DD41C[2] = { + 0, 0x001EFFFF +}; + +s32 D_800DD424[2] = { + 0, 0x0104FFFF +}; + +/*******************************/ + + +extern s32 D_800DFD94; +extern s32 D_80121164; + +extern LevelHeader* D_80121168; + +extern s32 D_80121170; +extern s32 D_80121174; + +// Size: 6 bytes +typedef struct unk8012117C { + s8 unk0; + s8 unk1; + s8 unk2; + s8 pad3[3]; +} unk8012117C; +extern unk8012117C *D_8012117C[2]; // Unknown number of entries + +extern s32 D_801211C0; +extern s16 D_801211C8[8]; // Unknown number of entries +extern Gfx *D_801211F0[3]; // Unknown number of entries. +extern Gfx *D_801211F8; +extern s32 D_80121208; +extern s32 D_80121218; +extern s32 D_80121228; +extern s8 D_80121250[16]; // Unknown number of entries +extern s32 D_801234E8; +extern s32 D_801234EC; +extern s32 D_801234F0; +extern s32 D_801234F4; +extern s32 D_801234F8; +extern s32 D_801234FC; +extern s32 D_80123500; +extern s32 D_80123504; +extern s32 D_80123508; +extern Settings *gSettingsPtr; +extern s8 D_80123514; +extern s8 gIsPaused; +extern s8 D_80123516; +extern s32 D_80123518; +extern s32 D_8012351C; +extern s32 D_80123520; +extern u8 D_80123524; +extern u8 D_80123525; +extern u8 D_80123526; +extern s32* D_80123548; // This is actually an OSMesgQueue pointer. +extern s32 D_80123560; + +void func_800014BC(f32 arg0); +s8* func_8001E29C(s32 arg0); +s32 func_8006A624(s8 arg0); +void func_8006F64C(s32*, f32, f32, f32, f32*, f32*, f32*); +void guPerspectiveF(s32*, s32*, f32, f32, f32, f32, f32); +void func_8006F870(s32*, s32*); +s16 func_80029F18(f32, f32, f32); +void func_8006A50C(void); +void func_800665E8(s32 arg0); +void func_8006CB58(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +void func_8006C164(void); +void func_8000E194(void); +f32 sqrtf(f32); +void osSetTime(u64); +void func_8001D5E0(f32 arg0, f32 arg1, f32 arg2); +void func_800705F8(s32, f32, f32, f32); +void func_8006ECFC(s32 arg0); + + +GLOBAL_ASM("asm/non_matchings/unknown_066AA0/func_8006A6B0.s") + +s32 func_8006B0AC(s32 arg0) { + if (arg0 > 0 && arg0 < D_80121170) { + return (*D_8012117C)[arg0].unk2 & 0xF; + } + return 0; +} + +s32 func_8006B0F8(s32 arg0) { + if (arg0 > 0 && arg0 < D_80121170) { + s32 temp = (*D_8012117C)[arg0].unk2; + if(temp != 0) { + return (temp >> 4) & 0xF; + } + } + return 1; +} + +s8 func_8006B14C(s32 arg0) { + if (arg0 >= 0 && arg0 < D_80121170) { + return (*D_8012117C)[arg0].unk1; + } + return -1; +} + +s8 func_8006B190(s32 arg0) { + if (arg0 >= 0 && arg0 < D_80121170) { + return (*D_8012117C)[arg0].unk0; + } + return 0; +} + +s32 func_8006B1D4(s32 arg0) { + s8* temp; + + if (arg0 < 0 || arg0 >= D_80121174) { + arg0 = 0; + } + temp = func_8001E29C(0x1B); + + return temp[arg0]; +} + +void func_8006B224(s32* arg0, s32* arg1) { + *arg0 = D_80121170; + *arg1 = D_80121174; +} + + +s32 func_8006B240(void) { + return D_800DD31C; +} + +#if 1 +GLOBAL_ASM("asm/non_matchings/unknown_066AA0/func_8006B250.s") +#else + +extern s32 *D_80121160; +extern s32 D_800DD314; + +Settings *get_settings(void); +s32 *func_80076C58(s32); +LevelHeader *func_80070C9C(s32, s32); +void func_8006C1AC(s32 arg0, s32 arg1, s32 arg2, s32 arg3); +void func_8006C2E4(void); +s16 func_8006C2F0(void); +void func_8006DB20(s32 arg0); +void func_80072708(void); + +// load_level(levelID, numOfPlayers, entrance, vehicle, ???); +void func_8006B250(s32 arg0, s32 arg1, s32 arg2, s32 arg3, s32 arg4) { + s32 sp48; + s32 sp44; + Settings *settings; + s32 temp_s0_2; + s32 temp_s0_5; + s32 temp_t8_3; + s32 temp_v0_5; + s8 *temp_v0_4; + s32 phi_v1; + s32 phi_v1_2; + s32 phi_v0_2; + s32 phi_s0; + s32 phi_v1_5; + s8 phi_s0_2; + s32 phi_at; + s32 phi_s0_3; + s32 phi_s0_5; + s32 phi_v1_9; + s32 temp, temp2; + + func_80072708(); + if (arg4 == -1) { + arg4 = 0; + } + if (arg1 == -1) { + sp48 = 1; + arg1 = 0; + } else { + sp48 = 0; + } + if (arg1 == 0) { + func_8000318C(0x8); + } else if (arg1 == 1) { + func_8000318C(0xC); + } else { + func_8000318C(0x10); + } + + settings = get_settings(); + D_80121160 = func_80076C58(0x16); + phi_v1 = 0; + while (-1 != D_80121160[phi_v1]) { + phi_v1++; + } + phi_v1--; + if (arg0 >= phi_v1) { + arg0 = 0; + } + temp2 = D_80121160[arg0]; + temp = D_80121160[arg0 + 1] - temp2; + D_80121168 = func_80070C9C(temp, 0xFFFF00FF); + func_80076E68(0x17, D_80121168, temp2, temp); + D_800DD330 = 0; + sp44 = arg0; + if (D_80121168->race_type == 0) { + func_8006C2E4(); + } + if (func_8006C2F0() == 0) { + if (D_800DD32C == 0) { + if (D_80121168->race_type == 8) { + phi_v1_2 = settings->courseFlagsPtr[temp2] & 1; + phi_v0_2 = 0; + if (D_80121168->world == 0 || D_80121168->world == 5) { + phi_v0_2 = 1; + } + if (phi_v1_2 == 0 || phi_v0_2 != 0) { + func_8006C1AC(arg0, arg2, arg3, arg4); + if ((settings->bosses & (1 << settings->worldId)) != 0) { + arg4 = 7; + } else { + arg4 = 3; + } + if (phi_v0_2 != 0) { + arg4 = 0; + if (phi_v1_2 != 0) { + D_800DD330 = (u8)2; + } + } + temp_v0_4 = func_8001E29C(0x43); + phi_s0 = 0; + while(arg0 != temp_v0_4[phi_s0 + 1]) { + phi_s0++; + } + arg0 = temp_v0_4[phi_s0 + 1]; + arg2 = arg4; + } + + } + if (D_80121168->race_type == 5) { + if (D_80121168->world > 0 && D_80121168->world < 5) { + if ((settings->keys & (1 << D_80121168->world)) != 0) { + temp_v0_5 = 0x4000 << (D_80121168->world + 0x1F); + if ((settings->cutsceneFlags & temp_v0_5) == 0) { + func_8006C1AC(arg0, arg2, arg3, arg4); + settings->cutsceneFlags |= temp_v0_5; + arg2 = 0; + arg4 = 5; + arg0 = func_8001E29C(0x44)[D_80121168->world - 1]; + } + } + } + } + if (D_80121168->race_type == 5 && D_80121168->world == 0 && (settings->cutsceneFlags & 0x2000) == 0 && settings->wizpigAmulet >= 4) { + s32 temp_a1 = arg2; + s32 temp_a3 = arg4; + arg4 = 0; + arg2 = 0; + func_8006C1AC(arg0, temp_a1, arg3, temp_a3); + settings->cutsceneFlags |= 0x2000; + arg0 = (s32) func_8001E29C(0x44)[1]; + } + } + } + D_800DD32C = 0; + if (sp44 != arg0) { + func_80071140(D_80121168); + temp2 = D_80121160[arg0]; + temp = D_80121160[arg0 + 1] - temp2; + D_80121168 = func_80070C9C(temp, 0xFFFF00FF); + func_80076E68(0x17, D_80121168, temp2, temp); + } + func_80071140(D_80121160); + func_8006BFC8(&D_80121168->unk20); + func_8000CBC0(); + D_80121164 = arg0; + for (phi_v1_5 = 0; phi_v1_5 < 7; phi_v1_5++) { + if ((s32)D_80121168->unk74[phi_v1_5] != -1) { + D_80121168->unk74[phi_v1_5] = func_8001E29C((s32)D_80121168->unk74[phi_v1_5]); + func_8007F1E8(D_80121168->unk74[phi_v1_5]); + } + } + if (arg4 == 0x64) { + if(get_trophy_race_world_id() != 0 && D_80121168->race_type == 0) { + arg4 = 0; + } else if(is_in_tracks_mode() == 1 && D_80121168->race_type == 0) { + arg4 = 0; + } + } + if (D_80121168->race_type == 0 || D_80121168->race_type == 8) { + D_800DD31C = 1; + } else { + D_800DD31C = 0; + } + if (sp48 != 0 && D_80121168->race_type != 7) { + D_80121168->race_type = 6; + } + func_80000BE0(D_80121168->unkB3); + func_80000CBC(); + func_80031BB8(0x20); + phi_s0_2 = (u8)0; + if (arg3 >= 0 && arg3 < 3) { + phi_s0_2 = D_80121168->unk4F[arg3]; + } + func_80017E74(phi_s0_2); + settings->courseId = arg0; + if (D_80121168->world != -1) { + settings->worldId = D_80121168->world; + } + if (settings->worldId == 0 && settings->worldId > 0) { + D_800DD314 = func_8006DB2C(); + } + if (settings->worldId == 0 && settings->worldId > 0 && D_800DD314 != -1) { + arg3 = D_800DD314; + } + func_8006DB20(arg3); + if (D_80121168->race_type == 5) { + if (settings->worldId > 0) { + temp_s0_5 = 8 << (settings->worldId + 31); + if (settings->worldId == 5) { + if (settings->balloonsPtr[0] >= 47) { + if (settings->ttAmulet >= 4) { + if ((settings->cutsceneFlags & temp_s0_5) == 0) { + settings->cutsceneFlags |= temp_s0_5; + arg4 = 5; + } + } + } + } else { + if (settings->balloonsPtr[settings->worldId] >= 4) { + if ((settings->cutsceneFlags & temp_s0_5) == 0) { + settings->cutsceneFlags |= temp_s0_5; + arg4 = 5; + } + } + temp_t8_3 = temp_s0_5 << 5; + if (settings->balloonsPtr[settings->worldId] >= 8) { + if ((settings->cutsceneFlags & temp_t8_3) == 0) { + settings->cutsceneFlags |= temp_t8_3; + arg4 = 5; + } + } + } + } + } + if (arg1 != 0 && D_80121168->race_type == 0) { + arg4 = 0x64; + } + if (D_80121168->race_type == 0 || ((D_80121168->race_type & 0x40) != 0 && is_in_two_player_adventure(D_80121168->race_type) != 0)) { + D_800DD318 = (u8)1; + arg4 = 0x64; + } else { + D_800DD318 = (u8)0; + } + if (D_80121168->race_type == 0 && sp48 == 0 && func_8000E4C8(arg4) != 0) { + arg4 = 0x64; + } + func_8001E450(arg4); + func_800249F0(D_80121168->geometry, D_80121168->skybox, arg1, arg3, arg2, D_80121168->collectables, D_80121168->unkBA); + if (D_80121168->unk3A == 0 && D_80121168->unk3C == 0 && D_80121168->fogR == 0 && D_80121168->fogG == 0 && D_80121168->fogB == 0) { + phi_s0_3 = 0; + while(phi_s0_3 < 4) { + func_800307BC(phi_s0_3); + phi_s0_3++; + } + } else { + phi_s0_3 = 0; + while(phi_s0_3 < 4) { + func_80030664(phi_s0_3, D_80121168->unk3A, D_80121168->unk3C, (u8)D_80121168->fogR, D_80121168->fogG, D_80121168->fogB); + phi_s0_3++; + } + } + settings = get_settings(); + if (D_80121168->world != -1) { + settings->worldId = D_80121168->world; + } + settings->courseId = arg0; + if (D_80121168->weather_enable > 0) { + func_800AB4A8( + D_80121168->unk92, + D_80121168->weather_enable, + D_80121168->unk96 << 8, + D_80121168->unk98 << 8, + D_80121168->unk9A << 8, + D_80121168->unk94 * 0x101, + D_80121168->unk95 * 0x101 + ); + func_800AB308(-1, -0x200); + } + if (D_80121168->unk49 == -1) { + D_80121168->unkA4 = func_8007AE74(D_80121168->unkA4); + D_80121168->unkA8 = (u16)0; + D_80121168->unkAA = (u16)0; + } + if ((s32)D_80121168->unkAC != -1) { + D_80121168->unkAC = func_8001E29C((s32)D_80121168->unkAC); + func_8007F414(D_80121168->unkAC); + } + func_800660EC((f32)D_80121168->unk9C); + func_80077B34(D_80121168->unk9D, D_80121168->unk9E, D_80121168->unk9F); + func_8007A974(); + func_8007AB24(D_80121168->unk4[arg1]); +} +#endif + +void func_8006BD10(f32 arg0) { + if (D_80121168->music != 0) { + func_800012E8(); + func_80000B34(D_80121168->music); + func_800014BC(arg0); + func_80001074(D_80121168->instruments); + } +} + +s32 func_8006BD88(void) { + return D_80121164; +} + +u8 func_8006BD98(void) { + return D_80121168->race_type; +} + +LevelHeader* func_8006BDB0(void) { + return D_80121168; +} + +/* Unused? */ +u8 func_8006BDC0(void) { + return D_80121170 - 1; +} + +GLOBAL_ASM("asm/non_matchings/unknown_066AA0/func_8006BDDC.s") + +void func_8006BEFC(void) { + func_8006C164(); + func_80077B34(0, 0, 0); + func_80071140(D_80121168); + func_800049D8(); + func_80001844(); + func_800018E0(); + func_800012E8(); + func_80031B60(); + func_8002C7D4(); + func_80008174(); + func_80000968(0); + if (D_80121168->weather_enable > 0) { + func_800AB35C(); + } + if (D_80121168->unk49 == 0xFF) { + func_8007B2BC(D_80121168->unkA4); + } +} + +extern s32 *D_80121160; +Settings *get_settings(void); +s32 *func_80076C58(s32); + +#if 1 +GLOBAL_ASM("asm/non_matchings/unknown_066AA0/func_8006BFC8.s") +#else +void func_8006BFC8(s8 *arg0) { + s32 temp, temp2; + s16 phi_v1; + s8 phi_s0 = 0; + + if (!is_in_tracks_mode()) { + Settings *settings = get_settings(); + // Regalloc issue: temp3 should be a3, not v1. + s32 temp3 = settings->courseFlagsPtr[settings->courseId]; + if (temp3 & 2) { + phi_s0 = 1; + } + if (temp3 & 4) { + phi_s0 = 2; + } + } else { + phi_s0 = 3; + } + + if (get_trophy_race_world_id() != 0) { + phi_s0 = 4; + } + + if(is_in_adventure_two()){ + phi_s0 += 5; + } + + phi_s0 = arg0[phi_s0]; + + if ((func_8009C30C() << 6) < 0) { + phi_s0 = 9; + } + if (func_8006DA0C() == 1) { + phi_s0 = 5; + } + D_80121160 = func_80076C58(1); + phi_v1 = 0; + while (-1 != (s32)D_80121160[phi_v1]) { + phi_v1++; + } + phi_v1--; + if (phi_s0 >= phi_v1) { + phi_s0 = 0; + } + temp2 = D_80121160[phi_s0]; + temp = D_80121160[phi_s0 + 1] - temp2; + D_801211C0 = func_80070C9C(temp, 0xFFFF00FF, D_80121160); + func_80076E68(0, D_801211C0, temp2, temp); + func_80071140(D_80121160); +} +#endif + +void func_8006C164(void) { + func_80071140(D_801211C0); +} + +s32 func_8006C18C(void) { + return D_801211C0; +} + +s8 func_8006C19C(void) { + return D_800DD318; +} + +void func_8006C1AC(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + D_801211C8[D_800DD328++] = arg0; + D_801211C8[D_800DD328++] = arg1; + D_801211C8[D_800DD328++] = arg2; + D_801211C8[D_800DD328++] = arg3; +} + +void func_8006C22C(s32 *arg0, s32 *arg1, s32 *arg2, s32 *arg3) { + s16 temp_v1; + + D_800DD328--; + *arg3 = D_801211C8[D_800DD328]; + D_800DD328--; + temp_v1 = D_801211C8[D_800DD328]; + D_800DD328--; + *arg1 = D_801211C8[D_800DD328]; + D_800DD328--; + *arg0 = D_801211C8[D_800DD328]; + + if (temp_v1 != -1) { + *arg2 = temp_v1; + } + + D_800DD32C = 1; +} + + +void func_8006C2E4(void) { + D_800DD328 = 0; +} + +s16 func_8006C2F0(void) { + return D_800DD328; +} + +s32 func_8006C300(void) { + if (D_800DD330 >= 2) { + D_800DD330 = 1; + return 0; + } else { + return D_800DD330; + } +} + +#if 1 +GLOBAL_ASM("asm/non_matchings/unknown_066AA0/D_8006C330.s") +#else +void func_8006C330(s32 arg0) { + func_8006C3E0(); + D_800DD37C = func_8006A1C4(D_800DD37C, 0); + D_80123520 = 0; + D_801234EC = -1; + while(1) { + if (func_8006EAC0() != 0) { + func_80072708(); + audioStopThread(); + func_800C73BC(); + __osSpSetStatus(0xAAAA82); + func_800CD250(0x1D6); + while(1); // Infinite loop + } + func_8006C60C(); + func_80065E30(); + } + // This infinite loop creates too many nops! Needs to be 0x10 aligned, not 0x20 aligned. +} +#endif + +#if 1 +GLOBAL_ASM("asm/non_matchings/unknown_066AA0/func_8006C3E0.s") +#else +extern Gfx *D_801211F0; +extern u8 D_800DD374; +extern u8 D_800DD3A0; +extern u16 D_80121260; +extern u8 D_80123538; + +extern s32 D_80123544; +extern s32 D_801234E8; + +void osCreateScheduler(u16*, s32*, s32, u8, s32); +void osScAddClient(u16*, u8*, s32**, s32); + +void func_8006C3E0(void) { + s32 sp24; + + func_80070B30(); + func_800C6170(); + D_800DD374 = 1; + if (func_8006F4EC() != 0) { + D_800DD374 = 0; + } + D_80123514 = 0; + D_80123518 = 0; + + if (osTvType == 0) { + sp24 = 0xE; + } else if (osTvType == 1) { + sp24 = 0; + } else if (osTvType == 2) { + sp24 = 0x1C; + } + + osCreateScheduler(&D_80121260, &D_801234E8, 0xD, sp24, 1); + D_800DD3A0 = 0; + if (func_8006EFB8() == 0) { + D_800DD3A0 = 1; + } + func_8007A310(1, &D_80121260); + func_80076BA0(); + func_80078100(&D_80121260); + audio_init(&D_80121260); + func_80008040(); + D_800DD384 = func_8006A10C(); + func_8007AC70(); + func_8005F850(); + func_8000BF8C(); + func_800B5E88(); + func_800598D0(); + func_800AE530(); + func_800AB1F0(); + func_8006E3BC(); + func_8006EFDC(); + func_800C3C00(); + func_80075B18(); + func_80081218(); + func_800C7350(); + osCreateMesgQueue(&D_80123548, &D_80123544, 1); + osScAddClient(&D_80121260, &D_80123538, &D_80123548, 3); + D_80123560 = 0; + D_80123504 = 0; + D_80123508 = 0; + D_801234E8 = 0; + + // ??? + D_801211F8 = D_801211F0; + fast3d_cmd(D_801211F8++, 0xE9000000, 0x00000000) + fast3d_cmd(D_801211F8++, 0xB8000000, 0x00000000) + + osSetTime(0); +} +#endif + +GLOBAL_ASM("asm/non_matchings/unknown_066AA0/func_8006C60C.s") + +void func_8006CAE4(s32 arg0, s32 arg1, s32 arg2) { + D_80123500 = arg0 - 1; + if (arg1 == -1) { + D_801234F4 = func_8009C1B0(); + } else { + D_801234F4 = arg1; + } + func_8006CB58(D_801234F4, D_80123500, D_80123504, arg2); +} + +void func_8006CB58(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { + func_8006ECFC(arg1); + func_800710B0(0); + func_80065EA0(); + func_800C3048(); + func_8006B250(arg0, arg1, arg2, arg3, D_80123508); + func_8009ECF0(func_80066210()); + func_800AE728(8, 0x10, 0x96, 0x64, 0x32, 0); + func_8001BF20(); + osSetTime(0); + func_800710B0(2); + func_80072298(1); +} + +void func_8006CC14(void) { + func_800710B0(0); + if (D_800DD38C == 0) { + if (D_800DD3F0 != 1) { + func_80077A54(); + } + D_800DD38C = 1; + } + func_8006BEFC(); + func_800C01D8(&D_800DD3F4); + func_800AE270(); + func_800A003C(); + func_800C30CC(); + D_801211F8 = D_801211F0[D_801234E8]; + fast3d_cmd(D_801211F8++, 0xE9000000, 0x00000000) + fast3d_cmd(D_801211F8++, 0xB8000000, 0x00000000) + func_800710B0(2); +} + +// Has a jump table +GLOBAL_ASM("asm/non_matchings/unknown_066AA0/func_8006CCF0.s") + +void func_8006D8A4(void) { + D_800DD390 = 0x2C; + gIsPaused = 0; + func_800945E4(); + func_800C01D8(&D_800DD408); +} + +void func_8006D8E0(s32 arg0) { + D_80123516 = arg0 + 1; +} + +void func_8006D8F0(s32 arg0) { + s32 temp; + if (D_801234EC != 4) { + D_801234F4 = D_80121250[0]; + D_80123504 = 0; + D_80123508 = 0x64; + temp = D_80121250[1]; + if (D_80121250[15] >= 0) { + D_80123504 = D_80121250[15]; + } + if (D_80121250[temp + 8] >= 0) { + D_80123508 = D_80121250[temp + 8]; + } + D_801234F8 = 1; + } +} + +void func_8006D968(s8 *arg0) { + s32 i; + if (D_801234EC != 4) { + D_80121250[0] = D_801234F4; + for(i = 0; i < 2; i++) { + D_80121250[i + 2] = arg0[i + 8]; + D_80121250[i + 4] = arg0[i + 10]; + D_80121250[i + 6] = arg0[i + 12]; + D_80121250[i + 8] = arg0[i + 14]; + D_80121250[i + 10] = arg0[i + 18]; + D_80121250[i + 12] = arg0[i + 20]; + } + D_80121250[14] = arg0[22]; + D_80121250[15] = arg0[23]; + D_801234FC = 1; + } +} + +s32 func_8006DA0C(void) { + return D_801234EC; +} + +/* Unused? */ +void func_8006DA1C(s32 arg0) { + D_801234EC = arg0; +} + +#if 1 +GLOBAL_ASM("asm/non_matchings/unknown_066AA0/func_8006DA28.s") +#else + +// For some reason this function is storing arg0 in s0. + +void func_8006DB3C(s32 arg0, s32 arg1, s32 arg2, s32 arg3, s32 arg4); +void func_800813C0(s32); +void func_80004A60(s32, s32); +void MenuInit(s32); + +void func_8006DA28(s32 arg0, s32 arg1, s32 arg2) { + func_8006ECFC(0); + D_801234EC = 1; + D_801234F0 = 1; + func_80004A60(0, 0x7FFF); + func_80004A60(1, 0x7FFF); + func_80004A60(2, 0x7FFF); + func_80065EA0(); + + if (D_80123514 == 0) { + D_80123514 = 0; // Someone at rare: "I know I just checked if this was zero, but I need to be sure!" + if (arg1 < 0) { + D_80123514 = 1; + } else { + func_8006DB3C(arg1, -1, 0, 2, arg2); + } + } + if (arg0 == 0 || arg0 == 1 || arg0 == 2) { + func_800813C0(arg0); + } + MenuInit(arg0); + D_80123504 = 0; +} +#endif + +void func_8006DB14(s32 arg0) { + D_80123518 = arg0; +} + +void func_8006DB20(s32 arg0) { + D_8012351C = arg0; +} + +s32 func_8006DB2C(void) { + return D_80123518; +} + +void func_8006DB3C(s32 arg0, s32 arg1, s32 arg2, s32 arg3, s32 arg4) { + func_800710B0(0); + func_80065EA0(); + func_800C3048(); + func_8006B250(arg0, arg1, arg2, arg3, arg4); + func_8009ECF0(func_80066210()); + func_800AE728(4, 4, 0x6E, 0x30, 0x20, 0); + func_8001BF20(); + osSetTime(0); + func_800710B0(2); +} + +void func_8006DBE4(void) { + if (D_80123514 == 0) { + D_80123514 = 1; + func_800710B0(0); + func_8006BEFC(); + func_800C01D8(&D_800DD3F4); + func_800AE270(); + func_800A003C(); + func_800C30CC(); + func_800710B0(2); + } + D_80123514 = 0; +} + +void func_8006DC58(s32 arg0) { + if (func_800C73E0() == 0) { + func_80010994(arg0); + particlePtrList_flush(); + func_8001BF20(); + D_80024D54(&D_801211F8, &D_80121208, &D_80121218, &D_80121228, arg0); + func_800C3440(arg0); + func_80078054(&D_801211F8); + func_80077050(&D_801211F8); + func_80077268(&D_801211F8); + } +} + +// Has a jump table +GLOBAL_ASM("asm/non_matchings/unknown_066AA0/func_8006DCF8.s") + +void func_8006E2E8(s32 arg0, s32 arg1, s32 arg2) { + if (D_80123514 == 0) { + func_8006DBE4(); + if (func_800C73E0() == 0) { + D_801211F8 = D_801211F0[D_801234E8]; + fast3d_cmd(D_801211F8++, 0xE9000000, 0x00000000) + fast3d_cmd(D_801211F8++, 0xB8000000, 0x00000000) + } + } + if (arg0 != -1) { + func_8006DB3C(arg0, arg1, 0, 2, arg2); + D_80123514 = (u8)0; + return; + } + D_80123514 = (u8)1; +} + +GLOBAL_ASM("asm/non_matchings/unknown_066AA0/func_8006E3BC.s") + +void func_8006E5BC(void) { + s32 i, j; + gSettingsPtr->playerCount = func_8009C3C8(); + for (i = 0; i < 8; i++) { + gSettingsPtr->racers[i].best_times = 0; + gSettingsPtr->racers[i].character = func_8009C228(i); + if (gSettingsPtr->playerCount >= 2) { + gSettingsPtr->racers[i].starting_position = i; + } else if (is_in_two_player_adventure()) { + gSettingsPtr->racers[i].starting_position = 5 - i; + } else { + gSettingsPtr->racers[i].starting_position = 7 - i; + } + gSettingsPtr->racers[i].unk7 = 0; + for(j = 0; j < 4; j++) { + gSettingsPtr->racers[i].placements[j] = 0; + } + gSettingsPtr->racers[i].course_time = 0; + for(j = 0; j < 3; j++) { + gSettingsPtr->racers[i].lap_times[j] = 0; + } + } + gSettingsPtr->timeTrialRacer = 0; + gSettingsPtr->unk115[0] = 0; + gSettingsPtr->unk115[1] = 0; + gSettingsPtr->display_times = 0; + gSettingsPtr->worldId = 0; + gSettingsPtr->courseId = 0; +} + +GLOBAL_ASM("asm/non_matchings/unknown_066AA0/func_8006E770.s") + +void func_8006E994(Settings* settings) { + s32 i; + s32 sp20; + s32 sp1C; + + func_8006B224(&sp1C, &sp20); + settings->newGame = 1; + + for (i = 0; i < sp20; i++) { + settings->balloonsPtr[i] = 0; + } + for(i = 0; i < sp1C; i++) { + settings->courseFlagsPtr[i] = 0; + } + + settings->keys = 0; + settings->unkA = 0; + settings->bosses = 0; + settings->trophies = 0; + settings->cutsceneFlags = 0; + settings->tajFlags = 0; + settings->ttAmulet = 0; + settings->wizpigAmulet = 0; +} + +// Unused? +void func_8006EA58(void) { + func_8006E770(gSettingsPtr, 3); + func_8006E994(gSettingsPtr); +} + +Settings* get_settings(void) { + return gSettingsPtr; +} + +s8 func_8006EAA0(void) { + return gIsPaused; +} + +s8 func_8006EAB0(void) { + return D_80123516; +} + +s32 func_8006EAC0(void) { + if (D_80123560 == 0) { + D_80123560 = (s32) ((osRecvMesg(&D_80123548, NULL, 0) + 1) != 0); + } + return D_80123560; +} + +s32 func_8006EB14(void) { + return D_801234F4; +} + +/* Unused? */ +void func_8006EB24(void) { + D_800DD37C |= 0x01; +} + +/* Unused? */ +void func_8006EB40(void) { + D_800DD37C |= 0x02; +} + +void func_8006EB5C(void) { + D_800DD37C |= 0x03; +} + +void func_8006EB78(s32 arg0) { + D_800DD37C &= -0x301; + D_800DD37C |= (0x04 | ((arg0 & 3) << 8)); +} + +void func_8006EBA8(void) { + D_800DD37C |= 0x08; +} + +void func_8006EBC4(void) { + D_800DD37C |= 0x10; +} + +void func_8006EBE0(void) { + D_800DD37C |= 0x20; +} + +void func_8006EBFC(void) { + D_800DD37C |= 0x30; +} + +void func_8006EC18(s32 arg0) { + D_800DD37C &= -0xC01; + D_800DD37C |= (0x40 | ((arg0 & 3) << 0xA)); +} + +void func_8006EC48(s32 arg0) { + if (D_801234EC == 0 && !is_in_tracks_mode()) { + D_800DD37C &= -0xC01; + D_800DD37C |= (0x40 | ((arg0 & 3) << 0xA)); + } +} + +void func_8006ECAC(s32 arg0) { + D_800DD37C = ((arg0 & 0x03) << 10) | 0x80; +} + +/* Unused? */ +void func_8006ECC4(void) { + D_800DD37C |= 0x100; +} + +void func_8006ECE0(void) { + D_800DD37C |= 0x200; +} + +GLOBAL_ASM("asm/non_matchings/unknown_066AA0/func_8006ECFC.s") + +#if 1 +GLOBAL_ASM("asm/non_matchings/unknown_066AA0/func_8006EFB8.s") +#else +s32 func_8006EFB8(void) { + if (D_A4000000 != -1) { // regalloc issue with D_A4000000 + return 0; + } + return 1; +} +#endif + +#if 1 +GLOBAL_ASM("asm/non_matchings/unknown_066AA0/func_8006EFDC.s") +#else + +/* Size: 0x40 bytes, I think this might be a 4x4 matrix. */ +typedef struct unk80121200 { + u8 pad0[0x40]; +} unk80121200; + +/* Size: 10 bytes */ +typedef struct unk80121210 { + u8 pad0[10]; +} unk80121210; + +/* Size: 16 bytes */ +typedef struct unk80121220 { + u8 pad0[16]; +} unk80121220; + +extern s32 D_8012350C; + +extern s32 D_800DD3BC; +extern s32 D_800DD3CC; +extern s32 D_800DD3DC; +extern s32 D_800DD3EC; + +extern s32 D_80123528; +extern s32 D_8012352C; +extern s32 D_80123530; +extern s32 D_80123534; + +extern unk80121200 *D_80121200[3]; +extern unk80121210 *D_80121210[3]; +extern unk80121220 *D_80121220[3]; + +void *func_80070C9C(s32, s32); // Allocates memory? + +void func_8006EFDC(void) { + s32 size; + s8* current; + + D_8012350C = 3; + + size = (D_800DD3EC * sizeof(unk80121220)) + + (D_800DD3BC * sizeof(Gfx)) + + (D_800DD3DC * sizeof(unk80121200)) + + (D_800DD3CC * sizeof(unk80121210)); + + current = (s8*)func_80070C9C(size, 0xFF0000FF); + D_801211F0[0] = (Gfx*)current; + current += (D_800DD3BC * sizeof(Gfx)); + D_80121200[0] = (unk80121200*)current; + current += (D_800DD3DC * sizeof(unk80121200)); + D_80121210[0] = (unk80121210*)current; + current += (D_800DD3CC * sizeof(unk80121210)); + D_80121220[0] = (unk80121220*)current; + + current = (s8*)func_80070C9C(size, 0xFFFF00FF); + D_801211F0[1] = (Gfx*)current; + current += (D_800DD3BC * sizeof(Gfx)); + D_80121200[1] = (unk80121200*)current; + current += (D_800DD3DC * sizeof(unk80121200)); + D_80121210[1] = (unk80121210*)current; + current += (D_800DD3CC * sizeof(unk80121210)); + D_80121220[1] = (unk80121220*)current; + + D_80123528 = D_800DD3BC; + D_8012352C = D_800DD3DC; + D_80123530 = D_800DD3EC; + D_80123534 = D_800DD3CC; +} +#endif + +void func_8006F140(s32 arg0) { + if (D_800DD394 == 0) { + D_800DD394 = 0x28; + D_80123524 = 0; + D_80123526 = 0; + if (arg0 == 1) { + func_800C01D8(&D_800DD41C); + } + if (arg0 == 3) { + D_800DD394 = 0x11A; + func_800C01D8(&D_800DD424); + } + if (arg0 == 4) { + D_800DD394 = 0x168; + func_800C01D8(&D_800DD424); + } + if (arg0 == 0) { + D_800DD394 = 2; + } + } +} + +// Unused? +void func_8006F20C(void) { + if (D_800DD394 == 0) { + func_800C01D8(&D_800DD41C); + D_800DD394 = 0x28; + D_80123524 = 1; + } +} + +void func_8006F254(void) { + if (D_800DD394 == 0) { + func_800C01D8(&D_800DD41C); + D_800DD394 = 0x28; + D_80123524 = 2; + } +} + +void func_8006F29C(void) { + if (D_800DD394 == 0) { + if ((gSettingsPtr->trophies & 0xFF) == 0xFF && !(gSettingsPtr->cutsceneFlags & 1) && gSettingsPtr->bosses & 1) { + gSettingsPtr->cutsceneFlags |= 1; + func_800C01D8(&D_800DD41C); + D_800DD394 = 0x28; + D_80123525 = 0x2D; + D_80123524 = 3; + } + } +} + +void func_8006F338(s32 arg0) { + if (D_800DD394 == 0) { + D_80123525 = arg0; + func_800C01D8(&D_800DD41C); + D_800DD394 = 0x28; + D_80123524 = 4; + } +} + +void func_8006F388(u8 arg0) { + D_800DD398 = arg0; +} + +void func_8006F398(void) { + s32 i; + u8 temp; + u8 *first_racer_data; + u8 *second_racer_data; + + func_8006A50C(); + func_8000E194(); + + first_racer_data = (u8*)(gSettingsPtr->racers); + second_racer_data = (u8*)(gSettingsPtr->racers + 1); + + for(i = 0; i < sizeof(Racer); i++) { + temp = first_racer_data[i]; + first_racer_data[i] = second_racer_data[i]; + second_racer_data[i] = temp; + } +} + +void func_8006F42C(void) { + D_800DD3F0 = 2; +} + +void func_8006F43C(void) { + s32 phi_s1 = 0; + s32 phi_s0 = 0; + while(phi_s0 != 4) { + phi_s1 |= func_8006A528(phi_s0); + phi_s0++; + } + if (phi_s1 & 0x1000) { + D_800DFD94 = 1; + } + D_80123520++; + if (D_80123520 >= 8) { + func_8006DA28(0x1A, 0x27, 2); + } +} + +s32 func_8006F4C8(void) { + if (D_800DD384 == -1) { + return 1; + } else { + return 0; + } +} + +#if 1 +GLOBAL_ASM("asm/non_matchings/unknown_066AA0/func_8006F4EC.s") +#else +s32 func_8006F4EC(void) { + if (SP_IMEM != 0x17D7) { // Same regalloc issue as func_8006EFB8 + return 0; + } + return 1; +} +#endif