summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMegaMech <MegaMech@users.noreply.github.com>2024-05-01 19:19:02 -0600
committerGitHub <noreply@github.com>2024-05-01 19:19:02 -0600
commitf5d8147d4bbe44c64903c9e6627b9a5dd7d2eb26 (patch)
tree06d07a9309a1b14100cb286f557e33a2fcabdb68 /src
parenta66a6fd0091161bd4864f25ce4794397058eefcb (diff)
Update Attempts and cleanup synthesis_process_notes (#633)
* Update code_80005FD0.c
Diffstat (limited to 'src')
-rw-r--r--src/audio/data.c6
-rw-r--r--src/audio/data.h2
-rw-r--r--src/audio/synthesis.c146
-rw-r--r--src/audio/synthesis.h2
-rw-r--r--src/code_80005FD0.c155
5 files changed, 98 insertions, 213 deletions
diff --git a/src/audio/data.c b/src/audio/data.c
index f1cb322ad..5efa7734a 100644
--- a/src/audio/data.c
+++ b/src/audio/data.c
@@ -354,9 +354,9 @@ u16 gHeadsetPanQuantization[0x10] = {
0x40, 0x40, 0x30, 0x30, 0x20, 0x20, 0x10, 0, 0, 0,
};
-s32 gUnknownData_800F6290[32] = { //maybe envelope of some kind?
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 500, 0, 0, 0, 500, 0, 0, 0, 500, 0, 0, 0, 500, 0, 0,
+s16 gUnknownData_800F6290[64] = { // maybe envelope of some kind?
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 500, 0, 0, 0, 0, 0, 0, 0, 500, 0, 0, 0, 0, 0, 0, 0, 500, 0, 0, 0, 0, 0, 0, 0, 500, 0, 0, 0, 0,
};
// Linearly interpolated between
diff --git a/src/audio/data.h b/src/audio/data.h
index 801137152..563352ce0 100644
--- a/src/audio/data.h
+++ b/src/audio/data.h
@@ -34,7 +34,7 @@ extern u32 fill2;
extern struct NoteSubEu gZeroNoteSub;
extern struct NoteSubEu gDefaultNoteSub;
extern u16 gHeadsetPanQuantization[0x10];
-extern s32 gUnknownData_800F6290[32];
+extern s16 gUnknownData_800F6290[];
extern f32 gHeadsetPanVolume[128];
extern f32 gStereoPanVolume[128];
extern f32 gDefaultPanVolume[128];
diff --git a/src/audio/synthesis.c b/src/audio/synthesis.c
index b688bb061..c6e3e5360 100644
--- a/src/audio/synthesis.c
+++ b/src/audio/synthesis.c
@@ -326,8 +326,8 @@ Acmd *synthesis_do_one_audio_update(s16 *aiBuf, s32 bufLen, Acmd *acmd, s32 upda
#ifdef NON_MATCHING
//generated by m2c commit beb457dabfc7a01ec6540a5404a6a05097a13602 on Nov-01-2023
-u64 *synthesis_process_note(s32 noteIndex, struct NoteSubEu *noteSubEu, struct NoteSynthesisState *synthesisState, s16 *aiBuf, s32 inBuf, u64 *cmd, s32 updateIndex) {
- s32 pad[4];
+Acmd *synthesis_process_note(s32 noteIndex, struct NoteSubEu *noteSubEu, struct NoteSynthesisState *synthesisState, UNUSED s16 *aiBuf, s32 inBuf, Acmd *cmd, s32 updateIndex) {
+ UNUSED s32 pad[4];
struct AudioBankSample *audioBookSample;
s16 *curLoadedBook;
struct AdpcmLoop *loopInfo;
@@ -338,7 +338,7 @@ u64 *synthesis_process_note(s32 noteIndex, struct NoteSubEu *noteSubEu, struct N
s32 nSamplesToLoad;
s32 spFC;
- s32 pad2[2];
+ UNUSED s32 pad2[2];
s32 loopInfo_2;
u8 *sampleAddr;
@@ -350,9 +350,8 @@ u64 *synthesis_process_note(s32 noteIndex, struct NoteSubEu *noteSubEu, struct N
s32 endPos;
s32 nSamplesToProcess;
- s32 pad3;
+ UNUSED s32 pad3;
- //u32 spE4;
s32 s3;
s32 leftRight;
s32 s4;
@@ -362,16 +361,15 @@ u64 *synthesis_process_note(s32 noteIndex, struct NoteSubEu *noteSubEu, struct N
u32 var_t2;
u8 *var_a0_2;
- //s32 spD8;
s32 s5Aligned;
s32 temp_t6;
s32 nParts;
s32 curPart;
s32 aligned;
- s32 pad4;
+ UNUSED s32 pad4;
s32 resampledTempLen; /* compiler-managed */
u16 noteSamplesDmemAddrBeforeResampling;
- s32 pad6[1];
+ UNUSED s32 pad6[1];
struct Note *note;
u16 addr;
@@ -387,9 +385,6 @@ u64 *synthesis_process_note(s32 noteIndex, struct NoteSubEu *noteSubEu, struct N
synthesisState->curVolRight = 0;
synthesisState->prevHeadsetPanRight = 0;
synthesisState->prevHeadsetPanLeft = 0;
- //synthesisState->reverbVol = noteSubEu->reverbVol;
- ////synthesisState->unk5 = 0;
- //note->noteSubEu.finished = 0;
}
resamplingRateFixedPoint = noteSubEu->resamplingRateFixedPoint;
@@ -398,7 +393,6 @@ u64 *synthesis_process_note(s32 noteIndex, struct NoteSubEu *noteSubEu, struct N
nSamplesToLoad = (samplesLenFixedPoint >> 0x10);
synthesisState->samplePosFrac = samplesLenFixedPoint & 0xFFFF; // m2c didn't have & 0xFFFF
-//var_a0 = noteSubEu->unk0;
if (noteSubEu->isSyntheticWave) {
cmd = load_wave_samples(cmd, noteSubEu, synthesisState, nSamplesToLoad);
@@ -406,24 +400,14 @@ u64 *synthesis_process_note(s32 noteIndex, struct NoteSubEu *noteSubEu, struct N
synthesisState->samplePosInt += nSamplesToLoad;
} else {
audioBookSample = noteSubEu->sound.audioBankSound->sample;
- //sp130 = audioBookSample;
loopInfo = audioBookSample->loop;
- //sp12C = loopInfo;
endPos = loopInfo->end;
sampleAddr = audioBookSample->sampleAddr; // book?
resampledTempLen = 0;
- //if (nParts > 0) {
- // nSamplesToLoad = samplesLenFixedPoint >> 0x10;
- // sp114 = flags;
- // var_s2_2 = cmd;
-//loop_6:
+
for (curPart = 0; curPart < nParts; curPart++) {
nAdpcmSamplesProcessed = 0;
s4 = 0;
-
-
- //temp_a1 = audioBookSample->unkC;
- //temp_a2_2 = temp_a1 + 8;
if (nParts == 1) {
samplesLenAdjusted = nSamplesToLoad;
@@ -435,27 +419,22 @@ u64 *synthesis_process_note(s32 noteIndex, struct NoteSubEu *noteSubEu, struct N
// sm64 also has if (audioBookSample->codec == CODEC_A) {
if (curLoadedBook != (*audioBookSample->book).book) {
u32 nEntries;
- //temp_v0_3 = var_s2_2;
- // var_s2_2 += 8;
- //temp_v0_3->unk0 = ((temp_a1->unk0 * 16 * temp_a1->unk4) & 0xFFFFFF) | 0x0B000000;
- //temp_v0_3->unk4 = (s32) ((((u32) (noteSubEu->unk0 << 0xB) >> 0x1D) * 2) + temp_a2_2 + 0x80000000);
- //var_a0 = noteSubEu->unk0;
curLoadedBook = audioBookSample->book->book; // or just one book?
nEntries = 16 * audioBookSample->book->order * audioBookSample->book->npredictors;
aLoadADPCM(cmd++, nEntries, VIRTUAL_TO_PHYSICAL2(noteSubEu->bookOffset+curLoadedBook));
// noteSubEu here unsure but seems better?
}
if (noteSubEu->bookOffset != 0) {
- curLoadedBook = &gUnknownData_800F6290; // type?
+ curLoadedBook = &gUnknownData_800F6290[0];
}
while (nAdpcmSamplesProcessed != samplesLenAdjusted) {
-//loop_15:
+
s32 samplesRemaining;
s32 s1;
noteFinished = FALSE;
restart = FALSE;
- //temp_a2_3 = synthesisState->samplePosInt;
+
s3 = synthesisState->samplePosInt & 0xF;
samplesRemaining = endPos - synthesisState->samplePosInt;
nSamplesToProcess = samplesLenAdjusted - nAdpcmSamplesProcessed;
@@ -464,11 +443,10 @@ u64 *synthesis_process_note(s32 noteIndex, struct NoteSubEu *noteSubEu, struct N
}
a1 = 16 - s3;
- //var_s5 = a1;
+
if (nSamplesToProcess < samplesRemaining) {
loopInfo_2 = ((nSamplesToProcess - a1) + 0xF) / 16;
s1 = loopInfo_2 * 16;
- //var_t0 = loopInfo_2;
var_s6 = (a1 + s1) - nSamplesToProcess;
} else {
s1 = samplesRemaining - a1;
@@ -488,86 +466,48 @@ u64 *synthesis_process_note(s32 noteIndex, struct NoteSubEu *noteSubEu, struct N
if (loopInfo_2 != 0) {
temp_t6 = ((synthesisState->samplePosInt - s3) + 16) / 16; // diff from sm64 sh
if (audioBookSample->loaded == 0x81) { // sm64 has audioBookSample->medium
- //var_s0 = ((loopInfo_2 * 9) + 0x1F) & ~0xF;
var_a0_2 = (temp_t6 * 9) + sampleAddr;
} else {
- //spD8 = nSamplesToProcess;
- //sp11C = noteFinished;
- //sp118 = restart;
- //spE4 = samplesLenAdjusted;
- //temp_a1_3 += ((loopInfo_2 * 9) + 0x1F) & ~0xF;
- //var_s0 = temp_a1_3;
var_a0_2 = dma_sample_data((uintptr_t) (temp_t6 * 9) + sampleAddr, ALIGN(((loopInfo_2 * 9) + 16), 4), flags, &synthesisState->sampleDmaIndex);
// unsure flags?
}
- //var_t1 = 0x540 - var_s0;
+
var_t2 = ((uintptr_t)var_a0_2 & 0xF);
-
- //var_s2_2->unk4 = (s32) ((var_a0_2 - var_t2) + 0x80000000);
aligned = ALIGN(((loopInfo_2 * 9) + 16), 4);
addr = (0x540 - aligned) & 0xFFFF; // DMEM_ADDR_COMPRESSED_ADPCM_DATA
- //var_s2_2->unk0 = (((var_s0 >> 4) & 0xFF) << 16) | 0x14000000 | ((0x540 - var_s0) & 0xFFFF);
- // var_s2_2 += 8;
- //aLoadBuffer(cmd++, ALIGN(((loopInfo_2 * 9) + 16), 4), addr, VIRTUAL_TO_PHYSICAL2(var_a0_2 - var_t2));
+
aLoadBuffer(cmd++, VIRTUAL_TO_PHYSICAL2(var_a0_2 - var_t2), addr, aligned);
} else {
s1 = 0; // ?
var_t2 = 0;
- //addr = 0x540 - (((loopInfo_2 * 9) + 16));
}
- //temp_v0_4 = var_s2_2;
+
if (synthesisState->restart != FALSE) {
aSetLoop(cmd++, VIRTUAL_TO_PHYSICAL2(audioBookSample->loop->state));
- //temp_v0_4->unk0 = 0x0F000000;
- //var_s2_2 += 8;
- //temp_v0_4->unk4 = (s32) (audioBookSample->unk8 + 0x80000010);
+
flags = A_LOOP;
synthesisState->restart = FALSE;
}
nSamplesInThisIteration = (s1 + a1) - var_s6;
s5Aligned = ALIGN(s4 + 16, 4);
if (nAdpcmSamplesProcessed == 0) {
- //var_a2 = s1 * 2;
- //var_s2_2->unk4 = (s32) ((var_a2 & 0xFFFF) | 0x01A00000);
- ///var_s2_2->unk0 = ((var_t1 + var_t2) & 0xFFFF) | 0x08000000;
- //temp_s2 = var_s2_2 + 8;
- //temp_s2->unk0 = (s32) (((sp114 & 0xFF) << 0x10) | 0x01000000);
- //temp_s2->unk4 = (s32) VIRTUAL_TO_PHYSICAL2(synthesisState->synthesisBuffers->adpcmdecState);
- //var_s2_2 = temp_s2 + 8;
- //spFC = s3 * 2;
+
aligned = ALIGN(((loopInfo_2 * 9) + 16), 4);
addr = (0x540 - aligned) & 0xFFFF;
aSetBuffer(cmd++, 0, addr + var_t2, 0x1A0, s1 * 2); // unsure
// s1 or s3 here?
aADPCMdec(cmd++, flags, VIRTUAL_TO_PHYSICAL2(synthesisState->synthesisBuffers->adpcmdecState));
spFC = s3 * 2;
- //nSamplesInThisIteration = (s1 + a1) - var_s6;
+
} else {
- // temp_t8 = (s4 + 0x1F) & ~0xF;
- // var_s2_2->unk0 = ((var_t1 + var_t2) & 0xFFFF) | 0x08000000;
- // var_a2 = s1 * 2;
- // var_s2_2->unk4 = (s32) (((temp_t8 + 0x1A0) << 0x10) | (var_a2 & 0xFFFF));
- // temp_s2_2 = var_s2_2 + 8;
- // temp_s2_2->unk0 = (s32) (((sp114 & 0xFF) << 0x10) | 0x01000000);
- // temp_s2_2->unk4 = (s32) VIRTUAL_TO_PHYSICAL2(synthesisState->synthesisBuffers->adpcmdecState);
- // temp_s2_3 = temp_s2_2 + 8;
- // temp_s2_3->unk0 = (s32) (((temp_t8 + (s3 * 2) + 0x1A0) & 0xFFFFFF) | 0x0A000000);
- // temp_s2_3->unk4 = (s32) (((s4 + 0x1A0) << 0x10) | ((nSamplesInThisIteration * 2) & 0xFFFF));
- // var_s2_2 = temp_s2_3 + 8;
+
aligned = ALIGN(((loopInfo_2 * 9) + 16), 4);
addr = (0x540 - aligned) & 0xFFFF;
aSetBuffer(cmd++, 0, addr + var_t2, 0x1A0 + s5Aligned, s1 * 2); // unsure
-
- // The real macro here. Decompme requires the below to work.
- //aS8Dec(cmd++, flags, VIRTUAL_TO_PHYSICAL2(synthesisState->synthesisBuffers->adpcmdecState));
+
aADPCMdec(cmd++, flags, VIRTUAL_TO_PHYSICAL2(synthesisState->synthesisBuffers->adpcmdecState));
- // {\
- // Acmd *_a = (Acmd *) (cmd++);\
- // _a->words.w0 = _SHIFTL(23, 24, 8) | _SHIFTL(flags, 16, 8);\
- // _a->words.w1 = (uintptr_t) VIRTUAL_TO_PHYSICAL2(synthesisState->synthesisBuffers->adpcmdecState);\
- // };
- //nSamplesInThisIteration = (s1 + a1) - var_s6;
+
aDMEMMove(cmd++, 0x1A0 + s5Aligned + (s3 * 2), 0x1A0 + s4, nSamplesInThisIteration * 2);
}
@@ -593,22 +533,8 @@ u64 *synthesis_process_note(s32 noteIndex, struct NoteSubEu *noteSubEu, struct N
if (noteFinished) {
aClearBuffer(cmd++, 0x1A0 + s4,
(samplesLenAdjusted - nAdpcmSamplesProcessed) * 2);
- //var_s2_2->unk0 = ((s4 + 0x1A0) & 0xFFFFFF) | 0x02000000;
- //var_s2_2->unk4 = (s32) ((samplesLenAdjusted - nAdpcmSamplesProcessed) * 2);
- //var_s2_2 += 8;
noteSubEu->finished = 1; // sm64 says = 1
note->noteSubEu.finished = 1;
- //note->noteSubEu.enabled = 0;
- //note->noteSubEu.samplePosInt = 0;
-
- //note->noteSubEu.stereoHeadsetEffects = note->noteSubEu.stereoHeadsetEffects | 0x20;// |= 0x20;
- //note->noteSubEu.stereoHeadsetEffects = ~(1 << 6);
- /* mips to c
- arg1->unk0 = (s8) ((u8) arg1->unk0 | 0x20);
- sp8C->unkB0 = (u8) (sp8C->unkB0 | 0x20);
- sp8C->unkB0 = (u8) (sp8C->unkB0 & 0xFF7F);
- */
- //spE4 = samplesLenAdjusted;
func_800B6FB4(updateIndex, noteIndex);
} else {
@@ -618,9 +544,6 @@ u64 *synthesis_process_note(s32 noteIndex, struct NoteSubEu *noteSubEu, struct N
} else {
synthesisState->samplePosInt += nSamplesToProcess;
}
- // if (nAdpcmSamplesProcessed != samplesLenAdjusted) {
- // goto loop_15;
- // }
}
}
@@ -629,25 +552,8 @@ u64 *synthesis_process_note(s32 noteIndex, struct NoteSubEu *noteSubEu, struct N
noteSamplesDmemAddrBeforeResampling = 0x1A0 + spFC;
break;
case 2:
- //temp_v0_5 = var_s2_2;
switch(curPart) {
case 0:
- // temp_v0_6 = var_s2_2;
- // var_s2_2 += 8;
- // temp_v0_6->unk0 = ((((s32) var_t5 / 2) + 7) & 0xFFF8) | 0x11000000;
- // temp_v0_6->unk4 = (s32) (((spFC + 0x1A0) << 0x10) | 0x20);
- // spA0 = var_t5;
- // sp9E = 0x20;
- // var_a0 = arg1->unk0;
- // temp_t7_3 = (u32) (var_a0 * 4) >> 0x1F;
- // var_v1_2 = temp_t7_3;
- // if (temp_t7_3 != 0) {
- // var_s2_2->unk4 = (s32) (var_t5 + 0x10);
- // var_s2_2->unk0 = ((var_t5 + 0x20) & 0xFFFFFF) | 0x02000000;
- // var_a0 = arg1->unk0;
- // var_s2_2 += 8;
- // var_v1_2 = (u32) (var_a0 * 4) >> 0x1F;
- // }
aDownsampleHalf(cmd++, ALIGN(samplesLenAdjusted / 2, 3), 0x1A0 + spFC, DMEM_ADDR_RESAMPLED);
resampledTempLen = samplesLenAdjusted;
noteSamplesDmemAddrBeforeResampling = DMEM_ADDR_RESAMPLED;
@@ -656,11 +562,6 @@ u64 *synthesis_process_note(s32 noteIndex, struct NoteSubEu *noteSubEu, struct N
}
break;
case 1:
- //var_s2_2 += 8;
- // temp_v0_5->unk0 = ((((s32) var_t5 / 2) + 7) & 0xFFF8) | 0x11000000;
- // temp_v0_5->unk4 = (s32) (((spFC + 0x1A0) << 0x10) | ((spA0 + 0x20) & 0xFFFF));
- // var_a0 = arg1->unk0;
- // var_t6 = (u32) (var_a0 * 4) >> 0x1F;
aDownsampleHalf(cmd++, ALIGN(samplesLenAdjusted / 2, 3), DMEM_ADDR_RESAMPLED2 + spFC, resampledTempLen + DMEM_ADDR_RESAMPLED);
break;
@@ -677,10 +578,7 @@ u64 *synthesis_process_note(s32 noteIndex, struct NoteSubEu *noteSubEu, struct N
flags = A_INIT;
noteSubEu->needsInit = FALSE;
}
- //temp_a2_4 = inBuf * 2;
- // flags = flags;
- //sp114 = flags;
- //flags = flags | sp54;
+
cmd = final_resample(cmd, synthesisState, inBuf * 2, resamplingRateFixedPoint, noteSamplesDmemAddrBeforeResampling, flags);
if ((noteSubEu->headsetPanRight) || (synthesisState->prevHeadsetPanRight)) {
@@ -691,7 +589,7 @@ u64 *synthesis_process_note(s32 noteIndex, struct NoteSubEu *noteSubEu, struct N
leftRight = 0;
}
cmd = func_800B86A0(cmd, noteSubEu, synthesisState, inBuf, 0, leftRight, flags);
- //var_s2 = temp_v0_8;
+
if (noteSubEu->usesHeadsetPanEffects) {
//synthesisState->restart = 1;
cmd = note_apply_headset_pan_effects(cmd, noteSubEu, synthesisState, inBuf * 2, flags, leftRight);
diff --git a/src/audio/synthesis.h b/src/audio/synthesis.h
index 9d8de57a9..a1854442b 100644
--- a/src/audio/synthesis.h
+++ b/src/audio/synthesis.h
@@ -103,7 +103,7 @@ Acmd *synthesis_execute(Acmd*, s32*, s16*, s32);
Acmd *synthesis_resample_and_mix_reverb(Acmd*, s32, s16, s16);
Acmd *synthesis_save_reverb_samples(Acmd*, s16, s16);
Acmd *synthesis_do_one_audio_update(s16*, s32, Acmd*, s32);
-u64 *synthesis_process_note(s32 noteIndex, struct NoteSubEu *noteSubEu, struct NoteSynthesisState *synthesisState, s16 *aiBuf, s32 inBuf, u64 *cmd, s32 updateIndex);
+Acmd *synthesis_process_note(s32 noteIndex, struct NoteSubEu *noteSubEu, struct NoteSynthesisState *synthesisState, s16 *aiBuf, s32 inBuf, Acmd *cmd, s32 updateIndex);
Acmd *load_wave_samples(Acmd *acmd, struct NoteSubEu *noteSubEu, struct NoteSynthesisState *synthesisState, s32 nSamplesToLoad);
Acmd *final_resample(Acmd *acmd, struct NoteSynthesisState *synthesisState, s32 count, u16 pitch, u16 dmemIn, u32 flags);
Acmd *func_800B86A0(Acmd *cmd, struct NoteSubEu *note, struct NoteSynthesisState *synthesisState, s32 nSamples, u16 inBuf, s32 headsetPanSettings, u32 flags);
diff --git a/src/code_80005FD0.c b/src/code_80005FD0.c
index 7fe95d63f..060832135 100644
--- a/src/code_80005FD0.c
+++ b/src/code_80005FD0.c
@@ -830,86 +830,73 @@ void func_800070F4(void) {
}
}
-#ifdef NON_MATCHING
-// https://decomp.me/scratch/AqmzN
-// Decently close overall but there's a huge amount of register mismatches
-// Permuter has not had much luck finding solutions.
-// Replacing `temp_s0` for `var_v0` is a pretty good start, but the permuter
-// is unable to find any improvements after that :(
-
void func_800074D4(void) {
- Player *var_a0_2;
f32 temp_a0;
+ s32 temp;
s32 sp68[8];
- UNUSED s32 temp_s0;
+ UNUSED s32 pad;
s32 temp_t1;
- s32 var_a3;
- s32 var_a3_2;
- s32 var_v0;
- s32 this_loops_upper_bound_is_brough_to_you_by_the_number_eight = NUM_PLAYERS;
-
- for (var_a3 = 0; var_a3 < this_loops_upper_bound_is_brough_to_you_by_the_number_eight; ) {
- gCourseCompletionPercentByRank[var_a3++] = 0.0f;
+ s32 i;
+ s32 j;
+ s32 this_loops_upper_bound_is_brough_to_you_by_the_number = 8;
+
+ for (i = 0; i < this_loops_upper_bound_is_brough_to_you_by_the_number;) {
+ gCourseCompletionPercentByRank[i++] = 0.0f;
}
- var_v0 = 0;
- for (var_a3 = 0; var_a3 < this_loops_upper_bound_is_brough_to_you_by_the_number_eight; var_a3++) {
- var_a0_2 = &gPlayers[var_a3];
- if (var_a0_2->type & 0x800) {
- sp68[var_v0] = var_a3;
- gCourseCompletionPercentByRank[var_v0] = -gTimePlayerLastTouchedFinishLine[var_a3];
- var_v0++;
+
+ for (j = 0, i = 0; i < this_loops_upper_bound_is_brough_to_you_by_the_number; i++) {
+ if (gPlayers[i].type & 0x800) {
+ sp68[j] = i;
+ gCourseCompletionPercentByRank[j] = -gTimePlayerLastTouchedFinishLine[i];
+ j++;
}
}
- temp_t1 = var_v0;
- for (var_a3 = 0; var_a3 < this_loops_upper_bound_is_brough_to_you_by_the_number_eight; var_a3++) {
- var_a0_2 = &gPlayers[var_a3];
- if (!(var_a0_2->type & 0x800)) {
- sp68[var_v0] = var_a3;
- gCourseCompletionPercentByRank[var_v0] = gCourseCompletionPercentByPlayerId[var_a3];
- var_v0++;
+ temp_t1 = j;
+ for (i = 0; i < this_loops_upper_bound_is_brough_to_you_by_the_number; i++) {
+ if (!(gPlayers[i].type & 0x800)) {
+ sp68[j] = i;
+ gCourseCompletionPercentByRank[j] = gCourseCompletionPercentByPlayerId[i];
+ j++;
}
}
-
- for (var_a3 = 0; var_a3 < temp_t1 - 1; var_a3++) {
- for (var_a3_2 = var_a3 + 1; var_a3_2 < temp_t1; var_a3_2++) {
- if (gCourseCompletionPercentByRank[var_a3] < gCourseCompletionPercentByRank[var_a3_2]) {
- var_v0 = sp68[var_a3];
- sp68[var_a3] = sp68[var_a3_2];
- sp68[var_a3_2] = var_v0;
- temp_a0 = gCourseCompletionPercentByRank[var_a3];
- gCourseCompletionPercentByRank[var_a3] = gCourseCompletionPercentByRank[var_a3_2];
- gCourseCompletionPercentByRank[var_a3_2] = temp_a0;
+
+ for (i = 0; i < (temp_t1 - 1); i++) {
+ for (j = i + 1; j < temp_t1; j++) {
+ if (gCourseCompletionPercentByRank[i] < gCourseCompletionPercentByRank[j]) {
+ temp = sp68[i];
+ sp68[i] = sp68[j];
+ sp68[j] = temp;
+ temp_a0 = gCourseCompletionPercentByRank[i];
+ gCourseCompletionPercentByRank[i] = gCourseCompletionPercentByRank[j];
+ gCourseCompletionPercentByRank[j] = temp_a0;
}
}
}
-
- for (var_a3 = temp_t1; var_a3 < this_loops_upper_bound_is_brough_to_you_by_the_number_eight - 1; var_a3++) {
- for (var_a3_2 = var_a3 + 1; var_a3_2 < this_loops_upper_bound_is_brough_to_you_by_the_number_eight; var_a3_2++) {
- if (gCourseCompletionPercentByRank[var_a3] < gCourseCompletionPercentByRank[var_a3_2]) {
- var_v0 = sp68[var_a3];
- sp68[var_a3] = sp68[var_a3_2];
- sp68[var_a3_2] = var_v0;
- temp_a0 = gCourseCompletionPercentByRank[var_a3];
- gCourseCompletionPercentByRank[var_a3] = gCourseCompletionPercentByRank[var_a3_2];
- gCourseCompletionPercentByRank[var_a3_2] = temp_a0;
+
+ for (i = temp_t1; i < (this_loops_upper_bound_is_brough_to_you_by_the_number - 1); i++) {
+ for (j = i + 1; j < this_loops_upper_bound_is_brough_to_you_by_the_number; j++) {
+ if (gCourseCompletionPercentByRank[i] < gCourseCompletionPercentByRank[j]) {
+ temp = sp68[i];
+ sp68[i] = sp68[j];
+ sp68[j] = temp;
+ temp_a0 = gCourseCompletionPercentByRank[i];
+ gCourseCompletionPercentByRank[i] = gCourseCompletionPercentByRank[j];
+ gCourseCompletionPercentByRank[j] = temp_a0;
}
}
}
- for (var_a3 = 0; var_a3 < NUM_PLAYERS; var_a3++) {
- D_801643E0[var_a3] = gGPCurrentRaceRankByPlayerId[var_a3];
+ for (i = 0; i < 8; i++) {
+ D_801643E0[i] = gGPCurrentRaceRankByPlayerId[i];
}
- for (var_a3 = 0; var_a3 < this_loops_upper_bound_is_brough_to_you_by_the_number_eight; var_a3++) {
- gGPCurrentRaceRankByPlayerId[sp68[var_a3]] = var_a3;
- gGPCurrentRacePlayerIdByRank[var_a3] = sp68[var_a3];
+ for (i = 0; i < this_loops_upper_bound_is_brough_to_you_by_the_number; i++) {
+ gGPCurrentRaceRankByPlayerId[sp68[i]] = i;
+ gGPCurrentRacePlayerIdByRank[i] = sp68[i];
}
}
-#else
-GLOBAL_ASM("asm/non_matchings/code_80005FD0/func_800074D4.s")
-#endif
s32 func_80007BF8(u16 arg0, u16 arg1, u16 arg2, u16 arg3, u16 arg4) {
s32 var_v1;
@@ -927,13 +914,11 @@ s32 func_80007BF8(u16 arg0, u16 arg1, u16 arg2, u16 arg3, u16 arg4) {
return var_v1;
}
-#ifdef NON_MATCHING // Likely func equiv
-// https://decomp.me/scratch/Te4u1
-
-void func_80007D04(s32 playerId, Player *player) {
+void func_80007D04(s32 playerId, Player* player) {
s16 temp_t1;
s16 temp_t2;
s32 var_v0;
+
temp_t1 = D_80164450[D_80163478];
temp_t2 = D_80164450[playerId];
@@ -954,33 +939,40 @@ void func_80007D04(s32 playerId, Player *player) {
return;
}
- // Something wrong here. Maybe needs
- // var_v0 = 0;
+ switch (gCCSelection) { // WTF, FAKE ?
+ case 3:
+ break;
+ }
+
switch (gCCSelection) {
- case CC_50:
+ case 0:
var_v0 = 0;
if (playerId == D_80163344[0]) {
var_v0 = 0x14;
}
break;
+
case 1:
var_v0 = 8;
if (playerId == D_80163344[0]) {
var_v0 = 0x18;
}
break;
+
case 2:
var_v0 = 0x12;
if (playerId == D_80163344[0]) {
var_v0 = 0x24;
}
break;
+
case 3:
var_v0 = 8;
if (playerId == D_80163344[0]) {
var_v0 = 0x18;
}
break;
+
default:
var_v0 = 0;
break;
@@ -990,7 +982,6 @@ void func_80007D04(s32 playerId, Player *player) {
player->effects |= 0x200000;
player_speed(player);
D_801634C0[playerId] = 1;
-
} else if (temp_t2 < (temp_t1 + var_v0 + 0x32)) {
player->effects &= ~0x200000;
player_speed(player);
@@ -1006,10 +997,6 @@ void func_80007D04(s32 playerId, Player *player) {
}
}
-#else
-GLOBAL_ASM("asm/non_matchings/code_80005FD0/func_80007D04.s")
-#endif
-
void func_80007FA4(s32 arg0, Player *player, f32 arg2) {
f32 temp_f0;
f32 temp_f12;
@@ -5912,32 +5899,32 @@ void func_80017054(Camera *camera, UNUSED Player *player, UNUSED s32 index, s32
// https://decomp.me/scratch/Ck7hV
// Really crazy diff, permuter only able to find fakematches for improvements (and they're big improvements)
// There's something really, really wrong with the empty `if` statement
-void func_80017054(Camera *camera, Player *player, s32 index, s32 cameraId) {
- s32 stackPadding0;
- s32 stackPadding1;
+void func_80017054(Camera *camera, UNUSED Player *player, UNUSED s32 index, s32 cameraId) {
+ UNUSED s32 stackPadding0;
+ UNUSED s32 stackPadding1;
f32 spAC;
f32 spA8;
f32 spA4;
- s32 stackPadding2;
- s32 stackPadding3;
+ UNUSED s32 stackPadding2;
+ UNUSED s32 stackPadding3;
f32 sp98;
f32 sp94;
f32 sp90;
f32 sp8C;
f32 sp88;
f32 sp84;
- f32 stackPadding4;
- f32 stackPadding5;
- f32 stackPadding6;
- s32 stackPadding7;
- s32 stackPadding8;
+ UNUSED f32 stackPadding4;
+ UNUSED f32 stackPadding5;
+ UNUSED f32 stackPadding6;
+ UNUSED s32 stackPadding7;
+ UNUSED s32 stackPadding8;
s16 sp6E;
s16 sp6C;
- s32 stackPadding9;
- s32 stackPaddingA;
- s32 stackPaddingB;
+ UNUSED s32 stackPadding9;
+ UNUSED s32 stackPaddingA;
+ UNUSED s32 stackPaddingB;
s32 pathIndex;
- s32 stackPaddingC;
+ UNUSED s32 stackPaddingC;
s32 sp58;
s16 sp56;
s32 playerId;