release r2, update credits
[fceu.git] / drivers / common / menu.c
index 5fe0cfc..6a7f795 100644 (file)
@@ -27,6 +27,7 @@
 #include "../../general.h"
 #include "../../input.h"
 #include "../../palette.h"
+#include "../../fce.h"
 #include "revision.h"
 
 #define array_size(x) (sizeof(x) / sizeof(x[0]))
@@ -57,6 +58,9 @@ typedef enum
        MA_OPT_GG,
        MA_OPT_SHOWFPS,
        MA_OPT_FSKIP,
+       MA_OPT_SWFILTER,
+       MA_OPT_HWFILTER,
+       MA_OPT_SCALING,
        MA_OPT_RENDERER,
        MA_OPT_SOUNDON,
        MA_OPT_SOUNDRATE,
@@ -95,7 +99,7 @@ static int emu_check_save_file(int slot, int *time)
        int retval = 0;
        int ret;
        
-       fname = FCEU_MakeFName(FCEUMKF_STATE,CurrentState,0);
+       fname = FCEU_MakeFName(FCEUMKF_STATE, slot, 0);
        st = fopen(fname,"rb");
        if (st == NULL)
                goto out;
@@ -426,6 +430,8 @@ static int menu_loop_fceu_options(int id, int keys)
 // -------------- options --------------
 
 static const char *men_frameskip[] = { "Auto", "0", "1", "2", "3", "4", NULL };
+static const char *men_swfilter[] = { "none", "Scale2x", "Eagle2x", NULL };
+static const char *men_scaling[] = { "1x", "proportional", "4:3 scaled", "fullscreen", NULL };
 static const char *men_rates[]   = { "8000", "11025", "16000", "22050", "44100", NULL };
 static const int   men_rates_i[] = {  8000 ,  11025 ,  16000 ,  22050 ,  44100 };
 static const char *men_region[] = { "Auto", "NTSC", "PAL", NULL };
@@ -436,12 +442,14 @@ static const char h_renderer[] = "ROM reload required for this\n"
 static int sndrate_i;
 static int sndon;
 static int turbo_i;
+static int frameskip_i;
 
 static void config_commit(void)
 {
        Settings.sound_rate = men_rates_i[sndrate_i];
-       soundvol = sndon ? 0 : 50;
+       soundvol = sndon ? 50 : 0;
        Settings.turbo_rate_add = (turbo_i * 2 << 24) / 60 + 1;
+       Settings.frameskip = frameskip_i - 1;
 
        if (Settings.region_force)
                FCEUI_SetVidSystem(Settings.region_force - 1);
@@ -449,8 +457,11 @@ static void config_commit(void)
 
 static menu_entry e_menu_options[] =
 {
-       mee_onoff      ("Show FPS",                MA_OPT_SHOWFPS, Settings.showfps, 1),
-       mee_enum       ("Frameskip",               MA_OPT_FSKIP, Settings.frameskip, men_frameskip),
+//     mee_onoff      ("Show FPS",                MA_OPT_SHOWFPS, Settings.showfps, 1),
+       mee_enum       ("Frameskip",               MA_OPT_FSKIP, frameskip_i, men_frameskip),
+       mee_enum       ("Softwere filter",         MA_OPT_SWFILTER, Settings.sw_filter, men_swfilter),
+       mee_enum       ("Hardware filter",         MA_OPT_HWFILTER, Settings.hw_filter, NULL),
+       mee_enum       ("Scaling",                 MA_OPT_SCALING, Settings.scaling, men_scaling),
        mee_onoff_h    ("Accurate renderer (slow)",MA_OPT_RENDERER, Settings.accurate_mode, 1, h_renderer),
        mee_onoff      ("Enable sound",            MA_OPT_SOUNDON, sndon, 1),
        mee_enum       ("Sound Rate",              MA_OPT_SOUNDRATE, sndrate_i, men_rates),
@@ -458,7 +469,7 @@ static menu_entry e_menu_options[] =
        mee_range      ("Turbo rate (Hz)",         MA_OPT_TURBO, turbo_i, 1, 30),
        mee_enum       ("Confirm savestate",       MA_OPT_SSTATE, Settings.sstate_confirm, men_sstate),
        mee_range      ("Save slot",               MA_OPT_SSLOT, CurrentState, 0, 9),
-       mee_range      ("Gamma correction",        MA_OPT_GAMMA, Settings.gamma, 0, 300),
+//     mee_range      ("Gamma correction",        MA_OPT_GAMMA, Settings.gamma, 0, 300),
        mee_handler    ("[FCE Ultra options]",     menu_loop_fceu_options),
        mee_cust_nosave("Save global config",      MA_OPT_SAVECFG,      mh_savecfg, mgn_saveloadcfg),
        mee_cust_nosave("Save cfg for loaded game",MA_OPT_SAVECFG_GAME, mh_savecfg, mgn_saveloadcfg),
@@ -471,6 +482,10 @@ static int menu_loop_options(int id, int keys)
        int oldrate;
        int i;
 
+       i = me_id2offset(e_menu_options, MA_OPT_HWFILTER);
+       e_menu_options[i].data = plat_target.filters;
+       me_enable(e_menu_options, MA_OPT_HWFILTER, plat_target.filters != NULL);
+
        oldrate = Settings.sound_rate;
        for (i = 0; i < array_size(men_rates_i); i++) {
                if (Settings.sound_rate == men_rates_i[i]) {
@@ -480,6 +495,7 @@ static int menu_loop_options(int id, int keys)
        }
        sndon = soundvol != 0;
        turbo_i = (Settings.turbo_rate_add * 60 / 2) >> 24;
+       frameskip_i = Settings.frameskip + 1;
 
        me_loop(e_menu_options, &sel);
 
@@ -492,15 +508,49 @@ static int menu_loop_options(int id, int keys)
 
 // -------------- root menu --------------
 
+static void draw_frame_main(void)
+{
+       struct tm *tmp;
+       time_t ltime;
+       int capacity = -1;
+       char ltime_s[16];
+       char buff[128];
+       char *out;
+
+       if (!fceugi || !GameInterface)
+               return;
+
+       buff[0] = 0;
+       GameInterface(GI_INFOSTRING, buff);
+
+       smalltext_out16(4, 1, buff, 0xf7de);
+
+       if (plat_target.get_bat_capacity)
+               capacity = plat_target.get_bat_capacity();
+       ltime = time(NULL);
+       tmp = localtime(&ltime);
+       strftime(ltime_s, sizeof(ltime_s), "%H:%M", tmp);
+       if (capacity >= 0) {
+               snprintf(buff, sizeof(buff), "%s %3d%%", ltime_s, capacity);
+               out = buff;
+       }
+       else
+               out = ltime_s;
+       smalltext_out16(4, 1 + me_sfont_h, out, 0xf7de);
+}
+
 static const char credits_text[] = 
        "GPFCE " REV "\n"
        "(c) notaz, 2007,2012\n\n"
-       "Based on FCE Ultra versions\n"
-       "0.81 and 0.98.1x\n\n"
+       "Based on various FCE Ultra\n"
+       " / FCEUX versions\n\n"
        "         - Credits -\n"
        "Bero: FCE\n"
        "Xodnizel: FCE Ultra\n"
-       "FCA author: 6502 core\n";
+       "FCEUX team: FCEUX\n"
+       "CaH4e3: mappers\n"
+       "FCA author: 6502 core\n"
+       "M-HT: NEON scalers\n";
 
 static void draw_frame_credits(void)
 {
@@ -534,21 +584,18 @@ static int main_menu_handler(int id, int keys)
                break;
        case MA_MAIN_SAVE_STATE:
                if (fceugi) {
-                       Exit = 0;
                        return menu_loop_savestate(0);
                }
                break;
        case MA_MAIN_LOAD_STATE:
                if (fceugi) {
-                       Exit = 0;
                        return menu_loop_savestate(1);
                }
                break;
        case MA_MAIN_RESET_GAME:
                if (fceugi) {
                        FCEU_DoSimpleCommand(FCEUNPCMD_RESET);
-                       Exit = 0;
-                       return 0;
+                       return 1;
                }
                break;
        case MA_MAIN_LOAD_ROM:
@@ -602,10 +649,11 @@ int menu_loop(void)
        me_enable(e_menu_main, MA_MAIN_CHEATS,      fceugi && cheats);
 
        plat_video_menu_enter(fceugi != NULL);
+       memcpy(g_menubg_ptr, g_menubg_src_ptr, g_menuscreen_w * g_menuscreen_h * 2);
        in_set_config_int(0, IN_CFG_BLOCKING, 1);
 
        do {
-               me_loop_d(e_menu_main, &sel, NULL, NULL);
+               me_loop_d(e_menu_main, &sel, NULL, draw_frame_main);
        } while (!fceugi && menu_loop_ret == 0);
 
        /* wait until menu, ok, back is released */
@@ -615,6 +663,7 @@ int menu_loop(void)
        in_set_config_int(0, IN_CFG_BLOCKING, 0);
        plat_video_menu_leave();
 
+       Exit = 0;
        return menu_loop_ret;
 }