From 1ce47d9f0805327baebb0154e7aea6f1208b2b98 Mon Sep 17 00:00:00 2001 From: Joshua Eagles Date: Mon, 22 Jul 2024 20:20:04 -0400 Subject: [PATCH 1/9] add memory map setup --- mupen64plus-core/src/main/main.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/mupen64plus-core/src/main/main.c b/mupen64plus-core/src/main/main.c index a03494d3..72a95fee 100644 --- a/mupen64plus-core/src/main/main.c +++ b/mupen64plus-core/src/main/main.c @@ -1703,6 +1703,8 @@ m64p_error main_run(void) dd_rom_size, &dd_disk, dd_idisk); + setup_libretro_memory_map(); + // Attach rom to plugins failure_rval = M64ERR_PLUGIN_FAIL; if (!gfx.romOpen()) @@ -1873,3 +1875,21 @@ m64p_error close_pif(void) g_start_address = UINT32_C(0xa4000040); return M64ERR_SUCCESS; } + +void setup_libretro_memory_map() { + struct retro_memory_descriptor descs[1]; + struct retro_memory_map retromap; + + memset(descs, 0, sizeof(descs)); + + descs[0].flags = RETRO_MEMDESC_SYSTEM_RAM; + descs[0].ptr = g_dev.rdram.dram; + descs[0].start = 0; + descs[0].len = RDRAM_MAX_SIZE; + descs[0].select = 0; + + retromap.descriptors = &descs; + retromap.num_descriptors = sizeof(descs) / sizeof(*descs); + + environ_cb(RETRO_ENVIRONMENT_SET_MEMORY_MAPS, &retromap); +} From 709e5a6e8cb3443ab1d0232771cbcbb563626948 Mon Sep 17 00:00:00 2001 From: Joshua Eagles Date: Tue, 23 Jul 2024 19:11:35 -0400 Subject: [PATCH 2/9] move retroarch memory map setup to device.c --- mupen64plus-core/src/device/device.c | 25 +++++++++++++++++++++++++ mupen64plus-core/src/main/main.c | 20 -------------------- 2 files changed, 25 insertions(+), 20 deletions(-) diff --git a/mupen64plus-core/src/device/device.c b/mupen64plus-core/src/device/device.c index f3d61282..f4974471 100644 --- a/mupen64plus-core/src/device/device.c +++ b/mupen64plus-core/src/device/device.c @@ -21,6 +21,12 @@ #include "device.h" +#include + +#ifdef __LIBRETRO__ +#include +#endif // __LIBRETRO__ + #include "memory/memory.h" #include "pif/pif.h" #include "r4300/r4300_core.h" @@ -77,6 +83,23 @@ static void get_pi_dma_handler(struct cart* cart, struct dd_controller* dd, uint #undef RW } +void setup_retroarch_memory_map(struct device* dev) { + struct retro_memory_descriptor descs[1]; + struct retro_memory_map retromap; + + memset(descs, 0, sizeof(descs)); + + descs[0].ptr = dev->rdram.dram; + descs[0].start = 0; + descs[0].len = dev->rdram.dram_size; + descs[0].flags = RETRO_MEMDESC_SYSTEM_RAM; + + retromap.descriptors = descs; + retromap.num_descriptors = sizeof(descs) / sizeof(*descs); + + environ_cb(RETRO_ENVIRONMENT_SET_MEMORY_MAPS, &retromap); +} + void init_device(struct device* dev, /* memory */ void* base, @@ -220,6 +243,8 @@ void init_device(struct device* dev, flashram_type, flashram_storage, iflashram_storage, (const uint8_t*)dev->rdram.dram, sram_storage, isram_storage); + + setup_retroarch_memory_map(dev); } void poweron_device(struct device* dev) diff --git a/mupen64plus-core/src/main/main.c b/mupen64plus-core/src/main/main.c index 72a95fee..a03494d3 100644 --- a/mupen64plus-core/src/main/main.c +++ b/mupen64plus-core/src/main/main.c @@ -1703,8 +1703,6 @@ m64p_error main_run(void) dd_rom_size, &dd_disk, dd_idisk); - setup_libretro_memory_map(); - // Attach rom to plugins failure_rval = M64ERR_PLUGIN_FAIL; if (!gfx.romOpen()) @@ -1875,21 +1873,3 @@ m64p_error close_pif(void) g_start_address = UINT32_C(0xa4000040); return M64ERR_SUCCESS; } - -void setup_libretro_memory_map() { - struct retro_memory_descriptor descs[1]; - struct retro_memory_map retromap; - - memset(descs, 0, sizeof(descs)); - - descs[0].flags = RETRO_MEMDESC_SYSTEM_RAM; - descs[0].ptr = g_dev.rdram.dram; - descs[0].start = 0; - descs[0].len = RDRAM_MAX_SIZE; - descs[0].select = 0; - - retromap.descriptors = &descs; - retromap.num_descriptors = sizeof(descs) / sizeof(*descs); - - environ_cb(RETRO_ENVIRONMENT_SET_MEMORY_MAPS, &retromap); -} From ff47bd2fd45a4a0c2c0ca48467ef63517c98ebe3 Mon Sep 17 00:00:00 2001 From: Joshua Eagles Date: Fri, 26 Jul 2024 21:03:21 -0400 Subject: [PATCH 3/9] update retroarch memory map setup to map address space properly --- mupen64plus-core/src/device/device.c | 35 +++++++++++++++++++++------- 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/mupen64plus-core/src/device/device.c b/mupen64plus-core/src/device/device.c index f4974471..efb671fe 100644 --- a/mupen64plus-core/src/device/device.c +++ b/mupen64plus-core/src/device/device.c @@ -83,19 +83,38 @@ static void get_pi_dma_handler(struct cart* cart, struct dd_controller* dd, uint #undef RW } -void setup_retroarch_memory_map(struct device* dev) { - struct retro_memory_descriptor descs[1]; +struct n64_to_retroarch_memory_map { + size_t start; + size_t len; + void* ptr; +}; + +void setup_retroarch_memory_map(struct device* dev, struct mem_mapping* m64p_mappings, size_t m64p_mapping_count) { + struct n64_to_retroarch_memory_map n64_to_retroarch_mappings[] = { + { m64p_mappings[1].begin, m64p_mappings[1].end - m64p_mappings[1].begin, dev->rdram.dram }, + { m64p_mappings[18].begin, m64p_mappings[18].end - m64p_mappings[18].begin, dev->cart.cart_rom.rom }, + }; + size_t n64_to_retroarch_mapping_count = ARRAY_SIZE(n64_to_retroarch_mappings); + + struct retro_memory_descriptor descs[n64_to_retroarch_mapping_count * 2]; struct retro_memory_map retromap; memset(descs, 0, sizeof(descs)); - descs[0].ptr = dev->rdram.dram; - descs[0].start = 0; - descs[0].len = dev->rdram.dram_size; - descs[0].flags = RETRO_MEMDESC_SYSTEM_RAM; + for (int i = 0; i < n64_to_retroarch_mapping_count; i++) { + struct n64_to_retroarch_memory_map mapping = n64_to_retroarch_mappings[i]; + + descs[i].ptr = mapping.ptr; + descs[i].start = R4300_KSEG0 + mapping.start; + descs[i].len = mapping.len; + + descs[i + n64_to_retroarch_mapping_count].ptr = mapping.ptr; + descs[i + n64_to_retroarch_mapping_count].start = R4300_KSEG1 + mapping.start; + descs[i + n64_to_retroarch_mapping_count].len = mapping.len; + } retromap.descriptors = descs; - retromap.num_descriptors = sizeof(descs) / sizeof(*descs); + retromap.num_descriptors = ARRAY_SIZE(descs); environ_cb(RETRO_ENVIRONMENT_SET_MEMORY_MAPS, &retromap); } @@ -244,7 +263,7 @@ void init_device(struct device* dev, (const uint8_t*)dev->rdram.dram, sram_storage, isram_storage); - setup_retroarch_memory_map(dev); + setup_retroarch_memory_map(dev, mappings, ARRAY_SIZE(mappings)); } void poweron_device(struct device* dev) From 3339d71ccf8e1beb40bf8760c784b27b0e525e5c Mon Sep 17 00:00:00 2001 From: Joshua Eagles Date: Fri, 26 Jul 2024 21:11:57 -0400 Subject: [PATCH 4/9] add memory map flags for the retroarch memory maps --- mupen64plus-core/src/device/device.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/mupen64plus-core/src/device/device.c b/mupen64plus-core/src/device/device.c index efb671fe..4ad96038 100644 --- a/mupen64plus-core/src/device/device.c +++ b/mupen64plus-core/src/device/device.c @@ -87,12 +87,13 @@ struct n64_to_retroarch_memory_map { size_t start; size_t len; void* ptr; + uint64_t flags; }; void setup_retroarch_memory_map(struct device* dev, struct mem_mapping* m64p_mappings, size_t m64p_mapping_count) { struct n64_to_retroarch_memory_map n64_to_retroarch_mappings[] = { - { m64p_mappings[1].begin, m64p_mappings[1].end - m64p_mappings[1].begin, dev->rdram.dram }, - { m64p_mappings[18].begin, m64p_mappings[18].end - m64p_mappings[18].begin, dev->cart.cart_rom.rom }, + { m64p_mappings[1].begin, m64p_mappings[1].end - m64p_mappings[1].begin, dev->rdram.dram, RETRO_MEMDESC_SYSTEM_RAM }, + { m64p_mappings[18].begin, m64p_mappings[18].end - m64p_mappings[18].begin, dev->cart.cart_rom.rom, RETRO_MEMDESC_CONST}, }; size_t n64_to_retroarch_mapping_count = ARRAY_SIZE(n64_to_retroarch_mappings); @@ -107,10 +108,12 @@ void setup_retroarch_memory_map(struct device* dev, struct mem_mapping* m64p_map descs[i].ptr = mapping.ptr; descs[i].start = R4300_KSEG0 + mapping.start; descs[i].len = mapping.len; + descs[i].flags = mapping.flags; descs[i + n64_to_retroarch_mapping_count].ptr = mapping.ptr; descs[i + n64_to_retroarch_mapping_count].start = R4300_KSEG1 + mapping.start; descs[i + n64_to_retroarch_mapping_count].len = mapping.len; + descs[i + n64_to_retroarch_mapping_count].flags = mapping.flags; } retromap.descriptors = descs; From 18203f18fb5912a37eed37c8add47b0d79e88a41 Mon Sep 17 00:00:00 2001 From: Joshua Eagles Date: Thu, 1 Aug 2024 19:52:12 -0400 Subject: [PATCH 5/9] refactor to map the entirety of KSEG0 and KSEG1 --- mupen64plus-core/src/device/device.c | 50 ++++++++++++++++++++++++---- 1 file changed, 44 insertions(+), 6 deletions(-) diff --git a/mupen64plus-core/src/device/device.c b/mupen64plus-core/src/device/device.c index 4ad96038..bc312be6 100644 --- a/mupen64plus-core/src/device/device.c +++ b/mupen64plus-core/src/device/device.c @@ -87,16 +87,48 @@ struct n64_to_retroarch_memory_map { size_t start; size_t len; void* ptr; + bool isAccessibleCached; uint64_t flags; }; void setup_retroarch_memory_map(struct device* dev, struct mem_mapping* m64p_mappings, size_t m64p_mapping_count) { +#define BeginEndToBeginLength(begin, end) begin, end - begin struct n64_to_retroarch_memory_map n64_to_retroarch_mappings[] = { - { m64p_mappings[1].begin, m64p_mappings[1].end - m64p_mappings[1].begin, dev->rdram.dram, RETRO_MEMDESC_SYSTEM_RAM }, - { m64p_mappings[18].begin, m64p_mappings[18].end - m64p_mappings[18].begin, dev->cart.cart_rom.rom, RETRO_MEMDESC_CONST}, + { BeginEndToBeginLength(m64p_mappings[1].begin, m64p_mappings[1].end), dev->rdram.dram, true, RETRO_MEMDESC_SYSTEM_RAM }, + { BeginEndToBeginLength(m64p_mappings[2].begin, m64p_mappings[2].end), dev->rdram.regs, false }, + { BeginEndToBeginLength(m64p_mappings[3].begin, m64p_mappings[3].end), dev->sp.mem, false }, + { BeginEndToBeginLength(m64p_mappings[4].begin, m64p_mappings[4].end), dev->sp.regs, false }, + { BeginEndToBeginLength(m64p_mappings[5].begin, m64p_mappings[5].end), dev->sp.regs2, false }, + { BeginEndToBeginLength(m64p_mappings[6].begin, m64p_mappings[6].end), dev->dp.dpc_regs, false }, + { BeginEndToBeginLength(m64p_mappings[7].begin, m64p_mappings[7].end), dev->dp.dps_regs, false }, + { BeginEndToBeginLength(m64p_mappings[8].begin, m64p_mappings[8].end), dev->mi.regs, false }, + { BeginEndToBeginLength(m64p_mappings[9].begin, m64p_mappings[9].end), dev->vi.regs, false }, + { BeginEndToBeginLength(m64p_mappings[10].begin, m64p_mappings[10].end), dev->ai.regs, false }, + { BeginEndToBeginLength(m64p_mappings[11].begin, m64p_mappings[11].end), dev->pi.regs, false }, + { BeginEndToBeginLength(m64p_mappings[12].begin, m64p_mappings[12].end), dev->ri.regs, false }, + { BeginEndToBeginLength(m64p_mappings[13].begin, m64p_mappings[13].end), dev->si.regs, false }, + { BeginEndToBeginLength(m64p_mappings[14].begin, m64p_mappings[14].end), NULL, false }, + { BeginEndToBeginLength(m64p_mappings[15].begin, m64p_mappings[15].end), NULL, false, RETRO_MEMDESC_CONST }, + { BeginEndToBeginLength(m64p_mappings[16].begin, m64p_mappings[16].end), NULL, false }, + { BeginEndToBeginLength(m64p_mappings[18].begin, m64p_mappings[18].end), dev->cart.cart_rom.rom, false, RETRO_MEMDESC_CONST }, + { m64p_mappings[19].begin, PIF_ROM_SIZE, dev->pif.base, false, RETRO_MEMDESC_CONST }, + { m64p_mappings[19].begin + PIF_ROM_SIZE, PIF_RAM_SIZE, dev->pif.ram, false }, }; size_t n64_to_retroarch_mapping_count = ARRAY_SIZE(n64_to_retroarch_mappings); + if (m64p_mappings[14].handler.opaque != NULL) { + n64_to_retroarch_mappings[13].ptr = &dev->dd.regs; + n64_to_retroarch_mappings[14].ptr = &dev->dd.rom; + } + + if (dev->cart.use_flashram == -1) { + n64_to_retroarch_mappings[15].ptr = &dev->cart.sram; + } + else { + n64_to_retroarch_mappings[14].ptr = &dev->cart.flashram; + } +#undef BeginEndToBeginLength + struct retro_memory_descriptor descs[n64_to_retroarch_mapping_count * 2]; struct retro_memory_map retromap; @@ -105,10 +137,16 @@ void setup_retroarch_memory_map(struct device* dev, struct mem_mapping* m64p_map for (int i = 0; i < n64_to_retroarch_mapping_count; i++) { struct n64_to_retroarch_memory_map mapping = n64_to_retroarch_mappings[i]; - descs[i].ptr = mapping.ptr; - descs[i].start = R4300_KSEG0 + mapping.start; - descs[i].len = mapping.len; - descs[i].flags = mapping.flags; + if (mapping.ptr == NULL) { + continue; + } + + if (mapping.isAccessibleCached) { + descs[i].ptr = mapping.ptr; + descs[i].start = R4300_KSEG0 + mapping.start; + descs[i].len = mapping.len; + descs[i].flags = mapping.flags; + } descs[i + n64_to_retroarch_mapping_count].ptr = mapping.ptr; descs[i + n64_to_retroarch_mapping_count].start = R4300_KSEG1 + mapping.start; From 55f3802b1db63c5571ddfa3bab68730761e1747f Mon Sep 17 00:00:00 2001 From: Joshua Eagles Date: Fri, 2 Aug 2024 12:56:57 -0400 Subject: [PATCH 6/9] finish mapping the whole KSEG1 address space and improve code readability --- mupen64plus-core/src/device/device.c | 48 +++++++++++++--------------- 1 file changed, 23 insertions(+), 25 deletions(-) diff --git a/mupen64plus-core/src/device/device.c b/mupen64plus-core/src/device/device.c index bc312be6..fb800017 100644 --- a/mupen64plus-core/src/device/device.c +++ b/mupen64plus-core/src/device/device.c @@ -91,32 +91,31 @@ struct n64_to_retroarch_memory_map { uint64_t flags; }; -void setup_retroarch_memory_map(struct device* dev, struct mem_mapping* m64p_mappings, size_t m64p_mapping_count) { -#define BeginEndToBeginLength(begin, end) begin, end - begin +void setup_retroarch_memory_map(struct device* dev, size_t rom_size, size_t dd_rom_size) { struct n64_to_retroarch_memory_map n64_to_retroarch_mappings[] = { - { BeginEndToBeginLength(m64p_mappings[1].begin, m64p_mappings[1].end), dev->rdram.dram, true, RETRO_MEMDESC_SYSTEM_RAM }, - { BeginEndToBeginLength(m64p_mappings[2].begin, m64p_mappings[2].end), dev->rdram.regs, false }, - { BeginEndToBeginLength(m64p_mappings[3].begin, m64p_mappings[3].end), dev->sp.mem, false }, - { BeginEndToBeginLength(m64p_mappings[4].begin, m64p_mappings[4].end), dev->sp.regs, false }, - { BeginEndToBeginLength(m64p_mappings[5].begin, m64p_mappings[5].end), dev->sp.regs2, false }, - { BeginEndToBeginLength(m64p_mappings[6].begin, m64p_mappings[6].end), dev->dp.dpc_regs, false }, - { BeginEndToBeginLength(m64p_mappings[7].begin, m64p_mappings[7].end), dev->dp.dps_regs, false }, - { BeginEndToBeginLength(m64p_mappings[8].begin, m64p_mappings[8].end), dev->mi.regs, false }, - { BeginEndToBeginLength(m64p_mappings[9].begin, m64p_mappings[9].end), dev->vi.regs, false }, - { BeginEndToBeginLength(m64p_mappings[10].begin, m64p_mappings[10].end), dev->ai.regs, false }, - { BeginEndToBeginLength(m64p_mappings[11].begin, m64p_mappings[11].end), dev->pi.regs, false }, - { BeginEndToBeginLength(m64p_mappings[12].begin, m64p_mappings[12].end), dev->ri.regs, false }, - { BeginEndToBeginLength(m64p_mappings[13].begin, m64p_mappings[13].end), dev->si.regs, false }, - { BeginEndToBeginLength(m64p_mappings[14].begin, m64p_mappings[14].end), NULL, false }, - { BeginEndToBeginLength(m64p_mappings[15].begin, m64p_mappings[15].end), NULL, false, RETRO_MEMDESC_CONST }, - { BeginEndToBeginLength(m64p_mappings[16].begin, m64p_mappings[16].end), NULL, false }, - { BeginEndToBeginLength(m64p_mappings[18].begin, m64p_mappings[18].end), dev->cart.cart_rom.rom, false, RETRO_MEMDESC_CONST }, - { m64p_mappings[19].begin, PIF_ROM_SIZE, dev->pif.base, false, RETRO_MEMDESC_CONST }, - { m64p_mappings[19].begin + PIF_ROM_SIZE, PIF_RAM_SIZE, dev->pif.ram, false }, + { MM_RDRAM_DRAM, 0x3efffff, dev->rdram.dram, true, RETRO_MEMDESC_SYSTEM_RAM }, + { MM_RDRAM_REGS, 0xfffff, dev->rdram.regs, false }, + { MM_RSP_MEM, 0xffff, dev->sp.mem, false }, + { MM_RSP_REGS, 0xffff, dev->sp.regs, false }, + { MM_RSP_REGS2, 0xffff, dev->sp.regs2, false }, + { MM_DPC_REGS, 0xffff, dev->dp.dpc_regs, false }, + { MM_DPS_REGS, 0xffff, dev->dp.dps_regs, false }, + { MM_MI_REGS, 0xffff, dev->mi.regs, false }, + { MM_VI_REGS, 0xffff, dev->vi.regs, false }, + { MM_AI_REGS, 0xffff, dev->ai.regs, false }, + { MM_PI_REGS, 0xffff, dev->pi.regs, false }, + { MM_RI_REGS, 0xffff, dev->ri.regs, false }, + { MM_SI_REGS, 0xffff, dev->si.regs, false }, + { MM_DOM2_ADDR1, 0xffffff, NULL, false }, + { MM_DD_ROM, 0x1ffffff, NULL, false, RETRO_MEMDESC_CONST }, + { MM_DOM2_ADDR2, 0x1ffff, NULL, false }, + { MM_CART_ROM, rom_size - 1, dev->cart.cart_rom.rom, false, RETRO_MEMDESC_CONST }, + { MM_PIF_MEM, PIF_ROM_SIZE, dev->pif.base, false, RETRO_MEMDESC_CONST }, + { MM_PIF_MEM + PIF_ROM_SIZE, PIF_RAM_SIZE, dev->pif.ram, false }, }; size_t n64_to_retroarch_mapping_count = ARRAY_SIZE(n64_to_retroarch_mappings); - if (m64p_mappings[14].handler.opaque != NULL) { + if (dd_rom_size > 0) { n64_to_retroarch_mappings[13].ptr = &dev->dd.regs; n64_to_retroarch_mappings[14].ptr = &dev->dd.rom; } @@ -125,9 +124,8 @@ void setup_retroarch_memory_map(struct device* dev, struct mem_mapping* m64p_map n64_to_retroarch_mappings[15].ptr = &dev->cart.sram; } else { - n64_to_retroarch_mappings[14].ptr = &dev->cart.flashram; + n64_to_retroarch_mappings[15].ptr = &dev->cart.flashram; } -#undef BeginEndToBeginLength struct retro_memory_descriptor descs[n64_to_retroarch_mapping_count * 2]; struct retro_memory_map retromap; @@ -304,7 +302,7 @@ void init_device(struct device* dev, (const uint8_t*)dev->rdram.dram, sram_storage, isram_storage); - setup_retroarch_memory_map(dev, mappings, ARRAY_SIZE(mappings)); + setup_retroarch_memory_map(dev, rom_size, dd_rom_size); } void poweron_device(struct device* dev) From 208d403ca682072abeb76bea39ec7f12197d5077 Mon Sep 17 00:00:00 2001 From: Joshua Eagles Date: Fri, 2 Aug 2024 13:30:36 -0400 Subject: [PATCH 7/9] remove the -1 for the romsize mapping --- mupen64plus-core/src/device/device.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mupen64plus-core/src/device/device.c b/mupen64plus-core/src/device/device.c index fb800017..09abca7f 100644 --- a/mupen64plus-core/src/device/device.c +++ b/mupen64plus-core/src/device/device.c @@ -109,7 +109,7 @@ void setup_retroarch_memory_map(struct device* dev, size_t rom_size, size_t dd_r { MM_DOM2_ADDR1, 0xffffff, NULL, false }, { MM_DD_ROM, 0x1ffffff, NULL, false, RETRO_MEMDESC_CONST }, { MM_DOM2_ADDR2, 0x1ffff, NULL, false }, - { MM_CART_ROM, rom_size - 1, dev->cart.cart_rom.rom, false, RETRO_MEMDESC_CONST }, + { MM_CART_ROM, rom_size, dev->cart.cart_rom.rom, false, RETRO_MEMDESC_CONST }, { MM_PIF_MEM, PIF_ROM_SIZE, dev->pif.base, false, RETRO_MEMDESC_CONST }, { MM_PIF_MEM + PIF_ROM_SIZE, PIF_RAM_SIZE, dev->pif.ram, false }, }; From c6d20425a0c4b67d57d5e598e85dc1ced1fb2bc4 Mon Sep 17 00:00:00 2001 From: Joshua Eagles Date: Fri, 2 Aug 2024 13:40:48 -0400 Subject: [PATCH 8/9] set dd_rom_size when setting the pointer for it --- mupen64plus-core/src/device/device.c | 1 + 1 file changed, 1 insertion(+) diff --git a/mupen64plus-core/src/device/device.c b/mupen64plus-core/src/device/device.c index 09abca7f..f0a80426 100644 --- a/mupen64plus-core/src/device/device.c +++ b/mupen64plus-core/src/device/device.c @@ -118,6 +118,7 @@ void setup_retroarch_memory_map(struct device* dev, size_t rom_size, size_t dd_r if (dd_rom_size > 0) { n64_to_retroarch_mappings[13].ptr = &dev->dd.regs; n64_to_retroarch_mappings[14].ptr = &dev->dd.rom; + n64_to_retroarch_mappings[14].len = dd_rom_size; } if (dev->cart.use_flashram == -1) { From b5d7ca777e6e95507438956cf9c15f179f998d5a Mon Sep 17 00:00:00 2001 From: Joshua Eagles Date: Fri, 2 Aug 2024 13:55:27 -0400 Subject: [PATCH 9/9] fix pointers to dd regs and rom --- mupen64plus-core/src/device/device.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mupen64plus-core/src/device/device.c b/mupen64plus-core/src/device/device.c index f0a80426..194029bd 100644 --- a/mupen64plus-core/src/device/device.c +++ b/mupen64plus-core/src/device/device.c @@ -116,8 +116,8 @@ void setup_retroarch_memory_map(struct device* dev, size_t rom_size, size_t dd_r size_t n64_to_retroarch_mapping_count = ARRAY_SIZE(n64_to_retroarch_mappings); if (dd_rom_size > 0) { - n64_to_retroarch_mappings[13].ptr = &dev->dd.regs; - n64_to_retroarch_mappings[14].ptr = &dev->dd.rom; + n64_to_retroarch_mappings[13].ptr = dev->dd.regs; + n64_to_retroarch_mappings[14].ptr = dev->dd.rom; n64_to_retroarch_mappings[14].len = dd_rom_size; }