aboutsummaryrefslogtreecommitdiff
path: root/patches/beetle-pce-fast/0001-frameskip-interval.patch
blob: cdc689441941740132a9f51f614092c26075461d (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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
diff --git a/libretro.cpp b/libretro.cpp
index 48fd03a..c0fe238 100644
--- a/libretro.cpp
+++ b/libretro.cpp
@@ -1627,13 +1627,11 @@ static uint64_t audio_frames = 0;
 static unsigned frameskip_type             = 0;
 static unsigned frameskip_threshold        = 0;
 static uint16_t frameskip_counter          = 0;
+static uint16_t frameskip_interval         = 0;
 
 static bool retro_audio_buff_active        = false;
 static unsigned retro_audio_buff_occupancy = 0;
 static bool retro_audio_buff_underrun      = false;
-/* Maximum number of consecutive frames that
- * can be skipped */
-#define FRAMESKIP_MAX 30
 
 static unsigned audio_latency              = 0;
 static bool update_audio_latency           = false;
@@ -1747,6 +1745,7 @@ void retro_init(void)
    frameskip_type             = 0;
    frameskip_threshold        = 0;
    frameskip_counter          = 0;
+   frameskip_interval         = 0;
    retro_audio_buff_active    = false;
    retro_audio_buff_occupancy = 0;
    retro_audio_buff_underrun  = false;
@@ -1861,8 +1860,10 @@ static void check_variables(bool first_run)
    {
       if (strcmp(var.value, "auto") == 0)
          frameskip_type = 1;
-      else if (strcmp(var.value, "manual") == 0)
+      else if (strcmp(var.value, "auto_threshold") == 0)
          frameskip_type = 2;
+      else if (strcmp(var.value, "fixed_interval") == 0)
+         frameskip_type = 3;
    }
 
    /* Reinitialise frameskipping, if required */
@@ -1876,6 +1877,13 @@ static void check_variables(bool first_run)
    if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value)
       frameskip_threshold = strtol(var.value, NULL, 10);
 
+   var.key             = "pce_fast_frameskip_interval";
+   var.value           = NULL;
+   frameskip_interval  = 2;
+
+   if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value)
+      frameskip_interval = strtol(var.value, NULL, 10);
+
 	var.key = "pce_fast_hoverscan";
 
    if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value)
@@ -2355,16 +2363,19 @@ void retro_run(void)
          case 1: /* auto */
             skip_frame = retro_audio_buff_underrun ? 1 : 0;
             break;
-         case 2: /* manual */
+         case 2: /* auto_threshold */
             skip_frame = (retro_audio_buff_occupancy < frameskip_threshold) ? 1 : 0;
             break;
+         case 3: /* fixed_interval */
+            skip_frame = 1;
+            break;
          default:
             skip_frame = 0;
             break;
       }
 
       if (!skip_frame ||
-          (frameskip_counter >= FRAMESKIP_MAX))
+          (frameskip_counter >= frameskip_interval))
       {
          skip_frame        = 0;
          frameskip_counter = 0;
diff --git a/libretro_core_options.h b/libretro_core_options.h
index 4b1a0a7..0e664b9 100644
--- a/libretro_core_options.h
+++ b/libretro_core_options.h
@@ -97,13 +97,14 @@ struct retro_core_option_v2_definition option_defs_us[] = {
       "pce_fast_frameskip",
       "Frameskip",
       NULL,
-      "Skip frames to avoid audio buffer under-run (crackling). Improves performance at the expense of visual smoothness. 'Auto' skips frames when advised by the frontend. 'Manual' utilizes the 'Frameskip Threshold (%)' setting.",
+      "Skip frames to avoid audio buffer under-run (crackling). Improves performance at the expense of visual smoothness. 'Auto' skips frames when advised by the frontend. 'Auto (Threshold)' utilises the 'Frameskip Threshold (%)' setting. 'Fixed Interval' utilizes the 'Frameskip Interval' setting.",
       NULL,
       "video",
       {
-         { "disabled", NULL },
-         { "auto",     "Auto" },
-         { "manual",   "Manual" },
+         { "disabled",       NULL },
+         { "auto",           "Auto" },
+         { "auto_threshold", "Auto (Threshold)" },
+         { "fixed_interval", "Fixed Interval" },
          { NULL, NULL },
       },
       "disabled"
@@ -136,6 +137,28 @@ struct retro_core_option_v2_definition option_defs_us[] = {
       },
       "33"
    },
+   {
+      "pce_fast_frameskip_interval",
+      "Frameskip Interval",
+      NULL,
+      "The maximum number of frames that can be skipped before a new frame is rendered.",
+      NULL,
+      NULL,
+      {
+         { "1",  NULL },
+         { "2",  NULL },
+         { "3",  NULL },
+         { "4",  NULL },
+         { "5",  NULL },
+         { "6",  NULL },
+         { "7",  NULL },
+         { "8",  NULL },
+         { "9",  NULL },
+         { "10", NULL },
+         { NULL, NULL },
+      },
+      "2"
+   },
    {
       "pce_fast_hoverscan",
       "Horizontal Overscan (352 Width Mode Only)",