From e43c9382b0791e28aa2fedc19f502a8e3e9a7dbb Mon Sep 17 00:00:00 2001 From: notaz Date: Fri, 19 Nov 2021 00:33:04 +0200 Subject: [PATCH] fix some crashes when loading bad state --- libpcsxcore/psxcounters.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libpcsxcore/psxcounters.c b/libpcsxcore/psxcounters.c index bd0f09b9..b2cc07b2 100644 --- a/libpcsxcore/psxcounters.c +++ b/libpcsxcore/psxcounters.c @@ -502,13 +502,16 @@ s32 psxRcntFreeze( void *f, s32 Mode ) if (Mode == 0) { // don't trust things from a savestate + rcnts[3].rate = 1; for( i = 0; i < CounterQuantity; ++i ) { _psxRcntWmode( i, rcnts[i].mode ); count = (psxRegs.cycle - rcnts[i].cycleStart) / rcnts[i].rate; _psxRcntWcount( i, count ); } - hsync_steps = (psxRegs.cycle - rcnts[3].cycleStart) / rcnts[3].target; + hsync_steps = 0; + if (rcnts[3].target) + hsync_steps = (psxRegs.cycle - rcnts[3].cycleStart) / rcnts[3].target; psxRcntSet(); base_cycle = 0; -- 2.39.5