aboutsummaryrefslogtreecommitdiff
path: root/frontend
diff options
context:
space:
mode:
authorneonloop2021-03-14 18:54:30 +0000
committerneonloop2021-03-14 19:28:36 +0000
commitcc67e49563096e4367881e8bbe4554f1a7d21595 (patch)
tree393883d80d2b417d67a4fb2150dbd37392017802 /frontend
parent34c62fb129becec9e61a48227d9ed89867cdd470 (diff)
downloadpcsx_rearmed-cc67e49563096e4367881e8bbe4554f1a7d21595.tar.gz
pcsx_rearmed-cc67e49563096e4367881e8bbe4554f1a7d21595.tar.bz2
pcsx_rearmed-cc67e49563096e4367881e8bbe4554f1a7d21595.zip
Adds frameskip based on free audio buffer space
Diffstat (limited to 'frontend')
-rw-r--r--frontend/libretro.c12
-rw-r--r--frontend/menu.c7
-rw-r--r--frontend/plugin_lib.c35
-rw-r--r--frontend/plugin_lib.h1
4 files changed, 41 insertions, 14 deletions
diff --git a/frontend/libretro.c b/frontend/libretro.c
index 59f1201..e588b8d 100644
--- a/frontend/libretro.c
+++ b/frontend/libretro.c
@@ -151,6 +151,7 @@ static int vout_open(void) { return 0; }
static void vout_close(void) {}
static int snd_init(void) { return 0; }
static void snd_finish(void) {}
+static float snd_capacity(void) { return 0.3; }
static int snd_busy(void) { return 0; }
#define GPU_PEOPS_ODD_EVEN_BIT (1 << 0)
@@ -510,11 +511,12 @@ static void snd_feed(void *buf, int bytes)
void out_register_libretro(struct out_driver *drv)
{
- drv->name = "libretro";
- drv->init = snd_init;
- drv->finish = snd_finish;
- drv->busy = snd_busy;
- drv->feed = snd_feed;
+ drv->name = "libretro";
+ drv->init = snd_init;
+ drv->finish = snd_finish;
+ drv->busy = snd_busy;
+ drv->feed = snd_feed;
+ drv->capacity = snd_capacity;
}
#define RETRO_DEVICE_PSE_STANDARD RETRO_DEVICE_SUBCLASS(RETRO_DEVICE_JOYPAD, 0)
diff --git a/frontend/menu.c b/frontend/menu.c
index 7bf4080..52e6b98 100644
--- a/frontend/menu.c
+++ b/frontend/menu.c
@@ -93,7 +93,7 @@ typedef enum
} menu_id;
static int last_vout_w, last_vout_h, last_vout_bpp;
-static int cpu_clock, cpu_clock_st, volume_boost, frameskip;
+static int cpu_clock, cpu_clock_st, volume_boost, frameskip, frameskip_type;
static char last_selected_fname[MAXPATHLEN];
static int config_save_counter, region, in_type_sel1, in_type_sel2;
static int psx_clock;
@@ -325,6 +325,7 @@ static void menu_sync_config(void)
spu_config.iVolume = 768 + 128 * volume_boost;
pl_rearmed_cbs.frameskip = frameskip - 1;
+ pl_rearmed_cbs.frameskip_type = frameskip_type;
pl_timing_prepare(Config.PsxType);
}
@@ -337,6 +338,7 @@ static void menu_set_defconfig(void)
g_gamma = 100;
volume_boost = 0;
frameskip = 0;
+ frameskip_type = 0;
analog_deadzone = 50;
soft_scaling = 1;
soft_filter = 0;
@@ -424,6 +426,7 @@ static const struct {
CE_INTVAL_N("adev0_is_nublike", in_adev_is_nublike[0]),
CE_INTVAL_N("adev1_is_nublike", in_adev_is_nublike[1]),
CE_INTVAL_V(frameskip, 3),
+ CE_INTVAL(frameskip_type),
CE_INTVAL_P(thread_rendering),
CE_INTVAL_P(gpu_peops.iUseDither),
CE_INTVAL_P(gpu_peops.dwActFixes),
@@ -1611,6 +1614,7 @@ static int mh_restore_defaults(int id, int keys)
static const char *men_region[] = { "Auto", "NTSC", "PAL", NULL };
static const char *men_frameskip[] = { "Auto", "Off", "1", "2", "3", NULL };
+static const char *men_fs_type[] = { "Time", "Audio", NULL };
/*
static const char *men_confirm_save[] = { "OFF", "writes", "loads", "both", NULL };
static const char h_confirm_save[] = "Ask for confirmation when overwriting save,\n"
@@ -1625,6 +1629,7 @@ static menu_entry e_menu_options[] =
// mee_range ("Save slot", 0, state_slot, 0, 9),
// mee_enum_h ("Confirm savestate", 0, dummy, men_confirm_save, h_confirm_save),
mee_enum_h ("Frameskip", 0, frameskip, men_frameskip, h_frameskip),
+ mee_enum ("Frameskip type", 0, frameskip_type, men_fs_type),
mee_onoff ("Show FPS", 0, g_opts, OPT_SHOWFPS),
mee_enum ("Region", 0, region, men_region),
mee_range ("CPU clock", MA_OPT_CPU_CLOCKS, cpu_clock, 20, 5000),
diff --git a/frontend/plugin_lib.c b/frontend/plugin_lib.c
index eee255b..6c5b296 100644
--- a/frontend/plugin_lib.c
+++ b/frontend/plugin_lib.c
@@ -33,6 +33,8 @@
#include "../libpcsxcore/new_dynarec/new_dynarec.h"
#include "../libpcsxcore/psxmem_map.h"
#include "../plugins/dfinput/externals.h"
+#include "../plugins/dfsound/out.h"
+
#define HUD_HEIGHT 10
@@ -702,17 +704,34 @@ void pl_frame_limit(void)
tv_expect.tv_usec = usadj << 10;
}
- if (!(g_opts & OPT_NO_FRAMELIM) && diff > frame_interval) {
- // yay for working usleep on pandora!
- //printf("usleep %d\n", diff - frame_interval / 2);
- usleep(diff - frame_interval);
+ if (!(g_opts & OPT_NO_FRAMELIM)) {
+ if (pl_rearmed_cbs.frameskip && pl_rearmed_cbs.frameskip_type == 1) {
+ while (out_current && out_current->capacity() < 0.1) {
+ usleep(500);
+ }
+ } else {
+ if (diff > frame_interval) {
+ // yay for working usleep on pandora!
+ //printf("usleep %d\n", diff - frame_interval / 2);
+ usleep(diff - frame_interval);
+ }
+ }
}
+
if (pl_rearmed_cbs.frameskip) {
- if (diff < -frame_interval)
- pl_rearmed_cbs.fskip_advice = 1;
- else if (diff >= 0)
- pl_rearmed_cbs.fskip_advice = 0;
+ if (pl_rearmed_cbs.frameskip_type == 1) {
+ if (out_current->capacity() > 0.5) {
+ pl_rearmed_cbs.fskip_advice = 1;
+ } else {
+ pl_rearmed_cbs.fskip_advice = 0;
+ }
+ } else {
+ if (diff < -frame_interval)
+ pl_rearmed_cbs.fskip_advice = 1;
+ else if (diff >= 0)
+ pl_rearmed_cbs.fskip_advice = 0;
+ }
// recompilation is not that fast and may cause frame skip on
// loading screens and such, resulting in flicker or glitches
diff --git a/frontend/plugin_lib.h b/frontend/plugin_lib.h
index 71dfcb5..841eeb9 100644
--- a/frontend/plugin_lib.h
+++ b/frontend/plugin_lib.h
@@ -69,6 +69,7 @@ struct rearmed_cbs {
void *gles_display, *gles_surface;
// gpu options
int frameskip;
+ int frameskip_type;
int fskip_advice;
unsigned int *gpu_frame_count;
unsigned int *gpu_hcnt;