From: notaz Date: Thu, 18 Nov 2021 22:33:04 +0000 (+0200) Subject: fix some crashes when loading bad state X-Git-Tag: r23~74 X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e43c9382b0791e28aa2fedc19f502a8e3e9a7dbb;p=pcsx_rearmed.git fix some crashes when loading bad state --- 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;