Add more audio banks and add some occasional mappings for audio macros (#777)

* Add more audio banks and add some occasional mappings for audio macros

* Remove config define for extra sound banks

---------

Co-authored-by: gheskett <gheskett@gmail.com>
This commit is contained in:
Reonu
2024-07-03 22:30:21 +01:00
committed by Gregory Heskett
parent 4500ffb579
commit aacf2c5e6d
3 changed files with 123 additions and 23 deletions

View File

@@ -36,15 +36,27 @@ enum SoundBank {
SOUND_BANK_MENU, SOUND_BANK_MENU,
SOUND_BANK_GENERAL2, SOUND_BANK_GENERAL2,
SOUND_BANK_OBJ2, SOUND_BANK_OBJ2,
SOUND_BANK_CUSTOM_FOREGROUND_1,
SOUND_BANK_CUSTOM_FOREGROUND_2,
SOUND_BANK_CUSTOM_FOREGROUND_3,
SOUND_BANK_CUSTOM_BACKGROUND_1,
SOUND_BANK_CUSTOM_BACKGROUND_2,
SOUND_BANK_CUSTOM_BACKGROUND_3,
SOUND_BANK_COUNT SOUND_BANK_COUNT
}; };
#define SOUND_BANKS_ALL_BITS 0xffff #define SOUND_BANKS_ALL_BITS 0xffff
#define SOUND_BANKS_ALL ((1 << SOUND_BANK_COUNT) - 1) #define SOUND_BANKS_ALL ((1 << SOUND_BANK_COUNT) - 1)
#define SOUND_BANKS_FOREGROUND (\ #define SOUND_BANKS_FOREGROUND (\
(1 << SOUND_BANK_ACTION) |\ (1 << SOUND_BANK_ACTION) |\
(1 << SOUND_BANK_VOICE) |\ (1 << SOUND_BANK_VOICE) |\
(1 << SOUND_BANK_MENU)) (1 << SOUND_BANK_MENU) |\
(1 << SOUND_BANK_CUSTOM_FOREGROUND_1) |\
(1 << SOUND_BANK_CUSTOM_FOREGROUND_2) |\
(1 << SOUND_BANK_CUSTOM_FOREGROUND_3))
#define SOUND_BANKS_BACKGROUND (SOUND_BANKS_ALL & ~SOUND_BANKS_FOREGROUND) #define SOUND_BANKS_BACKGROUND (SOUND_BANKS_ALL & ~SOUND_BANKS_FOREGROUND)
#define SOUND_BANKS_DISABLED_DURING_INTRO_CUTSCENE (\ #define SOUND_BANKS_DISABLED_DURING_INTRO_CUTSCENE (\
(1 << SOUND_BANK_ENV) |\ (1 << SOUND_BANK_ENV) |\
@@ -589,4 +601,6 @@ enum SoundBank {
#define SOUND_OBJ2_BOSS_DIALOG_GRUNT /* 0x90694081 */ SOUND_ARG_LOAD(SOUND_BANK_OBJ2, 0x69, 0x40, SOUND_DISCRETE) #define SOUND_OBJ2_BOSS_DIALOG_GRUNT /* 0x90694081 */ SOUND_ARG_LOAD(SOUND_BANK_OBJ2, 0x69, 0x40, SOUND_DISCRETE)
#define SOUND_OBJ2_MRI_SPINNING /* 0x906B0081 */ SOUND_ARG_LOAD(SOUND_BANK_OBJ2, 0x6B, 0x00, SOUND_DISCRETE) #define SOUND_OBJ2_MRI_SPINNING /* 0x906B0081 */ SOUND_ARG_LOAD(SOUND_BANK_OBJ2, 0x6B, 0x00, SOUND_DISCRETE)
// Add defines for sounds using extra custom banks here!
#endif // SOUNDS_H #endif // SOUNDS_H

View File

@@ -12,7 +12,7 @@ seq_setmutescale 0
seq_setvol 127 seq_setvol 127
#endif #endif
seq_settempo 120 seq_settempo 120
seq_initchannels 0x3ff seq_initchannels 0xffff
seq_startchannel 0, .channel0 seq_startchannel 0, .channel0
seq_startchannel 1, .channel1 seq_startchannel 1, .channel1
seq_startchannel 2, .channel2 seq_startchannel 2, .channel2
@@ -23,6 +23,12 @@ seq_startchannel 6, .channel6
seq_startchannel 7, .channel7 seq_startchannel 7, .channel7
seq_startchannel 8, .channel38 seq_startchannel 8, .channel38
seq_startchannel 9, .channel59 seq_startchannel 9, .channel59
seq_startchannel 10, .channelA
seq_startchannel 11, .channelB
seq_startchannel 12, .channelC
seq_startchannel 13, .channelD
seq_startchannel 14, .channelE
seq_startchannel 15, .channelF
.seq_loop: .seq_loop:
seq_delay 20000 seq_delay 20000
seq_jump .seq_loop seq_jump .seq_loop
@@ -71,6 +77,72 @@ chan_stereoheadseteffects 1
chan_setdyntable .channel59_table chan_setdyntable .channel59_table
chan_jump .main_loop_023589 chan_jump .main_loop_023589
.channelA:
chan_largenoteson
chan_setinstr 0
chan_setpanmix 127
chan_setnotepriority 14
chan_setval 0
chan_iowriteval 5
chan_stereoheadseteffects 1
chan_setdyntable .channelA_table
chan_jump .main_loop_023589
.channelB:
chan_largenoteson
chan_setinstr 0
chan_setpanmix 127
chan_setnotepriority 14
chan_setval 0
chan_iowriteval 5
chan_stereoheadseteffects 1
chan_setdyntable .channelB_table
chan_jump .main_loop_023589
.channelC:
chan_largenoteson
chan_setinstr 0
chan_setpanmix 127
chan_setnotepriority 14
chan_setval 0
chan_iowriteval 5
chan_stereoheadseteffects 1
chan_setdyntable .channelC_table
chan_jump .main_loop_023589
.channelD:
chan_largenoteson
chan_setinstr 0
chan_setpanmix 127
chan_setnotepriority 14
chan_setval 0
chan_iowriteval 5
chan_stereoheadseteffects 1
chan_setdyntable .channelD_table
chan_jump .main_loop_023589
.channelE:
chan_largenoteson
chan_setinstr 0
chan_setpanmix 127
chan_setnotepriority 14
chan_setval 0
chan_iowriteval 5
chan_stereoheadseteffects 1
chan_setdyntable .channelE_table
chan_jump .main_loop_023589
.channelF:
chan_largenoteson
chan_setinstr 0
chan_setpanmix 127
chan_setnotepriority 14
chan_setval 0
chan_iowriteval 5
chan_stereoheadseteffects 1
chan_setdyntable .channelF_table
chan_jump .main_loop_023589
// Main loop for standard, non-continuous sound effects // Main loop for standard, non-continuous sound effects
.main_loop_023589: .main_loop_023589:
chan_hang chan_hang
@@ -7903,6 +7975,31 @@ layer_note0 38, 0x3, 127, 127
layer_delay 0x2a layer_delay 0x2a
layer_jump .layer_32B7 layer_jump .layer_32B7
.channelA_table:
// Add custom sounds for Channel A here!
.channelB_table:
// Add custom sounds for Channel B here!
.channelC_table:
// Add custom sounds for Channel C here!
.channelD_table:
// Add custom sounds for Channel D here!
.channelE_table:
// Add custom sounds for Channel E here!
.channelF_table:
// Add custom sounds for Channel F here!
.align 2, 0 .align 2, 0
.envelope_32C4: .envelope_32C4:
envelope_line 7 20000 envelope_line 7 20000

View File

@@ -313,10 +313,10 @@ STATIC_ASSERT(ARRAY_COUNT(sBackgroundMusicDefaultVolume) == SEQ_COUNT,
u8 sCurrentBackgroundMusicSeqId = SEQUENCE_NONE; u8 sCurrentBackgroundMusicSeqId = SEQUENCE_NONE;
u8 sMusicDynamicDelay = 0; u8 sMusicDynamicDelay = 0;
u8 sSoundBankUsedListBack[SOUND_BANK_COUNT] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; u8 sSoundBankUsedListBack[SOUND_BANK_COUNT] = {[0 ... SOUND_BANK_COUNT-1] = 0};
u8 sSoundBankFreeListFront[SOUND_BANK_COUNT] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }; u8 sSoundBankFreeListFront[SOUND_BANK_COUNT] = {[0 ... SOUND_BANK_COUNT-1] = 1};
u8 sNumSoundsInBank[SOUND_BANK_COUNT] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; // only used for debugging u8 sNumSoundsInBank[SOUND_BANK_COUNT] = {[0 ... SOUND_BANK_COUNT-1] = 0}; // only used for debugging
u8 sMaxChannelsForSoundBank[SOUND_BANK_COUNT] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }; u8 sMaxChannelsForSoundBank[SOUND_BANK_COUNT] = {[0 ... SOUND_BANK_COUNT-1] = 1};
// sBackgroundMusicMaxTargetVolume and sBackgroundMusicTargetVolume use the 0x80 // sBackgroundMusicMaxTargetVolume and sBackgroundMusicTargetVolume use the 0x80
// bit to indicate that they are set, and the rest of the bits for the actual value // bit to indicate that they are set, and the rest of the bits for the actual value
@@ -347,8 +347,7 @@ struct UnkStruct80343D00 D_SH_80343D00;
#endif #endif
struct Sound sSoundRequests[0x100]; struct Sound sSoundRequests[0x100];
// Curiously, this has size 3, despite SEQUENCE_PLAYERS == 4 on EU struct ChannelVolumeScaleFade D_80360928[SEQUENCE_PLAYERS][CHANNELS_MAX];
struct ChannelVolumeScaleFade D_80360928[3][CHANNELS_MAX];
u8 sUsedChannelsForSoundBank[SOUND_BANK_COUNT]; u8 sUsedChannelsForSoundBank[SOUND_BANK_COUNT];
u8 sCurrentSound[SOUND_BANK_COUNT][MAX_CHANNELS_PER_SOUND_BANK]; // index into sSoundBanks u8 sCurrentSound[SOUND_BANK_COUNT][MAX_CHANNELS_PER_SOUND_BANK]; // index into sSoundBanks
@@ -1341,12 +1340,7 @@ static void update_game_sound(void) {
get_sound_reverb(bank, soundIndex, channelIndex); get_sound_reverb(bank, soundIndex, channelIndex);
#endif #endif
break; break;
case SOUND_BANK_GENERAL: default:
case SOUND_BANK_ENV:
case SOUND_BANK_OBJ:
case SOUND_BANK_AIR:
case SOUND_BANK_GENERAL2:
case SOUND_BANK_OBJ2:
#if defined(VERSION_EU) || defined(VERSION_SH) #if defined(VERSION_EU) || defined(VERSION_SH)
func_802ad770(0x05020000 | ((channelIndex & 0xff) << 8), func_802ad770(0x05020000 | ((channelIndex & 0xff) << 8),
get_sound_reverb(bank, soundIndex, channelIndex)); get_sound_reverb(bank, soundIndex, channelIndex));
@@ -1507,12 +1501,7 @@ static void update_game_sound(void) {
get_sound_reverb(bank, soundIndex, channelIndex); get_sound_reverb(bank, soundIndex, channelIndex);
#endif #endif
break; break;
case SOUND_BANK_GENERAL: default:
case SOUND_BANK_ENV:
case SOUND_BANK_OBJ:
case SOUND_BANK_AIR:
case SOUND_BANK_GENERAL2:
case SOUND_BANK_OBJ2:
#if defined(VERSION_EU) || defined(VERSION_SH) #if defined(VERSION_EU) || defined(VERSION_SH)
func_802ad770(0x05020000 | ((channelIndex & 0xff) << 8), func_802ad770(0x05020000 | ((channelIndex & 0xff) << 8),
get_sound_reverb(bank, soundIndex, channelIndex)); get_sound_reverb(bank, soundIndex, channelIndex));
@@ -1952,7 +1941,7 @@ void sound_init(void) {
for (i = 0; i < SOUND_BANK_COUNT; i++) { for (i = 0; i < SOUND_BANK_COUNT; i++) {
// Set each sound in the bank to STOPPED // Set each sound in the bank to STOPPED
for (j = 0; j < 40; j++) { for (j = 0; j < ARRAY_COUNT(sSoundBanks[0]); j++) {
sSoundBanks[i][j].soundStatus = SOUND_STATUS_STOPPED; sSoundBanks[i][j].soundStatus = SOUND_STATUS_STOPPED;
} }
@@ -1972,7 +1961,7 @@ void sound_init(void) {
sSoundBanks[i][0].next = 0xff; sSoundBanks[i][0].next = 0xff;
// Set free list to contain every sound slot // Set free list to contain every sound slot
for (j = 1; j < 40 - 1; j++) { for (j = 1; j < ARRAY_COUNT(sSoundBanks[0]) - 1; j++) {
sSoundBanks[i][j].prev = j - 1; sSoundBanks[i][j].prev = j - 1;
sSoundBanks[i][j].next = j + 1; sSoundBanks[i][j].next = j + 1;
} }
@@ -1980,7 +1969,7 @@ void sound_init(void) {
sSoundBanks[i][j].next = 0xff; sSoundBanks[i][j].next = 0xff;
} }
for (j = 0; j < 3; j++) { for (j = 0; j < SEQUENCE_PLAYERS; j++) {
for (i = 0; i < CHANNELS_MAX; i++) { for (i = 0; i < CHANNELS_MAX; i++) {
D_80360928[j][i].remainingFrames = 0; D_80360928[j][i].remainingFrames = 0;
} }