mirror of
https://github.com/HarbourMasters/Starship.git
synced 2025-04-28 20:37:58 +03:00
Exposed audio functions and implemented id on messages
This commit is contained in:
parent
9e53825c80
commit
29523e168c
8 changed files with 134 additions and 9 deletions
66
example/.vscode/api_definitions.v1.lua
vendored
66
example/.vscode/api_definitions.v1.lua
vendored
|
@ -10764,6 +10764,72 @@ function Audio_PlaySoundTestTrack(_trackNumber) end
|
|||
---@param _seqId number
|
||||
---@return nil
|
||||
function Audio_PlayBgm(_seqId) end
|
||||
---@enum AudioType
|
||||
AudioType = {
|
||||
AUDIO_TYPE_MUSIC = 0,
|
||||
AUDIO_TYPE_VOICE = 1,
|
||||
AUDIO_TYPE_SFX = 2,
|
||||
AUDIO_TYPE_MAX = 3
|
||||
}
|
||||
|
||||
---@enum OptionSoundMode
|
||||
OptionSoundMode = {
|
||||
OPTIONSOUND_STEREO = 0,
|
||||
OPTIONSOUND_MONO = 1,
|
||||
OPTIONSOUND_HEADSET = 2,
|
||||
OPTIONSOUND_MAX = 3
|
||||
}
|
||||
|
||||
---@param _msgId number
|
||||
---@return nil
|
||||
function Audio_PlayVoice(_msgId) end
|
||||
---@param _msgId number
|
||||
---@return nil
|
||||
function Audio_PlayVoiceWithoutBGM(_msgId) end
|
||||
---@param _void nil
|
||||
---@return nil
|
||||
function Audio_ClearVoice(_void) end
|
||||
---@param _void nil
|
||||
---@return number
|
||||
function Audio_GetCurrentVoice(_void) end
|
||||
---@param _void nil
|
||||
---@return number
|
||||
function Audio_GetCurrentVoiceStatus(_void) end
|
||||
---@param _unkVoiceParam number
|
||||
---@return nil
|
||||
function Audio_SetUnkVoiceParam(_unkVoiceParam) end
|
||||
---@param _void nil
|
||||
---@return number
|
||||
function Audio_UpdateFrequencyAnalysis(_void) end
|
||||
---@param _audioType number
|
||||
---@param volume number
|
||||
---@return nil
|
||||
function Audio_SetVolume(_audioType, volume) end
|
||||
---@param _fadeoutTime number
|
||||
---@return nil
|
||||
function Audio_FadeOutAll(_fadeoutTime) end
|
||||
---@param _unused number
|
||||
---@param specParam number
|
||||
---@return nil
|
||||
function Audio_SetAudioSpec(_unused, specParam) end
|
||||
---@param _void nil
|
||||
---@return nil
|
||||
function AudioLoad_Init(_void) end
|
||||
---@param _void nil
|
||||
---@return nil
|
||||
function Audio_dummy_80016A50(_void) end
|
||||
---@param _void nil
|
||||
---@return nil
|
||||
function Audio_InitSounds(_void) end
|
||||
---@param _void nil
|
||||
---@return nil
|
||||
function Audio_Update(_void) end
|
||||
---@param _void nil
|
||||
---@return SPTask
|
||||
function AudioThread_CreateTask(_void) end
|
||||
---@param _void nil
|
||||
---@return nil
|
||||
function AudioThread_PreNMIReset(_void) end
|
||||
---@enum PlayState
|
||||
PlayState = {
|
||||
PLAY_STANDBY = 0,
|
||||
|
|
|
@ -946,7 +946,7 @@ extern "C" {
|
|||
#endif
|
||||
|
||||
u16* Message_PtrFromId(u16 msgId);
|
||||
u16 Message_IdFromPtr(u16*);
|
||||
s16 Message_IdFromPtr(u16*);
|
||||
s32 Message_GetWidth(u16* msgPtr);
|
||||
s32 Message_GetCharCount(u16* msgPtr);
|
||||
void Message_DisplayChar(Gfx** gfxPtr, u16 msgChar, s32 xpos, s32 ypos);
|
||||
|
|
|
@ -5167,6 +5167,34 @@ lua.set_function("Audio_PlaySoundTest", Audio_PlaySoundTest);
|
|||
lua.set_function("Audio_PlaySequenceDistorted", Audio_PlaySequenceDistorted);
|
||||
lua.set_function("Audio_PlaySoundTestTrack", Audio_PlaySoundTestTrack);
|
||||
lua.set_function("Audio_PlayBgm", Audio_PlayBgm);
|
||||
auto enum_AudioType = lua["AudioType"].force();
|
||||
enum_AudioType["AUDIO_TYPE_MUSIC"] = (uint32_t) AUDIO_TYPE_MUSIC;
|
||||
enum_AudioType["AUDIO_TYPE_VOICE"] = (uint32_t) AUDIO_TYPE_VOICE;
|
||||
enum_AudioType["AUDIO_TYPE_SFX"] = (uint32_t) AUDIO_TYPE_SFX;
|
||||
enum_AudioType["AUDIO_TYPE_MAX"] = (uint32_t) AUDIO_TYPE_MAX;
|
||||
|
||||
auto enum_OptionSoundMode = lua["OptionSoundMode"].force();
|
||||
enum_OptionSoundMode["OPTIONSOUND_STEREO"] = (uint32_t) OPTIONSOUND_STEREO;
|
||||
enum_OptionSoundMode["OPTIONSOUND_MONO"] = (uint32_t) OPTIONSOUND_MONO;
|
||||
enum_OptionSoundMode["OPTIONSOUND_HEADSET"] = (uint32_t) OPTIONSOUND_HEADSET;
|
||||
enum_OptionSoundMode["OPTIONSOUND_MAX"] = (uint32_t) OPTIONSOUND_MAX;
|
||||
|
||||
lua.set_function("Audio_PlayVoice", Audio_PlayVoice);
|
||||
lua.set_function("Audio_PlayVoiceWithoutBGM", Audio_PlayVoiceWithoutBGM);
|
||||
lua.set_function("Audio_ClearVoice", Audio_ClearVoice);
|
||||
lua.set_function("Audio_GetCurrentVoice", Audio_GetCurrentVoice);
|
||||
lua.set_function("Audio_GetCurrentVoiceStatus", Audio_GetCurrentVoiceStatus);
|
||||
lua.set_function("Audio_SetUnkVoiceParam", Audio_SetUnkVoiceParam);
|
||||
lua.set_function("Audio_UpdateFrequencyAnalysis", Audio_UpdateFrequencyAnalysis);
|
||||
lua.set_function("Audio_SetVolume", Audio_SetVolume);
|
||||
lua.set_function("Audio_FadeOutAll", Audio_FadeOutAll);
|
||||
lua.set_function("Audio_SetAudioSpec", Audio_SetAudioSpec);
|
||||
lua.set_function("AudioLoad_Init", AudioLoad_Init);
|
||||
lua.set_function("Audio_dummy_80016A50", Audio_dummy_80016A50);
|
||||
lua.set_function("Audio_InitSounds", Audio_InitSounds);
|
||||
lua.set_function("Audio_Update", Audio_Update);
|
||||
lua.set_function("AudioThread_CreateTask", AudioThread_CreateTask);
|
||||
lua.set_function("AudioThread_PreNMIReset", AudioThread_PreNMIReset);
|
||||
auto enum_PlayState = lua["PlayState"].force();
|
||||
enum_PlayState["PLAY_STANDBY"] = (uint32_t) PLAY_STANDBY;
|
||||
enum_PlayState["PLAY_INIT"] = (uint32_t) PLAY_INIT;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include "global.h"
|
||||
#include "mods.h"
|
||||
#include "port/resource/importers/MessageFactory.h"
|
||||
|
||||
u16* Message_PtrFromId(u16 msgId) {
|
||||
s32 i;
|
||||
|
@ -14,10 +15,15 @@ u16* Message_PtrFromId(u16 msgId) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
u16 Message_IdFromPtr(u16* msgPtr) {
|
||||
s16 Message_IdFromPtr(u16* msgPtr) {
|
||||
s32 i;
|
||||
MsgLookup* lookup = (MsgLookup*) LOAD_ASSET(gMsgLookup);
|
||||
|
||||
s16 msgId = Message_SearchCustomID(msgPtr);
|
||||
if (msgId != -1) {
|
||||
return msgId;
|
||||
}
|
||||
|
||||
while (lookup->msgPtr != NULL) {
|
||||
if (GameEngine_OTRSigCheck(msgPtr)) {
|
||||
if (strcmp(((char*) msgPtr) + 7, lookup->path) == 0) {
|
||||
|
@ -30,6 +36,7 @@ u16 Message_IdFromPtr(u16* msgPtr) {
|
|||
}
|
||||
lookup++;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@ s32 func_radio_800BA7BC(u16* msg, s32 priority) {
|
|||
void Radio_PlayMessage(u16* msg, RadioCharacterId character) {
|
||||
TeamId teamId;
|
||||
s32 pad;
|
||||
s32 priority;
|
||||
s32 priority = 0;
|
||||
msg = SEGMENTED_TO_VIRTUAL(msg);
|
||||
|
||||
switch (msg[0]) {
|
||||
|
@ -126,7 +126,9 @@ void Radio_PlayMessage(u16* msg, RadioCharacterId character) {
|
|||
gRadioState = 100;
|
||||
|
||||
gRadioMsgId = Message_IdFromPtr(msg);
|
||||
Audio_PlayVoice(gRadioMsgId);
|
||||
if(gRadioMsgId != -1){
|
||||
Audio_PlayVoice(gRadioMsgId);
|
||||
}
|
||||
}
|
||||
|
||||
void Radio_CalculatePositions(){
|
||||
|
|
|
@ -20,9 +20,10 @@ std::vector<std::string> gASCIIFullTable = {
|
|||
"7", "8", "9", "'", "(", ")", ":", "|",
|
||||
};
|
||||
|
||||
std::shared_ptr<Ship::IResource> ResourceFactoryBinaryMessageV0::ReadResource(std::shared_ptr<Ship::File> file,
|
||||
std::shared_ptr<Ship::ResourceInitData> initData) {
|
||||
if (!FileHasValidFormatAndReader(file, initData)) {
|
||||
std::vector<std::pair<uint16_t*, int32_t>> gCustomMessageTable;
|
||||
|
||||
std::shared_ptr<Ship::IResource> ResourceFactoryBinaryMessageV0::ReadResource(std::shared_ptr<Ship::File> file) {
|
||||
if (!FileHasValidFormatAndReader(file)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -44,6 +45,7 @@ std::shared_ptr<Ship::IResource> ResourceFactoryXMLMessageV0::ReadResource(std::
|
|||
}
|
||||
auto msg = std::make_shared<Message>(file->InitData);
|
||||
auto parent = std::get<std::shared_ptr<tinyxml2::XMLDocument>>(file->Reader)->FirstChildElement("Message");
|
||||
auto id = parent->IntAttribute("Id", -1);
|
||||
|
||||
tinyxml2::XMLElement* element = parent->FirstChildElement("Line");
|
||||
|
||||
|
@ -81,6 +83,18 @@ std::shared_ptr<Ship::IResource> ResourceFactoryXMLMessageV0::ReadResource(std::
|
|||
} // end
|
||||
|
||||
msg->mMessage.push_back(0);
|
||||
gCustomMessageTable.emplace_back(msg->mMessage.data(), id);
|
||||
|
||||
return msg;
|
||||
}
|
||||
} // namespace LUS
|
||||
|
||||
extern "C" int16_t Message_SearchCustomID(uint16_t* msg) {
|
||||
for (auto& pair : SF64::gCustomMessageTable) {
|
||||
if(pair.first == msg) {
|
||||
return (int16_t) pair.second;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
|
@ -1,4 +1,5 @@
|
|||
#pragma once
|
||||
#ifdef __cplusplus
|
||||
|
||||
#include "Resource.h"
|
||||
#include "ResourceFactoryXML.h"
|
||||
|
@ -16,3 +17,6 @@ class ResourceFactoryXMLMessageV0 : public Ship::ResourceFactoryXML {
|
|||
std::shared_ptr<Ship::IResource> ReadResource(std::shared_ptr<Ship::File> file) override;
|
||||
};
|
||||
}; // namespace LUS
|
||||
#else
|
||||
extern int16_t Message_SearchCustomID(uint16_t* msg);
|
||||
#endif
|
|
@ -129,8 +129,12 @@ def sanitize_type(member_type):
|
|||
return member_type
|
||||
|
||||
blacklist = [
|
||||
'audio',
|
||||
'portable-file-dialogs.h',
|
||||
'ast_audio',
|
||||
'sf64audio_provisional',
|
||||
'audioseq_cmd',
|
||||
'audiothread_cmd',
|
||||
'libaudio',
|
||||
'portable-file-dialogs',
|
||||
'rmonint.h',
|
||||
'PR/',
|
||||
'libultra/',
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue