From cc221f590c5cb939ca971561e27e0a974affb2e5 Mon Sep 17 00:00:00 2001
From: Stenzek <stenzek@gmail.com>
Date: Sat, 9 Sep 2023 20:05:16 +1000
Subject: [PATCH] Counters: Don't skip vblanks on video mode change

---
 pcsx2/Counters.cpp | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/pcsx2/Counters.cpp b/pcsx2/Counters.cpp
index 212ffddaff..22623c8703 100644
--- a/pcsx2/Counters.cpp
+++ b/pcsx2/Counters.cpp
@@ -465,11 +465,10 @@ void UpdateVSyncRate(bool force)
 		if (custom && video_mode_initialized)
 			Console.Indent().WriteLn(Color_StrongGreen, "... with user configured refresh rate: %.02f Hz", vertical_frequency);
 
-		hsyncCounter.CycleT = vSyncInfo.hRender; // Amount of cycles before the counter will be updated
-		vsyncCounter.CycleT = vSyncInfo.Render;  // Amount of cycles before the counter will be updated
-		hsyncCounter.sCycle = cpuRegs.cycle;
-		vsyncCounter.sCycle = cpuRegs.cycle;
-		vsyncCounter.Mode = MODE_VRENDER;
+		hsyncCounter.CycleT = (hsyncCounter.Mode == MODE_HBLANK) ? vSyncInfo.hBlank : vSyncInfo.hRender;
+		vsyncCounter.CycleT = (vsyncCounter.Mode == MODE_GSBLANK) ?
+								  vSyncInfo.GSBlank :
+								  ((vsyncCounter.Mode == MODE_VSYNC) ? vSyncInfo.Blank : vSyncInfo.Render);
 		cpuRcntSet();
 
 		PerformanceMetrics::SetVerticalFrequency(vertical_frequency);
@@ -683,7 +682,7 @@ __fi void rcntUpdate_hScanline()
 	if( !cpuTestCycle( hsyncCounter.sCycle, hsyncCounter.CycleT ) ) return;
 
 	//iopEventAction = 1;
-	if (hsyncCounter.Mode & MODE_HBLANK) { //HBLANK Start
+	if (hsyncCounter.Mode == MODE_HBLANK) { //HBLANK Start
 		rcntStartGate(false, hsyncCounter.sCycle);
 		psxCheckStartGate16(0);