mirror of
https://github.com/RaySollium99/libpicofe.git
synced 2025-09-05 06:47:45 -04:00
vsync bugfix + refactoring
git-svn-id: file:///home/notaz/opt/svn/PicoDrive/platform@738 be3aeb3a-fb24-0410-a615-afba39da0efa
This commit is contained in:
parent
0c2e114ed7
commit
f71361b521
5 changed files with 29 additions and 31 deletions
12
common/emu.c
12
common/emu.c
|
@ -1276,9 +1276,6 @@ void emu_loop(void)
|
||||||
if (PicoAHW & PAHW_MCD)
|
if (PicoAHW & PAHW_MCD)
|
||||||
PicoCDBufferInit();
|
PicoCDBufferInit();
|
||||||
|
|
||||||
if (currentConfig.EmuOpt & EOPT_PSYNC)
|
|
||||||
plat_video_wait_vsync();
|
|
||||||
|
|
||||||
pemu_loop_prep();
|
pemu_loop_prep();
|
||||||
|
|
||||||
timestamp_fps = get_ticks();
|
timestamp_fps = get_ticks();
|
||||||
|
@ -1286,6 +1283,8 @@ void emu_loop(void)
|
||||||
|
|
||||||
frames_done = frames_shown = pframes_done = 0;
|
frames_done = frames_shown = pframes_done = 0;
|
||||||
|
|
||||||
|
plat_video_wait_vsync();
|
||||||
|
|
||||||
/* loop with resync every 1 sec. */
|
/* loop with resync every 1 sec. */
|
||||||
while (engineState == PGS_Running)
|
while (engineState == PGS_Running)
|
||||||
{
|
{
|
||||||
|
@ -1414,12 +1413,9 @@ void emu_loop(void)
|
||||||
if (diff < diff_lim)
|
if (diff < diff_lim)
|
||||||
{
|
{
|
||||||
// we are too fast
|
// we are too fast
|
||||||
if (currentConfig.EmuOpt & EOPT_PSYNC) {
|
plat_wait_till_us(timestamp_base + diff_lim - target_frametime / 4);
|
||||||
if (diff_lim - diff > target_frametime/2)
|
if (currentConfig.EmuOpt & EOPT_VSYNC)
|
||||||
plat_wait_till_us(timestamp_base + target_frametime/4);
|
|
||||||
plat_video_wait_vsync();
|
plat_video_wait_vsync();
|
||||||
} else
|
|
||||||
plat_wait_till_us(timestamp_base + diff_lim);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ extern int g_screen_height;
|
||||||
#define EOPT_EN_CD_LEDS (1<<10)
|
#define EOPT_EN_CD_LEDS (1<<10)
|
||||||
#define EOPT_CONFIRM_LOAD (1<<11)
|
#define EOPT_CONFIRM_LOAD (1<<11)
|
||||||
#define EOPT_A_SN_GAMMA (1<<12)
|
#define EOPT_A_SN_GAMMA (1<<12)
|
||||||
#define EOPT_PSYNC (1<<13)
|
#define EOPT_VSYNC (1<<13)
|
||||||
#define EOPT_GIZ_SCANLN (1<<14)
|
#define EOPT_GIZ_SCANLN (1<<14)
|
||||||
#define EOPT_GIZ_DBLBUF (1<<15)
|
#define EOPT_GIZ_DBLBUF (1<<15)
|
||||||
#define EOPT_VSYNC_MODE (1<<16)
|
#define EOPT_VSYNC_MODE (1<<16)
|
||||||
|
|
13
gp2x/emu.c
13
gp2x/emu.c
|
@ -756,6 +756,9 @@ void pemu_loop_prep(void)
|
||||||
{
|
{
|
||||||
static int gp2x_old_clock = -1, EmuOpt_old = 0, pal_old = 0;
|
static int gp2x_old_clock = -1, EmuOpt_old = 0, pal_old = 0;
|
||||||
static int gp2x_old_gamma = 100;
|
static int gp2x_old_gamma = 100;
|
||||||
|
gp2x_soc_t soc;
|
||||||
|
|
||||||
|
soc = soc_detect();
|
||||||
|
|
||||||
if ((EmuOpt_old ^ currentConfig.EmuOpt) & EOPT_RAM_TIMINGS) {
|
if ((EmuOpt_old ^ currentConfig.EmuOpt) & EOPT_RAM_TIMINGS) {
|
||||||
if (currentConfig.EmuOpt & EOPT_RAM_TIMINGS)
|
if (currentConfig.EmuOpt & EOPT_RAM_TIMINGS)
|
||||||
|
@ -773,16 +776,16 @@ void pemu_loop_prep(void)
|
||||||
printf(" done\n");
|
printf(" done\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gp2x_old_gamma != currentConfig.gamma || (EmuOpt_old&0x1000) != (currentConfig.EmuOpt&0x1000)) {
|
if (gp2x_old_gamma != currentConfig.gamma || ((EmuOpt_old ^ currentConfig.EmuOpt) & EOPT_A_SN_GAMMA)) {
|
||||||
set_lcd_gamma(currentConfig.gamma, !!(currentConfig.EmuOpt&0x1000));
|
set_lcd_gamma(currentConfig.gamma, !!(currentConfig.EmuOpt & EOPT_A_SN_GAMMA));
|
||||||
gp2x_old_gamma = currentConfig.gamma;
|
gp2x_old_gamma = currentConfig.gamma;
|
||||||
printf("updated gamma to %i, A_SN's curve: %i\n", currentConfig.gamma, !!(currentConfig.EmuOpt&0x1000));
|
printf("updated gamma to %i, A_SN's curve: %i\n", currentConfig.gamma, !!(currentConfig.EmuOpt&0x1000));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (((EmuOpt_old ^ currentConfig.EmuOpt) & EOPT_PSYNC) || Pico.m.pal != pal_old) {
|
if (((EmuOpt_old ^ currentConfig.EmuOpt) & EOPT_VSYNC) || Pico.m.pal != pal_old) {
|
||||||
if (currentConfig.EmuOpt & EOPT_PSYNC)
|
if ((currentConfig.EmuOpt & EOPT_VSYNC) || soc == SOCID_POLLUX)
|
||||||
set_lcd_custom_rate(Pico.m.pal);
|
set_lcd_custom_rate(Pico.m.pal);
|
||||||
else
|
else if (EmuOpt_old & EOPT_VSYNC)
|
||||||
unset_lcd_custom_rate();
|
unset_lcd_custom_rate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -89,7 +89,7 @@ static const char *mgn_aopt_gamma(menu_id id, int *offs)
|
||||||
mee_onoff ("Tearing Fix", MA_OPT_TEARING_FIX, currentConfig.EmuOpt, EOPT_WIZ_TEAR_FIX), \
|
mee_onoff ("Tearing Fix", MA_OPT_TEARING_FIX, currentConfig.EmuOpt, EOPT_WIZ_TEAR_FIX), \
|
||||||
mee_range_cust("Gamma correction", MA_OPT2_GAMMA, currentConfig.gamma, 1, 300, mgn_aopt_gamma), \
|
mee_range_cust("Gamma correction", MA_OPT2_GAMMA, currentConfig.gamma, 1, 300, mgn_aopt_gamma), \
|
||||||
mee_onoff ("A_SN's gamma curve", MA_OPT2_A_SN_GAMMA, currentConfig.EmuOpt, EOPT_A_SN_GAMMA), \
|
mee_onoff ("A_SN's gamma curve", MA_OPT2_A_SN_GAMMA, currentConfig.EmuOpt, EOPT_A_SN_GAMMA), \
|
||||||
mee_onoff ("Perfect vsync", MA_OPT2_VSYNC, currentConfig.EmuOpt, EOPT_PSYNC),
|
mee_onoff ("Vsync", MA_OPT2_VSYNC, currentConfig.EmuOpt, EOPT_VSYNC),
|
||||||
|
|
||||||
#define MENU_GP2X_OPTIONS_ADV \
|
#define MENU_GP2X_OPTIONS_ADV \
|
||||||
mee_onoff ("Use second CPU for sound", MA_OPT_ARM940_SOUND, PicoOpt, POPT_EXT_FM), \
|
mee_onoff ("Use second CPU for sound", MA_OPT_ARM940_SOUND, PicoOpt, POPT_EXT_FM), \
|
||||||
|
|
|
@ -34,6 +34,17 @@ static unsigned int pllsetreg0;
|
||||||
static int last_pal_setting = 0;
|
static int last_pal_setting = 0;
|
||||||
|
|
||||||
|
|
||||||
|
/* misc */
|
||||||
|
static void pollux_set_fromenv(const char *env_var)
|
||||||
|
{
|
||||||
|
const char *set_string;
|
||||||
|
set_string = getenv(env_var);
|
||||||
|
if (set_string)
|
||||||
|
pollux_set(memregs, set_string);
|
||||||
|
else
|
||||||
|
printf("env var %s not defined.\n", env_var);
|
||||||
|
}
|
||||||
|
|
||||||
/* video stuff */
|
/* video stuff */
|
||||||
static void pollux_video_flip(int buf_count)
|
static void pollux_video_flip(int buf_count)
|
||||||
{
|
{
|
||||||
|
@ -62,6 +73,7 @@ static void gp2x_video_changemode_ll_(int bpp)
|
||||||
int code = 0, bytes = 2;
|
int code = 0, bytes = 2;
|
||||||
int rot_cmd[2] = { 0, 0 };
|
int rot_cmd[2] = { 0, 0 };
|
||||||
unsigned int r;
|
unsigned int r;
|
||||||
|
char buff[32];
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (bpp == prev_bpp)
|
if (bpp == prev_bpp)
|
||||||
|
@ -79,7 +91,8 @@ static void gp2x_video_changemode_ll_(int bpp)
|
||||||
memregl[0x4000>>2] |= 1 << 3;
|
memregl[0x4000>>2] |= 1 << 3;
|
||||||
|
|
||||||
/* the above ioctl resets LCD timings, so set them here */
|
/* the above ioctl resets LCD timings, so set them here */
|
||||||
set_lcd_custom_rate(last_pal_setting);
|
snprintf(buff, sizeof(buff), "POLLUX_LCD_TIMINGS_%s", last_pal_setting ? "PAL" : "NTSC");
|
||||||
|
pollux_set_fromenv(buff);
|
||||||
|
|
||||||
switch (abs(bpp))
|
switch (abs(bpp))
|
||||||
{
|
{
|
||||||
|
@ -141,17 +154,6 @@ static void gp2x_set_cpuclk_(unsigned int mhz)
|
||||||
cpuclk_was_changed = 1;
|
cpuclk_was_changed = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* misc */
|
|
||||||
static void pollux_set_fromenv(const char *env_var)
|
|
||||||
{
|
|
||||||
const char *set_string;
|
|
||||||
set_string = getenv(env_var);
|
|
||||||
if (set_string)
|
|
||||||
pollux_set(memregs, set_string);
|
|
||||||
else
|
|
||||||
printf("env var %s not defined.\n", env_var);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* RAM timings */
|
/* RAM timings */
|
||||||
static void set_ram_timings_(void)
|
static void set_ram_timings_(void)
|
||||||
{
|
{
|
||||||
|
@ -175,10 +177,7 @@ static void unset_ram_timings_(void)
|
||||||
/* LCD refresh */
|
/* LCD refresh */
|
||||||
static void set_lcd_custom_rate_(int is_pal)
|
static void set_lcd_custom_rate_(int is_pal)
|
||||||
{
|
{
|
||||||
char buff[32];
|
/* just remember PAL/NTSC. We always set timings in _changemode_ll() */
|
||||||
|
|
||||||
snprintf(buff, sizeof(buff), "POLLUX_LCD_TIMINGS_%s", is_pal ? "PAL" : "NTSC");
|
|
||||||
pollux_set_fromenv(buff);
|
|
||||||
last_pal_setting = is_pal;
|
last_pal_setting = is_pal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue