mirror of
				https://github.com/coop-deluxe/sm64coopdx.git
				synced 2025-10-30 08:01:01 +00:00 
			
		
		
		
	More audio fixes
by djoslin0 and theclashingfritz
This commit is contained in:
		
							parent
							
								
									bd247372ef
								
							
						
					
					
						commit
						25fe547113
					
				
					 5 changed files with 42 additions and 46 deletions
				
			
		| 
						 | 
					@ -4,12 +4,14 @@ Developers:
 | 
				
			||||||
    FluffaLuigi
 | 
					    FluffaLuigi
 | 
				
			||||||
    kebabstorm
 | 
					    kebabstorm
 | 
				
			||||||
    MegaMech
 | 
					    MegaMech
 | 
				
			||||||
 | 
					    theclashingfritz
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Contributors:
 | 
					Contributors:
 | 
				
			||||||
    AloXado320
 | 
					    AloXado320
 | 
				
			||||||
    anzz1
 | 
					    anzz1
 | 
				
			||||||
    Avery
 | 
					    Avery
 | 
				
			||||||
    Cameron Hall
 | 
					    Cameron Hall
 | 
				
			||||||
 | 
					    camthesaxman
 | 
				
			||||||
    charity
 | 
					    charity
 | 
				
			||||||
    Cjes
 | 
					    Cjes
 | 
				
			||||||
    DorfDork
 | 
					    DorfDork
 | 
				
			||||||
| 
						 | 
					@ -18,7 +20,7 @@ Contributors:
 | 
				
			||||||
    eros71
 | 
					    eros71
 | 
				
			||||||
    Filipianosol
 | 
					    Filipianosol
 | 
				
			||||||
    GammaTendonNine
 | 
					    GammaTendonNine
 | 
				
			||||||
    kebabstorm
 | 
					    gunvalk
 | 
				
			||||||
    Llennpie
 | 
					    Llennpie
 | 
				
			||||||
    LuigiNoodle
 | 
					    LuigiNoodle
 | 
				
			||||||
    PeachyPeach
 | 
					    PeachyPeach
 | 
				
			||||||
| 
						 | 
					@ -28,7 +30,6 @@ Contributors:
 | 
				
			||||||
    steven.
 | 
					    steven.
 | 
				
			||||||
    SunlitSpace542
 | 
					    SunlitSpace542
 | 
				
			||||||
    Super Keeberghrh
 | 
					    Super Keeberghrh
 | 
				
			||||||
    theclashingfritz
 | 
					 | 
				
			||||||
    TheGag96
 | 
					    TheGag96
 | 
				
			||||||
    Victor Diego Alejandro Diaz Urbaneja
 | 
					    Victor Diego Alejandro Diaz Urbaneja
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -58,33 +58,33 @@ struct AudioSessionSettingsEU gAudioSessionPresets[] = {
 | 
				
			||||||
#ifndef VERSION_EU
 | 
					#ifndef VERSION_EU
 | 
				
			||||||
struct AudioSessionSettings gAudioSessionPresets[18] = {
 | 
					struct AudioSessionSettings gAudioSessionPresets[18] = {
 | 
				
			||||||
#ifdef VERSION_JP
 | 
					#ifdef VERSION_JP
 | 
				
			||||||
    { 32000, 32, 1, 0x0800, 0x2FFF, 0x7FFF, 0x0000E800, 0x0000E800, 0x0000E800, 0x0000E800 },
 | 
					    { 32000, 16, 1, 0x0800, 0x2FFF, 0x7FFF, 0x3900, 0x6000, 0x4400, 0x2A00 },
 | 
				
			||||||
    { 32000, 32, 1, 0x0A00, 0x47FF, 0x7FFF, 0x0000E800, 0x0000E800, 0x0000E800, 0x0000E800 },
 | 
					    { 32000, 16, 1, 0x0A00, 0x47FF, 0x7FFF, 0x3900, 0x6000, 0x4400, 0x2A00 },
 | 
				
			||||||
    { 32000, 32, 1, 0x1000, 0x2FFF, 0x7FFF, 0x0000E800, 0x0000E800, 0x0000E800, 0x0000E800 },
 | 
					    { 32000, 16, 1, 0x1000, 0x2FFF, 0x7FFF, 0x3900, 0x6000, 0x4400, 0x2A00 },
 | 
				
			||||||
    { 32000, 32, 1, 0x0E00, 0x3FFF, 0x7FFF, 0x0000E800, 0x0000E800, 0x0000E800, 0x0000E800 },
 | 
					    { 32000, 16, 1, 0x0E00, 0x3FFF, 0x7FFF, 0x3900, 0x6000, 0x4400, 0x2A00 },
 | 
				
			||||||
    { 32000, 32, 1, 0x0C00, 0x4FFF, 0x7FFF, 0x0000E800, 0x0000E800, 0x0000E800, 0x0000E800 },
 | 
					    { 32000, 16, 1, 0x0C00, 0x4FFF, 0x7FFF, 0x3900, 0x6000, 0x4400, 0x2A00 },
 | 
				
			||||||
    { 32000, 32, 1, 0x0800, 0x2FFF, 0x7FFF, 0x0000E800, 0x0000E800, 0x0000E800, 0x0000E800 },
 | 
					    { 32000, 16, 1, 0x0800, 0x2FFF, 0x7FFF, 0x3E00, 0x6200, 0x3F00, 0x2A00 },
 | 
				
			||||||
    { 32000, 32, 1, 0x0A00, 0x47FF, 0x7FFF, 0x0000E800, 0x0000E800, 0x0000E800, 0x0000E800 },
 | 
					    { 32000, 16, 1, 0x0A00, 0x47FF, 0x7FFF, 0x3F00, 0x6200, 0x4400, 0x2A80 },
 | 
				
			||||||
    { 32000, 40, 1, 0x0800, 0x37FF, 0x7FFF, 0x0000E800, 0x0000E800, 0x0000E800, 0x0000E800 },
 | 
					    { 32000, 20, 1, 0x0800, 0x37FF, 0x7FFF, 0x3300, 0x5500, 0x4000, 0x1B00 },
 | 
				
			||||||
#else
 | 
					#else
 | 
				
			||||||
    { 32000, 32, 1, 0x0C00, 0x2FFF, 0x7FFF, 0x0000E800, 0x0000E800, 0x0000E800, 0x0000E800 },
 | 
					    { 32000, 16, 1, 0x0C00, 0x2FFF, 0x7FFF, 0x7400, 0xCC00, 0x7400, 0x7400 },
 | 
				
			||||||
    { 32000, 32, 1, 0x0A00, 0x47FF, 0x7FFF, 0x0000E800, 0x0000E800, 0x0000E800, 0x0000E800 },
 | 
					    { 32000, 16, 1, 0x0A00, 0x47FF, 0x7FFF, 0x7400, 0xCC00, 0x7400, 0x7400 },
 | 
				
			||||||
    { 32000, 32, 1, 0x1000, 0x2FFF, 0x7FFF, 0x0000E800, 0x0000E800, 0x0000E800, 0x0000E800 },
 | 
					    { 32000, 16, 1, 0x1000, 0x2FFF, 0x7FFF, 0x7400, 0xCC00, 0x7400, 0x7400 },
 | 
				
			||||||
    { 32000, 32, 1, 0x0E00, 0x3FFF, 0x7FFF, 0x0000E800, 0x0000E800, 0x0000E800, 0x0000E800 },
 | 
					    { 32000, 16, 1, 0x0E00, 0x3FFF, 0x7FFF, 0x7400, 0xCC00, 0x7400, 0x7400 },
 | 
				
			||||||
    { 32000, 32, 1, 0x0C00, 0x4FFF, 0x7FFF, 0x0000E800, 0x0000E800, 0x0000E800, 0x0000E800 },
 | 
					    { 32000, 16, 1, 0x0C00, 0x4FFF, 0x7FFF, 0x7400, 0xCC00, 0x7400, 0x7400 },
 | 
				
			||||||
    { 32000, 32, 1, 0x0C00, 0x2FFF, 0x7FFF, 0x0000E800, 0x0000E800, 0x0000E800, 0x0000E800 },
 | 
					    { 32000, 16, 1, 0x0C00, 0x2FFF, 0x7FFF, 0x7400, 0xCC00, 0x7400, 0x7400 },
 | 
				
			||||||
    { 32000, 32, 1, 0x0A00, 0x47FF, 0x7FFF, 0x0000E800, 0x0000E800, 0x0000E800, 0x0000E800 },
 | 
					    { 32000, 16, 1, 0x0A00, 0x47FF, 0x7FFF, 0x7400, 0xCC00, 0x7400, 0x7400 },
 | 
				
			||||||
    { 32000, 40, 1, 0x0800, 0x37FF, 0x7FFF, 0x0000E800, 0x0000E800, 0x0000E800, 0x0000E800 },
 | 
					    { 32000, 20, 1, 0x0800, 0x37FF, 0x7FFF, 0x7400, 0xCC00, 0x7400, 0x7400 },
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
    { 27000, 32, 1, 0x0800, 0x2FFF, 0x7FFF, 0x0000E800, 0x0000E800, 0x0000E800, 0x0000E800 },
 | 
					    { 27000, 16, 1, 0x0800, 0x2FFF, 0x7FFF, 0x7400, 0x7400, 0x7400, 0x7400 },
 | 
				
			||||||
    { 27000, 32, 1, 0x0800, 0x3FFF, 0x7FFF, 0x0000E800, 0x0000E800, 0x0000E800, 0x0000E800 },
 | 
					    { 27000, 16, 1, 0x0800, 0x3FFF, 0x7FFF, 0x7400, 0x7400, 0x7400, 0x7400 },
 | 
				
			||||||
    { 27000, 32, 1, 0x1000, 0x2FFF, 0x7FFF, 0x0000E800, 0x0000E800, 0x0000E800, 0x0000E800 },
 | 
					    { 27000, 16, 1, 0x1000, 0x2FFF, 0x7FFF, 0x7400, 0x7400, 0x7400, 0x7400 },
 | 
				
			||||||
    { 27000, 32, 1, 0x1000, 0x3FFF, 0x7FFF, 0x0000E800, 0x0000E800, 0x0000E800, 0x0000E800 },
 | 
					    { 27000, 16, 1, 0x1000, 0x3FFF, 0x7FFF, 0x7400, 0x7400, 0x7400, 0x7400 },
 | 
				
			||||||
    { 27000, 32, 1, 0x0C00, 0x4FFF, 0x7FFF, 0x0000E800, 0x0000E800, 0x0000E800, 0x0000E800 },
 | 
					    { 27000, 16, 1, 0x0C00, 0x4FFF, 0x7FFF, 0x7400, 0x7400, 0x7400, 0x7400 },
 | 
				
			||||||
    { 32000, 28, 1, 0x0800, 0x2FFF, 0x7FFF, 0x0000E800, 0x0000E800, 0x0000E800, 0x0000E800 },
 | 
					    { 32000, 14, 1, 0x0800, 0x2FFF, 0x7FFF, 0x7400, 0x7400, 0x7400, 0x7400 },
 | 
				
			||||||
    { 32000, 24, 1, 0x0800, 0x2FFF, 0x7FFF, 0x0000E800, 0x0000E800, 0x0000E800, 0x0000E800 },
 | 
					    { 32000, 12, 1, 0x0800, 0x2FFF, 0x7FFF, 0x7400, 0x7400, 0x7400, 0x7400 },
 | 
				
			||||||
    { 32000, 20, 1, 0x0800, 0x2FFF, 0x7FFF, 0x0000E800, 0x0000E800, 0x0000E800, 0x0000E800 },
 | 
					    { 32000, 10, 1, 0x0800, 0x2FFF, 0x7FFF, 0x7400, 0x7400, 0x7400, 0x7400 },
 | 
				
			||||||
    { 32000, 16, 1, 0x0800, 0x2FFF, 0x7FFF, 0x0000E800, 0x0000E800, 0x0000E800, 0x0000E800 },
 | 
					    { 32000, 8, 1, 0x0800, 0x2FFF, 0x7FFF, 0x7400, 0x7400, 0x7400, 0x7400 },
 | 
				
			||||||
    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
 | 
					    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -110,11 +110,11 @@ extern u32 gAudioRandom;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#if defined(VERSION_EU) || defined(VERSION_SH)
 | 
					#if defined(VERSION_EU) || defined(VERSION_SH)
 | 
				
			||||||
#define UNUSED_COUNT_80333EE8 24
 | 
					#define UNUSED_COUNT_80333EE8 24
 | 
				
			||||||
#define AUDIO_HEAP_BASE 0x36B00
 | 
					#define AUDIO_HEAP_BASE 0x96B00
 | 
				
			||||||
#define AUDIO_INIT_POOL_SIZE (0x2c00 + EXT_AUDIO_INIT_POOL_SIZE)
 | 
					#define AUDIO_INIT_POOL_SIZE (0x2c00 + EXT_AUDIO_INIT_POOL_SIZE)
 | 
				
			||||||
#else
 | 
					#else
 | 
				
			||||||
#define UNUSED_COUNT_80333EE8 16
 | 
					#define UNUSED_COUNT_80333EE8 16
 | 
				
			||||||
#define AUDIO_HEAP_BASE 0x31150
 | 
					#define AUDIO_HEAP_BASE 0x8AED0
 | 
				
			||||||
#define AUDIO_INIT_POOL_SIZE (0x2500 + EXT_AUDIO_INIT_POOL_SIZE)
 | 
					#define AUDIO_INIT_POOL_SIZE (0x2500 + EXT_AUDIO_INIT_POOL_SIZE)
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -208,7 +208,7 @@ void *soundAlloc(struct SoundAllocPool *pool, u32 size) {
 | 
				
			||||||
        bzero(start, alignedSize);
 | 
					        bzero(start, alignedSize);
 | 
				
			||||||
        pool->cur += alignedSize;
 | 
					        pool->cur += alignedSize;
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
        fprintf(stderr, "soundAlloc failed: tried to alloc %u bytes (%i free)\n", ALIGN16(size), pool->start + pool->size - pool->cur);
 | 
					        fprintf(stderr, "soundAlloc failed: tried to alloc %u bytes at %p (%i free)\n", ALIGN16(size), (void*)pool, pool->start + pool->size - pool->cur);
 | 
				
			||||||
        return NULL;
 | 
					        return NULL;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    pool->numAllocatedEntries++;
 | 
					    pool->numAllocatedEntries++;
 | 
				
			||||||
| 
						 | 
					@ -221,7 +221,7 @@ void *soundAlloc(struct SoundAllocPool *pool, u32 size) {
 | 
				
			||||||
        bzero(start, alignedSize);
 | 
					        bzero(start, alignedSize);
 | 
				
			||||||
        pool->cur += alignedSize;
 | 
					        pool->cur += alignedSize;
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
        fprintf(stderr, "soundAlloc failed: tried to alloc %u bytes (%i free)\n", (unsigned int)ALIGN16(size), (int)(pool->start + pool->size - pool->cur));
 | 
					        fprintf(stderr, "soundAlloc failed: tried to alloc %u bytes at %p (%i free)\n", (unsigned int)ALIGN16(size), (void*)pool, (int)(pool->start + pool->size - pool->cur));
 | 
				
			||||||
        return NULL;
 | 
					        return NULL;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    return start;
 | 
					    return start;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -46,7 +46,9 @@ OSMesgQueue gAudioDmaMesgQueue;
 | 
				
			||||||
OSMesg gAudioDmaMesg;
 | 
					OSMesg gAudioDmaMesg;
 | 
				
			||||||
OSIoMesg gAudioDmaIoMesg;
 | 
					OSIoMesg gAudioDmaIoMesg;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct SharedDma sSampleDmas[0x60];
 | 
					#define SAMPLE_DMA_COUNT 0x90
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					struct SharedDma sSampleDmas[SAMPLE_DMA_COUNT];
 | 
				
			||||||
u32 gSampleDmaNumListItems;
 | 
					u32 gSampleDmaNumListItems;
 | 
				
			||||||
u32 sSampleDmaListSize1;
 | 
					u32 sSampleDmaListSize1;
 | 
				
			||||||
u32 sUnused80226B40; // set to 0, never read
 | 
					u32 sUnused80226B40; // set to 0, never read
 | 
				
			||||||
| 
						 | 
					@ -291,19 +293,12 @@ void *dma_sample_data(uintptr_t devAddr, u32 size, s32 arg2, u8 *arg3) {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void init_sample_dma_buffers(UNUSED s32 arg0) {
 | 
					void init_sample_dma_buffers(UNUSED s32 arg0) {
 | 
				
			||||||
    s32 i;
 | 
					 | 
				
			||||||
#ifdef VERSION_EU
 | 
					 | 
				
			||||||
#define j i
 | 
					 | 
				
			||||||
#else
 | 
					 | 
				
			||||||
    s32 j;
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#ifdef VERSION_EU
 | 
					#ifdef VERSION_EU
 | 
				
			||||||
    sDmaBufSize = 0x400 * 4;
 | 
					    sDmaBufSize = 0x400 * 4;
 | 
				
			||||||
    for (i = 0; i < gMaxSimultaneousNotes * 3 * gAudioBufferParameters.presetUnk4; i++) {
 | 
					    for (s32 i = 0; i < gMaxSimultaneousNotes * 3 * gAudioBufferParameters.presetUnk4; i++) {
 | 
				
			||||||
#else
 | 
					#else
 | 
				
			||||||
    sDmaBufSize = (144 * 9) * 4;
 | 
					    sDmaBufSize = (144 * 9) * 4;
 | 
				
			||||||
    for (i = 0; i < gMaxSimultaneousNotes * 3; i++) {
 | 
					    for (s32 i = 0; i < gMaxSimultaneousNotes * 3; i++) {
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
        sSampleDmas[gSampleDmaNumListItems].buffer = soundAlloc(&gNotesAndBuffersPool, sDmaBufSize);
 | 
					        sSampleDmas[gSampleDmaNumListItems].buffer = soundAlloc(&gNotesAndBuffersPool, sDmaBufSize);
 | 
				
			||||||
        if (sSampleDmas[gSampleDmaNumListItems].buffer == NULL) {
 | 
					        if (sSampleDmas[gSampleDmaNumListItems].buffer == NULL) {
 | 
				
			||||||
| 
						 | 
					@ -324,12 +319,12 @@ void init_sample_dma_buffers(UNUSED s32 arg0) {
 | 
				
			||||||
out1:
 | 
					out1:
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    for (i = 0; (u32) i < gSampleDmaNumListItems; i++) {
 | 
					    for (s32 i = 0; (u32) i < gSampleDmaNumListItems; i++) {
 | 
				
			||||||
        sSampleDmaReuseQueue1[i] = (u8) i;
 | 
					        sSampleDmaReuseQueue1[i] = (u8) i;
 | 
				
			||||||
        sSampleDmas[i].reuseIndex = (u8) i;
 | 
					        sSampleDmas[i].reuseIndex = (u8) i;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    for (j = gSampleDmaNumListItems; j < 0x100; j++) {
 | 
					    for (s32 j = gSampleDmaNumListItems; j < 0x100; j++) {
 | 
				
			||||||
        sSampleDmaReuseQueue1[j] = 0;
 | 
					        sSampleDmaReuseQueue1[j] = 0;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -342,7 +337,7 @@ out1:
 | 
				
			||||||
#else
 | 
					#else
 | 
				
			||||||
    sDmaBufSize = (160 * 9) * 4;
 | 
					    sDmaBufSize = (160 * 9) * 4;
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
    for (i = 0; i < gMaxSimultaneousNotes; i++) {
 | 
					    for (s32 i = 0; i < gMaxSimultaneousNotes; i++) {
 | 
				
			||||||
        sSampleDmas[gSampleDmaNumListItems].buffer = soundAlloc(&gNotesAndBuffersPool, sDmaBufSize);
 | 
					        sSampleDmas[gSampleDmaNumListItems].buffer = soundAlloc(&gNotesAndBuffersPool, sDmaBufSize);
 | 
				
			||||||
        if (sSampleDmas[gSampleDmaNumListItems].buffer == NULL) {
 | 
					        if (sSampleDmas[gSampleDmaNumListItems].buffer == NULL) {
 | 
				
			||||||
#ifdef VERSION_EU
 | 
					#ifdef VERSION_EU
 | 
				
			||||||
| 
						 | 
					@ -362,14 +357,14 @@ out1:
 | 
				
			||||||
out2:
 | 
					out2:
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    for (i = sSampleDmaListSize1; (u32) i < gSampleDmaNumListItems; i++) {
 | 
					    for (s32 i = sSampleDmaListSize1; (u32) i < gSampleDmaNumListItems; i++) {
 | 
				
			||||||
        sSampleDmaReuseQueue2[i - sSampleDmaListSize1] = (u8) i;
 | 
					        sSampleDmaReuseQueue2[i - sSampleDmaListSize1] = (u8) i;
 | 
				
			||||||
        sSampleDmas[i].reuseIndex = (u8)(i - sSampleDmaListSize1);
 | 
					        sSampleDmas[i].reuseIndex = (u8)(i - sSampleDmaListSize1);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // This probably meant to touch the range size1..size2 as well... but it
 | 
					    // This probably meant to touch the range size1..size2 as well... but it
 | 
				
			||||||
    // doesn't matter, since these values are never read anyway.
 | 
					    // doesn't matter, since these values are never read anyway.
 | 
				
			||||||
    for (j = gSampleDmaNumListItems; j < 0x100; j++) {
 | 
					    for (s32 j = gSampleDmaNumListItems; j < 0x100; j++) {
 | 
				
			||||||
        sSampleDmaReuseQueue2[j] = sSampleDmaListSize1;
 | 
					        sSampleDmaReuseQueue2[j] = sSampleDmaListSize1;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue