diff options
Diffstat (limited to 'src')
78 files changed, 1519 insertions, 765 deletions
diff --git a/src/audio_core/audio_renderer.h b/src/audio_core/audio_renderer.h index 046417da3..71ba4be40 100644 --- a/src/audio_core/audio_renderer.h +++ b/src/audio_core/audio_renderer.h | |||
| @@ -143,7 +143,7 @@ struct AuxInfo { | |||
| 143 | std::array<u8, 24> output_mix_buffers; | 143 | std::array<u8, 24> output_mix_buffers; |
| 144 | u32_le mix_buffer_count; | 144 | u32_le mix_buffer_count; |
| 145 | u32_le sample_rate; // Stored in the aux buffer currently | 145 | u32_le sample_rate; // Stored in the aux buffer currently |
| 146 | u32_le sampe_count; | 146 | u32_le sample_count; |
| 147 | u64_le send_buffer_info; | 147 | u64_le send_buffer_info; |
| 148 | u64_le send_buffer_base; | 148 | u64_le send_buffer_base; |
| 149 | 149 | ||
diff --git a/src/common/bit_field.h b/src/common/bit_field.h index bf803da8d..21e07925d 100644 --- a/src/common/bit_field.h +++ b/src/common/bit_field.h | |||
| @@ -117,21 +117,21 @@ private: | |||
| 117 | // We don't delete it because we want BitField to be trivially copyable. | 117 | // We don't delete it because we want BitField to be trivially copyable. |
| 118 | constexpr BitField& operator=(const BitField&) = default; | 118 | constexpr BitField& operator=(const BitField&) = default; |
| 119 | 119 | ||
| 120 | // StorageType is T for non-enum types and the underlying type of T if | 120 | // UnderlyingType is T for non-enum types and the underlying type of T if |
| 121 | // T is an enumeration. Note that T is wrapped within an enable_if in the | 121 | // T is an enumeration. Note that T is wrapped within an enable_if in the |
| 122 | // former case to workaround compile errors which arise when using | 122 | // former case to workaround compile errors which arise when using |
| 123 | // std::underlying_type<T>::type directly. | 123 | // std::underlying_type<T>::type directly. |
| 124 | using StorageType = typename std::conditional_t<std::is_enum<T>::value, std::underlying_type<T>, | 124 | using UnderlyingType = typename std::conditional_t<std::is_enum_v<T>, std::underlying_type<T>, |
| 125 | std::enable_if<true, T>>::type; | 125 | std::enable_if<true, T>>::type; |
| 126 | 126 | ||
| 127 | // Unsigned version of StorageType | 127 | // We store the value as the unsigned type to avoid undefined behaviour on value shifting |
| 128 | using StorageTypeU = std::make_unsigned_t<StorageType>; | 128 | using StorageType = std::make_unsigned_t<UnderlyingType>; |
| 129 | 129 | ||
| 130 | public: | 130 | public: |
| 131 | /// Constants to allow limited introspection of fields if needed | 131 | /// Constants to allow limited introspection of fields if needed |
| 132 | static constexpr std::size_t position = Position; | 132 | static constexpr std::size_t position = Position; |
| 133 | static constexpr std::size_t bits = Bits; | 133 | static constexpr std::size_t bits = Bits; |
| 134 | static constexpr StorageType mask = (((StorageTypeU)~0) >> (8 * sizeof(T) - bits)) << position; | 134 | static constexpr StorageType mask = (((StorageType)~0) >> (8 * sizeof(T) - bits)) << position; |
| 135 | 135 | ||
| 136 | /** | 136 | /** |
| 137 | * Formats a value by masking and shifting it according to the field parameters. A value | 137 | * Formats a value by masking and shifting it according to the field parameters. A value |
| @@ -148,11 +148,12 @@ public: | |||
| 148 | * union in a constexpr context. | 148 | * union in a constexpr context. |
| 149 | */ | 149 | */ |
| 150 | static constexpr FORCE_INLINE T ExtractValue(const StorageType& storage) { | 150 | static constexpr FORCE_INLINE T ExtractValue(const StorageType& storage) { |
| 151 | if (std::numeric_limits<T>::is_signed) { | 151 | if constexpr (std::numeric_limits<UnderlyingType>::is_signed) { |
| 152 | std::size_t shift = 8 * sizeof(T) - bits; | 152 | std::size_t shift = 8 * sizeof(T) - bits; |
| 153 | return (T)((storage << (shift - position)) >> shift); | 153 | return static_cast<T>(static_cast<UnderlyingType>(storage << (shift - position)) >> |
| 154 | shift); | ||
| 154 | } else { | 155 | } else { |
| 155 | return (T)((storage & mask) >> position); | 156 | return static_cast<T>((storage & mask) >> position); |
| 156 | } | 157 | } |
| 157 | } | 158 | } |
| 158 | 159 | ||
diff --git a/src/common/string_util.cpp b/src/common/string_util.cpp index 731d1db34..14f7037d8 100644 --- a/src/common/string_util.cpp +++ b/src/common/string_util.cpp | |||
| @@ -4,11 +4,10 @@ | |||
| 4 | 4 | ||
| 5 | #include <algorithm> | 5 | #include <algorithm> |
| 6 | #include <cctype> | 6 | #include <cctype> |
| 7 | #include <cerrno> | ||
| 8 | #include <codecvt> | 7 | #include <codecvt> |
| 9 | #include <cstdio> | ||
| 10 | #include <cstdlib> | 8 | #include <cstdlib> |
| 11 | #include <cstring> | 9 | #include <locale> |
| 10 | #include <sstream> | ||
| 12 | #include "common/common_paths.h" | 11 | #include "common/common_paths.h" |
| 13 | #include "common/logging/log.h" | 12 | #include "common/logging/log.h" |
| 14 | #include "common/string_util.h" | 13 | #include "common/string_util.h" |
| @@ -33,24 +32,6 @@ std::string ToUpper(std::string str) { | |||
| 33 | return str; | 32 | return str; |
| 34 | } | 33 | } |
| 35 | 34 | ||
| 36 | // For Debugging. Read out an u8 array. | ||
| 37 | std::string ArrayToString(const u8* data, std::size_t size, int line_len, bool spaces) { | ||
| 38 | std::ostringstream oss; | ||
| 39 | oss << std::setfill('0') << std::hex; | ||
| 40 | |||
| 41 | for (int line = 0; size; ++data, --size) { | ||
| 42 | oss << std::setw(2) << (int)*data; | ||
| 43 | |||
| 44 | if (line_len == ++line) { | ||
| 45 | oss << '\n'; | ||
| 46 | line = 0; | ||
| 47 | } else if (spaces) | ||
| 48 | oss << ' '; | ||
| 49 | } | ||
| 50 | |||
| 51 | return oss.str(); | ||
| 52 | } | ||
| 53 | |||
| 54 | std::string StringFromBuffer(const std::vector<u8>& data) { | 35 | std::string StringFromBuffer(const std::vector<u8>& data) { |
| 55 | return std::string(data.begin(), std::find(data.begin(), data.end(), '\0')); | 36 | return std::string(data.begin(), std::find(data.begin(), data.end(), '\0')); |
| 56 | } | 37 | } |
| @@ -75,40 +56,6 @@ std::string StripQuotes(const std::string& s) { | |||
| 75 | return s; | 56 | return s; |
| 76 | } | 57 | } |
| 77 | 58 | ||
| 78 | bool TryParse(const std::string& str, u32* const output) { | ||
| 79 | char* endptr = nullptr; | ||
| 80 | |||
| 81 | // Reset errno to a value other than ERANGE | ||
| 82 | errno = 0; | ||
| 83 | |||
| 84 | unsigned long value = strtoul(str.c_str(), &endptr, 0); | ||
| 85 | |||
| 86 | if (!endptr || *endptr) | ||
| 87 | return false; | ||
| 88 | |||
| 89 | if (errno == ERANGE) | ||
| 90 | return false; | ||
| 91 | |||
| 92 | #if ULONG_MAX > UINT_MAX | ||
| 93 | if (value >= 0x100000000ull && value <= 0xFFFFFFFF00000000ull) | ||
| 94 | return false; | ||
| 95 | #endif | ||
| 96 | |||
| 97 | *output = static_cast<u32>(value); | ||
| 98 | return true; | ||
| 99 | } | ||
| 100 | |||
| 101 | bool TryParse(const std::string& str, bool* const output) { | ||
| 102 | if ("1" == str || "true" == ToLower(str)) | ||
| 103 | *output = true; | ||
| 104 | else if ("0" == str || "false" == ToLower(str)) | ||
| 105 | *output = false; | ||
| 106 | else | ||
| 107 | return false; | ||
| 108 | |||
| 109 | return true; | ||
| 110 | } | ||
| 111 | |||
| 112 | std::string StringFromBool(bool value) { | 59 | std::string StringFromBool(bool value) { |
| 113 | return value ? "True" : "False"; | 60 | return value ? "True" : "False"; |
| 114 | } | 61 | } |
diff --git a/src/common/string_util.h b/src/common/string_util.h index 32bf6a19c..08f96533b 100644 --- a/src/common/string_util.h +++ b/src/common/string_util.h | |||
| @@ -5,8 +5,6 @@ | |||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include <cstddef> | 7 | #include <cstddef> |
| 8 | #include <iomanip> | ||
| 9 | #include <sstream> | ||
| 10 | #include <string> | 8 | #include <string> |
| 11 | #include <vector> | 9 | #include <vector> |
| 12 | #include "common/common_types.h" | 10 | #include "common/common_types.h" |
| @@ -19,44 +17,13 @@ std::string ToLower(std::string str); | |||
| 19 | /// Make a string uppercase | 17 | /// Make a string uppercase |
| 20 | std::string ToUpper(std::string str); | 18 | std::string ToUpper(std::string str); |
| 21 | 19 | ||
| 22 | std::string ArrayToString(const u8* data, std::size_t size, int line_len = 20, bool spaces = true); | ||
| 23 | |||
| 24 | std::string StringFromBuffer(const std::vector<u8>& data); | 20 | std::string StringFromBuffer(const std::vector<u8>& data); |
| 25 | 21 | ||
| 26 | std::string StripSpaces(const std::string& s); | 22 | std::string StripSpaces(const std::string& s); |
| 27 | std::string StripQuotes(const std::string& s); | 23 | std::string StripQuotes(const std::string& s); |
| 28 | 24 | ||
| 29 | // Thousand separator. Turns 12345678 into 12,345,678 | ||
| 30 | template <typename I> | ||
| 31 | std::string ThousandSeparate(I value, int spaces = 0) { | ||
| 32 | std::ostringstream oss; | ||
| 33 | |||
| 34 | // std::locale("") seems to be broken on many platforms | ||
| 35 | #if defined _WIN32 || (defined __linux__ && !defined __clang__) | ||
| 36 | oss.imbue(std::locale("")); | ||
| 37 | #endif | ||
| 38 | oss << std::setw(spaces) << value; | ||
| 39 | |||
| 40 | return oss.str(); | ||
| 41 | } | ||
| 42 | |||
| 43 | std::string StringFromBool(bool value); | 25 | std::string StringFromBool(bool value); |
| 44 | 26 | ||
| 45 | bool TryParse(const std::string& str, bool* output); | ||
| 46 | bool TryParse(const std::string& str, u32* output); | ||
| 47 | |||
| 48 | template <typename N> | ||
| 49 | static bool TryParse(const std::string& str, N* const output) { | ||
| 50 | std::istringstream iss(str); | ||
| 51 | |||
| 52 | N tmp = 0; | ||
| 53 | if (iss >> tmp) { | ||
| 54 | *output = tmp; | ||
| 55 | return true; | ||
| 56 | } else | ||
| 57 | return false; | ||
| 58 | } | ||
| 59 | |||
| 60 | std::string TabsToSpaces(int tab_size, std::string in); | 27 | std::string TabsToSpaces(int tab_size, std::string in); |
| 61 | 28 | ||
| 62 | void SplitString(const std::string& str, char delim, std::vector<std::string>& output); | 29 | void SplitString(const std::string& str, char delim, std::vector<std::string>& output); |
diff --git a/src/core/file_sys/bis_factory.cpp b/src/core/file_sys/bis_factory.cpp index 76a2b7e86..e29f70b3a 100644 --- a/src/core/file_sys/bis_factory.cpp +++ b/src/core/file_sys/bis_factory.cpp | |||
| @@ -8,8 +8,9 @@ | |||
| 8 | 8 | ||
| 9 | namespace FileSys { | 9 | namespace FileSys { |
| 10 | 10 | ||
| 11 | BISFactory::BISFactory(VirtualDir nand_root_, VirtualDir load_root_) | 11 | BISFactory::BISFactory(VirtualDir nand_root_, VirtualDir load_root_, VirtualDir dump_root_) |
| 12 | : nand_root(std::move(nand_root_)), load_root(std::move(load_root_)), | 12 | : nand_root(std::move(nand_root_)), load_root(std::move(load_root_)), |
| 13 | dump_root(std::move(dump_root_)), | ||
| 13 | sysnand_cache(std::make_unique<RegisteredCache>( | 14 | sysnand_cache(std::make_unique<RegisteredCache>( |
| 14 | GetOrCreateDirectoryRelative(nand_root, "/system/Contents/registered"))), | 15 | GetOrCreateDirectoryRelative(nand_root, "/system/Contents/registered"))), |
| 15 | usrnand_cache(std::make_unique<RegisteredCache>( | 16 | usrnand_cache(std::make_unique<RegisteredCache>( |
| @@ -32,4 +33,10 @@ VirtualDir BISFactory::GetModificationLoadRoot(u64 title_id) const { | |||
| 32 | return GetOrCreateDirectoryRelative(load_root, fmt::format("/{:016X}", title_id)); | 33 | return GetOrCreateDirectoryRelative(load_root, fmt::format("/{:016X}", title_id)); |
| 33 | } | 34 | } |
| 34 | 35 | ||
| 36 | VirtualDir BISFactory::GetModificationDumpRoot(u64 title_id) const { | ||
| 37 | if (title_id == 0) | ||
| 38 | return nullptr; | ||
| 39 | return GetOrCreateDirectoryRelative(dump_root, fmt::format("/{:016X}", title_id)); | ||
| 40 | } | ||
| 41 | |||
| 35 | } // namespace FileSys | 42 | } // namespace FileSys |
diff --git a/src/core/file_sys/bis_factory.h b/src/core/file_sys/bis_factory.h index 364d309bd..453c11ad2 100644 --- a/src/core/file_sys/bis_factory.h +++ b/src/core/file_sys/bis_factory.h | |||
| @@ -17,17 +17,19 @@ class RegisteredCache; | |||
| 17 | /// registered caches. | 17 | /// registered caches. |
| 18 | class BISFactory { | 18 | class BISFactory { |
| 19 | public: | 19 | public: |
| 20 | explicit BISFactory(VirtualDir nand_root, VirtualDir load_root); | 20 | explicit BISFactory(VirtualDir nand_root, VirtualDir load_root, VirtualDir dump_root); |
| 21 | ~BISFactory(); | 21 | ~BISFactory(); |
| 22 | 22 | ||
| 23 | RegisteredCache* GetSystemNANDContents() const; | 23 | RegisteredCache* GetSystemNANDContents() const; |
| 24 | RegisteredCache* GetUserNANDContents() const; | 24 | RegisteredCache* GetUserNANDContents() const; |
| 25 | 25 | ||
| 26 | VirtualDir GetModificationLoadRoot(u64 title_id) const; | 26 | VirtualDir GetModificationLoadRoot(u64 title_id) const; |
| 27 | VirtualDir GetModificationDumpRoot(u64 title_id) const; | ||
| 27 | 28 | ||
| 28 | private: | 29 | private: |
| 29 | VirtualDir nand_root; | 30 | VirtualDir nand_root; |
| 30 | VirtualDir load_root; | 31 | VirtualDir load_root; |
| 32 | VirtualDir dump_root; | ||
| 31 | 33 | ||
| 32 | std::unique_ptr<RegisteredCache> sysnand_cache; | 34 | std::unique_ptr<RegisteredCache> sysnand_cache; |
| 33 | std::unique_ptr<RegisteredCache> usrnand_cache; | 35 | std::unique_ptr<RegisteredCache> usrnand_cache; |
diff --git a/src/core/file_sys/card_image.cpp b/src/core/file_sys/card_image.cpp index 1ece55731..2c145bd09 100644 --- a/src/core/file_sys/card_image.cpp +++ b/src/core/file_sys/card_image.cpp | |||
| @@ -176,7 +176,7 @@ Loader::ResultStatus XCI::AddNCAFromPartition(XCIPartition part) { | |||
| 176 | for (const VirtualFile& file : partitions[static_cast<std::size_t>(part)]->GetFiles()) { | 176 | for (const VirtualFile& file : partitions[static_cast<std::size_t>(part)]->GetFiles()) { |
| 177 | if (file->GetExtension() != "nca") | 177 | if (file->GetExtension() != "nca") |
| 178 | continue; | 178 | continue; |
| 179 | auto nca = std::make_shared<NCA>(file); | 179 | auto nca = std::make_shared<NCA>(file, nullptr, 0, keys); |
| 180 | // TODO(DarkLordZach): Add proper Rev1+ Support | 180 | // TODO(DarkLordZach): Add proper Rev1+ Support |
| 181 | if (nca->IsUpdate()) | 181 | if (nca->IsUpdate()) |
| 182 | continue; | 182 | continue; |
diff --git a/src/core/file_sys/card_image.h b/src/core/file_sys/card_image.h index 8f62571cf..25f5914b6 100644 --- a/src/core/file_sys/card_image.h +++ b/src/core/file_sys/card_image.h | |||
| @@ -9,6 +9,7 @@ | |||
| 9 | #include <vector> | 9 | #include <vector> |
| 10 | #include "common/common_types.h" | 10 | #include "common/common_types.h" |
| 11 | #include "common/swap.h" | 11 | #include "common/swap.h" |
| 12 | #include "core/crypto/key_manager.h" | ||
| 12 | #include "core/file_sys/vfs.h" | 13 | #include "core/file_sys/vfs.h" |
| 13 | 14 | ||
| 14 | namespace Loader { | 15 | namespace Loader { |
| @@ -107,5 +108,7 @@ private: | |||
| 107 | std::shared_ptr<NSP> secure_partition; | 108 | std::shared_ptr<NSP> secure_partition; |
| 108 | std::shared_ptr<NCA> program; | 109 | std::shared_ptr<NCA> program; |
| 109 | std::vector<std::shared_ptr<NCA>> ncas; | 110 | std::vector<std::shared_ptr<NCA>> ncas; |
| 111 | |||
| 112 | Core::Crypto::KeyManager keys; | ||
| 110 | }; | 113 | }; |
| 111 | } // namespace FileSys | 114 | } // namespace FileSys |
diff --git a/src/core/file_sys/content_archive.cpp b/src/core/file_sys/content_archive.cpp index b46fe893c..19b6f8600 100644 --- a/src/core/file_sys/content_archive.cpp +++ b/src/core/file_sys/content_archive.cpp | |||
| @@ -101,8 +101,9 @@ static bool IsValidNCA(const NCAHeader& header) { | |||
| 101 | return header.magic == Common::MakeMagic('N', 'C', 'A', '3'); | 101 | return header.magic == Common::MakeMagic('N', 'C', 'A', '3'); |
| 102 | } | 102 | } |
| 103 | 103 | ||
| 104 | NCA::NCA(VirtualFile file_, VirtualFile bktr_base_romfs_, u64 bktr_base_ivfc_offset) | 104 | NCA::NCA(VirtualFile file_, VirtualFile bktr_base_romfs_, u64 bktr_base_ivfc_offset, |
| 105 | : file(std::move(file_)), bktr_base_romfs(std::move(bktr_base_romfs_)) { | 105 | Core::Crypto::KeyManager keys_) |
| 106 | : file(std::move(file_)), bktr_base_romfs(std::move(bktr_base_romfs_)), keys(std::move(keys_)) { | ||
| 106 | if (file == nullptr) { | 107 | if (file == nullptr) { |
| 107 | status = Loader::ResultStatus::ErrorNullFile; | 108 | status = Loader::ResultStatus::ErrorNullFile; |
| 108 | return; | 109 | return; |
diff --git a/src/core/file_sys/content_archive.h b/src/core/file_sys/content_archive.h index 4bba55607..99294cbb4 100644 --- a/src/core/file_sys/content_archive.h +++ b/src/core/file_sys/content_archive.h | |||
| @@ -79,7 +79,8 @@ inline bool IsDirectoryExeFS(const std::shared_ptr<VfsDirectory>& pfs) { | |||
| 79 | class NCA : public ReadOnlyVfsDirectory { | 79 | class NCA : public ReadOnlyVfsDirectory { |
| 80 | public: | 80 | public: |
| 81 | explicit NCA(VirtualFile file, VirtualFile bktr_base_romfs = nullptr, | 81 | explicit NCA(VirtualFile file, VirtualFile bktr_base_romfs = nullptr, |
| 82 | u64 bktr_base_ivfc_offset = 0); | 82 | u64 bktr_base_ivfc_offset = 0, |
| 83 | Core::Crypto::KeyManager keys = Core::Crypto::KeyManager()); | ||
| 83 | ~NCA() override; | 84 | ~NCA() override; |
| 84 | 85 | ||
| 85 | Loader::ResultStatus GetStatus() const; | 86 | Loader::ResultStatus GetStatus() const; |
diff --git a/src/core/file_sys/control_metadata.cpp b/src/core/file_sys/control_metadata.cpp index a012c2be9..c8fa912bf 100644 --- a/src/core/file_sys/control_metadata.cpp +++ b/src/core/file_sys/control_metadata.cpp | |||
| @@ -66,4 +66,10 @@ std::string NACP::GetVersionString() const { | |||
| 66 | return Common::StringFromFixedZeroTerminatedBuffer(raw->version_string.data(), | 66 | return Common::StringFromFixedZeroTerminatedBuffer(raw->version_string.data(), |
| 67 | raw->version_string.size()); | 67 | raw->version_string.size()); |
| 68 | } | 68 | } |
| 69 | |||
| 70 | std::vector<u8> NACP::GetRawBytes() const { | ||
| 71 | std::vector<u8> out(sizeof(RawNACP)); | ||
| 72 | std::memcpy(out.data(), raw.get(), sizeof(RawNACP)); | ||
| 73 | return out; | ||
| 74 | } | ||
| 69 | } // namespace FileSys | 75 | } // namespace FileSys |
diff --git a/src/core/file_sys/control_metadata.h b/src/core/file_sys/control_metadata.h index 141f7e056..bfaad46b4 100644 --- a/src/core/file_sys/control_metadata.h +++ b/src/core/file_sys/control_metadata.h | |||
| @@ -81,6 +81,7 @@ public: | |||
| 81 | u64 GetTitleId() const; | 81 | u64 GetTitleId() const; |
| 82 | u64 GetDLCBaseTitleId() const; | 82 | u64 GetDLCBaseTitleId() const; |
| 83 | std::string GetVersionString() const; | 83 | std::string GetVersionString() const; |
| 84 | std::vector<u8> GetRawBytes() const; | ||
| 84 | 85 | ||
| 85 | private: | 86 | private: |
| 86 | std::unique_ptr<RawNACP> raw; | 87 | std::unique_ptr<RawNACP> raw; |
diff --git a/src/core/file_sys/errors.h b/src/core/file_sys/errors.h index fea0593c7..e4a4ee4ab 100644 --- a/src/core/file_sys/errors.h +++ b/src/core/file_sys/errors.h | |||
| @@ -8,25 +8,10 @@ | |||
| 8 | 8 | ||
| 9 | namespace FileSys { | 9 | namespace FileSys { |
| 10 | 10 | ||
| 11 | namespace ErrCodes { | 11 | constexpr ResultCode ERROR_PATH_NOT_FOUND{ErrorModule::FS, 1}; |
| 12 | enum { | 12 | constexpr ResultCode ERROR_ENTITY_NOT_FOUND{ErrorModule::FS, 1002}; |
| 13 | NotFound = 1, | 13 | constexpr ResultCode ERROR_SD_CARD_NOT_FOUND{ErrorModule::FS, 2001}; |
| 14 | TitleNotFound = 1002, | 14 | constexpr ResultCode ERROR_INVALID_OFFSET{ErrorModule::FS, 6061}; |
| 15 | SdCardNotFound = 2001, | 15 | constexpr ResultCode ERROR_INVALID_SIZE{ErrorModule::FS, 6062}; |
| 16 | RomFSNotFound = 2520, | ||
| 17 | }; | ||
| 18 | } | ||
| 19 | |||
| 20 | constexpr ResultCode ERROR_PATH_NOT_FOUND(ErrorModule::FS, ErrCodes::NotFound); | ||
| 21 | |||
| 22 | // TODO(bunnei): Replace these with correct errors for Switch OS | ||
| 23 | constexpr ResultCode ERROR_INVALID_PATH(-1); | ||
| 24 | constexpr ResultCode ERROR_UNSUPPORTED_OPEN_FLAGS(-1); | ||
| 25 | constexpr ResultCode ERROR_INVALID_OPEN_FLAGS(-1); | ||
| 26 | constexpr ResultCode ERROR_FILE_NOT_FOUND(-1); | ||
| 27 | constexpr ResultCode ERROR_UNEXPECTED_FILE_OR_DIRECTORY(-1); | ||
| 28 | constexpr ResultCode ERROR_DIRECTORY_ALREADY_EXISTS(-1); | ||
| 29 | constexpr ResultCode ERROR_FILE_ALREADY_EXISTS(-1); | ||
| 30 | constexpr ResultCode ERROR_DIRECTORY_NOT_EMPTY(-1); | ||
| 31 | 16 | ||
| 32 | } // namespace FileSys | 17 | } // namespace FileSys |
diff --git a/src/core/file_sys/patch_manager.cpp b/src/core/file_sys/patch_manager.cpp index 0c1156989..8d062eb3e 100644 --- a/src/core/file_sys/patch_manager.cpp +++ b/src/core/file_sys/patch_manager.cpp | |||
| @@ -19,6 +19,7 @@ | |||
| 19 | #include "core/file_sys/vfs_vector.h" | 19 | #include "core/file_sys/vfs_vector.h" |
| 20 | #include "core/hle/service/filesystem/filesystem.h" | 20 | #include "core/hle/service/filesystem/filesystem.h" |
| 21 | #include "core/loader/loader.h" | 21 | #include "core/loader/loader.h" |
| 22 | #include "core/settings.h" | ||
| 22 | 23 | ||
| 23 | namespace FileSys { | 24 | namespace FileSys { |
| 24 | 25 | ||
| @@ -119,6 +120,18 @@ std::vector<u8> PatchManager::PatchNSO(const std::vector<u8>& nso) const { | |||
| 119 | const auto build_id_raw = Common::HexArrayToString(header.build_id); | 120 | const auto build_id_raw = Common::HexArrayToString(header.build_id); |
| 120 | const auto build_id = build_id_raw.substr(0, build_id_raw.find_last_not_of('0') + 1); | 121 | const auto build_id = build_id_raw.substr(0, build_id_raw.find_last_not_of('0') + 1); |
| 121 | 122 | ||
| 123 | if (Settings::values.dump_nso) { | ||
| 124 | LOG_INFO(Loader, "Dumping NSO for build_id={}, title_id={:016X}", build_id, title_id); | ||
| 125 | const auto dump_dir = Service::FileSystem::GetModificationDumpRoot(title_id); | ||
| 126 | if (dump_dir != nullptr) { | ||
| 127 | const auto nso_dir = GetOrCreateDirectoryRelative(dump_dir, "/nso"); | ||
| 128 | const auto file = nso_dir->CreateFile(fmt::format("{}.nso", build_id)); | ||
| 129 | |||
| 130 | file->Resize(nso.size()); | ||
| 131 | file->WriteBytes(nso); | ||
| 132 | } | ||
| 133 | } | ||
| 134 | |||
| 122 | LOG_INFO(Loader, "Patching NSO for build_id={}", build_id); | 135 | LOG_INFO(Loader, "Patching NSO for build_id={}", build_id); |
| 123 | 136 | ||
| 124 | const auto load_dir = Service::FileSystem::GetModificationLoadRoot(title_id); | 137 | const auto load_dir = Service::FileSystem::GetModificationLoadRoot(title_id); |
diff --git a/src/core/file_sys/registered_cache.cpp b/src/core/file_sys/registered_cache.cpp index 96302a241..a3f8f2f73 100644 --- a/src/core/file_sys/registered_cache.cpp +++ b/src/core/file_sys/registered_cache.cpp | |||
| @@ -106,9 +106,12 @@ static ContentRecordType GetCRTypeFromNCAType(NCAContentType type) { | |||
| 106 | 106 | ||
| 107 | VirtualFile RegisteredCache::OpenFileOrDirectoryConcat(const VirtualDir& dir, | 107 | VirtualFile RegisteredCache::OpenFileOrDirectoryConcat(const VirtualDir& dir, |
| 108 | std::string_view path) const { | 108 | std::string_view path) const { |
| 109 | if (dir->GetFileRelative(path) != nullptr) | 109 | const auto file = dir->GetFileRelative(path); |
| 110 | return dir->GetFileRelative(path); | 110 | if (file != nullptr) |
| 111 | if (dir->GetDirectoryRelative(path) != nullptr) { | 111 | return file; |
| 112 | |||
| 113 | const auto nca_dir = dir->GetDirectoryRelative(path); | ||
| 114 | if (nca_dir != nullptr) { | ||
| 112 | const auto nca_dir = dir->GetDirectoryRelative(path); | 115 | const auto nca_dir = dir->GetDirectoryRelative(path); |
| 113 | VirtualFile file = nullptr; | 116 | VirtualFile file = nullptr; |
| 114 | 117 | ||
| @@ -225,7 +228,7 @@ void RegisteredCache::ProcessFiles(const std::vector<NcaID>& ids) { | |||
| 225 | 228 | ||
| 226 | if (file == nullptr) | 229 | if (file == nullptr) |
| 227 | continue; | 230 | continue; |
| 228 | const auto nca = std::make_shared<NCA>(parser(file, id)); | 231 | const auto nca = std::make_shared<NCA>(parser(file, id), nullptr, 0, keys); |
| 229 | if (nca->GetStatus() != Loader::ResultStatus::Success || | 232 | if (nca->GetStatus() != Loader::ResultStatus::Success || |
| 230 | nca->GetType() != NCAContentType::Meta) { | 233 | nca->GetType() != NCAContentType::Meta) { |
| 231 | continue; | 234 | continue; |
| @@ -315,7 +318,7 @@ std::unique_ptr<NCA> RegisteredCache::GetEntry(u64 title_id, ContentRecordType t | |||
| 315 | const auto raw = GetEntryRaw(title_id, type); | 318 | const auto raw = GetEntryRaw(title_id, type); |
| 316 | if (raw == nullptr) | 319 | if (raw == nullptr) |
| 317 | return nullptr; | 320 | return nullptr; |
| 318 | return std::make_unique<NCA>(raw); | 321 | return std::make_unique<NCA>(raw, nullptr, 0, keys); |
| 319 | } | 322 | } |
| 320 | 323 | ||
| 321 | std::unique_ptr<NCA> RegisteredCache::GetEntry(RegisteredCacheEntry entry) const { | 324 | std::unique_ptr<NCA> RegisteredCache::GetEntry(RegisteredCacheEntry entry) const { |
diff --git a/src/core/file_sys/registered_cache.h b/src/core/file_sys/registered_cache.h index 6cfb16017..6b89db8de 100644 --- a/src/core/file_sys/registered_cache.h +++ b/src/core/file_sys/registered_cache.h | |||
| @@ -12,6 +12,7 @@ | |||
| 12 | #include <vector> | 12 | #include <vector> |
| 13 | #include <boost/container/flat_map.hpp> | 13 | #include <boost/container/flat_map.hpp> |
| 14 | #include "common/common_types.h" | 14 | #include "common/common_types.h" |
| 15 | #include "core/crypto/key_manager.h" | ||
| 15 | #include "core/file_sys/vfs.h" | 16 | #include "core/file_sys/vfs.h" |
| 16 | 17 | ||
| 17 | namespace FileSys { | 18 | namespace FileSys { |
| @@ -133,6 +134,8 @@ private: | |||
| 133 | 134 | ||
| 134 | VirtualDir dir; | 135 | VirtualDir dir; |
| 135 | RegisteredCacheParsingFunction parser; | 136 | RegisteredCacheParsingFunction parser; |
| 137 | Core::Crypto::KeyManager keys; | ||
| 138 | |||
| 136 | // maps tid -> NcaID of meta | 139 | // maps tid -> NcaID of meta |
| 137 | boost::container::flat_map<u64, NcaID> meta_id; | 140 | boost::container::flat_map<u64, NcaID> meta_id; |
| 138 | // maps tid -> meta | 141 | // maps tid -> meta |
diff --git a/src/core/file_sys/savedata_factory.cpp b/src/core/file_sys/savedata_factory.cpp index ef1aaebbb..5434f2149 100644 --- a/src/core/file_sys/savedata_factory.cpp +++ b/src/core/file_sys/savedata_factory.cpp | |||
| @@ -83,28 +83,32 @@ ResultVal<VirtualDir> SaveDataFactory::Open(SaveDataSpaceId space, SaveDataDescr | |||
| 83 | return MakeResult<VirtualDir>(std::move(out)); | 83 | return MakeResult<VirtualDir>(std::move(out)); |
| 84 | } | 84 | } |
| 85 | 85 | ||
| 86 | std::string SaveDataFactory::GetFullPath(SaveDataSpaceId space, SaveDataType type, u64 title_id, | 86 | VirtualDir SaveDataFactory::GetSaveDataSpaceDirectory(SaveDataSpaceId space) const { |
| 87 | u128 user_id, u64 save_id) { | 87 | return dir->GetDirectoryRelative(GetSaveDataSpaceIdPath(space)); |
| 88 | // According to switchbrew, if a save is of type SaveData and the title id field is 0, it should | 88 | } |
| 89 | // be interpreted as the title id of the current process. | ||
| 90 | if (type == SaveDataType::SaveData && title_id == 0) | ||
| 91 | title_id = Core::CurrentProcess()->GetTitleID(); | ||
| 92 | |||
| 93 | std::string out; | ||
| 94 | 89 | ||
| 90 | std::string SaveDataFactory::GetSaveDataSpaceIdPath(SaveDataSpaceId space) { | ||
| 95 | switch (space) { | 91 | switch (space) { |
| 96 | case SaveDataSpaceId::NandSystem: | 92 | case SaveDataSpaceId::NandSystem: |
| 97 | out = "/system/"; | 93 | return "/system/"; |
| 98 | break; | ||
| 99 | case SaveDataSpaceId::NandUser: | 94 | case SaveDataSpaceId::NandUser: |
| 100 | out = "/user/"; | 95 | return "/user/"; |
| 101 | break; | ||
| 102 | case SaveDataSpaceId::TemporaryStorage: | 96 | case SaveDataSpaceId::TemporaryStorage: |
| 103 | out = "/temp/"; | 97 | return "/temp/"; |
| 104 | break; | ||
| 105 | default: | 98 | default: |
| 106 | ASSERT_MSG(false, "Unrecognized SaveDataSpaceId: {:02X}", static_cast<u8>(space)); | 99 | ASSERT_MSG(false, "Unrecognized SaveDataSpaceId: {:02X}", static_cast<u8>(space)); |
| 100 | return "/unrecognized/"; ///< To prevent corruption when ignoring asserts. | ||
| 107 | } | 101 | } |
| 102 | } | ||
| 103 | |||
| 104 | std::string SaveDataFactory::GetFullPath(SaveDataSpaceId space, SaveDataType type, u64 title_id, | ||
| 105 | u128 user_id, u64 save_id) { | ||
| 106 | // According to switchbrew, if a save is of type SaveData and the title id field is 0, it should | ||
| 107 | // be interpreted as the title id of the current process. | ||
| 108 | if (type == SaveDataType::SaveData && title_id == 0) | ||
| 109 | title_id = Core::CurrentProcess()->GetTitleID(); | ||
| 110 | |||
| 111 | std::string out = GetSaveDataSpaceIdPath(space); | ||
| 108 | 112 | ||
| 109 | switch (type) { | 113 | switch (type) { |
| 110 | case SaveDataType::SystemSaveData: | 114 | case SaveDataType::SystemSaveData: |
diff --git a/src/core/file_sys/savedata_factory.h b/src/core/file_sys/savedata_factory.h index d69ef6741..2a0088040 100644 --- a/src/core/file_sys/savedata_factory.h +++ b/src/core/file_sys/savedata_factory.h | |||
| @@ -52,6 +52,9 @@ public: | |||
| 52 | 52 | ||
| 53 | ResultVal<VirtualDir> Open(SaveDataSpaceId space, SaveDataDescriptor meta); | 53 | ResultVal<VirtualDir> Open(SaveDataSpaceId space, SaveDataDescriptor meta); |
| 54 | 54 | ||
| 55 | VirtualDir GetSaveDataSpaceDirectory(SaveDataSpaceId space) const; | ||
| 56 | |||
| 57 | static std::string GetSaveDataSpaceIdPath(SaveDataSpaceId space); | ||
| 55 | static std::string GetFullPath(SaveDataSpaceId space, SaveDataType type, u64 title_id, | 58 | static std::string GetFullPath(SaveDataSpaceId space, SaveDataType type, u64 title_id, |
| 56 | u128 user_id, u64 save_id); | 59 | u128 user_id, u64 save_id); |
| 57 | 60 | ||
diff --git a/src/core/file_sys/submission_package.cpp b/src/core/file_sys/submission_package.cpp index 2aaba4179..e1a4210db 100644 --- a/src/core/file_sys/submission_package.cpp +++ b/src/core/file_sys/submission_package.cpp | |||
| @@ -252,7 +252,7 @@ void NSP::ReadNCAs(const std::vector<VirtualFile>& files) { | |||
| 252 | continue; | 252 | continue; |
| 253 | } | 253 | } |
| 254 | 254 | ||
| 255 | auto next_nca = std::make_shared<NCA>(next_file); | 255 | auto next_nca = std::make_shared<NCA>(next_file, nullptr, 0, keys); |
| 256 | if (next_nca->GetType() == NCAContentType::Program) | 256 | if (next_nca->GetType() == NCAContentType::Program) |
| 257 | program_status[cnmt.GetTitleID()] = next_nca->GetStatus(); | 257 | program_status[cnmt.GetTitleID()] = next_nca->GetStatus(); |
| 258 | if (next_nca->GetStatus() == Loader::ResultStatus::Success || | 258 | if (next_nca->GetStatus() == Loader::ResultStatus::Success || |
diff --git a/src/core/file_sys/submission_package.h b/src/core/file_sys/submission_package.h index 338080b7e..9a28ed5bb 100644 --- a/src/core/file_sys/submission_package.h +++ b/src/core/file_sys/submission_package.h | |||
| @@ -70,6 +70,8 @@ private: | |||
| 70 | std::map<u64, std::map<ContentRecordType, std::shared_ptr<NCA>>> ncas; | 70 | std::map<u64, std::map<ContentRecordType, std::shared_ptr<NCA>>> ncas; |
| 71 | std::vector<VirtualFile> ticket_files; | 71 | std::vector<VirtualFile> ticket_files; |
| 72 | 72 | ||
| 73 | Core::Crypto::KeyManager keys; | ||
| 74 | |||
| 73 | VirtualFile romfs; | 75 | VirtualFile romfs; |
| 74 | VirtualDir exefs; | 76 | VirtualDir exefs; |
| 75 | }; | 77 | }; |
diff --git a/src/core/hle/kernel/errors.h b/src/core/hle/kernel/errors.h index ee698c8a7..8b58d701d 100644 --- a/src/core/hle/kernel/errors.h +++ b/src/core/hle/kernel/errors.h | |||
| @@ -8,58 +8,28 @@ | |||
| 8 | 8 | ||
| 9 | namespace Kernel { | 9 | namespace Kernel { |
| 10 | 10 | ||
| 11 | namespace ErrCodes { | 11 | // Confirmed Switch kernel error codes |
| 12 | enum { | ||
| 13 | // Confirmed Switch OS error codes | ||
| 14 | MaxConnectionsReached = 7, | ||
| 15 | InvalidSize = 101, | ||
| 16 | InvalidAddress = 102, | ||
| 17 | HandleTableFull = 105, | ||
| 18 | InvalidMemoryState = 106, | ||
| 19 | InvalidMemoryPermissions = 108, | ||
| 20 | InvalidMemoryRange = 110, | ||
| 21 | InvalidThreadPriority = 112, | ||
| 22 | InvalidProcessorId = 113, | ||
| 23 | InvalidHandle = 114, | ||
| 24 | InvalidPointer = 115, | ||
| 25 | InvalidCombination = 116, | ||
| 26 | Timeout = 117, | ||
| 27 | SynchronizationCanceled = 118, | ||
| 28 | TooLarge = 119, | ||
| 29 | InvalidEnumValue = 120, | ||
| 30 | NoSuchEntry = 121, | ||
| 31 | AlreadyRegistered = 122, | ||
| 32 | SessionClosed = 123, | ||
| 33 | InvalidState = 125, | ||
| 34 | ResourceLimitExceeded = 132, | ||
| 35 | }; | ||
| 36 | } | ||
| 37 | 12 | ||
| 38 | // WARNING: The kernel is quite inconsistent in it's usage of errors code. Make sure to always | 13 | constexpr ResultCode ERR_MAX_CONNECTIONS_REACHED{ErrorModule::Kernel, 7}; |
| 39 | // double check that the code matches before re-using the constant. | 14 | constexpr ResultCode ERR_INVALID_SIZE{ErrorModule::Kernel, 101}; |
| 40 | 15 | constexpr ResultCode ERR_INVALID_ADDRESS{ErrorModule::Kernel, 102}; | |
| 41 | constexpr ResultCode ERR_HANDLE_TABLE_FULL(ErrorModule::Kernel, ErrCodes::HandleTableFull); | 16 | constexpr ResultCode ERR_HANDLE_TABLE_FULL{ErrorModule::Kernel, 105}; |
| 42 | constexpr ResultCode ERR_SESSION_CLOSED_BY_REMOTE(ErrorModule::Kernel, ErrCodes::SessionClosed); | 17 | constexpr ResultCode ERR_INVALID_ADDRESS_STATE{ErrorModule::Kernel, 106}; |
| 43 | constexpr ResultCode ERR_PORT_NAME_TOO_LONG(ErrorModule::Kernel, ErrCodes::TooLarge); | 18 | constexpr ResultCode ERR_INVALID_MEMORY_PERMISSIONS{ErrorModule::Kernel, 108}; |
| 44 | constexpr ResultCode ERR_MAX_CONNECTIONS_REACHED(ErrorModule::Kernel, | 19 | constexpr ResultCode ERR_INVALID_MEMORY_RANGE{ErrorModule::Kernel, 110}; |
| 45 | ErrCodes::MaxConnectionsReached); | 20 | constexpr ResultCode ERR_INVALID_PROCESSOR_ID{ErrorModule::Kernel, 113}; |
| 46 | constexpr ResultCode ERR_INVALID_ENUM_VALUE(ErrorModule::Kernel, ErrCodes::InvalidEnumValue); | 21 | constexpr ResultCode ERR_INVALID_THREAD_PRIORITY{ErrorModule::Kernel, 112}; |
| 47 | constexpr ResultCode ERR_INVALID_COMBINATION_KERNEL(ErrorModule::Kernel, | 22 | constexpr ResultCode ERR_INVALID_HANDLE{ErrorModule::Kernel, 114}; |
| 48 | ErrCodes::InvalidCombination); | 23 | constexpr ResultCode ERR_INVALID_POINTER{ErrorModule::Kernel, 115}; |
| 49 | constexpr ResultCode ERR_INVALID_ADDRESS(ErrorModule::Kernel, ErrCodes::InvalidAddress); | 24 | constexpr ResultCode ERR_INVALID_COMBINATION{ErrorModule::Kernel, 116}; |
| 50 | constexpr ResultCode ERR_INVALID_ADDRESS_STATE(ErrorModule::Kernel, ErrCodes::InvalidMemoryState); | 25 | constexpr ResultCode RESULT_TIMEOUT{ErrorModule::Kernel, 117}; |
| 51 | constexpr ResultCode ERR_INVALID_MEMORY_PERMISSIONS(ErrorModule::Kernel, | 26 | constexpr ResultCode ERR_SYNCHRONIZATION_CANCELED{ErrorModule::Kernel, 118}; |
| 52 | ErrCodes::InvalidMemoryPermissions); | 27 | constexpr ResultCode ERR_OUT_OF_RANGE{ErrorModule::Kernel, 119}; |
| 53 | constexpr ResultCode ERR_INVALID_MEMORY_RANGE(ErrorModule::Kernel, ErrCodes::InvalidMemoryRange); | 28 | constexpr ResultCode ERR_INVALID_ENUM_VALUE{ErrorModule::Kernel, 120}; |
| 54 | constexpr ResultCode ERR_INVALID_HANDLE(ErrorModule::Kernel, ErrCodes::InvalidHandle); | 29 | constexpr ResultCode ERR_NOT_FOUND{ErrorModule::Kernel, 121}; |
| 55 | constexpr ResultCode ERR_INVALID_PROCESSOR_ID(ErrorModule::Kernel, ErrCodes::InvalidProcessorId); | 30 | constexpr ResultCode ERR_ALREADY_REGISTERED{ErrorModule::Kernel, 122}; |
| 56 | constexpr ResultCode ERR_INVALID_SIZE(ErrorModule::Kernel, ErrCodes::InvalidSize); | 31 | constexpr ResultCode ERR_SESSION_CLOSED_BY_REMOTE{ErrorModule::Kernel, 123}; |
| 57 | constexpr ResultCode ERR_ALREADY_REGISTERED(ErrorModule::Kernel, ErrCodes::AlreadyRegistered); | 32 | constexpr ResultCode ERR_INVALID_STATE{ErrorModule::Kernel, 125}; |
| 58 | constexpr ResultCode ERR_INVALID_STATE(ErrorModule::Kernel, ErrCodes::InvalidState); | 33 | constexpr ResultCode ERR_RESOURCE_LIMIT_EXCEEDED{ErrorModule::Kernel, 132}; |
| 59 | constexpr ResultCode ERR_INVALID_THREAD_PRIORITY(ErrorModule::Kernel, | ||
| 60 | ErrCodes::InvalidThreadPriority); | ||
| 61 | constexpr ResultCode ERR_INVALID_POINTER(ErrorModule::Kernel, ErrCodes::InvalidPointer); | ||
| 62 | constexpr ResultCode ERR_NOT_FOUND(ErrorModule::Kernel, ErrCodes::NoSuchEntry); | ||
| 63 | constexpr ResultCode RESULT_TIMEOUT(ErrorModule::Kernel, ErrCodes::Timeout); | ||
| 64 | 34 | ||
| 65 | } // namespace Kernel | 35 | } // namespace Kernel |
diff --git a/src/core/hle/kernel/process.cpp b/src/core/hle/kernel/process.cpp index 420218d59..f06b6bb55 100644 --- a/src/core/hle/kernel/process.cpp +++ b/src/core/hle/kernel/process.cpp | |||
| @@ -5,11 +5,9 @@ | |||
| 5 | #include <algorithm> | 5 | #include <algorithm> |
| 6 | #include <memory> | 6 | #include <memory> |
| 7 | #include "common/assert.h" | 7 | #include "common/assert.h" |
| 8 | #include "common/common_funcs.h" | ||
| 9 | #include "common/logging/log.h" | 8 | #include "common/logging/log.h" |
| 10 | #include "core/core.h" | 9 | #include "core/core.h" |
| 11 | #include "core/file_sys/program_metadata.h" | 10 | #include "core/file_sys/program_metadata.h" |
| 12 | #include "core/hle/kernel/errors.h" | ||
| 13 | #include "core/hle/kernel/kernel.h" | 11 | #include "core/hle/kernel/kernel.h" |
| 14 | #include "core/hle/kernel/process.h" | 12 | #include "core/hle/kernel/process.h" |
| 15 | #include "core/hle/kernel/resource_limit.h" | 13 | #include "core/hle/kernel/resource_limit.h" |
| @@ -17,6 +15,7 @@ | |||
| 17 | #include "core/hle/kernel/thread.h" | 15 | #include "core/hle/kernel/thread.h" |
| 18 | #include "core/hle/kernel/vm_manager.h" | 16 | #include "core/hle/kernel/vm_manager.h" |
| 19 | #include "core/memory.h" | 17 | #include "core/memory.h" |
| 18 | #include "core/settings.h" | ||
| 20 | 19 | ||
| 21 | namespace Kernel { | 20 | namespace Kernel { |
| 22 | 21 | ||
| @@ -35,6 +34,11 @@ SharedPtr<Process> Process::Create(KernelCore& kernel, std::string&& name) { | |||
| 35 | process->process_id = kernel.CreateNewProcessID(); | 34 | process->process_id = kernel.CreateNewProcessID(); |
| 36 | process->svc_access_mask.set(); | 35 | process->svc_access_mask.set(); |
| 37 | 36 | ||
| 37 | std::mt19937 rng(Settings::values.rng_seed.value_or(0)); | ||
| 38 | std::uniform_int_distribution<u64> distribution; | ||
| 39 | std::generate(process->random_entropy.begin(), process->random_entropy.end(), | ||
| 40 | [&] { return distribution(rng); }); | ||
| 41 | |||
| 38 | kernel.AppendNewProcess(process); | 42 | kernel.AppendNewProcess(process); |
| 39 | return process; | 43 | return process; |
| 40 | } | 44 | } |
| @@ -241,83 +245,15 @@ void Process::LoadModule(CodeSet module_, VAddr base_addr) { | |||
| 241 | } | 245 | } |
| 242 | 246 | ||
| 243 | ResultVal<VAddr> Process::HeapAllocate(VAddr target, u64 size, VMAPermission perms) { | 247 | ResultVal<VAddr> Process::HeapAllocate(VAddr target, u64 size, VMAPermission perms) { |
| 244 | if (target < vm_manager.GetHeapRegionBaseAddress() || | 248 | return vm_manager.HeapAllocate(target, size, perms); |
| 245 | target + size > vm_manager.GetHeapRegionEndAddress() || target + size < target) { | ||
| 246 | return ERR_INVALID_ADDRESS; | ||
| 247 | } | ||
| 248 | |||
| 249 | if (heap_memory == nullptr) { | ||
| 250 | // Initialize heap | ||
| 251 | heap_memory = std::make_shared<std::vector<u8>>(); | ||
| 252 | heap_start = heap_end = target; | ||
| 253 | } else { | ||
| 254 | vm_manager.UnmapRange(heap_start, heap_end - heap_start); | ||
| 255 | } | ||
| 256 | |||
| 257 | // If necessary, expand backing vector to cover new heap extents. | ||
| 258 | if (target < heap_start) { | ||
| 259 | heap_memory->insert(begin(*heap_memory), heap_start - target, 0); | ||
| 260 | heap_start = target; | ||
| 261 | vm_manager.RefreshMemoryBlockMappings(heap_memory.get()); | ||
| 262 | } | ||
| 263 | if (target + size > heap_end) { | ||
| 264 | heap_memory->insert(end(*heap_memory), (target + size) - heap_end, 0); | ||
| 265 | heap_end = target + size; | ||
| 266 | vm_manager.RefreshMemoryBlockMappings(heap_memory.get()); | ||
| 267 | } | ||
| 268 | ASSERT(heap_end - heap_start == heap_memory->size()); | ||
| 269 | |||
| 270 | CASCADE_RESULT(auto vma, vm_manager.MapMemoryBlock(target, heap_memory, target - heap_start, | ||
| 271 | size, MemoryState::Heap)); | ||
| 272 | vm_manager.Reprotect(vma, perms); | ||
| 273 | |||
| 274 | heap_used = size; | ||
| 275 | |||
| 276 | return MakeResult<VAddr>(heap_end - size); | ||
| 277 | } | 249 | } |
| 278 | 250 | ||
| 279 | ResultCode Process::HeapFree(VAddr target, u32 size) { | 251 | ResultCode Process::HeapFree(VAddr target, u32 size) { |
| 280 | if (target < vm_manager.GetHeapRegionBaseAddress() || | 252 | return vm_manager.HeapFree(target, size); |
| 281 | target + size > vm_manager.GetHeapRegionEndAddress() || target + size < target) { | ||
| 282 | return ERR_INVALID_ADDRESS; | ||
| 283 | } | ||
| 284 | |||
| 285 | if (size == 0) { | ||
| 286 | return RESULT_SUCCESS; | ||
| 287 | } | ||
| 288 | |||
| 289 | ResultCode result = vm_manager.UnmapRange(target, size); | ||
| 290 | if (result.IsError()) | ||
| 291 | return result; | ||
| 292 | |||
| 293 | heap_used -= size; | ||
| 294 | |||
| 295 | return RESULT_SUCCESS; | ||
| 296 | } | 253 | } |
| 297 | 254 | ||
| 298 | ResultCode Process::MirrorMemory(VAddr dst_addr, VAddr src_addr, u64 size) { | 255 | ResultCode Process::MirrorMemory(VAddr dst_addr, VAddr src_addr, u64 size) { |
| 299 | auto vma = vm_manager.FindVMA(src_addr); | 256 | return vm_manager.MirrorMemory(dst_addr, src_addr, size); |
| 300 | |||
| 301 | ASSERT_MSG(vma != vm_manager.vma_map.end(), "Invalid memory address"); | ||
| 302 | ASSERT_MSG(vma->second.backing_block, "Backing block doesn't exist for address"); | ||
| 303 | |||
| 304 | // The returned VMA might be a bigger one encompassing the desired address. | ||
| 305 | auto vma_offset = src_addr - vma->first; | ||
| 306 | ASSERT_MSG(vma_offset + size <= vma->second.size, | ||
| 307 | "Shared memory exceeds bounds of mapped block"); | ||
| 308 | |||
| 309 | const std::shared_ptr<std::vector<u8>>& backing_block = vma->second.backing_block; | ||
| 310 | std::size_t backing_block_offset = vma->second.offset + vma_offset; | ||
| 311 | |||
| 312 | CASCADE_RESULT(auto new_vma, | ||
| 313 | vm_manager.MapMemoryBlock(dst_addr, backing_block, backing_block_offset, size, | ||
| 314 | MemoryState::Mapped)); | ||
| 315 | // Protect mirror with permissions from old region | ||
| 316 | vm_manager.Reprotect(new_vma, vma->second.permissions); | ||
| 317 | // Remove permissions from old region | ||
| 318 | vm_manager.Reprotect(vma, VMAPermission::None); | ||
| 319 | |||
| 320 | return RESULT_SUCCESS; | ||
| 321 | } | 257 | } |
| 322 | 258 | ||
| 323 | ResultCode Process::UnmapMemory(VAddr dst_addr, VAddr /*src_addr*/, u64 size) { | 259 | ResultCode Process::UnmapMemory(VAddr dst_addr, VAddr /*src_addr*/, u64 size) { |
diff --git a/src/core/hle/kernel/process.h b/src/core/hle/kernel/process.h index 8d2616c79..cf48787ce 100644 --- a/src/core/hle/kernel/process.h +++ b/src/core/hle/kernel/process.h | |||
| @@ -8,6 +8,7 @@ | |||
| 8 | #include <bitset> | 8 | #include <bitset> |
| 9 | #include <cstddef> | 9 | #include <cstddef> |
| 10 | #include <memory> | 10 | #include <memory> |
| 11 | #include <random> | ||
| 11 | #include <string> | 12 | #include <string> |
| 12 | #include <vector> | 13 | #include <vector> |
| 13 | #include <boost/container/static_vector.hpp> | 14 | #include <boost/container/static_vector.hpp> |
| @@ -119,6 +120,8 @@ struct CodeSet final { | |||
| 119 | 120 | ||
| 120 | class Process final : public Object { | 121 | class Process final : public Object { |
| 121 | public: | 122 | public: |
| 123 | static constexpr std::size_t RANDOM_ENTROPY_SIZE = 4; | ||
| 124 | |||
| 122 | static SharedPtr<Process> Create(KernelCore& kernel, std::string&& name); | 125 | static SharedPtr<Process> Create(KernelCore& kernel, std::string&& name); |
| 123 | 126 | ||
| 124 | std::string GetTypeName() const override { | 127 | std::string GetTypeName() const override { |
| @@ -212,6 +215,11 @@ public: | |||
| 212 | total_process_running_time_ticks += ticks; | 215 | total_process_running_time_ticks += ticks; |
| 213 | } | 216 | } |
| 214 | 217 | ||
| 218 | /// Gets 8 bytes of random data for svcGetInfo RandomEntropy | ||
| 219 | u64 GetRandomEntropy(std::size_t index) const { | ||
| 220 | return random_entropy.at(index); | ||
| 221 | } | ||
| 222 | |||
| 215 | /** | 223 | /** |
| 216 | * Loads process-specifics configuration info with metadata provided | 224 | * Loads process-specifics configuration info with metadata provided |
| 217 | * by an executable. | 225 | * by an executable. |
| @@ -292,17 +300,6 @@ private: | |||
| 292 | u32 allowed_thread_priority_mask = 0xFFFFFFFF; | 300 | u32 allowed_thread_priority_mask = 0xFFFFFFFF; |
| 293 | u32 is_virtual_address_memory_enabled = 0; | 301 | u32 is_virtual_address_memory_enabled = 0; |
| 294 | 302 | ||
| 295 | // Memory used to back the allocations in the regular heap. A single vector is used to cover | ||
| 296 | // the entire virtual address space extents that bound the allocations, including any holes. | ||
| 297 | // This makes deallocation and reallocation of holes fast and keeps process memory contiguous | ||
| 298 | // in the emulator address space, allowing Memory::GetPointer to be reasonably safe. | ||
| 299 | std::shared_ptr<std::vector<u8>> heap_memory; | ||
| 300 | |||
| 301 | // The left/right bounds of the address space covered by heap_memory. | ||
| 302 | VAddr heap_start = 0; | ||
| 303 | VAddr heap_end = 0; | ||
| 304 | u64 heap_used = 0; | ||
| 305 | |||
| 306 | /// The Thread Local Storage area is allocated as processes create threads, | 303 | /// The Thread Local Storage area is allocated as processes create threads, |
| 307 | /// each TLS area is 0x200 bytes, so one page (0x1000) is split up in 8 parts, and each part | 304 | /// each TLS area is 0x200 bytes, so one page (0x1000) is split up in 8 parts, and each part |
| 308 | /// holds the TLS for a specific thread. This vector contains which parts are in use for each | 305 | /// holds the TLS for a specific thread. This vector contains which parts are in use for each |
| @@ -321,6 +318,9 @@ private: | |||
| 321 | /// Per-process handle table for storing created object handles in. | 318 | /// Per-process handle table for storing created object handles in. |
| 322 | HandleTable handle_table; | 319 | HandleTable handle_table; |
| 323 | 320 | ||
| 321 | /// Random values for svcGetInfo RandomEntropy | ||
| 322 | std::array<u64, RANDOM_ENTROPY_SIZE> random_entropy; | ||
| 323 | |||
| 324 | std::string name; | 324 | std::string name; |
| 325 | }; | 325 | }; |
| 326 | 326 | ||
diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp index 7e8e87c33..2e7c9d094 100644 --- a/src/core/hle/kernel/svc.cpp +++ b/src/core/hle/kernel/svc.cpp | |||
| @@ -34,6 +34,7 @@ | |||
| 34 | #include "core/hle/lock.h" | 34 | #include "core/hle/lock.h" |
| 35 | #include "core/hle/result.h" | 35 | #include "core/hle/result.h" |
| 36 | #include "core/hle/service/service.h" | 36 | #include "core/hle/service/service.h" |
| 37 | #include "core/settings.h" | ||
| 37 | 38 | ||
| 38 | namespace Kernel { | 39 | namespace Kernel { |
| 39 | namespace { | 40 | namespace { |
| @@ -122,6 +123,48 @@ static ResultCode SetHeapSize(VAddr* heap_addr, u64 heap_size) { | |||
| 122 | return RESULT_SUCCESS; | 123 | return RESULT_SUCCESS; |
| 123 | } | 124 | } |
| 124 | 125 | ||
| 126 | static ResultCode SetMemoryPermission(VAddr addr, u64 size, u32 prot) { | ||
| 127 | LOG_TRACE(Kernel_SVC, "called, addr=0x{:X}, size=0x{:X}, prot=0x{:X}", addr, size, prot); | ||
| 128 | |||
| 129 | if (!Common::Is4KBAligned(addr)) { | ||
| 130 | return ERR_INVALID_ADDRESS; | ||
| 131 | } | ||
| 132 | |||
| 133 | if (size == 0 || !Common::Is4KBAligned(size)) { | ||
| 134 | return ERR_INVALID_SIZE; | ||
| 135 | } | ||
| 136 | |||
| 137 | if (!IsValidAddressRange(addr, size)) { | ||
| 138 | return ERR_INVALID_ADDRESS_STATE; | ||
| 139 | } | ||
| 140 | |||
| 141 | const auto permission = static_cast<MemoryPermission>(prot); | ||
| 142 | if (permission != MemoryPermission::None && permission != MemoryPermission::Read && | ||
| 143 | permission != MemoryPermission::ReadWrite) { | ||
| 144 | return ERR_INVALID_MEMORY_PERMISSIONS; | ||
| 145 | } | ||
| 146 | |||
| 147 | auto* const current_process = Core::CurrentProcess(); | ||
| 148 | auto& vm_manager = current_process->VMManager(); | ||
| 149 | |||
| 150 | if (!IsInsideAddressSpace(vm_manager, addr, size)) { | ||
| 151 | return ERR_INVALID_ADDRESS_STATE; | ||
| 152 | } | ||
| 153 | |||
| 154 | const VMManager::VMAHandle iter = vm_manager.FindVMA(addr); | ||
| 155 | if (iter == vm_manager.vma_map.end()) { | ||
| 156 | return ERR_INVALID_ADDRESS_STATE; | ||
| 157 | } | ||
| 158 | |||
| 159 | LOG_WARNING(Kernel_SVC, "Uniformity check on protected memory is not implemented."); | ||
| 160 | // TODO: Performs a uniformity check to make sure only protected memory is changed (it doesn't | ||
| 161 | // make sense to allow changing permissions on kernel memory itself, etc). | ||
| 162 | |||
| 163 | const auto converted_permissions = SharedMemory::ConvertPermissions(permission); | ||
| 164 | |||
| 165 | return vm_manager.ReprotectRange(addr, size, converted_permissions); | ||
| 166 | } | ||
| 167 | |||
| 125 | static ResultCode SetMemoryAttribute(VAddr addr, u64 size, u32 state0, u32 state1) { | 168 | static ResultCode SetMemoryAttribute(VAddr addr, u64 size, u32 state0, u32 state1) { |
| 126 | LOG_WARNING(Kernel_SVC, | 169 | LOG_WARNING(Kernel_SVC, |
| 127 | "(STUBBED) called, addr=0x{:X}, size=0x{:X}, state0=0x{:X}, state1=0x{:X}", addr, | 170 | "(STUBBED) called, addr=0x{:X}, size=0x{:X}, state0=0x{:X}, state1=0x{:X}", addr, |
| @@ -171,7 +214,7 @@ static ResultCode ConnectToNamedPort(Handle* out_handle, VAddr port_name_address | |||
| 171 | // Read 1 char beyond the max allowed port name to detect names that are too long. | 214 | // Read 1 char beyond the max allowed port name to detect names that are too long. |
| 172 | std::string port_name = Memory::ReadCString(port_name_address, PortNameMaxLength + 1); | 215 | std::string port_name = Memory::ReadCString(port_name_address, PortNameMaxLength + 1); |
| 173 | if (port_name.size() > PortNameMaxLength) { | 216 | if (port_name.size() > PortNameMaxLength) { |
| 174 | return ERR_PORT_NAME_TOO_LONG; | 217 | return ERR_OUT_OF_RANGE; |
| 175 | } | 218 | } |
| 176 | 219 | ||
| 177 | LOG_TRACE(Kernel_SVC, "called port_name={}", port_name); | 220 | LOG_TRACE(Kernel_SVC, "called port_name={}", port_name); |
| @@ -267,8 +310,9 @@ static ResultCode WaitSynchronization(Handle* index, VAddr handles_address, u64 | |||
| 267 | 310 | ||
| 268 | static constexpr u64 MaxHandles = 0x40; | 311 | static constexpr u64 MaxHandles = 0x40; |
| 269 | 312 | ||
| 270 | if (handle_count > MaxHandles) | 313 | if (handle_count > MaxHandles) { |
| 271 | return ResultCode(ErrorModule::Kernel, ErrCodes::TooLarge); | 314 | return ERR_OUT_OF_RANGE; |
| 315 | } | ||
| 272 | 316 | ||
| 273 | auto* const thread = GetCurrentThread(); | 317 | auto* const thread = GetCurrentThread(); |
| 274 | 318 | ||
| @@ -333,8 +377,7 @@ static ResultCode CancelSynchronization(Handle thread_handle) { | |||
| 333 | } | 377 | } |
| 334 | 378 | ||
| 335 | ASSERT(thread->GetStatus() == ThreadStatus::WaitSynchAny); | 379 | ASSERT(thread->GetStatus() == ThreadStatus::WaitSynchAny); |
| 336 | thread->SetWaitSynchronizationResult( | 380 | thread->SetWaitSynchronizationResult(ERR_SYNCHRONIZATION_CANCELED); |
| 337 | ResultCode(ErrorModule::Kernel, ErrCodes::SynchronizationCanceled)); | ||
| 338 | thread->ResumeFromWait(); | 381 | thread->ResumeFromWait(); |
| 339 | return RESULT_SUCCESS; | 382 | return RESULT_SUCCESS; |
| 340 | } | 383 | } |
| @@ -558,7 +601,16 @@ static ResultCode GetInfo(u64* result, u64 info_id, u64 handle, u64 info_sub_id) | |||
| 558 | *result = 0; | 601 | *result = 0; |
| 559 | break; | 602 | break; |
| 560 | case GetInfoType::RandomEntropy: | 603 | case GetInfoType::RandomEntropy: |
| 561 | *result = 0; | 604 | if (handle != 0) { |
| 605 | return ERR_INVALID_HANDLE; | ||
| 606 | } | ||
| 607 | |||
| 608 | if (info_sub_id >= Process::RANDOM_ENTROPY_SIZE) { | ||
| 609 | return ERR_INVALID_COMBINATION; | ||
| 610 | } | ||
| 611 | |||
| 612 | *result = current_process->GetRandomEntropy(info_sub_id); | ||
| 613 | return RESULT_SUCCESS; | ||
| 562 | break; | 614 | break; |
| 563 | case GetInfoType::ASLRRegionBaseAddr: | 615 | case GetInfoType::ASLRRegionBaseAddr: |
| 564 | *result = vm_manager.GetASLRRegionBaseAddress(); | 616 | *result = vm_manager.GetASLRRegionBaseAddress(); |
| @@ -591,7 +643,7 @@ static ResultCode GetInfo(u64* result, u64 info_id, u64 handle, u64 info_sub_id) | |||
| 591 | case GetInfoType::ThreadTickCount: { | 643 | case GetInfoType::ThreadTickCount: { |
| 592 | constexpr u64 num_cpus = 4; | 644 | constexpr u64 num_cpus = 4; |
| 593 | if (info_sub_id != 0xFFFFFFFFFFFFFFFF && info_sub_id >= num_cpus) { | 645 | if (info_sub_id != 0xFFFFFFFFFFFFFFFF && info_sub_id >= num_cpus) { |
| 594 | return ERR_INVALID_COMBINATION_KERNEL; | 646 | return ERR_INVALID_COMBINATION; |
| 595 | } | 647 | } |
| 596 | 648 | ||
| 597 | const auto thread = | 649 | const auto thread = |
| @@ -1184,7 +1236,7 @@ static ResultCode SetThreadCoreMask(Handle thread_handle, u32 core, u64 mask) { | |||
| 1184 | } | 1236 | } |
| 1185 | 1237 | ||
| 1186 | if (mask == 0) { | 1238 | if (mask == 0) { |
| 1187 | return ResultCode(ErrorModule::Kernel, ErrCodes::InvalidCombination); | 1239 | return ERR_INVALID_COMBINATION; |
| 1188 | } | 1240 | } |
| 1189 | 1241 | ||
| 1190 | /// This value is used to only change the affinity mask without changing the current ideal core. | 1242 | /// This value is used to only change the affinity mask without changing the current ideal core. |
| @@ -1193,12 +1245,12 @@ static ResultCode SetThreadCoreMask(Handle thread_handle, u32 core, u64 mask) { | |||
| 1193 | if (core == OnlyChangeMask) { | 1245 | if (core == OnlyChangeMask) { |
| 1194 | core = thread->GetIdealCore(); | 1246 | core = thread->GetIdealCore(); |
| 1195 | } else if (core >= Core::NUM_CPU_CORES && core != static_cast<u32>(-1)) { | 1247 | } else if (core >= Core::NUM_CPU_CORES && core != static_cast<u32>(-1)) { |
| 1196 | return ResultCode(ErrorModule::Kernel, ErrCodes::InvalidProcessorId); | 1248 | return ERR_INVALID_PROCESSOR_ID; |
| 1197 | } | 1249 | } |
| 1198 | 1250 | ||
| 1199 | // Error out if the input core isn't enabled in the input mask. | 1251 | // Error out if the input core isn't enabled in the input mask. |
| 1200 | if (core < Core::NUM_CPU_CORES && (mask & (1ull << core)) == 0) { | 1252 | if (core < Core::NUM_CPU_CORES && (mask & (1ull << core)) == 0) { |
| 1201 | return ResultCode(ErrorModule::Kernel, ErrCodes::InvalidCombination); | 1253 | return ERR_INVALID_COMBINATION; |
| 1202 | } | 1254 | } |
| 1203 | 1255 | ||
| 1204 | thread->ChangeCore(core, mask); | 1256 | thread->ChangeCore(core, mask); |
| @@ -1287,7 +1339,7 @@ struct FunctionDef { | |||
| 1287 | static const FunctionDef SVC_Table[] = { | 1339 | static const FunctionDef SVC_Table[] = { |
| 1288 | {0x00, nullptr, "Unknown"}, | 1340 | {0x00, nullptr, "Unknown"}, |
| 1289 | {0x01, SvcWrap<SetHeapSize>, "SetHeapSize"}, | 1341 | {0x01, SvcWrap<SetHeapSize>, "SetHeapSize"}, |
| 1290 | {0x02, nullptr, "SetMemoryPermission"}, | 1342 | {0x02, SvcWrap<SetMemoryPermission>, "SetMemoryPermission"}, |
| 1291 | {0x03, SvcWrap<SetMemoryAttribute>, "SetMemoryAttribute"}, | 1343 | {0x03, SvcWrap<SetMemoryAttribute>, "SetMemoryAttribute"}, |
| 1292 | {0x04, SvcWrap<MapMemory>, "MapMemory"}, | 1344 | {0x04, SvcWrap<MapMemory>, "MapMemory"}, |
| 1293 | {0x05, SvcWrap<UnmapMemory>, "UnmapMemory"}, | 1345 | {0x05, SvcWrap<UnmapMemory>, "UnmapMemory"}, |
diff --git a/src/core/hle/kernel/svc_wrap.h b/src/core/hle/kernel/svc_wrap.h index b09753c80..233a99fb0 100644 --- a/src/core/hle/kernel/svc_wrap.h +++ b/src/core/hle/kernel/svc_wrap.h | |||
| @@ -121,6 +121,11 @@ void SvcWrap() { | |||
| 121 | FuncReturn(func(Param(0), Param(1), Param(2)).raw); | 121 | FuncReturn(func(Param(0), Param(1), Param(2)).raw); |
| 122 | } | 122 | } |
| 123 | 123 | ||
| 124 | template <ResultCode func(u64, u64, u32)> | ||
| 125 | void SvcWrap() { | ||
| 126 | FuncReturn(func(Param(0), Param(1), static_cast<u32>(Param(2))).raw); | ||
| 127 | } | ||
| 128 | |||
| 124 | template <ResultCode func(u32, u64, u64, u32)> | 129 | template <ResultCode func(u32, u64, u64, u32)> |
| 125 | void SvcWrap() { | 130 | void SvcWrap() { |
| 126 | FuncReturn( | 131 | FuncReturn( |
diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp index dd5cd9ced..4ffb76818 100644 --- a/src/core/hle/kernel/thread.cpp +++ b/src/core/hle/kernel/thread.cpp | |||
| @@ -142,36 +142,7 @@ void Thread::ResumeFromWait() { | |||
| 142 | 142 | ||
| 143 | status = ThreadStatus::Ready; | 143 | status = ThreadStatus::Ready; |
| 144 | 144 | ||
| 145 | std::optional<s32> new_processor_id = GetNextProcessorId(affinity_mask); | 145 | ChangeScheduler(); |
| 146 | if (!new_processor_id) { | ||
| 147 | new_processor_id = processor_id; | ||
| 148 | } | ||
| 149 | if (ideal_core != -1 && | ||
| 150 | Core::System::GetInstance().Scheduler(ideal_core).GetCurrentThread() == nullptr) { | ||
| 151 | new_processor_id = ideal_core; | ||
| 152 | } | ||
| 153 | |||
| 154 | ASSERT(*new_processor_id < 4); | ||
| 155 | |||
| 156 | // Add thread to new core's scheduler | ||
| 157 | auto* next_scheduler = &Core::System::GetInstance().Scheduler(*new_processor_id); | ||
| 158 | |||
| 159 | if (*new_processor_id != processor_id) { | ||
| 160 | // Remove thread from previous core's scheduler | ||
| 161 | scheduler->RemoveThread(this); | ||
| 162 | next_scheduler->AddThread(this, current_priority); | ||
| 163 | } | ||
| 164 | |||
| 165 | processor_id = *new_processor_id; | ||
| 166 | |||
| 167 | // If the thread was ready, unschedule from the previous core and schedule on the new core | ||
| 168 | scheduler->UnscheduleThread(this, current_priority); | ||
| 169 | next_scheduler->ScheduleThread(this, current_priority); | ||
| 170 | |||
| 171 | // Change thread's scheduler | ||
| 172 | scheduler = next_scheduler; | ||
| 173 | |||
| 174 | Core::System::GetInstance().CpuCore(processor_id).PrepareReschedule(); | ||
| 175 | } | 146 | } |
| 176 | 147 | ||
| 177 | /** | 148 | /** |
| @@ -364,42 +335,45 @@ void Thread::UpdatePriority() { | |||
| 364 | void Thread::ChangeCore(u32 core, u64 mask) { | 335 | void Thread::ChangeCore(u32 core, u64 mask) { |
| 365 | ideal_core = core; | 336 | ideal_core = core; |
| 366 | affinity_mask = mask; | 337 | affinity_mask = mask; |
| 338 | ChangeScheduler(); | ||
| 339 | } | ||
| 367 | 340 | ||
| 341 | void Thread::ChangeScheduler() { | ||
| 368 | if (status != ThreadStatus::Ready) { | 342 | if (status != ThreadStatus::Ready) { |
| 369 | return; | 343 | return; |
| 370 | } | 344 | } |
| 371 | 345 | ||
| 346 | auto& system = Core::System::GetInstance(); | ||
| 372 | std::optional<s32> new_processor_id{GetNextProcessorId(affinity_mask)}; | 347 | std::optional<s32> new_processor_id{GetNextProcessorId(affinity_mask)}; |
| 373 | 348 | ||
| 374 | if (!new_processor_id) { | 349 | if (!new_processor_id) { |
| 375 | new_processor_id = processor_id; | 350 | new_processor_id = processor_id; |
| 376 | } | 351 | } |
| 377 | if (ideal_core != -1 && | 352 | if (ideal_core != -1 && system.Scheduler(ideal_core).GetCurrentThread() == nullptr) { |
| 378 | Core::System::GetInstance().Scheduler(ideal_core).GetCurrentThread() == nullptr) { | ||
| 379 | new_processor_id = ideal_core; | 353 | new_processor_id = ideal_core; |
| 380 | } | 354 | } |
| 381 | 355 | ||
| 382 | ASSERT(*new_processor_id < 4); | 356 | ASSERT(*new_processor_id < 4); |
| 383 | 357 | ||
| 384 | // Add thread to new core's scheduler | 358 | // Add thread to new core's scheduler |
| 385 | auto* next_scheduler = &Core::System::GetInstance().Scheduler(*new_processor_id); | 359 | auto& next_scheduler = system.Scheduler(*new_processor_id); |
| 386 | 360 | ||
| 387 | if (*new_processor_id != processor_id) { | 361 | if (*new_processor_id != processor_id) { |
| 388 | // Remove thread from previous core's scheduler | 362 | // Remove thread from previous core's scheduler |
| 389 | scheduler->RemoveThread(this); | 363 | scheduler->RemoveThread(this); |
| 390 | next_scheduler->AddThread(this, current_priority); | 364 | next_scheduler.AddThread(this, current_priority); |
| 391 | } | 365 | } |
| 392 | 366 | ||
| 393 | processor_id = *new_processor_id; | 367 | processor_id = *new_processor_id; |
| 394 | 368 | ||
| 395 | // If the thread was ready, unschedule from the previous core and schedule on the new core | 369 | // If the thread was ready, unschedule from the previous core and schedule on the new core |
| 396 | scheduler->UnscheduleThread(this, current_priority); | 370 | scheduler->UnscheduleThread(this, current_priority); |
| 397 | next_scheduler->ScheduleThread(this, current_priority); | 371 | next_scheduler.ScheduleThread(this, current_priority); |
| 398 | 372 | ||
| 399 | // Change thread's scheduler | 373 | // Change thread's scheduler |
| 400 | scheduler = next_scheduler; | 374 | scheduler = &next_scheduler; |
| 401 | 375 | ||
| 402 | Core::System::GetInstance().CpuCore(processor_id).PrepareReschedule(); | 376 | system.CpuCore(processor_id).PrepareReschedule(); |
| 403 | } | 377 | } |
| 404 | 378 | ||
| 405 | bool Thread::AllWaitObjectsReady() { | 379 | bool Thread::AllWaitObjectsReady() { |
diff --git a/src/core/hle/kernel/thread.h b/src/core/hle/kernel/thread.h index 4a6e11239..d384d50db 100644 --- a/src/core/hle/kernel/thread.h +++ b/src/core/hle/kernel/thread.h | |||
| @@ -374,6 +374,8 @@ private: | |||
| 374 | explicit Thread(KernelCore& kernel); | 374 | explicit Thread(KernelCore& kernel); |
| 375 | ~Thread() override; | 375 | ~Thread() override; |
| 376 | 376 | ||
| 377 | void ChangeScheduler(); | ||
| 378 | |||
| 377 | Core::ARM_Interface::ThreadContext context{}; | 379 | Core::ARM_Interface::ThreadContext context{}; |
| 378 | 380 | ||
| 379 | u32 thread_id = 0; | 381 | u32 thread_id = 0; |
diff --git a/src/core/hle/kernel/vm_manager.cpp b/src/core/hle/kernel/vm_manager.cpp index 1a92c8f70..ec7fd6150 100644 --- a/src/core/hle/kernel/vm_manager.cpp +++ b/src/core/hle/kernel/vm_manager.cpp | |||
| @@ -243,6 +243,85 @@ ResultCode VMManager::ReprotectRange(VAddr target, u64 size, VMAPermission new_p | |||
| 243 | return RESULT_SUCCESS; | 243 | return RESULT_SUCCESS; |
| 244 | } | 244 | } |
| 245 | 245 | ||
| 246 | ResultVal<VAddr> VMManager::HeapAllocate(VAddr target, u64 size, VMAPermission perms) { | ||
| 247 | if (target < GetHeapRegionBaseAddress() || target + size > GetHeapRegionEndAddress() || | ||
| 248 | target + size < target) { | ||
| 249 | return ERR_INVALID_ADDRESS; | ||
| 250 | } | ||
| 251 | |||
| 252 | if (heap_memory == nullptr) { | ||
| 253 | // Initialize heap | ||
| 254 | heap_memory = std::make_shared<std::vector<u8>>(); | ||
| 255 | heap_start = heap_end = target; | ||
| 256 | } else { | ||
| 257 | UnmapRange(heap_start, heap_end - heap_start); | ||
| 258 | } | ||
| 259 | |||
| 260 | // If necessary, expand backing vector to cover new heap extents. | ||
| 261 | if (target < heap_start) { | ||
| 262 | heap_memory->insert(begin(*heap_memory), heap_start - target, 0); | ||
| 263 | heap_start = target; | ||
| 264 | RefreshMemoryBlockMappings(heap_memory.get()); | ||
| 265 | } | ||
| 266 | if (target + size > heap_end) { | ||
| 267 | heap_memory->insert(end(*heap_memory), (target + size) - heap_end, 0); | ||
| 268 | heap_end = target + size; | ||
| 269 | RefreshMemoryBlockMappings(heap_memory.get()); | ||
| 270 | } | ||
| 271 | ASSERT(heap_end - heap_start == heap_memory->size()); | ||
| 272 | |||
| 273 | CASCADE_RESULT(auto vma, MapMemoryBlock(target, heap_memory, target - heap_start, size, | ||
| 274 | MemoryState::Heap)); | ||
| 275 | Reprotect(vma, perms); | ||
| 276 | |||
| 277 | heap_used = size; | ||
| 278 | |||
| 279 | return MakeResult<VAddr>(heap_end - size); | ||
| 280 | } | ||
| 281 | |||
| 282 | ResultCode VMManager::HeapFree(VAddr target, u64 size) { | ||
| 283 | if (target < GetHeapRegionBaseAddress() || target + size > GetHeapRegionEndAddress() || | ||
| 284 | target + size < target) { | ||
| 285 | return ERR_INVALID_ADDRESS; | ||
| 286 | } | ||
| 287 | |||
| 288 | if (size == 0) { | ||
| 289 | return RESULT_SUCCESS; | ||
| 290 | } | ||
| 291 | |||
| 292 | const ResultCode result = UnmapRange(target, size); | ||
| 293 | if (result.IsError()) { | ||
| 294 | return result; | ||
| 295 | } | ||
| 296 | |||
| 297 | heap_used -= size; | ||
| 298 | return RESULT_SUCCESS; | ||
| 299 | } | ||
| 300 | |||
| 301 | ResultCode VMManager::MirrorMemory(VAddr dst_addr, VAddr src_addr, u64 size) { | ||
| 302 | const auto vma = FindVMA(src_addr); | ||
| 303 | |||
| 304 | ASSERT_MSG(vma != vma_map.end(), "Invalid memory address"); | ||
| 305 | ASSERT_MSG(vma->second.backing_block, "Backing block doesn't exist for address"); | ||
| 306 | |||
| 307 | // The returned VMA might be a bigger one encompassing the desired address. | ||
| 308 | const auto vma_offset = src_addr - vma->first; | ||
| 309 | ASSERT_MSG(vma_offset + size <= vma->second.size, | ||
| 310 | "Shared memory exceeds bounds of mapped block"); | ||
| 311 | |||
| 312 | const std::shared_ptr<std::vector<u8>>& backing_block = vma->second.backing_block; | ||
| 313 | const std::size_t backing_block_offset = vma->second.offset + vma_offset; | ||
| 314 | |||
| 315 | CASCADE_RESULT(auto new_vma, MapMemoryBlock(dst_addr, backing_block, backing_block_offset, size, | ||
| 316 | MemoryState::Mapped)); | ||
| 317 | // Protect mirror with permissions from old region | ||
| 318 | Reprotect(new_vma, vma->second.permissions); | ||
| 319 | // Remove permissions from old region | ||
| 320 | Reprotect(vma, VMAPermission::None); | ||
| 321 | |||
| 322 | return RESULT_SUCCESS; | ||
| 323 | } | ||
| 324 | |||
| 246 | void VMManager::RefreshMemoryBlockMappings(const std::vector<u8>* block) { | 325 | void VMManager::RefreshMemoryBlockMappings(const std::vector<u8>* block) { |
| 247 | // If this ever proves to have a noticeable performance impact, allow users of the function to | 326 | // If this ever proves to have a noticeable performance impact, allow users of the function to |
| 248 | // specify a specific range of addresses to limit the scan to. | 327 | // specify a specific range of addresses to limit the scan to. |
| @@ -495,8 +574,7 @@ u64 VMManager::GetTotalMemoryUsage() const { | |||
| 495 | } | 574 | } |
| 496 | 575 | ||
| 497 | u64 VMManager::GetTotalHeapUsage() const { | 576 | u64 VMManager::GetTotalHeapUsage() const { |
| 498 | LOG_WARNING(Kernel, "(STUBBED) called"); | 577 | return heap_used; |
| 499 | return 0x0; | ||
| 500 | } | 578 | } |
| 501 | 579 | ||
| 502 | VAddr VMManager::GetAddressSpaceBaseAddress() const { | 580 | VAddr VMManager::GetAddressSpaceBaseAddress() const { |
diff --git a/src/core/hle/kernel/vm_manager.h b/src/core/hle/kernel/vm_manager.h index 2447cbb8f..248cc46dc 100644 --- a/src/core/hle/kernel/vm_manager.h +++ b/src/core/hle/kernel/vm_manager.h | |||
| @@ -186,6 +186,11 @@ public: | |||
| 186 | /// Changes the permissions of a range of addresses, splitting VMAs as necessary. | 186 | /// Changes the permissions of a range of addresses, splitting VMAs as necessary. |
| 187 | ResultCode ReprotectRange(VAddr target, u64 size, VMAPermission new_perms); | 187 | ResultCode ReprotectRange(VAddr target, u64 size, VMAPermission new_perms); |
| 188 | 188 | ||
| 189 | ResultVal<VAddr> HeapAllocate(VAddr target, u64 size, VMAPermission perms); | ||
| 190 | ResultCode HeapFree(VAddr target, u64 size); | ||
| 191 | |||
| 192 | ResultCode MirrorMemory(VAddr dst_addr, VAddr src_addr, u64 size); | ||
| 193 | |||
| 189 | /** | 194 | /** |
| 190 | * Scans all VMAs and updates the page table range of any that use the given vector as backing | 195 | * Scans all VMAs and updates the page table range of any that use the given vector as backing |
| 191 | * memory. This should be called after any operation that causes reallocation of the vector. | 196 | * memory. This should be called after any operation that causes reallocation of the vector. |
| @@ -343,5 +348,15 @@ private: | |||
| 343 | 348 | ||
| 344 | VAddr tls_io_region_base = 0; | 349 | VAddr tls_io_region_base = 0; |
| 345 | VAddr tls_io_region_end = 0; | 350 | VAddr tls_io_region_end = 0; |
| 351 | |||
| 352 | // Memory used to back the allocations in the regular heap. A single vector is used to cover | ||
| 353 | // the entire virtual address space extents that bound the allocations, including any holes. | ||
| 354 | // This makes deallocation and reallocation of holes fast and keeps process memory contiguous | ||
| 355 | // in the emulator address space, allowing Memory::GetPointer to be reasonably safe. | ||
| 356 | std::shared_ptr<std::vector<u8>> heap_memory; | ||
| 357 | // The left/right bounds of the address space covered by heap_memory. | ||
| 358 | VAddr heap_start = 0; | ||
| 359 | VAddr heap_end = 0; | ||
| 360 | u64 heap_used = 0; | ||
| 346 | }; | 361 | }; |
| 347 | } // namespace Kernel | 362 | } // namespace Kernel |
diff --git a/src/core/hle/result.h b/src/core/hle/result.h index c6b18cfba..bfb77cc31 100644 --- a/src/core/hle/result.h +++ b/src/core/hle/result.h | |||
| @@ -19,8 +19,6 @@ | |||
| 19 | enum class ErrorDescription : u32 { | 19 | enum class ErrorDescription : u32 { |
| 20 | Success = 0, | 20 | Success = 0, |
| 21 | RemoteProcessDead = 301, | 21 | RemoteProcessDead = 301, |
| 22 | InvalidOffset = 6061, | ||
| 23 | InvalidLength = 6062, | ||
| 24 | }; | 22 | }; |
| 25 | 23 | ||
| 26 | /** | 24 | /** |
diff --git a/src/core/hle/service/acc/acc.cpp b/src/core/hle/service/acc/acc.cpp index 8318eff5f..c629f9357 100644 --- a/src/core/hle/service/acc/acc.cpp +++ b/src/core/hle/service/acc/acc.cpp | |||
| @@ -252,8 +252,10 @@ void Module::Interface::TrySelectUserWithoutInteraction(Kernel::HLERequestContex | |||
| 252 | rb.PushRaw<u128>(INVALID_UUID); | 252 | rb.PushRaw<u128>(INVALID_UUID); |
| 253 | return; | 253 | return; |
| 254 | } | 254 | } |
| 255 | auto user_list = profile_manager->GetAllUsers(); | 255 | |
| 256 | if (user_list.empty()) { | 256 | const auto user_list = profile_manager->GetAllUsers(); |
| 257 | if (std::all_of(user_list.begin(), user_list.end(), | ||
| 258 | [](const auto& user) { return user.uuid == INVALID_UUID; })) { | ||
| 257 | rb.Push(ResultCode(-1)); // TODO(ogniK): Find the correct error code | 259 | rb.Push(ResultCode(-1)); // TODO(ogniK): Find the correct error code |
| 258 | rb.PushRaw<u128>(INVALID_UUID); | 260 | rb.PushRaw<u128>(INVALID_UUID); |
| 259 | return; | 261 | return; |
diff --git a/src/core/hle/service/acc/profile_manager.cpp b/src/core/hle/service/acc/profile_manager.cpp index c08394e4c..968263846 100644 --- a/src/core/hle/service/acc/profile_manager.cpp +++ b/src/core/hle/service/acc/profile_manager.cpp | |||
| @@ -2,8 +2,11 @@ | |||
| 2 | // Licensed under GPLv2 or any later version | 2 | // Licensed under GPLv2 or any later version |
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include <cstring> | ||
| 5 | #include <random> | 6 | #include <random> |
| 6 | 7 | ||
| 8 | #include <fmt/format.h> | ||
| 9 | |||
| 7 | #include "common/file_util.h" | 10 | #include "common/file_util.h" |
| 8 | #include "core/hle/service/acc/profile_manager.h" | 11 | #include "core/hle/service/acc/profile_manager.h" |
| 9 | #include "core/settings.h" | 12 | #include "core/settings.h" |
| @@ -39,6 +42,19 @@ UUID UUID::Generate() { | |||
| 39 | return UUID{distribution(gen), distribution(gen)}; | 42 | return UUID{distribution(gen), distribution(gen)}; |
| 40 | } | 43 | } |
| 41 | 44 | ||
| 45 | std::string UUID::Format() const { | ||
| 46 | return fmt::format("0x{:016X}{:016X}", uuid[1], uuid[0]); | ||
| 47 | } | ||
| 48 | |||
| 49 | std::string UUID::FormatSwitch() const { | ||
| 50 | std::array<u8, 16> s{}; | ||
| 51 | std::memcpy(s.data(), uuid.data(), sizeof(u128)); | ||
| 52 | return fmt::format("{:02x}{:02x}{:02x}{:02x}-{:02x}{:02x}-{:02x}{:02x}-{:02x}{:02x}-{:02x}{" | ||
| 53 | ":02x}{:02x}{:02x}{:02x}{:02x}", | ||
| 54 | s[0], s[1], s[2], s[3], s[4], s[5], s[6], s[7], s[8], s[9], s[10], s[11], | ||
| 55 | s[12], s[13], s[14], s[15]); | ||
| 56 | } | ||
| 57 | |||
| 42 | ProfileManager::ProfileManager() { | 58 | ProfileManager::ProfileManager() { |
| 43 | ParseUserSaveFile(); | 59 | ParseUserSaveFile(); |
| 44 | 60 | ||
| @@ -325,11 +341,12 @@ void ProfileManager::ParseUserSaveFile() { | |||
| 325 | return; | 341 | return; |
| 326 | } | 342 | } |
| 327 | 343 | ||
| 328 | for (std::size_t i = 0; i < MAX_USERS; ++i) { | 344 | for (const auto& user : data.users) { |
| 329 | const auto& user = data.users[i]; | 345 | if (user.uuid == UUID(INVALID_UUID)) { |
| 346 | continue; | ||
| 347 | } | ||
| 330 | 348 | ||
| 331 | if (user.uuid != UUID(INVALID_UUID)) | 349 | AddUser({user.uuid, user.username, user.timestamp, {}, false}); |
| 332 | AddUser({user.uuid, user.username, user.timestamp, {}, false}); | ||
| 333 | } | 350 | } |
| 334 | 351 | ||
| 335 | std::stable_partition(profiles.begin(), profiles.end(), | 352 | std::stable_partition(profiles.begin(), profiles.end(), |
diff --git a/src/core/hle/service/acc/profile_manager.h b/src/core/hle/service/acc/profile_manager.h index 747c46c20..d2d8e6c6b 100644 --- a/src/core/hle/service/acc/profile_manager.h +++ b/src/core/hle/service/acc/profile_manager.h | |||
| @@ -42,18 +42,9 @@ struct UUID { | |||
| 42 | void Invalidate() { | 42 | void Invalidate() { |
| 43 | uuid = INVALID_UUID; | 43 | uuid = INVALID_UUID; |
| 44 | } | 44 | } |
| 45 | std::string Format() const { | ||
| 46 | return fmt::format("0x{:016X}{:016X}", uuid[1], uuid[0]); | ||
| 47 | } | ||
| 48 | 45 | ||
| 49 | std::string FormatSwitch() const { | 46 | std::string Format() const; |
| 50 | std::array<u8, 16> s{}; | 47 | std::string FormatSwitch() const; |
| 51 | std::memcpy(s.data(), uuid.data(), sizeof(u128)); | ||
| 52 | return fmt::format("{:02x}{:02x}{:02x}{:02x}-{:02x}{:02x}-{:02x}{:02x}-{:02x}{:02x}-{:02x}{" | ||
| 53 | ":02x}{:02x}{:02x}{:02x}{:02x}", | ||
| 54 | s[0], s[1], s[2], s[3], s[4], s[5], s[6], s[7], s[8], s[9], s[10], s[11], | ||
| 55 | s[12], s[13], s[14], s[15]); | ||
| 56 | } | ||
| 57 | }; | 48 | }; |
| 58 | static_assert(sizeof(UUID) == 16, "UUID is an invalid size!"); | 49 | static_assert(sizeof(UUID) == 16, "UUID is an invalid size!"); |
| 59 | 50 | ||
diff --git a/src/core/hle/service/audio/audren_u.cpp b/src/core/hle/service/audio/audren_u.cpp index fac6785a5..d3ea57ea7 100644 --- a/src/core/hle/service/audio/audren_u.cpp +++ b/src/core/hle/service/audio/audren_u.cpp | |||
| @@ -28,13 +28,13 @@ public: | |||
| 28 | {1, &IAudioRenderer::GetSampleCount, "GetSampleCount"}, | 28 | {1, &IAudioRenderer::GetSampleCount, "GetSampleCount"}, |
| 29 | {2, &IAudioRenderer::GetMixBufferCount, "GetMixBufferCount"}, | 29 | {2, &IAudioRenderer::GetMixBufferCount, "GetMixBufferCount"}, |
| 30 | {3, &IAudioRenderer::GetState, "GetState"}, | 30 | {3, &IAudioRenderer::GetState, "GetState"}, |
| 31 | {4, &IAudioRenderer::RequestUpdate, "RequestUpdate"}, | 31 | {4, &IAudioRenderer::RequestUpdateImpl, "RequestUpdate"}, |
| 32 | {5, &IAudioRenderer::Start, "Start"}, | 32 | {5, &IAudioRenderer::Start, "Start"}, |
| 33 | {6, &IAudioRenderer::Stop, "Stop"}, | 33 | {6, &IAudioRenderer::Stop, "Stop"}, |
| 34 | {7, &IAudioRenderer::QuerySystemEvent, "QuerySystemEvent"}, | 34 | {7, &IAudioRenderer::QuerySystemEvent, "QuerySystemEvent"}, |
| 35 | {8, nullptr, "SetRenderingTimeLimit"}, | 35 | {8, &IAudioRenderer::SetRenderingTimeLimit, "SetRenderingTimeLimit"}, |
| 36 | {9, nullptr, "GetRenderingTimeLimit"}, | 36 | {9, &IAudioRenderer::GetRenderingTimeLimit, "GetRenderingTimeLimit"}, |
| 37 | {10, nullptr, "RequestUpdateAuto"}, | 37 | {10, &IAudioRenderer::RequestUpdateImpl, "RequestUpdateAuto"}, |
| 38 | {11, nullptr, "ExecuteAudioRendererRendering"}, | 38 | {11, nullptr, "ExecuteAudioRendererRendering"}, |
| 39 | }; | 39 | }; |
| 40 | // clang-format on | 40 | // clang-format on |
| @@ -79,7 +79,7 @@ private: | |||
| 79 | LOG_DEBUG(Service_Audio, "called"); | 79 | LOG_DEBUG(Service_Audio, "called"); |
| 80 | } | 80 | } |
| 81 | 81 | ||
| 82 | void RequestUpdate(Kernel::HLERequestContext& ctx) { | 82 | void RequestUpdateImpl(Kernel::HLERequestContext& ctx) { |
| 83 | ctx.WriteBuffer(renderer->UpdateAudioRenderer(ctx.ReadBuffer())); | 83 | ctx.WriteBuffer(renderer->UpdateAudioRenderer(ctx.ReadBuffer())); |
| 84 | IPC::ResponseBuilder rb{ctx, 2}; | 84 | IPC::ResponseBuilder rb{ctx, 2}; |
| 85 | rb.Push(RESULT_SUCCESS); | 85 | rb.Push(RESULT_SUCCESS); |
| @@ -110,8 +110,29 @@ private: | |||
| 110 | LOG_WARNING(Service_Audio, "(STUBBED) called"); | 110 | LOG_WARNING(Service_Audio, "(STUBBED) called"); |
| 111 | } | 111 | } |
| 112 | 112 | ||
| 113 | void SetRenderingTimeLimit(Kernel::HLERequestContext& ctx) { | ||
| 114 | IPC::RequestParser rp{ctx}; | ||
| 115 | rendering_time_limit_percent = rp.Pop<u32>(); | ||
| 116 | ASSERT(rendering_time_limit_percent >= 0 && rendering_time_limit_percent <= 100); | ||
| 117 | |||
| 118 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 119 | rb.Push(RESULT_SUCCESS); | ||
| 120 | |||
| 121 | LOG_DEBUG(Service_Audio, "called. rendering_time_limit_percent={}", | ||
| 122 | rendering_time_limit_percent); | ||
| 123 | } | ||
| 124 | |||
| 125 | void GetRenderingTimeLimit(Kernel::HLERequestContext& ctx) { | ||
| 126 | LOG_DEBUG(Service_Audio, "called"); | ||
| 127 | |||
| 128 | IPC::ResponseBuilder rb{ctx, 3}; | ||
| 129 | rb.Push(RESULT_SUCCESS); | ||
| 130 | rb.Push(rendering_time_limit_percent); | ||
| 131 | } | ||
| 132 | |||
| 113 | Kernel::SharedPtr<Kernel::Event> system_event; | 133 | Kernel::SharedPtr<Kernel::Event> system_event; |
| 114 | std::unique_ptr<AudioCore::AudioRenderer> renderer; | 134 | std::unique_ptr<AudioCore::AudioRenderer> renderer; |
| 135 | u32 rendering_time_limit_percent = 100; | ||
| 115 | }; | 136 | }; |
| 116 | 137 | ||
| 117 | class IAudioDevice final : public ServiceFramework<IAudioDevice> { | 138 | class IAudioDevice final : public ServiceFramework<IAudioDevice> { |
diff --git a/src/core/hle/service/audio/hwopus.cpp b/src/core/hle/service/audio/hwopus.cpp index 783c39503..763e619a4 100644 --- a/src/core/hle/service/audio/hwopus.cpp +++ b/src/core/hle/service/audio/hwopus.cpp | |||
| @@ -77,8 +77,8 @@ private: | |||
| 77 | IPC::ResponseBuilder rb{ctx, 6}; | 77 | IPC::ResponseBuilder rb{ctx, 6}; |
| 78 | rb.Push(RESULT_SUCCESS); | 78 | rb.Push(RESULT_SUCCESS); |
| 79 | rb.Push<u32>(consumed); | 79 | rb.Push<u32>(consumed); |
| 80 | rb.Push<u64>(performance); | ||
| 81 | rb.Push<u32>(sample_count); | 80 | rb.Push<u32>(sample_count); |
| 81 | rb.Push<u64>(performance); | ||
| 82 | ctx.WriteBuffer(samples.data(), samples.size() * sizeof(s16)); | 82 | ctx.WriteBuffer(samples.data(), samples.size() * sizeof(s16)); |
| 83 | } | 83 | } |
| 84 | 84 | ||
diff --git a/src/core/hle/service/btdrv/btdrv.cpp b/src/core/hle/service/btdrv/btdrv.cpp index d0a15cc4c..f3bde6d0d 100644 --- a/src/core/hle/service/btdrv/btdrv.cpp +++ b/src/core/hle/service/btdrv/btdrv.cpp | |||
| @@ -2,12 +2,49 @@ | |||
| 2 | // Licensed under GPLv2 or any later version | 2 | // Licensed under GPLv2 or any later version |
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include "common/logging/log.h" | ||
| 6 | #include "core/hle/ipc_helpers.h" | ||
| 7 | #include "core/hle/kernel/event.h" | ||
| 8 | #include "core/hle/kernel/hle_ipc.h" | ||
| 5 | #include "core/hle/service/btdrv/btdrv.h" | 9 | #include "core/hle/service/btdrv/btdrv.h" |
| 6 | #include "core/hle/service/service.h" | 10 | #include "core/hle/service/service.h" |
| 7 | #include "core/hle/service/sm/sm.h" | 11 | #include "core/hle/service/sm/sm.h" |
| 8 | 12 | ||
| 9 | namespace Service::BtDrv { | 13 | namespace Service::BtDrv { |
| 10 | 14 | ||
| 15 | class Bt final : public ServiceFramework<Bt> { | ||
| 16 | public: | ||
| 17 | explicit Bt() : ServiceFramework{"bt"} { | ||
| 18 | // clang-format off | ||
| 19 | static const FunctionInfo functions[] = { | ||
| 20 | {0, nullptr, "Unknown0"}, | ||
| 21 | {1, nullptr, "Unknown1"}, | ||
| 22 | {2, nullptr, "Unknown2"}, | ||
| 23 | {3, nullptr, "Unknown3"}, | ||
| 24 | {4, nullptr, "Unknown4"}, | ||
| 25 | {5, nullptr, "Unknown5"}, | ||
| 26 | {6, nullptr, "Unknown6"}, | ||
| 27 | {7, nullptr, "Unknown7"}, | ||
| 28 | {8, nullptr, "Unknown8"}, | ||
| 29 | {9, &Bt::RegisterEvent, "RegisterEvent"}, | ||
| 30 | }; | ||
| 31 | // clang-format on | ||
| 32 | RegisterHandlers(functions); | ||
| 33 | } | ||
| 34 | |||
| 35 | private: | ||
| 36 | void RegisterEvent(Kernel::HLERequestContext& ctx) { | ||
| 37 | auto& kernel = Core::System::GetInstance().Kernel(); | ||
| 38 | register_event = | ||
| 39 | Kernel::Event::Create(kernel, Kernel::ResetType::OneShot, "BT:RegisterEvent"); | ||
| 40 | IPC::ResponseBuilder rb{ctx, 2, 1}; | ||
| 41 | rb.Push(RESULT_SUCCESS); | ||
| 42 | rb.PushCopyObjects(register_event); | ||
| 43 | LOG_WARNING(Service_BTM, "(STUBBED) called"); | ||
| 44 | } | ||
| 45 | Kernel::SharedPtr<Kernel::Event> register_event; | ||
| 46 | }; | ||
| 47 | |||
| 11 | class BtDrv final : public ServiceFramework<BtDrv> { | 48 | class BtDrv final : public ServiceFramework<BtDrv> { |
| 12 | public: | 49 | public: |
| 13 | explicit BtDrv() : ServiceFramework{"btdrv"} { | 50 | explicit BtDrv() : ServiceFramework{"btdrv"} { |
| @@ -67,6 +104,7 @@ public: | |||
| 67 | 104 | ||
| 68 | void InstallInterfaces(SM::ServiceManager& sm) { | 105 | void InstallInterfaces(SM::ServiceManager& sm) { |
| 69 | std::make_shared<BtDrv>()->InstallAsService(sm); | 106 | std::make_shared<BtDrv>()->InstallAsService(sm); |
| 107 | std::make_shared<Bt>()->InstallAsService(sm); | ||
| 70 | } | 108 | } |
| 71 | 109 | ||
| 72 | } // namespace Service::BtDrv | 110 | } // namespace Service::BtDrv |
diff --git a/src/core/hle/service/btm/btm.cpp b/src/core/hle/service/btm/btm.cpp index b949bfabd..a02f6b53a 100644 --- a/src/core/hle/service/btm/btm.cpp +++ b/src/core/hle/service/btm/btm.cpp | |||
| @@ -6,13 +6,118 @@ | |||
| 6 | 6 | ||
| 7 | #include "common/logging/log.h" | 7 | #include "common/logging/log.h" |
| 8 | #include "core/hle/ipc_helpers.h" | 8 | #include "core/hle/ipc_helpers.h" |
| 9 | #include "core/hle/kernel/event.h" | ||
| 9 | #include "core/hle/kernel/hle_ipc.h" | 10 | #include "core/hle/kernel/hle_ipc.h" |
| 10 | #include "core/hle/service/btm/btm.h" | 11 | #include "core/hle/service/btm/btm.h" |
| 11 | #include "core/hle/service/service.h" | 12 | #include "core/hle/service/service.h" |
| 12 | #include "core/hle/service/sm/sm.h" | ||
| 13 | 13 | ||
| 14 | namespace Service::BTM { | 14 | namespace Service::BTM { |
| 15 | 15 | ||
| 16 | class IBtmUserCore final : public ServiceFramework<IBtmUserCore> { | ||
| 17 | public: | ||
| 18 | explicit IBtmUserCore() : ServiceFramework{"IBtmUserCore"} { | ||
| 19 | // clang-format off | ||
| 20 | static const FunctionInfo functions[] = { | ||
| 21 | {0, &IBtmUserCore::GetScanEvent, "GetScanEvent"}, | ||
| 22 | {1, nullptr, "Unknown1"}, | ||
| 23 | {2, nullptr, "Unknown2"}, | ||
| 24 | {3, nullptr, "Unknown3"}, | ||
| 25 | {4, nullptr, "Unknown4"}, | ||
| 26 | {5, nullptr, "Unknown5"}, | ||
| 27 | {6, nullptr, "Unknown6"}, | ||
| 28 | {7, nullptr, "Unknown7"}, | ||
| 29 | {8, nullptr, "Unknown8"}, | ||
| 30 | {9, nullptr, "Unknown9"}, | ||
| 31 | {10, nullptr, "Unknown10"}, | ||
| 32 | {17, &IBtmUserCore::GetConnectionEvent, "GetConnectionEvent"}, | ||
| 33 | {18, nullptr, "Unknown18"}, | ||
| 34 | {19, nullptr, "Unknown19"}, | ||
| 35 | {20, nullptr, "Unknown20"}, | ||
| 36 | {21, nullptr, "Unknown21"}, | ||
| 37 | {22, nullptr, "Unknown22"}, | ||
| 38 | {23, nullptr, "Unknown23"}, | ||
| 39 | {24, nullptr, "Unknown24"}, | ||
| 40 | {25, nullptr, "Unknown25"}, | ||
| 41 | {26, &IBtmUserCore::GetDiscoveryEvent, "AcquireBleServiceDiscoveryEventImpl"}, | ||
| 42 | {27, nullptr, "Unknown27"}, | ||
| 43 | {28, nullptr, "Unknown28"}, | ||
| 44 | {29, nullptr, "Unknown29"}, | ||
| 45 | {30, nullptr, "Unknown30"}, | ||
| 46 | {31, nullptr, "Unknown31"}, | ||
| 47 | {32, nullptr, "Unknown32"}, | ||
| 48 | {33, &IBtmUserCore::GetConfigEvent, "GetConfigEvent"}, | ||
| 49 | {34, nullptr, "Unknown34"}, | ||
| 50 | {35, nullptr, "Unknown35"}, | ||
| 51 | {36, nullptr, "Unknown36"}, | ||
| 52 | {37, nullptr, "Unknown37"}, | ||
| 53 | }; | ||
| 54 | // clang-format on | ||
| 55 | RegisterHandlers(functions); | ||
| 56 | } | ||
| 57 | |||
| 58 | private: | ||
| 59 | void GetScanEvent(Kernel::HLERequestContext& ctx) { | ||
| 60 | auto& kernel = Core::System::GetInstance().Kernel(); | ||
| 61 | scan_event = | ||
| 62 | Kernel::Event::Create(kernel, Kernel::ResetType::OneShot, "IBtmUserCore:ScanEvent"); | ||
| 63 | IPC::ResponseBuilder rb{ctx, 2, 1}; | ||
| 64 | rb.Push(RESULT_SUCCESS); | ||
| 65 | rb.PushCopyObjects(scan_event); | ||
| 66 | LOG_WARNING(Service_BTM, "(STUBBED) called"); | ||
| 67 | } | ||
| 68 | void GetConnectionEvent(Kernel::HLERequestContext& ctx) { | ||
| 69 | auto& kernel = Core::System::GetInstance().Kernel(); | ||
| 70 | connection_event = Kernel::Event::Create(kernel, Kernel::ResetType::OneShot, | ||
| 71 | "IBtmUserCore:ConnectionEvent"); | ||
| 72 | IPC::ResponseBuilder rb{ctx, 2, 1}; | ||
| 73 | rb.Push(RESULT_SUCCESS); | ||
| 74 | rb.PushCopyObjects(connection_event); | ||
| 75 | LOG_WARNING(Service_BTM, "(STUBBED) called"); | ||
| 76 | } | ||
| 77 | void GetDiscoveryEvent(Kernel::HLERequestContext& ctx) { | ||
| 78 | auto& kernel = Core::System::GetInstance().Kernel(); | ||
| 79 | service_discovery = | ||
| 80 | Kernel::Event::Create(kernel, Kernel::ResetType::OneShot, "IBtmUserCore:Discovery"); | ||
| 81 | IPC::ResponseBuilder rb{ctx, 2, 1}; | ||
| 82 | rb.Push(RESULT_SUCCESS); | ||
| 83 | rb.PushCopyObjects(service_discovery); | ||
| 84 | LOG_WARNING(Service_BTM, "(STUBBED) called"); | ||
| 85 | } | ||
| 86 | void GetConfigEvent(Kernel::HLERequestContext& ctx) { | ||
| 87 | auto& kernel = Core::System::GetInstance().Kernel(); | ||
| 88 | config_event = | ||
| 89 | Kernel::Event::Create(kernel, Kernel::ResetType::OneShot, "IBtmUserCore:ConfigEvent"); | ||
| 90 | IPC::ResponseBuilder rb{ctx, 2, 1}; | ||
| 91 | rb.Push(RESULT_SUCCESS); | ||
| 92 | rb.PushCopyObjects(config_event); | ||
| 93 | LOG_WARNING(Service_BTM, "(STUBBED) called"); | ||
| 94 | } | ||
| 95 | Kernel::SharedPtr<Kernel::Event> scan_event; | ||
| 96 | Kernel::SharedPtr<Kernel::Event> connection_event; | ||
| 97 | Kernel::SharedPtr<Kernel::Event> service_discovery; | ||
| 98 | Kernel::SharedPtr<Kernel::Event> config_event; | ||
| 99 | }; | ||
| 100 | |||
| 101 | class BTM_USR final : public ServiceFramework<BTM_USR> { | ||
| 102 | public: | ||
| 103 | explicit BTM_USR() : ServiceFramework{"btm:u"} { | ||
| 104 | // clang-format off | ||
| 105 | static const FunctionInfo functions[] = { | ||
| 106 | {0, &BTM_USR::GetCoreImpl, "GetCoreImpl"}, | ||
| 107 | }; | ||
| 108 | // clang-format on | ||
| 109 | RegisterHandlers(functions); | ||
| 110 | } | ||
| 111 | |||
| 112 | private: | ||
| 113 | void GetCoreImpl(Kernel::HLERequestContext& ctx) { | ||
| 114 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; | ||
| 115 | rb.Push(RESULT_SUCCESS); | ||
| 116 | rb.PushIpcInterface<IBtmUserCore>(); | ||
| 117 | LOG_DEBUG(Service_BTM, "called"); | ||
| 118 | } | ||
| 119 | }; | ||
| 120 | |||
| 16 | class BTM final : public ServiceFramework<BTM> { | 121 | class BTM final : public ServiceFramework<BTM> { |
| 17 | public: | 122 | public: |
| 18 | explicit BTM() : ServiceFramework{"btm"} { | 123 | explicit BTM() : ServiceFramework{"btm"} { |
| @@ -116,6 +221,7 @@ void InstallInterfaces(SM::ServiceManager& sm) { | |||
| 116 | std::make_shared<BTM>()->InstallAsService(sm); | 221 | std::make_shared<BTM>()->InstallAsService(sm); |
| 117 | std::make_shared<BTM_DBG>()->InstallAsService(sm); | 222 | std::make_shared<BTM_DBG>()->InstallAsService(sm); |
| 118 | std::make_shared<BTM_SYS>()->InstallAsService(sm); | 223 | std::make_shared<BTM_SYS>()->InstallAsService(sm); |
| 224 | std::make_shared<BTM_USR>()->InstallAsService(sm); | ||
| 119 | } | 225 | } |
| 120 | 226 | ||
| 121 | } // namespace Service::BTM | 227 | } // namespace Service::BTM |
diff --git a/src/core/hle/service/filesystem/filesystem.cpp b/src/core/hle/service/filesystem/filesystem.cpp index e32a7c48e..5d6294016 100644 --- a/src/core/hle/service/filesystem/filesystem.cpp +++ b/src/core/hle/service/filesystem/filesystem.cpp | |||
| @@ -303,25 +303,42 @@ ResultVal<FileSys::VirtualDir> OpenSaveData(FileSys::SaveDataSpaceId space, | |||
| 303 | static_cast<u8>(space), save_struct.DebugInfo()); | 303 | static_cast<u8>(space), save_struct.DebugInfo()); |
| 304 | 304 | ||
| 305 | if (save_data_factory == nullptr) { | 305 | if (save_data_factory == nullptr) { |
| 306 | return ResultCode(ErrorModule::FS, FileSys::ErrCodes::TitleNotFound); | 306 | return FileSys::ERROR_ENTITY_NOT_FOUND; |
| 307 | } | 307 | } |
| 308 | 308 | ||
| 309 | return save_data_factory->Open(space, save_struct); | 309 | return save_data_factory->Open(space, save_struct); |
| 310 | } | 310 | } |
| 311 | 311 | ||
| 312 | ResultVal<FileSys::VirtualDir> OpenSaveDataSpace(FileSys::SaveDataSpaceId space) { | ||
| 313 | LOG_TRACE(Service_FS, "Opening Save Data Space for space_id={:01X}", static_cast<u8>(space)); | ||
| 314 | |||
| 315 | if (save_data_factory == nullptr) { | ||
| 316 | return FileSys::ERROR_ENTITY_NOT_FOUND; | ||
| 317 | } | ||
| 318 | |||
| 319 | return MakeResult(save_data_factory->GetSaveDataSpaceDirectory(space)); | ||
| 320 | } | ||
| 321 | |||
| 312 | ResultVal<FileSys::VirtualDir> OpenSDMC() { | 322 | ResultVal<FileSys::VirtualDir> OpenSDMC() { |
| 313 | LOG_TRACE(Service_FS, "Opening SDMC"); | 323 | LOG_TRACE(Service_FS, "Opening SDMC"); |
| 314 | 324 | ||
| 315 | if (sdmc_factory == nullptr) { | 325 | if (sdmc_factory == nullptr) { |
| 316 | return ResultCode(ErrorModule::FS, FileSys::ErrCodes::SdCardNotFound); | 326 | return FileSys::ERROR_SD_CARD_NOT_FOUND; |
| 317 | } | 327 | } |
| 318 | 328 | ||
| 319 | return sdmc_factory->Open(); | 329 | return sdmc_factory->Open(); |
| 320 | } | 330 | } |
| 321 | 331 | ||
| 322 | std::unique_ptr<FileSys::RegisteredCacheUnion> GetUnionContents() { | 332 | std::shared_ptr<FileSys::RegisteredCacheUnion> registered_cache_union; |
| 323 | return std::make_unique<FileSys::RegisteredCacheUnion>(std::vector<FileSys::RegisteredCache*>{ | 333 | |
| 324 | GetSystemNANDContents(), GetUserNANDContents(), GetSDMCContents()}); | 334 | std::shared_ptr<FileSys::RegisteredCacheUnion> GetUnionContents() { |
| 335 | if (registered_cache_union == nullptr) { | ||
| 336 | registered_cache_union = | ||
| 337 | std::make_shared<FileSys::RegisteredCacheUnion>(std::vector<FileSys::RegisteredCache*>{ | ||
| 338 | GetSystemNANDContents(), GetUserNANDContents(), GetSDMCContents()}); | ||
| 339 | } | ||
| 340 | |||
| 341 | return registered_cache_union; | ||
| 325 | } | 342 | } |
| 326 | 343 | ||
| 327 | FileSys::RegisteredCache* GetSystemNANDContents() { | 344 | FileSys::RegisteredCache* GetSystemNANDContents() { |
| @@ -360,6 +377,15 @@ FileSys::VirtualDir GetModificationLoadRoot(u64 title_id) { | |||
| 360 | return bis_factory->GetModificationLoadRoot(title_id); | 377 | return bis_factory->GetModificationLoadRoot(title_id); |
| 361 | } | 378 | } |
| 362 | 379 | ||
| 380 | FileSys::VirtualDir GetModificationDumpRoot(u64 title_id) { | ||
| 381 | LOG_TRACE(Service_FS, "Opening mod dump root for tid={:016X}", title_id); | ||
| 382 | |||
| 383 | if (bis_factory == nullptr) | ||
| 384 | return nullptr; | ||
| 385 | |||
| 386 | return bis_factory->GetModificationDumpRoot(title_id); | ||
| 387 | } | ||
| 388 | |||
| 363 | void CreateFactories(FileSys::VfsFilesystem& vfs, bool overwrite) { | 389 | void CreateFactories(FileSys::VfsFilesystem& vfs, bool overwrite) { |
| 364 | if (overwrite) { | 390 | if (overwrite) { |
| 365 | bis_factory = nullptr; | 391 | bis_factory = nullptr; |
| @@ -373,13 +399,21 @@ void CreateFactories(FileSys::VfsFilesystem& vfs, bool overwrite) { | |||
| 373 | FileSys::Mode::ReadWrite); | 399 | FileSys::Mode::ReadWrite); |
| 374 | auto load_directory = vfs.OpenDirectory(FileUtil::GetUserPath(FileUtil::UserPath::LoadDir), | 400 | auto load_directory = vfs.OpenDirectory(FileUtil::GetUserPath(FileUtil::UserPath::LoadDir), |
| 375 | FileSys::Mode::ReadWrite); | 401 | FileSys::Mode::ReadWrite); |
| 402 | auto dump_directory = vfs.OpenDirectory(FileUtil::GetUserPath(FileUtil::UserPath::DumpDir), | ||
| 403 | FileSys::Mode::ReadWrite); | ||
| 376 | 404 | ||
| 377 | if (bis_factory == nullptr) | 405 | if (bis_factory == nullptr) { |
| 378 | bis_factory = std::make_unique<FileSys::BISFactory>(nand_directory, load_directory); | 406 | bis_factory = |
| 379 | if (save_data_factory == nullptr) | 407 | std::make_unique<FileSys::BISFactory>(nand_directory, load_directory, dump_directory); |
| 408 | } | ||
| 409 | |||
| 410 | if (save_data_factory == nullptr) { | ||
| 380 | save_data_factory = std::make_unique<FileSys::SaveDataFactory>(std::move(nand_directory)); | 411 | save_data_factory = std::make_unique<FileSys::SaveDataFactory>(std::move(nand_directory)); |
| 381 | if (sdmc_factory == nullptr) | 412 | } |
| 413 | |||
| 414 | if (sdmc_factory == nullptr) { | ||
| 382 | sdmc_factory = std::make_unique<FileSys::SDMCFactory>(std::move(sd_directory)); | 415 | sdmc_factory = std::make_unique<FileSys::SDMCFactory>(std::move(sd_directory)); |
| 416 | } | ||
| 383 | } | 417 | } |
| 384 | 418 | ||
| 385 | void InstallInterfaces(SM::ServiceManager& service_manager, FileSys::VfsFilesystem& vfs) { | 419 | void InstallInterfaces(SM::ServiceManager& service_manager, FileSys::VfsFilesystem& vfs) { |
diff --git a/src/core/hle/service/filesystem/filesystem.h b/src/core/hle/service/filesystem/filesystem.h index 6ca5c5636..ff9182e84 100644 --- a/src/core/hle/service/filesystem/filesystem.h +++ b/src/core/hle/service/filesystem/filesystem.h | |||
| @@ -45,15 +45,17 @@ ResultVal<FileSys::VirtualFile> OpenRomFS(u64 title_id, FileSys::StorageId stora | |||
| 45 | FileSys::ContentRecordType type); | 45 | FileSys::ContentRecordType type); |
| 46 | ResultVal<FileSys::VirtualDir> OpenSaveData(FileSys::SaveDataSpaceId space, | 46 | ResultVal<FileSys::VirtualDir> OpenSaveData(FileSys::SaveDataSpaceId space, |
| 47 | FileSys::SaveDataDescriptor save_struct); | 47 | FileSys::SaveDataDescriptor save_struct); |
| 48 | ResultVal<FileSys::VirtualDir> OpenSaveDataSpace(FileSys::SaveDataSpaceId space); | ||
| 48 | ResultVal<FileSys::VirtualDir> OpenSDMC(); | 49 | ResultVal<FileSys::VirtualDir> OpenSDMC(); |
| 49 | 50 | ||
| 50 | std::unique_ptr<FileSys::RegisteredCacheUnion> GetUnionContents(); | 51 | std::shared_ptr<FileSys::RegisteredCacheUnion> GetUnionContents(); |
| 51 | 52 | ||
| 52 | FileSys::RegisteredCache* GetSystemNANDContents(); | 53 | FileSys::RegisteredCache* GetSystemNANDContents(); |
| 53 | FileSys::RegisteredCache* GetUserNANDContents(); | 54 | FileSys::RegisteredCache* GetUserNANDContents(); |
| 54 | FileSys::RegisteredCache* GetSDMCContents(); | 55 | FileSys::RegisteredCache* GetSDMCContents(); |
| 55 | 56 | ||
| 56 | FileSys::VirtualDir GetModificationLoadRoot(u64 title_id); | 57 | FileSys::VirtualDir GetModificationLoadRoot(u64 title_id); |
| 58 | FileSys::VirtualDir GetModificationDumpRoot(u64 title_id); | ||
| 57 | 59 | ||
| 58 | // Creates the SaveData, SDMC, and BIS Factories. Should be called once and before any function | 60 | // Creates the SaveData, SDMC, and BIS Factories. Should be called once and before any function |
| 59 | // above is called. | 61 | // above is called. |
diff --git a/src/core/hle/service/filesystem/fsp_srv.cpp b/src/core/hle/service/filesystem/fsp_srv.cpp index c1c83a11d..038dc80b1 100644 --- a/src/core/hle/service/filesystem/fsp_srv.cpp +++ b/src/core/hle/service/filesystem/fsp_srv.cpp | |||
| @@ -11,6 +11,7 @@ | |||
| 11 | 11 | ||
| 12 | #include "common/assert.h" | 12 | #include "common/assert.h" |
| 13 | #include "common/common_types.h" | 13 | #include "common/common_types.h" |
| 14 | #include "common/hex_util.h" | ||
| 14 | #include "common/logging/log.h" | 15 | #include "common/logging/log.h" |
| 15 | #include "common/string_util.h" | 16 | #include "common/string_util.h" |
| 16 | #include "core/file_sys/directory.h" | 17 | #include "core/file_sys/directory.h" |
| @@ -62,12 +63,12 @@ private: | |||
| 62 | // Error checking | 63 | // Error checking |
| 63 | if (length < 0) { | 64 | if (length < 0) { |
| 64 | IPC::ResponseBuilder rb{ctx, 2}; | 65 | IPC::ResponseBuilder rb{ctx, 2}; |
| 65 | rb.Push(ResultCode(ErrorModule::FS, ErrorDescription::InvalidLength)); | 66 | rb.Push(FileSys::ERROR_INVALID_SIZE); |
| 66 | return; | 67 | return; |
| 67 | } | 68 | } |
| 68 | if (offset < 0) { | 69 | if (offset < 0) { |
| 69 | IPC::ResponseBuilder rb{ctx, 2}; | 70 | IPC::ResponseBuilder rb{ctx, 2}; |
| 70 | rb.Push(ResultCode(ErrorModule::FS, ErrorDescription::InvalidOffset)); | 71 | rb.Push(FileSys::ERROR_INVALID_OFFSET); |
| 71 | return; | 72 | return; |
| 72 | } | 73 | } |
| 73 | 74 | ||
| @@ -107,12 +108,12 @@ private: | |||
| 107 | // Error checking | 108 | // Error checking |
| 108 | if (length < 0) { | 109 | if (length < 0) { |
| 109 | IPC::ResponseBuilder rb{ctx, 2}; | 110 | IPC::ResponseBuilder rb{ctx, 2}; |
| 110 | rb.Push(ResultCode(ErrorModule::FS, ErrorDescription::InvalidLength)); | 111 | rb.Push(FileSys::ERROR_INVALID_SIZE); |
| 111 | return; | 112 | return; |
| 112 | } | 113 | } |
| 113 | if (offset < 0) { | 114 | if (offset < 0) { |
| 114 | IPC::ResponseBuilder rb{ctx, 2}; | 115 | IPC::ResponseBuilder rb{ctx, 2}; |
| 115 | rb.Push(ResultCode(ErrorModule::FS, ErrorDescription::InvalidOffset)); | 116 | rb.Push(FileSys::ERROR_INVALID_OFFSET); |
| 116 | return; | 117 | return; |
| 117 | } | 118 | } |
| 118 | 119 | ||
| @@ -138,12 +139,12 @@ private: | |||
| 138 | // Error checking | 139 | // Error checking |
| 139 | if (length < 0) { | 140 | if (length < 0) { |
| 140 | IPC::ResponseBuilder rb{ctx, 2}; | 141 | IPC::ResponseBuilder rb{ctx, 2}; |
| 141 | rb.Push(ResultCode(ErrorModule::FS, ErrorDescription::InvalidLength)); | 142 | rb.Push(FileSys::ERROR_INVALID_SIZE); |
| 142 | return; | 143 | return; |
| 143 | } | 144 | } |
| 144 | if (offset < 0) { | 145 | if (offset < 0) { |
| 145 | IPC::ResponseBuilder rb{ctx, 2}; | 146 | IPC::ResponseBuilder rb{ctx, 2}; |
| 146 | rb.Push(ResultCode(ErrorModule::FS, ErrorDescription::InvalidOffset)); | 147 | rb.Push(FileSys::ERROR_INVALID_OFFSET); |
| 147 | return; | 148 | return; |
| 148 | } | 149 | } |
| 149 | 150 | ||
| @@ -451,7 +452,147 @@ private: | |||
| 451 | VfsDirectoryServiceWrapper backend; | 452 | VfsDirectoryServiceWrapper backend; |
| 452 | }; | 453 | }; |
| 453 | 454 | ||
| 455 | class ISaveDataInfoReader final : public ServiceFramework<ISaveDataInfoReader> { | ||
| 456 | public: | ||
| 457 | explicit ISaveDataInfoReader(FileSys::SaveDataSpaceId space) | ||
| 458 | : ServiceFramework("ISaveDataInfoReader") { | ||
| 459 | static const FunctionInfo functions[] = { | ||
| 460 | {0, &ISaveDataInfoReader::ReadSaveDataInfo, "ReadSaveDataInfo"}, | ||
| 461 | }; | ||
| 462 | RegisterHandlers(functions); | ||
| 463 | |||
| 464 | FindAllSaves(space); | ||
| 465 | } | ||
| 466 | |||
| 467 | void ReadSaveDataInfo(Kernel::HLERequestContext& ctx) { | ||
| 468 | // Calculate how many entries we can fit in the output buffer | ||
| 469 | const u64 count_entries = ctx.GetWriteBufferSize() / sizeof(SaveDataInfo); | ||
| 470 | |||
| 471 | // Cap at total number of entries. | ||
| 472 | const u64 actual_entries = std::min(count_entries, info.size() - next_entry_index); | ||
| 473 | |||
| 474 | // Determine data start and end | ||
| 475 | const auto* begin = reinterpret_cast<u8*>(info.data() + next_entry_index); | ||
| 476 | const auto* end = reinterpret_cast<u8*>(info.data() + next_entry_index + actual_entries); | ||
| 477 | const auto range_size = static_cast<std::size_t>(std::distance(begin, end)); | ||
| 478 | |||
| 479 | next_entry_index += actual_entries; | ||
| 480 | |||
| 481 | // Write the data to memory | ||
| 482 | ctx.WriteBuffer(begin, range_size); | ||
| 483 | |||
| 484 | IPC::ResponseBuilder rb{ctx, 3}; | ||
| 485 | rb.Push(RESULT_SUCCESS); | ||
| 486 | rb.Push<u32>(static_cast<u32>(actual_entries)); | ||
| 487 | } | ||
| 488 | |||
| 489 | private: | ||
| 490 | static u64 stoull_be(std::string_view str) { | ||
| 491 | if (str.size() != 16) | ||
| 492 | return 0; | ||
| 493 | |||
| 494 | const auto bytes = Common::HexStringToArray<0x8>(str); | ||
| 495 | u64 out{}; | ||
| 496 | std::memcpy(&out, bytes.data(), sizeof(u64)); | ||
| 497 | |||
| 498 | return Common::swap64(out); | ||
| 499 | } | ||
| 500 | |||
| 501 | void FindAllSaves(FileSys::SaveDataSpaceId space) { | ||
| 502 | const auto save_root = OpenSaveDataSpace(space); | ||
| 503 | ASSERT(save_root.Succeeded()); | ||
| 504 | |||
| 505 | for (const auto& type : (*save_root)->GetSubdirectories()) { | ||
| 506 | if (type->GetName() == "save") { | ||
| 507 | for (const auto& save_id : type->GetSubdirectories()) { | ||
| 508 | for (const auto& user_id : save_id->GetSubdirectories()) { | ||
| 509 | const auto save_id_numeric = stoull_be(save_id->GetName()); | ||
| 510 | auto user_id_numeric = Common::HexStringToArray<0x10>(user_id->GetName()); | ||
| 511 | std::reverse(user_id_numeric.begin(), user_id_numeric.end()); | ||
| 512 | |||
| 513 | if (save_id_numeric != 0) { | ||
| 514 | // System Save Data | ||
| 515 | info.emplace_back(SaveDataInfo{ | ||
| 516 | 0, | ||
| 517 | space, | ||
| 518 | FileSys::SaveDataType::SystemSaveData, | ||
| 519 | {}, | ||
| 520 | user_id_numeric, | ||
| 521 | save_id_numeric, | ||
| 522 | 0, | ||
| 523 | user_id->GetSize(), | ||
| 524 | {}, | ||
| 525 | }); | ||
| 526 | |||
| 527 | continue; | ||
| 528 | } | ||
| 529 | |||
| 530 | for (const auto& title_id : user_id->GetSubdirectories()) { | ||
| 531 | const auto device = | ||
| 532 | std::all_of(user_id_numeric.begin(), user_id_numeric.end(), | ||
| 533 | [](u8 val) { return val == 0; }); | ||
| 534 | info.emplace_back(SaveDataInfo{ | ||
| 535 | 0, | ||
| 536 | space, | ||
| 537 | device ? FileSys::SaveDataType::DeviceSaveData | ||
| 538 | : FileSys::SaveDataType::SaveData, | ||
| 539 | {}, | ||
| 540 | user_id_numeric, | ||
| 541 | save_id_numeric, | ||
| 542 | stoull_be(title_id->GetName()), | ||
| 543 | title_id->GetSize(), | ||
| 544 | {}, | ||
| 545 | }); | ||
| 546 | } | ||
| 547 | } | ||
| 548 | } | ||
| 549 | } else if (space == FileSys::SaveDataSpaceId::TemporaryStorage) { | ||
| 550 | // Temporary Storage | ||
| 551 | for (const auto& user_id : type->GetSubdirectories()) { | ||
| 552 | for (const auto& title_id : user_id->GetSubdirectories()) { | ||
| 553 | if (!title_id->GetFiles().empty() || | ||
| 554 | !title_id->GetSubdirectories().empty()) { | ||
| 555 | auto user_id_numeric = | ||
| 556 | Common::HexStringToArray<0x10>(user_id->GetName()); | ||
| 557 | std::reverse(user_id_numeric.begin(), user_id_numeric.end()); | ||
| 558 | |||
| 559 | info.emplace_back(SaveDataInfo{ | ||
| 560 | 0, | ||
| 561 | space, | ||
| 562 | FileSys::SaveDataType::TemporaryStorage, | ||
| 563 | {}, | ||
| 564 | user_id_numeric, | ||
| 565 | stoull_be(type->GetName()), | ||
| 566 | stoull_be(title_id->GetName()), | ||
| 567 | title_id->GetSize(), | ||
| 568 | {}, | ||
| 569 | }); | ||
| 570 | } | ||
| 571 | } | ||
| 572 | } | ||
| 573 | } | ||
| 574 | } | ||
| 575 | } | ||
| 576 | |||
| 577 | struct SaveDataInfo { | ||
| 578 | u64_le save_id_unknown; | ||
| 579 | FileSys::SaveDataSpaceId space; | ||
| 580 | FileSys::SaveDataType type; | ||
| 581 | INSERT_PADDING_BYTES(0x6); | ||
| 582 | std::array<u8, 0x10> user_id; | ||
| 583 | u64_le save_id; | ||
| 584 | u64_le title_id; | ||
| 585 | u64_le save_image_size; | ||
| 586 | INSERT_PADDING_BYTES(0x28); | ||
| 587 | }; | ||
| 588 | static_assert(sizeof(SaveDataInfo) == 0x60, "SaveDataInfo has incorrect size."); | ||
| 589 | |||
| 590 | std::vector<SaveDataInfo> info; | ||
| 591 | u64 next_entry_index = 0; | ||
| 592 | }; | ||
| 593 | |||
| 454 | FSP_SRV::FSP_SRV() : ServiceFramework("fsp-srv") { | 594 | FSP_SRV::FSP_SRV() : ServiceFramework("fsp-srv") { |
| 595 | // clang-format off | ||
| 455 | static const FunctionInfo functions[] = { | 596 | static const FunctionInfo functions[] = { |
| 456 | {0, nullptr, "MountContent"}, | 597 | {0, nullptr, "MountContent"}, |
| 457 | {1, &FSP_SRV::Initialize, "Initialize"}, | 598 | {1, &FSP_SRV::Initialize, "Initialize"}, |
| @@ -485,7 +626,7 @@ FSP_SRV::FSP_SRV() : ServiceFramework("fsp-srv") { | |||
| 485 | {58, nullptr, "ReadSaveDataFileSystemExtraData"}, | 626 | {58, nullptr, "ReadSaveDataFileSystemExtraData"}, |
| 486 | {59, nullptr, "WriteSaveDataFileSystemExtraData"}, | 627 | {59, nullptr, "WriteSaveDataFileSystemExtraData"}, |
| 487 | {60, nullptr, "OpenSaveDataInfoReader"}, | 628 | {60, nullptr, "OpenSaveDataInfoReader"}, |
| 488 | {61, nullptr, "OpenSaveDataInfoReaderBySaveDataSpaceId"}, | 629 | {61, &FSP_SRV::OpenSaveDataInfoReaderBySaveDataSpaceId, "OpenSaveDataInfoReaderBySaveDataSpaceId"}, |
| 489 | {62, nullptr, "OpenCacheStorageList"}, | 630 | {62, nullptr, "OpenCacheStorageList"}, |
| 490 | {64, nullptr, "OpenSaveDataInternalStorageFileSystem"}, | 631 | {64, nullptr, "OpenSaveDataInternalStorageFileSystem"}, |
| 491 | {65, nullptr, "UpdateSaveDataMacForDebug"}, | 632 | {65, nullptr, "UpdateSaveDataMacForDebug"}, |
| @@ -544,6 +685,7 @@ FSP_SRV::FSP_SRV() : ServiceFramework("fsp-srv") { | |||
| 544 | {1009, nullptr, "GetAndClearMemoryReportInfo"}, | 685 | {1009, nullptr, "GetAndClearMemoryReportInfo"}, |
| 545 | {1100, nullptr, "OverrideSaveDataTransferTokenSignVerificationKey"}, | 686 | {1100, nullptr, "OverrideSaveDataTransferTokenSignVerificationKey"}, |
| 546 | }; | 687 | }; |
| 688 | // clang-format on | ||
| 547 | RegisterHandlers(functions); | 689 | RegisterHandlers(functions); |
| 548 | } | 690 | } |
| 549 | 691 | ||
| @@ -602,7 +744,7 @@ void FSP_SRV::MountSaveData(Kernel::HLERequestContext& ctx) { | |||
| 602 | 744 | ||
| 603 | if (dir.Failed()) { | 745 | if (dir.Failed()) { |
| 604 | IPC::ResponseBuilder rb{ctx, 2, 0, 0}; | 746 | IPC::ResponseBuilder rb{ctx, 2, 0, 0}; |
| 605 | rb.Push(ResultCode(ErrorModule::FS, FileSys::ErrCodes::TitleNotFound)); | 747 | rb.Push(FileSys::ERROR_ENTITY_NOT_FOUND); |
| 606 | return; | 748 | return; |
| 607 | } | 749 | } |
| 608 | 750 | ||
| @@ -618,6 +760,15 @@ void FSP_SRV::OpenReadOnlySaveDataFileSystem(Kernel::HLERequestContext& ctx) { | |||
| 618 | MountSaveData(ctx); | 760 | MountSaveData(ctx); |
| 619 | } | 761 | } |
| 620 | 762 | ||
| 763 | void FSP_SRV::OpenSaveDataInfoReaderBySaveDataSpaceId(Kernel::HLERequestContext& ctx) { | ||
| 764 | IPC::RequestParser rp{ctx}; | ||
| 765 | const auto space = rp.PopRaw<FileSys::SaveDataSpaceId>(); | ||
| 766 | |||
| 767 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; | ||
| 768 | rb.Push(RESULT_SUCCESS); | ||
| 769 | rb.PushIpcInterface<ISaveDataInfoReader>(std::make_shared<ISaveDataInfoReader>(space)); | ||
| 770 | } | ||
| 771 | |||
| 621 | void FSP_SRV::GetGlobalAccessLogMode(Kernel::HLERequestContext& ctx) { | 772 | void FSP_SRV::GetGlobalAccessLogMode(Kernel::HLERequestContext& ctx) { |
| 622 | LOG_WARNING(Service_FS, "(STUBBED) called"); | 773 | LOG_WARNING(Service_FS, "(STUBBED) called"); |
| 623 | 774 | ||
| @@ -685,7 +836,7 @@ void FSP_SRV::OpenRomStorage(Kernel::HLERequestContext& ctx) { | |||
| 685 | static_cast<u8>(storage_id), title_id); | 836 | static_cast<u8>(storage_id), title_id); |
| 686 | 837 | ||
| 687 | IPC::ResponseBuilder rb{ctx, 2}; | 838 | IPC::ResponseBuilder rb{ctx, 2}; |
| 688 | rb.Push(ResultCode(ErrorModule::FS, FileSys::ErrCodes::TitleNotFound)); | 839 | rb.Push(FileSys::ERROR_ENTITY_NOT_FOUND); |
| 689 | } | 840 | } |
| 690 | 841 | ||
| 691 | } // namespace Service::FileSystem | 842 | } // namespace Service::FileSystem |
diff --git a/src/core/hle/service/filesystem/fsp_srv.h b/src/core/hle/service/filesystem/fsp_srv.h index 4aa0358cb..e7abec0a3 100644 --- a/src/core/hle/service/filesystem/fsp_srv.h +++ b/src/core/hle/service/filesystem/fsp_srv.h | |||
| @@ -25,6 +25,7 @@ private: | |||
| 25 | void CreateSaveData(Kernel::HLERequestContext& ctx); | 25 | void CreateSaveData(Kernel::HLERequestContext& ctx); |
| 26 | void MountSaveData(Kernel::HLERequestContext& ctx); | 26 | void MountSaveData(Kernel::HLERequestContext& ctx); |
| 27 | void OpenReadOnlySaveDataFileSystem(Kernel::HLERequestContext& ctx); | 27 | void OpenReadOnlySaveDataFileSystem(Kernel::HLERequestContext& ctx); |
| 28 | void OpenSaveDataInfoReaderBySaveDataSpaceId(Kernel::HLERequestContext& ctx); | ||
| 28 | void GetGlobalAccessLogMode(Kernel::HLERequestContext& ctx); | 29 | void GetGlobalAccessLogMode(Kernel::HLERequestContext& ctx); |
| 29 | void OpenDataStorageByCurrentProcess(Kernel::HLERequestContext& ctx); | 30 | void OpenDataStorageByCurrentProcess(Kernel::HLERequestContext& ctx); |
| 30 | void OpenDataStorageByDataId(Kernel::HLERequestContext& ctx); | 31 | void OpenDataStorageByDataId(Kernel::HLERequestContext& ctx); |
diff --git a/src/core/hle/service/hid/controllers/npad.cpp b/src/core/hle/service/hid/controllers/npad.cpp index ff9b64be4..205e4fd14 100644 --- a/src/core/hle/service/hid/controllers/npad.cpp +++ b/src/core/hle/service/hid/controllers/npad.cpp | |||
| @@ -40,6 +40,29 @@ enum class JoystickId : std::size_t { | |||
| 40 | Joystick_Right, | 40 | Joystick_Right, |
| 41 | }; | 41 | }; |
| 42 | 42 | ||
| 43 | static std::size_t NPadIdToIndex(u32 npad_id) { | ||
| 44 | switch (npad_id) { | ||
| 45 | case 0: | ||
| 46 | case 1: | ||
| 47 | case 2: | ||
| 48 | case 3: | ||
| 49 | case 4: | ||
| 50 | case 5: | ||
| 51 | case 6: | ||
| 52 | case 7: | ||
| 53 | return npad_id; | ||
| 54 | case 8: | ||
| 55 | case NPAD_HANDHELD: | ||
| 56 | return 8; | ||
| 57 | case 9: | ||
| 58 | case NPAD_UNKNOWN: | ||
| 59 | return 9; | ||
| 60 | default: | ||
| 61 | UNIMPLEMENTED_MSG("Unknown npad id {}", npad_id); | ||
| 62 | return 0; | ||
| 63 | } | ||
| 64 | } | ||
| 65 | |||
| 43 | Controller_NPad::Controller_NPad() = default; | 66 | Controller_NPad::Controller_NPad() = default; |
| 44 | Controller_NPad::~Controller_NPad() = default; | 67 | Controller_NPad::~Controller_NPad() = default; |
| 45 | 68 | ||
| @@ -288,10 +311,11 @@ void Controller_NPad::OnUpdate(u8* data, std::size_t data_len) { | |||
| 288 | switch (controller_type) { | 311 | switch (controller_type) { |
| 289 | case NPadControllerType::Handheld: | 312 | case NPadControllerType::Handheld: |
| 290 | handheld_entry.connection_status.raw = 0; | 313 | handheld_entry.connection_status.raw = 0; |
| 291 | handheld_entry.connection_status.IsConnected.Assign(1); | 314 | handheld_entry.connection_status.IsWired.Assign(1); |
| 292 | if (!Settings::values.use_docked_mode) { | 315 | handheld_entry.connection_status.IsLeftJoyConnected.Assign(1); |
| 293 | handheld_entry.connection_status.IsWired.Assign(1); | 316 | handheld_entry.connection_status.IsRightJoyConnected.Assign(1); |
| 294 | } | 317 | handheld_entry.connection_status.IsLeftJoyWired.Assign(1); |
| 318 | handheld_entry.connection_status.IsRightJoyWired.Assign(1); | ||
| 295 | handheld_entry.pad_states.raw = pad_state.raw; | 319 | handheld_entry.pad_states.raw = pad_state.raw; |
| 296 | handheld_entry.l_stick = lstick_entry; | 320 | handheld_entry.l_stick = lstick_entry; |
| 297 | handheld_entry.r_stick = rstick_entry; | 321 | handheld_entry.r_stick = rstick_entry; |
| @@ -310,6 +334,7 @@ void Controller_NPad::OnUpdate(u8* data, std::size_t data_len) { | |||
| 310 | dual_entry.pad_states.raw = pad_state.raw; | 334 | dual_entry.pad_states.raw = pad_state.raw; |
| 311 | dual_entry.l_stick = lstick_entry; | 335 | dual_entry.l_stick = lstick_entry; |
| 312 | dual_entry.r_stick = rstick_entry; | 336 | dual_entry.r_stick = rstick_entry; |
| 337 | break; | ||
| 313 | case NPadControllerType::JoyLeft: | 338 | case NPadControllerType::JoyLeft: |
| 314 | left_entry.connection_status.raw = 0; | 339 | left_entry.connection_status.raw = 0; |
| 315 | 340 | ||
| @@ -370,16 +395,30 @@ void Controller_NPad::SetSupportedNPadIdTypes(u8* data, std::size_t length) { | |||
| 370 | supported_npad_id_types.clear(); | 395 | supported_npad_id_types.clear(); |
| 371 | supported_npad_id_types.resize(length / sizeof(u32)); | 396 | supported_npad_id_types.resize(length / sizeof(u32)); |
| 372 | std::memcpy(supported_npad_id_types.data(), data, length); | 397 | std::memcpy(supported_npad_id_types.data(), data, length); |
| 398 | bool had_controller_update = false; | ||
| 373 | for (std::size_t i = 0; i < connected_controllers.size(); i++) { | 399 | for (std::size_t i = 0; i < connected_controllers.size(); i++) { |
| 374 | auto& controller = connected_controllers[i]; | 400 | auto& controller = connected_controllers[i]; |
| 375 | if (!controller.is_connected) { | 401 | if (!controller.is_connected) { |
| 376 | continue; | 402 | continue; |
| 377 | } | 403 | } |
| 378 | if (!IsControllerSupported(PREFERRED_CONTROLLER)) { | 404 | if (!IsControllerSupported(PREFERRED_CONTROLLER)) { |
| 379 | controller.type = DecideBestController(PREFERRED_CONTROLLER); | 405 | const auto best_type = DecideBestController(PREFERRED_CONTROLLER); |
| 380 | InitNewlyAddedControler(i); | 406 | const bool is_handheld = (best_type == NPadControllerType::Handheld || |
| 407 | PREFERRED_CONTROLLER == NPadControllerType::Handheld); | ||
| 408 | if (is_handheld) { | ||
| 409 | controller.type = NPadControllerType::None; | ||
| 410 | controller.is_connected = false; | ||
| 411 | AddNewController(best_type); | ||
| 412 | } else { | ||
| 413 | controller.type = best_type; | ||
| 414 | InitNewlyAddedControler(i); | ||
| 415 | } | ||
| 416 | had_controller_update = true; | ||
| 381 | } | 417 | } |
| 382 | } | 418 | } |
| 419 | if (had_controller_update) { | ||
| 420 | styleset_changed_event->Signal(); | ||
| 421 | } | ||
| 383 | } | 422 | } |
| 384 | 423 | ||
| 385 | void Controller_NPad::GetSupportedNpadIdTypes(u32* data, std::size_t max_length) { | 424 | void Controller_NPad::GetSupportedNpadIdTypes(u32* data, std::size_t max_length) { |
| @@ -457,15 +496,11 @@ void Controller_NPad::AddNewController(NPadControllerType controller) { | |||
| 457 | } | 496 | } |
| 458 | 497 | ||
| 459 | void Controller_NPad::ConnectNPad(u32 npad_id) { | 498 | void Controller_NPad::ConnectNPad(u32 npad_id) { |
| 460 | if (npad_id >= connected_controllers.size()) | 499 | connected_controllers[NPadIdToIndex(npad_id)].is_connected = true; |
| 461 | return; | ||
| 462 | connected_controllers[npad_id].is_connected = true; | ||
| 463 | } | 500 | } |
| 464 | 501 | ||
| 465 | void Controller_NPad::DisconnectNPad(u32 npad_id) { | 502 | void Controller_NPad::DisconnectNPad(u32 npad_id) { |
| 466 | if (npad_id >= connected_controllers.size()) | 503 | connected_controllers[NPadIdToIndex(npad_id)].is_connected = false; |
| 467 | return; | ||
| 468 | connected_controllers[npad_id].is_connected = false; | ||
| 469 | } | 504 | } |
| 470 | 505 | ||
| 471 | Controller_NPad::LedPattern Controller_NPad::GetLedPattern(u32 npad_id) { | 506 | Controller_NPad::LedPattern Controller_NPad::GetLedPattern(u32 npad_id) { |
diff --git a/src/core/hle/service/hid/hid.cpp b/src/core/hle/service/hid/hid.cpp index a45fd4954..39631b14f 100644 --- a/src/core/hle/service/hid/hid.cpp +++ b/src/core/hle/service/hid/hid.cpp | |||
| @@ -286,10 +286,10 @@ public: | |||
| 286 | {519, nullptr, "GetPalmaOperationResult"}, | 286 | {519, nullptr, "GetPalmaOperationResult"}, |
| 287 | {520, nullptr, "ReadPalmaPlayLog"}, | 287 | {520, nullptr, "ReadPalmaPlayLog"}, |
| 288 | {521, nullptr, "ResetPalmaPlayLog"}, | 288 | {521, nullptr, "ResetPalmaPlayLog"}, |
| 289 | {522, nullptr, "SetIsPalmaAllConnectable"}, | 289 | {522, &Hid::SetIsPalmaAllConnectable, "SetIsPalmaAllConnectable"}, |
| 290 | {523, nullptr, "SetIsPalmaPairedConnectable"}, | 290 | {523, nullptr, "SetIsPalmaPairedConnectable"}, |
| 291 | {524, nullptr, "PairPalma"}, | 291 | {524, nullptr, "PairPalma"}, |
| 292 | {525, nullptr, "SetPalmaBoostMode"}, | 292 | {525, &Hid::SetPalmaBoostMode, "SetPalmaBoostMode"}, |
| 293 | {1000, nullptr, "SetNpadCommunicationMode"}, | 293 | {1000, nullptr, "SetNpadCommunicationMode"}, |
| 294 | {1001, nullptr, "GetNpadCommunicationMode"}, | 294 | {1001, nullptr, "GetNpadCommunicationMode"}, |
| 295 | }; | 295 | }; |
| @@ -596,6 +596,18 @@ private: | |||
| 596 | rb.Push(RESULT_SUCCESS); | 596 | rb.Push(RESULT_SUCCESS); |
| 597 | LOG_WARNING(Service_HID, "(STUBBED) called"); | 597 | LOG_WARNING(Service_HID, "(STUBBED) called"); |
| 598 | } | 598 | } |
| 599 | |||
| 600 | void SetIsPalmaAllConnectable(Kernel::HLERequestContext& ctx) { | ||
| 601 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 602 | rb.Push(RESULT_SUCCESS); | ||
| 603 | LOG_WARNING(Service_HID, "(STUBBED) called"); | ||
| 604 | } | ||
| 605 | |||
| 606 | void SetPalmaBoostMode(Kernel::HLERequestContext& ctx) { | ||
| 607 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 608 | rb.Push(RESULT_SUCCESS); | ||
| 609 | LOG_WARNING(Service_HID, "(STUBBED) called"); | ||
| 610 | } | ||
| 599 | }; | 611 | }; |
| 600 | 612 | ||
| 601 | class HidDbg final : public ServiceFramework<HidDbg> { | 613 | class HidDbg final : public ServiceFramework<HidDbg> { |
diff --git a/src/core/hle/service/nfp/nfp.cpp b/src/core/hle/service/nfp/nfp.cpp index c1af878fe..1d6e7756f 100644 --- a/src/core/hle/service/nfp/nfp.cpp +++ b/src/core/hle/service/nfp/nfp.cpp | |||
| @@ -212,7 +212,7 @@ private: | |||
| 212 | IPC::ResponseBuilder rb{ctx, 2}; | 212 | IPC::ResponseBuilder rb{ctx, 2}; |
| 213 | auto amiibo = nfp_interface.GetAmiiboBuffer(); | 213 | auto amiibo = nfp_interface.GetAmiiboBuffer(); |
| 214 | TagInfo tag_info{}; | 214 | TagInfo tag_info{}; |
| 215 | std::memcpy(tag_info.uuid.data(), amiibo.uuid.data(), sizeof(tag_info.uuid.size())); | 215 | tag_info.uuid = amiibo.uuid; |
| 216 | tag_info.uuid_length = static_cast<u8>(tag_info.uuid.size()); | 216 | tag_info.uuid_length = static_cast<u8>(tag_info.uuid.size()); |
| 217 | 217 | ||
| 218 | tag_info.protocol = 1; // TODO(ogniK): Figure out actual values | 218 | tag_info.protocol = 1; // TODO(ogniK): Figure out actual values |
diff --git a/src/core/hle/service/ns/ns.cpp b/src/core/hle/service/ns/ns.cpp index 07c1381fe..1d2978f24 100644 --- a/src/core/hle/service/ns/ns.cpp +++ b/src/core/hle/service/ns/ns.cpp | |||
| @@ -2,6 +2,9 @@ | |||
| 2 | // Licensed under GPLv2 or any later version | 2 | // Licensed under GPLv2 or any later version |
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include "common/logging/log.h" | ||
| 6 | #include "core/file_sys/control_metadata.h" | ||
| 7 | #include "core/file_sys/patch_manager.h" | ||
| 5 | #include "core/hle/ipc_helpers.h" | 8 | #include "core/hle/ipc_helpers.h" |
| 6 | #include "core/hle/kernel/hle_ipc.h" | 9 | #include "core/hle/kernel/hle_ipc.h" |
| 7 | #include "core/hle/service/ns/ns.h" | 10 | #include "core/hle/service/ns/ns.h" |
| @@ -118,7 +121,7 @@ public: | |||
| 118 | {305, nullptr, "TerminateSystemApplet"}, | 121 | {305, nullptr, "TerminateSystemApplet"}, |
| 119 | {306, nullptr, "LaunchOverlayApplet"}, | 122 | {306, nullptr, "LaunchOverlayApplet"}, |
| 120 | {307, nullptr, "TerminateOverlayApplet"}, | 123 | {307, nullptr, "TerminateOverlayApplet"}, |
| 121 | {400, nullptr, "GetApplicationControlData"}, | 124 | {400, &IApplicationManagerInterface::GetApplicationControlData, "GetApplicationControlData"}, |
| 122 | {401, nullptr, "InvalidateAllApplicationControlCache"}, | 125 | {401, nullptr, "InvalidateAllApplicationControlCache"}, |
| 123 | {402, nullptr, "RequestDownloadApplicationControlData"}, | 126 | {402, nullptr, "RequestDownloadApplicationControlData"}, |
| 124 | {403, nullptr, "GetMaxApplicationControlCacheCount"}, | 127 | {403, nullptr, "GetMaxApplicationControlCacheCount"}, |
| @@ -243,6 +246,65 @@ public: | |||
| 243 | 246 | ||
| 244 | RegisterHandlers(functions); | 247 | RegisterHandlers(functions); |
| 245 | } | 248 | } |
| 249 | |||
| 250 | void GetApplicationControlData(Kernel::HLERequestContext& ctx) { | ||
| 251 | IPC::RequestParser rp{ctx}; | ||
| 252 | const auto flag = rp.PopRaw<u64>(); | ||
| 253 | LOG_DEBUG(Service_NS, "called with flag={:016X}", flag); | ||
| 254 | |||
| 255 | const auto title_id = rp.PopRaw<u64>(); | ||
| 256 | |||
| 257 | const auto size = ctx.GetWriteBufferSize(); | ||
| 258 | |||
| 259 | const FileSys::PatchManager pm{title_id}; | ||
| 260 | const auto control = pm.GetControlMetadata(); | ||
| 261 | |||
| 262 | std::vector<u8> out; | ||
| 263 | |||
| 264 | if (control.first != nullptr) { | ||
| 265 | if (size < 0x4000) { | ||
| 266 | LOG_ERROR(Service_NS, | ||
| 267 | "output buffer is too small! (actual={:016X}, expected_min=0x4000)", | ||
| 268 | size); | ||
| 269 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 270 | // TODO(DarkLordZach): Find a better error code for this. | ||
| 271 | rb.Push(ResultCode(-1)); | ||
| 272 | return; | ||
| 273 | } | ||
| 274 | |||
| 275 | out.resize(0x4000); | ||
| 276 | const auto bytes = control.first->GetRawBytes(); | ||
| 277 | std::memcpy(out.data(), bytes.data(), bytes.size()); | ||
| 278 | } else { | ||
| 279 | LOG_WARNING(Service_NS, "missing NACP data for title_id={:016X}, defaulting to zeros.", | ||
| 280 | title_id); | ||
| 281 | out.resize(std::min<u64>(0x4000, size)); | ||
| 282 | } | ||
| 283 | |||
| 284 | if (control.second != nullptr) { | ||
| 285 | if (size < 0x4000 + control.second->GetSize()) { | ||
| 286 | LOG_ERROR(Service_NS, | ||
| 287 | "output buffer is too small! (actual={:016X}, expected_min={:016X})", | ||
| 288 | size, 0x4000 + control.second->GetSize()); | ||
| 289 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 290 | // TODO(DarkLordZach): Find a better error code for this. | ||
| 291 | rb.Push(ResultCode(-1)); | ||
| 292 | return; | ||
| 293 | } | ||
| 294 | |||
| 295 | out.resize(0x4000 + control.second->GetSize()); | ||
| 296 | control.second->Read(out.data() + 0x4000, control.second->GetSize()); | ||
| 297 | } else { | ||
| 298 | LOG_WARNING(Service_NS, "missing icon data for title_id={:016X}, defaulting to zeros.", | ||
| 299 | title_id); | ||
| 300 | } | ||
| 301 | |||
| 302 | ctx.WriteBuffer(out); | ||
| 303 | |||
| 304 | IPC::ResponseBuilder rb{ctx, 3}; | ||
| 305 | rb.Push(RESULT_SUCCESS); | ||
| 306 | rb.Push<u32>(static_cast<u32>(out.size())); | ||
| 307 | } | ||
| 246 | }; | 308 | }; |
| 247 | 309 | ||
| 248 | class IApplicationVersionInterface final : public ServiceFramework<IApplicationVersionInterface> { | 310 | class IApplicationVersionInterface final : public ServiceFramework<IApplicationVersionInterface> { |
diff --git a/src/core/hle/service/service.cpp b/src/core/hle/service/service.cpp index a4cf45267..1ec340466 100644 --- a/src/core/hle/service/service.cpp +++ b/src/core/hle/service/service.cpp | |||
| @@ -80,8 +80,8 @@ namespace Service { | |||
| 80 | * Creates a function string for logging, complete with the name (or header code, depending | 80 | * Creates a function string for logging, complete with the name (or header code, depending |
| 81 | * on what's passed in) the port name, and all the cmd_buff arguments. | 81 | * on what's passed in) the port name, and all the cmd_buff arguments. |
| 82 | */ | 82 | */ |
| 83 | static std::string MakeFunctionString(const char* name, const char* port_name, | 83 | [[maybe_unused]] static std::string MakeFunctionString(const char* name, const char* port_name, |
| 84 | const u32* cmd_buff) { | 84 | const u32* cmd_buff) { |
| 85 | // Number of params == bits 0-5 + bits 6-11 | 85 | // Number of params == bits 0-5 + bits 6-11 |
| 86 | int num_params = (cmd_buff[0] & 0x3F) + ((cmd_buff[0] >> 6) & 0x3F); | 86 | int num_params = (cmd_buff[0] & 0x3F) + ((cmd_buff[0] >> 6) & 0x3F); |
| 87 | 87 | ||
diff --git a/src/core/hle/service/spl/module.cpp b/src/core/hle/service/spl/module.cpp index 44a6717d0..b2de2a818 100644 --- a/src/core/hle/service/spl/module.cpp +++ b/src/core/hle/service/spl/module.cpp | |||
| @@ -3,18 +3,23 @@ | |||
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include <algorithm> | 5 | #include <algorithm> |
| 6 | #include <chrono> | ||
| 6 | #include <cstdlib> | 7 | #include <cstdlib> |
| 8 | #include <ctime> | ||
| 9 | #include <functional> | ||
| 7 | #include <vector> | 10 | #include <vector> |
| 8 | #include "common/logging/log.h" | 11 | #include "common/logging/log.h" |
| 9 | #include "core/hle/ipc_helpers.h" | 12 | #include "core/hle/ipc_helpers.h" |
| 10 | #include "core/hle/service/spl/csrng.h" | 13 | #include "core/hle/service/spl/csrng.h" |
| 11 | #include "core/hle/service/spl/module.h" | 14 | #include "core/hle/service/spl/module.h" |
| 12 | #include "core/hle/service/spl/spl.h" | 15 | #include "core/hle/service/spl/spl.h" |
| 16 | #include "core/settings.h" | ||
| 13 | 17 | ||
| 14 | namespace Service::SPL { | 18 | namespace Service::SPL { |
| 15 | 19 | ||
| 16 | Module::Interface::Interface(std::shared_ptr<Module> module, const char* name) | 20 | Module::Interface::Interface(std::shared_ptr<Module> module, const char* name) |
| 17 | : ServiceFramework(name), module(std::move(module)) {} | 21 | : ServiceFramework(name), module(std::move(module)), |
| 22 | rng(Settings::values.rng_seed.value_or(std::time(nullptr))) {} | ||
| 18 | 23 | ||
| 19 | Module::Interface::~Interface() = default; | 24 | Module::Interface::~Interface() = default; |
| 20 | 25 | ||
| @@ -23,8 +28,9 @@ void Module::Interface::GetRandomBytes(Kernel::HLERequestContext& ctx) { | |||
| 23 | 28 | ||
| 24 | std::size_t size = ctx.GetWriteBufferSize(); | 29 | std::size_t size = ctx.GetWriteBufferSize(); |
| 25 | 30 | ||
| 31 | std::uniform_int_distribution<u16> distribution(0, std::numeric_limits<u8>::max()); | ||
| 26 | std::vector<u8> data(size); | 32 | std::vector<u8> data(size); |
| 27 | std::generate(data.begin(), data.end(), std::rand); | 33 | std::generate(data.begin(), data.end(), [&] { return static_cast<u8>(distribution(rng)); }); |
| 28 | 34 | ||
| 29 | ctx.WriteBuffer(data); | 35 | ctx.WriteBuffer(data); |
| 30 | 36 | ||
diff --git a/src/core/hle/service/spl/module.h b/src/core/hle/service/spl/module.h index 48fda6099..afa1f0295 100644 --- a/src/core/hle/service/spl/module.h +++ b/src/core/hle/service/spl/module.h | |||
| @@ -4,6 +4,7 @@ | |||
| 4 | 4 | ||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include <random> | ||
| 7 | #include "core/hle/service/service.h" | 8 | #include "core/hle/service/service.h" |
| 8 | 9 | ||
| 9 | namespace Service::SPL { | 10 | namespace Service::SPL { |
| @@ -19,6 +20,9 @@ public: | |||
| 19 | 20 | ||
| 20 | protected: | 21 | protected: |
| 21 | std::shared_ptr<Module> module; | 22 | std::shared_ptr<Module> module; |
| 23 | |||
| 24 | private: | ||
| 25 | std::mt19937 rng; | ||
| 22 | }; | 26 | }; |
| 23 | }; | 27 | }; |
| 24 | 28 | ||
diff --git a/src/core/hle/service/time/interface.cpp b/src/core/hle/service/time/interface.cpp index 18a5d71d5..e3cbd7004 100644 --- a/src/core/hle/service/time/interface.cpp +++ b/src/core/hle/service/time/interface.cpp | |||
| @@ -21,7 +21,7 @@ Time::Time(std::shared_ptr<Module> time, const char* name) | |||
| 21 | {102, nullptr, "GetStandardUserSystemClockInitialYear"}, | 21 | {102, nullptr, "GetStandardUserSystemClockInitialYear"}, |
| 22 | {200, nullptr, "IsStandardNetworkSystemClockAccuracySufficient"}, | 22 | {200, nullptr, "IsStandardNetworkSystemClockAccuracySufficient"}, |
| 23 | {300, nullptr, "CalculateMonotonicSystemClockBaseTimePoint"}, | 23 | {300, nullptr, "CalculateMonotonicSystemClockBaseTimePoint"}, |
| 24 | {400, nullptr, "GetClockSnapshot"}, | 24 | {400, &Time::GetClockSnapshot, "GetClockSnapshot"}, |
| 25 | {401, nullptr, "GetClockSnapshotFromSystemClockContext"}, | 25 | {401, nullptr, "GetClockSnapshotFromSystemClockContext"}, |
| 26 | {500, nullptr, "CalculateStandardUserSystemClockDifferenceByUser"}, | 26 | {500, nullptr, "CalculateStandardUserSystemClockDifferenceByUser"}, |
| 27 | {501, nullptr, "CalculateSpanBetween"}, | 27 | {501, nullptr, "CalculateSpanBetween"}, |
diff --git a/src/core/hle/service/time/time.cpp b/src/core/hle/service/time/time.cpp index 28fd8debc..85e7b1195 100644 --- a/src/core/hle/service/time/time.cpp +++ b/src/core/hle/service/time/time.cpp | |||
| @@ -15,6 +15,44 @@ | |||
| 15 | 15 | ||
| 16 | namespace Service::Time { | 16 | namespace Service::Time { |
| 17 | 17 | ||
| 18 | static void PosixToCalendar(u64 posix_time, CalendarTime& calendar_time, | ||
| 19 | CalendarAdditionalInfo& additional_info, | ||
| 20 | [[maybe_unused]] const TimeZoneRule& /*rule*/) { | ||
| 21 | const std::time_t time(posix_time); | ||
| 22 | const std::tm* tm = std::localtime(&time); | ||
| 23 | if (tm == nullptr) { | ||
| 24 | calendar_time = {}; | ||
| 25 | additional_info = {}; | ||
| 26 | return; | ||
| 27 | } | ||
| 28 | calendar_time.year = tm->tm_year + 1900; | ||
| 29 | calendar_time.month = tm->tm_mon + 1; | ||
| 30 | calendar_time.day = tm->tm_mday; | ||
| 31 | calendar_time.hour = tm->tm_hour; | ||
| 32 | calendar_time.minute = tm->tm_min; | ||
| 33 | calendar_time.second = tm->tm_sec; | ||
| 34 | |||
| 35 | additional_info.day_of_week = tm->tm_wday; | ||
| 36 | additional_info.day_of_year = tm->tm_yday; | ||
| 37 | std::memcpy(additional_info.name.data(), "UTC", sizeof("UTC")); | ||
| 38 | additional_info.utc_offset = 0; | ||
| 39 | } | ||
| 40 | |||
| 41 | static u64 CalendarToPosix(const CalendarTime& calendar_time, | ||
| 42 | [[maybe_unused]] const TimeZoneRule& /*rule*/) { | ||
| 43 | std::tm time{}; | ||
| 44 | time.tm_year = calendar_time.year - 1900; | ||
| 45 | time.tm_mon = calendar_time.month - 1; | ||
| 46 | time.tm_mday = calendar_time.day; | ||
| 47 | |||
| 48 | time.tm_hour = calendar_time.hour; | ||
| 49 | time.tm_min = calendar_time.minute; | ||
| 50 | time.tm_sec = calendar_time.second; | ||
| 51 | |||
| 52 | std::time_t epoch_time = std::mktime(&time); | ||
| 53 | return static_cast<u64>(epoch_time); | ||
| 54 | } | ||
| 55 | |||
| 18 | class ISystemClock final : public ServiceFramework<ISystemClock> { | 56 | class ISystemClock final : public ServiceFramework<ISystemClock> { |
| 19 | public: | 57 | public: |
| 20 | ISystemClock() : ServiceFramework("ISystemClock") { | 58 | ISystemClock() : ServiceFramework("ISystemClock") { |
| @@ -80,8 +118,8 @@ public: | |||
| 80 | {5, nullptr, "GetTimeZoneRuleVersion"}, | 118 | {5, nullptr, "GetTimeZoneRuleVersion"}, |
| 81 | {100, &ITimeZoneService::ToCalendarTime, "ToCalendarTime"}, | 119 | {100, &ITimeZoneService::ToCalendarTime, "ToCalendarTime"}, |
| 82 | {101, &ITimeZoneService::ToCalendarTimeWithMyRule, "ToCalendarTimeWithMyRule"}, | 120 | {101, &ITimeZoneService::ToCalendarTimeWithMyRule, "ToCalendarTimeWithMyRule"}, |
| 83 | {201, nullptr, "ToPosixTime"}, | 121 | {201, &ITimeZoneService::ToPosixTime, "ToPosixTime"}, |
| 84 | {202, nullptr, "ToPosixTimeWithMyRule"}, | 122 | {202, &ITimeZoneService::ToPosixTimeWithMyRule, "ToPosixTimeWithMyRule"}, |
| 85 | }; | 123 | }; |
| 86 | RegisterHandlers(functions); | 124 | RegisterHandlers(functions); |
| 87 | } | 125 | } |
| @@ -151,24 +189,29 @@ private: | |||
| 151 | rb.PushRaw(additional_info); | 189 | rb.PushRaw(additional_info); |
| 152 | } | 190 | } |
| 153 | 191 | ||
| 154 | void PosixToCalendar(u64 posix_time, CalendarTime& calendar_time, | 192 | void ToPosixTime(Kernel::HLERequestContext& ctx) { |
| 155 | CalendarAdditionalInfo& additional_info, const TimeZoneRule& /*rule*/) { | 193 | // TODO(ogniK): Figure out how to handle multiple times |
| 156 | std::time_t t(posix_time); | 194 | LOG_WARNING(Service_Time, "(STUBBED) called"); |
| 157 | std::tm* tm = std::localtime(&t); | 195 | IPC::RequestParser rp{ctx}; |
| 158 | if (!tm) { | 196 | auto calendar_time = rp.PopRaw<CalendarTime>(); |
| 159 | return; | 197 | auto posix_time = CalendarToPosix(calendar_time, {}); |
| 160 | } | 198 | |
| 161 | calendar_time.year = tm->tm_year + 1900; | 199 | IPC::ResponseBuilder rb{ctx, 3}; |
| 162 | calendar_time.month = tm->tm_mon + 1; | 200 | rb.Push(RESULT_SUCCESS); |
| 163 | calendar_time.day = tm->tm_mday; | 201 | rb.PushRaw<u32>(1); // Amount of times we're returning |
| 164 | calendar_time.hour = tm->tm_hour; | 202 | ctx.WriteBuffer(&posix_time, sizeof(u64)); |
| 165 | calendar_time.minute = tm->tm_min; | 203 | } |
| 166 | calendar_time.second = tm->tm_sec; | 204 | |
| 167 | 205 | void ToPosixTimeWithMyRule(Kernel::HLERequestContext& ctx) { | |
| 168 | additional_info.day_of_week = tm->tm_wday; | 206 | LOG_WARNING(Service_Time, "(STUBBED) called"); |
| 169 | additional_info.day_of_year = tm->tm_yday; | 207 | IPC::RequestParser rp{ctx}; |
| 170 | std::memcpy(additional_info.name.data(), "UTC", sizeof("UTC")); | 208 | auto calendar_time = rp.PopRaw<CalendarTime>(); |
| 171 | additional_info.utc_offset = 0; | 209 | auto posix_time = CalendarToPosix(calendar_time, {}); |
| 210 | |||
| 211 | IPC::ResponseBuilder rb{ctx, 3}; | ||
| 212 | rb.Push(RESULT_SUCCESS); | ||
| 213 | rb.PushRaw<u32>(1); // Amount of times we're returning | ||
| 214 | ctx.WriteBuffer(&posix_time, sizeof(u64)); | ||
| 172 | } | 215 | } |
| 173 | }; | 216 | }; |
| 174 | 217 | ||
| @@ -207,6 +250,55 @@ void Module::Interface::GetStandardLocalSystemClock(Kernel::HLERequestContext& c | |||
| 207 | LOG_DEBUG(Service_Time, "called"); | 250 | LOG_DEBUG(Service_Time, "called"); |
| 208 | } | 251 | } |
| 209 | 252 | ||
| 253 | void Module::Interface::GetClockSnapshot(Kernel::HLERequestContext& ctx) { | ||
| 254 | LOG_DEBUG(Service_Time, "called"); | ||
| 255 | |||
| 256 | IPC::RequestParser rp{ctx}; | ||
| 257 | auto unknown_u8 = rp.PopRaw<u8>(); | ||
| 258 | |||
| 259 | ClockSnapshot clock_snapshot{}; | ||
| 260 | |||
| 261 | const s64 time_since_epoch{std::chrono::duration_cast<std::chrono::seconds>( | ||
| 262 | std::chrono::system_clock::now().time_since_epoch()) | ||
| 263 | .count()}; | ||
| 264 | CalendarTime calendar_time{}; | ||
| 265 | const std::time_t time(time_since_epoch); | ||
| 266 | const std::tm* tm = std::localtime(&time); | ||
| 267 | if (tm == nullptr) { | ||
| 268 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 269 | rb.Push(ResultCode(-1)); // TODO(ogniK): Find appropriate error code | ||
| 270 | return; | ||
| 271 | } | ||
| 272 | SteadyClockTimePoint steady_clock_time_point{CoreTiming::cyclesToMs(CoreTiming::GetTicks()) / | ||
| 273 | 1000}; | ||
| 274 | |||
| 275 | LocationName location_name{"UTC"}; | ||
| 276 | calendar_time.year = tm->tm_year + 1900; | ||
| 277 | calendar_time.month = tm->tm_mon + 1; | ||
| 278 | calendar_time.day = tm->tm_mday; | ||
| 279 | calendar_time.hour = tm->tm_hour; | ||
| 280 | calendar_time.minute = tm->tm_min; | ||
| 281 | calendar_time.second = tm->tm_sec; | ||
| 282 | clock_snapshot.system_posix_time = time_since_epoch; | ||
| 283 | clock_snapshot.network_posix_time = time_since_epoch; | ||
| 284 | clock_snapshot.system_calendar_time = calendar_time; | ||
| 285 | clock_snapshot.network_calendar_time = calendar_time; | ||
| 286 | |||
| 287 | CalendarAdditionalInfo additional_info{}; | ||
| 288 | PosixToCalendar(time_since_epoch, calendar_time, additional_info, {}); | ||
| 289 | |||
| 290 | clock_snapshot.system_calendar_info = additional_info; | ||
| 291 | clock_snapshot.network_calendar_info = additional_info; | ||
| 292 | |||
| 293 | clock_snapshot.steady_clock_timepoint = steady_clock_time_point; | ||
| 294 | clock_snapshot.location_name = location_name; | ||
| 295 | clock_snapshot.clock_auto_adjustment_enabled = 1; | ||
| 296 | clock_snapshot.ipc_u8 = unknown_u8; | ||
| 297 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 298 | rb.Push(RESULT_SUCCESS); | ||
| 299 | ctx.WriteBuffer(&clock_snapshot, sizeof(ClockSnapshot)); | ||
| 300 | } | ||
| 301 | |||
| 210 | Module::Interface::Interface(std::shared_ptr<Module> time, const char* name) | 302 | Module::Interface::Interface(std::shared_ptr<Module> time, const char* name) |
| 211 | : ServiceFramework(name), time(std::move(time)) {} | 303 | : ServiceFramework(name), time(std::move(time)) {} |
| 212 | 304 | ||
diff --git a/src/core/hle/service/time/time.h b/src/core/hle/service/time/time.h index 5659ecad3..77871ae07 100644 --- a/src/core/hle/service/time/time.h +++ b/src/core/hle/service/time/time.h | |||
| @@ -5,6 +5,7 @@ | |||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include <array> | 7 | #include <array> |
| 8 | #include "common/common_funcs.h" | ||
| 8 | #include "core/hle/service/service.h" | 9 | #include "core/hle/service/service.h" |
| 9 | 10 | ||
| 10 | namespace Service::Time { | 11 | namespace Service::Time { |
| @@ -53,6 +54,23 @@ struct SystemClockContext { | |||
| 53 | static_assert(sizeof(SystemClockContext) == 0x20, | 54 | static_assert(sizeof(SystemClockContext) == 0x20, |
| 54 | "SystemClockContext structure has incorrect size"); | 55 | "SystemClockContext structure has incorrect size"); |
| 55 | 56 | ||
| 57 | struct ClockSnapshot { | ||
| 58 | SystemClockContext user_clock_context; | ||
| 59 | SystemClockContext network_clock_context; | ||
| 60 | s64_le system_posix_time; | ||
| 61 | s64_le network_posix_time; | ||
| 62 | CalendarTime system_calendar_time; | ||
| 63 | CalendarTime network_calendar_time; | ||
| 64 | CalendarAdditionalInfo system_calendar_info; | ||
| 65 | CalendarAdditionalInfo network_calendar_info; | ||
| 66 | SteadyClockTimePoint steady_clock_timepoint; | ||
| 67 | LocationName location_name; | ||
| 68 | u8 clock_auto_adjustment_enabled; | ||
| 69 | u8 ipc_u8; | ||
| 70 | INSERT_PADDING_BYTES(2); | ||
| 71 | }; | ||
| 72 | static_assert(sizeof(ClockSnapshot) == 0xd0, "ClockSnapshot is an invalid size"); | ||
| 73 | |||
| 56 | class Module final { | 74 | class Module final { |
| 57 | public: | 75 | public: |
| 58 | class Interface : public ServiceFramework<Interface> { | 76 | class Interface : public ServiceFramework<Interface> { |
| @@ -65,6 +83,7 @@ public: | |||
| 65 | void GetStandardSteadyClock(Kernel::HLERequestContext& ctx); | 83 | void GetStandardSteadyClock(Kernel::HLERequestContext& ctx); |
| 66 | void GetTimeZoneService(Kernel::HLERequestContext& ctx); | 84 | void GetTimeZoneService(Kernel::HLERequestContext& ctx); |
| 67 | void GetStandardLocalSystemClock(Kernel::HLERequestContext& ctx); | 85 | void GetStandardLocalSystemClock(Kernel::HLERequestContext& ctx); |
| 86 | void GetClockSnapshot(Kernel::HLERequestContext& ctx); | ||
| 68 | 87 | ||
| 69 | protected: | 88 | protected: |
| 70 | std::shared_ptr<Module> time; | 89 | std::shared_ptr<Module> time; |
diff --git a/src/core/loader/nro.cpp b/src/core/loader/nro.cpp index bc8e402a8..c8e491fec 100644 --- a/src/core/loader/nro.cpp +++ b/src/core/loader/nro.cpp | |||
| @@ -12,10 +12,12 @@ | |||
| 12 | #include "common/swap.h" | 12 | #include "common/swap.h" |
| 13 | #include "core/core.h" | 13 | #include "core/core.h" |
| 14 | #include "core/file_sys/control_metadata.h" | 14 | #include "core/file_sys/control_metadata.h" |
| 15 | #include "core/file_sys/romfs_factory.h" | ||
| 15 | #include "core/file_sys/vfs_offset.h" | 16 | #include "core/file_sys/vfs_offset.h" |
| 16 | #include "core/gdbstub/gdbstub.h" | 17 | #include "core/gdbstub/gdbstub.h" |
| 17 | #include "core/hle/kernel/process.h" | 18 | #include "core/hle/kernel/process.h" |
| 18 | #include "core/hle/kernel/vm_manager.h" | 19 | #include "core/hle/kernel/vm_manager.h" |
| 20 | #include "core/hle/service/filesystem/filesystem.h" | ||
| 19 | #include "core/loader/nro.h" | 21 | #include "core/loader/nro.h" |
| 20 | #include "core/loader/nso.h" | 22 | #include "core/loader/nso.h" |
| 21 | #include "core/memory.h" | 23 | #include "core/memory.h" |
| @@ -208,6 +210,9 @@ ResultStatus AppLoader_NRO::Load(Kernel::Process& process) { | |||
| 208 | return ResultStatus::ErrorLoadingNRO; | 210 | return ResultStatus::ErrorLoadingNRO; |
| 209 | } | 211 | } |
| 210 | 212 | ||
| 213 | if (romfs != nullptr) | ||
| 214 | Service::FileSystem::RegisterRomFS(std::make_unique<FileSys::RomFSFactory>(*this)); | ||
| 215 | |||
| 211 | process.Run(base_address, Kernel::THREADPRIO_DEFAULT, Memory::DEFAULT_STACK_SIZE); | 216 | process.Run(base_address, Kernel::THREADPRIO_DEFAULT, Memory::DEFAULT_STACK_SIZE); |
| 212 | 217 | ||
| 213 | is_loaded = true; | 218 | is_loaded = true; |
diff --git a/src/core/loader/nso.cpp b/src/core/loader/nso.cpp index 68efca5c0..aaf006309 100644 --- a/src/core/loader/nso.cpp +++ b/src/core/loader/nso.cpp | |||
| @@ -154,7 +154,7 @@ std::optional<VAddr> AppLoader_NSO::LoadModule(const FileSys::VfsFile& file, VAd | |||
| 154 | program_image.resize(image_size); | 154 | program_image.resize(image_size); |
| 155 | 155 | ||
| 156 | // Apply patches if necessary | 156 | // Apply patches if necessary |
| 157 | if (pm && pm->HasNSOPatch(nso_header.build_id)) { | 157 | if (pm && (pm->HasNSOPatch(nso_header.build_id) || Settings::values.dump_nso)) { |
| 158 | std::vector<u8> pi_header(program_image.size() + 0x100); | 158 | std::vector<u8> pi_header(program_image.size() + 0x100); |
| 159 | std::memcpy(pi_header.data(), &nso_header, sizeof(NsoHeader)); | 159 | std::memcpy(pi_header.data(), &nso_header, sizeof(NsoHeader)); |
| 160 | std::memcpy(pi_header.data() + 0x100, program_image.data(), program_image.size()); | 160 | std::memcpy(pi_header.data() + 0x100, program_image.data(), program_image.size()); |
diff --git a/src/core/settings.h b/src/core/settings.h index a8954647f..e424479f2 100644 --- a/src/core/settings.h +++ b/src/core/settings.h | |||
| @@ -6,6 +6,7 @@ | |||
| 6 | 6 | ||
| 7 | #include <array> | 7 | #include <array> |
| 8 | #include <atomic> | 8 | #include <atomic> |
| 9 | #include <optional> | ||
| 9 | #include <string> | 10 | #include <string> |
| 10 | #include "common/common_types.h" | 11 | #include "common/common_types.h" |
| 11 | 12 | ||
| @@ -114,6 +115,7 @@ struct Values { | |||
| 114 | // System | 115 | // System |
| 115 | bool use_docked_mode; | 116 | bool use_docked_mode; |
| 116 | bool enable_nfc; | 117 | bool enable_nfc; |
| 118 | std::optional<u32> rng_seed; | ||
| 117 | s32 current_user; | 119 | s32 current_user; |
| 118 | s32 language_index; | 120 | s32 language_index; |
| 119 | 121 | ||
| @@ -157,6 +159,7 @@ struct Values { | |||
| 157 | bool use_gdbstub; | 159 | bool use_gdbstub; |
| 158 | u16 gdbstub_port; | 160 | u16 gdbstub_port; |
| 159 | std::string program_args; | 161 | std::string program_args; |
| 162 | bool dump_nso; | ||
| 160 | 163 | ||
| 161 | // WebService | 164 | // WebService |
| 162 | bool enable_telemetry; | 165 | bool enable_telemetry; |
diff --git a/src/video_core/engines/maxwell_3d.cpp b/src/video_core/engines/maxwell_3d.cpp index d1777b25b..6de07ea56 100644 --- a/src/video_core/engines/maxwell_3d.cpp +++ b/src/video_core/engines/maxwell_3d.cpp | |||
| @@ -121,10 +121,8 @@ void Maxwell3D::WriteReg(u32 method, u32 value, u32 remaining_params) { | |||
| 121 | debug_context->OnEvent(Tegra::DebugContext::Event::MaxwellCommandLoaded, nullptr); | 121 | debug_context->OnEvent(Tegra::DebugContext::Event::MaxwellCommandLoaded, nullptr); |
| 122 | } | 122 | } |
| 123 | 123 | ||
| 124 | u32 old = regs.reg_array[method]; | 124 | if (regs.reg_array[method] != value) { |
| 125 | regs.reg_array[method] = value; | 125 | regs.reg_array[method] = value; |
| 126 | |||
| 127 | if (value != old) { | ||
| 128 | if (method >= MAXWELL3D_REG_INDEX(vertex_attrib_format) && | 126 | if (method >= MAXWELL3D_REG_INDEX(vertex_attrib_format) && |
| 129 | method < MAXWELL3D_REG_INDEX(vertex_attrib_format) + regs.vertex_attrib_format.size()) { | 127 | method < MAXWELL3D_REG_INDEX(vertex_attrib_format) + regs.vertex_attrib_format.size()) { |
| 130 | dirty_flags.vertex_attrib_format = true; | 128 | dirty_flags.vertex_attrib_format = true; |
diff --git a/src/video_core/rasterizer_cache.h b/src/video_core/rasterizer_cache.h index 6d41321fa..bcf0c15a4 100644 --- a/src/video_core/rasterizer_cache.h +++ b/src/video_core/rasterizer_cache.h | |||
| @@ -5,6 +5,7 @@ | |||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include <set> | 7 | #include <set> |
| 8 | #include <unordered_map> | ||
| 8 | 9 | ||
| 9 | #include <boost/icl/interval_map.hpp> | 10 | #include <boost/icl/interval_map.hpp> |
| 10 | #include <boost/range/iterator_range_core.hpp> | 11 | #include <boost/range/iterator_range_core.hpp> |
| @@ -88,29 +89,25 @@ public: | |||
| 88 | 89 | ||
| 89 | /// Invalidates everything in the cache | 90 | /// Invalidates everything in the cache |
| 90 | void InvalidateAll() { | 91 | void InvalidateAll() { |
| 91 | while (object_cache.begin() != object_cache.end()) { | 92 | while (interval_cache.begin() != interval_cache.end()) { |
| 92 | Unregister(*object_cache.begin()->second.begin()); | 93 | Unregister(*interval_cache.begin()->second.begin()); |
| 93 | } | 94 | } |
| 94 | } | 95 | } |
| 95 | 96 | ||
| 96 | protected: | 97 | protected: |
| 97 | /// Tries to get an object from the cache with the specified address | 98 | /// Tries to get an object from the cache with the specified address |
| 98 | T TryGet(VAddr addr) const { | 99 | T TryGet(VAddr addr) const { |
| 99 | const ObjectInterval interval{addr}; | 100 | const auto iter = map_cache.find(addr); |
| 100 | for (auto& pair : boost::make_iterator_range(object_cache.equal_range(interval))) { | 101 | if (iter != map_cache.end()) |
| 101 | for (auto& cached_object : pair.second) { | 102 | return iter->second; |
| 102 | if (cached_object->GetAddr() == addr) { | ||
| 103 | return cached_object; | ||
| 104 | } | ||
| 105 | } | ||
| 106 | } | ||
| 107 | return nullptr; | 103 | return nullptr; |
| 108 | } | 104 | } |
| 109 | 105 | ||
| 110 | /// Register an object into the cache | 106 | /// Register an object into the cache |
| 111 | void Register(const T& object) { | 107 | void Register(const T& object) { |
| 112 | object->SetIsRegistered(true); | 108 | object->SetIsRegistered(true); |
| 113 | object_cache.add({GetInterval(object), ObjectSet{object}}); | 109 | interval_cache.add({GetInterval(object), ObjectSet{object}}); |
| 110 | map_cache.insert({object->GetAddr(), object}); | ||
| 114 | rasterizer.UpdatePagesCachedCount(object->GetAddr(), object->GetSizeInBytes(), 1); | 111 | rasterizer.UpdatePagesCachedCount(object->GetAddr(), object->GetSizeInBytes(), 1); |
| 115 | } | 112 | } |
| 116 | 113 | ||
| @@ -118,13 +115,13 @@ protected: | |||
| 118 | void Unregister(const T& object) { | 115 | void Unregister(const T& object) { |
| 119 | object->SetIsRegistered(false); | 116 | object->SetIsRegistered(false); |
| 120 | rasterizer.UpdatePagesCachedCount(object->GetAddr(), object->GetSizeInBytes(), -1); | 117 | rasterizer.UpdatePagesCachedCount(object->GetAddr(), object->GetSizeInBytes(), -1); |
| 121 | |||
| 122 | // Only flush if use_accurate_gpu_emulation is enabled, as it incurs a performance hit | 118 | // Only flush if use_accurate_gpu_emulation is enabled, as it incurs a performance hit |
| 123 | if (Settings::values.use_accurate_gpu_emulation) { | 119 | if (Settings::values.use_accurate_gpu_emulation) { |
| 124 | FlushObject(object); | 120 | FlushObject(object); |
| 125 | } | 121 | } |
| 126 | 122 | ||
| 127 | object_cache.subtract({GetInterval(object), ObjectSet{object}}); | 123 | interval_cache.subtract({GetInterval(object), ObjectSet{object}}); |
| 124 | map_cache.erase(object->GetAddr()); | ||
| 128 | } | 125 | } |
| 129 | 126 | ||
| 130 | /// Returns a ticks counter used for tracking when cached objects were last modified | 127 | /// Returns a ticks counter used for tracking when cached objects were last modified |
| @@ -141,7 +138,7 @@ private: | |||
| 141 | 138 | ||
| 142 | std::vector<T> objects; | 139 | std::vector<T> objects; |
| 143 | const ObjectInterval interval{addr, addr + size}; | 140 | const ObjectInterval interval{addr, addr + size}; |
| 144 | for (auto& pair : boost::make_iterator_range(object_cache.equal_range(interval))) { | 141 | for (auto& pair : boost::make_iterator_range(interval_cache.equal_range(interval))) { |
| 145 | for (auto& cached_object : pair.second) { | 142 | for (auto& cached_object : pair.second) { |
| 146 | if (!cached_object) { | 143 | if (!cached_object) { |
| 147 | continue; | 144 | continue; |
| @@ -167,15 +164,17 @@ private: | |||
| 167 | } | 164 | } |
| 168 | 165 | ||
| 169 | using ObjectSet = std::set<T>; | 166 | using ObjectSet = std::set<T>; |
| 170 | using ObjectCache = boost::icl::interval_map<VAddr, ObjectSet>; | 167 | using ObjectCache = std::unordered_map<VAddr, T>; |
| 171 | using ObjectInterval = typename ObjectCache::interval_type; | 168 | using IntervalCache = boost::icl::interval_map<VAddr, ObjectSet>; |
| 169 | using ObjectInterval = typename IntervalCache::interval_type; | ||
| 172 | 170 | ||
| 173 | static auto GetInterval(const T& object) { | 171 | static auto GetInterval(const T& object) { |
| 174 | return ObjectInterval::right_open(object->GetAddr(), | 172 | return ObjectInterval::right_open(object->GetAddr(), |
| 175 | object->GetAddr() + object->GetSizeInBytes()); | 173 | object->GetAddr() + object->GetSizeInBytes()); |
| 176 | } | 174 | } |
| 177 | 175 | ||
| 178 | ObjectCache object_cache; ///< Cache of objects | 176 | ObjectCache map_cache; |
| 179 | u64 modified_ticks{}; ///< Counter of cache state ticks, used for in-order flushing | 177 | IntervalCache interval_cache; ///< Cache of objects |
| 178 | u64 modified_ticks{}; ///< Counter of cache state ticks, used for in-order flushing | ||
| 180 | VideoCore::RasterizerInterface& rasterizer; | 179 | VideoCore::RasterizerInterface& rasterizer; |
| 181 | }; | 180 | }; |
diff --git a/src/video_core/renderer_base.cpp b/src/video_core/renderer_base.cpp index 0df3725c2..1482cdb40 100644 --- a/src/video_core/renderer_base.cpp +++ b/src/video_core/renderer_base.cpp | |||
| @@ -5,7 +5,6 @@ | |||
| 5 | #include "core/frontend/emu_window.h" | 5 | #include "core/frontend/emu_window.h" |
| 6 | #include "core/settings.h" | 6 | #include "core/settings.h" |
| 7 | #include "video_core/renderer_base.h" | 7 | #include "video_core/renderer_base.h" |
| 8 | #include "video_core/renderer_opengl/gl_rasterizer.h" | ||
| 9 | 8 | ||
| 10 | namespace VideoCore { | 9 | namespace VideoCore { |
| 11 | 10 | ||
diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp index 894f4f294..b44ecfa1c 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp | |||
| @@ -314,6 +314,8 @@ static constexpr std::array<FormatTuple, VideoCore::Surface::MaxPixelFormat> tex | |||
| 314 | {GL_SRGB8_ALPHA8, GL_RGBA, GL_UNSIGNED_BYTE, ComponentType::UNorm, false}, // ASTC_2D_5X4_SRGB | 314 | {GL_SRGB8_ALPHA8, GL_RGBA, GL_UNSIGNED_BYTE, ComponentType::UNorm, false}, // ASTC_2D_5X4_SRGB |
| 315 | {GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE, ComponentType::UNorm, false}, // ASTC_2D_5X5 | 315 | {GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE, ComponentType::UNorm, false}, // ASTC_2D_5X5 |
| 316 | {GL_SRGB8_ALPHA8, GL_RGBA, GL_UNSIGNED_BYTE, ComponentType::UNorm, false}, // ASTC_2D_5X5_SRGB | 316 | {GL_SRGB8_ALPHA8, GL_RGBA, GL_UNSIGNED_BYTE, ComponentType::UNorm, false}, // ASTC_2D_5X5_SRGB |
| 317 | {GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE, ComponentType::UNorm, false}, // ASTC_2D_10X8 | ||
| 318 | {GL_SRGB8_ALPHA8, GL_RGBA, GL_UNSIGNED_BYTE, ComponentType::UNorm, false}, // ASTC_2D_10X8_SRGB | ||
| 317 | 319 | ||
| 318 | // Depth formats | 320 | // Depth formats |
| 319 | {GL_DEPTH_COMPONENT32F, GL_DEPTH_COMPONENT, GL_FLOAT, ComponentType::Float, false}, // Z32F | 321 | {GL_DEPTH_COMPONENT32F, GL_DEPTH_COMPONENT, GL_FLOAT, ComponentType::Float, false}, // Z32F |
| @@ -456,6 +458,8 @@ static constexpr GLConversionArray morton_to_gl_fns = { | |||
| 456 | MortonCopy<true, PixelFormat::ASTC_2D_5X4_SRGB>, | 458 | MortonCopy<true, PixelFormat::ASTC_2D_5X4_SRGB>, |
| 457 | MortonCopy<true, PixelFormat::ASTC_2D_5X5>, | 459 | MortonCopy<true, PixelFormat::ASTC_2D_5X5>, |
| 458 | MortonCopy<true, PixelFormat::ASTC_2D_5X5_SRGB>, | 460 | MortonCopy<true, PixelFormat::ASTC_2D_5X5_SRGB>, |
| 461 | MortonCopy<true, PixelFormat::ASTC_2D_10X8>, | ||
| 462 | MortonCopy<true, PixelFormat::ASTC_2D_10X8_SRGB>, | ||
| 459 | MortonCopy<true, PixelFormat::Z32F>, | 463 | MortonCopy<true, PixelFormat::Z32F>, |
| 460 | MortonCopy<true, PixelFormat::Z16>, | 464 | MortonCopy<true, PixelFormat::Z16>, |
| 461 | MortonCopy<true, PixelFormat::Z24S8>, | 465 | MortonCopy<true, PixelFormat::Z24S8>, |
| @@ -526,6 +530,8 @@ static constexpr GLConversionArray gl_to_morton_fns = { | |||
| 526 | nullptr, | 530 | nullptr, |
| 527 | nullptr, | 531 | nullptr, |
| 528 | nullptr, | 532 | nullptr, |
| 533 | nullptr, | ||
| 534 | nullptr, | ||
| 529 | MortonCopy<false, PixelFormat::Z32F>, | 535 | MortonCopy<false, PixelFormat::Z32F>, |
| 530 | MortonCopy<false, PixelFormat::Z16>, | 536 | MortonCopy<false, PixelFormat::Z16>, |
| 531 | MortonCopy<false, PixelFormat::Z24S8>, | 537 | MortonCopy<false, PixelFormat::Z24S8>, |
| @@ -544,8 +550,8 @@ void SwizzleFunc(const GLConversionArray& functions, const SurfaceParams& params | |||
| 544 | if (params.is_layered) { | 550 | if (params.is_layered) { |
| 545 | u64 offset = params.GetMipmapLevelOffset(mip_level); | 551 | u64 offset = params.GetMipmapLevelOffset(mip_level); |
| 546 | u64 offset_gl = 0; | 552 | u64 offset_gl = 0; |
| 547 | u64 layer_size = params.LayerMemorySize(); | 553 | const u64 layer_size = params.LayerMemorySize(); |
| 548 | u64 gl_size = params.LayerSizeGL(mip_level); | 554 | const u64 gl_size = params.LayerSizeGL(mip_level); |
| 549 | for (u32 i = 0; i < params.depth; i++) { | 555 | for (u32 i = 0; i < params.depth; i++) { |
| 550 | functions[static_cast<std::size_t>(params.pixel_format)]( | 556 | functions[static_cast<std::size_t>(params.pixel_format)]( |
| 551 | params.MipWidth(mip_level), params.MipBlockHeight(mip_level), | 557 | params.MipWidth(mip_level), params.MipBlockHeight(mip_level), |
| @@ -555,7 +561,7 @@ void SwizzleFunc(const GLConversionArray& functions, const SurfaceParams& params | |||
| 555 | offset_gl += gl_size; | 561 | offset_gl += gl_size; |
| 556 | } | 562 | } |
| 557 | } else { | 563 | } else { |
| 558 | u64 offset = params.GetMipmapLevelOffset(mip_level); | 564 | const u64 offset = params.GetMipmapLevelOffset(mip_level); |
| 559 | functions[static_cast<std::size_t>(params.pixel_format)]( | 565 | functions[static_cast<std::size_t>(params.pixel_format)]( |
| 560 | params.MipWidth(mip_level), params.MipBlockHeight(mip_level), | 566 | params.MipWidth(mip_level), params.MipBlockHeight(mip_level), |
| 561 | params.MipHeight(mip_level), params.MipBlockDepth(mip_level), depth, gl_buffer.data(), | 567 | params.MipHeight(mip_level), params.MipBlockDepth(mip_level), depth, gl_buffer.data(), |
| @@ -709,18 +715,18 @@ static void FastCopySurface(const Surface& src_surface, const Surface& dst_surfa | |||
| 709 | 715 | ||
| 710 | MICROPROFILE_DEFINE(OpenGL_CopySurface, "OpenGL", "CopySurface", MP_RGB(128, 192, 64)); | 716 | MICROPROFILE_DEFINE(OpenGL_CopySurface, "OpenGL", "CopySurface", MP_RGB(128, 192, 64)); |
| 711 | static void CopySurface(const Surface& src_surface, const Surface& dst_surface, | 717 | static void CopySurface(const Surface& src_surface, const Surface& dst_surface, |
| 712 | GLuint copy_pbo_handle, GLenum src_attachment = 0, | 718 | const GLuint copy_pbo_handle, const GLenum src_attachment = 0, |
| 713 | GLenum dst_attachment = 0, std::size_t cubemap_face = 0) { | 719 | const GLenum dst_attachment = 0, const std::size_t cubemap_face = 0) { |
| 714 | MICROPROFILE_SCOPE(OpenGL_CopySurface); | 720 | MICROPROFILE_SCOPE(OpenGL_CopySurface); |
| 715 | ASSERT_MSG(dst_attachment == 0, "Unimplemented"); | 721 | ASSERT_MSG(dst_attachment == 0, "Unimplemented"); |
| 716 | 722 | ||
| 717 | const auto& src_params{src_surface->GetSurfaceParams()}; | 723 | const auto& src_params{src_surface->GetSurfaceParams()}; |
| 718 | const auto& dst_params{dst_surface->GetSurfaceParams()}; | 724 | const auto& dst_params{dst_surface->GetSurfaceParams()}; |
| 719 | 725 | ||
| 720 | auto source_format = GetFormatTuple(src_params.pixel_format, src_params.component_type); | 726 | const auto source_format = GetFormatTuple(src_params.pixel_format, src_params.component_type); |
| 721 | auto dest_format = GetFormatTuple(dst_params.pixel_format, dst_params.component_type); | 727 | const auto dest_format = GetFormatTuple(dst_params.pixel_format, dst_params.component_type); |
| 722 | 728 | ||
| 723 | std::size_t buffer_size = std::max(src_params.size_in_bytes, dst_params.size_in_bytes); | 729 | const std::size_t buffer_size = std::max(src_params.size_in_bytes, dst_params.size_in_bytes); |
| 724 | 730 | ||
| 725 | glBindBuffer(GL_PIXEL_PACK_BUFFER, copy_pbo_handle); | 731 | glBindBuffer(GL_PIXEL_PACK_BUFFER, copy_pbo_handle); |
| 726 | glBufferData(GL_PIXEL_PACK_BUFFER, buffer_size, nullptr, GL_STREAM_DRAW_ARB); | 732 | glBufferData(GL_PIXEL_PACK_BUFFER, buffer_size, nullptr, GL_STREAM_DRAW_ARB); |
| @@ -744,13 +750,10 @@ static void CopySurface(const Surface& src_surface, const Surface& dst_surface, | |||
| 744 | LOG_DEBUG(HW_GPU, "Trying to upload extra texture data from the CPU during " | 750 | LOG_DEBUG(HW_GPU, "Trying to upload extra texture data from the CPU during " |
| 745 | "reinterpretation but the texture is tiled."); | 751 | "reinterpretation but the texture is tiled."); |
| 746 | } | 752 | } |
| 747 | std::size_t remaining_size = dst_params.size_in_bytes - src_params.size_in_bytes; | 753 | const std::size_t remaining_size = dst_params.size_in_bytes - src_params.size_in_bytes; |
| 748 | std::vector<u8> data(remaining_size); | ||
| 749 | std::memcpy(data.data(), Memory::GetPointer(dst_params.addr + src_params.size_in_bytes), | ||
| 750 | data.size()); | ||
| 751 | 754 | ||
| 752 | glBufferSubData(GL_PIXEL_PACK_BUFFER, src_params.size_in_bytes, remaining_size, | 755 | glBufferSubData(GL_PIXEL_PACK_BUFFER, src_params.size_in_bytes, remaining_size, |
| 753 | data.data()); | 756 | Memory::GetPointer(dst_params.addr + src_params.size_in_bytes)); |
| 754 | } | 757 | } |
| 755 | 758 | ||
| 756 | glBindBuffer(GL_PIXEL_PACK_BUFFER, 0); | 759 | glBindBuffer(GL_PIXEL_PACK_BUFFER, 0); |
| @@ -932,7 +935,9 @@ static void ConvertFormatAsNeeded_LoadGLBuffer(std::vector<u8>& data, PixelForma | |||
| 932 | case PixelFormat::ASTC_2D_8X8_SRGB: | 935 | case PixelFormat::ASTC_2D_8X8_SRGB: |
| 933 | case PixelFormat::ASTC_2D_8X5_SRGB: | 936 | case PixelFormat::ASTC_2D_8X5_SRGB: |
| 934 | case PixelFormat::ASTC_2D_5X4_SRGB: | 937 | case PixelFormat::ASTC_2D_5X4_SRGB: |
| 935 | case PixelFormat::ASTC_2D_5X5_SRGB: { | 938 | case PixelFormat::ASTC_2D_5X5_SRGB: |
| 939 | case PixelFormat::ASTC_2D_10X8: | ||
| 940 | case PixelFormat::ASTC_2D_10X8_SRGB: { | ||
| 936 | // Convert ASTC pixel formats to RGBA8, as most desktop GPUs do not support ASTC. | 941 | // Convert ASTC pixel formats to RGBA8, as most desktop GPUs do not support ASTC. |
| 937 | u32 block_width{}; | 942 | u32 block_width{}; |
| 938 | u32 block_height{}; | 943 | u32 block_height{}; |
| @@ -967,7 +972,11 @@ static void ConvertFormatAsNeeded_FlushGLBuffer(std::vector<u8>& data, PixelForm | |||
| 967 | case PixelFormat::ASTC_2D_4X4: | 972 | case PixelFormat::ASTC_2D_4X4: |
| 968 | case PixelFormat::ASTC_2D_8X8: | 973 | case PixelFormat::ASTC_2D_8X8: |
| 969 | case PixelFormat::ASTC_2D_4X4_SRGB: | 974 | case PixelFormat::ASTC_2D_4X4_SRGB: |
| 970 | case PixelFormat::ASTC_2D_8X8_SRGB: { | 975 | case PixelFormat::ASTC_2D_8X8_SRGB: |
| 976 | case PixelFormat::ASTC_2D_5X5: | ||
| 977 | case PixelFormat::ASTC_2D_5X5_SRGB: | ||
| 978 | case PixelFormat::ASTC_2D_10X8: | ||
| 979 | case PixelFormat::ASTC_2D_10X8_SRGB: { | ||
| 971 | LOG_CRITICAL(HW_GPU, "Conversion of format {} after texture flushing is not implemented", | 980 | LOG_CRITICAL(HW_GPU, "Conversion of format {} after texture flushing is not implemented", |
| 972 | static_cast<u32>(pixel_format)); | 981 | static_cast<u32>(pixel_format)); |
| 973 | UNREACHABLE(); | 982 | UNREACHABLE(); |
| @@ -1336,6 +1345,7 @@ Surface RasterizerCacheOpenGL::RecreateSurface(const Surface& old_surface, | |||
| 1336 | break; | 1345 | break; |
| 1337 | case SurfaceTarget::TextureCubemap: | 1346 | case SurfaceTarget::TextureCubemap: |
| 1338 | case SurfaceTarget::Texture3D: | 1347 | case SurfaceTarget::Texture3D: |
| 1348 | case SurfaceTarget::Texture2DArray: | ||
| 1339 | case SurfaceTarget::TextureCubeArray: | 1349 | case SurfaceTarget::TextureCubeArray: |
| 1340 | AccurateCopySurface(old_surface, new_surface); | 1350 | AccurateCopySurface(old_surface, new_surface); |
| 1341 | break; | 1351 | break; |
diff --git a/src/video_core/renderer_opengl/gl_state.cpp b/src/video_core/renderer_opengl/gl_state.cpp index 2635f2b0c..98622a058 100644 --- a/src/video_core/renderer_opengl/gl_state.cpp +++ b/src/video_core/renderer_opengl/gl_state.cpp | |||
| @@ -266,7 +266,8 @@ void OpenGLState::ApplyViewport() const { | |||
| 266 | const auto& updated = viewports[0]; | 266 | const auto& updated = viewports[0]; |
| 267 | if (updated.x != current.x || updated.y != current.y || updated.width != current.width || | 267 | if (updated.x != current.x || updated.y != current.y || updated.width != current.width || |
| 268 | updated.height != current.height) { | 268 | updated.height != current.height) { |
| 269 | glViewport(updated.x, updated.y, updated.width, updated.height); | 269 | glViewport(static_cast<GLint>(updated.x), static_cast<GLint>(updated.y), |
| 270 | static_cast<GLsizei>(updated.width), static_cast<GLsizei>(updated.height)); | ||
| 270 | } | 271 | } |
| 271 | if (updated.depth_range_near != current.depth_range_near || | 272 | if (updated.depth_range_near != current.depth_range_near || |
| 272 | updated.depth_range_far != current.depth_range_far) { | 273 | updated.depth_range_far != current.depth_range_far) { |
| @@ -313,7 +314,7 @@ void OpenGLState::ApplyGlobalBlending() const { | |||
| 313 | } | 314 | } |
| 314 | } | 315 | } |
| 315 | 316 | ||
| 316 | void OpenGLState::ApplyTargetBlending(int target, bool force) const { | 317 | void OpenGLState::ApplyTargetBlending(std::size_t target, bool force) const { |
| 317 | const Blend& updated = blend[target]; | 318 | const Blend& updated = blend[target]; |
| 318 | const Blend& current = cur_state.blend[target]; | 319 | const Blend& current = cur_state.blend[target]; |
| 319 | const bool blend_changed = updated.enabled != current.enabled || force; | 320 | const bool blend_changed = updated.enabled != current.enabled || force; |
diff --git a/src/video_core/renderer_opengl/gl_state.h b/src/video_core/renderer_opengl/gl_state.h index eacca0b9c..e5d1baae6 100644 --- a/src/video_core/renderer_opengl/gl_state.h +++ b/src/video_core/renderer_opengl/gl_state.h | |||
| @@ -208,7 +208,7 @@ private: | |||
| 208 | void ApplyPrimitiveRestart() const; | 208 | void ApplyPrimitiveRestart() const; |
| 209 | void ApplyStencilTest() const; | 209 | void ApplyStencilTest() const; |
| 210 | void ApplyViewport() const; | 210 | void ApplyViewport() const; |
| 211 | void ApplyTargetBlending(int target, bool force) const; | 211 | void ApplyTargetBlending(std::size_t target, bool force) const; |
| 212 | void ApplyGlobalBlending() const; | 212 | void ApplyGlobalBlending() const; |
| 213 | void ApplyBlending() const; | 213 | void ApplyBlending() const; |
| 214 | void ApplyLogicOp() const; | 214 | void ApplyLogicOp() const; |
diff --git a/src/video_core/surface.cpp b/src/video_core/surface.cpp index 051ad3964..9582dd2ca 100644 --- a/src/video_core/surface.cpp +++ b/src/video_core/surface.cpp | |||
| @@ -306,6 +306,8 @@ PixelFormat PixelFormatFromTextureFormat(Tegra::Texture::TextureFormat format, | |||
| 306 | return is_srgb ? PixelFormat::ASTC_2D_8X8_SRGB : PixelFormat::ASTC_2D_8X8; | 306 | return is_srgb ? PixelFormat::ASTC_2D_8X8_SRGB : PixelFormat::ASTC_2D_8X8; |
| 307 | case Tegra::Texture::TextureFormat::ASTC_2D_8X5: | 307 | case Tegra::Texture::TextureFormat::ASTC_2D_8X5: |
| 308 | return is_srgb ? PixelFormat::ASTC_2D_8X5_SRGB : PixelFormat::ASTC_2D_8X5; | 308 | return is_srgb ? PixelFormat::ASTC_2D_8X5_SRGB : PixelFormat::ASTC_2D_8X5; |
| 309 | case Tegra::Texture::TextureFormat::ASTC_2D_10X8: | ||
| 310 | return is_srgb ? PixelFormat::ASTC_2D_10X8_SRGB : PixelFormat::ASTC_2D_10X8; | ||
| 309 | case Tegra::Texture::TextureFormat::R16_G16: | 311 | case Tegra::Texture::TextureFormat::R16_G16: |
| 310 | switch (component_type) { | 312 | switch (component_type) { |
| 311 | case Tegra::Texture::ComponentType::FLOAT: | 313 | case Tegra::Texture::ComponentType::FLOAT: |
| @@ -453,6 +455,8 @@ bool IsPixelFormatASTC(PixelFormat format) { | |||
| 453 | case PixelFormat::ASTC_2D_5X5_SRGB: | 455 | case PixelFormat::ASTC_2D_5X5_SRGB: |
| 454 | case PixelFormat::ASTC_2D_8X8_SRGB: | 456 | case PixelFormat::ASTC_2D_8X8_SRGB: |
| 455 | case PixelFormat::ASTC_2D_8X5_SRGB: | 457 | case PixelFormat::ASTC_2D_8X5_SRGB: |
| 458 | case PixelFormat::ASTC_2D_10X8: | ||
| 459 | case PixelFormat::ASTC_2D_10X8_SRGB: | ||
| 456 | return true; | 460 | return true; |
| 457 | default: | 461 | default: |
| 458 | return false; | 462 | return false; |
diff --git a/src/video_core/surface.h b/src/video_core/surface.h index dfdb8d122..0dd3eb2e4 100644 --- a/src/video_core/surface.h +++ b/src/video_core/surface.h | |||
| @@ -74,19 +74,21 @@ enum class PixelFormat { | |||
| 74 | ASTC_2D_5X4_SRGB = 56, | 74 | ASTC_2D_5X4_SRGB = 56, |
| 75 | ASTC_2D_5X5 = 57, | 75 | ASTC_2D_5X5 = 57, |
| 76 | ASTC_2D_5X5_SRGB = 58, | 76 | ASTC_2D_5X5_SRGB = 58, |
| 77 | ASTC_2D_10X8 = 59, | ||
| 78 | ASTC_2D_10X8_SRGB = 60, | ||
| 77 | 79 | ||
| 78 | MaxColorFormat, | 80 | MaxColorFormat, |
| 79 | 81 | ||
| 80 | // Depth formats | 82 | // Depth formats |
| 81 | Z32F = 59, | 83 | Z32F = 61, |
| 82 | Z16 = 60, | 84 | Z16 = 62, |
| 83 | 85 | ||
| 84 | MaxDepthFormat, | 86 | MaxDepthFormat, |
| 85 | 87 | ||
| 86 | // DepthStencil formats | 88 | // DepthStencil formats |
| 87 | Z24S8 = 61, | 89 | Z24S8 = 63, |
| 88 | S8Z24 = 62, | 90 | S8Z24 = 64, |
| 89 | Z32FS8 = 63, | 91 | Z32FS8 = 65, |
| 90 | 92 | ||
| 91 | MaxDepthStencilFormat, | 93 | MaxDepthStencilFormat, |
| 92 | 94 | ||
| @@ -193,6 +195,8 @@ static constexpr u32 GetCompressionFactor(PixelFormat format) { | |||
| 193 | 4, // ASTC_2D_5X4_SRGB | 195 | 4, // ASTC_2D_5X4_SRGB |
| 194 | 4, // ASTC_2D_5X5 | 196 | 4, // ASTC_2D_5X5 |
| 195 | 4, // ASTC_2D_5X5_SRGB | 197 | 4, // ASTC_2D_5X5_SRGB |
| 198 | 4, // ASTC_2D_10X8 | ||
| 199 | 4, // ASTC_2D_10X8_SRGB | ||
| 196 | 1, // Z32F | 200 | 1, // Z32F |
| 197 | 1, // Z16 | 201 | 1, // Z16 |
| 198 | 1, // Z24S8 | 202 | 1, // Z24S8 |
| @@ -208,70 +212,72 @@ static constexpr u32 GetDefaultBlockWidth(PixelFormat format) { | |||
| 208 | if (format == PixelFormat::Invalid) | 212 | if (format == PixelFormat::Invalid) |
| 209 | return 0; | 213 | return 0; |
| 210 | constexpr std::array<u32, MaxPixelFormat> block_width_table = {{ | 214 | constexpr std::array<u32, MaxPixelFormat> block_width_table = {{ |
| 211 | 1, // ABGR8U | 215 | 1, // ABGR8U |
| 212 | 1, // ABGR8S | 216 | 1, // ABGR8S |
| 213 | 1, // ABGR8UI | 217 | 1, // ABGR8UI |
| 214 | 1, // B5G6R5U | 218 | 1, // B5G6R5U |
| 215 | 1, // A2B10G10R10U | 219 | 1, // A2B10G10R10U |
| 216 | 1, // A1B5G5R5U | 220 | 1, // A1B5G5R5U |
| 217 | 1, // R8U | 221 | 1, // R8U |
| 218 | 1, // R8UI | 222 | 1, // R8UI |
| 219 | 1, // RGBA16F | 223 | 1, // RGBA16F |
| 220 | 1, // RGBA16U | 224 | 1, // RGBA16U |
| 221 | 1, // RGBA16UI | 225 | 1, // RGBA16UI |
| 222 | 1, // R11FG11FB10F | 226 | 1, // R11FG11FB10F |
| 223 | 1, // RGBA32UI | 227 | 1, // RGBA32UI |
| 224 | 4, // DXT1 | 228 | 4, // DXT1 |
| 225 | 4, // DXT23 | 229 | 4, // DXT23 |
| 226 | 4, // DXT45 | 230 | 4, // DXT45 |
| 227 | 4, // DXN1 | 231 | 4, // DXN1 |
| 228 | 4, // DXN2UNORM | 232 | 4, // DXN2UNORM |
| 229 | 4, // DXN2SNORM | 233 | 4, // DXN2SNORM |
| 230 | 4, // BC7U | 234 | 4, // BC7U |
| 231 | 4, // BC6H_UF16 | 235 | 4, // BC6H_UF16 |
| 232 | 4, // BC6H_SF16 | 236 | 4, // BC6H_SF16 |
| 233 | 4, // ASTC_2D_4X4 | 237 | 4, // ASTC_2D_4X4 |
| 234 | 1, // G8R8U | 238 | 1, // G8R8U |
| 235 | 1, // G8R8S | 239 | 1, // G8R8S |
| 236 | 1, // BGRA8 | 240 | 1, // BGRA8 |
| 237 | 1, // RGBA32F | 241 | 1, // RGBA32F |
| 238 | 1, // RG32F | 242 | 1, // RG32F |
| 239 | 1, // R32F | 243 | 1, // R32F |
| 240 | 1, // R16F | 244 | 1, // R16F |
| 241 | 1, // R16U | 245 | 1, // R16U |
| 242 | 1, // R16S | 246 | 1, // R16S |
| 243 | 1, // R16UI | 247 | 1, // R16UI |
| 244 | 1, // R16I | 248 | 1, // R16I |
| 245 | 1, // RG16 | 249 | 1, // RG16 |
| 246 | 1, // RG16F | 250 | 1, // RG16F |
| 247 | 1, // RG16UI | 251 | 1, // RG16UI |
| 248 | 1, // RG16I | 252 | 1, // RG16I |
| 249 | 1, // RG16S | 253 | 1, // RG16S |
| 250 | 1, // RGB32F | 254 | 1, // RGB32F |
| 251 | 1, // RGBA8_SRGB | 255 | 1, // RGBA8_SRGB |
| 252 | 1, // RG8U | 256 | 1, // RG8U |
| 253 | 1, // RG8S | 257 | 1, // RG8S |
| 254 | 1, // RG32UI | 258 | 1, // RG32UI |
| 255 | 1, // R32UI | 259 | 1, // R32UI |
| 256 | 8, // ASTC_2D_8X8 | 260 | 8, // ASTC_2D_8X8 |
| 257 | 8, // ASTC_2D_8X5 | 261 | 8, // ASTC_2D_8X5 |
| 258 | 5, // ASTC_2D_5X4 | 262 | 5, // ASTC_2D_5X4 |
| 259 | 1, // BGRA8_SRGB | 263 | 1, // BGRA8_SRGB |
| 260 | 4, // DXT1_SRGB | 264 | 4, // DXT1_SRGB |
| 261 | 4, // DXT23_SRGB | 265 | 4, // DXT23_SRGB |
| 262 | 4, // DXT45_SRGB | 266 | 4, // DXT45_SRGB |
| 263 | 4, // BC7U_SRGB | 267 | 4, // BC7U_SRGB |
| 264 | 4, // ASTC_2D_4X4_SRGB | 268 | 4, // ASTC_2D_4X4_SRGB |
| 265 | 8, // ASTC_2D_8X8_SRGB | 269 | 8, // ASTC_2D_8X8_SRGB |
| 266 | 8, // ASTC_2D_8X5_SRGB | 270 | 8, // ASTC_2D_8X5_SRGB |
| 267 | 5, // ASTC_2D_5X4_SRGB | 271 | 5, // ASTC_2D_5X4_SRGB |
| 268 | 5, // ASTC_2D_5X5 | 272 | 5, // ASTC_2D_5X5 |
| 269 | 5, // ASTC_2D_5X5_SRGB | 273 | 5, // ASTC_2D_5X5_SRGB |
| 270 | 1, // Z32F | 274 | 10, // ASTC_2D_10X8 |
| 271 | 1, // Z16 | 275 | 10, // ASTC_2D_10X8_SRGB |
| 272 | 1, // Z24S8 | 276 | 1, // Z32F |
| 273 | 1, // S8Z24 | 277 | 1, // Z16 |
| 274 | 1, // Z32FS8 | 278 | 1, // Z24S8 |
| 279 | 1, // S8Z24 | ||
| 280 | 1, // Z32FS8 | ||
| 275 | }}; | 281 | }}; |
| 276 | ASSERT(static_cast<std::size_t>(format) < block_width_table.size()); | 282 | ASSERT(static_cast<std::size_t>(format) < block_width_table.size()); |
| 277 | return block_width_table[static_cast<std::size_t>(format)]; | 283 | return block_width_table[static_cast<std::size_t>(format)]; |
| @@ -341,6 +347,8 @@ static constexpr u32 GetDefaultBlockHeight(PixelFormat format) { | |||
| 341 | 4, // ASTC_2D_5X4_SRGB | 347 | 4, // ASTC_2D_5X4_SRGB |
| 342 | 5, // ASTC_2D_5X5 | 348 | 5, // ASTC_2D_5X5 |
| 343 | 5, // ASTC_2D_5X5_SRGB | 349 | 5, // ASTC_2D_5X5_SRGB |
| 350 | 8, // ASTC_2D_10X8 | ||
| 351 | 8, // ASTC_2D_10X8_SRGB | ||
| 344 | 1, // Z32F | 352 | 1, // Z32F |
| 345 | 1, // Z16 | 353 | 1, // Z16 |
| 346 | 1, // Z24S8 | 354 | 1, // Z24S8 |
| @@ -416,6 +424,8 @@ static constexpr u32 GetFormatBpp(PixelFormat format) { | |||
| 416 | 128, // ASTC_2D_5X4_SRGB | 424 | 128, // ASTC_2D_5X4_SRGB |
| 417 | 128, // ASTC_2D_5X5 | 425 | 128, // ASTC_2D_5X5 |
| 418 | 128, // ASTC_2D_5X5_SRGB | 426 | 128, // ASTC_2D_5X5_SRGB |
| 427 | 128, // ASTC_2D_10X8 | ||
| 428 | 128, // ASTC_2D_10X8_SRGB | ||
| 419 | 32, // Z32F | 429 | 32, // Z32F |
| 420 | 16, // Z16 | 430 | 16, // Z16 |
| 421 | 32, // Z24S8 | 431 | 32, // Z24S8 |
diff --git a/src/video_core/textures/decoders.cpp b/src/video_core/textures/decoders.cpp index 3066abf61..19f30b1b5 100644 --- a/src/video_core/textures/decoders.cpp +++ b/src/video_core/textures/decoders.cpp | |||
| @@ -45,7 +45,7 @@ constexpr auto fast_swizzle_table = SwizzleTable<8, 4, 16>(); | |||
| 45 | * Instead of going gob by gob, we map the coordinates inside a block and manage from | 45 | * Instead of going gob by gob, we map the coordinates inside a block and manage from |
| 46 | * those. Block_Width is assumed to be 1. | 46 | * those. Block_Width is assumed to be 1. |
| 47 | */ | 47 | */ |
| 48 | void PreciseProcessBlock(u8* swizzled_data, u8* unswizzled_data, const bool unswizzle, | 48 | void PreciseProcessBlock(u8* const swizzled_data, u8* const unswizzled_data, const bool unswizzle, |
| 49 | const u32 x_start, const u32 y_start, const u32 z_start, const u32 x_end, | 49 | const u32 x_start, const u32 y_start, const u32 z_start, const u32 x_end, |
| 50 | const u32 y_end, const u32 z_end, const u32 tile_offset, | 50 | const u32 y_end, const u32 z_end, const u32 tile_offset, |
| 51 | const u32 xy_block_size, const u32 layer_z, const u32 stride_x, | 51 | const u32 xy_block_size, const u32 layer_z, const u32 stride_x, |
| @@ -81,7 +81,7 @@ void PreciseProcessBlock(u8* swizzled_data, u8* unswizzled_data, const bool unsw | |||
| 81 | * Instead of going gob by gob, we map the coordinates inside a block and manage from | 81 | * Instead of going gob by gob, we map the coordinates inside a block and manage from |
| 82 | * those. Block_Width is assumed to be 1. | 82 | * those. Block_Width is assumed to be 1. |
| 83 | */ | 83 | */ |
| 84 | void FastProcessBlock(u8* swizzled_data, u8* unswizzled_data, const bool unswizzle, | 84 | void FastProcessBlock(u8* const swizzled_data, u8* const unswizzled_data, const bool unswizzle, |
| 85 | const u32 x_start, const u32 y_start, const u32 z_start, const u32 x_end, | 85 | const u32 x_start, const u32 y_start, const u32 z_start, const u32 x_end, |
| 86 | const u32 y_end, const u32 z_end, const u32 tile_offset, | 86 | const u32 y_end, const u32 z_end, const u32 tile_offset, |
| 87 | const u32 xy_block_size, const u32 layer_z, const u32 stride_x, | 87 | const u32 xy_block_size, const u32 layer_z, const u32 stride_x, |
| @@ -90,10 +90,10 @@ void FastProcessBlock(u8* swizzled_data, u8* unswizzled_data, const bool unswizz | |||
| 90 | u32 z_address = tile_offset; | 90 | u32 z_address = tile_offset; |
| 91 | const u32 x_startb = x_start * bytes_per_pixel; | 91 | const u32 x_startb = x_start * bytes_per_pixel; |
| 92 | const u32 x_endb = x_end * bytes_per_pixel; | 92 | const u32 x_endb = x_end * bytes_per_pixel; |
| 93 | const u32 copy_size = 16; | 93 | constexpr u32 copy_size = 16; |
| 94 | const u32 gob_size_x = 64; | 94 | constexpr u32 gob_size_x = 64; |
| 95 | const u32 gob_size_y = 8; | 95 | constexpr u32 gob_size_y = 8; |
| 96 | const u32 gob_size_z = 1; | 96 | constexpr u32 gob_size_z = 1; |
| 97 | const u32 gob_size = gob_size_x * gob_size_y * gob_size_z; | 97 | const u32 gob_size = gob_size_x * gob_size_y * gob_size_z; |
| 98 | for (u32 z = z_start; z < z_end; z++) { | 98 | for (u32 z = z_start; z < z_end; z++) { |
| 99 | u32 y_address = z_address; | 99 | u32 y_address = z_address; |
| @@ -126,23 +126,23 @@ void FastProcessBlock(u8* swizzled_data, u8* unswizzled_data, const bool unswizz | |||
| 126 | * https://envytools.readthedocs.io/en/latest/hw/memory/g80-surface.html#blocklinear-surfaces | 126 | * https://envytools.readthedocs.io/en/latest/hw/memory/g80-surface.html#blocklinear-surfaces |
| 127 | */ | 127 | */ |
| 128 | template <bool fast> | 128 | template <bool fast> |
| 129 | void SwizzledData(u8* swizzled_data, u8* unswizzled_data, const bool unswizzle, const u32 width, | 129 | void SwizzledData(u8* const swizzled_data, u8* const unswizzled_data, const bool unswizzle, |
| 130 | const u32 height, const u32 depth, const u32 bytes_per_pixel, | 130 | const u32 width, const u32 height, const u32 depth, const u32 bytes_per_pixel, |
| 131 | const u32 out_bytes_per_pixel, const u32 block_height, const u32 block_depth) { | 131 | const u32 out_bytes_per_pixel, const u32 block_height, const u32 block_depth) { |
| 132 | auto div_ceil = [](const u32 x, const u32 y) { return ((x + y - 1) / y); }; | 132 | auto div_ceil = [](const u32 x, const u32 y) { return ((x + y - 1) / y); }; |
| 133 | const u32 stride_x = width * out_bytes_per_pixel; | 133 | const u32 stride_x = width * out_bytes_per_pixel; |
| 134 | const u32 layer_z = height * stride_x; | 134 | const u32 layer_z = height * stride_x; |
| 135 | const u32 gob_x_bytes = 64; | 135 | constexpr u32 gob_x_bytes = 64; |
| 136 | const u32 gob_elements_x = gob_x_bytes / bytes_per_pixel; | 136 | const u32 gob_elements_x = gob_x_bytes / bytes_per_pixel; |
| 137 | const u32 gob_elements_y = 8; | 137 | constexpr u32 gob_elements_y = 8; |
| 138 | const u32 gob_elements_z = 1; | 138 | constexpr u32 gob_elements_z = 1; |
| 139 | const u32 block_x_elements = gob_elements_x; | 139 | const u32 block_x_elements = gob_elements_x; |
| 140 | const u32 block_y_elements = gob_elements_y * block_height; | 140 | const u32 block_y_elements = gob_elements_y * block_height; |
| 141 | const u32 block_z_elements = gob_elements_z * block_depth; | 141 | const u32 block_z_elements = gob_elements_z * block_depth; |
| 142 | const u32 blocks_on_x = div_ceil(width, block_x_elements); | 142 | const u32 blocks_on_x = div_ceil(width, block_x_elements); |
| 143 | const u32 blocks_on_y = div_ceil(height, block_y_elements); | 143 | const u32 blocks_on_y = div_ceil(height, block_y_elements); |
| 144 | const u32 blocks_on_z = div_ceil(depth, block_z_elements); | 144 | const u32 blocks_on_z = div_ceil(depth, block_z_elements); |
| 145 | const u32 gob_size = gob_x_bytes * gob_elements_y * gob_elements_z; | 145 | constexpr u32 gob_size = gob_x_bytes * gob_elements_y * gob_elements_z; |
| 146 | const u32 xy_block_size = gob_size * block_height; | 146 | const u32 xy_block_size = gob_size * block_height; |
| 147 | const u32 block_size = xy_block_size * block_depth; | 147 | const u32 block_size = xy_block_size * block_depth; |
| 148 | u32 tile_offset = 0; | 148 | u32 tile_offset = 0; |
| @@ -171,7 +171,7 @@ void SwizzledData(u8* swizzled_data, u8* unswizzled_data, const bool unswizzle, | |||
| 171 | } | 171 | } |
| 172 | 172 | ||
| 173 | void CopySwizzledData(u32 width, u32 height, u32 depth, u32 bytes_per_pixel, | 173 | void CopySwizzledData(u32 width, u32 height, u32 depth, u32 bytes_per_pixel, |
| 174 | u32 out_bytes_per_pixel, u8* swizzled_data, u8* unswizzled_data, | 174 | u32 out_bytes_per_pixel, u8* const swizzled_data, u8* const unswizzled_data, |
| 175 | bool unswizzle, u32 block_height, u32 block_depth) { | 175 | bool unswizzle, u32 block_height, u32 block_depth) { |
| 176 | if (bytes_per_pixel % 3 != 0 && (width * bytes_per_pixel) % 16 == 0) { | 176 | if (bytes_per_pixel % 3 != 0 && (width * bytes_per_pixel) % 16 == 0) { |
| 177 | SwizzledData<true>(swizzled_data, unswizzled_data, unswizzle, width, height, depth, | 177 | SwizzledData<true>(swizzled_data, unswizzled_data, unswizzle, width, height, depth, |
| @@ -202,6 +202,8 @@ u32 BytesPerPixel(TextureFormat format) { | |||
| 202 | case TextureFormat::ASTC_2D_5X4: | 202 | case TextureFormat::ASTC_2D_5X4: |
| 203 | case TextureFormat::ASTC_2D_8X8: | 203 | case TextureFormat::ASTC_2D_8X8: |
| 204 | case TextureFormat::ASTC_2D_8X5: | 204 | case TextureFormat::ASTC_2D_8X5: |
| 205 | case TextureFormat::ASTC_2D_10X8: | ||
| 206 | case TextureFormat::ASTC_2D_5X5: | ||
| 205 | case TextureFormat::A8R8G8B8: | 207 | case TextureFormat::A8R8G8B8: |
| 206 | case TextureFormat::A2B10G10R10: | 208 | case TextureFormat::A2B10G10R10: |
| 207 | case TextureFormat::BF10GF11RF11: | 209 | case TextureFormat::BF10GF11RF11: |
| @@ -294,6 +296,8 @@ std::vector<u8> DecodeTexture(const std::vector<u8>& texture_data, TextureFormat | |||
| 294 | case TextureFormat::BC6H_SF16: | 296 | case TextureFormat::BC6H_SF16: |
| 295 | case TextureFormat::ASTC_2D_4X4: | 297 | case TextureFormat::ASTC_2D_4X4: |
| 296 | case TextureFormat::ASTC_2D_8X8: | 298 | case TextureFormat::ASTC_2D_8X8: |
| 299 | case TextureFormat::ASTC_2D_5X5: | ||
| 300 | case TextureFormat::ASTC_2D_10X8: | ||
| 297 | case TextureFormat::A8R8G8B8: | 301 | case TextureFormat::A8R8G8B8: |
| 298 | case TextureFormat::A2B10G10R10: | 302 | case TextureFormat::A2B10G10R10: |
| 299 | case TextureFormat::A1B5G5R5: | 303 | case TextureFormat::A1B5G5R5: |
| @@ -321,9 +325,9 @@ std::vector<u8> DecodeTexture(const std::vector<u8>& texture_data, TextureFormat | |||
| 321 | std::size_t CalculateSize(bool tiled, u32 bytes_per_pixel, u32 width, u32 height, u32 depth, | 325 | std::size_t CalculateSize(bool tiled, u32 bytes_per_pixel, u32 width, u32 height, u32 depth, |
| 322 | u32 block_height, u32 block_depth) { | 326 | u32 block_height, u32 block_depth) { |
| 323 | if (tiled) { | 327 | if (tiled) { |
| 324 | const u32 gobs_in_x = 64; | 328 | constexpr u32 gobs_in_x = 64; |
| 325 | const u32 gobs_in_y = 8; | 329 | constexpr u32 gobs_in_y = 8; |
| 326 | const u32 gobs_in_z = 1; | 330 | constexpr u32 gobs_in_z = 1; |
| 327 | const u32 aligned_width = Common::AlignUp(width * bytes_per_pixel, gobs_in_x); | 331 | const u32 aligned_width = Common::AlignUp(width * bytes_per_pixel, gobs_in_x); |
| 328 | const u32 aligned_height = Common::AlignUp(height, gobs_in_y * block_height); | 332 | const u32 aligned_height = Common::AlignUp(height, gobs_in_y * block_height); |
| 329 | const u32 aligned_depth = Common::AlignUp(depth, gobs_in_z * block_depth); | 333 | const u32 aligned_depth = Common::AlignUp(depth, gobs_in_z * block_depth); |
diff --git a/src/yuzu/configuration/config.cpp b/src/yuzu/configuration/config.cpp index d4fd60a73..be69fb831 100644 --- a/src/yuzu/configuration/config.cpp +++ b/src/yuzu/configuration/config.cpp | |||
| @@ -134,6 +134,14 @@ void Config::ReadValues() { | |||
| 134 | Service::Account::MAX_USERS - 1); | 134 | Service::Account::MAX_USERS - 1); |
| 135 | 135 | ||
| 136 | Settings::values.language_index = qt_config->value("language_index", 1).toInt(); | 136 | Settings::values.language_index = qt_config->value("language_index", 1).toInt(); |
| 137 | |||
| 138 | const auto enabled = qt_config->value("rng_seed_enabled", false).toBool(); | ||
| 139 | if (enabled) { | ||
| 140 | Settings::values.rng_seed = qt_config->value("rng_seed", 0).toULongLong(); | ||
| 141 | } else { | ||
| 142 | Settings::values.rng_seed = std::nullopt; | ||
| 143 | } | ||
| 144 | |||
| 137 | qt_config->endGroup(); | 145 | qt_config->endGroup(); |
| 138 | 146 | ||
| 139 | qt_config->beginGroup("Miscellaneous"); | 147 | qt_config->beginGroup("Miscellaneous"); |
| @@ -145,6 +153,7 @@ void Config::ReadValues() { | |||
| 145 | Settings::values.use_gdbstub = qt_config->value("use_gdbstub", false).toBool(); | 153 | Settings::values.use_gdbstub = qt_config->value("use_gdbstub", false).toBool(); |
| 146 | Settings::values.gdbstub_port = qt_config->value("gdbstub_port", 24689).toInt(); | 154 | Settings::values.gdbstub_port = qt_config->value("gdbstub_port", 24689).toInt(); |
| 147 | Settings::values.program_args = qt_config->value("program_args", "").toString().toStdString(); | 155 | Settings::values.program_args = qt_config->value("program_args", "").toString().toStdString(); |
| 156 | Settings::values.dump_nso = qt_config->value("dump_nso", false).toBool(); | ||
| 148 | qt_config->endGroup(); | 157 | qt_config->endGroup(); |
| 149 | 158 | ||
| 150 | qt_config->beginGroup("WebService"); | 159 | qt_config->beginGroup("WebService"); |
| @@ -162,6 +171,7 @@ void Config::ReadValues() { | |||
| 162 | 171 | ||
| 163 | qt_config->beginGroup("UIGameList"); | 172 | qt_config->beginGroup("UIGameList"); |
| 164 | UISettings::values.show_unknown = qt_config->value("show_unknown", true).toBool(); | 173 | UISettings::values.show_unknown = qt_config->value("show_unknown", true).toBool(); |
| 174 | UISettings::values.show_add_ons = qt_config->value("show_add_ons", true).toBool(); | ||
| 165 | UISettings::values.icon_size = qt_config->value("icon_size", 64).toUInt(); | 175 | UISettings::values.icon_size = qt_config->value("icon_size", 64).toUInt(); |
| 166 | UISettings::values.row_1_text_id = qt_config->value("row_1_text_id", 3).toUInt(); | 176 | UISettings::values.row_1_text_id = qt_config->value("row_1_text_id", 3).toUInt(); |
| 167 | UISettings::values.row_2_text_id = qt_config->value("row_2_text_id", 2).toUInt(); | 177 | UISettings::values.row_2_text_id = qt_config->value("row_2_text_id", 2).toUInt(); |
| @@ -272,6 +282,10 @@ void Config::SaveValues() { | |||
| 272 | qt_config->setValue("current_user", Settings::values.current_user); | 282 | qt_config->setValue("current_user", Settings::values.current_user); |
| 273 | 283 | ||
| 274 | qt_config->setValue("language_index", Settings::values.language_index); | 284 | qt_config->setValue("language_index", Settings::values.language_index); |
| 285 | |||
| 286 | qt_config->setValue("rng_seed_enabled", Settings::values.rng_seed.has_value()); | ||
| 287 | qt_config->setValue("rng_seed", Settings::values.rng_seed.value_or(0)); | ||
| 288 | |||
| 275 | qt_config->endGroup(); | 289 | qt_config->endGroup(); |
| 276 | 290 | ||
| 277 | qt_config->beginGroup("Miscellaneous"); | 291 | qt_config->beginGroup("Miscellaneous"); |
| @@ -283,6 +297,7 @@ void Config::SaveValues() { | |||
| 283 | qt_config->setValue("use_gdbstub", Settings::values.use_gdbstub); | 297 | qt_config->setValue("use_gdbstub", Settings::values.use_gdbstub); |
| 284 | qt_config->setValue("gdbstub_port", Settings::values.gdbstub_port); | 298 | qt_config->setValue("gdbstub_port", Settings::values.gdbstub_port); |
| 285 | qt_config->setValue("program_args", QString::fromStdString(Settings::values.program_args)); | 299 | qt_config->setValue("program_args", QString::fromStdString(Settings::values.program_args)); |
| 300 | qt_config->setValue("dump_nso", Settings::values.dump_nso); | ||
| 286 | qt_config->endGroup(); | 301 | qt_config->endGroup(); |
| 287 | 302 | ||
| 288 | qt_config->beginGroup("WebService"); | 303 | qt_config->beginGroup("WebService"); |
| @@ -298,6 +313,7 @@ void Config::SaveValues() { | |||
| 298 | 313 | ||
| 299 | qt_config->beginGroup("UIGameList"); | 314 | qt_config->beginGroup("UIGameList"); |
| 300 | qt_config->setValue("show_unknown", UISettings::values.show_unknown); | 315 | qt_config->setValue("show_unknown", UISettings::values.show_unknown); |
| 316 | qt_config->setValue("show_add_ons", UISettings::values.show_add_ons); | ||
| 301 | qt_config->setValue("icon_size", UISettings::values.icon_size); | 317 | qt_config->setValue("icon_size", UISettings::values.icon_size); |
| 302 | qt_config->setValue("row_1_text_id", UISettings::values.row_1_text_id); | 318 | qt_config->setValue("row_1_text_id", UISettings::values.row_1_text_id); |
| 303 | qt_config->setValue("row_2_text_id", UISettings::values.row_2_text_id); | 319 | qt_config->setValue("row_2_text_id", UISettings::values.row_2_text_id); |
diff --git a/src/yuzu/configuration/configure_debug.cpp b/src/yuzu/configuration/configure_debug.cpp index 9e765fc93..fd5876b41 100644 --- a/src/yuzu/configuration/configure_debug.cpp +++ b/src/yuzu/configuration/configure_debug.cpp | |||
| @@ -34,6 +34,7 @@ void ConfigureDebug::setConfiguration() { | |||
| 34 | ui->toggle_console->setChecked(UISettings::values.show_console); | 34 | ui->toggle_console->setChecked(UISettings::values.show_console); |
| 35 | ui->log_filter_edit->setText(QString::fromStdString(Settings::values.log_filter)); | 35 | ui->log_filter_edit->setText(QString::fromStdString(Settings::values.log_filter)); |
| 36 | ui->homebrew_args_edit->setText(QString::fromStdString(Settings::values.program_args)); | 36 | ui->homebrew_args_edit->setText(QString::fromStdString(Settings::values.program_args)); |
| 37 | ui->dump_decompressed_nso->setChecked(Settings::values.dump_nso); | ||
| 37 | } | 38 | } |
| 38 | 39 | ||
| 39 | void ConfigureDebug::applyConfiguration() { | 40 | void ConfigureDebug::applyConfiguration() { |
| @@ -42,6 +43,7 @@ void ConfigureDebug::applyConfiguration() { | |||
| 42 | UISettings::values.show_console = ui->toggle_console->isChecked(); | 43 | UISettings::values.show_console = ui->toggle_console->isChecked(); |
| 43 | Settings::values.log_filter = ui->log_filter_edit->text().toStdString(); | 44 | Settings::values.log_filter = ui->log_filter_edit->text().toStdString(); |
| 44 | Settings::values.program_args = ui->homebrew_args_edit->text().toStdString(); | 45 | Settings::values.program_args = ui->homebrew_args_edit->text().toStdString(); |
| 46 | Settings::values.dump_nso = ui->dump_decompressed_nso->isChecked(); | ||
| 45 | Debugger::ToggleConsole(); | 47 | Debugger::ToggleConsole(); |
| 46 | Log::Filter filter; | 48 | Log::Filter filter; |
| 47 | filter.ParseFilterString(Settings::values.log_filter); | 49 | filter.ParseFilterString(Settings::values.log_filter); |
diff --git a/src/yuzu/configuration/configure_debug.ui b/src/yuzu/configuration/configure_debug.ui index ff4987604..9c5b702f8 100644 --- a/src/yuzu/configuration/configure_debug.ui +++ b/src/yuzu/configuration/configure_debug.ui | |||
| @@ -7,7 +7,7 @@ | |||
| 7 | <x>0</x> | 7 | <x>0</x> |
| 8 | <y>0</y> | 8 | <y>0</y> |
| 9 | <width>400</width> | 9 | <width>400</width> |
| 10 | <height>300</height> | 10 | <height>357</height> |
| 11 | </rect> | 11 | </rect> |
| 12 | </property> | 12 | </property> |
| 13 | <property name="windowTitle"> | 13 | <property name="windowTitle"> |
| @@ -130,6 +130,25 @@ | |||
| 130 | </widget> | 130 | </widget> |
| 131 | </item> | 131 | </item> |
| 132 | <item> | 132 | <item> |
| 133 | <widget class="QGroupBox" name="groupBox_4"> | ||
| 134 | <property name="title"> | ||
| 135 | <string>Dump</string> | ||
| 136 | </property> | ||
| 137 | <layout class="QVBoxLayout" name="verticalLayout_4"> | ||
| 138 | <item> | ||
| 139 | <widget class="QCheckBox" name="dump_decompressed_nso"> | ||
| 140 | <property name="whatsThis"> | ||
| 141 | <string>When checked, any NSO yuzu tries to load or patch will be copied decompressed to the yuzu/dump directory.</string> | ||
| 142 | </property> | ||
| 143 | <property name="text"> | ||
| 144 | <string>Dump Decompressed NSOs</string> | ||
| 145 | </property> | ||
| 146 | </widget> | ||
| 147 | </item> | ||
| 148 | </layout> | ||
| 149 | </widget> | ||
| 150 | </item> | ||
| 151 | <item> | ||
| 133 | <spacer name="verticalSpacer"> | 152 | <spacer name="verticalSpacer"> |
| 134 | <property name="orientation"> | 153 | <property name="orientation"> |
| 135 | <enum>Qt::Vertical</enum> | 154 | <enum>Qt::Vertical</enum> |
diff --git a/src/yuzu/configuration/configure_gamelist.cpp b/src/yuzu/configuration/configure_gamelist.cpp index 8743ce982..639d5df0f 100644 --- a/src/yuzu/configuration/configure_gamelist.cpp +++ b/src/yuzu/configuration/configure_gamelist.cpp | |||
| @@ -42,6 +42,7 @@ ConfigureGameList::~ConfigureGameList() = default; | |||
| 42 | 42 | ||
| 43 | void ConfigureGameList::applyConfiguration() { | 43 | void ConfigureGameList::applyConfiguration() { |
| 44 | UISettings::values.show_unknown = ui->show_unknown->isChecked(); | 44 | UISettings::values.show_unknown = ui->show_unknown->isChecked(); |
| 45 | UISettings::values.show_add_ons = ui->show_add_ons->isChecked(); | ||
| 45 | UISettings::values.icon_size = ui->icon_size_combobox->currentData().toUInt(); | 46 | UISettings::values.icon_size = ui->icon_size_combobox->currentData().toUInt(); |
| 46 | UISettings::values.row_1_text_id = ui->row_1_text_combobox->currentData().toUInt(); | 47 | UISettings::values.row_1_text_id = ui->row_1_text_combobox->currentData().toUInt(); |
| 47 | UISettings::values.row_2_text_id = ui->row_2_text_combobox->currentData().toUInt(); | 48 | UISettings::values.row_2_text_id = ui->row_2_text_combobox->currentData().toUInt(); |
| @@ -50,6 +51,7 @@ void ConfigureGameList::applyConfiguration() { | |||
| 50 | 51 | ||
| 51 | void ConfigureGameList::setConfiguration() { | 52 | void ConfigureGameList::setConfiguration() { |
| 52 | ui->show_unknown->setChecked(UISettings::values.show_unknown); | 53 | ui->show_unknown->setChecked(UISettings::values.show_unknown); |
| 54 | ui->show_add_ons->setChecked(UISettings::values.show_add_ons); | ||
| 53 | ui->icon_size_combobox->setCurrentIndex( | 55 | ui->icon_size_combobox->setCurrentIndex( |
| 54 | ui->icon_size_combobox->findData(UISettings::values.icon_size)); | 56 | ui->icon_size_combobox->findData(UISettings::values.icon_size)); |
| 55 | ui->row_1_text_combobox->setCurrentIndex( | 57 | ui->row_1_text_combobox->setCurrentIndex( |
diff --git a/src/yuzu/configuration/configure_gamelist.ui b/src/yuzu/configuration/configure_gamelist.ui index 7471fdb60..7a69377e7 100644 --- a/src/yuzu/configuration/configure_gamelist.ui +++ b/src/yuzu/configuration/configure_gamelist.ui | |||
| @@ -1,126 +1,133 @@ | |||
| 1 | <?xml version="1.0" encoding="UTF-8"?> | 1 | <?xml version="1.0" encoding="UTF-8"?> |
| 2 | <ui version="4.0"> | 2 | <ui version="4.0"> |
| 3 | <class>ConfigureGameList</class> | 3 | <class>ConfigureGameList</class> |
| 4 | <widget class="QWidget" name="ConfigureGeneral"> | 4 | <widget class="QWidget" name="ConfigureGameList"> |
| 5 | <property name="geometry"> | 5 | <property name="geometry"> |
| 6 | <rect> | 6 | <rect> |
| 7 | <x>0</x> | 7 | <x>0</x> |
| 8 | <y>0</y> | 8 | <y>0</y> |
| 9 | <width>300</width> | 9 | <width>300</width> |
| 10 | <height>377</height> | 10 | <height>377</height> |
| 11 | </rect> | 11 | </rect> |
| 12 | </property> | 12 | </property> |
| 13 | <property name="windowTitle"> | 13 | <property name="windowTitle"> |
| 14 | <string>Form</string> | 14 | <string>Form</string> |
| 15 | </property> | 15 | </property> |
| 16 | <layout class="QHBoxLayout" name="HorizontalLayout"> | 16 | <layout class="QHBoxLayout" name="HorizontalLayout"> |
| 17 | <item> | 17 | <item> |
| 18 | <layout class="QVBoxLayout" name="VerticalLayout"> | 18 | <layout class="QVBoxLayout" name="VerticalLayout"> |
| 19 | <item> | ||
| 20 | <widget class="QGroupBox" name="GeneralGroupBox"> | ||
| 21 | <property name="title"> | ||
| 22 | <string>General</string> | ||
| 23 | </property> | ||
| 24 | <layout class="QHBoxLayout" name="GeneralHorizontalLayout"> | ||
| 25 | <item> | ||
| 26 | <layout class="QVBoxLayout" name="GeneralVerticalLayout"> | ||
| 19 | <item> | 27 | <item> |
| 20 | <widget class="QGroupBox" name="GeneralGroupBox"> | 28 | <widget class="QCheckBox" name="show_unknown"> |
| 21 | <property name="title"> | 29 | <property name="text"> |
| 22 | <string>General</string> | 30 | <string>Show files with type 'Unknown'</string> |
| 23 | </property> | 31 | </property> |
| 24 | <layout class="QHBoxLayout" name="GeneralHorizontalLayout"> | 32 | </widget> |
| 25 | <item> | ||
| 26 | <layout class="QVBoxLayout" name="GeneralVerticalLayout"> | ||
| 27 | <item> | ||
| 28 | <widget class="QCheckBox" name="show_unknown"> | ||
| 29 | <property name="text"> | ||
| 30 | <string>Show files with type 'Unknown'</string> | ||
| 31 | </property> | ||
| 32 | </widget> | ||
| 33 | </item> | ||
| 34 | </layout> | ||
| 35 | </item> | ||
| 36 | </layout> | ||
| 37 | </widget> | ||
| 38 | </item> | 33 | </item> |
| 39 | <item> | 34 | <item> |
| 40 | <widget class="QGroupBox" name="IconSizeGroupBox"> | 35 | <widget class="QCheckBox" name="show_add_ons"> |
| 41 | <property name="title"> | 36 | <property name="text"> |
| 42 | <string>Icon Size</string> | 37 | <string>Show Add-Ons Column</string> |
| 43 | </property> | 38 | </property> |
| 44 | <layout class="QHBoxLayout" name="icon_size_qhbox_layout"> | 39 | </widget> |
| 45 | <item> | ||
| 46 | <layout class="QVBoxLayout" name="icon_size_qvbox_layout"> | ||
| 47 | <item> | ||
| 48 | <layout class="QHBoxLayout" name="icon_size_qhbox_layout_2"> | ||
| 49 | <item> | ||
| 50 | <widget class="QLabel" name="icon_size_label"> | ||
| 51 | <property name="text"> | ||
| 52 | <string>Icon Size:</string> | ||
| 53 | </property> | ||
| 54 | </widget> | ||
| 55 | </item> | ||
| 56 | <item> | ||
| 57 | <widget class="QComboBox" name="icon_size_combobox"/> | ||
| 58 | </item> | ||
| 59 | </layout> | ||
| 60 | </item> | ||
| 61 | </layout> | ||
| 62 | </item> | ||
| 63 | </layout> | ||
| 64 | </widget> | ||
| 65 | </item> | 40 | </item> |
| 41 | </layout> | ||
| 42 | </item> | ||
| 43 | </layout> | ||
| 44 | </widget> | ||
| 45 | </item> | ||
| 46 | <item> | ||
| 47 | <widget class="QGroupBox" name="IconSizeGroupBox"> | ||
| 48 | <property name="title"> | ||
| 49 | <string>Icon Size</string> | ||
| 50 | </property> | ||
| 51 | <layout class="QHBoxLayout" name="icon_size_qhbox_layout"> | ||
| 52 | <item> | ||
| 53 | <layout class="QVBoxLayout" name="icon_size_qvbox_layout"> | ||
| 66 | <item> | 54 | <item> |
| 67 | <widget class="QGroupBox" name="RowGroupBox"> | 55 | <layout class="QHBoxLayout" name="icon_size_qhbox_layout_2"> |
| 68 | <property name="title"> | 56 | <item> |
| 69 | <string>Row Text</string> | 57 | <widget class="QLabel" name="icon_size_label"> |
| 58 | <property name="text"> | ||
| 59 | <string>Icon Size:</string> | ||
| 70 | </property> | 60 | </property> |
| 71 | <layout class="QHBoxLayout" name="RowHorizontalLayout"> | 61 | </widget> |
| 72 | <item> | 62 | </item> |
| 73 | <layout class="QVBoxLayout" name="RowVerticalLayout"> | 63 | <item> |
| 74 | <item> | 64 | <widget class="QComboBox" name="icon_size_combobox"/> |
| 75 | <layout class="QHBoxLayout" name="row_1_qhbox_layout"> | 65 | </item> |
| 76 | <item> | 66 | </layout> |
| 77 | <widget class="QLabel" name="row_1_label"> | ||
| 78 | <property name="text"> | ||
| 79 | <string>Row 1 Text:</string> | ||
| 80 | </property> | ||
| 81 | </widget> | ||
| 82 | </item> | ||
| 83 | <item> | ||
| 84 | <widget class="QComboBox" name="row_1_text_combobox"/> | ||
| 85 | </item> | ||
| 86 | </layout> | ||
| 87 | </item> | ||
| 88 | <item> | ||
| 89 | <layout class="QHBoxLayout" name="row_2_qhbox_layout"> | ||
| 90 | <item> | ||
| 91 | <widget class="QLabel" name="row_2_label"> | ||
| 92 | <property name="text"> | ||
| 93 | <string>Row 2 Text:</string> | ||
| 94 | </property> | ||
| 95 | </widget> | ||
| 96 | </item> | ||
| 97 | <item> | ||
| 98 | <widget class="QComboBox" name="row_2_text_combobox"/> | ||
| 99 | </item> | ||
| 100 | </layout> | ||
| 101 | </item> | ||
| 102 | </layout> | ||
| 103 | </item> | ||
| 104 | </layout> | ||
| 105 | </widget> | ||
| 106 | </item> | 67 | </item> |
| 68 | </layout> | ||
| 69 | </item> | ||
| 70 | </layout> | ||
| 71 | </widget> | ||
| 72 | </item> | ||
| 73 | <item> | ||
| 74 | <widget class="QGroupBox" name="RowGroupBox"> | ||
| 75 | <property name="title"> | ||
| 76 | <string>Row Text</string> | ||
| 77 | </property> | ||
| 78 | <layout class="QHBoxLayout" name="RowHorizontalLayout"> | ||
| 79 | <item> | ||
| 80 | <layout class="QVBoxLayout" name="RowVerticalLayout"> | ||
| 107 | <item> | 81 | <item> |
| 108 | <spacer name="verticalSpacer"> | 82 | <layout class="QHBoxLayout" name="row_1_qhbox_layout"> |
| 109 | <property name="orientation"> | 83 | <item> |
| 110 | <enum>Qt::Vertical</enum> | 84 | <widget class="QLabel" name="row_1_label"> |
| 85 | <property name="text"> | ||
| 86 | <string>Row 1 Text:</string> | ||
| 111 | </property> | 87 | </property> |
| 112 | <property name="sizeHint" stdset="0"> | 88 | </widget> |
| 113 | <size> | 89 | </item> |
| 114 | <width>20</width> | 90 | <item> |
| 115 | <height>40</height> | 91 | <widget class="QComboBox" name="row_1_text_combobox"/> |
| 116 | </size> | 92 | </item> |
| 93 | </layout> | ||
| 94 | </item> | ||
| 95 | <item> | ||
| 96 | <layout class="QHBoxLayout" name="row_2_qhbox_layout"> | ||
| 97 | <item> | ||
| 98 | <widget class="QLabel" name="row_2_label"> | ||
| 99 | <property name="text"> | ||
| 100 | <string>Row 2 Text:</string> | ||
| 117 | </property> | 101 | </property> |
| 118 | </spacer> | 102 | </widget> |
| 103 | </item> | ||
| 104 | <item> | ||
| 105 | <widget class="QComboBox" name="row_2_text_combobox"/> | ||
| 106 | </item> | ||
| 107 | </layout> | ||
| 119 | </item> | 108 | </item> |
| 120 | </layout> | 109 | </layout> |
| 121 | </item> | 110 | </item> |
| 111 | </layout> | ||
| 112 | </widget> | ||
| 113 | </item> | ||
| 114 | <item> | ||
| 115 | <spacer name="verticalSpacer"> | ||
| 116 | <property name="orientation"> | ||
| 117 | <enum>Qt::Vertical</enum> | ||
| 118 | </property> | ||
| 119 | <property name="sizeHint" stdset="0"> | ||
| 120 | <size> | ||
| 121 | <width>20</width> | ||
| 122 | <height>40</height> | ||
| 123 | </size> | ||
| 124 | </property> | ||
| 125 | </spacer> | ||
| 126 | </item> | ||
| 122 | </layout> | 127 | </layout> |
| 123 | </widget> | 128 | </item> |
| 129 | </layout> | ||
| 130 | </widget> | ||
| 124 | <resources/> | 131 | <resources/> |
| 125 | <connections/> | 132 | <connections/> |
| 126 | </ui> | 133 | </ui> |
diff --git a/src/yuzu/configuration/configure_general.cpp b/src/yuzu/configuration/configure_general.cpp index b322258a0..314f51203 100644 --- a/src/yuzu/configuration/configure_general.cpp +++ b/src/yuzu/configuration/configure_general.cpp | |||
| @@ -47,6 +47,9 @@ void ConfigureGeneral::OnDockedModeChanged(bool last_state, bool new_state) { | |||
| 47 | } | 47 | } |
| 48 | 48 | ||
| 49 | Core::System& system{Core::System::GetInstance()}; | 49 | Core::System& system{Core::System::GetInstance()}; |
| 50 | if (!system.IsPoweredOn()) { | ||
| 51 | return; | ||
| 52 | } | ||
| 50 | Service::SM::ServiceManager& sm = system.ServiceManager(); | 53 | Service::SM::ServiceManager& sm = system.ServiceManager(); |
| 51 | 54 | ||
| 52 | // Message queue is shared between these services, we just need to signal an operation | 55 | // Message queue is shared between these services, we just need to signal an operation |
diff --git a/src/yuzu/configuration/configure_system.cpp b/src/yuzu/configuration/configure_system.cpp index 4803d43bb..ab5d46492 100644 --- a/src/yuzu/configuration/configure_system.cpp +++ b/src/yuzu/configuration/configure_system.cpp | |||
| @@ -137,6 +137,12 @@ ConfigureSystem::ConfigureSystem(QWidget* parent) | |||
| 137 | connect(ui->pm_remove, &QPushButton::pressed, this, &ConfigureSystem::DeleteUser); | 137 | connect(ui->pm_remove, &QPushButton::pressed, this, &ConfigureSystem::DeleteUser); |
| 138 | connect(ui->pm_set_image, &QPushButton::pressed, this, &ConfigureSystem::SetUserImage); | 138 | connect(ui->pm_set_image, &QPushButton::pressed, this, &ConfigureSystem::SetUserImage); |
| 139 | 139 | ||
| 140 | connect(ui->rng_seed_checkbox, &QCheckBox::stateChanged, this, [this](bool checked) { | ||
| 141 | ui->rng_seed_edit->setEnabled(checked); | ||
| 142 | if (!checked) | ||
| 143 | ui->rng_seed_edit->setText(QStringLiteral("00000000")); | ||
| 144 | }); | ||
| 145 | |||
| 140 | scene = new QGraphicsScene; | 146 | scene = new QGraphicsScene; |
| 141 | ui->current_user_icon->setScene(scene); | 147 | ui->current_user_icon->setScene(scene); |
| 142 | 148 | ||
| @@ -155,6 +161,13 @@ void ConfigureSystem::setConfiguration() { | |||
| 155 | 161 | ||
| 156 | PopulateUserList(); | 162 | PopulateUserList(); |
| 157 | UpdateCurrentUser(); | 163 | UpdateCurrentUser(); |
| 164 | |||
| 165 | ui->rng_seed_checkbox->setChecked(Settings::values.rng_seed.has_value()); | ||
| 166 | ui->rng_seed_edit->setEnabled(Settings::values.rng_seed.has_value()); | ||
| 167 | |||
| 168 | const auto rng_seed = | ||
| 169 | QString("%1").arg(Settings::values.rng_seed.value_or(0), 8, 16, QLatin1Char{'0'}).toUpper(); | ||
| 170 | ui->rng_seed_edit->setText(rng_seed); | ||
| 158 | } | 171 | } |
| 159 | 172 | ||
| 160 | void ConfigureSystem::PopulateUserList() { | 173 | void ConfigureSystem::PopulateUserList() { |
| @@ -195,6 +208,12 @@ void ConfigureSystem::applyConfiguration() { | |||
| 195 | return; | 208 | return; |
| 196 | 209 | ||
| 197 | Settings::values.language_index = ui->combo_language->currentIndex(); | 210 | Settings::values.language_index = ui->combo_language->currentIndex(); |
| 211 | |||
| 212 | if (ui->rng_seed_checkbox->isChecked()) | ||
| 213 | Settings::values.rng_seed = ui->rng_seed_edit->text().toULongLong(nullptr, 16); | ||
| 214 | else | ||
| 215 | Settings::values.rng_seed = std::nullopt; | ||
| 216 | |||
| 198 | Settings::Apply(); | 217 | Settings::Apply(); |
| 199 | } | 218 | } |
| 200 | 219 | ||
diff --git a/src/yuzu/configuration/configure_system.ui b/src/yuzu/configuration/configure_system.ui index 020b32a37..a91580893 100644 --- a/src/yuzu/configuration/configure_system.ui +++ b/src/yuzu/configuration/configure_system.ui | |||
| @@ -6,7 +6,7 @@ | |||
| 6 | <rect> | 6 | <rect> |
| 7 | <x>0</x> | 7 | <x>0</x> |
| 8 | <y>0</y> | 8 | <y>0</y> |
| 9 | <width>360</width> | 9 | <width>366</width> |
| 10 | <height>483</height> | 10 | <height>483</height> |
| 11 | </rect> | 11 | </rect> |
| 12 | </property> | 12 | </property> |
| @@ -22,98 +22,6 @@ | |||
| 22 | <string>System Settings</string> | 22 | <string>System Settings</string> |
| 23 | </property> | 23 | </property> |
| 24 | <layout class="QGridLayout" name="gridLayout"> | 24 | <layout class="QGridLayout" name="gridLayout"> |
| 25 | <item row="1" column="0"> | ||
| 26 | <widget class="QLabel" name="label_language"> | ||
| 27 | <property name="text"> | ||
| 28 | <string>Language</string> | ||
| 29 | </property> | ||
| 30 | </widget> | ||
| 31 | </item> | ||
| 32 | <item row="0" column="0"> | ||
| 33 | <widget class="QLabel" name="label_birthday"> | ||
| 34 | <property name="text"> | ||
| 35 | <string>Birthday</string> | ||
| 36 | </property> | ||
| 37 | </widget> | ||
| 38 | </item> | ||
| 39 | <item row="3" column="0"> | ||
| 40 | <widget class="QLabel" name="label_console_id"> | ||
| 41 | <property name="text"> | ||
| 42 | <string>Console ID:</string> | ||
| 43 | </property> | ||
| 44 | </widget> | ||
| 45 | </item> | ||
| 46 | <item row="0" column="1"> | ||
| 47 | <layout class="QHBoxLayout" name="horizontalLayout_birthday2"> | ||
| 48 | <item> | ||
| 49 | <widget class="QComboBox" name="combo_birthmonth"> | ||
| 50 | <item> | ||
| 51 | <property name="text"> | ||
| 52 | <string>January</string> | ||
| 53 | </property> | ||
| 54 | </item> | ||
| 55 | <item> | ||
| 56 | <property name="text"> | ||
| 57 | <string>February</string> | ||
| 58 | </property> | ||
| 59 | </item> | ||
| 60 | <item> | ||
| 61 | <property name="text"> | ||
| 62 | <string>March</string> | ||
| 63 | </property> | ||
| 64 | </item> | ||
| 65 | <item> | ||
| 66 | <property name="text"> | ||
| 67 | <string>April</string> | ||
| 68 | </property> | ||
| 69 | </item> | ||
| 70 | <item> | ||
| 71 | <property name="text"> | ||
| 72 | <string>May</string> | ||
| 73 | </property> | ||
| 74 | </item> | ||
| 75 | <item> | ||
| 76 | <property name="text"> | ||
| 77 | <string>June</string> | ||
| 78 | </property> | ||
| 79 | </item> | ||
| 80 | <item> | ||
| 81 | <property name="text"> | ||
| 82 | <string>July</string> | ||
| 83 | </property> | ||
| 84 | </item> | ||
| 85 | <item> | ||
| 86 | <property name="text"> | ||
| 87 | <string>August</string> | ||
| 88 | </property> | ||
| 89 | </item> | ||
| 90 | <item> | ||
| 91 | <property name="text"> | ||
| 92 | <string>September</string> | ||
| 93 | </property> | ||
| 94 | </item> | ||
| 95 | <item> | ||
| 96 | <property name="text"> | ||
| 97 | <string>October</string> | ||
| 98 | </property> | ||
| 99 | </item> | ||
| 100 | <item> | ||
| 101 | <property name="text"> | ||
| 102 | <string>November</string> | ||
| 103 | </property> | ||
| 104 | </item> | ||
| 105 | <item> | ||
| 106 | <property name="text"> | ||
| 107 | <string>December</string> | ||
| 108 | </property> | ||
| 109 | </item> | ||
| 110 | </widget> | ||
| 111 | </item> | ||
| 112 | <item> | ||
| 113 | <widget class="QComboBox" name="combo_birthday"/> | ||
| 114 | </item> | ||
| 115 | </layout> | ||
| 116 | </item> | ||
| 117 | <item row="1" column="1"> | 25 | <item row="1" column="1"> |
| 118 | <widget class="QComboBox" name="combo_language"> | 26 | <widget class="QComboBox" name="combo_language"> |
| 119 | <property name="toolTip"> | 27 | <property name="toolTip"> |
| @@ -206,6 +114,13 @@ | |||
| 206 | </item> | 114 | </item> |
| 207 | </widget> | 115 | </widget> |
| 208 | </item> | 116 | </item> |
| 117 | <item row="3" column="0"> | ||
| 118 | <widget class="QLabel" name="label_console_id"> | ||
| 119 | <property name="text"> | ||
| 120 | <string>Console ID:</string> | ||
| 121 | </property> | ||
| 122 | </widget> | ||
| 123 | </item> | ||
| 209 | <item row="2" column="0"> | 124 | <item row="2" column="0"> |
| 210 | <widget class="QLabel" name="label_sound"> | 125 | <widget class="QLabel" name="label_sound"> |
| 211 | <property name="text"> | 126 | <property name="text"> |
| @@ -213,6 +128,100 @@ | |||
| 213 | </property> | 128 | </property> |
| 214 | </widget> | 129 | </widget> |
| 215 | </item> | 130 | </item> |
| 131 | <item row="0" column="0"> | ||
| 132 | <widget class="QLabel" name="label_birthday"> | ||
| 133 | <property name="text"> | ||
| 134 | <string>Birthday</string> | ||
| 135 | </property> | ||
| 136 | </widget> | ||
| 137 | </item> | ||
| 138 | <item row="0" column="1"> | ||
| 139 | <layout class="QHBoxLayout" name="horizontalLayout_birthday2"> | ||
| 140 | <item> | ||
| 141 | <widget class="QComboBox" name="combo_birthmonth"> | ||
| 142 | <item> | ||
| 143 | <property name="text"> | ||
| 144 | <string>January</string> | ||
| 145 | </property> | ||
| 146 | </item> | ||
| 147 | <item> | ||
| 148 | <property name="text"> | ||
| 149 | <string>February</string> | ||
| 150 | </property> | ||
| 151 | </item> | ||
| 152 | <item> | ||
| 153 | <property name="text"> | ||
| 154 | <string>March</string> | ||
| 155 | </property> | ||
| 156 | </item> | ||
| 157 | <item> | ||
| 158 | <property name="text"> | ||
| 159 | <string>April</string> | ||
| 160 | </property> | ||
| 161 | </item> | ||
| 162 | <item> | ||
| 163 | <property name="text"> | ||
| 164 | <string>May</string> | ||
| 165 | </property> | ||
| 166 | </item> | ||
| 167 | <item> | ||
| 168 | <property name="text"> | ||
| 169 | <string>June</string> | ||
| 170 | </property> | ||
| 171 | </item> | ||
| 172 | <item> | ||
| 173 | <property name="text"> | ||
| 174 | <string>July</string> | ||
| 175 | </property> | ||
| 176 | </item> | ||
| 177 | <item> | ||
| 178 | <property name="text"> | ||
| 179 | <string>August</string> | ||
| 180 | </property> | ||
| 181 | </item> | ||
| 182 | <item> | ||
| 183 | <property name="text"> | ||
| 184 | <string>September</string> | ||
| 185 | </property> | ||
| 186 | </item> | ||
| 187 | <item> | ||
| 188 | <property name="text"> | ||
| 189 | <string>October</string> | ||
| 190 | </property> | ||
| 191 | </item> | ||
| 192 | <item> | ||
| 193 | <property name="text"> | ||
| 194 | <string>November</string> | ||
| 195 | </property> | ||
| 196 | </item> | ||
| 197 | <item> | ||
| 198 | <property name="text"> | ||
| 199 | <string>December</string> | ||
| 200 | </property> | ||
| 201 | </item> | ||
| 202 | </widget> | ||
| 203 | </item> | ||
| 204 | <item> | ||
| 205 | <widget class="QComboBox" name="combo_birthday"/> | ||
| 206 | </item> | ||
| 207 | </layout> | ||
| 208 | </item> | ||
| 209 | <item row="3" column="1"> | ||
| 210 | <widget class="QPushButton" name="button_regenerate_console_id"> | ||
| 211 | <property name="sizePolicy"> | ||
| 212 | <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> | ||
| 213 | <horstretch>0</horstretch> | ||
| 214 | <verstretch>0</verstretch> | ||
| 215 | </sizepolicy> | ||
| 216 | </property> | ||
| 217 | <property name="layoutDirection"> | ||
| 218 | <enum>Qt::RightToLeft</enum> | ||
| 219 | </property> | ||
| 220 | <property name="text"> | ||
| 221 | <string>Regenerate</string> | ||
| 222 | </property> | ||
| 223 | </widget> | ||
| 224 | </item> | ||
| 216 | <item row="2" column="1"> | 225 | <item row="2" column="1"> |
| 217 | <widget class="QComboBox" name="combo_sound"> | 226 | <widget class="QComboBox" name="combo_sound"> |
| 218 | <item> | 227 | <item> |
| @@ -232,19 +241,38 @@ | |||
| 232 | </item> | 241 | </item> |
| 233 | </widget> | 242 | </widget> |
| 234 | </item> | 243 | </item> |
| 235 | <item row="3" column="1"> | 244 | <item row="1" column="0"> |
| 236 | <widget class="QPushButton" name="button_regenerate_console_id"> | 245 | <widget class="QLabel" name="label_language"> |
| 246 | <property name="text"> | ||
| 247 | <string>Language</string> | ||
| 248 | </property> | ||
| 249 | </widget> | ||
| 250 | </item> | ||
| 251 | <item row="4" column="0"> | ||
| 252 | <widget class="QCheckBox" name="rng_seed_checkbox"> | ||
| 253 | <property name="text"> | ||
| 254 | <string>RNG Seed</string> | ||
| 255 | </property> | ||
| 256 | </widget> | ||
| 257 | </item> | ||
| 258 | <item row="4" column="1"> | ||
| 259 | <widget class="QLineEdit" name="rng_seed_edit"> | ||
| 237 | <property name="sizePolicy"> | 260 | <property name="sizePolicy"> |
| 238 | <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> | 261 | <sizepolicy hsizetype="Minimum" vsizetype="Fixed"> |
| 239 | <horstretch>0</horstretch> | 262 | <horstretch>0</horstretch> |
| 240 | <verstretch>0</verstretch> | 263 | <verstretch>0</verstretch> |
| 241 | </sizepolicy> | 264 | </sizepolicy> |
| 242 | </property> | 265 | </property> |
| 243 | <property name="layoutDirection"> | 266 | <property name="font"> |
| 244 | <enum>Qt::RightToLeft</enum> | 267 | <font> |
| 268 | <family>Lucida Console</family> | ||
| 269 | </font> | ||
| 245 | </property> | 270 | </property> |
| 246 | <property name="text"> | 271 | <property name="inputMask"> |
| 247 | <string>Regenerate</string> | 272 | <string notr="true">HHHHHHHH</string> |
| 273 | </property> | ||
| 274 | <property name="maxLength"> | ||
| 275 | <number>8</number> | ||
| 248 | </property> | 276 | </property> |
| 249 | </widget> | 277 | </widget> |
| 250 | </item> | 278 | </item> |
diff --git a/src/yuzu/game_list.cpp b/src/yuzu/game_list.cpp index a5a4aa432..11a8c390b 100644 --- a/src/yuzu/game_list.cpp +++ b/src/yuzu/game_list.cpp | |||
| @@ -215,12 +215,18 @@ GameList::GameList(FileSys::VirtualFilesystem vfs, GMainWindow* parent) | |||
| 215 | tree_view->setUniformRowHeights(true); | 215 | tree_view->setUniformRowHeights(true); |
| 216 | tree_view->setContextMenuPolicy(Qt::CustomContextMenu); | 216 | tree_view->setContextMenuPolicy(Qt::CustomContextMenu); |
| 217 | 217 | ||
| 218 | item_model->insertColumns(0, COLUMN_COUNT); | 218 | item_model->insertColumns(0, UISettings::values.show_add_ons ? COLUMN_COUNT : COLUMN_COUNT - 1); |
| 219 | item_model->setHeaderData(COLUMN_NAME, Qt::Horizontal, tr("Name")); | 219 | item_model->setHeaderData(COLUMN_NAME, Qt::Horizontal, tr("Name")); |
| 220 | item_model->setHeaderData(COLUMN_COMPATIBILITY, Qt::Horizontal, tr("Compatibility")); | 220 | item_model->setHeaderData(COLUMN_COMPATIBILITY, Qt::Horizontal, tr("Compatibility")); |
| 221 | item_model->setHeaderData(COLUMN_ADD_ONS, Qt::Horizontal, tr("Add-ons")); | 221 | |
| 222 | item_model->setHeaderData(COLUMN_FILE_TYPE, Qt::Horizontal, tr("File type")); | 222 | if (UISettings::values.show_add_ons) { |
| 223 | item_model->setHeaderData(COLUMN_SIZE, Qt::Horizontal, tr("Size")); | 223 | item_model->setHeaderData(COLUMN_ADD_ONS, Qt::Horizontal, tr("Add-ons")); |
| 224 | item_model->setHeaderData(COLUMN_FILE_TYPE, Qt::Horizontal, tr("File type")); | ||
| 225 | item_model->setHeaderData(COLUMN_SIZE, Qt::Horizontal, tr("Size")); | ||
| 226 | } else { | ||
| 227 | item_model->setHeaderData(COLUMN_FILE_TYPE - 1, Qt::Horizontal, tr("File type")); | ||
| 228 | item_model->setHeaderData(COLUMN_SIZE - 1, Qt::Horizontal, tr("Size")); | ||
| 229 | } | ||
| 224 | 230 | ||
| 225 | connect(tree_view, &QTreeView::activated, this, &GameList::ValidateEntry); | 231 | connect(tree_view, &QTreeView::activated, this, &GameList::ValidateEntry); |
| 226 | connect(tree_view, &QTreeView::customContextMenuRequested, this, &GameList::PopupContextMenu); | 232 | connect(tree_view, &QTreeView::customContextMenuRequested, this, &GameList::PopupContextMenu); |
| @@ -394,6 +400,25 @@ void GameList::PopulateAsync(const QString& dir_path, bool deep_scan) { | |||
| 394 | } | 400 | } |
| 395 | 401 | ||
| 396 | tree_view->setEnabled(false); | 402 | tree_view->setEnabled(false); |
| 403 | |||
| 404 | // Update the columns in case UISettings has changed | ||
| 405 | item_model->removeColumns(0, item_model->columnCount()); | ||
| 406 | item_model->insertColumns(0, UISettings::values.show_add_ons ? COLUMN_COUNT : COLUMN_COUNT - 1); | ||
| 407 | item_model->setHeaderData(COLUMN_NAME, Qt::Horizontal, tr("Name")); | ||
| 408 | item_model->setHeaderData(COLUMN_COMPATIBILITY, Qt::Horizontal, tr("Compatibility")); | ||
| 409 | |||
| 410 | if (UISettings::values.show_add_ons) { | ||
| 411 | item_model->setHeaderData(COLUMN_ADD_ONS, Qt::Horizontal, tr("Add-ons")); | ||
| 412 | item_model->setHeaderData(COLUMN_FILE_TYPE, Qt::Horizontal, tr("File type")); | ||
| 413 | item_model->setHeaderData(COLUMN_SIZE, Qt::Horizontal, tr("Size")); | ||
| 414 | } else { | ||
| 415 | item_model->setHeaderData(COLUMN_FILE_TYPE - 1, Qt::Horizontal, tr("File type")); | ||
| 416 | item_model->setHeaderData(COLUMN_SIZE - 1, Qt::Horizontal, tr("Size")); | ||
| 417 | item_model->removeColumns(COLUMN_COUNT - 1, 1); | ||
| 418 | } | ||
| 419 | |||
| 420 | LoadInterfaceLayout(); | ||
| 421 | |||
| 397 | // Delete any rows that might already exist if we're repopulating | 422 | // Delete any rows that might already exist if we're repopulating |
| 398 | item_model->removeRows(0, item_model->rowCount()); | 423 | item_model->removeRows(0, item_model->rowCount()); |
| 399 | 424 | ||
diff --git a/src/yuzu/game_list_worker.cpp b/src/yuzu/game_list_worker.cpp index 3d865a12d..362902e46 100644 --- a/src/yuzu/game_list_worker.cpp +++ b/src/yuzu/game_list_worker.cpp | |||
| @@ -123,17 +123,22 @@ void GameListWorker::AddInstalledTitlesToGameList() { | |||
| 123 | if (it != compatibility_list.end()) | 123 | if (it != compatibility_list.end()) |
| 124 | compatibility = it->second.first; | 124 | compatibility = it->second.first; |
| 125 | 125 | ||
| 126 | emit EntryReady({ | 126 | QList<QStandardItem*> list{ |
| 127 | new GameListItemPath( | 127 | new GameListItemPath( |
| 128 | FormatGameName(file->GetFullPath()), icon, QString::fromStdString(name), | 128 | FormatGameName(file->GetFullPath()), icon, QString::fromStdString(name), |
| 129 | QString::fromStdString(Loader::GetFileTypeString(loader->GetFileType())), | 129 | QString::fromStdString(Loader::GetFileTypeString(loader->GetFileType())), |
| 130 | program_id), | 130 | program_id), |
| 131 | new GameListItemCompat(compatibility), | 131 | new GameListItemCompat(compatibility), |
| 132 | new GameListItem(FormatPatchNameVersions(patch, *loader)), | ||
| 133 | new GameListItem( | 132 | new GameListItem( |
| 134 | QString::fromStdString(Loader::GetFileTypeString(loader->GetFileType()))), | 133 | QString::fromStdString(Loader::GetFileTypeString(loader->GetFileType()))), |
| 135 | new GameListItemSize(file->GetSize()), | 134 | new GameListItemSize(file->GetSize()), |
| 136 | }); | 135 | }; |
| 136 | |||
| 137 | if (UISettings::values.show_add_ons) { | ||
| 138 | list.insert(2, new GameListItem(FormatPatchNameVersions(patch, *loader))); | ||
| 139 | } | ||
| 140 | |||
| 141 | emit EntryReady(list); | ||
| 137 | } | 142 | } |
| 138 | 143 | ||
| 139 | const auto control_data = cache->ListEntriesFilter(FileSys::TitleType::Application, | 144 | const auto control_data = cache->ListEntriesFilter(FileSys::TitleType::Application, |
| @@ -216,18 +221,23 @@ void GameListWorker::AddFstEntriesToGameList(const std::string& dir_path, unsign | |||
| 216 | if (it != compatibility_list.end()) | 221 | if (it != compatibility_list.end()) |
| 217 | compatibility = it->second.first; | 222 | compatibility = it->second.first; |
| 218 | 223 | ||
| 219 | emit EntryReady({ | 224 | QList<QStandardItem*> list{ |
| 220 | new GameListItemPath( | 225 | new GameListItemPath( |
| 221 | FormatGameName(physical_name), icon, QString::fromStdString(name), | 226 | FormatGameName(physical_name), icon, QString::fromStdString(name), |
| 222 | QString::fromStdString(Loader::GetFileTypeString(loader->GetFileType())), | 227 | QString::fromStdString(Loader::GetFileTypeString(loader->GetFileType())), |
| 223 | program_id), | 228 | program_id), |
| 224 | new GameListItemCompat(compatibility), | 229 | new GameListItemCompat(compatibility), |
| 225 | new GameListItem( | 230 | new GameListItem( |
| 226 | FormatPatchNameVersions(patch, *loader, loader->IsRomFSUpdatable())), | ||
| 227 | new GameListItem( | ||
| 228 | QString::fromStdString(Loader::GetFileTypeString(loader->GetFileType()))), | 231 | QString::fromStdString(Loader::GetFileTypeString(loader->GetFileType()))), |
| 229 | new GameListItemSize(FileUtil::GetSize(physical_name)), | 232 | new GameListItemSize(FileUtil::GetSize(physical_name)), |
| 230 | }); | 233 | }; |
| 234 | |||
| 235 | if (UISettings::values.show_add_ons) { | ||
| 236 | list.insert(2, new GameListItem(FormatPatchNameVersions( | ||
| 237 | patch, *loader, loader->IsRomFSUpdatable()))); | ||
| 238 | } | ||
| 239 | |||
| 240 | emit EntryReady(std::move(list)); | ||
| 231 | } else if (is_dir && recursion > 0) { | 241 | } else if (is_dir && recursion > 0) { |
| 232 | watch_list.append(QString::fromStdString(physical_name)); | 242 | watch_list.append(QString::fromStdString(physical_name)); |
| 233 | AddFstEntriesToGameList(physical_name, recursion - 1); | 243 | AddFstEntriesToGameList(physical_name, recursion - 1); |
diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index 221702dc3..999086e7f 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp | |||
| @@ -941,7 +941,8 @@ void GMainWindow::OnGameListDumpRomFS(u64 program_id, const std::string& game_pa | |||
| 941 | const auto full = res == "Full"; | 941 | const auto full = res == "Full"; |
| 942 | const auto entry_size = CalculateRomFSEntrySize(extracted, full); | 942 | const auto entry_size = CalculateRomFSEntrySize(extracted, full); |
| 943 | 943 | ||
| 944 | QProgressDialog progress(tr("Extracting RomFS..."), tr("Cancel"), 0, entry_size, this); | 944 | QProgressDialog progress(tr("Extracting RomFS..."), tr("Cancel"), 0, |
| 945 | static_cast<s32>(entry_size), this); | ||
| 945 | progress.setWindowModality(Qt::WindowModal); | 946 | progress.setWindowModality(Qt::WindowModal); |
| 946 | progress.setMinimumDuration(100); | 947 | progress.setMinimumDuration(100); |
| 947 | 948 | ||
diff --git a/src/yuzu/main.ui b/src/yuzu/main.ui index 28cf269e7..75e96387f 100644 --- a/src/yuzu/main.ui +++ b/src/yuzu/main.ui | |||
| @@ -70,6 +70,8 @@ | |||
| 70 | <addaction name="separator"/> | 70 | <addaction name="separator"/> |
| 71 | <addaction name="action_Load_Amiibo"/> | 71 | <addaction name="action_Load_Amiibo"/> |
| 72 | <addaction name="separator"/> | 72 | <addaction name="separator"/> |
| 73 | <addaction name="action_Open_yuzu_Folder"/> | ||
| 74 | <addaction name="separator"/> | ||
| 73 | <addaction name="action_Exit"/> | 75 | <addaction name="action_Exit"/> |
| 74 | </widget> | 76 | </widget> |
| 75 | <widget class="QMenu" name="menu_Emulation"> | 77 | <widget class="QMenu" name="menu_Emulation"> |
| @@ -110,7 +112,6 @@ | |||
| 110 | <string>&Help</string> | 112 | <string>&Help</string> |
| 111 | </property> | 113 | </property> |
| 112 | <addaction name="action_Report_Compatibility"/> | 114 | <addaction name="action_Report_Compatibility"/> |
| 113 | <addaction name="action_Open_yuzu_Folder" /> | ||
| 114 | <addaction name="separator"/> | 115 | <addaction name="separator"/> |
| 115 | <addaction name="action_About"/> | 116 | <addaction name="action_About"/> |
| 116 | </widget> | 117 | </widget> |
diff --git a/src/yuzu/ui_settings.h b/src/yuzu/ui_settings.h index 2e617d52a..32a0d813c 100644 --- a/src/yuzu/ui_settings.h +++ b/src/yuzu/ui_settings.h | |||
| @@ -59,6 +59,7 @@ struct Values { | |||
| 59 | 59 | ||
| 60 | // Game List | 60 | // Game List |
| 61 | bool show_unknown; | 61 | bool show_unknown; |
| 62 | bool show_add_ons; | ||
| 62 | uint32_t icon_size; | 63 | uint32_t icon_size; |
| 63 | uint8_t row_1_text_id; | 64 | uint8_t row_1_text_id; |
| 64 | uint8_t row_2_text_id; | 65 | uint8_t row_2_text_id; |
diff --git a/src/yuzu_cmd/config.cpp b/src/yuzu_cmd/config.cpp index b456266a6..9cc409fd5 100644 --- a/src/yuzu_cmd/config.cpp +++ b/src/yuzu_cmd/config.cpp | |||
| @@ -132,6 +132,13 @@ void Config::ReadValues() { | |||
| 132 | Settings::values.current_user = std::clamp<int>( | 132 | Settings::values.current_user = std::clamp<int>( |
| 133 | sdl2_config->GetInteger("System", "current_user", 0), 0, Service::Account::MAX_USERS - 1); | 133 | sdl2_config->GetInteger("System", "current_user", 0), 0, Service::Account::MAX_USERS - 1); |
| 134 | 134 | ||
| 135 | const auto enabled = sdl2_config->GetBoolean("System", "rng_seed_enabled", false); | ||
| 136 | if (enabled) { | ||
| 137 | Settings::values.rng_seed = sdl2_config->GetInteger("System", "rng_seed", 0); | ||
| 138 | } else { | ||
| 139 | Settings::values.rng_seed = std::nullopt; | ||
| 140 | } | ||
| 141 | |||
| 135 | // Miscellaneous | 142 | // Miscellaneous |
| 136 | Settings::values.log_filter = sdl2_config->Get("Miscellaneous", "log_filter", "*:Trace"); | 143 | Settings::values.log_filter = sdl2_config->Get("Miscellaneous", "log_filter", "*:Trace"); |
| 137 | Settings::values.use_dev_keys = sdl2_config->GetBoolean("Miscellaneous", "use_dev_keys", false); | 144 | Settings::values.use_dev_keys = sdl2_config->GetBoolean("Miscellaneous", "use_dev_keys", false); |
| @@ -141,6 +148,7 @@ void Config::ReadValues() { | |||
| 141 | Settings::values.gdbstub_port = | 148 | Settings::values.gdbstub_port = |
| 142 | static_cast<u16>(sdl2_config->GetInteger("Debugging", "gdbstub_port", 24689)); | 149 | static_cast<u16>(sdl2_config->GetInteger("Debugging", "gdbstub_port", 24689)); |
| 143 | Settings::values.program_args = sdl2_config->Get("Debugging", "program_args", ""); | 150 | Settings::values.program_args = sdl2_config->Get("Debugging", "program_args", ""); |
| 151 | Settings::values.dump_nso = sdl2_config->GetBoolean("Debugging", "dump_nso", false); | ||
| 144 | 152 | ||
| 145 | // Web Service | 153 | // Web Service |
| 146 | Settings::values.enable_telemetry = | 154 | Settings::values.enable_telemetry = |
diff --git a/src/yuzu_cmd/default_ini.h b/src/yuzu_cmd/default_ini.h index e0b223cd6..ecf625e7b 100644 --- a/src/yuzu_cmd/default_ini.h +++ b/src/yuzu_cmd/default_ini.h | |||
| @@ -178,6 +178,11 @@ use_docked_mode = | |||
| 178 | # 1 (default): Yes, 0 : No | 178 | # 1 (default): Yes, 0 : No |
| 179 | enable_nfc = | 179 | enable_nfc = |
| 180 | 180 | ||
| 181 | # Sets the seed for the RNG generator built into the switch | ||
| 182 | # rng_seed will be ignored and randomly generated if rng_seed_enabled is false | ||
| 183 | rng_seed_enabled = | ||
| 184 | rng_seed = | ||
| 185 | |||
| 181 | # Sets the account username, max length is 32 characters | 186 | # Sets the account username, max length is 32 characters |
| 182 | # yuzu (default) | 187 | # yuzu (default) |
| 183 | username = yuzu | 188 | username = yuzu |
| @@ -201,6 +206,8 @@ log_filter = *:Trace | |||
| 201 | # Port for listening to GDB connections. | 206 | # Port for listening to GDB connections. |
| 202 | use_gdbstub=false | 207 | use_gdbstub=false |
| 203 | gdbstub_port=24689 | 208 | gdbstub_port=24689 |
| 209 | # Determines whether or not yuzu will dump all NSOs it attempts to load while loading them | ||
| 210 | dump_nso=false | ||
| 204 | 211 | ||
| 205 | [WebService] | 212 | [WebService] |
| 206 | # Whether or not to enable telemetry | 213 | # Whether or not to enable telemetry |