mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2025-10-30 08:01:01 +00:00
Allocate Sequence
This commit is contained in:
parent
9c28364d81
commit
ca6a3d1148
6 changed files with 61 additions and 0 deletions
|
|
@ -10180,6 +10180,12 @@ function audio_sample_play(audio, position, volume)
|
|||
-- ...
|
||||
end
|
||||
|
||||
--- @return integer
|
||||
--- Allocates an `audio` sequence
|
||||
function allocate_seq()
|
||||
-- ...
|
||||
end
|
||||
|
||||
--- Resets camera config overrides
|
||||
function camera_reset_overrides()
|
||||
-- ...
|
||||
|
|
|
|||
|
|
@ -1458,6 +1458,27 @@ Plays an `audio` sample at `position` with `volume`
|
|||
|
||||
<br />
|
||||
|
||||
## [allocate_seq](#allocate_seq)
|
||||
|
||||
### Description
|
||||
Allocates an `audio` sequence
|
||||
|
||||
### Lua Example
|
||||
`local integerValue = allocate_seq()`
|
||||
|
||||
### Parameters
|
||||
- None
|
||||
|
||||
### Returns
|
||||
- `integer`
|
||||
|
||||
### C Prototype
|
||||
`u32 allocate_seq(void);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
---
|
||||
# functions from smlua_camera_utils.h
|
||||
|
||||
|
|
|
|||
|
|
@ -1824,6 +1824,7 @@
|
|||
- [audio_sample_destroy](functions-6.md#audio_sample_destroy)
|
||||
- [audio_sample_stop](functions-6.md#audio_sample_stop)
|
||||
- [audio_sample_play](functions-6.md#audio_sample_play)
|
||||
- [allocate_seq](functions-6.md#allocate_seq)
|
||||
|
||||
<br />
|
||||
|
||||
|
|
|
|||
|
|
@ -30759,6 +30759,21 @@ int smlua_func_audio_sample_play(lua_State* L) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_allocate_seq(UNUSED lua_State* L) {
|
||||
if (L == NULL) { return 0; }
|
||||
|
||||
int top = lua_gettop(L);
|
||||
if (top != 0) {
|
||||
LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "allocate_seq", 0, top);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
lua_pushinteger(L, allocate_seq());
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
//////////////////////////
|
||||
// smlua_camera_utils.h //
|
||||
//////////////////////////
|
||||
|
|
@ -38038,6 +38053,7 @@ void smlua_bind_functions_autogen(void) {
|
|||
smlua_bind_function(L, "audio_sample_destroy", smlua_func_audio_sample_destroy);
|
||||
smlua_bind_function(L, "audio_sample_stop", smlua_func_audio_sample_stop);
|
||||
smlua_bind_function(L, "audio_sample_play", smlua_func_audio_sample_play);
|
||||
smlua_bind_function(L, "allocate_seq", smlua_func_allocate_seq);
|
||||
|
||||
// smlua_camera_utils.h
|
||||
smlua_bind_function(L, "camera_reset_overrides", smlua_func_camera_reset_overrides);
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@
|
|||
#define STB_VORBIS_HEADER_ONLY
|
||||
#include "pc/utils/stb_vorbis.c"
|
||||
|
||||
#define MAX_CUSTOM_SEQS 1024
|
||||
|
||||
#include "types.h"
|
||||
#include "seq_ids.h"
|
||||
#include "audio/external.h"
|
||||
|
|
@ -29,6 +31,8 @@ struct AudioOverride {
|
|||
|
||||
struct AudioOverride sAudioOverrides[MAX_AUDIO_OVERRIDE] = { 0 };
|
||||
|
||||
static u32 sCustomSeqsCount = 0;
|
||||
|
||||
static void smlua_audio_utils_reset(struct AudioOverride* override) {
|
||||
if (override == NULL) { return; }
|
||||
|
||||
|
|
@ -65,6 +69,7 @@ void smlua_audio_utils_reset_all(void) {
|
|||
#endif
|
||||
smlua_audio_utils_reset(&sAudioOverrides[i]);
|
||||
}
|
||||
sCustomSeqsCount = 0;
|
||||
}
|
||||
|
||||
bool smlua_audio_utils_override(u8 sequenceId, s32* bankId, void** seqData) {
|
||||
|
|
@ -619,3 +624,12 @@ void smlua_audio_custom_deinit(void) {
|
|||
sModAudioPool = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
u32 allocate_seq() {
|
||||
if ((sCustomSeqsCount + SEQ_COUNT) < MAX_CUSTOM_SEQS) {
|
||||
return (++sCustomSeqsCount + SEQ_COUNT);
|
||||
}
|
||||
LOG_ERROR("Cannot allocate more custom sequences.");
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -76,4 +76,7 @@ void audio_custom_update_volume(void);
|
|||
void audio_custom_shutdown(void);
|
||||
void smlua_audio_custom_deinit(void);
|
||||
|
||||
/* |description|Allocates an `audio` sequence|descriptionEnd| */
|
||||
u32 allocate_seq(void);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue