[build] Fix compile errors for Switch.

This commit is contained in:
Prince Frizzy 2025-05-18 21:58:19 -04:00
parent 1c57e5e887
commit 968204e9d1
No known key found for this signature in database
GPG key ID: 0A8A0E97BACA3FC6
5 changed files with 24 additions and 13 deletions

View file

@ -23,7 +23,7 @@ static u32 sGfxCommandErrorSize = 0;
#define CHECK_TOKEN_INDEX(tokenIndex, returnValue) { \
if (tokenIndex >= aNode->mTokens.Count()) { \
PrintDataErrorGfx(" ERROR: Invalid token index: %llu, tokens count is: %d", tokenIndex, aNode->mTokens.Count()); \
DynOS_PrintDataErrorGfx(" ERROR: Invalid token index: %llu, tokens count is: %d", tokenIndex, aNode->mTokens.Count()); \
return returnValue; \
} \
}
@ -1217,7 +1217,7 @@ template <typename T, typename SmluaToFunc, typename ReturnFunc>
static String ConvertParam(lua_State *L, GfxData *aGfxData, u32 paramIndex, const char *typeName, const SmluaToFunc &smluaToFunc, const ReturnFunc &returnFunc) {
T value = smluaToFunc(L, paramIndex);
if (!gSmLuaConvertSuccess) {
PrintDataErrorGfx(" ERROR: Failed to convert parameter %u to %s", paramIndex, typeName);
DynOS_PrintDataErrorGfx(" ERROR: Failed to convert parameter %u to %s", paramIndex, typeName);
return "";
}
return returnFunc(value);
@ -1266,7 +1266,7 @@ static String ResolveParam(lua_State *L, GfxData *aGfxData, u32 paramIndex, char
[&aGfxData] (Gfx *gfx) { return CreateRawPointerDataNode(aGfxData, gfx); }
);
}
PrintDataErrorGfx(" ERROR: Unknown parameter type: '%c'", paramType);
DynOS_PrintDataErrorGfx(" ERROR: Unknown parameter type: '%c'", paramType);
return "";
}
@ -1353,7 +1353,7 @@ static bool CheckGfxLength(GfxData *aGfxData, Gfx *gfx, u32 lengthToWrite) {
if (lengthToWrite > 1) {
u32 gfxLength = gfx_get_length(gfx);
if (gfxLength < lengthToWrite) {
PrintDataErrorGfx(" ERROR: Cannot write %u commands to display list of length: %u", lengthToWrite, gfxLength);
DynOS_PrintDataErrorGfx(" ERROR: Cannot write %u commands to display list of length: %u", lengthToWrite, gfxLength);
return false;
}
}

View file

@ -22,7 +22,7 @@
#include "game/save_file.h"
#include "pc/network/network_player.h"
#include "string_utils.h"
#include "pc/pc_main.h"
#include "pc/game_main.h"
#define ARRAY_LEN(arr) (sizeof(arr) / sizeof(arr[0]))

View file

@ -95,6 +95,8 @@ static u32 sDrawnFrames = 0;
bool gGameInited = false;
bool gGfxInited = false;
f32 gMasterVolume = 100.0f;
u8 gLuaVolumeMaster = 127;
u8 gLuaVolumeLevel = 127;
u8 gLuaVolumeSfx = 127;
@ -304,18 +306,25 @@ void produce_one_dummy_frame(void (*callback)(), u8 clearColorR, u8 clearColorG,
static s16 sAudioBuffer[SAMPLES_HIGH * 2 * 2] = { 0 };
void buffer_audio(void) {
bool shouldMute = configMuteFocusLoss && !wm_api->has_focus();
const f32 masterMod = (f32)configMasterVolume / 127.0f * (f32)gLuaVolumeMaster / 127.0f;
set_sequence_player_volume(SEQ_PLAYER_LEVEL, shouldMute ? 0 : (f32)configMusicVolume / 127.0f * (f32)gLuaVolumeLevel / 127.0f * masterMod);
set_sequence_player_volume(SEQ_PLAYER_SFX, shouldMute ? 0 : (f32)configSfxVolume / 127.0f * (f32)gLuaVolumeSfx / 127.0f * masterMod);
set_sequence_player_volume(SEQ_PLAYER_ENV, shouldMute ? 0 : (f32)configEnvVolume / 127.0f * (f32)gLuaVolumeEnv / 127.0f * masterMod);
bool shouldMute = (configMuteFocusLoss && !wm_api->has_focus()) || (gMasterVolume == 0);
if (!shouldMute) {
set_sequence_player_volume(SEQ_PLAYER_LEVEL, (f32)configMusicVolume / 127.0f * (f32)gLuaVolumeLevel / 127.0f);
set_sequence_player_volume(SEQ_PLAYER_SFX, (f32)configSfxVolume / 127.0f * (f32)gLuaVolumeSfx / 127.0f);
set_sequence_player_volume(SEQ_PLAYER_ENV, (f32)configEnvVolume / 127.0f * (f32)gLuaVolumeEnv / 127.0f);
}
int samplesLeft = audio_api->buffered();
u32 numAudioSamples = samplesLeft < audio_api->get_desired_buffered() ? SAMPLES_HIGH : SAMPLES_LOW;
for (s32 i = 0; i < 2; i++) {
create_next_audio_buffer(sAudioBuffer + i * (numAudioSamples * 2), numAudioSamples);
}
audio_api->play((u8 *)sAudioBuffer, 2 * numAudioSamples * 4);
if (!shouldMute) {
for (u16 i = 0; i < ARRAY_COUNT(sAudioBuffer); i++) {
sAudioBuffer[i] *= gMasterVolume;
}
audio_api->play((u8 *)sAudioBuffer, 2 * numAudioSamples * 4);
}
}
void *audio_thread(UNUSED void *arg) {

View file

@ -14,6 +14,8 @@ extern "C" {
extern bool gGameInited;
extern bool gGfxInited;
extern f32 gMasterVolume;
extern u8 gLuaVolumeMaster;
extern u8 gLuaVolumeLevel;
extern u8 gLuaVolumeSfx;

View file

@ -359,7 +359,7 @@ void audio_stream_stop(struct ModAudio* audio) {
f32 audio_stream_get_position(struct ModAudio* audio) {
if (!audio_sanity_check(audio, true, "get stream position from")) { return 0; }
u64 cursor; ma_data_source_get_cursor_in_pcm_frames(&audio->decoder, &cursor);
ma_uint64 cursor; ma_data_source_get_cursor_in_pcm_frames(&audio->decoder, &cursor);
return (f32)cursor / ma_engine_get_sample_rate(&sModAudioEngine);
}
@ -384,7 +384,7 @@ void audio_stream_set_looping(struct ModAudio* audio, bool looping) {
void audio_stream_set_loop_points(struct ModAudio* audio, s64 loopStart, s64 loopEnd) {
if (!audio_sanity_check(audio, true, "set stream loop points for")) { return; }
u64 length; ma_data_source_get_length_in_pcm_frames(&audio->decoder, &length);
ma_uint64 length; ma_data_source_get_length_in_pcm_frames(&audio->decoder, &length);
if (loopStart < 0) loopStart += length;
if (loopEnd <= 0) loopEnd += length;