From 6ac53cb98240fbea0fb6a902de95db64a09176b1 Mon Sep 17 00:00:00 2001 From: Gliniak Date: Fri, 10 Jan 2025 19:43:06 +0100 Subject: [PATCH 1/4] [Emulator] Added logging file extension and magic value --- src/xenia/emulator.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/src/xenia/emulator.cc b/src/xenia/emulator.cc index adb58570f..d41d1cf7d 100644 --- a/src/xenia/emulator.cc +++ b/src/xenia/emulator.cc @@ -505,6 +505,7 @@ Emulator::FileSignatureType Emulator::GetFileSignature( return FileSignatureType::XISO; } + XELOGE("{}: {} ({:08X})", __func__, path.extension(), magic_value); return FileSignatureType::Unknown; } From 247d16ffe73184f200c8c3aa0faa1e93b6e77ad5 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 2/4] [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. From 4d19245c4a4efe9b6cc1261054a5e877c758e75a Mon Sep 17 00:00:00 2001 From: The-Little-Wolf <116989599+The-Little-Wolf@users.noreply.github.com> Date: Fri, 17 Jan 2025 15:01:25 -0800 Subject: [PATCH 3/4] Revert "Merge remote-tracking branch 'upstream/canary_experimental' into canary_experimental" This reverts commit 6ac1f2b285035350bdbf2ed751d88caec13d60d7, reversing changes made to 65cf0d7c059d0ed452b177449fe8a1bc57c630d6. --- src/xenia/base/threading.h | 9 --------- src/xenia/base/threading_posix.cc | 16 ++-------------- src/xenia/emulator.cc | 6 ------ src/xenia/kernel/xam/xam_user.cc | 12 ------------ 4 files changed, 2 insertions(+), 41 deletions(-) diff --git a/src/xenia/base/threading.h b/src/xenia/base/threading.h index c0ac71647..6c336558e 100644 --- a/src/xenia/base/threading.h +++ b/src/xenia/base/threading.h @@ -410,15 +410,6 @@ struct ThreadPriority { static const int32_t kAboveNormal = 1; static const int32_t kHighest = 2; }; -#else -struct ThreadPriority { - static const int32_t kLowest = 1; - static const int32_t kBelowNormal = 8; - static const int32_t kNormal = 16; - static const int32_t kAboveNormal = 24; - static const int32_t kHighest = 32; -}; -#endif // Models a Win32-like thread object. // https://msdn.microsoft.com/en-us/library/windows/desktop/ms682453(v=vs.85).aspx diff --git a/src/xenia/base/threading_posix.cc b/src/xenia/base/threading_posix.cc index 733592800..f72f72d6f 100644 --- a/src/xenia/base/threading_posix.cc +++ b/src/xenia/base/threading_posix.cc @@ -27,8 +27,6 @@ #include #include -#include "logging.h" - #if XE_PLATFORM_ANDROID #include @@ -662,18 +660,8 @@ class PosixCondition : public PosixConditionBase { WaitStarted(); sched_param param{}; param.sched_priority = new_priority; - int res = pthread_setschedparam(thread_, SCHED_FIFO, ¶m); - if (res != 0) { - switch (res) { - case EPERM: - XELOGW("Permission denied while setting priority"); - break; - case EINVAL: - assert_always(); - default: - XELOGW("Unknown error while setting priority"); - } - } + if (pthread_setschedparam(thread_, SCHED_FIFO, ¶m) != 0) + assert_always(); } void QueueUserCallback(std::function callback) { diff --git a/src/xenia/emulator.cc b/src/xenia/emulator.cc index d41d1cf7d..665473244 100644 --- a/src/xenia/emulator.cc +++ b/src/xenia/emulator.cc @@ -1373,12 +1373,6 @@ X_STATUS Emulator::CompleteLaunch(const std::filesystem::path& path, return X_STATUS_NOT_FOUND; } - if (!module->is_executable()) { - kernel_state_->UnloadUserModule(module, false); - XELOGE("Failed to load user module {}", path); - return X_STATUS_NOT_SUPPORTED; - } - X_RESULT result = kernel_state_->ApplyTitleUpdate(module); if (XFAILED(result)) { XELOGE("Failed to apply title update! Cannot run module {}", path); diff --git a/src/xenia/kernel/xam/xam_user.cc b/src/xenia/kernel/xam/xam_user.cc index 3b311bc38..7802dffa6 100644 --- a/src/xenia/kernel/xam/xam_user.cc +++ b/src/xenia/kernel/xam/xam_user.cc @@ -799,18 +799,6 @@ dword_result_t XamUserGetUserFlagsFromXUID_entry(qword_t xuid) { } DECLARE_XAM_EXPORT1(XamUserGetUserFlagsFromXUID, kUserProfiles, kImplemented); -dword_result_t XamUserGetOnlineLanguageFromXUID_entry(qword_t xuid) { - /* Notes: - - Calls XamUserGetUserFlagsFromXUID and returns (ulonglong)(cached_flag << - 0x20) >> 0x39 & 0x1f; - - XamUserGetMembershipTierFromXUID and XamUserGetOnlineCountryFromXUID also - call it - - Removed in metro - */ - return cvars::user_language; -} -DECLARE_XAM_EXPORT1(XamUserGetOnlineLanguageFromXUID, kUserProfiles, kStub); - constexpr uint8_t kStatsMaxAmount = 64; struct X_STATS_DETAILS { From 5de1f23228e1bd1e6ccfeb258c34b486cc6518b3 Mon Sep 17 00:00:00 2001 From: The-Little-Wolf <116989599+The-Little-Wolf@users.noreply.github.com> Date: Fri, 17 Jan 2025 15:02:10 -0800 Subject: [PATCH 4/4] Reapply "Merge remote-tracking branch 'upstream/canary_experimental' into canary_experimental" This reverts commit fd3484f48753d2690d28a8cdd08f6b26f7c31336. --- src/xenia/base/threading.h | 9 +++++++++ src/xenia/base/threading_posix.cc | 16 ++++++++++++++-- src/xenia/emulator.cc | 6 ++++++ src/xenia/kernel/xam/xam_user.cc | 12 ++++++++++++ 4 files changed, 41 insertions(+), 2 deletions(-) diff --git a/src/xenia/base/threading.h b/src/xenia/base/threading.h index 6c336558e..c0ac71647 100644 --- a/src/xenia/base/threading.h +++ b/src/xenia/base/threading.h @@ -410,6 +410,15 @@ struct ThreadPriority { static const int32_t kAboveNormal = 1; static const int32_t kHighest = 2; }; +#else +struct ThreadPriority { + static const int32_t kLowest = 1; + static const int32_t kBelowNormal = 8; + static const int32_t kNormal = 16; + static const int32_t kAboveNormal = 24; + static const int32_t kHighest = 32; +}; +#endif // Models a Win32-like thread object. // https://msdn.microsoft.com/en-us/library/windows/desktop/ms682453(v=vs.85).aspx diff --git a/src/xenia/base/threading_posix.cc b/src/xenia/base/threading_posix.cc index f72f72d6f..733592800 100644 --- a/src/xenia/base/threading_posix.cc +++ b/src/xenia/base/threading_posix.cc @@ -27,6 +27,8 @@ #include #include +#include "logging.h" + #if XE_PLATFORM_ANDROID #include @@ -660,8 +662,18 @@ class PosixCondition : public PosixConditionBase { WaitStarted(); sched_param param{}; param.sched_priority = new_priority; - if (pthread_setschedparam(thread_, SCHED_FIFO, ¶m) != 0) - assert_always(); + int res = pthread_setschedparam(thread_, SCHED_FIFO, ¶m); + if (res != 0) { + switch (res) { + case EPERM: + XELOGW("Permission denied while setting priority"); + break; + case EINVAL: + assert_always(); + default: + XELOGW("Unknown error while setting priority"); + } + } } void QueueUserCallback(std::function callback) { diff --git a/src/xenia/emulator.cc b/src/xenia/emulator.cc index 665473244..d41d1cf7d 100644 --- a/src/xenia/emulator.cc +++ b/src/xenia/emulator.cc @@ -1373,6 +1373,12 @@ X_STATUS Emulator::CompleteLaunch(const std::filesystem::path& path, return X_STATUS_NOT_FOUND; } + if (!module->is_executable()) { + kernel_state_->UnloadUserModule(module, false); + XELOGE("Failed to load user module {}", path); + return X_STATUS_NOT_SUPPORTED; + } + X_RESULT result = kernel_state_->ApplyTitleUpdate(module); if (XFAILED(result)) { XELOGE("Failed to apply title update! Cannot run module {}", path); diff --git a/src/xenia/kernel/xam/xam_user.cc b/src/xenia/kernel/xam/xam_user.cc index 7802dffa6..3b311bc38 100644 --- a/src/xenia/kernel/xam/xam_user.cc +++ b/src/xenia/kernel/xam/xam_user.cc @@ -799,6 +799,18 @@ dword_result_t XamUserGetUserFlagsFromXUID_entry(qword_t xuid) { } DECLARE_XAM_EXPORT1(XamUserGetUserFlagsFromXUID, kUserProfiles, kImplemented); +dword_result_t XamUserGetOnlineLanguageFromXUID_entry(qword_t xuid) { + /* Notes: + - Calls XamUserGetUserFlagsFromXUID and returns (ulonglong)(cached_flag << + 0x20) >> 0x39 & 0x1f; + - XamUserGetMembershipTierFromXUID and XamUserGetOnlineCountryFromXUID also + call it + - Removed in metro + */ + return cvars::user_language; +} +DECLARE_XAM_EXPORT1(XamUserGetOnlineLanguageFromXUID, kUserProfiles, kStub); + constexpr uint8_t kStatsMaxAmount = 64; struct X_STATS_DETAILS {