Add support for title.db, and use title.db to augment TMD finding

Also added support for system title CIA building, and fixed various minor issues.
Also moved MakeMagic to Common.
This commit is contained in:
Pengfei
2021-07-01 14:13:20 +08:00
parent 857bd12a6f
commit e2bef4d705
16 changed files with 326 additions and 88 deletions
+1 -1
View File
@@ -175,7 +175,7 @@ bool CIABuilder::AddContent(u16 content_id, NCCHContainer& ncch) {
file->SetHashEnabled(false);
// DLCs do not have a meta
if (tmd_chunk.index != TMDContentIndex::Main || (tmd.GetTitleID() & 0x0004008c'00000000)) {
if (tmd_chunk.index != TMDContentIndex::Main || (tmd.GetTitleID() >> 32) == 0x0004008c) {
return true;
}
-4
View File
@@ -22,10 +22,6 @@
namespace Core {
constexpr u32 MakeMagic(char a, char b, char c, char d) {
return a | b << 8 | c << 16 | d << 24;
}
static const int kMaxSections = 8; ///< Maximum number of sections (files) in an ExeFs
static const int kBlockSize = 0x200; ///< Size of ExeFS blocks (in bytes)
+1 -4
View File
@@ -4,15 +4,12 @@
#include <cstring>
#include <vector>
#include "common/common_funcs.h"
#include "common/common_types.h"
#include "core/ncch/smdh.h"
namespace Core {
constexpr u32 MakeMagic(char a, char b, char c, char d) {
return a | b << 8 | c << 16 | d << 24;
}
// 8x8 Z-Order coordinate from 2D coordinates
static constexpr u32 MortonInterleave(u32 x, u32 y) {
constexpr u32 xlut[] = {0x00, 0x01, 0x04, 0x05, 0x10, 0x11, 0x14, 0x15};
+7
View File
@@ -207,6 +207,13 @@ const TitleMetadata::ContentChunk& TitleMetadata::GetContentChunkByID(u32 conten
return *it;
}
bool TitleMetadata::HasContentID(u32 content_id) const {
const auto it =
std::find_if(tmd_chunks.begin(), tmd_chunks.end(),
[content_id](const ContentChunk& chunk) { return chunk.id == content_id; });
return it != tmd_chunks.end();
}
void TitleMetadata::AddContentChunk(const ContentChunk& chunk) {
tmd_chunks.push_back(chunk);
}
+1
View File
@@ -127,6 +127,7 @@ public:
ContentChunk& GetContentChunkByID(u32 content_id);
const ContentChunk& GetContentChunkByID(u32 content_id) const;
bool HasContentID(u32 content_id) const;
void SetTitleID(u64 title_id);
void SetTitleType(u32 type);