You've already forked Microtransactions64
mirror of
https://github.com/Print-and-Panic/Microtransactions64.git
synced 2026-01-21 10:17:19 -08:00
Merge pull request #454 from HackerN64/develop/2.0.3
HackerSM64 2.0.3 Release: Audio Crash
This commit is contained in:
@@ -1 +1 @@
|
||||
v2.0.2
|
||||
v2.0.3
|
||||
|
||||
@@ -274,7 +274,7 @@ void sound_alloc_pool_init(struct SoundAllocPool *pool, void *memAddr, u32 size)
|
||||
#ifdef VERSION_SH
|
||||
pool->size = size - ((uintptr_t) memAddr & 0xf);
|
||||
#else
|
||||
pool->size = size;
|
||||
pool->size = ALIGN16(size);
|
||||
#endif
|
||||
pool->numAllocatedEntries = 0;
|
||||
}
|
||||
@@ -408,6 +408,8 @@ void *alloc_bank_or_seq(struct SoundMultiPool *arg0, s32 arg1, s32 size, s32 arg
|
||||
u32 leftAvail, rightAvail;
|
||||
#endif
|
||||
|
||||
size = ALIGN16(size);
|
||||
|
||||
#ifdef VERSION_SH
|
||||
switch (poolIdx) {
|
||||
case 0:
|
||||
@@ -656,7 +658,7 @@ void *alloc_bank_or_seq(struct SoundMultiPool *arg0, s32 arg1, s32 size, s32 arg
|
||||
#if defined(VERSION_SH)
|
||||
tp->entries[1].ptr = (u8 *) ((uintptr_t) (pool->start + pool->size - size) & ~0x0f);
|
||||
#else
|
||||
tp->entries[1].ptr = pool->start + pool->size - size - 0x10;
|
||||
tp->entries[1].ptr = pool->start + pool->size - size;
|
||||
#endif
|
||||
tp->entries[1].id = id;
|
||||
tp->entries[1].size = size;
|
||||
|
||||
@@ -38,8 +38,14 @@ struct SeqOrBankEntry {
|
||||
struct PersistentPool {
|
||||
/*0x00*/ u32 numEntries;
|
||||
/*0x04*/ struct SoundAllocPool pool;
|
||||
#ifdef EXPAND_AUDIO_HEAP // TODO: Make this a configurable define rather than using static values
|
||||
/*0x14*/ struct SeqOrBankEntry entries[64];
|
||||
// size = 0x314
|
||||
#else
|
||||
/*0x14*/ struct SeqOrBankEntry entries[32];
|
||||
}; // size = 0x194
|
||||
// size = 0x194
|
||||
#endif
|
||||
};
|
||||
|
||||
struct TemporaryPool {
|
||||
/*EU, SH*/
|
||||
@@ -64,9 +70,14 @@ struct SoundMultiPool {
|
||||
/* */ u32 pad2[4];
|
||||
}; // size = 0x1D0
|
||||
|
||||
#ifdef VERSION_SH
|
||||
struct Unk1Pool {
|
||||
struct SoundAllocPool pool;
|
||||
#ifdef EXPAND_AUDIO_HEAP
|
||||
struct SeqOrBankEntry entries[64];
|
||||
#else
|
||||
struct SeqOrBankEntry entries[32];
|
||||
#endif
|
||||
};
|
||||
|
||||
struct UnkEntry {
|
||||
@@ -85,6 +96,7 @@ struct UnkPool {
|
||||
/*0x510*/ s32 numEntries;
|
||||
/*0x514*/ u32 unk514;
|
||||
};
|
||||
#endif
|
||||
|
||||
extern u8 gAudioHeap[];
|
||||
extern s16 gVolume;
|
||||
|
||||
@@ -24,6 +24,8 @@ struct SharedDma {
|
||||
// EU only
|
||||
void port_eu_init(void);
|
||||
|
||||
ALIGNED16 u32 dmaTempBuffer[4];
|
||||
|
||||
struct Note *gNotes;
|
||||
|
||||
struct SequencePlayer gSequencePlayers[SEQUENCE_PLAYERS];
|
||||
@@ -199,11 +201,7 @@ void *dma_sample_data(uintptr_t devAddr, u32 size, s32 arg2, u8 *dmaIndexRef) {
|
||||
|
||||
if (arg2 != 0 || *dmaIndexRef >= sSampleDmaListSize1) {
|
||||
for (i = sSampleDmaListSize1; i < gSampleDmaNumListItems; i++) {
|
||||
#if defined(VERSION_EU)
|
||||
dma = &sSampleDmas[i];
|
||||
#else
|
||||
dma = sSampleDmas + i;
|
||||
#endif
|
||||
bufferPos = devAddr - dma->source;
|
||||
if (0 <= bufferPos && (size_t) bufferPos <= dma->bufSize - size) {
|
||||
// We already have a DMA request for this memory range.
|
||||
@@ -220,11 +218,7 @@ void *dma_sample_data(uintptr_t devAddr, u32 size, s32 arg2, u8 *dmaIndexRef) {
|
||||
}
|
||||
dma->ttl = 60;
|
||||
*dmaIndexRef = (u8) i;
|
||||
#if defined(VERSION_EU)
|
||||
return &dma->buffer[(devAddr - dma->source)];
|
||||
#else
|
||||
return (devAddr - dma->source) + dma->buffer;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -237,12 +231,7 @@ void *dma_sample_data(uintptr_t devAddr, u32 size, s32 arg2, u8 *dmaIndexRef) {
|
||||
hasDma = TRUE;
|
||||
}
|
||||
} else {
|
||||
#if defined(VERSION_EU)
|
||||
dma = sSampleDmas;
|
||||
dma += *dmaIndexRef;
|
||||
#else
|
||||
dma = sSampleDmas + *dmaIndexRef;
|
||||
#endif
|
||||
bufferPos = devAddr - dma->source;
|
||||
if (0 <= bufferPos && (size_t) bufferPos <= dma->bufSize - size) {
|
||||
// We already have DMA for this memory range.
|
||||
@@ -258,11 +247,7 @@ void *dma_sample_data(uintptr_t devAddr, u32 size, s32 arg2, u8 *dmaIndexRef) {
|
||||
sSampleDmaReuseQueueTail1++;
|
||||
}
|
||||
dma->ttl = 2;
|
||||
#if defined(VERSION_EU)
|
||||
return dma->buffer + (devAddr - dma->source);
|
||||
#else
|
||||
return (devAddr - dma->source) + dma->buffer;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -279,21 +264,13 @@ void *dma_sample_data(uintptr_t devAddr, u32 size, s32 arg2, u8 *dmaIndexRef) {
|
||||
dma->ttl = 2;
|
||||
dma->source = dmaDevAddr;
|
||||
dma->sizeUnused = transfer;
|
||||
#ifdef VERSION_US
|
||||
#ifdef VERSION_US // TODO: Is there a reason this only exists in US?
|
||||
osInvalDCache(dma->buffer, transfer);
|
||||
#endif
|
||||
#if defined(VERSION_EU)
|
||||
osPiStartDma(&gCurrAudioFrameDmaIoMesgBufs[gCurrAudioFrameDmaCount++], OS_MESG_PRI_NORMAL,
|
||||
OS_READ, dmaDevAddr, dma->buffer, transfer, &gCurrAudioFrameDmaQueue);
|
||||
*dmaIndexRef = dmaIndex;
|
||||
return (devAddr - dmaDevAddr) + dma->buffer;
|
||||
#else
|
||||
gCurrAudioFrameDmaCount++;
|
||||
osPiStartDma(&gCurrAudioFrameDmaIoMesgBufs[gCurrAudioFrameDmaCount - 1], OS_MESG_PRI_NORMAL,
|
||||
OS_READ, dmaDevAddr, dma->buffer, transfer, &gCurrAudioFrameDmaQueue);
|
||||
*dmaIndexRef = dmaIndex;
|
||||
return dma->buffer + (devAddr - dmaDevAddr);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -526,8 +503,6 @@ void patch_audio_bank(struct AudioBank *mem, u8 *offset, u32 numInstruments, u32
|
||||
}
|
||||
|
||||
struct AudioBank *bank_load_immediate(s32 bankId, s32 arg1) {
|
||||
u32 buf[4];
|
||||
|
||||
// (This is broken if the length is 1 (mod 16), but that never happens --
|
||||
// it's always divisible by 4.)
|
||||
s32 alloc = gAlCtlHeader->seqArray[bankId].len + 0xf;
|
||||
@@ -539,9 +514,9 @@ struct AudioBank *bank_load_immediate(s32 bankId, s32 arg1) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
audio_dma_copy_immediate((uintptr_t) ctlData, buf, 0x10);
|
||||
u32 numInstruments = buf[0];
|
||||
u32 numDrums = buf[1];
|
||||
audio_dma_copy_immediate((uintptr_t) ctlData, dmaTempBuffer, 0x10);
|
||||
u32 numInstruments = dmaTempBuffer[0];
|
||||
u32 numDrums = dmaTempBuffer[1];
|
||||
audio_dma_copy_immediate((uintptr_t)(ctlData + 0x10), ret, alloc);
|
||||
patch_audio_bank(ret, gAlTbl->seqArray[bankId].offset, numInstruments, numDrums);
|
||||
gCtlEntries[bankId].numInstruments = (u8) numInstruments;
|
||||
@@ -553,8 +528,6 @@ struct AudioBank *bank_load_immediate(s32 bankId, s32 arg1) {
|
||||
}
|
||||
|
||||
struct AudioBank *bank_load_async(s32 bankId, s32 arg1, struct SequencePlayer *seqPlayer) {
|
||||
u32 buf[4];
|
||||
|
||||
size_t alloc = gAlCtlHeader->seqArray[bankId].len + 0xf;
|
||||
alloc = ALIGN16(alloc);
|
||||
alloc -= 0x10;
|
||||
@@ -564,9 +537,9 @@ struct AudioBank *bank_load_async(s32 bankId, s32 arg1, struct SequencePlayer *s
|
||||
return NULL;
|
||||
}
|
||||
|
||||
audio_dma_copy_immediate((uintptr_t) ctlData, buf, 0x10);
|
||||
u32 numInstruments = buf[0];
|
||||
u32 numDrums = buf[1];
|
||||
audio_dma_copy_immediate((uintptr_t) ctlData, dmaTempBuffer, 0x10);
|
||||
u32 numInstruments = dmaTempBuffer[0];
|
||||
u32 numDrums = dmaTempBuffer[1];
|
||||
seqPlayer->loadingBankId = (u8) bankId;
|
||||
#if defined(VERSION_EU)
|
||||
gCtlEntries[bankId].numInstruments = numInstruments;
|
||||
@@ -830,11 +803,8 @@ void load_sequence_internal(u32 player, u32 seqId, s32 loadAsync) {
|
||||
|
||||
// (void) must be omitted from parameters to fix stack with -framepointer
|
||||
void audio_init() {
|
||||
#if defined(VERSION_JP) || defined(VERSION_US) || defined(VERSION_EU)
|
||||
u8 buf[0x10];
|
||||
#endif
|
||||
s32 i, /*j,*/ k;
|
||||
UNUSED u32 size;
|
||||
u32 size;
|
||||
void *data;
|
||||
|
||||
gAudioLoadLock = AUDIO_LOCK_UNINITIALIZED;
|
||||
@@ -909,10 +879,6 @@ void audio_init() {
|
||||
bzero(&gAiBuffers, sizeof(gAiBuffers));
|
||||
for (i = 0; i < NUMAIBUFFERS; i++) {
|
||||
gAiBuffers[i] = soundAlloc(&gAudioInitPool, AIBUFFER_LEN);
|
||||
|
||||
/*for (j = 0; j < (s32) (AIBUFFER_LEN / sizeof(s16)); j++) {
|
||||
gAiBuffers[i][j] = 0;
|
||||
}*/
|
||||
}
|
||||
|
||||
#if defined(VERSION_EU)
|
||||
@@ -929,7 +895,7 @@ void audio_init() {
|
||||
eu_stubbed_printf_0("Main Heap Initialize.\n");
|
||||
|
||||
// Load headers for sounds and sequences
|
||||
gSeqFileHeader = (ALSeqFile *) buf;
|
||||
gSeqFileHeader = (ALSeqFile *) dmaTempBuffer;
|
||||
data = gMusicData;
|
||||
audio_dma_copy_immediate((uintptr_t) data, gSeqFileHeader, 0x10);
|
||||
gSequenceCount = gSeqFileHeader->seqCount;
|
||||
@@ -940,7 +906,7 @@ void audio_init() {
|
||||
alSeqFileNew(gSeqFileHeader, data);
|
||||
|
||||
// Load header for CTL (instrument metadata)
|
||||
gAlCtlHeader = (ALSeqFile *) buf;
|
||||
gAlCtlHeader = (ALSeqFile *) dmaTempBuffer;
|
||||
data = gSoundDataADSR;
|
||||
audio_dma_copy_immediate((uintptr_t) data, gAlCtlHeader, 0x10);
|
||||
size = gAlCtlHeader->seqCount * sizeof(ALSeqData) + 4;
|
||||
@@ -951,7 +917,7 @@ void audio_init() {
|
||||
alSeqFileNew(gAlCtlHeader, data);
|
||||
|
||||
// Load header for TBL (raw sound data)
|
||||
gAlTbl = (ALSeqFile *) buf;
|
||||
gAlTbl = (ALSeqFile *) dmaTempBuffer;
|
||||
audio_dma_copy_immediate((uintptr_t) data, gAlTbl, 0x10);
|
||||
size = gAlTbl->seqCount * sizeof(ALSeqData) + 4;
|
||||
size = ALIGN16(size);
|
||||
|
||||
Reference in New Issue
Block a user