From 9be9a47b824e3cdc45952e21ccb6e59664a4efe5 Mon Sep 17 00:00:00 2001 From: gheskett Date: Mon, 12 Jul 2021 19:16:06 -0500 Subject: [PATCH] Expand audio heap --- README.md | 1 + include/config.h | 2 ++ src/audio/data.c | 34 ++++++++++++++++++++++++++++++++++ src/audio/data.h | 22 ++++++++++++++++++---- src/buffers/buffers.c | 7 ++++--- 5 files changed, 59 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 35dc5b0e..88272861 100644 --- a/README.md +++ b/README.md @@ -43,6 +43,7 @@ This is a fork of the ultrasm64 repo by CrashOveride which includes the followin - Included `actors/group0.c` in `behavior_data.c` - The internal ROM name is now set with a define in `config.h` to make it simpler - There is a `gIsConsole` variable that is 1 when running on console and 0 when running on emulator. This way you can wrap your code in a console check. +- Expanded audio heap allows for a larger concurrent note count and the importing of more m64 sequences and sound banks (By ArcticJaguar725) **Other Bugfixes:** - Castle music fix (Fixes the castle music sometimes triggering after getting a dialog) * diff --git a/include/config.h b/include/config.h index 0a233f3a..e6193d32 100644 --- a/include/config.h +++ b/include/config.h @@ -91,6 +91,8 @@ #define NO_FALSE_LEDGEGRABS // Number of possible unique model ID's (keep it higher than 256) #define MODEL_ID_COUNT 256 +// Increase audio heap size to allow for more concurrent notes to be played and for more custom sequences/banks to be imported (does nothing with EU and SH versions) +#define EXPAND_AUDIO_HEAP // BUG/GAME QOL FIXES // Fix instant warp offset not working when warping across different areas diff --git a/src/audio/data.c b/src/audio/data.c index 4fdc13e5..3fa09d9e 100644 --- a/src/audio/data.c +++ b/src/audio/data.c @@ -49,6 +49,39 @@ struct AudioSessionSettingsEU gAudioSessionPresets[] = { // - memory used for temporary sequences // - memory used for temporary banks #if defined(VERSION_JP) || defined(VERSION_US) +#ifdef EXPAND_AUDIO_HEAP +struct AudioSessionSettings gAudioSessionPresets[18] = { +#ifdef VERSION_JP + { 32000, 32, 1, 0x0800, 0x2FFF, 0x7FFF, 0x7200, 0xC000, 0x8800, 0x5400 }, + { 32000, 32, 1, 0x0A00, 0x47FF, 0x7FFF, 0x7200, 0xC000, 0x8800, 0x5400 }, + { 32000, 32, 1, 0x1000, 0x2FFF, 0x7FFF, 0x7200, 0xC000, 0x8800, 0x5400 }, + { 32000, 32, 1, 0x0E00, 0x3FFF, 0x7FFF, 0x7200, 0xC000, 0x8800, 0x5400 }, + { 32000, 32, 1, 0x0C00, 0x4FFF, 0x7FFF, 0x7200, 0xC000, 0x8800, 0x5400 }, + { 32000, 32, 1, 0x0800, 0x2FFF, 0x7FFF, 0x7C00, 0xC400, 0x7E00, 0x5400 }, + { 32000, 32, 1, 0x0A00, 0x47FF, 0x7FFF, 0x7E00, 0xC400, 0x8800, 0x5500 }, + { 32000, 40, 1, 0x0800, 0x37FF, 0x7FFF, 0x6600, 0xAA00, 0x8000, 0x3600 }, +#else + { 32000, 32, 1, 0x0C00, 0x2FFF, 0x7FFF, 0x7400, 0xDA00, 0x8800, 0x5400 }, + { 32000, 32, 1, 0x0A00, 0x47FF, 0x7FFF, 0x7400, 0xDA00, 0x8800, 0x5400 }, + { 32000, 32, 1, 0x1000, 0x2FFF, 0x7FFF, 0x7400, 0xDA00, 0x8800, 0x5400 }, + { 32000, 32, 1, 0x0E00, 0x3FFF, 0x7FFF, 0x7400, 0xDA00, 0x8800, 0x5400 }, + { 32000, 32, 1, 0x0C00, 0x4FFF, 0x7FFF, 0x7400, 0xDA00, 0x8800, 0x5400 }, + { 32000, 32, 1, 0x0C00, 0x2FFF, 0x7FFF, 0x8000, 0xDC00, 0x7E00, 0x5400 }, + { 32000, 32, 1, 0x0A00, 0x47FF, 0x7FFF, 0x8200, 0xDC00, 0x8800, 0x5500 }, + { 32000, 40, 1, 0x0800, 0x37FF, 0x7FFF, 0x6980, 0xC500, 0x8000, 0x3600 }, +#endif + { 27000, 32, 1, 0x0800, 0x2FFF, 0x7FFF, 0x4A00, 0xAA00, 0xE800, 0x4800 }, + { 27000, 32, 1, 0x0800, 0x3FFF, 0x7FFF, 0x4A00, 0xAA00, 0xE800, 0x4800 }, + { 27000, 32, 1, 0x1000, 0x2FFF, 0x7FFF, 0x4A00, 0xAA00, 0xE800, 0x4800 }, + { 27000, 32, 1, 0x1000, 0x3FFF, 0x7FFF, 0x4A00, 0xAA00, 0xE800, 0x4800 }, + { 27000, 32, 1, 0x0C00, 0x4FFF, 0x7FFF, 0x4A00, 0xAA00, 0xE800, 0x4800 }, + { 32000, 28, 1, 0x0800, 0x2FFF, 0x7FFF, 0x4A00, 0xAA00, 0xE800, 0x4800 }, + { 32000, 24, 1, 0x0800, 0x2FFF, 0x7FFF, 0x4A00, 0xAA00, 0xE800, 0x4800 }, + { 32000, 20, 1, 0x0800, 0x2FFF, 0x7FFF, 0x4A00, 0xAA00, 0xE800, 0x4800 }, + { 32000, 16, 1, 0x0800, 0x2FFF, 0x7FFF, 0x4A00, 0xAA00, 0xE800, 0x4800 }, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } +}; +#else struct AudioSessionSettings gAudioSessionPresets[18] = { #ifdef VERSION_JP { 32000, 16, 1, 0x0800, 0x2FFF, 0x7FFF, 0x3900, 0x6000, 0x4400, 0x2A00 }, @@ -81,6 +114,7 @@ struct AudioSessionSettings gAudioSessionPresets[18] = { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }; #endif +#endif // gAudioCosineTable[k] = round((2**15 - 1) * cos(pi/2 * k / 127)). Unused. #if defined(VERSION_JP) || defined(VERSION_US) u16 gAudioCosineTable[128] = { diff --git a/src/audio/data.h b/src/audio/data.h index ee8b30b1..cf19472d 100644 --- a/src/audio/data.h +++ b/src/audio/data.h @@ -109,6 +109,20 @@ extern u16 gUnused80226E98[0x10]; extern u32 gAudioRandom; +#ifdef EXPAND_AUDIO_HEAP +#if defined(VERSION_US) || defined(VERSION_JP) +#define EXT_AUDIO_HEAP_SIZE 0x24400 +#define EXT_AUDIO_INIT_POOL_SIZE 0x8000 +#else +// EU and SH versions not yet supported for extended audio heap +#define EXT_AUDIO_HEAP_SIZE 0x0 +#define EXT_AUDIO_INIT_POOL_SIZE 0x0 +#endif +#else +#define EXT_AUDIO_HEAP_SIZE 0x0 +#define EXT_AUDIO_INIT_POOL_SIZE 0x0 +#endif + #ifdef VERSION_SH extern f32 unk_sh_data_1[]; @@ -136,12 +150,12 @@ extern OSMesgQueue *D_SH_80350FA8; #if defined(VERSION_EU) || defined(VERSION_SH) #define UNUSED_COUNT_80333EE8 24 -#define AUDIO_HEAP_SIZE 0x2c500 -#define AUDIO_INIT_POOL_SIZE 0x2c00 +#define AUDIO_HEAP_SIZE (0x2c500 + EXT_AUDIO_HEAP_SIZE + EXT_AUDIO_INIT_POOL_SIZE) +#define AUDIO_INIT_POOL_SIZE (0x2c00 + EXT_AUDIO_INIT_POOL_SIZE) #else #define UNUSED_COUNT_80333EE8 16 -#define AUDIO_HEAP_SIZE 0x31150 -#define AUDIO_INIT_POOL_SIZE 0x2500 +#define AUDIO_HEAP_SIZE (0x31150 + EXT_AUDIO_HEAP_SIZE + EXT_AUDIO_INIT_POOL_SIZE) +#define AUDIO_INIT_POOL_SIZE (0x2500 + EXT_AUDIO_INIT_POOL_SIZE) #endif #ifdef VERSION_SH diff --git a/src/buffers/buffers.c b/src/buffers/buffers.c index d37193e8..770c3117 100644 --- a/src/buffers/buffers.c +++ b/src/buffers/buffers.c @@ -2,6 +2,7 @@ #include #include "buffers.h" +#include "audio/data.h" #ifdef HVQM #include #endif @@ -9,11 +10,11 @@ ALIGNED8 u8 gDecompressionHeap[0xD000]; #if defined(VERSION_EU) -ALIGNED16 u8 gAudioHeap[DOUBLE_SIZE_ON_64_BIT(0x31200) - 0x3800]; +ALIGNED16 u8 gAudioHeap[DOUBLE_SIZE_ON_64_BIT(0x31200 + EXT_AUDIO_HEAP_SIZE + EXT_AUDIO_INIT_POOL_SIZE) - 0x3800]; #elif defined(VERSION_SH) -ALIGNED16 u8 gAudioHeap[DOUBLE_SIZE_ON_64_BIT(0x31200) - 0x4800]; +ALIGNED16 u8 gAudioHeap[DOUBLE_SIZE_ON_64_BIT(0x31200 + EXT_AUDIO_HEAP_SIZE + EXT_AUDIO_INIT_POOL_SIZE) - 0x4800]; #else -ALIGNED16 u8 gAudioHeap[DOUBLE_SIZE_ON_64_BIT(0x31200)]; +ALIGNED16 u8 gAudioHeap[DOUBLE_SIZE_ON_64_BIT(0x31200 + EXT_AUDIO_HEAP_SIZE + EXT_AUDIO_INIT_POOL_SIZE)]; #endif ALIGNED8 u8 gIdleThreadStack[0x800];