Content enumeration.

This commit is contained in:
Ben Vanik
2015-02-12 16:15:45 -08:00
parent 1e1a123fba
commit 1ddb8f0c8f
8 changed files with 130 additions and 26 deletions

View File

@@ -202,16 +202,31 @@ SHIM_CALL XamContentCreateEnumerator_shim(PPCContext* ppc_state,
SHIM_SET_RETURN_32(X_E_INVALIDARG);
return;
}
// 4 + 4 + 128*2 + 42 = 306
if (buffer_size_ptr) {
uint32_t bp = SHIM_MEM_32(buffer_size_ptr);
SHIM_SET_MEM_32(buffer_size_ptr, item_count * 306);
if (!device_id) {
// 0 == whatever
device_id = dummy_device_info_.device_id;
}
XEnumerator* e = new XEnumerator(state);
if (buffer_size_ptr) {
uint32_t bp = SHIM_MEM_32(buffer_size_ptr);
SHIM_SET_MEM_32(buffer_size_ptr, item_count * XCONTENT_DATA::kSize);
}
auto e = new XStaticEnumerator(state, item_count, XCONTENT_DATA::kSize);
e->Initialize();
// Get all content data.
auto content_datas =
state->content_manager()->ListContent(device_id, content_type);
for (auto& content_data : content_datas) {
auto ptr = e->AppendItem();
if (!ptr) {
// Too many items.
break;
}
content_data.Write(ptr);
}
SHIM_SET_MEM_32(handle_ptr, e->handle());
SHIM_SET_RETURN_32(X_ERROR_SUCCESS);