mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2024-11-22 12:05:11 +00:00
Added default volume support for custom sequences
This commit is contained in:
parent
9dc78a0971
commit
2c187bba45
8 changed files with 107 additions and 16 deletions
|
@ -7019,9 +7019,10 @@ end
|
|||
|
||||
--- @param sequenceId integer
|
||||
--- @param bankId integer
|
||||
--- @param defaultVolume integer
|
||||
--- @param m64Name string
|
||||
--- @return nil
|
||||
function smlua_audio_utils_replace_sequence(sequenceId, bankId, m64Name)
|
||||
function smlua_audio_utils_replace_sequence(sequenceId, bankId, defaultVolume, m64Name)
|
||||
-- ...
|
||||
end
|
||||
|
||||
|
|
|
@ -24564,20 +24564,21 @@ The `reliable` field will ensure that the packet arrives, but should be used spa
|
|||
## [smlua_audio_utils_replace_sequence](#smlua_audio_utils_replace_sequence)
|
||||
|
||||
### Lua Example
|
||||
`smlua_audio_utils_replace_sequence(sequenceId, bankId, m64Name)`
|
||||
`smlua_audio_utils_replace_sequence(sequenceId, bankId, defaultVolume, m64Name)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| sequenceId | `integer` |
|
||||
| bankId | `integer` |
|
||||
| defaultVolume | `integer` |
|
||||
| m64Name | `string` |
|
||||
|
||||
### Returns
|
||||
- None
|
||||
|
||||
### C Prototype
|
||||
`void smlua_audio_utils_replace_sequence(u8 sequenceId, u8 bankId, const char* m64Name);`
|
||||
`void smlua_audio_utils_replace_sequence(u8 sequenceId, u8 bankId, u8 defaultVolume, const char* m64Name);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
|
|
|
@ -280,8 +280,7 @@ u16 sLevelAcousticReaches[LEVEL_COUNT] = {
|
|||
#define VOLUME_RANGE_UNK2 0.8f
|
||||
#endif
|
||||
|
||||
// Default volume for background music sequences (playing on player 0).
|
||||
u8 sBackgroundMusicDefaultVolume[] = {
|
||||
const u8 sBackgroundMusicDefaultVolumeDefault[] = {
|
||||
127, // SEQ_SOUND_PLAYER
|
||||
80, // SEQ_EVENT_CUTSCENE_COLLECT_STAR
|
||||
80, // SEQ_MENU_TITLE_SCREEN
|
||||
|
@ -319,7 +318,75 @@ u8 sBackgroundMusicDefaultVolume[] = {
|
|||
0, // SEQ_EVENT_CUTSCENE_LAKITU (not in JP)
|
||||
};
|
||||
|
||||
STATIC_ASSERT(ARRAY_COUNT(sBackgroundMusicDefaultVolume) == SEQ_COUNT,
|
||||
// Default volume for background music sequences (playing on player 0).
|
||||
u8 sBackgroundMusicDefaultVolume[64] = {
|
||||
127, // SEQ_SOUND_PLAYER
|
||||
80, // SEQ_EVENT_CUTSCENE_COLLECT_STAR
|
||||
80, // SEQ_MENU_TITLE_SCREEN
|
||||
75, // SEQ_LEVEL_GRASS
|
||||
70, // SEQ_LEVEL_INSIDE_CASTLE
|
||||
75, // SEQ_LEVEL_WATER
|
||||
75, // SEQ_LEVEL_HOT
|
||||
75, // SEQ_LEVEL_BOSS_KOOPA
|
||||
70, // SEQ_LEVEL_SNOW
|
||||
65, // SEQ_LEVEL_SLIDE
|
||||
80, // SEQ_LEVEL_SPOOKY
|
||||
65, // SEQ_EVENT_PIRANHA_PLANT
|
||||
85, // SEQ_LEVEL_UNDERGROUND
|
||||
75, // SEQ_MENU_STAR_SELECT
|
||||
65, // SEQ_EVENT_POWERUP
|
||||
70, // SEQ_EVENT_METAL_CAP
|
||||
65, // SEQ_EVENT_KOOPA_MESSAGE
|
||||
70, // SEQ_LEVEL_KOOPA_ROAD
|
||||
70, // SEQ_EVENT_HIGH_SCORE
|
||||
65, // SEQ_EVENT_MERRY_GO_ROUND
|
||||
80, // SEQ_EVENT_RACE
|
||||
70, // SEQ_EVENT_CUTSCENE_STAR_SPAWN
|
||||
85, // SEQ_EVENT_BOSS
|
||||
75, // SEQ_EVENT_CUTSCENE_COLLECT_KEY
|
||||
75, // SEQ_EVENT_ENDLESS_STAIRS
|
||||
85, // SEQ_LEVEL_BOSS_KOOPA_FINAL
|
||||
70, // SEQ_EVENT_CUTSCENE_CREDITS
|
||||
80, // SEQ_EVENT_SOLVE_PUZZLE
|
||||
80, // SEQ_EVENT_TOAD_MESSAGE
|
||||
70, // SEQ_EVENT_PEACH_MESSAGE
|
||||
75, // SEQ_EVENT_CUTSCENE_INTRO
|
||||
80, // SEQ_EVENT_CUTSCENE_VICTORY
|
||||
70, // SEQ_EVENT_CUTSCENE_ENDING
|
||||
65, // SEQ_MENU_FILE_SELECT
|
||||
0, // SEQ_EVENT_CUTSCENE_LAKITU (not in JP)
|
||||
75, // SEQ_???
|
||||
75, // SEQ_???
|
||||
75, // SEQ_???
|
||||
75, // SEQ_???
|
||||
75, // SEQ_???
|
||||
75, // SEQ_???
|
||||
75, // SEQ_???
|
||||
75, // SEQ_???
|
||||
75, // SEQ_???
|
||||
75, // SEQ_???
|
||||
75, // SEQ_???
|
||||
75, // SEQ_???
|
||||
75, // SEQ_???
|
||||
75, // SEQ_???
|
||||
75, // SEQ_???
|
||||
75, // SEQ_???
|
||||
75, // SEQ_???
|
||||
75, // SEQ_???
|
||||
75, // SEQ_???
|
||||
75, // SEQ_???
|
||||
75, // SEQ_???
|
||||
75, // SEQ_???
|
||||
75, // SEQ_???
|
||||
75, // SEQ_???
|
||||
75, // SEQ_???
|
||||
75, // SEQ_???
|
||||
75, // SEQ_???
|
||||
75, // SEQ_???
|
||||
75, // SEQ_???
|
||||
};
|
||||
|
||||
STATIC_ASSERT(ARRAY_COUNT(sBackgroundMusicDefaultVolume) == 64,
|
||||
"change this array if you are adding sequences");
|
||||
|
||||
u8 sCurrentBackgroundMusicSeqId = SEQUENCE_NONE;
|
||||
|
@ -2665,4 +2732,17 @@ void unused_80321460(UNUSED s32 arg0, UNUSED s32 arg1, UNUSED s32 arg2, UNUSED s
|
|||
|
||||
void unused_80321474(UNUSED s32 arg0) {
|
||||
}
|
||||
|
||||
void sound_reset_background_music_default_volume(u8 seqId) {
|
||||
if (seqId >= SEQ_EVENT_CUTSCENE_LAKITU) {
|
||||
sBackgroundMusicDefaultVolume[seqId] = 75;
|
||||
return;
|
||||
}
|
||||
sBackgroundMusicDefaultVolume[seqId] = sBackgroundMusicDefaultVolumeDefault[seqId];
|
||||
}
|
||||
|
||||
void sound_set_background_music_default_volume(u8 seqId, u8 volume) {
|
||||
sBackgroundMusicDefaultVolume[seqId] = volume;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -68,6 +68,9 @@ void audio_set_sound_mode(u8 arg0);
|
|||
|
||||
void audio_init(void); // in load.c
|
||||
|
||||
void sound_reset_background_music_default_volume(u8 seqId);
|
||||
void sound_set_background_music_default_volume(u8 seqId, u8 volume);
|
||||
|
||||
#if defined(VERSION_EU) || defined(VERSION_SH)
|
||||
struct SPTask *unused_80321460();
|
||||
struct SPTask *unused_80321460(void);
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#include "pc/mods/mods_utils.h"
|
||||
#include "pc/crash_handler.h"
|
||||
#include "pc/lua/utils/smlua_text_utils.h"
|
||||
#include "pc/lua/utils/smlua_audio_utils.h"
|
||||
|
||||
lua_State* gLuaState = NULL;
|
||||
u8 gLuaInitializingScript = 0;
|
||||
|
|
|
@ -14621,16 +14621,18 @@ int smlua_func_save_file_set_flags(lua_State* L) {
|
|||
/////////////////////////
|
||||
|
||||
int smlua_func_smlua_audio_utils_replace_sequence(lua_State* L) {
|
||||
if(!smlua_functions_valid_param_count(L, 3)) { return 0; }
|
||||
if(!smlua_functions_valid_param_count(L, 4)) { return 0; }
|
||||
|
||||
u8 sequenceId = smlua_to_integer(L, 1);
|
||||
if (!gSmLuaConvertSuccess) { return 0; }
|
||||
u8 bankId = smlua_to_integer(L, 2);
|
||||
if (!gSmLuaConvertSuccess) { return 0; }
|
||||
const char* m64Name = smlua_to_string(L, 3);
|
||||
u8 defaultVolume = smlua_to_integer(L, 3);
|
||||
if (!gSmLuaConvertSuccess) { return 0; }
|
||||
const char* m64Name = smlua_to_string(L, 4);
|
||||
if (!gSmLuaConvertSuccess) { return 0; }
|
||||
|
||||
smlua_audio_utils_replace_sequence(sequenceId, bankId, m64Name);
|
||||
smlua_audio_utils_replace_sequence(sequenceId, bankId, defaultVolume, m64Name);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#include "types.h"
|
||||
#include "audio/external.h"
|
||||
#include "pc/mods/mods.h"
|
||||
#include "pc/lua/smlua.h"
|
||||
#include "pc/debuglog.h"
|
||||
|
@ -16,14 +17,14 @@ struct AudioOverride {
|
|||
|
||||
struct AudioOverride sAudioOverrides[MAX_OVERRIDE] = { 0 };
|
||||
|
||||
static smlua_audio_utils_reset(struct AudioOverride* override) {
|
||||
static void smlua_audio_utils_reset(struct AudioOverride* override) {
|
||||
if (override == NULL) { return; }
|
||||
|
||||
override->enabled = false;
|
||||
override->loaded = false;
|
||||
|
||||
if (override->filename) {
|
||||
free(override->filename);
|
||||
free((char*)override->filename);
|
||||
override->filename = NULL;
|
||||
}
|
||||
|
||||
|
@ -31,13 +32,14 @@ static smlua_audio_utils_reset(struct AudioOverride* override) {
|
|||
override->bank = 0;
|
||||
|
||||
if (override->buffer != NULL) {
|
||||
free(override->filename);
|
||||
override->filename = NULL;
|
||||
free((u8*)override->buffer);
|
||||
override->buffer = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void smlua_audio_utils_reset_all(void) {
|
||||
for (s32 i = 0; i < MAX_OVERRIDE; i++) {
|
||||
if (sAudioOverrides[i].enabled) { sound_reset_background_music_default_volume(i); }
|
||||
smlua_audio_utils_reset(&sAudioOverrides[i]);
|
||||
}
|
||||
}
|
||||
|
@ -83,7 +85,7 @@ bool smlua_audio_utils_override(u8 sequenceId, s32* bankId, void** seqData) {
|
|||
return true;
|
||||
}
|
||||
|
||||
void smlua_audio_utils_replace_sequence(u8 sequenceId, u8 bankId, const char* m64Name) {
|
||||
void smlua_audio_utils_replace_sequence(u8 sequenceId, u8 bankId, u8 defaultVolume, const char* m64Name) {
|
||||
if (gLuaActiveMod == NULL) { return; }
|
||||
if (sequenceId >= MAX_OVERRIDE) {
|
||||
LOG_LUA("Invalid sequenceId given to smlua_audio_utils_replace_sequence(): %d", sequenceId);
|
||||
|
@ -111,6 +113,7 @@ void smlua_audio_utils_replace_sequence(u8 sequenceId, u8 bankId, const char* m6
|
|||
override->filename = strdup(fullPath);
|
||||
override->enabled = true;
|
||||
override->bank = bankId;
|
||||
sound_set_background_music_default_volume(sequenceId, defaultVolume);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#ifndef SMLUA_AUDIO_UTILS_H
|
||||
#define SMLUA_AUDIO_UTILS_H
|
||||
|
||||
void smlua_audio_utils_reset_all(void);
|
||||
bool smlua_audio_utils_override(u8 sequenceId, s32* bankId, void** seqData);
|
||||
|
||||
void smlua_audio_utils_replace_sequence(u8 sequenceId, u8 bankId, const char* m64Name);
|
||||
void smlua_audio_utils_replace_sequence(u8 sequenceId, u8 bankId, u8 defaultVolume, const char* m64Name);
|
||||
|
||||
#endif
|
Loading…
Reference in a new issue