From f9db312fd0507ee469a86f0bf9a05b6d2f99142f Mon Sep 17 00:00:00 2001 From: The-Little-Wolf <116989599+The-Little-Wolf@users.noreply.github.com> Date: Sat, 11 Jan 2025 18:37:54 -0800 Subject: [PATCH] [Xboxkrnl/XConfig] add user audio config - Allows for user to set their audio type in the config - Record audio flags and how they function --- src/xenia/kernel/xam/xam_info.cc | 3 ++- src/xenia/kernel/xboxkrnl/xboxkrnl_audio.cc | 4 +++- src/xenia/kernel/xboxkrnl/xboxkrnl_xconfig.cc | 21 +++++++++++++++++++ 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/src/xenia/kernel/xam/xam_info.cc b/src/xenia/kernel/xam/xam_info.cc index a161011f0..b0818b04b 100644 --- a/src/xenia/kernel/xam/xam_info.cc +++ b/src/xenia/kernel/xam/xam_info.cc @@ -44,6 +44,7 @@ DEFINE_int32(avpack, 8, "Video"); DECLARE_int32(user_country); DECLARE_int32(user_language); +DECLARE_uint32(audio_flag); DEFINE_bool(staging_mode, 0, "Enables preview mode in dashboards to render debug information.", @@ -648,7 +649,7 @@ dword_result_t lstrlenW_entry(lpu16string_t string) { } DECLARE_XAM_EXPORT1(lstrlenW, kNone, kImplemented); -dword_result_t XGetAudioFlags_entry() { return 65537; } +dword_result_t XGetAudioFlags_entry() { return cvars::audio_flag; } DECLARE_XAM_EXPORT1(XGetAudioFlags, kNone, kStub); /* diff --git a/src/xenia/kernel/xboxkrnl/xboxkrnl_audio.cc b/src/xenia/kernel/xboxkrnl/xboxkrnl_audio.cc index c003f49ea..7a1139fe4 100644 --- a/src/xenia/kernel/xboxkrnl/xboxkrnl_audio.cc +++ b/src/xenia/kernel/xboxkrnl/xboxkrnl_audio.cc @@ -15,12 +15,14 @@ #include "xenia/kernel/xboxkrnl/xboxkrnl_private.h" #include "xenia/xbox.h" +DECLARE_uint32(audio_flag); + namespace xe { namespace kernel { namespace xboxkrnl { dword_result_t XAudioGetSpeakerConfig_entry(lpdword_t config_ptr) { - *config_ptr = 0x00010001; + *config_ptr = cvars::audio_flag; return X_ERROR_SUCCESS; } DECLARE_XBOXKRNL_EXPORT1(XAudioGetSpeakerConfig, kAudio, kImplemented); diff --git a/src/xenia/kernel/xboxkrnl/xboxkrnl_xconfig.cc b/src/xenia/kernel/xboxkrnl/xboxkrnl_xconfig.cc index 70e94a2fe..2c52aec22 100644 --- a/src/xenia/kernel/xboxkrnl/xboxkrnl_xconfig.cc +++ b/src/xenia/kernel/xboxkrnl/xboxkrnl_xconfig.cc @@ -37,6 +37,23 @@ DEFINE_int32(user_country, 103, " 102=UA 103=US 104=UY 105=UZ 106=VE 107=VN 108=YE 109=ZA\n", "XConfig"); +DEFINE_uint32( + audio_flag, 0x00010001, + "Audio Mode Analog.\n" + " 0x00000001 = Dolby Pro Logic\n" + " 0x00000002 = Analog Mono\n" + "Audio Mode Digital.\n" + " 0x00000000 = Digital Stereo (choose one of the above by itself)\n" + " 0x00010000 = Dolby Digital\n" + " 0x00030000 = Dolby Digital with WMA PRO\n" + "Special Flags.\n" + " 0x00000003 = Stereo Bypass\n" + " 0x80000000 = Low Latency\n" + " This Config requires you to pair an analog and digitial flag together\n" + " while digital stereo only requires an analog flag. Bonus flags are\n" + " optional. Ex) 0x00010001\n", + "XConfig"); + DECLARE_bool(widescreen); DECLARE_bool(use_50Hz_mode); DECLARE_int32(video_standard); @@ -109,6 +126,10 @@ X_STATUS xeExGetXConfigSetting(uint16_t category, uint16_t setting, xe::store_and_swap( value, cvars::widescreen ? 0x00050000 : 0x00040000); break; + case 0x000B: // XCONFIG_USER_AUDIO_FLAGS + setting_size = 4; + xe::store_and_swap(value, cvars::audio_flag); + break; case 0x000C: // XCONFIG_USER_RETAIL_FLAGS setting_size = 4; // TODO(benvanik): get this value.