RAIntegration: Fix memory writes

This commit is contained in:
Henrik Rydgård 2024-04-05 21:00:12 +02:00
parent c9515ceb4e
commit d39b606931

View file

@ -236,6 +236,15 @@ bool IsActive() {
return GetGameID() != 0;
}
static void raintegration_write_memory_handler(uint32_t address, uint8_t *buffer, uint32_t num_bytes, rc_client_t *client) {
// convert_retroachievements_address_to_real_address
uint32_t realAddress = address + PSP_MEMORY_OFFSET;
uint8_t *writePtr = Memory::GetPointerWriteRange(realAddress, num_bytes);
if (writePtr) {
memcpy(writePtr, buffer, num_bytes);
}
}
static uint32_t read_memory_callback(uint32_t address, uint8_t *buffer, uint32_t num_bytes, rc_client_t *client) {
// Achievements are traditionally defined relative to the base of main memory of the emulated console.
// This is some kind of RetroArch-related legacy. In the PSP's case, this is simply a straight offset of 0x08000000.
@ -483,14 +492,7 @@ static void raintegration_get_game_name_handler(char *buffer, uint32_t buffer_si
snprintf(buffer, buffer_size, "%s", g_gamePath.GetFilename().c_str());
}
static void raintegration_write_memory_handler(uint32_t address, uint8_t *buffer, uint32_t num_bytes, rc_client_t *client) {
// convert_retroachievements_address_to_real_address
uint32_t realAddress = address + PSP_MEMORY_OFFSET;
uint8_t *writePtr = Memory::GetPointerWriteRange(address, num_bytes);
if (writePtr) {
memcpy(writePtr, buffer, num_bytes);
}
}
static void raintegration_write_memory_handler(uint32_t address, uint8_t *buffer, uint32_t num_bytes, rc_client_t *client);
static void raintegration_event_handler(const rc_client_raintegration_event_t *event, rc_client_t *client) {
switch (event->type) {