diff options
| author | 2018-11-22 21:39:05 -0500 | |
|---|---|---|
| committer | 2018-11-22 21:39:10 -0500 | |
| commit | 86ad1f8db65e9e52795c9601ea120c6fe0e76e29 (patch) | |
| tree | 5ede904d3559d9c14f243e691efc9a456f37d681 /src | |
| parent | fsp_srv: Add support for using open source archive if not found in NAND (diff) | |
| download | yuzu-86ad1f8db65e9e52795c9601ea120c6fe0e76e29.tar.gz yuzu-86ad1f8db65e9e52795c9601ea120c6fe0e76e29.tar.xz yuzu-86ad1f8db65e9e52795c9601ea120c6fe0e76e29.zip | |
file_sys: Implement system archive synthesizer for NgWord (806)
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/file_sys/system_archive/ng_word.cpp | 42 | ||||
| -rw-r--r-- | src/core/file_sys/system_archive/ng_word.h | 13 | ||||
| -rw-r--r-- | src/core/file_sys/system_archive/system_archive.cpp | 8 | ||||
| -rw-r--r-- | src/core/file_sys/vfs_vector.cpp | 1 | ||||
| -rw-r--r-- | src/core/file_sys/vfs_vector.h | 3 |
5 files changed, 61 insertions, 6 deletions
diff --git a/src/core/file_sys/system_archive/ng_word.cpp b/src/core/file_sys/system_archive/ng_word.cpp new file mode 100644 index 000000000..d0acdbd49 --- /dev/null +++ b/src/core/file_sys/system_archive/ng_word.cpp | |||
| @@ -0,0 +1,42 @@ | |||
| 1 | // Copyright 2018 yuzu emulator team | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #include <fmt/format.h> | ||
| 6 | #include "common/common_types.h" | ||
| 7 | #include "core/file_sys/system_archive/ng_word.h" | ||
| 8 | #include "core/file_sys/vfs_vector.h" | ||
| 9 | |||
| 10 | namespace FileSys::SystemArchive { | ||
| 11 | |||
| 12 | namespace NgWord1Data { | ||
| 13 | |||
| 14 | constexpr std::size_t NUMBER_WORD_TXT_FILES = 0x10; | ||
| 15 | |||
| 16 | // Should this archive replacement mysteriously not work on a future game, consider updating. | ||
| 17 | constexpr std::array<u8, 4> VERSION_DAT{0x0, 0x0, 0x0, 0x19}; // 5.1.0 System Version | ||
| 18 | |||
| 19 | constexpr std::array<u8, 30> WORD_TXT{ | ||
| 20 | 0xFE, 0xFF, 0x00, 0x5E, 0x00, 0x76, 0x00, 0x65, 0x00, 0x72, 0x00, 0x79, 0x00, 0x62, 0x00, | ||
| 21 | 0x61, 0x00, 0x64, 0x00, 0x77, 0x00, 0x6F, 0x00, 0x72, 0x00, 0x64, 0x00, 0x24, 0x00, 0x0A, | ||
| 22 | }; // "^verybadword$" in UTF-16 | ||
| 23 | |||
| 24 | } // namespace NgWord1Data | ||
| 25 | |||
| 26 | VirtualDir NgWord1() { | ||
| 27 | std::vector<VirtualFile> files(NgWord1Data::NUMBER_WORD_TXT_FILES); | ||
| 28 | |||
| 29 | for (std::size_t i = 0; i < NgWord1Data::NUMBER_WORD_TXT_FILES; ++i) { | ||
| 30 | files[i] = std::make_shared<ArrayVfsFile<NgWord1Data::WORD_TXT.size()>>( | ||
| 31 | NgWord1Data::WORD_TXT, fmt::format("{}.txt", i)); | ||
| 32 | } | ||
| 33 | |||
| 34 | files.push_back(std::make_shared<ArrayVfsFile<NgWord1Data::WORD_TXT.size()>>( | ||
| 35 | NgWord1Data::WORD_TXT, "common.txt")); | ||
| 36 | files.push_back(std::make_shared<ArrayVfsFile<NgWord1Data::VERSION_DAT.size()>>( | ||
| 37 | NgWord1Data::VERSION_DAT, "version.dat")); | ||
| 38 | |||
| 39 | return std::make_shared<VectorVfsDirectory>(files, std::vector<VirtualDir>{}, "data"); | ||
| 40 | } | ||
| 41 | |||
| 42 | } // namespace FileSys::SystemArchive | ||
diff --git a/src/core/file_sys/system_archive/ng_word.h b/src/core/file_sys/system_archive/ng_word.h new file mode 100644 index 000000000..f4bc67344 --- /dev/null +++ b/src/core/file_sys/system_archive/ng_word.h | |||
| @@ -0,0 +1,13 @@ | |||
| 1 | // Copyright 2018 yuzu emulator team | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #pragma once | ||
| 6 | |||
| 7 | #include "core/file_sys/vfs_types.h" | ||
| 8 | |||
| 9 | namespace FileSys::SystemArchive { | ||
| 10 | |||
| 11 | VirtualDir NgWord1(); | ||
| 12 | |||
| 13 | } // namespace FileSys::SystemArchive | ||
diff --git a/src/core/file_sys/system_archive/system_archive.cpp b/src/core/file_sys/system_archive/system_archive.cpp index 8451310a3..c9c40a07d 100644 --- a/src/core/file_sys/system_archive/system_archive.cpp +++ b/src/core/file_sys/system_archive/system_archive.cpp | |||
| @@ -21,7 +21,7 @@ struct SystemArchiveDescriptor { | |||
| 21 | SystemArchiveSupplier supplier; | 21 | SystemArchiveSupplier supplier; |
| 22 | }; | 22 | }; |
| 23 | 23 | ||
| 24 | const static std::array<SystemArchiveDescriptor, SYSTEM_ARCHIVE_COUNT> SYSTEM_ARCHIVES = {{ | 24 | const std::array<SystemArchiveDescriptor, SYSTEM_ARCHIVE_COUNT> SYSTEM_ARCHIVES = {{ |
| 25 | {0x0100000000000800, "CertStore", nullptr}, | 25 | {0x0100000000000800, "CertStore", nullptr}, |
| 26 | {0x0100000000000801, "ErrorMessage", nullptr}, | 26 | {0x0100000000000801, "ErrorMessage", nullptr}, |
| 27 | {0x0100000000000802, "MiiModel", nullptr}, | 27 | {0x0100000000000802, "MiiModel", nullptr}, |
| @@ -50,7 +50,7 @@ const static std::array<SystemArchiveDescriptor, SYSTEM_ARCHIVE_COUNT> SYSTEM_AR | |||
| 50 | {0x0100000000000819, "BootImagePackage", nullptr}, | 50 | {0x0100000000000819, "BootImagePackage", nullptr}, |
| 51 | {0x010000000000081A, "BootImagePackageSafe", nullptr}, | 51 | {0x010000000000081A, "BootImagePackageSafe", nullptr}, |
| 52 | {0x010000000000081B, "BootImagePackageExFat", nullptr}, | 52 | {0x010000000000081B, "BootImagePackageExFat", nullptr}, |
| 53 | {0x010000000000081C, "BottImagePackageExFatSafe", nullptr}, | 53 | {0x010000000000081C, "BootImagePackageExFatSafe", nullptr}, |
| 54 | {0x010000000000081D, "FatalMessage", nullptr}, | 54 | {0x010000000000081D, "FatalMessage", nullptr}, |
| 55 | {0x010000000000081E, "ControllerIcon", nullptr}, | 55 | {0x010000000000081E, "ControllerIcon", nullptr}, |
| 56 | {0x010000000000081F, "PlatformConfigIcosa", nullptr}, | 56 | {0x010000000000081F, "PlatformConfigIcosa", nullptr}, |
| @@ -64,11 +64,11 @@ const static std::array<SystemArchiveDescriptor, SYSTEM_ARCHIVE_COUNT> SYSTEM_AR | |||
| 64 | {0x0100000000000827, "ContentActionTable", nullptr}, | 64 | {0x0100000000000827, "ContentActionTable", nullptr}, |
| 65 | }}; | 65 | }}; |
| 66 | 66 | ||
| 67 | VirtualFile SynthesizeSystemArchive(u64 title_id) { | 67 | VirtualFile SynthesizeSystemArchive(const u64 title_id) { |
| 68 | if (title_id < SYSTEM_ARCHIVES.front().title_id || title_id > SYSTEM_ARCHIVES.back().title_id) | 68 | if (title_id < SYSTEM_ARCHIVES.front().title_id || title_id > SYSTEM_ARCHIVES.back().title_id) |
| 69 | return nullptr; | 69 | return nullptr; |
| 70 | 70 | ||
| 71 | const auto desc = SYSTEM_ARCHIVES[title_id - SYSTEM_ARCHIVE_BASE_TITLE_ID]; | 71 | const auto& desc = SYSTEM_ARCHIVES[title_id - SYSTEM_ARCHIVE_BASE_TITLE_ID]; |
| 72 | 72 | ||
| 73 | LOG_INFO(Service_FS, "Synthesizing system archive '{}' (0x{:016X}).", desc.name, desc.title_id); | 73 | LOG_INFO(Service_FS, "Synthesizing system archive '{}' (0x{:016X}).", desc.name, desc.title_id); |
| 74 | 74 | ||
diff --git a/src/core/file_sys/vfs_vector.cpp b/src/core/file_sys/vfs_vector.cpp index 808f31e81..515626658 100644 --- a/src/core/file_sys/vfs_vector.cpp +++ b/src/core/file_sys/vfs_vector.cpp | |||
| @@ -3,7 +3,6 @@ | |||
| 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 <cstring> | ||
| 7 | #include <utility> | 6 | #include <utility> |
| 8 | #include "core/file_sys/vfs_vector.h" | 7 | #include "core/file_sys/vfs_vector.h" |
| 9 | 8 | ||
diff --git a/src/core/file_sys/vfs_vector.h b/src/core/file_sys/vfs_vector.h index 7ed5123d2..ac36cb2ee 100644 --- a/src/core/file_sys/vfs_vector.h +++ b/src/core/file_sys/vfs_vector.h | |||
| @@ -4,6 +4,7 @@ | |||
| 4 | 4 | ||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include <cstring> | ||
| 7 | #include "core/file_sys/vfs.h" | 8 | #include "core/file_sys/vfs.h" |
| 8 | 9 | ||
| 9 | namespace FileSys { | 10 | namespace FileSys { |
| @@ -13,7 +14,7 @@ template <std::size_t size> | |||
| 13 | class ArrayVfsFile : public VfsFile { | 14 | class ArrayVfsFile : public VfsFile { |
| 14 | public: | 15 | public: |
| 15 | ArrayVfsFile(std::array<u8, size> data, std::string name = "", VirtualDir parent = nullptr) | 16 | ArrayVfsFile(std::array<u8, size> data, std::string name = "", VirtualDir parent = nullptr) |
| 16 | : data(std::move(data)), name(std::move(name)), parent(std::move(parent)) {} | 17 | : data(data), name(std::move(name)), parent(std::move(parent)) {} |
| 17 | 18 | ||
| 18 | std::string GetName() const override { | 19 | std::string GetName() const override { |
| 19 | return name; | 20 | return name; |