gpulib: update after open
[pcsx_rearmed.git] / frontend / menu.c
index ec3c5a2..7bec49a 100644 (file)
 #include "../libpcsxcore/cdrom.h"
 #include "../libpcsxcore/cdriso.h"
 #include "../libpcsxcore/cheat.h"
-#include "../libpcsxcore/psemu_plugin_defs.h"
 #include "../libpcsxcore/new_dynarec/new_dynarec.h"
-#include "../plugins/dfinput/main.h"
+#include "../plugins/dfinput/externals.h"
 #include "../plugins/gpulib/cspace.h"
+#include "psemu_plugin_defs.h"
 #include "revision.h"
 
 #define REARMED_BIRTHDAY_TIME 1293306830       /* 25 Dec 2010 */
@@ -79,6 +79,7 @@ typedef enum
        MA_OPT_HWFILTER,
        MA_OPT_SWFILTER,
        MA_OPT_GAMMA,
+       MA_OPT_VOUT_MODE,
 } menu_id;
 
 static int last_vout_w, last_vout_h, last_vout_bpp;
@@ -90,7 +91,7 @@ static int psx_clock;
 static int memcard1_sel, memcard2_sel;
 int g_opts, g_scaler, g_gamma = 100;
 int soft_scaling, analog_deadzone; // for Caanoo
-int filter, soft_filter;
+int soft_filter;
 
 #ifdef __ARM_ARCH_7A__
 #define DEFAULT_PSX_CLOCK 57
@@ -115,11 +116,13 @@ static int bios_sel, gpu_plugsel, spu_plugsel;
 #ifndef UI_FEATURES_H
 #define MENU_BIOS_PATH "bios/"
 #define MENU_SHOW_VARSCALER 0
+#define MENU_SHOW_VOUTMODE 1
 #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
 #endif
 
@@ -227,6 +230,7 @@ static void menu_set_defconfig(void)
        analog_deadzone = 50;
        soft_scaling = 1;
        soft_filter = 0;
+       plat_target.vout_fullscreen = 0;
        psx_clock = DEFAULT_PSX_CLOCK;
 
        region = 0;
@@ -274,7 +278,7 @@ static const struct {
        CE_CONFIG_STR(Spu),
 //     CE_CONFIG_STR(Cdr),
        CE_CONFIG_VAL(Xa),
-       CE_CONFIG_VAL(Sio),
+//     CE_CONFIG_VAL(Sio),
        CE_CONFIG_VAL(Mdec),
        CE_CONFIG_VAL(Cdda),
        CE_CONFIG_VAL(Debug),
@@ -283,15 +287,16 @@ static const struct {
        CE_CONFIG_VAL(RCntFix),
        CE_CONFIG_VAL(VSyncWA),
        CE_CONFIG_VAL(Cpu),
-       CE_CONFIG_VAL(CdrReschedule),
        CE_INTVAL(region),
        CE_INTVAL_V(g_scaler, 2),
        CE_INTVAL(g_layer_x),
        CE_INTVAL(g_layer_y),
        CE_INTVAL(g_layer_w),
        CE_INTVAL(g_layer_h),
-       CE_INTVAL(filter),
        CE_INTVAL(soft_filter),
+       CE_INTVAL(plat_target.vout_method),
+       CE_INTVAL(plat_target.hwfilter),
+       CE_INTVAL(plat_target.vout_fullscreen),
        CE_INTVAL(state_slot),
        CE_INTVAL(cpu_clock),
        CE_INTVAL(g_opts),
@@ -624,12 +629,18 @@ static void draw_savestate_bg(int slot)
 
        x = gpu->ulControl[5] & 0x3ff;
        y = (gpu->ulControl[5] >> 10) & 0x1ff;
-       s = (u16 *)gpu->psxVRam + y * 1024 + x;
        w = psx_widths[(gpu->ulStatus >> 16) & 7];
        tmp = gpu->ulControl[7];
        h = ((tmp >> 10) & 0x3ff) - (tmp & 0x3ff);
        if (gpu->ulStatus & 0x80000) // doubleheight
                h *= 2;
+       if (h <= 0 || h > 512)
+               goto out;
+       if (y > 512 - 64)
+               y = 0;
+       if (y + h > 512)
+               h = 512 - y;
+       s = (u16 *)gpu->psxVRam + y * 1024 + x;
 
        x = max(0, g_menuscreen_w - w) & ~3;
        y = max(0, g_menuscreen_h / 2 - h / 2);
@@ -690,6 +701,9 @@ me_bind_action emuctrl_actions[] =
        { "Fast Forward     ", 1 << SACTION_FAST_FORWARD },
 #if MENU_SHOW_MINIMIZE
        { "Minimize         ", 1 << SACTION_MINIMIZE },
+#endif
+#if MENU_SHOW_FULLSCREEN
+       { "Toggle fullscreen", 1 << SACTION_TOGGLE_FULLSCREEN },
 #endif
        { "Enter Menu       ", 1 << SACTION_ENTER_MENU },
        { "Gun Trigger      ", 1 << SACTION_GUN_TRIGGER },
@@ -1068,6 +1082,7 @@ static const char *men_soft_filter[] = { "None",
 static const char *men_dummy[] = { NULL };
 static const char h_cscaler[]   = "Displays the scaler layer, you can resize it\n"
                                  "using d-pad or move it using R+d-pad";
+static const char h_overlay[]   = "Overlay provides hardware accelerated scaling";
 static const char h_soft_filter[] = "Works only if game uses low resolution modes";
 static const char h_gamma[]     = "Gamma/brightness adjustment (default 100)";
 
@@ -1126,8 +1141,9 @@ static int menu_loop_cscaler(int id, int keys)
 static menu_entry e_menu_gfx_options[] =
 {
        mee_enum      ("Scaler",                   MA_OPT_VARSCALER, g_scaler, men_scaler),
+       mee_enum      ("Video output mode",        MA_OPT_VOUT_MODE, plat_target.vout_method, men_dummy),
        mee_onoff     ("Software Scaling",         MA_OPT_SCALER2, soft_scaling, 1),
-       mee_enum      ("Hardware Filter",          MA_OPT_HWFILTER, filter, men_dummy),
+       mee_enum      ("Hardware Filter",          MA_OPT_HWFILTER, plat_target.hwfilter, men_dummy),
        mee_enum_h    ("Software Filter",          MA_OPT_SWFILTER, soft_filter, men_soft_filter, h_soft_filter),
        mee_range_h   ("Gamma adjustment",         MA_OPT_GAMMA, g_gamma, 1, 200, h_gamma),
 //     mee_onoff     ("Vsync",                    0, vsync, 1),
@@ -1352,7 +1368,6 @@ static int menu_loop_speed_hacks(int id, int keys)
        return 0;
 }
 
-static const char *men_cfg_cdrr[] = { "Auto", "ON", "OFF", NULL };
 static const char h_cfg_cpul[]   = "Shows CPU usage in %";
 static const char h_cfg_spu[]    = "Shows active SPU channels\n"
                                   "(green: normal, red: fmod, blue: noise)";
@@ -1366,7 +1381,6 @@ static const char h_cfg_rcnt1[]  = "Parasite Eve 2, Vandal Hearts 1/2 Fix\n"
                                   "(timing hack, breaks other games)";
 static const char h_cfg_rcnt2[]  = "InuYasha Sengoku Battle Fix\n"
                                   "(timing hack, breaks other games)";
-static const char h_cfg_cdrr[]   = "Compatibility tweak (CD timing hack, breaks FMVs)";
 static const char h_cfg_nodrc[]  = "Disable dynamic recompiler and use interpreter\n"
                                   "Might be useful to overcome some dynarec bugs";
 static const char h_cfg_shacks[] = "Breaks games but may give better performance\n"
@@ -1379,11 +1393,10 @@ static menu_entry e_menu_adv_options[] =
        mee_onoff_h   ("Disable Frame Limiter",  0, g_opts, OPT_NO_FRAMELIM, h_cfg_fl),
        mee_onoff_h   ("Disable XA Decoding",    0, Config.Xa, 1, h_cfg_xa),
        mee_onoff_h   ("Disable CD Audio",       0, Config.Cdda, 1, h_cfg_cdda),
-       mee_onoff_h   ("SIO IRQ Always Enabled", 0, Config.Sio, 1, h_cfg_sio),
+       //mee_onoff_h   ("SIO IRQ Always Enabled", 0, Config.Sio, 1, h_cfg_sio),
        mee_onoff_h   ("SPU IRQ Always Enabled", 0, Config.SpuIrq, 1, h_cfg_spuirq),
        //mee_onoff_h   ("Rootcounter hack",       0, Config.RCntFix, 1, h_cfg_rcnt1),
        mee_onoff_h   ("Rootcounter hack 2",     0, Config.VSyncWA, 1, h_cfg_rcnt2),
-       mee_enum_h    ("CD read reschedule hack",0, Config.CdrReschedule, men_cfg_cdrr, h_cfg_cdrr),
        mee_onoff_h   ("Disable dynarec (slow!)",0, Config.Cpu, 1, h_cfg_nodrc),
        mee_handler_h ("[Speed hacks]",             menu_loop_speed_hacks, h_cfg_shacks),
        mee_end,
@@ -2293,6 +2306,11 @@ void menu_init(void)
                && plat_target.cpu_clock_get != NULL && cpu_clock_st > 0;
        me_enable(e_menu_gfx_options, MA_OPT_CPU_CLOCKS, i);
 
+       i = me_id2offset(e_menu_gfx_options, MA_OPT_VOUT_MODE);
+       e_menu_gfx_options[i].data = plat_target.vout_methods;
+       me_enable(e_menu_gfx_options, MA_OPT_VOUT_MODE,
+               plat_target.vout_methods != NULL);
+
        i = me_id2offset(e_menu_gfx_options, MA_OPT_HWFILTER);
        e_menu_gfx_options[i].data = plat_target.hwfilters;
        me_enable(e_menu_gfx_options, MA_OPT_HWFILTER,
@@ -2305,6 +2323,7 @@ void menu_init(void)
        me_enable(e_menu_gfx_options, MA_OPT_SWFILTER, 0);
 #endif
        me_enable(e_menu_gfx_options, MA_OPT_VARSCALER, MENU_SHOW_VARSCALER);
+       me_enable(e_menu_gfx_options, MA_OPT_VOUT_MODE, MENU_SHOW_VOUTMODE);
        me_enable(e_menu_gfx_options, MA_OPT_VARSCALER_C, MENU_SHOW_VARSCALER);
        me_enable(e_menu_gfx_options, MA_OPT_SCALER2, MENU_SHOW_SCALER2);
        me_enable(e_menu_keyconfig, MA_CTRL_NUBS_BTNS, MENU_SHOW_NUBS_BTNS);