From 116eeb35d4a622418eaeb9eae5531c5cc18e3384 Mon Sep 17 00:00:00 2001 From: Rosalie Wanders Date: Thu, 9 Jan 2025 13:42:58 +0100 Subject: [PATCH] 3rdParty: apply experimental rom size patch to mupen64plus-core --- Source/3rdParty/mupen64plus-core/src/device/cart/cart_rom.c | 2 +- Source/3rdParty/mupen64plus-core/src/device/device.c | 5 +++-- Source/3rdParty/mupen64plus-core/src/device/gb/m64282fp.c | 4 +--- Source/3rdParty/mupen64plus-core/src/device/memory/memory.c | 2 +- Source/3rdParty/mupen64plus-core/src/device/memory/memory.h | 2 +- Source/3rdParty/mupen64plus-core/src/main/util.h | 3 +++ 6 files changed, 10 insertions(+), 8 deletions(-) diff --git a/Source/3rdParty/mupen64plus-core/src/device/cart/cart_rom.c b/Source/3rdParty/mupen64plus-core/src/device/cart/cart_rom.c index 86657df1f..c9da76805 100644 --- a/Source/3rdParty/mupen64plus-core/src/device/cart/cart_rom.c +++ b/Source/3rdParty/mupen64plus-core/src/device/cart/cart_rom.c @@ -32,7 +32,7 @@ #define __STDC_FORMAT_MACROS #include -#define CART_ROM_ADDR_MASK UINT32_C(0x03ffffff); +#define CART_ROM_ADDR_MASK UINT32_C(0xefffffff); void init_cart_rom(struct cart_rom* cart_rom, diff --git a/Source/3rdParty/mupen64plus-core/src/device/device.c b/Source/3rdParty/mupen64plus-core/src/device/device.c index f3d612822..2487ef4f7 100644 --- a/Source/3rdParty/mupen64plus-core/src/device/device.c +++ b/Source/3rdParty/mupen64plus-core/src/device/device.c @@ -21,6 +21,7 @@ #include "device.h" +#include "main/util.h" #include "memory/memory.h" #include "pif/pif.h" #include "r4300/r4300_core.h" @@ -57,7 +58,7 @@ static void get_pi_dma_handler(struct cart* cart, struct dd_controller* dd, uint if (address >= MM_CART_ROM) { if (address >= MM_CART_DOM3) { - /* 0x1fd00000 - 0x7fffffff : dom3 addr2, cart rom (Paper Mario (U)) ??? */ + /* 0x1fd00000 - 0xffffffff : dom3 addr2, cart rom */ RW(cart, cart_dom3); } else { @@ -155,7 +156,7 @@ void init_device(struct device* dev, { A(MM_DD_ROM, 0x1ffffff), M64P_MEM_NOTHING, { NULL, RW(open_bus) } }, { A(MM_DOM2_ADDR2, 0x1ffff), M64P_MEM_FLASHRAMSTAT, { &dev->cart, RW(cart_dom2) } }, { A(MM_IS_VIEWER, 0xfff), M64P_MEM_NOTHING, { &dev->is, RW(is_viewer) } }, - { A(MM_CART_ROM, rom_size-1), M64P_MEM_ROM, { &dev->cart.cart_rom, RW(cart_rom) } }, + { A(MM_CART_ROM, min(rom_size-1, 0x3ffffff)), M64P_MEM_ROM, { &dev->cart.cart_rom, RW(cart_rom) } }, { A(MM_PIF_MEM, 0xffff), M64P_MEM_PIF, { &dev->pif, RW(pif_mem) } } }; diff --git a/Source/3rdParty/mupen64plus-core/src/device/gb/m64282fp.c b/Source/3rdParty/mupen64plus-core/src/device/gb/m64282fp.c index 8605c986c..78903b654 100644 --- a/Source/3rdParty/mupen64plus-core/src/device/gb/m64282fp.c +++ b/Source/3rdParty/mupen64plus-core/src/device/gb/m64282fp.c @@ -24,12 +24,10 @@ */ #include "m64282fp.h" +#include "main/util.h" #include -int min(int a, int b) { return (a < b) ? a : b; } -int max(int a, int b) { return (a < b) ? b : a; } - int clamp(int v, int low, int high) { return min(high, max(low, v)); diff --git a/Source/3rdParty/mupen64plus-core/src/device/memory/memory.c b/Source/3rdParty/mupen64plus-core/src/device/memory/memory.c index 38eee8e90..7e71a2802 100644 --- a/Source/3rdParty/mupen64plus-core/src/device/memory/memory.c +++ b/Source/3rdParty/mupen64plus-core/src/device/memory/memory.c @@ -227,7 +227,7 @@ enum { MB_DD_ROM = MB_RSP_MEM + SP_MEM_SIZE, MB_PIF_MEM = MB_DD_ROM + DD_ROM_MAX_SIZE, MB_MAX_SIZE = MB_PIF_MEM + PIF_ROM_SIZE + PIF_RAM_SIZE, - MB_MAX_SIZE_FULL = 0x20000000 + MB_MAX_SIZE_FULL = 0x120000000, }; /* Use LSB of mem_base pointer to encode mem_base mode diff --git a/Source/3rdParty/mupen64plus-core/src/device/memory/memory.h b/Source/3rdParty/mupen64plus-core/src/device/memory/memory.h index 7cb02e256..4dc9121cb 100644 --- a/Source/3rdParty/mupen64plus-core/src/device/memory/memory.h +++ b/Source/3rdParty/mupen64plus-core/src/device/memory/memory.h @@ -28,7 +28,7 @@ #include "osal/preproc.h" enum { RDRAM_MAX_SIZE = 0x800000 }; -enum { CART_ROM_MAX_SIZE = 0x4000000 }; +enum { CART_ROM_MAX_SIZE = 0x100000000 }; enum { DD_ROM_MAX_SIZE = 0x400000 }; typedef void (*read32fn)(void*,uint32_t,uint32_t*); diff --git a/Source/3rdParty/mupen64plus-core/src/main/util.h b/Source/3rdParty/mupen64plus-core/src/main/util.h index f66e24bb1..ae88469e2 100644 --- a/Source/3rdParty/mupen64plus-core/src/main/util.h +++ b/Source/3rdParty/mupen64plus-core/src/main/util.h @@ -185,6 +185,9 @@ struct xoshiro256pp_state xoshiro256pp_seed(uint64_t seed); uint64_t xoshiro256pp_next(struct xoshiro256pp_state* s); +#define min(a, b) ((a < b) ? a : b) +#define max(a, b) ((a < b) ? b : a) + /********************** GUI utilities **********************/