citra-emu
/
citra
Archived
1
0
Fork 0

Use open source Shared Font if no dumped file is available (#3881)

* Add virtual SharedFont; Load if dumped is missing

* Move open_source_archives to externals; add readme and git hash to open_source_archives

* Updated shared font to newest version: m fixed, symbols fixed
This commit is contained in:
Ben 2018-07-18 18:20:31 +02:00 committed by James Rowe
parent 7fa2076918
commit 7f1303a834
8 changed files with 92587 additions and 1 deletions

View File

@ -42,6 +42,9 @@ target_include_directories(microprofile INTERFACE ./microprofile)
add_library(nihstro-headers INTERFACE)
target_include_directories(nihstro-headers INTERFACE ./nihstro/include)
# Open Source Archives
add_subdirectory(open_source_archives)
# SoundTouch
add_subdirectory(soundtouch)
# The SoundTouch target doesn't export the necessary include paths as properties by default

View File

@ -0,0 +1,3 @@
add_library(open_source_archives INTERFACE)
target_include_directories(open_source_archives INTERFACE "include/")

View File

@ -0,0 +1,4 @@
These files were generated by https://github.com/B3n30/citra_system_archives at git commit 1f6b5341b5eda91132f8b6fddee44d90c81019e6. To generate the files use the run.sh inside that repository
The follwing system archives are currently included:
- JPN/EUR/USA System Font

File diff suppressed because it is too large Load Diff

View File

@ -416,7 +416,7 @@ add_library(core STATIC
create_target_directory_groups(core)
target_link_libraries(core PUBLIC common PRIVATE audio_core network video_core)
target_link_libraries(core PUBLIC Boost::boost PRIVATE cryptopp fmt)
target_link_libraries(core PUBLIC Boost::boost PRIVATE cryptopp fmt open_source_archives)
if (ENABLE_WEB_SERVICE)
target_link_libraries(core PUBLIC json-headers web_service)
endif()

View File

@ -19,6 +19,7 @@
#include "core/hle/service/am/am.h"
#include "core/hle/service/fs/archive.h"
#include "core/loader/loader.h"
#include "shared_font.app.romfs.h"
////////////////////////////////////////////////////////////////////////////////////////////////////
// FileSys namespace
@ -102,6 +103,7 @@ ResultVal<std::unique_ptr<FileBackend>> NCCHArchive::OpenFile(const Path& path,
constexpr u32 mii_data = 0x00010202;
constexpr u32 region_manifest = 0x00010402;
constexpr u32 ng_word_list = 0x00010302;
constexpr u32 shared_font = 0x00014002;
u32 high = static_cast<u32>(title_id >> 32);
u32 low = static_cast<u32>(title_id & 0xFFFFFFFF);
@ -115,6 +117,20 @@ ResultVal<std::unique_ptr<FileBackend>> NCCHArchive::OpenFile(const Path& path,
archive_name = "Mii Data";
else if (low == region_manifest)
archive_name = "Region manifest";
else if (low == shared_font) {
LOG_WARNING(
Service_FS,
"Shared Font file missing. Loading open source replacement from memory");
std::vector<u8> shared_font_file;
shared_font_file.assign(SHARED_FONT_DATA, SHARED_FONT_DATA + SHARED_FONT_DATA_len);
u64 romfs_offset = 0;
u64 romfs_size = shared_font_file.size();
std::unique_ptr<DelayGenerator> delay_generator =
std::make_unique<RomFSDelayGenerator>();
file = std::make_unique<IVFCFileInMemory>(std::move(shared_font_file), romfs_offset,
romfs_size, std::move(delay_generator));
return MakeResult<std::unique_ptr<FileBackend>>(std::move(file));
}
} else if (high == system_data_archive) {
if (low == ng_word_list)
archive_name = "NG bad word list";

View File

@ -115,4 +115,36 @@ bool IVFCFile::SetSize(const u64 size) const {
return false;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
IVFCFileInMemory::IVFCFileInMemory(std::vector<u8> bytes, u64 offset, u64 size,
std::unique_ptr<DelayGenerator> delay_generator_)
: romfs_file(std::move(bytes)), data_offset(offset), data_size(size) {
delay_generator = std::move(delay_generator_);
}
ResultVal<size_t> IVFCFileInMemory::Read(const u64 offset, const size_t length, u8* buffer) const {
LOG_TRACE(Service_FS, "called offset={}, length={}", offset, length);
size_t read_length = (size_t)std::min((u64)length, data_size - offset);
std::memcpy(buffer, romfs_file.data() + data_offset + offset, read_length);
return MakeResult<size_t>(read_length);
}
ResultVal<size_t> IVFCFileInMemory::Write(const u64 offset, const size_t length, const bool flush,
const u8* buffer) {
LOG_ERROR(Service_FS, "Attempted to write to IVFC file");
// TODO(Subv): Find error code
return MakeResult<size_t>(0);
}
u64 IVFCFileInMemory::GetSize() const {
return data_size;
}
bool IVFCFileInMemory::SetSize(const u64 size) const {
LOG_ERROR(Service_FS, "Attempted to set the size of an IVFC file");
return false;
}
} // namespace FileSys

View File

@ -7,6 +7,7 @@
#include <cstddef>
#include <memory>
#include <string>
#include <vector>
#include "common/common_types.h"
#include "common/file_util.h"
#include "core/file_sys/archive_backend.h"
@ -118,4 +119,24 @@ public:
}
};
class IVFCFileInMemory : public FileBackend {
public:
IVFCFileInMemory(std::vector<u8> bytes, u64 offset, u64 size,
std::unique_ptr<DelayGenerator> delay_generator_);
ResultVal<size_t> Read(u64 offset, size_t length, u8* buffer) const override;
ResultVal<size_t> Write(u64 offset, size_t length, bool flush, const u8* buffer) override;
u64 GetSize() const override;
bool SetSize(u64 size) const override;
bool Close() const override {
return false;
}
void Flush() const override {}
private:
std::vector<u8> romfs_file;
u64 data_offset;
u64 data_size;
};
} // namespace FileSys