Add rc_client MemoryPeekerV2 to AchievementManager

Has a more traditional read-x-bytes structure; for passing into rc_client in the constructor.
This commit is contained in:
LillyJadeKatrin 2024-03-14 19:08:01 -04:00
parent 05136ee099
commit 4ec662bcdf
2 changed files with 19 additions and 0 deletions

View File

@ -1749,4 +1749,21 @@ void AchievementManager::RequestV2(const rc_api_request_t* request,
});
}
u32 AchievementManager::MemoryPeekerV2(u32 address, u8* buffer, u32 num_bytes, rc_client_t* client)
{
if (buffer == nullptr)
return 0u;
auto& system = Core::System::GetInstance();
Core::CPUThreadGuard threadguard(system);
for (u32 num_read = 0; num_read < num_bytes; num_read++)
{
auto value = system.GetMMU().HostTryReadU8(threadguard, address + num_read,
PowerPC::RequestedAddressSpace::Physical);
if (!value.has_value())
return num_read;
buffer[num_read] = value.value().value;
}
return num_bytes;
}
#endif // USE_RETRO_ACHIEVEMENTS

View File

@ -204,8 +204,10 @@ private:
const std::function<int(rc_api_request_t*, const RcRequest*)>& init_request,
const std::function<int(RcResponse*, const char*)>& process_response);
ResponseType RequestImage(rc_api_fetch_image_request_t rc_request, Badge* rc_response);
static void RequestV2(const rc_api_request_t* request, rc_client_server_callback_t callback,
void* callback_data, rc_client_t* client);
static u32 MemoryPeekerV2(u32 address, u8* buffer, u32 num_bytes, rc_client_t* client);
rc_runtime_t m_runtime{};
Core::System* m_system{};