mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2024-11-25 05:25:14 +00:00
Fix strange audio bugs on 32-bit
increase audio heap size, fix buffer overflow reading gBankSetsData, warn on soundAlloc failure Provided by: camthesaxman
This commit is contained in:
parent
e95a1d48e0
commit
fc8bb5e6bd
6 changed files with 23 additions and 20 deletions
|
@ -60,14 +60,14 @@ struct AudioSessionSettings gAudioSessionPresets[18] = {
|
|||
{ 32000, 16, 1, 0x0A00, 0x47FF, 0x7FFF, 0x3F00, 0x6200, 0x4400, 0x2A80 },
|
||||
{ 32000, 20, 1, 0x0800, 0x37FF, 0x7FFF, 0x3300, 0x5500, 0x4000, 0x1B00 },
|
||||
#else
|
||||
{ 32000, 16, 1, 0x0C00, 0x2FFF, 0x7FFF, 0x7400, 0x7400, 0x7400, 0x7400 },
|
||||
{ 32000, 16, 1, 0x0A00, 0x47FF, 0x7FFF, 0x7400, 0x7400, 0x7400, 0x7400 },
|
||||
{ 32000, 16, 1, 0x1000, 0x2FFF, 0x7FFF, 0x7400, 0x7400, 0x7400, 0x7400 },
|
||||
{ 32000, 16, 1, 0x0E00, 0x3FFF, 0x7FFF, 0x7400, 0x7400, 0x7400, 0x7400 },
|
||||
{ 32000, 16, 1, 0x0C00, 0x4FFF, 0x7FFF, 0x7400, 0x7400, 0x7400, 0x7400 },
|
||||
{ 32000, 16, 1, 0x0C00, 0x2FFF, 0x7FFF, 0x7400, 0x7400, 0x7400, 0x7400 },
|
||||
{ 32000, 16, 1, 0x0A00, 0x47FF, 0x7FFF, 0x7400, 0x7400, 0x7400, 0x7400 },
|
||||
{ 32000, 20, 1, 0x0800, 0x37FF, 0x7FFF, 0x7400, 0x7400, 0x7400, 0x7400 },
|
||||
{ 32000, 16, 1, 0x0C00, 0x2FFF, 0x7FFF, 0x7400, 0xA000, 0x7400, 0x7400 },
|
||||
{ 32000, 16, 1, 0x0A00, 0x47FF, 0x7FFF, 0x7400, 0xA000, 0x7400, 0x7400 },
|
||||
{ 32000, 16, 1, 0x1000, 0x2FFF, 0x7FFF, 0x7400, 0xA000, 0x7400, 0x7400 },
|
||||
{ 32000, 16, 1, 0x0E00, 0x3FFF, 0x7FFF, 0x7400, 0xA000, 0x7400, 0x7400 },
|
||||
{ 32000, 16, 1, 0x0C00, 0x4FFF, 0x7FFF, 0x7400, 0xA000, 0x7400, 0x7400 },
|
||||
{ 32000, 16, 1, 0x0C00, 0x2FFF, 0x7FFF, 0x7400, 0xA000, 0x7400, 0x7400 },
|
||||
{ 32000, 16, 1, 0x0A00, 0x47FF, 0x7FFF, 0x7400, 0xA000, 0x7400, 0x7400 },
|
||||
{ 32000, 20, 1, 0x0800, 0x37FF, 0x7FFF, 0x7400, 0xA000, 0x7400, 0x7400 },
|
||||
#endif
|
||||
{ 27000, 16, 1, 0x0800, 0x2FFF, 0x7FFF, 0x7400, 0x7400, 0x7400, 0x7400 },
|
||||
{ 27000, 16, 1, 0x0800, 0x3FFF, 0x7FFF, 0x7400, 0x7400, 0x7400, 0x7400 },
|
||||
|
@ -583,8 +583,8 @@ f32 gVolRampingRhs128[128] = {
|
|||
|
||||
s16 gTatumsPerBeat = TATUMS_PER_BEAT;
|
||||
s8 gUnusedCount80333EE8 = UNUSED_COUNT_80333EE8;
|
||||
s32 gAudioHeapSize = DOUBLE_SIZE_ON_64_BIT(AUDIO_HEAP_SIZE);
|
||||
s32 D_80333EF0 = DOUBLE_SIZE_ON_64_BIT(D_80333EF0_VAL);
|
||||
s32 gAudioHeapSize = AUDIO_HEAP_SIZE;
|
||||
s32 D_80333EF0 = D_80333EF0_VAL;
|
||||
volatile s32 gAudioLoadLock = AUDIO_LOCK_UNINITIALIZED;
|
||||
|
||||
#ifdef VERSION_EU
|
||||
|
|
|
@ -106,12 +106,12 @@ extern u32 gAudioRandom;
|
|||
//make my life easier
|
||||
#ifdef VERSION_EU
|
||||
#define UNUSED_COUNT_80333EE8 24
|
||||
#define AUDIO_HEAP_SIZE 0x2c500
|
||||
#define D_80333EF0_VAL 0x2c00
|
||||
#define AUDIO_HEAP_SIZE DOUBLE_SIZE_ON_64_BIT(0x2c500)
|
||||
#define D_80333EF0_VAL DOUBLE_SIZE_ON_64_BIT(0x2c00)
|
||||
#else
|
||||
#define UNUSED_COUNT_80333EE8 16
|
||||
#define AUDIO_HEAP_SIZE 0x31150
|
||||
#define D_80333EF0_VAL 0x2500
|
||||
#define AUDIO_HEAP_SIZE DOUBLE_SIZE_ON_64_BIT(0x48000)
|
||||
#define D_80333EF0_VAL DOUBLE_SIZE_ON_64_BIT(0x2500)
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#include <ultra64.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "heap.h"
|
||||
#include "data.h"
|
||||
|
@ -209,6 +210,8 @@ void *soundAlloc(struct SoundAllocPool *pool, u32 size) {
|
|||
*pos = 0;
|
||||
}
|
||||
} else {
|
||||
fprintf(stderr, "soundAlloc failed: tried to alloc %u bytes (%i free)\n",
|
||||
ALIGN16(size), pool->start + pool->size - pool->cur);
|
||||
return NULL;
|
||||
}
|
||||
return start;
|
||||
|
@ -225,6 +228,8 @@ void *soundAlloc(struct SoundAllocPool *pool, u32 size) {
|
|||
start[i] = 0;
|
||||
}
|
||||
} else {
|
||||
fprintf(stderr, "soundAlloc failed: tried to alloc %u bytes (%i free)\n",
|
||||
(unsigned int)ALIGN16(size), (int)(pool->start + pool->size - pool->cur));
|
||||
return NULL;
|
||||
}
|
||||
return start;
|
||||
|
|
|
@ -1,13 +1,10 @@
|
|||
#include <ultra64.h>
|
||||
|
||||
#include "buffers.h"
|
||||
#include "audio/data.h"
|
||||
|
||||
ALIGNED8 u8 gDecompressionHeap[0xD000];
|
||||
#if defined(VERSION_EU) || defined(VERSION_SH)
|
||||
ALIGNED16 u8 gAudioHeap[DOUBLE_SIZE_ON_64_BIT(0x31200) - 0x3800];
|
||||
#else
|
||||
ALIGNED16 u8 gAudioHeap[DOUBLE_SIZE_ON_64_BIT(0x31200)];
|
||||
#endif
|
||||
ALIGNED16 u8 gAudioHeap[AUDIO_HEAP_SIZE];
|
||||
|
||||
ALIGNED8 u8 gIdleThreadStack[0x800];
|
||||
ALIGNED8 u8 gThread3Stack[0x2000];
|
||||
|
|
|
@ -307,7 +307,7 @@ static bool gfx_texture_cache_lookup(int tile, struct TextureHashmapNode **n, co
|
|||
hash = (hash >> HASH_SHIFT) & HASH_MASK;
|
||||
|
||||
struct TextureHashmapNode **node = &gfx_texture_cache.hashmap[hash];
|
||||
while (*node != NULL && *node - gfx_texture_cache.pool < gfx_texture_cache.pool_pos) {
|
||||
while (*node != NULL && *node - gfx_texture_cache.pool < (int)gfx_texture_cache.pool_pos) {
|
||||
if (CMPADDR((*node)->texture_addr, orig_addr) && (*node)->fmt == fmt && (*node)->siz == siz) {
|
||||
gfx_rapi->select_texture(tile, (*node)->texture_id);
|
||||
*n = *node;
|
||||
|
|
|
@ -339,6 +339,7 @@ void main_func(void) {
|
|||
#endif
|
||||
#ifdef DEBUG
|
||||
fflush(stdout);
|
||||
fflush(stderr);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue