From d4e8a886c56528a09f889ec9f28a87a9546d2729 Mon Sep 17 00:00:00 2001 From: trinemark <49107242+trinemark@users.noreply.github.com> Date: Fri, 5 Apr 2019 22:35:52 -0500 Subject: [PATCH] Fix libretro achievements https://github.com/LIJI32/SameBoy/issues/48 https://github.com/LIJI32/SameBoy/issues/157 --- libretro/libretro.c | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/libretro/libretro.c b/libretro/libretro.c index 4d5df93b..a596e941 100644 --- a/libretro/libretro.c +++ b/libretro/libretro.c @@ -393,7 +393,7 @@ static void init_for_current_model(unsigned id) set_link_cable_state(true); } - struct retro_memory_descriptor descs[8]; + struct retro_memory_descriptor descs[9]; size_t size; uint16_t bank; @@ -414,26 +414,31 @@ static void init_for_current_model(unsigned id) descs[2].start = 0xC000; descs[2].len = 0x1000; - descs[3].ptr = GB_get_direct_access(&gameboy[i], GB_DIRECT_ACCESS_CART_RAM, &size, &bank); - descs[3].start = 0xA000; - descs[3].len = 0x2000; + descs[3].ptr = descs[2].ptr + (bank * 0x1000); + descs[3].start = 0xD000; + descs[3].len = 0x1000; - descs[4].ptr = GB_get_direct_access(&gameboy[i], GB_DIRECT_ACCESS_VRAM, &size, &bank); - descs[4].start = 0x8000; + descs[4].ptr = GB_get_direct_access(&gameboy[i], GB_DIRECT_ACCESS_CART_RAM, &size, &bank); + descs[4].start = 0xA000; descs[4].len = 0x2000; - descs[5].ptr = GB_get_direct_access(&gameboy[i], GB_DIRECT_ACCESS_ROM, &size, &bank); - descs[5].start = 0x0000; - descs[5].len = 0x4000; - descs[5].flags = RETRO_MEMDESC_CONST; + descs[5].ptr = GB_get_direct_access(&gameboy[i], GB_DIRECT_ACCESS_VRAM, &size, &bank); + descs[5].start = 0x8000; + descs[5].len = 0x2000; - descs[6].ptr = GB_get_direct_access(&gameboy[i], GB_DIRECT_ACCESS_OAM, &size, &bank); - descs[6].start = 0xFE00; - descs[6].len = 0x00A0; + descs[6].ptr = GB_get_direct_access(&gameboy[i], GB_DIRECT_ACCESS_ROM, &size, &bank); + descs[6].start = 0x0000; + descs[6].len = 0x4000; + descs[6].flags = RETRO_MEMDESC_CONST; - descs[7].ptr = GB_get_direct_access(&gameboy[i], GB_DIRECT_ACCESS_RAM, &size, &bank) + 0x1000; - descs[7].start = 0xD000; - descs[7].len = 0x1000; + descs[7].ptr = descs[6].ptr + (bank * 0x4000); + descs[7].start = 0x4000; + descs[7].len = 0x4000; + descs[7].flags = RETRO_MEMDESC_CONST; + + descs[8].ptr = GB_get_direct_access(&gameboy[i], GB_DIRECT_ACCESS_OAM, &size, &bank); + descs[8].start = 0xFE00; + descs[8].len = 0x00A0; struct retro_memory_map mmaps; mmaps.descriptors = descs;