diff options
-rw-r--r-- | .gitmodules | 3 | ||||
-rw-r--r-- | Makefile | 38 | ||||
-rwxr-xr-x | configure | 21 | ||||
m--------- | frontend/libpicofe | 0 | ||||
-rw-r--r-- | frontend/libretro.c | 12 | ||||
-rw-r--r-- | frontend/main.c | 36 | ||||
-rw-r--r-- | frontend/main.h | 20 | ||||
-rw-r--r-- | frontend/menu.c | 67 | ||||
-rw-r--r-- | frontend/menu.h | 1 | ||||
-rw-r--r-- | frontend/menu_trimui.h | 31 | ||||
-rw-r--r-- | frontend/plat_trimui.c | 382 | ||||
-rw-r--r-- | frontend/plugin.c | 6 | ||||
-rw-r--r-- | frontend/plugin_lib.c | 35 | ||||
-rw-r--r-- | frontend/plugin_lib.h | 1 | ||||
-rw-r--r-- | plugins/dfsound/alsa.c | 21 | ||||
-rw-r--r-- | plugins/dfsound/nullsnd.c | 7 | ||||
-rw-r--r-- | plugins/dfsound/oss.c | 28 | ||||
-rw-r--r-- | plugins/dfsound/out.h | 1 | ||||
-rw-r--r-- | plugins/dfsound/pulseaudio.c | 33 | ||||
-rw-r--r-- | plugins/dfsound/sdl.c | 12 | ||||
-rw-r--r-- | plugins/gpulib/gpu.c | 4 |
21 files changed, 649 insertions, 110 deletions
diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..1f260d5 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "frontend/libpicofe"] + path = frontend/libpicofe + url = https://github.com/notaz/libpicofe @@ -2,7 +2,8 @@ # default stuff goes here, so that config can override TARGET ?= pcsx -CFLAGS += -Wall -Iinclude -ffast-math +CFLAGS += -Wall -Iinclude -ffast-math -DPICO_HOME_DIR='"/.pcsx/"' + ifeq ($(DEBUG), 1) CFLAGS += -O0 -ggdb else @@ -44,6 +45,16 @@ ifdef PCNT CFLAGS += -DPCNT endif +ifeq ($(PROFILE), YES) +CFLAGS += -fprofile-generate=./profile +else ifeq ($(PROFILE), APPLY) +CFLAGS += -fprofile-use -fprofile-dir=./profile -fbranch-probabilities +endif + +ifeq ($(PROFILE), YES) +LDFLAGS += -lgcov +endif + # core OBJS += libpcsxcore/cdriso.o libpcsxcore/cdrom.o libpcsxcore/cheat.o libpcsxcore/debug.o \ libpcsxcore/decode_xa.o libpcsxcore/disr3000a.o libpcsxcore/mdec.o \ @@ -285,6 +296,20 @@ frontend/main.o frontend/menu.o: CFLAGS += -include frontend/320240/ui_gp2x.h USE_PLUGIN_LIB = 1 USE_FRONTEND = 1 endif +ifeq "$(PLATFORM)" "trimui" +SYSROOT := $(shell $(CC) --print-sysroot) +SDL_CFLAGS := $(shell $(SYSROOT)/usr/bin/sdl-config --cflags) +SDL_LDFLAGS := $(shell $(SYSROOT)/usr/bin/sdl-config --libs) +OBJS += frontend/libpicofe/in_sdl.o +OBJS += frontend/libpicofe/linux/in_evdev.o +OBJS += frontend/plat_trimui.o frontend/blit320.o +frontend/main.o frontend/menu.o: CFLAGS += -include frontend/menu_trimui.h +USE_PLUGIN_LIB = 1 +USE_FRONTEND = 1 +CFLAGS += -DGPULIB_USE_MMAP -DGPU_UNAI_USE_INT_DIV_MULTINV -fomit-frame-pointer -ffast-math -ffunction-sections -fsingle-precision-constant +CFLAGS += $(SDL_CFLAGS) -DTRIMUI +LDFLAGS += $(SDL_LDFLAGS) -flto -fwhole-program +endif ifeq "$(PLATFORM)" "maemo" OBJS += maemo/hildon.o maemo/main.o maemo/maemo_xkb.o frontend/pl_gun_ts.o maemo/%.o: maemo/%.c @@ -444,3 +469,14 @@ rel: pcsx $(PLUGINS) \ mkdir out/pcsx_rearmed/bios/ cd out && zip -9 -r ../pcsx_rearmed_$(VER)_caanoo.zip * endif +ifeq "$(PLATFORM)" "trimui" +VER = v1.9 +rel: pcsx $(PLUGINS) \ + readme.txt COPYING + rm -rf out + mkdir -p out/pcsx_rearmed/ + cp -r $^ out/pcsx_rearmed/ + mkdir out/pcsx_rearmed/lib/ + mkdir out/pcsx_rearmed/bios/ + cd out && zip -9 -r ../pcsx_rearmed_$(VER)_trimui.zip * +endif @@ -37,7 +37,7 @@ check_define_val() # setting options to "yes" or "no" will make that choice default, # "" means "autodetect". -platform_list="generic pandora maemo caanoo libretro" +platform_list="generic pandora maemo caanoo libretro trimui" platform="generic" builtin_gpu_list="peops unai neon" builtin_gpu="" @@ -107,6 +107,18 @@ set_platform() optimize_arm926ej="yes" need_warm="yes" ;; + trimui) + ARCH="arm" + sound_drivers="sdl" + have_tslib="no" + have_chd="yes" + ram_fixed="yes" + drc_cache_base="no" # usually works, sometimes not + optimize_arm926ej="yes" + need_warm="no" + have_arm_neon="no" + plugins="" + ;; libretro) sound_drivers="libretro" need_libpicofe="no" @@ -569,7 +581,7 @@ if [ "$have_gles" = "yes" ]; then echo "LDLIBS_GLES = $LDLIBS_GLES" >> $config_mak fi if [ "$enable_dynarec" = "yes" ]; then - echo "USE_DYNAREC = 1" >> $config_mak + echo "DYNAREC = ari64" >> $config_mak fi if [ "$drc_cache_base" = "yes" ]; then echo "DRC_CACHE_BASE = 1" >> $config_mak @@ -577,8 +589,11 @@ fi if [ "$have_c64x_dsp" = "yes" ]; then echo "HAVE_C64_TOOLS = 1" >> $config_mak fi +if [ "$have_chd" = "yes" ]; then + echo "HAVE_CHD = 1" >> $config_mak +fi # use pandora's skin (for now) -test -e skin || ln -s frontend/pandora/skin skin +# test -e skin || ln -s frontend/pandora/skin skin # vim:shiftwidth=2:expandtab diff --git a/frontend/libpicofe b/frontend/libpicofe new file mode 160000 +Subproject 76e45c3489a0c32d91744413c198f685b553f6c diff --git a/frontend/libretro.c b/frontend/libretro.c index 9aadb32..77c23c0 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/main.c b/frontend/main.c index d3c7d40..c1f1cc4 100644 --- a/frontend/main.c +++ b/frontend/main.c @@ -54,12 +54,15 @@ enum sched_action emu_action, emu_action_old; char hud_msg[64]; int hud_new_msg; -static void make_path(char *buf, size_t size, const char *dir, const char *fname) +void make_path(char *buf, size_t size, const char *dir, const char *fname) { + char root_dir[MAXPATHLEN]; + plat_get_root_dir(root_dir, MAXPATHLEN); + if (fname) - snprintf(buf, size, ".%s%s", dir, fname); + snprintf(buf, size, "%s%s%s", root_dir, dir, fname); else - snprintf(buf, size, ".%s", dir); + snprintf(buf, size, "%s%s", root_dir, dir); } #define MAKE_PATH(buf, dir, fname) \ make_path(buf, sizeof(buf), dir, fname) @@ -103,7 +106,7 @@ void set_cd_image(const char *fname) static void set_default_paths(void) { #ifndef NO_FRONTEND - snprintf(Config.PatchesDir, sizeof(Config.PatchesDir), "." PATCHES_DIR); + MAKE_PATH(Config.PatchesDir, PATCHES_DIR, NULL); MAKE_PATH(Config.Mcd1, MEMCARD_DIR, "card1.mcd"); MAKE_PATH(Config.Mcd2, MEMCARD_DIR, "card2.mcd"); strcpy(Config.BiosDir, "bios"); @@ -125,6 +128,7 @@ void emu_set_default_config(void) Config.SpuIrq = Config.RCntFix = Config.VSyncWA = 0; Config.PsxAuto = 1; + pl_rearmed_cbs.frameskip_type = 0; pl_rearmed_cbs.thread_rendering = 0; pl_rearmed_cbs.gpu_neon.allow_interlace = 2; // auto @@ -133,7 +137,7 @@ void emu_set_default_config(void) pl_rearmed_cbs.gpu_peops.iUseDither = 0; pl_rearmed_cbs.gpu_peops.dwActFixes = 1<<7; pl_rearmed_cbs.gpu_unai.ilace_force = 0; - pl_rearmed_cbs.gpu_unai.pixel_skip = 1; + pl_rearmed_cbs.gpu_unai.pixel_skip = 0; pl_rearmed_cbs.gpu_unai.lighting = 1; pl_rearmed_cbs.gpu_unai.fast_lighting = 1; pl_rearmed_cbs.gpu_unai.blending = 1; @@ -162,6 +166,13 @@ void emu_set_default_config(void) new_dynarec_hacks = 0; cycle_multiplier = 200; +#ifdef TRIMUI + pl_rearmed_cbs.gpu_unai.scale_hires = 1; + pl_rearmed_cbs.frameskip_type = 1; // audio-based + spu_config.iTempo = 0; + cycle_multiplier = 175; +#endif + in_type[0] = PSE_PAD_TYPE_STANDARD; in_type[1] = PSE_PAD_TYPE_STANDARD; } @@ -477,17 +488,13 @@ static void create_profile_dir(const char *directory) { } static void check_profile(void) { - // make sure that ~/.pcsx exists - create_profile_dir(PCSX_DOT_DIR); - - create_profile_dir(BIOS_DIR); create_profile_dir(MEMCARD_DIR); create_profile_dir(STATES_DIR); create_profile_dir(PLUGINS_DIR); create_profile_dir(PLUGINS_CFG_DIR); create_profile_dir(CHEATS_DIR); create_profile_dir(PATCHES_DIR); - create_profile_dir(PCSX_DOT_DIR "cfg"); + create_profile_dir("/cfg/"); create_profile_dir("/screenshots/"); } @@ -601,7 +608,7 @@ int main(int argc, char *argv[]) // FIXME: this recovery doesn't work, just delete bad config and bail out // SysMessage("could not load plugins, retrying with defaults\n"); set_default_paths(); - snprintf(path, sizeof(path), "." PCSX_DOT_DIR "%s", cfgfile_basename); + MAKE_PATH(path, cfgfile_basename, NULL); remove(path); SysMessage("Failed loading plugins!"); return 1; @@ -626,6 +633,7 @@ int main(int argc, char *argv[]) SysPrintf(_("Could not load CD-ROM!\n")); return -1; } + menu_load_config(1); emu_on_new_cd(!loadst); ready_to_go = 1; } @@ -757,8 +765,10 @@ void SysUpdate() { } int get_state_filename(char *buf, int size, int i) { - return get_gameid_filename(buf, size, - "." STATES_DIR "%.32s-%.9s.%3.3d", i); + char fname[MAXPATHLEN]; + MAKE_PATH(fname, STATES_DIR, "%.32s-%.9s.%3.3d"); + + return get_gameid_filename(buf, size, fname, i); } int emu_check_state(int slot) diff --git a/frontend/main.h b/frontend/main.h index 7ce9e5d..b53a2a3 100644 --- a/frontend/main.h +++ b/frontend/main.h @@ -21,16 +21,12 @@ #include "config.h" -#define DEFAULT_MEM_CARD_1 "/.pcsx/memcards/card1.mcd" -#define DEFAULT_MEM_CARD_2 "/.pcsx/memcards/card2.mcd" -#define MEMCARD_DIR "/.pcsx/memcards/" -#define PLUGINS_DIR "/.pcsx/plugins/" -#define PLUGINS_CFG_DIR "/.pcsx/plugins/cfg/" -#define PCSX_DOT_DIR "/.pcsx/" -#define STATES_DIR "/.pcsx/sstates/" -#define CHEATS_DIR "/.pcsx/cheats/" -#define PATCHES_DIR "/.pcsx/patches/" -#define BIOS_DIR "/bios/" +#define MEMCARD_DIR "memcards/" +#define PLUGINS_DIR "plugins/" +#define PLUGINS_CFG_DIR "plugins/cfg/" +#define STATES_DIR "sstates/" +#define CHEATS_DIR "cheats/" +#define PATCHES_DIR "patches/" extern char cfgfile_basename[MAXPATHLEN]; @@ -52,6 +48,10 @@ int emu_save_state(int slot); int emu_load_state(int slot); void set_cd_image(const char *fname); +void make_path(char *buf, size_t size, const char *dir, const char *fname); + +#define MAKE_PATH(buf, dir, fname) \ + make_path(buf, sizeof(buf), dir, fname) extern unsigned long gpuDisp; extern int ready_to_go, g_emu_want_quit, g_emu_resetting; diff --git a/frontend/menu.c b/frontend/menu.c index bd56cf4..fc95294 100644 --- a/frontend/menu.c +++ b/frontend/menu.c @@ -87,6 +87,9 @@ typedef enum MA_OPT_VOUT_MODE, MA_OPT_SCANLINES, MA_OPT_SCANLINE_LEVEL, + MA_PLUG_PEOPS, + MA_PLUG_UNAI, + MA_PLUG_PEOPSGL, } menu_id; static int last_vout_w, last_vout_h, last_vout_bpp; @@ -101,10 +104,15 @@ int scanlines, scanline_level = 20; int soft_scaling, analog_deadzone; // for Caanoo int soft_filter; +#ifdef TRIMUI +#define DEFAULT_PSX_CLOCK 57 +#define DEFAULT_PSX_CLOCK_S "57" +#else // Default to 100% CPU speed as most hardware can handle it nowadays using the dynamic recompiler. // If not, the option is in the advanced speed hacks menu, so in a logical place. #define DEFAULT_PSX_CLOCK 100 #define DEFAULT_PSX_CLOCK_S "100" +#endif static const char *bioses[24]; static const char *gpu_plugins[16]; @@ -123,6 +131,7 @@ static int bios_sel, gpu_plugsel, spu_plugsel; #define MENU_SHOW_MINIMIZE 0 #define MENU_SHOW_FULLSCREEN 1 #define MENU_SHOW_VOLUME 0 +#define MENU_SHOW_DISPLAY 1 #endif static int min(int x, int y) { return x < y ? x : y; } @@ -420,6 +429,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_P(frameskip_type), CE_INTVAL_P(thread_rendering), CE_INTVAL_P(gpu_peops.iUseDither), CE_INTVAL_P(gpu_peops.dwActFixes), @@ -477,10 +487,14 @@ static char *get_cd_label(void) static void make_cfg_fname(char *buf, size_t size, int is_game) { - if (is_game) - snprintf(buf, size, "." PCSX_DOT_DIR "cfg/%.32s-%.9s.cfg", get_cd_label(), CdromId); + char fname[MAXPATHLEN]; + + if (is_game) { + snprintf(fname, MAXPATHLEN, "%.32s-%.9s.cfg", get_cd_label(), CdromId); + make_path(buf, size, "/cfg/", fname); + } else - snprintf(buf, size, "." PCSX_DOT_DIR "%s", cfgfile_basename); + make_path(buf, size, cfgfile_basename, NULL); } static void keys_write_all(FILE *f); @@ -537,7 +551,7 @@ static int menu_do_last_cd_img(int is_get) FILE *f; int i, ret = -1; - snprintf(path, sizeof(path), "." PCSX_DOT_DIR "lastcdimg.txt"); + MAKE_PATH(path, "lastcdimg.txt", NULL); f = fopen(path, is_get ? "r" : "w"); if (f == NULL) { ret = -1; @@ -581,7 +595,7 @@ static void parse_str_val(char *cval, const char *src) static void keys_load_all(const char *cfg); -static int menu_load_config(int is_game) +int menu_load_config(int is_game) { char cfgfile[MAXPATHLEN]; int i, ret = -1; @@ -694,15 +708,13 @@ fail: if (memcard1_sel == 0) strcpy(Config.Mcd1, "none"); else if (memcards[memcard1_sel] != NULL) - snprintf(Config.Mcd1, sizeof(Config.Mcd1), ".%s%s", - MEMCARD_DIR, memcards[memcard1_sel]); + MAKE_PATH(Config.Mcd1, MEMCARD_DIR, memcards[memcard1_sel]); } if ((unsigned int)memcard2_sel < ARRAY_SIZE(memcards)) { if (memcard2_sel == 0) strcpy(Config.Mcd2, "none"); else if (memcards[memcard2_sel] != NULL) - snprintf(Config.Mcd2, sizeof(Config.Mcd2), ".%s%s", - MEMCARD_DIR, memcards[memcard2_sel]); + MAKE_PATH(Config.Mcd2, MEMCARD_DIR, memcards[memcard2_sel]); } if (strcmp(mcd1_old, Config.Mcd1) || strcmp(mcd2_old, Config.Mcd2)) LoadMcds(Config.Mcd1, Config.Mcd2); @@ -1376,6 +1388,7 @@ static menu_entry e_menu_plugin_gpu_unai[] = mee_onoff ("Fast lighting", 0, pl_rearmed_cbs.gpu_unai.fast_lighting, 1), mee_onoff ("Blending", 0, pl_rearmed_cbs.gpu_unai.blending, 1), mee_onoff ("Pixel skip", 0, pl_rearmed_cbs.gpu_unai.pixel_skip, 1), + mee_onoff ("Downscale Hi-Res", 0, pl_rearmed_cbs.gpu_unai.scale_hires, 1), mee_end, }; @@ -1499,16 +1512,16 @@ static const char h_spu[] = "Configure built-in P.E.Op.S. Sound Driver V1 static menu_entry e_menu_plugin_options[] = { - mee_enum_h ("BIOS", 0, bios_sel, bioses, h_bios), - mee_enum_h ("GPU plugin", 0, gpu_plugsel, gpu_plugins, h_plugin_gpu), - mee_enum_h ("SPU plugin", 0, spu_plugsel, spu_plugins, h_plugin_spu), + mee_enum_h ("BIOS", 0, bios_sel, bioses, h_bios), + mee_enum_h ("GPU plugin", 0, gpu_plugsel, gpu_plugins, h_plugin_gpu), + mee_enum_h ("SPU plugin", 0, spu_plugsel, spu_plugins, h_plugin_spu), #ifdef __ARM_NEON__ - mee_handler_h ("Configure built-in GPU plugin", menu_loop_plugin_gpu_neon, h_gpu_neon), + mee_handler_h ("Configure built-in GPU plugin", menu_loop_plugin_gpu_neon, h_gpu_neon), #endif - mee_handler_h ("Configure gpu_peops plugin", menu_loop_plugin_gpu_peops, h_gpu_peops), - mee_handler_h ("Configure gpu_unai GPU plugin", menu_loop_plugin_gpu_unai, h_gpu_unai), - mee_handler_h ("Configure gpu_gles GPU plugin", menu_loop_plugin_gpu_peopsgl, h_gpu_peopsgl), - mee_handler_h ("Configure built-in SPU plugin", menu_loop_plugin_spu, h_spu), + mee_handler_id_h ("Configure gpu_peops plugin", MA_PLUG_PEOPS, menu_loop_plugin_gpu_peops, h_gpu_peops), + mee_handler_id_h ("Configure gpu_unai GPU plugin", MA_PLUG_UNAI, menu_loop_plugin_gpu_unai, h_gpu_unai), + mee_handler_id_h ("Configure gpu_gles GPU plugin", MA_PLUG_PEOPSGL, menu_loop_plugin_gpu_peopsgl, h_gpu_peopsgl), + mee_handler_h ("Configure built-in SPU plugin", menu_loop_plugin_spu, h_spu), mee_end, }; @@ -1604,6 +1617,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" @@ -1618,6 +1632,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 ("Auto frameskip type", 0, pl_rearmed_cbs.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), @@ -1768,10 +1783,10 @@ static void handle_memcard_sel(void) { strcpy(Config.Mcd1, "none"); if (memcard1_sel != 0) - snprintf(Config.Mcd1, sizeof(Config.Mcd1), ".%s%s", MEMCARD_DIR, memcards[memcard1_sel]); + MAKE_PATH(Config.Mcd1, MEMCARD_DIR, memcards[memcard1_sel]); strcpy(Config.Mcd2, "none"); if (memcard2_sel != 0) - snprintf(Config.Mcd2, sizeof(Config.Mcd2), ".%s%s", MEMCARD_DIR, memcards[memcard2_sel]); + MAKE_PATH(Config.Mcd2, MEMCARD_DIR, memcards[memcard2_sel]); LoadMcds(Config.Mcd1, Config.Mcd2); draw_mc_bg(); } @@ -2451,7 +2466,8 @@ do_plugins: closedir(dir); do_memcards: - dir = opendir("." MEMCARD_DIR); + MAKE_PATH(fname, MEMCARD_DIR, NULL); + dir = opendir(fname); if (dir == NULL) { perror("scan_bios_plugins memcards opendir"); return; @@ -2471,7 +2487,7 @@ do_memcards: if (ent->d_type != DT_REG && ent->d_type != DT_LNK) continue; - snprintf(fname, sizeof(fname), "." MEMCARD_DIR "%s", ent->d_name); + MAKE_PATH(fname, MEMCARD_DIR, ent->d_name); if (stat(fname, &st) != 0) { printf("bad memcard file: %s\n", ent->d_name); continue; @@ -2515,9 +2531,6 @@ void menu_init(void) exit(1); } - emu_make_path(buff, "skin/background.png", sizeof(buff)); - readpng(g_menubg_src_ptr, buff, READPNG_BG, g_menuscreen_w, g_menuscreen_h); - i = plat_target.cpu_clock_set != NULL && plat_target.cpu_clock_get != NULL && cpu_clock_st > 0; me_enable(e_menu_gfx_options, MA_OPT_CPU_CLOCKS, i); @@ -2545,6 +2558,12 @@ void menu_init(void) me_enable(e_menu_keyconfig, MA_CTRL_NUBS_BTNS, MENU_SHOW_NUBS_BTNS); me_enable(e_menu_keyconfig, MA_CTRL_VIBRATION, MENU_SHOW_VIBRATION); me_enable(e_menu_keyconfig, MA_CTRL_DEADZONE, MENU_SHOW_DEADZONE); + me_enable(e_menu_options, MA_OPT_DISP_OPTS, MENU_SHOW_DISPLAY); + +#ifdef TRIMUI + me_enable(e_menu_plugin_options, MA_PLUG_PEOPS, FALSE); + me_enable(e_menu_plugin_options, MA_PLUG_PEOPSGL, FALSE); +#endif } void menu_notify_mode_change(int w, int h, int bpp) diff --git a/frontend/menu.h b/frontend/menu.h index 8f5acda..db9b665 100644 --- a/frontend/menu.h +++ b/frontend/menu.h @@ -2,6 +2,7 @@ #define __MENU_H__ void menu_init(void); +int menu_load_config(int is_game); void menu_prepare_emu(void); void menu_loop(void); void menu_finish(void); diff --git a/frontend/menu_trimui.h b/frontend/menu_trimui.h new file mode 100644 index 0000000..6fa0fdc --- /dev/null +++ b/frontend/menu_trimui.h @@ -0,0 +1,31 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#ifndef UI_FEATURES_H +#define UI_FEATURES_H + +#define MENU_BIOS_PATH "pcsx_rearmed/bios/" +#define MENU_SHOW_VARSCALER 0 +#define MENU_SHOW_VOUTMODE 0 +#define MENU_SHOW_SCALER2 0 +#define MENU_SHOW_NUBS_BTNS 0 +#define MENU_SHOW_VIBRATION 0 +#define MENU_SHOW_DEADZONE 0 +#define MENU_SHOW_MINIMIZE 0 +#define MENU_SHOW_FULLSCREEN 1 +#define MENU_SHOW_VOLUME 0 +#define MENU_SHOW_DISPLAY 0 + +#endif diff --git a/frontend/plat_trimui.c b/frontend/plat_trimui.c new file mode 100644 index 0000000..6b1038a --- /dev/null +++ b/frontend/plat_trimui.c @@ -0,0 +1,382 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#include <stdio.h> +#include <stdlib.h> +#include <stdbool.h> +#include <string.h> +#include <unistd.h> +#include <sys/mman.h> +#include <sys/types.h> +#include <SDL.h> + +#include "main.h" +#include "menu.h" +#include "plat.h" +#include "cspace.h" +#include "blit320.h" +#include "plugin_lib.h" +#include "libpicofe/menu.h" +#include "libpicofe/plat.h" +#include "libpicofe/input.h" +#include "libpicofe/in_sdl.h" +#include "../libpcsxcore/psxmem_map.h" + +SDL_Surface* screen; +struct plat_target plat_target; + +static unsigned short *psx_vram; +static unsigned short *cspace_buf; +static int psx_step, psx_width, psx_height, psx_bpp; +static int psx_offset_x, psx_offset_y, psx_src_width, psx_src_height; +static int fb_offset_x, fb_offset_y; + +static const struct in_default_bind in_sdl_defbinds[] = { + { SDLK_UP, IN_BINDTYPE_PLAYER12, DKEY_UP }, + { SDLK_DOWN, IN_BINDTYPE_PLAYER12, DKEY_DOWN }, + { SDLK_LEFT, IN_BINDTYPE_PLAYER12, DKEY_LEFT }, + { SDLK_RIGHT, IN_BINDTYPE_PLAYER12, DKEY_RIGHT }, + { SDLK_LSHIFT, IN_BINDTYPE_PLAYER12, DKEY_TRIANGLE }, + { SDLK_LCTRL, IN_BINDTYPE_PLAYER12, DKEY_CROSS }, + { SDLK_SPACE, IN_BINDTYPE_PLAYER12, DKEY_CIRCLE }, + { SDLK_LALT, IN_BINDTYPE_PLAYER12, DKEY_SQUARE }, + { SDLK_RETURN, IN_BINDTYPE_PLAYER12, DKEY_START }, + { SDLK_RCTRL, IN_BINDTYPE_PLAYER12, DKEY_SELECT }, + { SDLK_TAB, IN_BINDTYPE_PLAYER12, DKEY_L1 }, + { SDLK_BACKSPACE, IN_BINDTYPE_PLAYER12, DKEY_R1 }, + { SDLK_e, IN_BINDTYPE_PLAYER12, DKEY_L2 }, + { SDLK_t, IN_BINDTYPE_PLAYER12, DKEY_R2 }, + { SDLK_ESCAPE, IN_BINDTYPE_EMU, SACTION_ENTER_MENU }, + { SDLK_F1, IN_BINDTYPE_EMU, SACTION_SAVE_STATE }, + { SDLK_F2, IN_BINDTYPE_EMU, SACTION_LOAD_STATE }, + { SDLK_F3, IN_BINDTYPE_EMU, SACTION_PREV_SSLOT }, + { SDLK_F4, IN_BINDTYPE_EMU, SACTION_NEXT_SSLOT }, + { SDLK_F5, IN_BINDTYPE_EMU, SACTION_TOGGLE_FSKIP }, + { SDLK_F6, IN_BINDTYPE_EMU, SACTION_SCREENSHOT }, + { SDLK_F7, IN_BINDTYPE_EMU, SACTION_TOGGLE_FPS }, + { SDLK_F8, IN_BINDTYPE_EMU, SACTION_SWITCH_DISPMODE }, + { SDLK_F11, IN_BINDTYPE_EMU, SACTION_TOGGLE_FULLSCREEN }, + { SDLK_F12, IN_BINDTYPE_EMU, SACTION_FAST_FORWARD }, + { 0, 0, 0 } +}; + +const struct menu_keymap in_sdl_key_map[] = +{ + { SDLK_UP, PBTN_UP }, + { SDLK_DOWN, PBTN_DOWN }, + { SDLK_LEFT, PBTN_LEFT }, + { SDLK_RIGHT, PBTN_RIGHT }, + { SDLK_SPACE, PBTN_MOK }, + { SDLK_LCTRL, PBTN_MBACK }, + { SDLK_LALT, PBTN_MA2 }, + { SDLK_LSHIFT, PBTN_MA3 }, + { SDLK_TAB, PBTN_L }, + { SDLK_BACKSPACE, PBTN_R }, +}; + +const struct menu_keymap in_sdl_joy_map[] = +{ + { SDLK_UP, PBTN_UP }, + { SDLK_DOWN, PBTN_DOWN }, + { SDLK_LEFT, PBTN_LEFT }, + { SDLK_RIGHT, PBTN_RIGHT }, + { SDLK_WORLD_0, PBTN_MOK }, + { SDLK_WORLD_1, PBTN_MBACK }, + { SDLK_WORLD_2, PBTN_MA2 }, + { SDLK_WORLD_3, PBTN_MA3 }, +}; + +static const char * const in_sdl_key_names[SDLK_LAST] = { + [SDLK_UP] = "up", + [SDLK_DOWN] = "down", + [SDLK_LEFT] = "left", + [SDLK_RIGHT] = "right", + [SDLK_LSHIFT] = "x", + [SDLK_LCTRL] = "b", + [SDLK_SPACE] = "a", + [SDLK_LALT] = "y", + [SDLK_RETURN] = "start", + [SDLK_RCTRL] = "select", + [SDLK_TAB] = "l", + [SDLK_BACKSPACE] = "r", + [SDLK_ESCAPE] = "menu", +}; + +static const struct in_pdata in_sdl_platform_data = { + .defbinds = in_sdl_defbinds, + .key_map = in_sdl_key_map, + .kmap_size = sizeof(in_sdl_key_map) / sizeof(in_sdl_key_map[0]), + .joy_map = in_sdl_joy_map, + .jmap_size = sizeof(in_sdl_joy_map) / sizeof(in_sdl_joy_map[0]), + .key_names = in_sdl_key_names, +}; + +static void *fb_flip(void) +{ + static int flip=0; + + { + flip^=1; + SDL_Flip(screen); + } + return screen->pixels; +} + +void plat_video_menu_enter(int is_rom_loaded) +{ +} + +void plat_video_menu_begin(void) +{ + g_menuscreen_ptr = fb_flip(); +} + +void plat_video_menu_end(void) +{ + g_menuscreen_ptr = fb_flip(); +} + +void plat_video_menu_leave(void) +{ + if (psx_vram == NULL) { + printf("%s, GPU plugin did not provide vram\n", __func__); + exit(-1); + } + + SDL_LockSurface(screen); + memset(g_menuscreen_ptr, 0, 320*240 * sizeof(uint16_t)); + SDL_UnlockSurface(screen); + g_menuscreen_ptr = fb_flip(); + SDL_LockSurface(screen); + memset(g_menuscreen_ptr, 0, 320*240 * sizeof(uint16_t)); + SDL_UnlockSurface(screen); +} + +void *plat_prepare_screenshot(int *w, int *h, int *bpp) +{ + *w = 320; + *h = 240; + *bpp = psx_bpp; + return pl_vout_buf; +} + +void plat_minimize(void) +{ +} + +#define make_flip_func(name, scale, blitfunc) \ + static void name(int doffs, const void *vram_, int w, int h, int sstride, int bgr24) \ + { \ + const unsigned short *vram = vram_; \ + unsigned char *conv = (unsigned char *)cspace_buf; \ + unsigned char *dst = (unsigned char *)screen->pixels + \ + (fb_offset_y * 320 + fb_offset_x) * sizeof(uint16_t); \ + int dst_stride = 640; \ + int len = psx_src_width * psx_bpp / 8; \ + int i; \ + void (*convertfunc)(void *dst, const void *src, int bytes); \ + convertfunc = psx_bpp == 24 ? bgr888_to_rgb565 : bgr555_to_rgb565; \ + \ + SDL_LockSurface(screen); \ + vram += psx_offset_y * 1024 + psx_offset_x; \ + for (i = psx_src_height; i > 0; i--, \ + vram += psx_step * 1024, \ + dst += dst_stride, \ + conv += dst_stride) { \ + if (scale) { \ + convertfunc(conv, vram, len); \ + blitfunc(dst, conv, dst_stride); \ + } else { \ + convertfunc(dst, vram, len); \ + } \ + } \ + SDL_UnlockSurface(screen); \ + } + +make_flip_func(raw_blit_soft, false, memcpy) +make_flip_func(raw_blit_soft_368, true, blit320_368) +make_flip_func(raw_blit_soft_512, true, blit320_512) +make_flip_func(raw_blit_soft_640, true, blit320_640) + +void *plat_gvideo_set_mode(int *w_, int *h_, int *bpp_) +{ + int poff_w, poff_h, w_max; + int w = *w_, h = *h_, bpp = *bpp_; + + if (!w || !h || !bpp) + return NULL; + + printf("psx mode: %dx%d@%d\n", w, h, bpp); + psx_width = w; + psx_height = h; + psx_bpp = bpp; + + switch (w + (bpp != 16) + !soft_scaling) { + case 640: + pl_plat_blit = raw_blit_soft_640; + w_max = 640; + break; + case 512: + pl_plat_blit = raw_blit_soft_512; + w_max = 512; + break; + case 384: + case 368: + pl_plat_blit = raw_blit_soft_368; + w_max = 368; + break; + default: + pl_plat_blit = raw_blit_soft; + w_max = 320; + break; + } + + psx_step = 1; + if (h > 256) { + psx_step = 2; + h /= 2; + } + + poff_w = poff_h = 0; + if (w > w_max) { + poff_w = w / 2 - w_max / 2; + w = w_max; + } + fb_offset_x = 0; + if (w < 320) + fb_offset_x = 320/2 - w / 2; + if (h > 240) { + poff_h = h / 2 - 240/2; + h = 240; + } + fb_offset_y = 240/2 - h / 2; + + psx_offset_x = poff_w * psx_bpp/8 / 2; + psx_offset_y = poff_h; + psx_src_width = w; + psx_src_height = h; + + if (fb_offset_x || fb_offset_y) { + // not fullscreen, must clear borders + SDL_LockSurface(screen); + memset(g_menuscreen_ptr, 0, 320*240 * sizeof(uint16_t)); + SDL_UnlockSurface(screen); + g_menuscreen_ptr = fb_flip(); + SDL_LockSurface(screen); + memset(g_menuscreen_ptr, 0, 320*240 * sizeof(uint16_t)); + SDL_UnlockSurface(screen); + memset(cspace_buf, 0, 320*240 * sizeof(uint16_t)); + } + + // adjust for hud + *w_ = 320; + *h_ = fb_offset_y + psx_src_height; + return g_menuscreen_ptr; +} + +/* not really used, we do raw_flip */ +void plat_gvideo_open(int is_pal) +{ +} + +void *plat_gvideo_flip(void) +{ + g_menuscreen_ptr = fb_flip(); + return g_menuscreen_ptr; +} + +void plat_gvideo_close(void) +{ +} + +static void *pl_emu_mmap(unsigned long addr, size_t size, int is_fixed, enum psxMapTag tag) +{ + void *retval; + + retval = plat_mmap(addr, size, 0, is_fixed); + if (tag == MAP_TAG_VRAM) { + psx_vram = retval; + } + return retval; +} + +static void pl_emu_munmap(void *ptr, size_t size, enum psxMapTag tag) +{ + plat_munmap(ptr, size); +} + +void plat_sdl_event_handler(void *event_) +{ +} + +void plat_init(void) +{ + if (SDL_WasInit(SDL_INIT_EVERYTHING)) { + SDL_InitSubSystem(SDL_INIT_VIDEO); + } + else { + SDL_Init(SDL_INIT_VIDEO); + } + screen = SDL_SetVideoMode(320, 240, 16, SDL_SWSURFACE); + if (screen == NULL) { + printf("%s, failed to set video mode\n", __func__); + exit(-1); + } + SDL_ShowCursor(0); + system("echo 10 > /proc/sys/vm/swappiness"); + + cspace_buf = calloc(1, 640 * 480 * sizeof(uint16_t)); + if (!cspace_buf) { + printf("%s, failed to allocate color conversion buffer\n", __func__); + exit(-1); + } + + g_menuscreen_w = 320; + g_menuscreen_h = 240; + g_menuscreen_pp = 320; + g_menuscreen_ptr = fb_flip(); + + in_sdl_init(&in_sdl_platform_data, plat_sdl_event_handler); + in_probe(); + + pl_plat_blit = raw_blit_soft; + psx_src_width = 320; + psx_src_height = 240; + psx_bpp = 16; + + pl_rearmed_cbs.screen_w = 320; + pl_rearmed_cbs.screen_h = 240; + psxMapHook = pl_emu_mmap; + psxUnmapHook = pl_emu_munmap; + in_enable_vibration = 1; +} + +void plat_pre_finish(void) +{ + system("echo 60 > /proc/sys/vm/swappiness"); +} + +void plat_finish(void) +{ + if (cspace_buf) { + free(cspace_buf); + } + + SDL_Quit(); +} + +void plat_trigger_vibrate(int pad, int low, int high) +{ +} diff --git a/frontend/plugin.c b/frontend/plugin.c index a617c24..47578d3 100644 --- a/frontend/plugin.c +++ b/frontend/plugin.c @@ -70,13 +70,13 @@ static long PADreadPort1(PadDataS *pad) { pad->absoluteX = in_analog_left[pad_index][0]; pad->absoluteY = in_analog_left[pad_index][1]; } - +#ifdef HAVE_LIBRETRO if (in_type[pad_index] == PSE_PAD_TYPE_MOUSE) { pad->moveX = in_mouse[pad_index][0]; pad->moveY = in_mouse[pad_index][1]; } - +#endif return 0; } @@ -102,11 +102,13 @@ static long PADreadPort2(PadDataS *pad) { pad->absoluteY = in_analog_left[pad_index][1]; } +#ifdef HAVE_LIBRETRO if (in_type[pad_index] == PSE_PAD_TYPE_MOUSE) { pad->moveX = in_mouse[pad_index][0]; pad->moveY = in_mouse[pad_index][1]; } +#endif return 0; } 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; diff --git a/plugins/dfsound/alsa.c b/plugins/dfsound/alsa.c index 6b9f83e..9873655 100644 --- a/plugins/dfsound/alsa.c +++ b/plugins/dfsound/alsa.c @@ -166,20 +166,22 @@ static void alsa_finish(void) } } -// GET BYTES BUFFERED -static int alsa_busy(void) -{ +static float alsa_capacity(void) { int l; - if (handle == NULL) // failed to open? - return 1; + if (handle == NULL) return 0; + if (buffer_size == 0) return 0; + l = snd_pcm_avail(handle); if (l < 0) return 0; - if (l < buffer_size / 2) // can we write in at least the half of fragments? - l = 1; // -> no? wait - else l = 0; // -> else go on - return l; + return (float)l / buffer_size; +} + +// GET BYTES BUFFERED +static int alsa_busy(void) +{ + return alsa_capacity() < 0.5; } // FEED SOUND DATA @@ -219,4 +221,5 @@ void out_register_alsa(struct out_driver *drv) drv->finish = alsa_finish; drv->busy = alsa_busy; drv->feed = alsa_feed; + drv->capacity = alsa_capacity; } diff --git a/plugins/dfsound/nullsnd.c b/plugins/dfsound/nullsnd.c index d8714df..ba6e51a 100644 --- a/plugins/dfsound/nullsnd.c +++ b/plugins/dfsound/nullsnd.c @@ -11,6 +11,12 @@ static void none_finish(void) { } +// GET BUFFER AVAILABLE +static float none_capacity(void) +{ + return 0.3; +} + // GET BYTES BUFFERED static int none_busy(void) { @@ -29,4 +35,5 @@ void out_register_none(struct out_driver *drv) drv->finish = none_finish; drv->busy = none_busy; drv->feed = none_feed; + drv->capacity = none_capacity; } diff --git a/plugins/dfsound/oss.c b/plugins/dfsound/oss.c index 6b1cb4a..67ba4c9 100644 --- a/plugins/dfsound/oss.c +++ b/plugins/dfsound/oss.c @@ -128,25 +128,26 @@ static void oss_finish(void) } //////////////////////////////////////////////////////////////////////// -// GET BUFFERED STATUS +// GET BUFFER AVAILABLE //////////////////////////////////////////////////////////////////////// -static int oss_busy(void) +static float oss_capacity(void) { audio_buf_info info; - unsigned long l; - if(oss_audio_fd == -1) return 1; - if(ioctl(oss_audio_fd,SNDCTL_DSP_GETOSPACE,&info)==-1) - l=0; - else - { - if(info.fragments<(info.fragstotal>>1)) // can we write in at least the half of fragments? - l=1; // -> no? wait - else l=0; // -> else go on - } + if(oss_audio_fd == -1) return 0; + if(ioctl(oss_audio_fd,SNDCTL_DSP_GETOSPACE,&info)==-1) return 0; + if(info.fragstotal == 0) return 0; + return (float)info.fragments / info.fragstotal; +} - return l; +//////////////////////////////////////////////////////////////////////// +// GET BUFFERED STATUS +//////////////////////////////////////////////////////////////////////// + +static int oss_busy(void) +{ + return oss_capacity() < 0.5; } //////////////////////////////////////////////////////////////////////// @@ -186,4 +187,5 @@ void out_register_oss(struct out_driver *drv) drv->finish = oss_finish; drv->busy = oss_busy; drv->feed = oss_feed; + drv->capacity = oss_capacity; } diff --git a/plugins/dfsound/out.h b/plugins/dfsound/out.h index e4878a8..2dcd226 100644 --- a/plugins/dfsound/out.h +++ b/plugins/dfsound/out.h @@ -7,6 +7,7 @@ struct out_driver { void (*finish)(void); int (*busy)(void); void (*feed)(void *data, int bytes); + float (*capacity)(void); }; extern struct out_driver *out_current; diff --git a/plugins/dfsound/pulseaudio.c b/plugins/dfsound/pulseaudio.c index 8ffd58f..0f4e32e 100644 --- a/plugins/dfsound/pulseaudio.c +++ b/plugins/dfsound/pulseaudio.c @@ -288,34 +288,32 @@ static void pulse_finish(void) } //////////////////////////////////////////////////////////////////////// -// GET BYTES BUFFERED +// GET BUFFER AVAILABLE //////////////////////////////////////////////////////////////////////// -static int pulse_busy(void) +static float pulse_capacity(void) { int free_space; if ((device.mainloop == NULL) || (device.api == NULL) || ( device.context == NULL) || (device.stream == NULL)) - return 1; + return 0; pa_threaded_mainloop_lock (device.mainloop); free_space = pa_stream_writable_size (device.stream); pa_threaded_mainloop_unlock (device.mainloop); + if (free_space == 0) return 0; - //fprintf (stderr, "Free space: %d\n", free_space); - //fprintf (stderr, "Used space: %d\n", maxlength - free_space); - if (free_space < mixlen * 3) - { - // Don't buffer anymore, just play - //fprintf (stderr, "Not buffering.\n"); - return 1; - } - else - { - // Buffer some sound - //fprintf (stderr, "Buffering.\n"); - return 0; - } + return (float)free_space / mixlen; +} + + +//////////////////////////////////////////////////////////////////////// +// GET BYTES BUFFERED +//////////////////////////////////////////////////////////////////////// + +static int pulse_busy(void) +{ + return pulse_capacity() < 0.33; } //////////////////////////////////////////////////////////////////////// @@ -346,4 +344,5 @@ void out_register_pulse(struct out_driver *drv) drv->finish = pulse_finish; drv->busy = pulse_busy; drv->feed = pulse_feed; + drv->capacity = pulse_capacity; } diff --git a/plugins/dfsound/sdl.c b/plugins/dfsound/sdl.c index ce92b6e..5a5ca51 100644 --- a/plugins/dfsound/sdl.c +++ b/plugins/dfsound/sdl.c @@ -103,17 +103,20 @@ static void sdl_finish(void) { pSndBuffer = NULL; } -static int sdl_busy(void) { +static float sdl_capacity(void) { int size; - if (pSndBuffer == NULL) return 1; + if (pSndBuffer == NULL) return 0; + if (iBufSize == 0) return 0; size = iReadPos - iWritePos; if (size <= 0) size += iBufSize; - if (size < iBufSize / 2) return 1; + return (float)size / iBufSize; +} - return 0; +static int sdl_busy(void) { + return sdl_capacity() < 0.5; } static void sdl_feed(void *pSound, int lBytes) { @@ -140,4 +143,5 @@ void out_register_sdl(struct out_driver *drv) drv->finish = sdl_finish; drv->busy = sdl_busy; drv->feed = sdl_feed; + drv->capacity = sdl_capacity; } diff --git a/plugins/gpulib/gpu.c b/plugins/gpulib/gpu.c index ed37b71..cffb97d 100644 --- a/plugins/gpulib/gpu.c +++ b/plugins/gpulib/gpu.c @@ -97,7 +97,9 @@ static noinline void decide_frameskip(void) gpu.frameskip.frame_ready = 1; } - if (!gpu.frameskip.active && *gpu.frameskip.advice) + if (gpu.frameskip.set < 0 && gpu.frameskip.cnt < 2 && *gpu.frameskip.advice) + gpu.frameskip.active = 1; + else if (!gpu.frameskip.active && *gpu.frameskip.advice) gpu.frameskip.active = 1; else if (gpu.frameskip.set > 0 && gpu.frameskip.cnt < gpu.frameskip.set) gpu.frameskip.active = 1; |