mirror of
https://github.com/citra-emu/citra.git
synced 2025-02-20 13:30:06 +00:00
create shared font if it is missing
This commit is contained in:
parent
22fc378fe9
commit
b96e6eba37
87385
dist/shared_font.app.romfs.h
vendored
Normal file
87385
dist/shared_font.app.romfs.h
vendored
Normal file
File diff suppressed because it is too large
Load Diff
@ -386,8 +386,11 @@ set(HEADERS
|
|||||||
telemetry_session.h
|
telemetry_session.h
|
||||||
)
|
)
|
||||||
|
|
||||||
create_directory_groups(${SRCS} ${HEADERS})
|
set(SYSTEM_ARCHIVES
|
||||||
add_library(core STATIC ${SRCS} ${HEADERS})
|
../../dist/shared_font.app.romfs.h
|
||||||
|
)
|
||||||
|
create_directory_groups(${SRCS} ${HEADERS} ${SYSTEM_ARCHIVES})
|
||||||
|
add_library(core STATIC ${SRCS} ${HEADERS} ${SYSTEM_ARCHIVES})
|
||||||
target_link_libraries(core PUBLIC common PRIVATE audio_core network video_core)
|
target_link_libraries(core PUBLIC common PRIVATE audio_core network video_core)
|
||||||
target_link_libraries(core PUBLIC Boost::boost PRIVATE cryptopp dynarmic fmt)
|
target_link_libraries(core PUBLIC Boost::boost PRIVATE cryptopp dynarmic fmt)
|
||||||
if (ENABLE_WEB_SERVICE)
|
if (ENABLE_WEB_SERVICE)
|
||||||
|
@ -15,6 +15,8 @@
|
|||||||
#include "core/file_sys/ivfc_archive.h"
|
#include "core/file_sys/ivfc_archive.h"
|
||||||
#include "core/hle/service/fs/archive.h"
|
#include "core/hle/service/fs/archive.h"
|
||||||
|
|
||||||
|
#include "../../dist/shared_font.app.romfs.h"
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// FileSys namespace
|
// FileSys namespace
|
||||||
|
|
||||||
@ -82,6 +84,36 @@ ResultVal<std::unique_ptr<ArchiveBackend>> ArchiveFactory_NCCH::Open(const Path&
|
|||||||
|
|
||||||
ResultCode ArchiveFactory_NCCH::Format(const Path& path,
|
ResultCode ArchiveFactory_NCCH::Format(const Path& path,
|
||||||
const FileSys::ArchiveFormatInfo& format_info) {
|
const FileSys::ArchiveFormatInfo& format_info) {
|
||||||
|
// TODO(B3N30): Take care of the format_info
|
||||||
|
auto vec = path.AsBinary();
|
||||||
|
const u32* data = reinterpret_cast<u32*>(vec.data());
|
||||||
|
u32 high = data[1];
|
||||||
|
u32 low = data[0];
|
||||||
|
std::string file_path = GetNCCHPath(mount_point, high, low);
|
||||||
|
|
||||||
|
// High Title ID of the archive: The category (https://3dbrew.org/wiki/Title_list).
|
||||||
|
constexpr u32 shared_data_archive = 0x0004009B;
|
||||||
|
|
||||||
|
// Low Title IDs.
|
||||||
|
constexpr u32 shared_font_archive = 0x00014002;
|
||||||
|
|
||||||
|
if (high == shared_data_archive) {
|
||||||
|
if (low == shared_font_archive) {
|
||||||
|
auto file = std::make_shared<FileUtil::IOFile>(file_path, "w+b");
|
||||||
|
if (!file->IsOpen()) {
|
||||||
|
LOG_ERROR(Service_FS, "Could not create shared font file.");
|
||||||
|
// TODO: Verify error code
|
||||||
|
return ResultCode(ErrorDescription::NotAuthorized, ErrorModule::FS,
|
||||||
|
ErrorSummary::NotSupported, ErrorLevel::Permanent);
|
||||||
|
}
|
||||||
|
file->WriteBytes(SHARED_FONT_DATA, SHARED_FONT_DATA_len);
|
||||||
|
file->Close();
|
||||||
|
file.reset();
|
||||||
|
LOG_DEBUG(Service_FS, "Created shared font file.");
|
||||||
|
return RESULT_SUCCESS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
LOG_ERROR(Service_FS, "Attempted to format a NCCH archive.");
|
LOG_ERROR(Service_FS, "Attempted to format a NCCH archive.");
|
||||||
// TODO: Verify error code
|
// TODO: Verify error code
|
||||||
return ResultCode(ErrorDescription::NotAuthorized, ErrorModule::FS, ErrorSummary::NotSupported,
|
return ResultCode(ErrorDescription::NotAuthorized, ErrorModule::FS, ErrorSummary::NotSupported,
|
||||||
|
@ -982,6 +982,18 @@ static bool LoadLegacySharedFont() {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool FormatSharedFont() {
|
||||||
|
// TODO (B3N30): create different font archive for region CHN/KOR/TWN
|
||||||
|
const u64_le shared_font_archive_id_low = 0x0004009b00014002;
|
||||||
|
const u64_le shared_font_archive_id_high = 0x00000001ffffff00;
|
||||||
|
std::vector<u8> shared_font_archive_id(16);
|
||||||
|
std::memcpy(&shared_font_archive_id[0], &shared_font_archive_id_low, sizeof(u64));
|
||||||
|
std::memcpy(&shared_font_archive_id[8], &shared_font_archive_id_high, sizeof(u64));
|
||||||
|
FileSys::Path archive_path(shared_font_archive_id);
|
||||||
|
return Service::FS::FormatArchive(Service::FS::ArchiveIdCode::NCCH,
|
||||||
|
FileSys::ArchiveFormatInfo{}, archive_path) == RESULT_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
void Init() {
|
void Init() {
|
||||||
AddService(new APT_A_Interface);
|
AddService(new APT_A_Interface);
|
||||||
AddService(new APT_S_Interface);
|
AddService(new APT_S_Interface);
|
||||||
@ -1000,6 +1012,8 @@ void Init() {
|
|||||||
} else if (LoadLegacySharedFont()) {
|
} else if (LoadLegacySharedFont()) {
|
||||||
LOG_WARNING(Service_APT, "Loaded shared font by legacy method");
|
LOG_WARNING(Service_APT, "Loaded shared font by legacy method");
|
||||||
shared_font_loaded = true;
|
shared_font_loaded = true;
|
||||||
|
} else if (FormatSharedFont() && LoadSharedFont()) {
|
||||||
|
shared_font_loaded = true;
|
||||||
} else {
|
} else {
|
||||||
LOG_WARNING(Service_APT, "Unable to load shared font");
|
LOG_WARNING(Service_APT, "Unable to load shared font");
|
||||||
shared_font_loaded = false;
|
shared_font_loaded = false;
|
||||||
|
Loading…
Reference in New Issue
Block a user