From de6a43bd2104c84d3909379362663ac1ed57b52e Mon Sep 17 00:00:00 2001 From: Flyinghead Date: Tue, 16 Apr 2024 09:40:55 +0200 Subject: [PATCH] savestate: drop support for legacy libretro and > VREG; deser >> ARMRST; deser >> rtc_EN; - if (deser.version() >= Deserializer::V9) - deser >> RealTimeClock; + deser >> RealTimeClock; deser >> aica_reg; diff --git a/core/hw/flashrom/nvmem.cpp b/core/hw/flashrom/nvmem.cpp index d6c61b02a5..e6cfa0d502 100644 --- a/core/hw/flashrom/nvmem.cpp +++ b/core/hw/flashrom/nvmem.cpp @@ -76,8 +76,7 @@ static void add_isp_to_nvmem(DCFlashChip *flash) for (u32 i = FLASH_USER_INET + 5; i <= 0xbf; i++) flash->WriteBlock(FLASH_PT_USER, i, block); - flash_isp1_block isp1; - memset(&isp1, 0, sizeof(isp1)); + flash_isp1_block isp1{}; isp1._unknown[3] = 1; memcpy(isp1.sega, "SEGA", 4); strcpy(isp1.username, "flycast1"); @@ -96,8 +95,7 @@ static void add_isp_to_nvmem(DCFlashChip *flash) block[60] = 1; flash->WriteBlock(FLASH_PT_USER, FLASH_USER_ISP1 + 5, block); - flash_isp2_block isp2; - memset(&isp2, 0, sizeof(isp2)); + flash_isp2_block isp2{}; memcpy(isp2.sega, "SEGA", 4); strcpy(isp2.username, "flycast2"); strcpy(isp2.password, "password"); @@ -373,36 +371,8 @@ void serialize(Serializer& ser) void deserialize(Deserializer& deser) { - if (deser.version() <= Deserializer::VLAST_LIBRETRO) - { - deser.skip(); // size - deser.skip(); // mask - - // Legacy libretro savestate - if (settings.platform.isArcade()) - sys_nvmem->Deserialize(deser); - - deser.skip(); // sys_nvmem/sys_rom->size - deser.skip(); // sys_nvmem/sys_rom->mask - if (settings.platform.isConsole()) - { - sys_nvmem->Deserialize(deser); - } - else if (settings.platform.isAtomiswave()) - { - deser >> static_cast(sys_rom)->state; - deser.deserialize(sys_rom->data, sys_rom->size); - } - else - { - deser.skip(); - } - } - else - { - sys_rom->Deserialize(deser); - sys_nvmem->Deserialize(deser); - } + sys_rom->Deserialize(deser); + sys_nvmem->Deserialize(deser); } } diff --git a/core/hw/gdrom/gdromv3.cpp b/core/hw/gdrom/gdromv3.cpp index a32b4f527a..1a29572ea5 100644 --- a/core/hw/gdrom/gdromv3.cpp +++ b/core/hw/gdrom/gdromv3.cpp @@ -1412,8 +1412,6 @@ void deserialize(Deserializer& deser) deser.skip(Deserializer::V44); // set_mode_offset (repeat) deser >> ata_cmd; deser >> cdda; - if (deser.version() < Deserializer::V10) - cdda.status = (bool)cdda.status ? cdda_t::Playing : cdda_t::NoInfo; deser >> gd_state; deser >> gd_disk_type; deser >> data_write_mode; @@ -1426,8 +1424,6 @@ void deserialize(Deserializer& deser) deser >> SecNumber; deser >> GDStatus; deser >> ByteCount; - if (deser.version() <= Deserializer::VLAST_LIBRETRO) - deser.skip(); // GDROM_TICK } } diff --git a/core/hw/holly/sb.cpp b/core/hw/holly/sb.cpp index 12e4c5a8cb..49e47b1df4 100644 --- a/core/hw/holly/sb.cpp +++ b/core/hw/holly/sb.cpp @@ -704,18 +704,7 @@ void sb_serialize(Serializer& ser) void sb_deserialize(Deserializer& deser) { - if (deser.version() <= Deserializer::VLAST_LIBRETRO) - { - for (u32& reg : sb_regs) - { - deser.skip(); // regs.data[i].flags - deser >> reg; - } - } - else - { - deser >> sb_regs; - } + deser >> sb_regs; if (deser.version() < Deserializer::V33) deser >> SB_ISTNRM; if (deser.version() >= Deserializer::V24) @@ -729,9 +718,6 @@ void sb_deserialize(Deserializer& deser) deser.skip(); // SB_FFST_rc; deser.skip(); // SB_FFST; } - if (deser.version() >= Deserializer::V15) - deser >> SB_ADST; - else - SB_ADST = 0; + deser >> SB_ADST; } } diff --git a/core/hw/maple/maple_devs.h b/core/hw/maple/maple_devs.h index 284d11a7c3..7f97e5af47 100755 --- a/core/hw/maple/maple_devs.h +++ b/core/hw/maple/maple_devs.h @@ -142,8 +142,7 @@ struct maple_device ser << player_num; } virtual void deserialize(Deserializer& deser) { - if (deser.version() >= Deserializer::V14) - deser >> player_num; + deser >> player_num; } virtual MapleDeviceType get_device_type() = 0; diff --git a/core/hw/naomi/naomi.cpp b/core/hw/naomi/naomi.cpp index 8e51c5993f..36b705eb0e 100644 --- a/core/hw/naomi/naomi.cpp +++ b/core/hw/naomi/naomi.cpp @@ -409,10 +409,7 @@ void naomi_Deserialize(Deserializer& deser) deser.skip(); // reg_dimm_parameterh; deser.skip(); // reg_dimm_status; } - if (deser.version() < Deserializer::V11) - deser.skip(); - else if (deser.version() >= Deserializer::V14) - deser >> aw_maple_devs; + deser >> aw_maple_devs; if (deser.version() >= Deserializer::V20) { deser >> coin_chute_time; diff --git a/core/hw/naomi/naomi_cart.cpp b/core/hw/naomi/naomi_cart.cpp index a2978a9ea0..ce9af41d00 100644 --- a/core/hw/naomi/naomi_cart.cpp +++ b/core/hw/naomi/naomi_cart.cpp @@ -777,7 +777,7 @@ void naomi_cart_serialize(Serializer& ser) void naomi_cart_deserialize(Deserializer& deser) { - if (CurrentCartridge != nullptr && (!settings.platform.isAtomiswave() || deser.version() >= Deserializer::V10_LIBRETRO)) + if (CurrentCartridge != nullptr) CurrentCartridge->Deserialize(deser); touchscreen::deserialize(deser); printer::deserialize(deser); diff --git a/core/hw/pvr/Renderer_if.cpp b/core/hw/pvr/Renderer_if.cpp index aa2b51442a..86ce77c7d7 100644 --- a/core/hw/pvr/Renderer_if.cpp +++ b/core/hw/pvr/Renderer_if.cpp @@ -536,11 +536,7 @@ void rend_serialize(Serializer& ser) } void rend_deserialize(Deserializer& deser) { - if ((deser.version() >= Deserializer::V12_LIBRETRO && deser.version() <= Deserializer::VLAST_LIBRETRO) - || deser.version() >= Deserializer::V12) - deser >> fb_w_cur; - else - fb_w_cur = 1; + deser >> fb_w_cur; if (deser.version() >= Deserializer::V20) { deser >> render_called; diff --git a/core/hw/pvr/pvr.cpp b/core/hw/pvr/pvr.cpp index 79478de0b2..22bead33e1 100644 --- a/core/hw/pvr/pvr.cpp +++ b/core/hw/pvr/pvr.cpp @@ -104,8 +104,7 @@ void deserialize(Deserializer& deser) deser >> taRenderPass; else taRenderPass = 0; - if (deser.version() >= Deserializer::V11 || (deser.version() >= Deserializer::V10_LIBRETRO && deser.version() <= Deserializer::VLAST_LIBRETRO)) - DeserializeTAContext(deser); + DeserializeTAContext(deser); if (!deser.rollback()) vram.deserialize(deser); diff --git a/core/hw/pvr/pvr_mem.cpp b/core/hw/pvr/pvr_mem.cpp index aafc3c62e0..a45c88870e 100644 --- a/core/hw/pvr/pvr_mem.cpp +++ b/core/hw/pvr/pvr_mem.cpp @@ -190,10 +190,7 @@ void YUV_deserialize(Deserializer& deser) deser >> YUV_y_curr; deser >> YUV_x_size; deser >> YUV_y_size; - if (deser.version() >= Deserializer::V16) - deser >> YUV_index; - else - YUV_index = 0; + deser >> YUV_index; } void YUV_reset() diff --git a/core/hw/pvr/spg.cpp b/core/hw/pvr/spg.cpp index 6cdc5bec0c..5fd93bc86e 100755 --- a/core/hw/pvr/spg.cpp +++ b/core/hw/pvr/spg.cpp @@ -315,19 +315,11 @@ void spg_Deserialize(Deserializer& deser) if (deser.version() < Deserializer::V30) deser.skip(); // in_vblank deser >> clc_pvr_scanline; - if (deser.version() >= Deserializer::V12) - { - deser >> maple_int_pending; - if (deser.version() >= Deserializer::V14) - { - deser >> pvr_numscanlines; - deser >> prv_cur_scanline; - deser >> Line_Cycles; - deser >> Frame_Cycles; - deser >> lightgun_line; - deser >> lightgun_hpos; - } - } - if (deser.version() < Deserializer::V14) - CalculateSync(); + deser >> maple_int_pending; + deser >> pvr_numscanlines; + deser >> prv_cur_scanline; + deser >> Line_Cycles; + deser >> Frame_Cycles; + deser >> lightgun_line; + deser >> lightgun_hpos; } diff --git a/core/hw/pvr/ta_ctx.cpp b/core/hw/pvr/ta_ctx.cpp index 58c23d0d1f..dd64b05a44 100644 --- a/core/hw/pvr/ta_ctx.cpp +++ b/core/hw/pvr/ta_ctx.cpp @@ -249,8 +249,7 @@ static void deserializeContext(Deserializer& deser, TA_context **pctx) tad_context& tad = (*pctx)->tad; deser.deserialize(tad.thd_root, size); tad.thd_data = tad.thd_root + size; - if ((deser.version() >= Deserializer::V12 && deser.version() < Deserializer::V26) - || (deser.version() >= Deserializer::V12_LIBRETRO && deser.version() <= Deserializer::VLAST_LIBRETRO)) + if (deser.version() < Deserializer::V26) { u32 render_pass_count; deser >> render_pass_count; diff --git a/core/hw/sh4/modules/mmu.cpp b/core/hw/sh4/modules/mmu.cpp index 54ec72d51d..483125fbb3 100644 --- a/core/hw/sh4/modules/mmu.cpp +++ b/core/hw/sh4/modules/mmu.cpp @@ -591,8 +591,6 @@ void mmu_deserialize(Deserializer& deser) deser >> UTLB; deser >> ITLB; - if (deser.version() >= Deserializer::V11 - || (deser.version() >= Deserializer::V11_LIBRETRO && deser.version() <= Deserializer::VLAST_LIBRETRO)) - deser >> sq_remap; + deser >> sq_remap; deser.skip(64 * 4, Deserializer::V23); // ITLB_LRU_USE } diff --git a/core/hw/sh4/sh4_mmr.cpp b/core/hw/sh4/sh4_mmr.cpp index 5d1579830c..5372003a04 100644 --- a/core/hw/sh4/sh4_mmr.cpp +++ b/core/hw/sh4/sh4_mmr.cpp @@ -692,59 +692,24 @@ void serialize(Serializer& ser) sh4_sched_serialize(ser); } -template -static void register_deserialize_libretro(T& regs, Deserializer& deser) -{ - for (auto& reg : regs) - { - deser.skip(); // regs.data[i].flags - deser >> reg; - } -} - void deserialize(Deserializer& deser) { deser >> OnChipRAM; - if (deser.version() <= Deserializer::VLAST_LIBRETRO) - { - register_deserialize_libretro(CCN, deser); - register_deserialize_libretro(UBC, deser); - register_deserialize_libretro(BSC, deser); - register_deserialize_libretro(DMAC, deser); - register_deserialize_libretro(CPG, deser); - register_deserialize_libretro(RTC, deser); - register_deserialize_libretro(INTC, deser); - register_deserialize_libretro(TMU, deser); - register_deserialize_libretro(SCI, deser); - register_deserialize_libretro(SCIF, deser); - } - else - { - deser >> CCN; - deser >> UBC; - deser >> BSC; - deser >> DMAC; - deser >> CPG; - deser >> RTC; - deser >> INTC; - deser >> TMU; - deser >> SCI; - deser >> SCIF; - } + deser >> CCN; + deser >> UBC; + deser >> BSC; + deser >> DMAC; + deser >> CPG; + deser >> RTC; + deser >> INTC; + deser >> TMU; + deser >> SCI; + deser >> SCIF; + SCIFSerialPort::Instance().deserialize(deser); - if (deser.version() >= Deserializer::V9 - // Note (lr): was added in V11 fa49de29 24/12/2020 but ver not updated until V12 (13/4/2021) - || (deser.version() >= Deserializer::V11_LIBRETRO && deser.version() <= Deserializer::VLAST_LIBRETRO)) - icache.Deserialize(deser); - else - icache.Reset(true); - if (deser.version() >= Deserializer::V10 - // Note (lr): was added in V11 2eb66879 27/12/2020 but ver not updated until V12 (13/4/2021) - || (deser.version() >= Deserializer::V11_LIBRETRO && deser.version() <= Deserializer::VLAST_LIBRETRO)) - ocache.Deserialize(deser); - else - ocache.Reset(true); + icache.Deserialize(deser); + ocache.Deserialize(deser); if (!deser.rollback()) mem_b.deserialize(deser); @@ -778,11 +743,7 @@ void deserialize2(Deserializer& deser) if (deser.version() <= Deserializer::V32) { deser >> SCIF_SCFSR2; - if (deser.version() >= Deserializer::V11 - || (deser.version() >= Deserializer::V11_LIBRETRO && deser.version() <= Deserializer::VLAST_LIBRETRO)) - deser >> SCIF_SCSCR2; - else - SCIF_SCSCR2.full = 0; + deser >> SCIF_SCSCR2; deser >> BSC_PDTRA; } diff --git a/core/serialize.cpp b/core/serialize.cpp index 4c6b5735d5..1d7548da20 100644 --- a/core/serialize.cpp +++ b/core/serialize.cpp @@ -54,62 +54,8 @@ void dc_serialize(Serializer& ser) DEBUG_LOG(SAVESTATE, "Saved %d bytes", (u32)ser.size()); } -static void dc_deserialize_libretro(Deserializer& deser) -{ - aica::deserialize(deser); - - sb_deserialize(deser); - - nvmem::deserialize(deser); - - gdrom::deserialize(deser); - - mcfg_DeserializeDevices(deser); - - pvr::deserialize(deser); - - sh4::deserialize(deser); - - if (deser.version() >= Deserializer::V13_LIBRETRO) - deser.skip(); // settings.network.EmulateBBA - config::EmulateBBA.override(false); - - ModemDeserialize(deser); - - sh4::deserialize2(deser); - - libGDR_deserialize(deser); - - deser.skip(); // FLASH_SIZE - deser.skip(); // BBSRAM_SIZE - deser.skip(); // BIOS_SIZE - deser.skip(); // RAM_SIZE - deser.skip(); // ARAM_SIZE - deser.skip(); // VRAM_SIZE - deser.skip(); // RAM_MASK - deser.skip(); // ARAM_MASK - deser.skip(); // VRAM_MASK - - naomi_Deserialize(deser); - - deser >> config::Broadcast.get(); - deser >> config::Cable.get(); - deser >> config::Region.get(); - - naomi_cart_deserialize(deser); - gd_hle_state.Deserialize(deser); - - DEBUG_LOG(SAVESTATE, "Loaded %d bytes (libretro compat)", (u32)deser.size()); -} - void dc_deserialize(Deserializer& deser) { - if (deser.version() >= Deserializer::V9_LIBRETRO && deser.version() <= Deserializer::VLAST_LIBRETRO) - { - dc_deserialize_libretro(deser); - sh4_sched_ffts(); - return; - } DEBUG_LOG(SAVESTATE, "Loading state version %d", deser.version()); aica::deserialize(deser); @@ -126,10 +72,7 @@ void dc_deserialize(Deserializer& deser) sh4::deserialize(deser); - if (deser.version() >= Deserializer::V13) - deser >> config::EmulateBBA.get(); - else - config::EmulateBBA.override(false); + deser >> config::EmulateBBA.get(); if (config::EmulateBBA) bba_Deserialize(deser); ModemDeserialize(deser); diff --git a/core/serialize.h b/core/serialize.h index 89ac59ae25..ccd494f9d4 100644 --- a/core/serialize.h +++ b/core/serialize.h @@ -26,22 +26,7 @@ class SerializeBase { public: enum Version : int32_t { - V9_LIBRETRO = 8, - V10_LIBRETRO, - V11_LIBRETRO, - V12_LIBRETRO, - V13_LIBRETRO, - VLAST_LIBRETRO = V13_LIBRETRO, - - V8 = 803, - V9, - V10, - V11, - V12, - V13, - V14, - V15, - V16, + V16 = 811, V17, V18, V19, @@ -111,7 +96,7 @@ class Deserializer : public SerializeBase this->limit -= 16; } deserialize(_version); - if (_version < V9_LIBRETRO || (_version > V13_LIBRETRO && _version < V8)) + if (_version < V16) throw Exception("Unsupported version"); if (_version > Current) throw Exception("Version too recent"); @@ -120,11 +105,10 @@ class Deserializer : public SerializeBase { u32 ramSize; deserialize(ramSize); - if (ramSize != settings.platform.ram_size) { + if (ramSize != settings.platform.ram_size) throw Exception("Selected RAM Size doesn't match Save State"); } } - } template void deserialize(T& obj)