diff --git a/src/xenia/kernel/util/xdbf_utils.cc b/src/xenia/kernel/util/xdbf_utils.cc index 4af86cb8f..488eb1641 100644 --- a/src/xenia/kernel/util/xdbf_utils.cc +++ b/src/xenia/kernel/util/xdbf_utils.cc @@ -57,7 +57,7 @@ bool XdbfFile::Write(uint8_t* data, size_t* data_size) { *data_size += sizeof(X_XDBF_HEADER); *data_size += entries.size() * sizeof(X_XDBF_ENTRY); - *data_size += free_entries.size() * sizeof(X_XDBF_FILELOC); + *data_size += 1 * sizeof(X_XDBF_FILELOC); size_t entries_size = 0; for (auto ent : entries) { @@ -71,7 +71,7 @@ bool XdbfFile::Write(uint8_t* data, size_t* data_size) { } header.entry_count = header.entry_used = (uint32_t)entries.size(); - header.free_count = header.free_used = (uint32_t)free_entries.size(); + header.free_count = header.free_used = 1; auto* ptr = data; memcpy(ptr, &header, sizeof(X_XDBF_HEADER)); @@ -93,6 +93,15 @@ bool XdbfFile::Write(uint8_t* data, size_t* data_size) { ptr += sizeof(X_XDBF_ENTRY); } + free_entries.clear(); + X_XDBF_FILELOC free_ent; + free_ent.offset = (uint32_t)*data_size - sizeof(X_XDBF_HEADER) - + (sizeof(X_XDBF_ENTRY) * header.entry_count) - + (sizeof(X_XDBF_FILELOC) * header.free_count); + + free_ent.size = 0 - free_ent.offset; + free_entries.push_back(free_ent); + for (auto ent : free_entries) { memcpy(free_ptr, &ent, sizeof(X_XDBF_FILELOC)); free_ptr++; diff --git a/src/xenia/kernel/xam/user_profile.cc b/src/xenia/kernel/xam/user_profile.cc index 0230f2b2d..0907c2008 100644 --- a/src/xenia/kernel/xam/user_profile.cc +++ b/src/xenia/kernel/xam/user_profile.cc @@ -162,6 +162,26 @@ util::GpdFile* UserProfile::SetTitleSpaData(const util::SpaFile& spa_data) { } } + // try adding title image & name + auto* title_image = + spa_data.GetEntry(static_cast(util::XdbfSpaSection::kImage), + static_cast(util::XdbfSpaID::Title)); + if (title_image) { + title_gpd.UpdateEntry(*title_image); + } + + auto title_name = xe::to_wstring(spa_data.GetTitleName()); + if (title_name.length()) { + util::XdbfEntry title_name_ent; + title_name_ent.info.section = + static_cast(util::XdbfGpdSection::kString); + title_name_ent.info.id = static_cast(util::XdbfSpaID::Title); + title_name_ent.data.resize((title_name.length() + 1) * 2); + xe::copy_and_swap((wchar_t*)title_name_ent.data.data(), + title_name.c_str(), title_name.length()); + title_gpd.UpdateEntry(title_name_ent); + } + title_gpds_[spa_title] = title_gpd; // Update dash GPD with title and write updated GPDs