aboutsummaryrefslogtreecommitdiff
path: root/patches/dosbox-pure/0001-add-auto-cycle-limit.patch
blob: 44a771166793fbfbf12f747c642cf1815cac6e7d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
diff --git a/Makefile b/Makefile
index 3e7941c..8c54b71 100644
--- a/Makefile
+++ b/Makefile
@@ -181,6 +181,10 @@ else
   endif
 endif
 
+ifneq (,$(CYCLE_LIMIT))
+	COMMONFLAGS += -DCYCLE_LIMIT=$(CYCLE_LIMIT)
+endif
+
 ifeq ($(BUILD),DEBUG)
   BUILDDIR := debug
   CFLAGS   := -DDEBUG -D_DEBUG -g -O0
diff --git a/dosbox_pure_libretro.cpp b/dosbox_pure_libretro.cpp
index 4f4ca7e..40ddef3 100644
--- a/dosbox_pure_libretro.cpp
+++ b/dosbox_pure_libretro.cpp
@@ -544,15 +544,30 @@ void DBP_SetRealModeCycles()
 		(year >  1999 ? 500000 : // Pentium III, 600 MHz and later
 		Cycles1981to1999[year - 1981]))); // Matching speed for year
 
+#ifdef CYCLE_LIMIT
+	if (CPU_CycleMax > CYCLE_LIMIT)
+	{
+		CPU_CycleMax = CYCLE_LIMIT;
+		CPU_AutoDetermineMode &= ~(CPU_AUTODETERMINE_CYCLES|(CPU_AUTODETERMINE_CYCLES<<CPU_AUTODETERMINE_SHIFT));
+		CPU_CycleAutoAdjust = true;
+		// Switch to dynamic core
+		if (CPU_AutoDetermineMode & CPU_AUTODETERMINE_CORE)
+		{
+#else
+
 	// Switch to dynamic core for newer real mode games 
 	if (CPU_CycleMax >= 8192 && (CPU_AutoDetermineMode & CPU_AUTODETERMINE_CORE))
 	{
+#endif
 		#if (C_DYNAMIC_X86)
 		if (cpudecoder != CPU_Core_Dyn_X86_Run) { void CPU_Core_Dyn_X86_Cache_Init(bool); CPU_Core_Dyn_X86_Cache_Init(true); cpudecoder = CPU_Core_Dyn_X86_Run; }
 		#elif (C_DYNREC)
 		if (cpudecoder != CPU_Core_Dynrec_Run)  { void CPU_Core_Dynrec_Cache_Init(bool);  CPU_Core_Dynrec_Cache_Init(true);  cpudecoder = CPU_Core_Dynrec_Run;  }
 		#endif
 	}
+#ifdef CYCLE_LIMIT
+	}
+#endif
 }
 
 static bool DBP_NeedFrameSkip(bool in_emulation)