Skip to content

Commit

Permalink
[XAM] Unfinished implementation for enumerating ODD content
Browse files Browse the repository at this point in the history
  • Loading branch information
Gliniak committed Nov 3, 2024
1 parent 464e9a1 commit d3101ee
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 0 deletions.
36 changes: 36 additions & 0 deletions src/xenia/kernel/xam/content_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,42 @@ std::vector<XCONTENT_AGGREGATE_DATA> ContentManager::ListContent(
return result;
}

std::vector<XCONTENT_AGGREGATE_DATA> ContentManager::ListContentODD(
const uint32_t device_id, const uint64_t xuid, const uint32_t title_id,
const XContentType content_type) const {
std::vector<XCONTENT_AGGREGATE_DATA> result;

auto xuid_str = fmt::format("{:016X}", xuid);
auto title_id_str = fmt::format("{:08X}", title_id);
auto content_type_str =
fmt::format("{:08X}", static_cast<uint32_t>(content_type));

std::filesystem::path game_content_path = "GAME:";
game_content_path =
game_content_path / "content" / xuid_str / title_id_str / content_type_str;

auto entry = kernel_state_->file_system()->ResolvePath(
xe::path_to_utf8(game_content_path));

if (!entry) {
return {};
}

for (auto& child : entry->children()) {
XCONTENT_AGGREGATE_DATA content_data;

content_data.device_id = device_id;
content_data.content_type = content_type;
content_data.set_display_name(xe::path_to_utf16(child->name()));
content_data.set_file_name(xe::path_to_utf8(child->name()));
content_data.title_id = title_id;
content_data.xuid = xuid;
result.emplace_back(std::move(content_data));
}

return result;
}

std::unique_ptr<ContentPackage> ContentManager::ResolvePackage(
const std::string_view root_name, const uint64_t xuid,
const XCONTENT_AGGREGATE_DATA& data, const uint32_t disc_number) {
Expand Down
4 changes: 4 additions & 0 deletions src/xenia/kernel/xam/content_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,10 @@ class ContentManager {
const uint32_t device_id, const uint64_t xuid, const uint32_t title_id,
const XContentType content_type) const;

std::vector<XCONTENT_AGGREGATE_DATA> ListContentODD(
const uint32_t device_id, const uint64_t xuid, const uint32_t title_id,
const XContentType content_type) const;

std::unique_ptr<ContentPackage> ResolvePackage(
const std::string_view root_name, const uint64_t xuid,
const XCONTENT_AGGREGATE_DATA& data, const uint32_t disc_number = -1);
Expand Down
8 changes: 8 additions & 0 deletions src/xenia/kernel/xam/xam_content.cc
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,14 @@ dword_result_t XamContentCreateEnumerator_entry(
}

if (!device_info || device_info->device_id == DummyDeviceId::ODD) {
auto disc_enumerated_data =
kernel_state()->content_manager()->ListContentODD(
static_cast<uint32_t>(DummyDeviceId::ODD), 0,
kernel_state()->title_id(), XContentType(uint32_t(content_type)));

enumerated_content.insert(enumerated_content.end(),
disc_enumerated_data.cbegin(),
disc_enumerated_data.cend());
// TODO(gibbed): disc drive content
}

Expand Down

0 comments on commit d3101ee

Please sign in to comment.