Doing some more fixes

This commit is contained in:
KiritoDv 2024-11-04 01:02:27 -06:00
parent 40ffb3d0b4
commit 4acc13fb36
7 changed files with 32 additions and 25 deletions

View File

@ -1139,9 +1139,9 @@ extern AudioCommonPoolSplit gPersistentCommonPoolSplit;
// 0x4 // 0x4
extern AudioCommonPoolSplit gTemporaryCommonPoolSplit; extern AudioCommonPoolSplit gTemporaryCommonPoolSplit;
// 0x4 // 0x4
extern u8 gSampleFontLoadStatus[64]; extern u8 gSampleFontLoadStatus[2048];
extern u8 gFontLoadStatus[64]; extern u8 gFontLoadStatus[2048];
extern u8 gSeqLoadStatus[256]; extern u8 gSeqLoadStatus[2048];
extern volatile u8 gAudioResetStep; extern volatile u8 gAudioResetStep;
extern u8 gAudioSpecId; extern u8 gAudioSpecId;
extern s32 gResetFadeoutFramesLeft; extern s32 gResetFadeoutFramesLeft;

View File

@ -31,9 +31,9 @@ AudioCommonPoolSplit gPersistentCommonPoolSplit;
// 0x4 // 0x4
AudioCommonPoolSplit gTemporaryCommonPoolSplit; AudioCommonPoolSplit gTemporaryCommonPoolSplit;
// 0x4 // 0x4
u8 gSampleFontLoadStatus[64]; u8 gSampleFontLoadStatus[2048];
u8 gFontLoadStatus[64]; u8 gFontLoadStatus[2048];
u8 gSeqLoadStatus[256]; u8 gSeqLoadStatus[2048];
volatile u8 gAudioResetStep; volatile u8 gAudioResetStep;
u8 gAudioSpecId; u8 gAudioSpecId;
s32 gResetFadeoutFramesLeft; s32 gResetFadeoutFramesLeft;

View File

@ -791,8 +791,8 @@ void* AudioLoad_AsyncLoadInner(s32 tableType, s32 id, s32 nChunks, s32 retData,
void AudioLoad_ProcessLoads(s32 resetStatus) { void AudioLoad_ProcessLoads(s32 resetStatus) {
AudioLoad_ProcessSlowLoads(resetStatus); AudioLoad_ProcessSlowLoads(resetStatus);
AudioLoad_ProcessSamplePreloads(resetStatus); // AudioLoad_ProcessSamplePreloads(resetStatus);
AudioLoad_ProcessAsyncLoads(resetStatus); // AudioLoad_ProcessAsyncLoads(resetStatus);
} }
static const char devstr27[] = "Clear Workarea %x -%x size %x \n"; static const char devstr27[] = "Clear Workarea %x -%x size %x \n";

View File

@ -690,7 +690,7 @@ Acmd* func_80009D78(Acmd* aList, s32 aiBufLen, s16 reverbIndex, s16 updateIndex)
if (sp64->lengthB != 0) { if (sp64->lengthB != 0) {
aList = func_800098DC(aList, sp64->lengthA + 0xC90, 0, sp64->lengthB, reverbIndex); aList = func_800098DC(aList, sp64->lengthA + 0xC90, 0, sp64->lengthB, reverbIndex);
} }
aAddMixer(aList++, 0x300, 0xC90, 0x990, 0x7FFF); aAddMixer(aList++, 0x300, 0xC90, 0x990);
aMix(aList++, 0x30, gSynthReverbs[reverbIndex].decayRatio + 0x8000, 0xC90, 0xC90); aMix(aList++, 0x30, gSynthReverbs[reverbIndex].decayRatio + 0x8000, 0xC90, 0xC90);
} else { } else {
sp62 = (sp64->startPos & 7) * 2; sp62 = (sp64->startPos & 7) * 2;
@ -705,7 +705,7 @@ Acmd* func_80009D78(Acmd* aList, s32 aiBufLen, s16 reverbIndex, s16 updateIndex)
aSetBuffer(aList++, 0, sp62 + 0x5F0, 0xE10, aiBufLen * 2); aSetBuffer(aList++, 0, sp62 + 0x5F0, 0xE10, aiBufLen * 2);
aResample(aList++, gSynthReverbs[reverbIndex].resampleFlags, gSynthReverbs[reverbIndex].unk_0A, aResample(aList++, gSynthReverbs[reverbIndex].resampleFlags, gSynthReverbs[reverbIndex].unk_0A,
OS_K0_TO_PHYSICAL(gSynthReverbs[reverbIndex].unk_34)); OS_K0_TO_PHYSICAL(gSynthReverbs[reverbIndex].unk_34));
aAddMixer(aList++, 0x300, 0xC90, 0x990, 0x7FFF); aAddMixer(aList++, 0x300, 0xC90, 0x990);
aMix(aList++, 0x30, gSynthReverbs[reverbIndex].decayRatio + 0x8000, 0xC90, 0xC90); aMix(aList++, 0x30, gSynthReverbs[reverbIndex].decayRatio + 0x8000, 0xC90, 0xC90);
} }
@ -837,7 +837,7 @@ Acmd* func_8000A700(s32 noteIndex, NoteSubEu* noteSub, NoteSynthesisState* synth
s32 padC8; s32 padC8;
s32 samplesLenAdjusted; // spC4 s32 samplesLenAdjusted; // spC4
s32 nAdpcmSamplesProcessed; // spC0 s32 nAdpcmSamplesProcessed; // spC0
u32 endPos; // spBC uintptr_t endPos; // spBC
s32 nSamplesToProcess; // spB8 s32 nSamplesToProcess; // spB8
s32 padB4; s32 padB4;
s32 padB0; s32 padB0;
@ -856,12 +856,12 @@ Acmd* func_8000A700(s32 noteIndex, NoteSubEu* noteSub, NoteSynthesisState* synth
s32 nParts; // sp7C s32 nParts; // sp7C
s32 curPart; // sp78 s32 curPart; // sp78
s32 nSamplesInThisIteration; s32 nSamplesInThisIteration;
s32 sampleDataStartPad; uintptr_t sampleDataStartPad;
s32 resampledTempLen; // sp6C s32 resampledTempLen; // sp6C
u16 noteSamplesDmemAddrBeforeResampling; // sp6A u16 noteSamplesDmemAddrBeforeResampling; // sp6A
s32 samplesRemaining; s32 samplesRemaining;
s32 frameIndex; s32 frameIndex;
s32 sampleDataOffset; uintptr_t sampleDataOffset;
Note* note; // sp58 Note* note; // sp58
u16 sp56; // sp56 u16 sp56; // sp56
@ -878,7 +878,7 @@ Acmd* func_8000A700(s32 noteIndex, NoteSubEu* noteSub, NoteSynthesisState* synth
u32 nEntries; u32 nEntries;
s32 aligned; s32 aligned;
s32 align2; s32 align2;
u16 addr; uintptr_t addr;
currentBook = NULL; currentBook = NULL;
note = &gNotes[noteIndex]; note = &gNotes[noteIndex];
@ -1000,19 +1000,18 @@ Acmd* func_8000A700(s32 noteIndex, NoteSubEu* noteSub, NoteSynthesisState* synth
skipBytes = 0; skipBytes = 0;
goto skip; goto skip;
} }
aligned = ALIGN16(nFramesToDecode * frameSize + 0x10); aligned = ALIGN16(nFramesToDecode * frameSize + SAMPLES_PER_FRAME);
addr = 0x990 - aligned; addr = 0x990 - aligned;
if (nFramesToDecode != 0) { if (nFramesToDecode != 0) {
// LTODO: Validate this // LTODO: Validate this
// bookSample->medium = 0; // bookSample->medium = 0;
frameIndex = (synthState->samplePosInt + skipInitialSamples - nFirstFrameSamplesToIgnore) / 16; frameIndex = (synthState->samplePosInt + skipInitialSamples - nFirstFrameSamplesToIgnore) / SAMPLES_PER_FRAME;
sampleDataOffset = frameIndex * frameSize; sampleDataOffset = frameIndex * frameSize;
if (bookSample->medium == 0) { if (bookSample->medium == 0) {
sampleData = sampleDmaStart + sampleDataOffset + sampleAddr; sampleData = sampleDataOffset + sampleAddr;
} else { } else {
sampleData = AudioLoad_DmaSampleData(sampleDmaStart + sampleDataOffset + sampleAddr, aligned, sampleData = sampleDataOffset + sampleAddr;
flags, &synthState->sampleDmaIndex, bookSample->medium);
} }
// if (1){} // if (1){}
sampleDataStartPad = (uintptr_t) sampleData & 0xF; sampleDataStartPad = (uintptr_t) sampleData & 0xF;
@ -1318,7 +1317,7 @@ Acmd* func_8000B98C(Acmd* aList, NoteSubEu* noteSub, NoteSynthesisState* synthSt
ALIGN16(var_a1)); ALIGN16(var_a1));
} }
aAddMixer(aList++, ALIGN64(size), 0x650, var_t0, 0x7FFF); aAddMixer(aList++, ALIGN64(size), 0x650, var_t0);
return aList; return aList;
} }

View File

@ -48,7 +48,7 @@ void AudioThread_CreateNextAudioBuffer(s16 *samples, u32 num_samples) {
gCurAudioFrameDmaCount = 0; gCurAudioFrameDmaCount = 0;
AudioLoad_DecreaseSampleDmaTtls(); AudioLoad_DecreaseSampleDmaTtls();
AudioLoad_ProcessLoads(gAudioResetStep); // AudioLoad_ProcessLoads(gAudioResetStep);
if (MQ_GET_MESG(gAudioSpecQueue, &specId)) { if (MQ_GET_MESG(gAudioSpecQueue, &specId)) {
if (gAudioResetStep == 0) { if (gAudioResetStep == 0) {

View File

@ -1,6 +1,7 @@
#include <stdbool.h> #include <stdbool.h>
#include <stdint.h> #include <stdint.h>
#include <string.h> #include <string.h>
#include <stdio.h>
#include "mixer.h" #include "mixer.h"
@ -14,9 +15,10 @@
#define ROUND_UP_8(v) (((v) + 7) & ~7) #define ROUND_UP_8(v) (((v) + 7) & ~7)
#define ROUND_DOWN_16(v) ((v) & ~0xf) #define ROUND_DOWN_16(v) ((v) & ~0xf)
#define DMEM_BUF_SIZE (0x1000 - 0x3C0 - 0x40) //#define DMEM_BUF_SIZE (0x1000 - 0x0330 - 0x10 - 0x40)
#define BUF_U8(a) (rspa.buf.as_u8 + ((a) - 0x3C0)) #define DMEM_BUF_SIZE 0xC80
#define BUF_S16(a) (rspa.buf.as_s16 + ((a) - 0x3C0) / sizeof(int16_t)) #define BUF_U8(a) (rspa.buf.as_u8 + ((a)-0x0330))
#define BUF_S16(a) (rspa.buf.as_s16 + ((a)-0x0330) / sizeof(int16_t))
static struct { static struct {
uint16_t in; uint16_t in;
@ -100,7 +102,13 @@ void aClearBufferImpl(uint16_t addr, int nbytes) {
} }
void aLoadBufferImpl(const void *source_addr, uint16_t dest_addr, uint16_t nbytes) { void aLoadBufferImpl(const void *source_addr, uint16_t dest_addr, uint16_t nbytes) {
#if __SANITIZE_ADDRESS__
for (size_t i = 0; i < ROUND_DOWN_16(nbytes); i++) {
BUF_U8(dest_addr)[i] = ((const unsigned char*)source_addr)[i];
}
#else
memcpy(BUF_U8(dest_addr), source_addr, ROUND_DOWN_16(nbytes)); memcpy(BUF_U8(dest_addr), source_addr, ROUND_DOWN_16(nbytes));
#endif
} }
void aSaveBufferImpl(uint16_t source_addr, int16_t *dest_addr, uint16_t nbytes) { void aSaveBufferImpl(uint16_t source_addr, int16_t *dest_addr, uint16_t nbytes) {

View File

@ -77,7 +77,7 @@ void aUnkCmd19Impl(uint8_t f, uint16_t count, uint16_t out_addr, uint16_t in_add
aEnvMixerImpl(inBuf, nSamples, swapReverb, negLeft, negRight, dryLeft, dryRight, wetLeft, wetRight) aEnvMixerImpl(inBuf, nSamples, swapReverb, negLeft, negRight, dryLeft, dryRight, wetLeft, wetRight)
#define aMix(pkt, c, g, i, o) aMixImpl(c, g, i, o) #define aMix(pkt, c, g, i, o) aMixImpl(c, g, i, o)
#define aS8Dec(pkt, f, s) aS8DecImpl(f, s) #define aS8Dec(pkt, f, s) aS8DecImpl(f, s)
#define aAddMixer(pkt, s, d, c, x) aAddMixerImpl(s, d, c) #define aAddMixer(pkt, s, d, c) aAddMixerImpl(s, d, c)
#define aDuplicate(pkt, s, d, c) aDuplicateImpl(s, d, c) #define aDuplicate(pkt, s, d, c) aDuplicateImpl(s, d, c)
#define aDMEMMove2(pkt, t, i, o, c) aDMEMMove2Impl(t, i, o, c) #define aDMEMMove2(pkt, t, i, o, c) aDMEMMove2Impl(t, i, o, c)
#define aResampleZoh(pkt, pitch, startFract) aResampleZohImpl(pitch, startFract) #define aResampleZoh(pkt, pitch, startFract) aResampleZohImpl(pitch, startFract)