Fixed more even things

This commit is contained in:
KiritoDv 2024-11-10 09:07:58 -06:00
parent ecc6a49f90
commit 304a0a5288
9 changed files with 208 additions and 141 deletions

View File

@ -7,6 +7,7 @@
typedef struct { typedef struct {
s32 msgId; s32 msgId;
u16* msgPtr; u16* msgPtr;
const char* path;
} MsgLookup; } MsgLookup;
u16* Message_PtrFromId(u16 msgId); u16* Message_PtrFromId(u16 msgId);

View File

@ -1131,11 +1131,11 @@ void func_80015FD4(SequencePlayer* seqPlayer) {
return; return;
} }
seqPlayer->tempoAcc += seqPlayer->tempo; seqPlayer->tempoAcc += seqPlayer->tempo;
seqPlayer->tempoAcc = seqPlayer->tempoAcc + (s16) seqPlayer->tempoChange; seqPlayer->tempoAcc += seqPlayer->tempoChange;
if (seqPlayer->tempoAcc < gMaxTempo) { if (seqPlayer->tempoAcc < gMaxTempo) {
return; return;
} }
seqPlayer->tempoAcc = (seqPlayer->tempoAcc - gMaxTempo) & 0xFFFF; // fake? seqPlayer->tempoAcc -= (u16) gMaxTempo;
if (seqPlayer->delay > 1) { if (seqPlayer->delay > 1) {
seqPlayer->delay--; seqPlayer->delay--;
} else { } else {
@ -1214,6 +1214,7 @@ void func_80015FD4(SequencePlayer* seqPlayer) {
seqPlayer->transposition += (s8) func_800146C0(temp_s0); seqPlayer->transposition += (s8) func_800146C0(temp_s0);
break; break;
case 0xDD: case 0xDD:
// LTODO: The original tempo is 0x30 but you can change it to 0x19
seqPlayer->tempo = func_800146C0(temp_s0) * 0x30; seqPlayer->tempo = func_800146C0(temp_s0) * 0x30;
if (seqPlayer->tempo > gMaxTempo) { if (seqPlayer->tempo > gMaxTempo) {
seqPlayer->tempo = gMaxTempo; seqPlayer->tempo = gMaxTempo;

View File

@ -811,79 +811,89 @@ Acmd* func_8000A25C(s16* aiBuf, s32 aiBufLen, Acmd* aList, s32 updateIndex) {
// https://decomp.me/scratch/RgX4r // https://decomp.me/scratch/RgX4r
#ifdef NON_MATCHING #ifdef NON_MATCHING
Acmd* func_8000A700(s32 noteIndex, NoteSubEu* noteSub, NoteSynthesisState* synthState, s16* aiBuf, s32 aiBufLen, Acmd* func_8000A700(
Acmd* aList, s32 updateIndex) { s32 noteIndex,
NoteSubEu* noteSub,
NoteSynthesisState* synthState,
s16* aiBuf,
s32 aiBufLen,
Acmd* aList,
s32 updateIndex
) {
s32 pad11C; s32 pad11C;
s32 pad118; s32 pad118;
s32 pad114; s32 pad114;
Sample* bookSample; // sp110 Sample* bookSample;
AdpcmLoop* loopInfo; // sp10C AdpcmLoop* loopInfo;
void* currentBook; // sp108 void* currentBook;
s32 pad104; s32 pad104;
s32 pad100; s32 pad100;
s32 noteFinished; // spFC s32 sampleFinished;
u32 restart; // spF8 u32 loopToPoint;
s32 flags; // spF4 s32 flags;
u16 resampleRateFixedPoint; // spF2 u16 resampleRateFixedPoint;
s32 nSamplesToLoad; // spEC s32 numSamplesToLoad;
s32 padE8; s32 padE8;
s32 padE4; s32 padE4;
s32 padE0; s32 padE0;
s32 skipBytes; // spDC s32 skipBytes;
s32 padD8; s32 padD8;
s32 padD4; s32 padD4;
s32 padD0; s32 padD0;
uintptr_t sampleAddr; // spCC uintptr_t sampleAddr;
s32 padC8; s32 padC8;
s32 samplesLenAdjusted; // spC4 s32 numSamplesToLoadAdj;
s32 nAdpcmSamplesProcessed; // spC0 s32 numSamplesProcessed;
uintptr_t endPos; // spBC u32 endPos;
s32 nSamplesToProcess; // spB8 s32 nSamplesToProcess;
s32 padB4; s32 padB4;
s32 padB0; s32 padB0;
s32 padAC; s32 padAC;
s32 padA8;
s32 padA4; s32 padA4;
s32 nTrailingSamplesToIgnore; // spA0 s32 padA8;
s32 numTrailingSamplesToIgnore;
s32 pad9C; s32 pad9C;
s32 pad98; s32 pad98;
s32 pad94; s32 pad94;
s32 frameSize; // sp90 s32 frameSize;
s32 pad8C; s32 pad8C;
s32 skipInitialSamples; // sp88 s32 skipInitialSamples;
s32 sampleDmaStart; // sp84 s32 sampleDmaStart;
s32 pad80; s32 pad80;
s32 nParts; // sp7C s32 numParts;
s32 curPart; // sp78 s32 curPart;
s32 nSamplesInThisIteration; s32 numSamplesInThisIteration;
uintptr_t sampleDataStartPad; uintptr_t sampleDataChunkAlignPad;
s32 resampledTempLen; // sp6C s32 resampledTempLen;
u16 noteSamplesDmemAddrBeforeResampling; // sp6A u16 noteSamplesDmemAddrBeforeResampling;
s32 samplesRemaining; s32 pasdasd;
s32 frameIndex; s32 frameIndex;
uintptr_t sampleDataOffset; uintptr_t sampleDataOffset;
Note* note; // sp58 Note* note;
u16 sp56; // sp56 u16 sp56;
s32 numSamplesInFirstFrame;
s32 nSamplesInFirstFrame;
s32 delaySide; s32 delaySide;
s32 nSamplesToDecode; s32 padasdsa;
s32 nFramesToDecode; s32 nFramesToDecode;
s32 nFirstFrameSamplesToIgnore; s32 nFirstFrameSamplesToIgnore;
s32 s5; s32 dmemUncompressedAddrOffset1;
u32 sampleslenFixedPoint; u32 sampleslenFixedPoint;
u8* sampleData; u8* samplesToLoadAddr;
s32 temp; s32 temp;
s32 temp2; s32 temp2;
unsigned int new_var2;
u32 nEntries; u32 nEntries;
s32 aligned; s32 aligned;
s32 align2; s32 align2;
uintptr_t addr; uintptr_t addr;
u8* new_var;
s32 samplesRemaining;
s32 numSamplesToDecode;
s32 sega;
currentBook = NULL; currentBook = NULL;
note = &gNotes[noteIndex]; note = &gNotes[noteIndex];
flags = 0; flags = 0;
if (noteSub->bitField0.needsInit == 1) { if (new_var2 = noteSub->bitField0.needsInit == 1) {
flags = 1; flags = 1;
synthState->restart = 0; synthState->restart = 0;
synthState->samplePosInt = 0; synthState->samplePosInt = 0;
@ -896,88 +906,90 @@ Acmd* func_8000A700(s32 noteIndex, NoteSubEu* noteSub, NoteSynthesisState* synth
note->noteSubEu.bitField0.finished = 0; note->noteSubEu.bitField0.finished = 0;
} }
resampleRateFixedPoint = noteSub->resampleRate; resampleRateFixedPoint = noteSub->resampleRate;
nParts = noteSub->bitField1.hasTwoParts + 1; numParts = noteSub->bitField1.hasTwoParts + 1;
sampleslenFixedPoint = (resampleRateFixedPoint * aiBufLen * 2) + synthState->samplePosFrac; sampleslenFixedPoint = ((resampleRateFixedPoint * aiBufLen) * 2) + synthState->samplePosFrac;
nSamplesToLoad = (sampleslenFixedPoint) >> 0x10; numSamplesToLoad = sampleslenFixedPoint >> 0x10;
synthState->samplePosFrac = sampleslenFixedPoint & 0xFFFF; synthState->samplePosFrac = sampleslenFixedPoint & 0xFFFF;
if ((synthState->numParts == 1) && (nParts == 2)) { if ((synthState->numParts == 1) && (numParts == 2)) {
nSamplesToLoad += 2; numSamplesToLoad += 2;
sp56 = 2; sp56 = 2;
} else if ((synthState->numParts == 2) && (nParts == 1)) { } else if ((synthState->numParts == 2) && (numParts == 1)) {
nSamplesToLoad -= 4; numSamplesToLoad -= 4;
sp56 = 4; sp56 = 4;
} else { } else {
sp56 = 0; sp56 = 0;
} }
synthState->numParts = nParts; synthState->numParts = numParts;
if (noteSub->bitField1.isSyntheticWave) { if (noteSub->bitField1.isSyntheticWave) {
aList = func_8000B3F0(aList, noteSub, synthState, nSamplesToLoad); aList = func_8000B3F0(aList, noteSub, synthState, numSamplesToLoad);
noteSamplesDmemAddrBeforeResampling = (synthState->samplePosInt * 2) + 0x5F0; noteSamplesDmemAddrBeforeResampling = (synthState->samplePosInt * ((char)2)) + 0x5F0;
synthState->samplePosInt += nSamplesToLoad; synthState->samplePosInt += numSamplesToLoad;
} else { } else {
bookSample = *(Sample**) noteSub->waveSampleAddr; bookSample = *((Sample**)noteSub->waveSampleAddr);
loopInfo = bookSample->loop; loopInfo = bookSample->loop;
endPos = loopInfo->end; endPos = loopInfo->end;
sampleAddr = bookSample->sampleAddr; sampleAddr = bookSample->sampleAddr;
resampledTempLen = 0; resampledTempLen = 0;
for (curPart = 0; curPart < nParts; curPart++) { for (curPart = 0; curPart < numParts; curPart++) {
nAdpcmSamplesProcessed = 0; numSamplesProcessed = 0;
s5 = 0; dmemUncompressedAddrOffset1 = 0;
if (nParts == 1) { if (numParts == 1) {
samplesLenAdjusted = nSamplesToLoad; numSamplesToLoadAdj = numSamplesToLoad;
} else if (nSamplesToLoad & 1) { } else if (numSamplesToLoad & 1) {
samplesLenAdjusted = (nSamplesToLoad & ~1) + (curPart * 2); numSamplesToLoadAdj = (numSamplesToLoad & (~1)) + (curPart * 2);
} else { } else {
samplesLenAdjusted = nSamplesToLoad; numSamplesToLoadAdj = numSamplesToLoad;
} }
if ((bookSample->codec == 0) && (currentBook != bookSample->book->book)) { if ((bookSample->codec == 0) && (currentBook != bookSample->book->book)) {
switch (noteSub->bitField1.bookOffset) { switch (noteSub->bitField1.bookOffset) {
case 1: case 1:
currentBook = &gD_800DD200[1]; currentBook = &gD_800DD200[1];
break; break;
case 2: case 2:
currentBook = &gD_800DD200[2]; currentBook = &gD_800DD200[2];
break; break;
default: default:
case 3: case 3:
currentBook = bookSample->book->book; currentBook = bookSample->book->book;
break; break;
} }
nEntries = 16 * bookSample->book->order * bookSample->book->numPredictors; nEntries = (16 * bookSample->book->order) * bookSample->book->numPredictors;
aLoadADPCM(aList++, nEntries, OS_K0_TO_PHYSICAL(currentBook)); aLoadADPCM(aList++, nEntries, OS_K0_TO_PHYSICAL(currentBook));
} }
while (nAdpcmSamplesProcessed != samplesLenAdjusted) {
restart = 0; while (numSamplesProcessed != numSamplesToLoadAdj) {
noteFinished = 0; sampleFinished = 0;
loopToPoint = 0;
samplesRemaining = endPos - synthState->samplePosInt; samplesRemaining = endPos - synthState->samplePosInt;
nSamplesToProcess = samplesLenAdjusted - nAdpcmSamplesProcessed; nSamplesToProcess = numSamplesToLoadAdj - numSamplesProcessed;
nFirstFrameSamplesToIgnore = synthState->samplePosInt & 0xF; nFirstFrameSamplesToIgnore = synthState->samplePosInt & 0xF;
if ((nFirstFrameSamplesToIgnore == 0) && (!synthState->restart)) {
if ((nFirstFrameSamplesToIgnore == 0) && !synthState->restart) {
nFirstFrameSamplesToIgnore = 0x10; nFirstFrameSamplesToIgnore = 0x10;
} }
numSamplesInFirstFrame = 0x10 - nFirstFrameSamplesToIgnore;
nSamplesInFirstFrame = 0x10 - nFirstFrameSamplesToIgnore;
if (nSamplesToProcess < samplesRemaining) { if (nSamplesToProcess < samplesRemaining) {
nFramesToDecode = (nSamplesToProcess - nSamplesInFirstFrame + 0xF) / 16; nFramesToDecode = ((nSamplesToProcess - numSamplesInFirstFrame) + 0xF) / 16;
nSamplesToDecode = nFramesToDecode * 0x10; numSamplesToDecode = nFramesToDecode * 0x10;
// if(1) {} numTrailingSamplesToIgnore = (numSamplesInFirstFrame + numSamplesToDecode) - nSamplesToProcess;
nTrailingSamplesToIgnore = (nSamplesInFirstFrame + nSamplesToDecode) - nSamplesToProcess;
} else { } else {
nSamplesToDecode = samplesRemaining - nSamplesInFirstFrame; numSamplesToDecode = samplesRemaining - numSamplesInFirstFrame;
nTrailingSamplesToIgnore = 0; numTrailingSamplesToIgnore = 0;
if (nSamplesToDecode <= 0) { if (numSamplesToDecode <= 0) {
nSamplesToDecode = 0; numSamplesToDecode = 0;
nSamplesInFirstFrame = samplesRemaining; numSamplesInFirstFrame = samplesRemaining;
} }
nFramesToDecode = (nSamplesToDecode + 0xF) / 16; nFramesToDecode = (numSamplesToDecode + 0xF) / 16;
if (loopInfo->count != 0) { if (loopInfo->count != 0) {
restart = 1; loopToPoint = 1;
} else { } else {
noteFinished = 1; sampleFinished = 1;
} }
} }
switch (bookSample->codec) { switch (bookSample->codec) {
@ -986,132 +998,163 @@ Acmd* func_8000A700(s32 noteIndex, NoteSubEu* noteSub, NoteSynthesisState* synth
skipInitialSamples = 0x10; skipInitialSamples = 0x10;
sampleDmaStart = 0; sampleDmaStart = 0;
break; break;
case 1: case 1:
frameSize = 0x10; frameSize = 0x10;
skipInitialSamples = 0x10; skipInitialSamples = 0x10;
sampleDmaStart = 0; sampleDmaStart = 0;
break; break;
case 2: case 2:
temp = temp = func_800097A8(
func_800097A8(bookSample, samplesLenAdjusted, flags, &synthState->synthesisBuffers->unk_40); bookSample, numSamplesToLoadAdj, flags, &synthState->synthesisBuffers->unk_40
aLoadBuffer(aList++, OS_K0_TO_PHYSICAL(temp), 0x5F0, (samplesLenAdjusted + 0x10) * 2); );
s5 = samplesLenAdjusted; if (0) {
nAdpcmSamplesProcessed = samplesLenAdjusted; }
aLoadBuffer(aList++, OS_K0_TO_PHYSICAL(temp), 0x5F0, (numSamplesToLoadAdj + 0x10) * 2);
flags = 0;
skipBytes = 0; skipBytes = 0;
numSamplesProcessed = numSamplesToLoadAdj;
dmemUncompressedAddrOffset1 = numSamplesToLoadAdj;
goto skip; goto skip;
} }
aligned = ALIGN16(nFramesToDecode * frameSize + 0x10);
aligned = ALIGN16((nFramesToDecode * frameSize) + 0x10);
addr = 0x990 - aligned; addr = 0x990 - aligned;
if (nFramesToDecode != 0) { if (nFramesToDecode != 0) {
// LTODO: Validate this if (1) {
// bookSample->medium = 0; }
frameIndex = (synthState->samplePosInt + skipInitialSamples - nFirstFrameSamplesToIgnore) / 16; frameIndex = (synthState->samplePosInt + skipInitialSamples - nFirstFrameSamplesToIgnore) / 16;
sampleDataOffset = frameIndex * frameSize; sampleDataOffset = frameIndex * frameSize;
if (bookSample->medium == 0) { if (bookSample->medium == 0) {
sampleData = sampleDmaStart + sampleDataOffset + sampleAddr; samplesToLoadAddr = (u8*)(sampleDmaStart + sampleDataOffset + sampleAddr);
} else { } else {
sampleData = sampleDmaStart + sampleDataOffset + sampleAddr; samplesToLoadAddr = (u8*)(sampleDmaStart + sampleDataOffset + sampleAddr);
} }
// if (1){} sampleDataChunkAlignPad = ((uintptr_t)samplesToLoadAddr) % 16;
sampleDataStartPad = (uintptr_t) sampleData & 0xF;
aLoadBuffer(aList++, OS_K0_TO_PHYSICAL(sampleData - sampleDataStartPad), addr, aligned); aLoadBuffer(aList++, OS_K0_TO_PHYSICAL(samplesToLoadAddr - sampleDataChunkAlignPad), addr, aligned);
} else { } else {
nSamplesToDecode = 0; numSamplesToDecode = 0;
sampleDataStartPad = 0; sampleDataChunkAlignPad = 0;
} }
if (synthState->restart) { if (synthState->restart) {
aSetLoop(aList++, OS_K0_TO_PHYSICAL(bookSample->loop->predictorState)); aSetLoop(aList++, OS_K0_TO_PHYSICAL(bookSample->loop->predictorState));
flags = 2; flags = 2;
synthState->restart = 0; synthState->restart = 0;
} }
nSamplesInThisIteration = nSamplesToDecode + nSamplesInFirstFrame - nTrailingSamplesToIgnore;
if (nAdpcmSamplesProcessed == 0) { numSamplesInThisIteration = (numSamplesToDecode + numSamplesInFirstFrame) - numTrailingSamplesToIgnore;
if (numSamplesProcessed == 0) {
switch (bookSample->codec) { switch (bookSample->codec) {
case 0: case 0:
aSetBuffer(aList++, 0, addr + sampleDataStartPad, 0x5F0, nSamplesToDecode * 2);
aSetBuffer(aList++, 0, addr + sampleDataChunkAlignPad, 0x5F0, numSamplesToDecode * 2);
aADPCMdec(aList++, flags, OS_K0_TO_PHYSICAL(synthState->synthesisBuffers)); aADPCMdec(aList++, flags, OS_K0_TO_PHYSICAL(synthState->synthesisBuffers));
break; break;
case 1: case 1:
aSetBuffer(aList++, 0, addr + sampleDataStartPad, 0x5F0, nSamplesToDecode * 2); aSetBuffer(aList++, 0, addr + sampleDataChunkAlignPad, 0x5F0, numSamplesToDecode * 2);
aS8Dec(aList++, flags, OS_K0_TO_PHYSICAL(synthState->synthesisBuffers)); aS8Dec(aList++, flags, OS_K0_TO_PHYSICAL(synthState->synthesisBuffers));
break; break;
} }
skipBytes = nFirstFrameSamplesToIgnore * 2; skipBytes = nFirstFrameSamplesToIgnore * 2;
} else { } else {
// if (1) {} align2 = ALIGN16(dmemUncompressedAddrOffset1 + 0x10);
align2 = ALIGN16(s5 + 0x10);
switch (bookSample->codec) { switch (bookSample->codec) {
case 0: case 0:
aSetBuffer(aList++, 0, addr + sampleDataStartPad, align2 + 0x5F0, nSamplesToDecode * 2); aSetBuffer(
aList++, 0, addr + sampleDataChunkAlignPad, align2 + 0x5F0, numSamplesToDecode * 2
);
aADPCMdec(aList++, flags, OS_K0_TO_PHYSICAL(synthState->synthesisBuffers)); aADPCMdec(aList++, flags, OS_K0_TO_PHYSICAL(synthState->synthesisBuffers));
break; break;
case 1: case 1:
aSetBuffer(aList++, 0, addr + sampleDataStartPad, align2 + 0x5F0, nSamplesToDecode * 2); aSetBuffer(
aList++, 0, addr + sampleDataChunkAlignPad, align2 + 0x5F0, numSamplesToDecode * 2
);
aS8Dec(aList++, flags, OS_K0_TO_PHYSICAL(synthState->synthesisBuffers)); aS8Dec(aList++, flags, OS_K0_TO_PHYSICAL(synthState->synthesisBuffers));
break; break;
} }
aDMEMMove(aList++, (align2 + (nFirstFrameSamplesToIgnore * 2) + 0x5F0), s5 + 0x5F0,
nSamplesInThisIteration * 2); aDMEMMove(
aList++, 0x5F0 + align2 + (nFirstFrameSamplesToIgnore * 2), 0x5F0 + dmemUncompressedAddrOffset1,
numSamplesInThisIteration * 2
);
} }
nAdpcmSamplesProcessed += nSamplesInThisIteration;
numSamplesProcessed += numSamplesInThisIteration;
switch (flags) { switch (flags) {
case 1: case 1:
skipBytes = 0x20; skipBytes = 0x20;
s5 = (nSamplesToDecode + 0x10) * 2; dmemUncompressedAddrOffset1 = (numSamplesToDecode + 0x10) * 2;
break; break;
case 2: case 2:
// if(1) {} dmemUncompressedAddrOffset1 = (numSamplesInThisIteration * 2) + dmemUncompressedAddrOffset1;
s5 = nSamplesInThisIteration * 2 + s5;
break; break;
default: default:
if (s5 != 0) { if (dmemUncompressedAddrOffset1 != 0) {
s5 = nSamplesInThisIteration * 2 + s5; dmemUncompressedAddrOffset1 = (numSamplesInThisIteration * 2) + dmemUncompressedAddrOffset1;
} else { } else {
// if (1) { } dmemUncompressedAddrOffset1 = (nFirstFrameSamplesToIgnore + numSamplesInThisIteration) * 2;
s5 = (nFirstFrameSamplesToIgnore + nSamplesInThisIteration) * 2;
} }
break; break;
} }
skip: skip:
flags = 0; flags = 0;
// goto dummy_label_147574; dummy_label_147574: ;
if (noteFinished) { if (sampleFinished) {
aClearBuffer(aList++, s5 + 0x5F0, (samplesLenAdjusted - nAdpcmSamplesProcessed) * 2); aClearBuffer(
aList++, dmemUncompressedAddrOffset1 + 0x5F0, (numSamplesToLoadAdj - numSamplesProcessed) * 2
);
noteSub->bitField0.finished = 1; noteSub->bitField0.finished = 1;
note->noteSubEu.bitField0.finished = 1; note->noteSubEu.bitField0.finished = 1;
func_80009A2C(updateIndex, noteIndex); func_80009A2C(updateIndex, noteIndex);
break; break;
} }
if (restart) { if (loopToPoint != 0) {
synthState->restart = 1; synthState->restart = 1;
synthState->samplePosInt = loopInfo->start; synthState->samplePosInt = loopInfo->start;
} else { } else {
synthState->samplePosInt += nSamplesToProcess; synthState->samplePosInt += nSamplesToProcess;
} }
} }
switch (nParts) {
switch (numParts) {
case 1: case 1:
noteSamplesDmemAddrBeforeResampling = skipBytes + 0x5F0; noteSamplesDmemAddrBeforeResampling = skipBytes + 0x5F0;
break; break;
case 2: case 2:
switch (curPart) { switch (curPart) {
case 0: case 0:
aInterl(aList++, skipBytes + 0x5F0, 0x470, ALIGN8(samplesLenAdjusted / 2)); aInterl(aList++, skipBytes + 0x5F0, 0x470, ALIGN8(numSamplesToLoadAdj / 2));
resampledTempLen = samplesLenAdjusted; resampledTempLen = numSamplesToLoadAdj;
noteSamplesDmemAddrBeforeResampling = 0x470; noteSamplesDmemAddrBeforeResampling = 0x470;
if (noteSub->bitField0.finished) { if (noteSub->bitField0.finished) {
aClearBuffer(aList++, resampledTempLen + noteSamplesDmemAddrBeforeResampling, aClearBuffer(
samplesLenAdjusted + 0x10); aList++, resampledTempLen + noteSamplesDmemAddrBeforeResampling,
numSamplesToLoadAdj + 0x10
);
} }
break; break;
case 1: case 1:
aInterl(aList++, skipBytes + 0x5F0, resampledTempLen + 0x470, aInterl(
ALIGN8(samplesLenAdjusted / 2)); aList++, skipBytes + 0x5F0, resampledTempLen + 0x470, ALIGN8(numSamplesToLoadAdj / 2)
);
break; break;
} }
break; break;
} }
@ -1120,22 +1163,21 @@ Acmd* func_8000A700(s32 noteIndex, NoteSubEu* noteSub, NoteSynthesisState* synth
} }
} }
} }
flags = 0; flags = 0;
if (noteSub->bitField0.needsInit == 1) { if (noteSub->bitField0.needsInit == 1) {
flags = 1; flags = 1;
noteSub->bitField0.needsInit = 0; noteSub->bitField0.needsInit = 0;
} }
flags = sp56 | flags; flags = sp56 | flags;
aList = func_8000B480(aList, synthState, aiBufLen * 2, resampleRateFixedPoint, noteSamplesDmemAddrBeforeResampling, aList = func_8000B480(
flags); aList, synthState, aiBufLen * 2, resampleRateFixedPoint, noteSamplesDmemAddrBeforeResampling, flags
);
if (flags & 1) { if (flags & 1) {
flags = 1; flags = 1;
} }
if (noteSub->bitField1.bookOffset == 3) { if (noteSub->bitField1.bookOffset == 3) {
aUnkCmd19(aList++, 0, aiBufLen * 2, 0x450, 0x450); aUnkCmd19(aList++, 0, aiBufLen * 2, 0x450, 0x450);
} }
temp2 = noteSub->gain; temp2 = noteSub->gain;
if (temp2 != 0) { if (temp2 != 0) {
if (temp2 < 0x10) { if (temp2 < 0x10) {
@ -1150,16 +1192,13 @@ Acmd* func_8000A700(s32 noteIndex, NoteSubEu* noteSub, NoteSynthesisState* synth
} else { } else {
delaySide = 0; delaySide = 0;
} }
aList = func_8000B51C(aList, noteSub, synthState, aiBufLen, 0x450, delaySide, flags); aList = func_8000B51C(aList, noteSub, synthState, aiBufLen, 0x450, delaySide, flags);
// if(restart) {}
if (noteSub->bitField0.usesHeadsetPanEffects) { if (noteSub->bitField0.usesHeadsetPanEffects) {
if (!(flags & 1)) { if (!(flags & 1)) {
flags = 0; flags = 0;
} }
aList = func_8000B98C(aList, noteSub, synthState, aiBufLen * 2, flags, delaySide); aList = func_8000B98C(aList, noteSub, synthState, aiBufLen * 2, flags, delaySide);
} }
return aList; return aList;
} }
#else #else

View File

@ -401,7 +401,7 @@ void AudioThread_ProcessCmds(u32 msg) {
case AUDIOCMD_OP_SEQPLAYER_SET_TRANSPOSITION: case AUDIOCMD_OP_SEQPLAYER_SET_TRANSPOSITION:
player->transposition = cmd->asSbyte; player->transposition = cmd->asSbyte;
break; break;
case 0x46: // AUDIOCMD_OP_SEQPLAYER_SET_IO? case AUDIOCMD_OP_SEQPLAYER_SET_IO:
player->unk_07[cmd->arg2] = cmd->asSbyte; player->unk_07[cmd->arg2] = cmd->asSbyte;
break; break;
} }

View File

@ -7,7 +7,7 @@ u16* Message_PtrFromId(u16 msgId) {
while (lookup->msgId != -1) { while (lookup->msgId != -1) {
if (lookup->msgId == msgId) { if (lookup->msgId == msgId) {
return lookup->msgPtr; return lookup->path;
} }
lookup++; lookup++;
} }
@ -19,9 +19,15 @@ u16 Message_IdFromPtr(u16* msgPtr) {
MsgLookup* lookup = (MsgLookup*) LOAD_ASSET(gMsgLookup); MsgLookup* lookup = (MsgLookup*) LOAD_ASSET(gMsgLookup);
while (lookup->msgPtr != NULL) { while (lookup->msgPtr != NULL) {
if(GameEngine_OTRSigCheck(msgPtr)){
if(strcmp(((char*) msgPtr) + 7, lookup->path) == 0){
return lookup->msgId;
}
} else {
if (lookup->msgPtr == msgPtr) { if (lookup->msgPtr == msgPtr) {
return lookup->msgId; return lookup->msgId;
} }
}
lookup++; lookup++;
} }
return -1; return -1;

View File

@ -57,9 +57,9 @@ void Radio_PlayMessage(u16* msg, RadioCharacterId character) {
TeamId teamId; TeamId teamId;
s32 pad; s32 pad;
s32 priority; s32 priority;
msg = LOAD_ASSET(msg); u16* lmsg = LOAD_ASSET(msg);
switch (msg[0]) { switch (lmsg[0]) {
default: default:
case MSGCHAR_PRI0: case MSGCHAR_PRI0:
priority = 0; priority = 0;

View File

@ -17,9 +17,11 @@ std::shared_ptr<Ship::IResource> ResourceFactoryBinaryMessageLookupV0::ReadResou
for (uint32_t i = 0; i < count - 1; i++) { for (uint32_t i = 0; i < count - 1; i++) {
SPDLOG_INFO("Reading message lookup table entry {}", i); SPDLOG_INFO("Reading message lookup table entry {}", i);
auto id = reader->ReadInt32(); auto id = reader->ReadInt32();
auto crc = reader->ReadUInt64();
uint16_t* ptr = LoadChild<uint16_t*>(reader->ReadUInt64()); uint16_t* ptr = LoadChild<uint16_t*>(crc);
table->mLookupTable.push_back({ id, ptr }); const char* name = ResourceGetNameByCrc(crc);
table->mLookupTable.push_back({ id, ptr, strdup(name) });
} }
return table; return table;

View File

@ -10,6 +10,14 @@
namespace fs = std::filesystem; namespace fs = std::filesystem;
std::unordered_map<uint32_t, void*> gAudioCache;
void* StoreOnCache(uint32_t addr){
if(gAudioCache.contains(addr)){
return gAudioCache[addr];
}
}
Ship::BinaryReader Audio_MakeReader(const char* resource, u32 offset){ Ship::BinaryReader Audio_MakeReader(const char* resource, u32 offset){
auto data = (char*)ResourceGetDataByName(resource); auto data = (char*)ResourceGetDataByName(resource);
auto size = ResourceGetSizeByName(resource); auto size = ResourceGetSizeByName(resource);
@ -51,6 +59,10 @@ EnvelopePoint* Audio_LoadEnvelope(uint32_t addr) {
extern "C" SoundFont* Audio_LoadFont(AudioTableEntry entry) { extern "C" SoundFont* Audio_LoadFont(AudioTableEntry entry) {
auto reader = Audio_MakeReader(gAudioBank, entry.romAddr); auto reader = Audio_MakeReader(gAudioBank, entry.romAddr);
if(gAudioCache.contains(entry.romAddr)){
return (SoundFont*) gAudioCache[entry.romAddr];
}
SoundFont* font = memalloc(SoundFont); SoundFont* font = memalloc(SoundFont);
font->numInstruments = (entry.shortData2 >> 8) & 0xFFu; font->numInstruments = (entry.shortData2 >> 8) & 0xFFu;
@ -80,6 +92,7 @@ extern "C" SoundFont* Audio_LoadFont(AudioTableEntry entry) {
gSampleFontLoadStatus[font->sampleBankId1] = 2; gSampleFontLoadStatus[font->sampleBankId1] = 2;
gAudioCache[entry.romAddr] = font;
return font; return font;
} }
@ -181,6 +194,10 @@ extern "C" Instrument* Audio_LoadInstrument(uint32_t addr, AudioTableEntry entry
} }
extern "C" Drum* Audio_LoadDrum(uint32_t addr, AudioTableEntry entry, uint32_t sampleBankID) { extern "C" Drum* Audio_LoadDrum(uint32_t addr, AudioTableEntry entry, uint32_t sampleBankID) {
if(addr == 0){
return nullptr;
}
auto reader = Audio_MakeReader(gAudioBank, entry.romAddr + addr); auto reader = Audio_MakeReader(gAudioBank, entry.romAddr + addr);
Drum* drum = memalloc(Drum); Drum* drum = memalloc(Drum);

View File

@ -8,6 +8,7 @@ namespace SF64 {
typedef struct { typedef struct {
s32 msgId; s32 msgId;
u16* msgPtr; u16* msgPtr;
const char* path;
} MsgLookup; } MsgLookup;
class Message : public Ship::Resource<void> { class Message : public Ship::Resource<void> {