Skip to content

Commit

Permalink
savestate: drop support for legacy libretro and <v16 savestates
Browse files Browse the repository at this point in the history
  • Loading branch information
flyinghead committed Apr 16, 2024
1 parent 336706e commit de6a43b
Show file tree
Hide file tree
Showing 16 changed files with 40 additions and 224 deletions.
3 changes: 1 addition & 2 deletions core/hw/aica/aica_if.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -581,8 +581,7 @@ void deserialize(Deserializer& deser)
deser >> VREG;
deser >> ARMRST;
deser >> rtc_EN;
if (deser.version() >= Deserializer::V9)
deser >> RealTimeClock;
deser >> RealTimeClock;

deser >> aica_reg;

Expand Down
38 changes: 4 additions & 34 deletions core/hw/flashrom/nvmem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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");
Expand Down Expand Up @@ -373,36 +371,8 @@ void serialize(Serializer& ser)

void deserialize(Deserializer& deser)
{
if (deser.version() <= Deserializer::VLAST_LIBRETRO)
{
deser.skip<u32>(); // size
deser.skip<u32>(); // mask

// Legacy libretro savestate
if (settings.platform.isArcade())
sys_nvmem->Deserialize(deser);

deser.skip<u32>(); // sys_nvmem/sys_rom->size
deser.skip<u32>(); // sys_nvmem/sys_rom->mask
if (settings.platform.isConsole())
{
sys_nvmem->Deserialize(deser);
}
else if (settings.platform.isAtomiswave())
{
deser >> static_cast<DCFlashChip*>(sys_rom)->state;
deser.deserialize(sys_rom->data, sys_rom->size);
}
else
{
deser.skip<u32>();
}
}
else
{
sys_rom->Deserialize(deser);
sys_nvmem->Deserialize(deser);
}
sys_rom->Deserialize(deser);
sys_nvmem->Deserialize(deser);
}

}
4 changes: 0 additions & 4 deletions core/hw/gdrom/gdromv3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1412,8 +1412,6 @@ void deserialize(Deserializer& deser)
deser.skip<u32>(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;
Expand All @@ -1426,8 +1424,6 @@ void deserialize(Deserializer& deser)
deser >> SecNumber;
deser >> GDStatus;
deser >> ByteCount;
if (deser.version() <= Deserializer::VLAST_LIBRETRO)
deser.skip<u32>(); // GDROM_TICK
}

}
18 changes: 2 additions & 16 deletions core/hw/holly/sb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<u32>(); // 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)
Expand All @@ -729,9 +718,6 @@ void sb_deserialize(Deserializer& deser)
deser.skip<u32>(); // SB_FFST_rc;
deser.skip<u32>(); // SB_FFST;
}
if (deser.version() >= Deserializer::V15)
deser >> SB_ADST;
else
SB_ADST = 0;
deser >> SB_ADST;
}
}
3 changes: 1 addition & 2 deletions core/hw/maple/maple_devs.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 1 addition & 4 deletions core/hw/naomi/naomi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -409,10 +409,7 @@ void naomi_Deserialize(Deserializer& deser)
deser.skip<u32>(); // reg_dimm_parameterh;
deser.skip<u32>(); // reg_dimm_status;
}
if (deser.version() < Deserializer::V11)
deser.skip<u8>();
else if (deser.version() >= Deserializer::V14)
deser >> aw_maple_devs;
deser >> aw_maple_devs;
if (deser.version() >= Deserializer::V20)
{
deser >> coin_chute_time;
Expand Down
2 changes: 1 addition & 1 deletion core/hw/naomi/naomi_cart.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 1 addition & 5 deletions core/hw/pvr/Renderer_if.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 1 addition & 2 deletions core/hw/pvr/pvr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 1 addition & 4 deletions core/hw/pvr/pvr_mem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
22 changes: 7 additions & 15 deletions core/hw/pvr/spg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -315,19 +315,11 @@ void spg_Deserialize(Deserializer& deser)
if (deser.version() < Deserializer::V30)
deser.skip<u32>(); // 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;
}
3 changes: 1 addition & 2 deletions core/hw/pvr/ta_ctx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 1 addition & 3 deletions core/hw/sh4/modules/mmu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
67 changes: 14 additions & 53 deletions core/hw/sh4/sh4_mmr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -692,59 +692,24 @@ void serialize(Serializer& ser)
sh4_sched_serialize(ser);
}

template<typename T>
static void register_deserialize_libretro(T& regs, Deserializer& deser)
{
for (auto& reg : regs)
{
deser.skip<u32>(); // 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);
Expand Down Expand Up @@ -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;
}

Expand Down
59 changes: 1 addition & 58 deletions core/serialize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<bool>(); // settings.network.EmulateBBA
config::EmulateBBA.override(false);

ModemDeserialize(deser);

sh4::deserialize2(deser);

libGDR_deserialize(deser);

deser.skip<u32>(); // FLASH_SIZE
deser.skip<u32>(); // BBSRAM_SIZE
deser.skip<u32>(); // BIOS_SIZE
deser.skip<u32>(); // RAM_SIZE
deser.skip<u32>(); // ARAM_SIZE
deser.skip<u32>(); // VRAM_SIZE
deser.skip<u32>(); // RAM_MASK
deser.skip<u32>(); // ARAM_MASK
deser.skip<u32>(); // 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);
Expand All @@ -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);
Expand Down
Loading

0 comments on commit de6a43b

Please sign in to comment.