From 816bb4c42643258ee2d754dd40bd4d1d55f9d2df Mon Sep 17 00:00:00 2001 From: Rosalie Wanders Date: Sun, 28 Sep 2025 08:13:04 +0200 Subject: [PATCH] 3rdParty: include rsp state in save states in mupen64plus-core --- .../mupen64plus-core/src/main/savestates.c | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/Source/3rdParty/mupen64plus-core/src/main/savestates.c b/Source/3rdParty/mupen64plus-core/src/main/savestates.c index b29c9f3d..9a920d5c 100644 --- a/Source/3rdParty/mupen64plus-core/src/main/savestates.c +++ b/Source/3rdParty/mupen64plus-core/src/main/savestates.c @@ -63,7 +63,7 @@ enum { GB_CART_FINGERPRINT_OFFSET = 0x134 }; enum { DD_DISK_ID_OFFSET = 0x43670 }; static const char* savestate_magic = "M64+SAVE"; -static const int savestate_latest_version = 0x00010900; /* 1.9 */ +static const int savestate_latest_version = 0x00020000; /* 2.0 */ static const unsigned char pj64_magic[4] = { 0xC8, 0xA6, 0xD8, 0x23 }; static savestates_job job = savestates_job_nothing; @@ -887,6 +887,14 @@ static int savestates_load_m64p(struct device* dev, char *filepath) *r4300_cp0_latch(&dev->r4300.cp0) = GETDATA(curr, uint64_t); *r4300_cp2_latch(&dev->r4300.cp2) = GETDATA(curr, uint64_t); } + + if (version >= 0x00020000) + { + /* extra rsp state */ + dev->sp.rsp_status = GETDATA(curr, uint32_t); + dev->sp.first_run = GETDATA(curr, uint32_t); + dev->sp.rsp_wait = GETDATA(curr, uint32_t); + } } else { @@ -958,9 +966,6 @@ static int savestates_load_m64p(struct device* dev, char *filepath) /* reset fb state */ poweron_fb(&dev->dp.fb); - dev->sp.rsp_status = 0; - dev->sp.rsp_wait = 0; - dev->sp.first_run = 1; dev->r4300.cp0.interrupt_unsafe_state = 0; *r4300_cp0_last_addr(&dev->r4300.cp0) = *r4300_pc(&dev->r4300); @@ -1264,9 +1269,6 @@ static int savestates_load_pj64(struct device* dev, // No flashram info in pj64 savestate. poweron_flashram(&dev->cart.flashram); - dev->sp.rsp_status = 0; - dev->sp.rsp_wait = 0; - dev->sp.first_run = 1; dev->r4300.cp0.interrupt_unsafe_state = 0; /* extra fb state */ @@ -1928,6 +1930,11 @@ static int savestates_save_m64p(const struct device* dev, char *filepath) PUTDATA(curr, uint64_t, *r4300_cp0_latch((struct cp0*)&dev->r4300.cp0)); PUTDATA(curr, uint64_t, *r4300_cp2_latch((struct cp2*)&dev->r4300.cp2)); + /* rsp state (since 2.0) */ + PUTDATA(curr, uint32_t, dev->sp.rsp_status); + PUTDATA(curr, uint32_t, dev->sp.first_run); + PUTDATA(curr, uint32_t, dev->sp.rsp_wait); + init_work(&save->work, savestates_save_m64p_work); queue_work(&save->work);