Misc matches (#704)

* couple of matches

* match func_800C4FE4

* match func_800C284C

* match func_800C2A2C

* match func_800C3724

* match func_800C4398

* format

* format2

* remove asms
This commit is contained in:
inspectredc
2025-04-30 17:36:02 +01:00
committed by GitHub
parent 1b10da7c24
commit 5dbcf42e95
10 changed files with 427 additions and 2418 deletions
+386 -351
View File
@@ -624,242 +624,273 @@ void func_800C2474(void) {
D_8018EFD8[var_v0].next = 0xFF;
}
#ifdef NON_MATCHING
// https://decomp.me/scratch/B9kUf
// No idea what's up with this function. `arg1_copy` is a huge improvement but feels very silly
// Presumably there's some macro being used to do all the or'ing (creating soundbits), that might
// matter for match purposes
void func_800C284C(u8 arg0, u8 arg1, u8 arg2, u16 arg3) {
u8 var_v1;
u8* arg1_copy = &arg1;
UNUSED s32 pad;
if ((D_800EA1EC == 0) || (arg0 == 2)) {
if (1) {}
func_800CBBB8(0x82000000 | (arg0 << 0x10) | (*arg1_copy << 8), arg3);
D_801930D0[arg0].unk_248 = *arg1_copy | (arg2 << 8);
if (D_801930D0[arg0].unk_000 != 1.0f) {
func_800CBB88(0x41000000 | (arg0 << 0x10), D_801930D0[arg0].unk_000);
}
D_801930D0[arg0].unk_028 = 0;
D_801930D0[arg0].unk_018 = 0;
D_801930D0[arg0].unk_014 = 0;
for (var_v1 = 0; var_v1 < 16; var_v1++) {
D_801930D0[arg0].unk_044[var_v1].unk_00 = 1.0f;
D_801930D0[arg0].unk_044[var_v1].unk_0C = 0;
D_801930D0[arg0].unk_044[var_v1].unk_10 = 1.0f;
D_801930D0[arg0].unk_044[var_v1].unk_1C = 0;
}
D_801930D0[arg0].unk_244 = 0;
D_801930D0[arg0].unk_246 = 0;
if ((D_800EA1EC != 0) && (arg0 != 2)) {
return;
}
func_800CBBB8(0x82000000 | (((u32) arg0 & 0xFF) << 0x10) | (((u32) arg1 & 0xFF) << 8), arg3);
D_801930D0[arg0].unk_248 = arg1 | (arg2 << 8);
if (D_801930D0[arg0].unk_000 != 1.0f) {
func_800CBB88(0x41000000 | (((u32) arg0 & 0xFF) << 0x10), D_801930D0[arg0].unk_000);
}
D_801930D0[arg0].unk_028 = 0;
D_801930D0[arg0].unk_018 = 0;
D_801930D0[arg0].unk_014 = 0;
for (var_v1 = 0; var_v1 < 16; var_v1++) {
D_801930D0[arg0].unk_044[var_v1].unk_00 = 1.0f;
D_801930D0[arg0].unk_044[var_v1].unk_0C = 0;
D_801930D0[arg0].unk_044[var_v1].unk_10 = 1.0f;
D_801930D0[arg0].unk_044[var_v1].unk_1C = 0;
}
D_801930D0[arg0].unk_244 = 0;
D_801930D0[arg0].unk_246 = 0;
}
#else
GLOBAL_ASM("asm/non_matchings/audio/external/func_800C284C.s")
#endif
void func_800C29B4(u8 arg0, u16 arg1) {
func_800CBBB8(((arg0 & 0xFF) << 0x10) | 0x83000000, arg1);
D_801930D0[arg0].unk_248 = 0xFFFF;
}
#ifdef NON_MATCHING
/**
* https://decomp.me/scratch/TS7EW
* The last big thing is the for loop in `case 10`. For some reason the 0 used for loop initialization is saved to 2
*variables? I speculate that this is functionally equivalent although its hard to tell with all the register allocation
*differences `arg0` is almost certainly `soundbits`, so all the `why*` variables are probably the results of macros
*pulling out the different parts of the full sound specification.
**/
void func_800C2A2C(u32 arg0) {
u16 var_a3;
u16 var_a0;
s32 var_a2;
u8 var_a1;
u8 var_t0;
u8 var_v1;
struct_D_801930D0_entry* temp_v0_3;
u8 test;
u8 why;
u16 why2;
u8 why3;
u8 why4;
u8 why5;
u8 temp_a1;
void func_800C2A2C(u32 cmd) {
f32 freqScaleTarget;
u16 channelMaskDisable;
u16 val;
u16 fadeTimer;
u8 priority;
u8 ioPort;
u8 i;
u8 duration;
u8 channelIndex;
u8 found;
u8 seqId;
u8 subArgs;
u8 op;
u8 seqPlayerIndex;
test = arg0 & 0xFF;
why = (arg0 & 0xFF00) >> 8;
why2 = (arg0 & 0xFF0000) >> 0xD;
why3 = (arg0 & 0xFF0000) >> 0xF;
why4 = (arg0 & 0xFF0000) >> 0x10;
why5 = (arg0 & 0xF00) >> 8;
temp_a1 = (arg0 & 0x0F000000) >> 0x18;
switch ((arg0 >> 0x1C) & 0xFF) {
op = cmd >> 28;
seqPlayerIndex = (cmd & 0xF000000) >> 24;
switch (op) {
case 0:
func_800C284C(temp_a1, arg0 & 0xFF, why, why2);
seqId = cmd & 0xFF;
subArgs = (cmd & 0xFF00) >> 8;
fadeTimer = (cmd & 0xFF0000) >> 13;
func_800C284C(seqPlayerIndex, seqId, subArgs, fadeTimer);
break;
case 1:
func_800C29B4(temp_a1, why2);
fadeTimer = (cmd & 0xFF0000) >> 13;
func_800C29B4(seqPlayerIndex, fadeTimer);
break;
case 2:
for (var_v1 = 0; var_v1 < D_80192CC6[temp_a1]; var_v1++) {
if (test == D_80192CA8[temp_a1][var_v1].thing0) {
if (var_v1 == 0) {
func_800C284C(temp_a1, test, why, why2);
seqId = cmd & 0xFF;
subArgs = (cmd & 0xFF00) >> 8;
fadeTimer = (cmd & 0xFF0000) >> 13;
priority = subArgs;
for (i = 0; i < D_80192CC6[seqPlayerIndex]; i++) {
if (D_80192CA8[seqPlayerIndex][i].thing0 == seqId) {
if (i == 0) {
func_800C284C(seqPlayerIndex, seqId, subArgs, fadeTimer);
}
return;
}
}
var_t0 = D_80192CC6[temp_a1];
for (var_v1 = 0; var_v1 < D_80192CC6[temp_a1]; var_v1++) {
if (why >= D_80192CA8[temp_a1][var_v1].thing1) {
var_t0 = var_v1;
var_v1 = D_80192CC6[temp_a1];
found = D_80192CC6[seqPlayerIndex];
for (i = 0; i < D_80192CC6[seqPlayerIndex]; i++) {
if (priority >= D_80192CA8[seqPlayerIndex][i].thing1) {
found = i;
i = D_80192CC6[seqPlayerIndex];
}
}
if ((var_t0 != D_80192CC6[temp_a1]) || (var_t0 == 0)) {
if (D_80192CC6[temp_a1] < 5) {
D_80192CC6[temp_a1]++;
if ((found != D_80192CC6[seqPlayerIndex]) || (found == 0)) {
if (D_80192CC6[seqPlayerIndex] < 5) {
D_80192CC6[seqPlayerIndex]++;
}
for (var_v1 = D_80192CC6[temp_a1] - 1; var_v1 != var_t0; var_v1--) {
D_80192CA8[temp_a1][var_v1].thing1 = D_80192CA8[temp_a1][var_v1 - 1].thing1;
D_80192CA8[temp_a1][var_v1].thing0 = D_80192CA8[temp_a1][var_v1 - 1].thing0;
for (i = D_80192CC6[seqPlayerIndex] - 1; i != found; i--) {
D_80192CA8[seqPlayerIndex][i].thing1 = D_80192CA8[seqPlayerIndex][i - 1].thing1;
D_80192CA8[seqPlayerIndex][i].thing0 = D_80192CA8[seqPlayerIndex][i - 1].thing0;
}
D_80192CA8[temp_a1][var_t0].thing1 = why;
D_80192CA8[temp_a1][var_t0].thing0 = test;
D_80192CA8[seqPlayerIndex][found].thing1 = subArgs;
D_80192CA8[seqPlayerIndex][found].thing0 = seqId;
}
if (var_t0 == 0) {
func_800C284C(temp_a1, test, why, why2);
if (found == 0) {
func_800C284C(seqPlayerIndex, seqId, subArgs, fadeTimer);
}
break;
case 3:
var_t0 = D_80192CC6[temp_a1];
for (var_v1 = 0; var_v1 < D_80192CC6[temp_a1]; var_v1++) {
if (test == D_80192CA8[temp_a1][var_v1].thing0) {
var_t0 = var_v1;
var_v1 = D_80192CC6[temp_a1];
fadeTimer = (cmd & 0xFF0000) >> 13;
found = D_80192CC6[seqPlayerIndex];
for (i = 0; i < D_80192CC6[seqPlayerIndex]; i++) {
seqId = cmd & 0xFF;
if (D_80192CA8[seqPlayerIndex][i].thing0 == seqId) {
found = i;
i = D_80192CC6[seqPlayerIndex];
}
}
if (var_t0 != D_80192CC6[temp_a1]) {
for (var_v1 = var_t0; var_v1 < D_80192CC6[temp_a1] - 1; var_v1++) {
D_80192CA8[temp_a1][var_v1].thing1 = D_80192CA8[temp_a1][var_v1 + 1].thing1;
D_80192CA8[temp_a1][var_v1].thing0 = D_80192CA8[temp_a1][var_v1 + 1].thing0;
if (found != D_80192CC6[seqPlayerIndex]) {
for (i = found; i < (D_80192CC6[seqPlayerIndex] - 1); i++) {
D_80192CA8[seqPlayerIndex][i].thing1 = D_80192CA8[seqPlayerIndex][i + 1].thing1;
D_80192CA8[seqPlayerIndex][i].thing0 = D_80192CA8[seqPlayerIndex][i + 1].thing0;
}
D_80192CC6[temp_a1]--;
D_80192CC6[seqPlayerIndex]--;
}
if (var_t0 == 0) {
func_800C29B4(temp_a1, why2);
if (D_80192CC6[temp_a1] != 0) {
func_800C284C(temp_a1, D_80192CA8[temp_a1][0].thing0, D_80192CA8[temp_a1][0].thing1, why2);
if (found == 0) {
func_800C29B4(seqPlayerIndex, fadeTimer);
if (D_80192CC6[seqPlayerIndex] != 0) {
func_800C284C(seqPlayerIndex, D_80192CA8[seqPlayerIndex][0].thing0,
D_80192CA8[seqPlayerIndex][0].thing1, fadeTimer);
}
}
break;
case 4:
var_a1 = why3;
if (var_a1 == 0) {
var_a1++;
duration = (cmd & 0xFF0000) >> 15;
val = cmd & 0xFF;
if (duration == 0) {
duration++;
}
temp_v0_3 = &D_801930D0[temp_a1 & 0xFF];
temp_v0_3->unk_004 = (arg0 & 0xFF) / 127.0f;
if (temp_v0_3->unk_000 != temp_v0_3->unk_004) {
temp_v0_3->unk_008 = (temp_v0_3->unk_000 - temp_v0_3->unk_004) / var_a1;
temp_v0_3->unk_00C = var_a1;
D_801930D0[seqPlayerIndex].unk_004 = val / 127.0f;
if (D_801930D0[seqPlayerIndex].unk_000 != D_801930D0[seqPlayerIndex].unk_004) {
D_801930D0[seqPlayerIndex].unk_008 =
(D_801930D0[seqPlayerIndex].unk_000 - D_801930D0[seqPlayerIndex].unk_004) / duration;
D_801930D0[seqPlayerIndex].unk_00C = duration;
}
break;
case 5:
var_a1 = why3;
if (var_a1 == 0) {
var_a1++;
duration = (cmd & 0xFF0000) >> 15;
val = cmd & 0xFFFF;
if (duration == 0) {
duration++;
}
freqScaleTarget = (f32) val / 1000.0f;
for (i = 0; i < 0x10; i++) {
D_801930D0[seqPlayerIndex].unk_044[i].unk_14 = freqScaleTarget;
D_801930D0[seqPlayerIndex].unk_044[i].unk_1C = duration;
D_801930D0[seqPlayerIndex].unk_044[i].unk_18 =
(D_801930D0[seqPlayerIndex].unk_044[i].unk_10 - freqScaleTarget) / duration;
}
temp_v0_3 = &D_801930D0[var_a1 & 0xFF];
for (var_v1 = 0; var_v1 < 0x10; var_v1++) {
temp_v0_3->unk_044[var_v1].unk_14 = ((arg0 & 0xFFFF) / 1000.0f);
temp_v0_3->unk_044[var_v1].unk_18 =
(temp_v0_3->unk_044[var_v1].unk_10 - temp_v0_3->unk_044[var_v1].unk_14) / var_a1;
temp_v0_3->unk_044[var_v1].unk_1C = var_a1;
}
D_801930D0[var_a1].unk_244 = 0xFFFF;
D_801930D0[seqPlayerIndex].unk_244 = 0xFFFF;
break;
case 6:
var_a1 = why3;
if (var_a1 == 0) {
var_a1++;
}
var_v1 = ((arg0 & 0xF00) >> 8) & 0xFF;
duration = (cmd & 0xFF0000) >> 15;
channelIndex = (cmd & 0xF00) >> 8;
val = cmd & 0xFF;
D_801930D0[var_a1 & 0xFF].unk_044[var_v1].unk_04 = test / 127.0f;
if (D_801930D0[var_a1 & 0xFF].unk_044[var_v1].unk_00 != D_801930D0[var_a1 & 0xFF].unk_044[var_v1].unk_04) {
D_801930D0[var_a1 & 0xFF].unk_044[var_v1].unk_08 = (D_801930D0[var_a1 & 0xFF].unk_044[var_v1].unk_00 -
D_801930D0[var_a1 & 0xFF].unk_044[var_v1].unk_04) /
var_a1;
D_801930D0[var_a1 & 0xFF].unk_044[var_v1].unk_0C = var_a1;
D_801930D0[var_a1 & 0xFF].unk_244 |= 1 << var_v1;
if (duration == 0) {
duration++;
}
D_801930D0[seqPlayerIndex].unk_044[channelIndex].unk_04 = val / 127.0f;
if (D_801930D0[seqPlayerIndex].unk_044[channelIndex].unk_00 !=
D_801930D0[seqPlayerIndex].unk_044[channelIndex].unk_04) {
D_801930D0[seqPlayerIndex].unk_044[channelIndex].unk_08 =
(D_801930D0[seqPlayerIndex].unk_044[channelIndex].unk_00 -
D_801930D0[seqPlayerIndex].unk_044[channelIndex].unk_04) /
duration;
D_801930D0[seqPlayerIndex].unk_044[channelIndex].unk_0C = duration;
D_801930D0[seqPlayerIndex].unk_244 |= 1 << channelIndex;
}
break;
case 7:
func_800CBBE8(0x46000000 | (temp_a1 & 0xFF) << 0x10 | (why4 & 0xFF) << 8, (u64) arg0);
ioPort = (cmd & 0xFF0000) >> 16;
val = cmd & 0xFF;
func_800CBBE8((0x46000000 | ((seqPlayerIndex & 0xFF) << 0x10)) | ((ioPort & 0xFF) << 8), val);
break;
case 8:
if (!(D_801930D0[temp_a1].unk_24A & (1 << why5))) {
func_800CBBE8(0x06000000 | ((temp_a1 & 0xFF) << 0x10) | (why5 & 0xFF) << 8 | (why4 & 0xFF), (u64) arg0);
channelIndex = (cmd & 0xF00) >> 8;
ioPort = (cmd & 0xFF0000) >> 16;
val = cmd & 0xFF;
if (!(D_801930D0[seqPlayerIndex].unk_24A & (1 << channelIndex))) {
func_800CBBE8(((0x06000000 | ((seqPlayerIndex & 0xFF) << 0x10)) | (((u32) channelIndex & 0xFF) << 8)) |
(ioPort & 0xFF),
val);
}
break;
case 9:
D_801930D0[temp_a1].unk_24A = arg0;
D_801930D0[seqPlayerIndex].unk_24A = cmd & 0xFFFF;
break;
case 10:
var_a0 = 1;
var_a3 = arg0 & 0xFFFF;
for (var_v1 = 0; var_v1 < 0x10; var_v1++) {
if (var_a3 & var_a0) {
var_a2 = 1;
} else {
var_a2 = 0;
}
func_800CBBE8(((temp_a1 & 0xFF) << 0x10) | 0x08000000 | ((var_v1 & 0xFF) << 8), var_a2);
var_a0 *= 2;
val = 1;
channelMaskDisable = cmd & 0xFFFF;
for (i = 0; i < 0x10; i++) {
func_800CBBE8(0x08000000 | ((seqPlayerIndex & 0xFF) << 0x10) | (((u32) i & 0xFF) << 8),
(channelMaskDisable & val) ? 1 : 0);
val <<= 1;
}
break;
case 11:
D_801930D0[temp_a1].unk_014 = arg0;
D_801930D0[seqPlayerIndex].unk_014 = cmd;
break;
case 12:
temp_v0_3 = &D_801930D0[temp_a1 & 0xFF];
if ((((arg0 & 0xF00000) >> 0x14) & 0xFF) != 0xF) {
var_t0 = temp_v0_3->unk_041++;
if (var_t0 < 5) {
temp_v0_3->unk_02C[var_t0] = arg0;
temp_v0_3->unk_040 = 2;
subArgs = (cmd & 0xF00000) >> 20;
if (subArgs != 0xF) {
found = D_801930D0[seqPlayerIndex].unk_041++;
if (found < 5) {
D_801930D0[seqPlayerIndex].unk_02C[found] = cmd;
D_801930D0[seqPlayerIndex].unk_040 = 2;
}
} else {
temp_v0_3->unk_041 = 0;
D_801930D0[seqPlayerIndex].unk_041 = 0;
}
break;
case 14:
switch (why5) { /* switch 1; irregular */
case 0: /* switch 1 */
func_800CBBB8(0xF0000000U, D_800EA1F0[arg0 & 0xFF]);
subArgs = (cmd & 0xF00) >> 8;
val = cmd & 0xFF;
switch (subArgs) {
case 0:
func_800CBBB8(0xF0000000, D_800EA1F0[val]);
break;
case 1: /* switch 1 */
D_800EA1EC = arg0 & 1;
case 1:
D_800EA1EC = val & 1;
break;
}
break;
case 15:
D_800EA1C0 = (arg0 & 0xFF00) >> 8;
audio_reset_session_eu((void*) test);
D_800EA1F4[0] = test;
func_800CBBE8(0x46020000U, why);
seqId = cmd & 0xFF;
subArgs = (cmd & 0xFF00) >> 8;
D_800EA1C0 = subArgs;
audio_reset_session_eu((void*) seqId);
D_800EA1F4[0] = seqId;
func_800CBBE8(0x46020000, subArgs);
func_800C5C40();
break;
default:
break;
}
}
#else
GLOBAL_ASM("asm/non_matchings/audio/external/func_800C2A2C.s")
#endif
void func_800C3448(u32 arg0) {
D_80192CD0[D_800EA1E4] = arg0;
@@ -933,183 +964,198 @@ void func_800C36C4(u8 arg0, u8 arg1, u8 arg2, u8 arg3) {
D_801930D0[arg0].unk_012 = 1;
}
#ifdef NON_MATCHING
// generated by m2c commit 1c7b040b356d06b5171add65d8ee527a500b156e on Apr-01-2024
void func_800C3724(void) {
u8 var_s5;
f32 var_f0;
u16 temp_a3_2;
s32 temp_lo;
s32 temp_s1;
s32 temp_t9_2;
u16 var_a2;
u8 var_s2;
u8 var_t0;
u32 temp_t5_3;
u8 temp_a1_3;
s32 var_a1;
struct_D_801930D0_entry* temp_s0;
struct_D_801930D0_entry* temp_s2;
struct_D_801930D0_entry* temp_s4_2;
for (var_s5 = 0; var_s5 < 3; var_s5++) {
if (D_801930D0[var_s5].unk_012 != 0) {
var_f0 = 1.0f;
for (var_s2 = 0; var_s2 < 3; var_s2++) {
temp_s4_2 = &D_801930D0[var_s5];
var_f0 *= temp_s4_2->unk_00E[var_s2] / 127.0f;
}
func_800C3448((D_801930D0[var_s5].unk_011 << 0x10) | 0x40000000 | ((var_s5 & 0xFF) << 0x18) |
((u32) (var_f0 * 127.0f) & 0xFF));
D_801930D0[var_s5].unk_012 = 0;
}
if (D_801930D0[var_s5].unk_00C != 0) {
D_801930D0[var_s5].unk_00C--;
if (D_801930D0[var_s5].unk_00C) {
D_801930D0[var_s5].unk_000 -= D_801930D0[var_s5].unk_008;
} else {
D_801930D0[var_s5].unk_000 = D_801930D0[var_s5].unk_004;
}
func_800CBB88(((var_s5 & 0xFF) << 0x10) | 0x41000000, D_801930D0[var_s5].unk_000);
}
if (D_801930D0[var_s5].unk_014 != 0) {
var_t0 = (u32) (D_801930D0[var_s5].unk_014 & 0xFF0000) >> 0xF;
var_a1 = D_801930D0[var_s5].unk_014 & 0xFFF;
var_a2 = var_a1;
if (var_t0 == 0) {
var_t0++;
}
if (gSequencePlayers[var_s5 & 0xFF].enabled != 0) {
temp_lo = (s32) gSequencePlayers[var_s5 & 0xFF].tempo / TATUMS_PER_BEAT;
temp_a3_2 = temp_lo;
temp_t9_2 = ((D_801930D0[var_s5].unk_014 & 0xF000) >> 0xC) & 0xFF;
switch (temp_t9_2) { /* switch 1; irregular */
case 1:
var_a2 += temp_a3_2;
break;
case 2: /* switch 1 */
if (var_a1 < temp_a3_2) {
var_a2 = (temp_a3_2 - var_a1);
}
break;
case 3: /* switch 1 */
var_a2 = (u32) (temp_a3_2 * ((f32) (var_a1 & 0xFFFF) / 100.0f));
break;
case 4: /* switch 1 */
if (D_801930D0[var_s5].unk_018 != 0) {
var_a2 = D_801930D0[var_s5].unk_018;
} else {
var_a2 = temp_a3_2;
}
break;
}
if (var_a2 >= 0x12D) {
var_a2 = 0x12C;
}
if (D_801930D0[var_s5].unk_018 == 0) {
D_801930D0[var_s5].unk_018 = temp_a3_2;
}
D_801930D0[var_s5].unk_020 = var_a2;
D_801930D0[var_s5].unk_01C = temp_lo;
D_801930D0[var_s5].unk_024 = (D_801930D0[var_s5].unk_01C - D_801930D0[var_s5].unk_020) / var_t0;
D_801930D0[var_s5].unk_028 = (u16) var_t0;
}
D_801930D0[var_s5].unk_014 = 0;
}
if (D_801930D0[var_s5].unk_028 != 0) {
D_801930D0[var_s5].unk_028--;
if (D_801930D0[var_s5].unk_028) {
D_801930D0[var_s5].unk_01C -= D_801930D0[var_s5].unk_024;
} else {
D_801930D0[var_s5].unk_01C = D_801930D0[var_s5].unk_020;
}
func_800CBBB8(((var_s5 & 0xFF) << 0x10) | 0x47000000, (u32) (s32) D_801930D0[var_s5].unk_01C);
}
if (D_801930D0[var_s5].unk_246 != 0) {
for (var_s2 = 0; var_s2 < 0x10; var_s2++) {
temp_s4_2 = &D_801930D0[var_s5];
if (temp_s4_2->unk_044[var_s2].unk_0C != 0) {
temp_s4_2->unk_044[var_s2].unk_0C--;
if (temp_s4_2->unk_044[var_s2].unk_0C) {
temp_s4_2->unk_044[var_s2].unk_00 -= temp_s4_2->unk_044[var_s2].unk_08;
} else {
temp_s4_2->unk_044[var_s2].unk_00 = temp_s4_2->unk_044[var_s2].unk_04;
temp_s4_2->unk_246 ^= 1 << var_s2;
}
func_800CBB88(((var_s5 & 0xFF) << 0x10) | 0x01000000 | ((var_s2 & 0xFF) << 8),
temp_s4_2->unk_044[var_s2].unk_00);
}
}
}
if (D_801930D0[var_s5].unk_244 != 0) {
for (var_s2 = 0; var_s2 < 0x10; var_s2++) {
temp_s4_2 = &D_801930D0[var_s5];
if (temp_s4_2->unk_044[var_s2].unk_1C != 0) {
temp_s4_2->unk_044[var_s2].unk_1C--;
if (temp_s4_2->unk_044[var_s2].unk_1C) {
temp_s4_2->unk_044[var_s2].unk_10 -= temp_s4_2->unk_044[var_s2].unk_18;
} else {
temp_s4_2->unk_044[var_s2].unk_10 = temp_s4_2->unk_044[var_s2].unk_14;
temp_s4_2->unk_244 ^= 1 << var_s2;
}
func_800CBB88(((var_s5 & 0xFF) << 0x10) | 0x04000000 | ((var_s2 & 0xFF) << 8),
temp_s4_2->unk_044[var_s2].unk_10);
}
}
}
if (D_801930D0[var_s5].unk_041 != 0) {
if (D_801930D0[var_s5].unk_040 != 0) {
D_801930D0[var_s5].unk_040--;
} else {
if (gSequencePlayers[var_s5].enabled == 0) {
for (var_s2 = 0; var_s2 < D_801930D0[var_s5].unk_041; var_s2++) {
temp_s4_2 = &D_801930D0[var_s5];
var_a1 = temp_s4_2->unk_02C[var_s2] & 0xFF;
temp_t5_3 = ((u32) (temp_s4_2->unk_02C[var_s2] & 0xF00000) >> 0x14) & 0xFF;
temp_s1 = ((u32) (temp_s4_2->unk_02C[var_s2] & 0xF0000) >> 0x10) & 0xFF;
temp_a1_3 = ((u32) (temp_s4_2->unk_02C[var_s2] & 0xFF00) >> 8) & 0xFF;
switch (temp_t5_3) {
case 0:
D_801930D0[temp_s1].unk_012 = 1;
D_801930D0[temp_s1].unk_00E[1] = 0x7F;
break;
case 1:
func_800C3448(temp_s4_2->unk_248 | 0x30000000 | (var_s5 << 0x18));
break;
case 2:
func_800C3448(D_801930D0[temp_s1].unk_248 | (temp_s1 << 0x18) | 0x10000);
D_801930D0[temp_s1].unk_012 = 1;
D_801930D0[temp_s1].unk_00E[1] = 0x7F;
break;
case 3:
func_800C3448((temp_s1 << 0x18) | 0xB0003000 | (temp_a1_3 << 0x10) | var_a1);
break;
case 4:
func_800C3448((temp_s1 << 0x18) | 0xB0004000 | (var_a1 << 0x10));
break;
case 5:
func_800C3448((D_801930D0[temp_s1].unk_042 << 0x10) | (temp_s1 << 0x18) |
(temp_s4_2->unk_02C[var_s2] & 0xFFFF));
func_800C36C4(temp_s1 & 0xFF, 1U, 0x7FU, 0U);
D_801930D0[temp_s1].unk_042 = 0;
break;
case 6:
temp_s4_2->unk_042 = temp_a1_3;
break;
}
}
D_801930D0[var_s5].unk_041 = 0;
}
}
}
}
}
#else
#ifdef VERSION_EU
GLOBAL_ASM("asm/eu_nonmatchings/func_800C3724.s")
#else
GLOBAL_ASM("asm/non_matchings/audio/external/func_800C3724.s")
#endif
void func_800C3724(void) {
u8 seqPlayerIndex;
f32 volume;
u8 tempoOp;
u16 tempoTarget;
u8 channelIndex;
u8 j;
u32 tempoCmd;
u16 tempoPrev;
u8 tempoTimer;
u8 setupOp;
u8 targetSeqPlayerIndex;
u8 setupVal1;
u8 setupVal2;
u16 seqId;
for (seqPlayerIndex = 0; seqPlayerIndex < 3; seqPlayerIndex++) {
if (D_801930D0[seqPlayerIndex].unk_012) {
volume = 1.0f;
for (j = 0; j < 3; j++) {
volume *= D_801930D0[seqPlayerIndex].unk_00E[j] / 127.0f;
}
func_800C3448(0x40000000 | (((u8) seqPlayerIndex) << 0x18) |
(((u8) D_801930D0[seqPlayerIndex].unk_011) << 0x10) | ((u16) (u8) (volume * 127.0f)));
D_801930D0[seqPlayerIndex].unk_012 = 0;
}
if (D_801930D0[seqPlayerIndex].unk_00C != 0) {
D_801930D0[seqPlayerIndex].unk_00C--;
if (D_801930D0[seqPlayerIndex].unk_00C) {
D_801930D0[seqPlayerIndex].unk_000 -= D_801930D0[seqPlayerIndex].unk_008;
} else {
D_801930D0[seqPlayerIndex].unk_000 = D_801930D0[seqPlayerIndex].unk_004;
}
func_800CBB88(0x41000000 | (((u32) seqPlayerIndex & 0xFF) << 0x10), D_801930D0[seqPlayerIndex].unk_000);
}
if (D_801930D0[seqPlayerIndex].unk_014 != 0) {
tempoCmd = D_801930D0[seqPlayerIndex].unk_014;
tempoTimer = (tempoCmd & 0xFF0000) >> 0xF;
tempoTarget = tempoCmd & 0xFFF;
if (tempoTimer == 0) {
tempoTimer++;
}
if (gSequencePlayers[seqPlayerIndex].enabled != 0) {
tempoPrev = gSequencePlayers[seqPlayerIndex].tempo / 48;
tempoOp = (tempoCmd & 0xF000) >> 0xC;
switch (tempoOp) {
case 1:
tempoTarget += tempoPrev;
break;
case 2:
if (tempoTarget < tempoPrev) {
tempoTarget = tempoPrev - tempoTarget;
}
break;
case 3:
tempoTarget = tempoPrev * (tempoTarget / 100.0f);
break;
case 4:
tempoTarget =
(D_801930D0[seqPlayerIndex].unk_018 != 0) ? D_801930D0[seqPlayerIndex].unk_018 : tempoPrev;
break;
default:
break;
}
if (tempoTarget > 300) {
tempoTarget = 300;
}
if (D_801930D0[seqPlayerIndex].unk_018 == 0) {
D_801930D0[seqPlayerIndex].unk_018 = tempoPrev;
}
D_801930D0[seqPlayerIndex].unk_020 = tempoTarget;
D_801930D0[seqPlayerIndex].unk_01C = gSequencePlayers[seqPlayerIndex].tempo / 48;
D_801930D0[seqPlayerIndex].unk_024 =
(D_801930D0[seqPlayerIndex].unk_01C - D_801930D0[seqPlayerIndex].unk_020) / tempoTimer;
D_801930D0[seqPlayerIndex].unk_028 = tempoTimer;
}
D_801930D0[seqPlayerIndex].unk_014 = 0;
}
if (D_801930D0[seqPlayerIndex].unk_028 != 0) {
D_801930D0[seqPlayerIndex].unk_028--;
if (D_801930D0[seqPlayerIndex].unk_028) {
D_801930D0[seqPlayerIndex].unk_01C -= D_801930D0[seqPlayerIndex].unk_024;
} else {
D_801930D0[seqPlayerIndex].unk_01C = D_801930D0[seqPlayerIndex].unk_020;
}
func_800CBBB8(0x47000000 | (((u32) seqPlayerIndex & 0xFF) << 0x10),
(s32) D_801930D0[seqPlayerIndex].unk_01C);
}
if (D_801930D0[seqPlayerIndex].unk_246 != 0) {
for (channelIndex = 0; channelIndex < 0x10; channelIndex++) {
if (D_801930D0[seqPlayerIndex].unk_044[channelIndex].unk_0C != 0) {
D_801930D0[seqPlayerIndex].unk_044[channelIndex].unk_0C--;
if (D_801930D0[seqPlayerIndex].unk_044[channelIndex].unk_0C) {
D_801930D0[seqPlayerIndex].unk_044[channelIndex].unk_00 -=
D_801930D0[seqPlayerIndex].unk_044[channelIndex].unk_08;
} else {
D_801930D0[seqPlayerIndex].unk_044[channelIndex].unk_00 =
D_801930D0[seqPlayerIndex].unk_044[channelIndex].unk_04;
D_801930D0[seqPlayerIndex].unk_246 ^= 1 << channelIndex;
}
func_800CBB88(0x01000000 | ((seqPlayerIndex & 0xFF) << 0x10) | (((u32) channelIndex & 0xFF) << 8),
D_801930D0[seqPlayerIndex].unk_044[channelIndex].unk_00);
}
}
}
if (D_801930D0[seqPlayerIndex].unk_244 != 0) {
for (channelIndex = 0; channelIndex < 0x10; channelIndex++) {
if (D_801930D0[seqPlayerIndex].unk_044[channelIndex].unk_1C != 0) {
D_801930D0[seqPlayerIndex].unk_044[channelIndex].unk_1C--;
if (D_801930D0[seqPlayerIndex].unk_044[channelIndex].unk_1C) {
D_801930D0[seqPlayerIndex].unk_044[channelIndex].unk_10 -=
D_801930D0[seqPlayerIndex].unk_044[channelIndex].unk_18;
} else {
D_801930D0[seqPlayerIndex].unk_044[channelIndex].unk_10 =
D_801930D0[seqPlayerIndex].unk_044[channelIndex].unk_14;
D_801930D0[seqPlayerIndex].unk_244 ^= 1 << channelIndex;
}
func_800CBB88(0x04000000 | ((seqPlayerIndex & 0xFF) << 0x10) | (((u32) channelIndex & 0xFF) << 8),
D_801930D0[seqPlayerIndex].unk_044[channelIndex].unk_10);
}
}
}
if (D_801930D0[seqPlayerIndex].unk_041) {
if (D_801930D0[seqPlayerIndex].unk_040 != 0) {
D_801930D0[seqPlayerIndex].unk_040--;
continue;
}
if (gSequencePlayers[seqPlayerIndex].enabled != 0) {
continue;
}
for (j = 0; j < D_801930D0[seqPlayerIndex].unk_041; j++) {
setupOp = (D_801930D0[seqPlayerIndex].unk_02C[j] & 0xF00000) >> 0x14;
targetSeqPlayerIndex = (D_801930D0[seqPlayerIndex].unk_02C[j] & 0xF0000) >> 0x10;
setupVal2 = (D_801930D0[seqPlayerIndex].unk_02C[j] & 0xFF00) >> 8;
setupVal1 = D_801930D0[seqPlayerIndex].unk_02C[j] & 0xFF;
switch (setupOp) {
case 0:
D_801930D0[targetSeqPlayerIndex].unk_012 = 1;
D_801930D0[targetSeqPlayerIndex].unk_00E[1] = 0x7F;
break;
case 1:
func_800C3448(0x30000000 | ((u8) seqPlayerIndex) << 0x18 |
(D_801930D0[seqPlayerIndex].unk_248));
break;
case 2:
func_800C3448((((u8) targetSeqPlayerIndex) << 0x18) | 0x10000 |
(u16) (D_801930D0[targetSeqPlayerIndex].unk_248));
D_801930D0[targetSeqPlayerIndex].unk_012 = 1;
D_801930D0[targetSeqPlayerIndex].unk_00E[1] = 0x7F;
break;
case 3:
func_800C3448(0xB0003000 | (((u8) targetSeqPlayerIndex) << 0x18) | (((u8) setupVal2) << 0x10) |
(u16) setupVal1);
break;
case 4:
func_800C3448(0xB0004000 | (((u8) targetSeqPlayerIndex) << 0x18) | (((u8) setupVal1) << 0x10));
break;
case 5:
seqId = D_801930D0[seqPlayerIndex].unk_02C[j] & 0xFFFF;
func_800C3448((((u8) targetSeqPlayerIndex) << 0x18) |
(((u8) D_801930D0[targetSeqPlayerIndex].unk_042) << 0x10) | ((u16) seqId));
func_800C36C4(targetSeqPlayerIndex, 1, 0x7F, 0);
D_801930D0[targetSeqPlayerIndex].unk_042 = 0;
break;
case 6:
D_801930D0[seqPlayerIndex].unk_042 = setupVal2;
break;
}
}
D_801930D0[seqPlayerIndex].unk_041 = 0;
}
}
}
#endif
void func_800C3F70(void) {
@@ -1241,21 +1287,19 @@ void func_800C41CC(u8 arg0, struct SoundCharacteristics* arg1) {
}
}
// Probably a variant of `process_sound_request` from SM64
#ifdef NON_MATCHING
// https://decomp.me/scratch/fmmyb
// Stack issue concerning `var_t2` and `var_t3`, no idea how to fix it
void func_800C4398(void) {
u8 bank;
u8 soundIndex;
u8 var_a3;
struct Sound* var_a2;
s32 pad;
u8 var_t2;
u32 var_t3;
var_a2 = &sSoundRequests[sNumProcessedSoundRequests];
if (var_a2->soundBits == 0)
if (var_a2->soundBits == 0) {
return;
}
bank = ((u32) (var_a2->soundBits & 0xF0000000) >> 0x1C);
soundIndex = sSoundBanks[bank][0].next;
@@ -1303,14 +1347,14 @@ void func_800C4398(void) {
}
}
if ((sSoundBanks[bank][sSoundBankFreeListFront[bank]].next != 0xFF) && (soundIndex != 0)) {
soundIndex = sSoundBankFreeListFront[bank];
var_t2 = soundIndex = sSoundBankFreeListFront[bank];
sSoundBanks[bank][soundIndex].unk00 = &(*var_a2->position)[0];
sSoundBanks[bank][soundIndex].unk04 = &(*var_a2->position)[1];
sSoundBanks[bank][soundIndex].unk08 = &(*var_a2->position)[2];
sSoundBanks[bank][soundIndex].cameraId = var_a2->cameraId;
sSoundBanks[bank][soundIndex].unk10 = var_a2->unk0C;
sSoundBanks[bank][soundIndex].unk14 = var_a2->unk10;
sSoundBanks[bank][0, soundIndex].unk18 = var_a2->unk14;
sSoundBanks[bank][soundIndex].unk18 = var_a2->unk14;
sSoundBanks[bank][soundIndex].soundBits = var_a2->soundBits;
sSoundBanks[bank][soundIndex].soundStatus = (u8) ((u32) (var_a2->soundBits & 0x01000000) >> 0x18);
sSoundBanks[bank][soundIndex].freshness = 2;
@@ -1319,16 +1363,13 @@ void func_800C4398(void) {
sSoundBankUsedListBack[bank] = sSoundBankFreeListFront[bank];
sSoundBankFreeListFront[bank] = sSoundBanks[bank][sSoundBankFreeListFront[bank]].next;
sSoundBanks[bank][sSoundBankFreeListFront[bank]].prev = 0xFF;
sSoundBanks[bank][soundIndex].next = 0xFF;
sSoundBanks[bank][var_t2].next = 0xFF;
} else if (sSoundBanks[bank][sSoundBankFreeListFront[bank]].next == 0xFF) {
if (D_800EA1C8 != *var_a2->position) {
(*var_a2->position)[1] = 100000.0f;
}
}
}
#else
GLOBAL_ASM("asm/non_matchings/audio/external/func_800C4398.s")
#endif
void delete_sound_from_bank(u8 bankId, u8 soundId) {
UNUSED s32 stackPadding;
@@ -1506,9 +1547,6 @@ void func_800C4888(u8 bankId) {
GLOBAL_ASM("asm/non_matchings/audio/external/func_800C4888.s")
#endif
#ifdef NON_MATCHING
// https://decomp.me/scratch/Lm9EX
/* ~*~*~* UwU Resgister allocation OwO *~*~*~ */
void func_800C4FE4(u8 bankId) {
u8 soundId;
u8 var_s4;
@@ -1529,8 +1567,8 @@ void func_800C4FE4(u8 bankId) {
D_801930D0->unk_00E[2] = 0x28;
}
func_800C19D0(bankId, soundId, D_80192C38);
func_800CBBE8((D_80192C38 << 8) | 0x06020000, 1);
func_800CBBE8((D_80192C38 << 8) | 0x06020000 | 4, temp_s0->soundBits & 0xFF);
func_800CBBE8(((D_80192C38 & 0xFF) << 8) | 0x06020000, 1);
func_800CBBE8(((D_80192C38 & 0xFF) << 8) | 0x06020000 | 4, (u8) (temp_s0->soundBits & 0xFF));
temp_s0->soundStatus = 4U;
} else if (((u8) thing->soundScriptIO[7]) == 0x80) {
func_800CBBE8(((D_80192C38 & 0xFF) << 8) | 0x06020000 | 7, 0);
@@ -1543,9 +1581,6 @@ void func_800C4FE4(u8 bankId) {
D_80192C38 += 1;
}
}
#else
GLOBAL_ASM("asm/non_matchings/audio/external/func_800C4FE4.s")
#endif
// Seems somewhat similar to certain parts of `select_current_sounds` from SM64
void func_800C5278(u8 bankId) {
+12 -24
View File
@@ -1136,37 +1136,25 @@ f64 func_8009186C(f64 arg0) {
return ((f64) sp38 * 0.6931471805599453) + (2 * var_f2);
}
#ifdef NON_MATCHING
// https://decomp.me/scratch/dXpT5
// Some math reordering issues on the continued fraction line
f64 func_8009195C(f64 arg0) {
s32 temp_f10;
s32 six = 6;
s32 ten = 10;
s32 fourteen = 14;
s32 eighteen = 18;
f64 temp_f2;
f64 temp_f0;
s32 i;
if (arg0 >= 0.0) {
temp_f2 = 0.5;
} else {
temp_f2 = -0.5;
}
temp_f10 = temp_f2 + (arg0 / 0.6931471805599453);
temp_f10 = ((arg0 >= 0.0) ? 0.5 : -0.5) + (arg0 / 0.6931471805599453);
arg0 -= (temp_f10 * 0.6931471805599453);
temp_f2 = arg0 * arg0;
/**
* This is the denominator part a tanh(x/2) continued fraction, where arg0 is x
* The best reference to this I can find is:
*https://math.stackexchange.com/questions/3241906/continued-fraction-02-6-10-14-22n-1-frace-1e1
**/
temp_f2 =
2 + (temp_f2 / (six + (temp_f2 / (ten + (temp_f2 / (fourteen + (temp_f2 / (eighteen + (temp_f2 / 22)))))))));
temp_f2 = SQ(arg0);
temp_f0 = temp_f2 / 22;
for (i = 0; i < 4; i++) {
temp_f0 = temp_f2 / ((18 - 4 * i) + temp_f0);
}
temp_f2 = 2 + temp_f0;
return func_80091A6C((temp_f2 + arg0) / (temp_f2 - arg0), temp_f10);
}
#else
GLOBAL_ASM("asm/non_matchings/menu_items/func_8009195C.s")
#endif
/**
* This function appears to multiply some `value`
+29 -45
View File
@@ -1213,54 +1213,38 @@ UNUSED void func_802B8414(uintptr_t addr, Mat4 arg1, s16 arg2, s16 arg3, s32 arg
}
}
#ifdef MIPS_TO_C
// generated by m2c commit beb457dabfc7a01ec6540a5404a6a05097a13602 on Oct-29-2023
void func_802B8614(Player* arg0) {
f64 sp78;
f64 sp70;
f64 sp68;
f64 sp58;
f64 sp50;
f64 sp48;
f64 sp40;
f64 sp38;
f64 temp_f12;
f64 temp_f14;
f64 temp_f16;
f64 temp_f18;
f64 temp_f20;
f64 temp_f2;
f64 temp_f30;
f64 temp_f4;
f64 temp_f6;
UNUSED f64 pad[4];
f64 corner1PosX = arg0->tyres[FRONT_RIGHT].pos[0];
f64 corner1PosY = arg0->tyres[FRONT_RIGHT].baseHeight;
f64 corner1PosZ = arg0->tyres[FRONT_RIGHT].pos[2];
temp_f6 = (f64) arg0->tyres[FRONT_RIGHT].pos[0];
sp78 = temp_f6;
sp70 = (f64) arg0->tyres[FRONT_RIGHT].baseHeight;
sp68 = (f64) arg0->tyres[FRONT_RIGHT].pos[2];
temp_f30 = (f64) arg0->tyres[FRONT_LEFT].pos[0];
sp58 = (f64) arg0->tyres[FRONT_LEFT].baseHeight;
sp50 = (f64) arg0->tyres[FRONT_LEFT].pos[2];
sp48 = (f64) arg0->tyres[BACK_RIGHT].pos[0];
sp40 = (f64) arg0->tyres[BACK_RIGHT].baseHeight;
temp_f4 = (f64) arg0->tyres[BACK_RIGHT].pos[2];
temp_f2 = sp58 - sp70;
sp38 = temp_f4;
temp_f12 = temp_f4 - sp50;
temp_f14 = sp50 - sp68;
temp_f16 = sp40 - sp58;
temp_f18 = sp48 - temp_f30;
temp_f20 = temp_f30 - temp_f6;
if (0.0 == 0.0) {
f64 corner0PosX = arg0->tyres[FRONT_LEFT].pos[0];
f64 corner0PosY = arg0->tyres[FRONT_LEFT].baseHeight;
f64 corner0PosZ = arg0->tyres[FRONT_LEFT].pos[2];
f64 corner3PosX = arg0->tyres[BACK_RIGHT].pos[0];
f64 corner3PosY = arg0->tyres[BACK_RIGHT].baseHeight;
f64 corner3PosZ = arg0->tyres[BACK_RIGHT].pos[2];
f64 xValue = (corner0PosY - corner1PosY) * (corner3PosZ - corner0PosZ) -
(corner0PosZ - corner1PosZ) * (corner3PosY - corner0PosY);
f64 yValue = (corner0PosZ - corner1PosZ) * (corner3PosX - corner0PosX) -
(corner0PosX - corner1PosX) * (corner3PosZ - corner0PosZ);
f64 zValue = (corner0PosX - corner1PosX) * (corner3PosY - corner0PosY) -
(corner0PosY - corner1PosY) * (corner3PosX - corner0PosX);
f64 length = sqrtf((xValue * xValue) + (yValue * yValue) + (zValue * zValue));
length = 0.0;
if (length == 0.0) {
arg0->unk_058 = 0.0f;
arg0->unk_060 = 0.0f;
arg0->unk_05C = 1.0f;
return;
arg0->unk_060 = 0.0f;
} else {
arg0->unk_058 = ((f32) xValue) / length;
arg0->unk_05C = ((f32) yValue) / length;
arg0->unk_060 = ((f32) zValue) / length;
}
arg0->unk_058 = (f32) ((f64) (f32) ((temp_f2 * temp_f12) - (temp_f14 * temp_f16)) / 0.0);
arg0->unk_05C = (f32) ((f64) (f32) ((temp_f14 * temp_f18) - (temp_f20 * temp_f12)) / 0.0);
arg0->unk_060 = (f32) ((f64) (f32) ((temp_f20 * temp_f16) - (temp_f2 * temp_f18)) / 0.0);
}
#else
GLOBAL_ASM("asm/non_matchings/racing/math_util/func_802B8614.s")
#endif