From 2e7821e337ca9da422c64f7d0a198b33042e84a8 Mon Sep 17 00:00:00 2001
From: radius <andres.430@gmail.com>
Date: Tue, 29 Nov 2016 23:22:22 -0500
Subject: [PATCH 1/2] add a toggle to the firmware check so it can be overruled

---
 config.def.h                 |  2 +-
 configuration.c              |  1 +
 configuration.h              |  1 +
 intl/msg_hash_chs.c          | 10 ++++++++++
 intl/msg_hash_eo.h           |  4 ++++
 intl/msg_hash_fr.h           |  4 ++++
 intl/msg_hash_ja.c           | 10 ++++++++++
 intl/msg_hash_ja.h           |  4 ++++
 intl/msg_hash_lbl.h          |  2 ++
 intl/msg_hash_nl.h           |  4 ++++
 intl/msg_hash_ru.h           |  4 ++++
 intl/msg_hash_us.c           | 10 ++++++++++
 intl/msg_hash_us.h           |  6 ++++++
 intl/msg_hash_vn.c           | 10 ++++++++++
 menu/cbs/menu_cbs_sublabel.c |  4 ++++
 menu/menu_displaylist.c      |  3 +++
 menu/menu_setting.c          | 16 +++++++++++-----
 msg_hash.h                   |  1 +
 tasks/task_content.c         |  6 ++++--
 19 files changed, 94 insertions(+), 8 deletions(-)

diff --git a/config.def.h b/config.def.h
index 7320a71d71..9afa317c8c 100644
--- a/config.def.h
+++ b/config.def.h
@@ -437,7 +437,7 @@ static const bool load_dummy_on_core_shutdown = false;
 #else
 static const bool load_dummy_on_core_shutdown = true;
 #endif
-
+static const bool check_firmware_before_loading = true;
 /* Forcibly disable composition.
  * Only valid on Windows Vista/7/8 for now. */
 static const bool disable_composition = false;
diff --git a/configuration.c b/configuration.c
index 9256fde0b9..c727ed3dd5 100644
--- a/configuration.c
+++ b/configuration.c
@@ -699,6 +699,7 @@ static int populate_settings_bool(settings_t *settings, struct config_bool_setti
    SETTING_BOOL("input_descriptor_label_show",   &settings->input.input_descriptor_label_show, true, input_descriptor_label_show, false);
    SETTING_BOOL("input_descriptor_hide_unbound", &settings->input.input_descriptor_hide_unbound, true, input_descriptor_hide_unbound, false);
    SETTING_BOOL("load_dummy_on_core_shutdown",   &settings->load_dummy_on_core_shutdown, true, load_dummy_on_core_shutdown, false);
+   SETTING_BOOL("check_firmware_before_loading", &settings->check_firmware_before_loading, true, check_firmware_before_loading, false);
    SETTING_BOOL("builtin_mediaplayer_enable",    &settings->multimedia.builtin_mediaplayer_enable, false, false /* TODO */, false);
    SETTING_BOOL("builtin_imageviewer_enable",    &settings->multimedia.builtin_imageviewer_enable, true, true, false);
    SETTING_BOOL("fps_show",                      &settings->fps_show, true, false, false);
diff --git a/configuration.h b/configuration.h
index bef8bbb67e..fc52188ea4 100644
--- a/configuration.h
+++ b/configuration.h
@@ -440,6 +440,7 @@ typedef struct settings
 #endif
    bool fps_show;
    bool load_dummy_on_core_shutdown;
+   bool check_firmware_before_loading;
 
    bool game_specific_options;
    bool auto_overrides_enable;
diff --git a/intl/msg_hash_chs.c b/intl/msg_hash_chs.c
index 9b83e5dee7..524e028390 100644
--- a/intl/msg_hash_chs.c
+++ b/intl/msg_hash_chs.c
@@ -346,6 +346,16 @@ int menu_hash_get_help_chs_enum(enum msg_hash_enums msg, char *s, size_t len)
                "inside the menu and RetroArch won't \n"
                "shutdown.");
          break;
+      case MENU_ENUM_LABEL_CHECK_FOR_MISSING_FIRMWARE:
+         snprintf(s, len,
+               "Some cores might need \n"
+               "firmware or bios files. \n"
+               " \n"
+               "If this option is disabled, \n"
+               "it will try to load even if such \n"
+               "firmware is missing. \n"
+               "down. \n");
+         break;
       case MENU_ENUM_LABEL_PARENT_DIRECTORY:
          snprintf(s, len,
                "回到上级目录。");
diff --git a/intl/msg_hash_eo.h b/intl/msg_hash_eo.h
index 0fb82b102e..2de206143c 100644
--- a/intl/msg_hash_eo.h
+++ b/intl/msg_hash_eo.h
@@ -2152,6 +2152,10 @@ MSG_HASH(
    MENU_ENUM_SUBLABEL_DUMMY_ON_CORE_SHUTDOWN,
    "Some cores might have a shutdown feature. If enabled, it will prevent the core from shutting RetroArch down. Instead, it loads a dummy core."
    )
+MSG_HASH(
+   MENU_ENUM_SUBLABEL_CHECK_FOR_MISSING_FIRMWARE,
+   "Check if all the required firmware is present before attempting to load content."
+   )
 MSG_HASH(
    MENU_ENUM_SUBLABEL_VIDEO_REFRESH_RATE,
    "Vertical refresh rate of your monitor. Used to calculate a suitable audio input rate. NOTE: This will be ignored if 'Threaded Video' is enabled."
diff --git a/intl/msg_hash_fr.h b/intl/msg_hash_fr.h
index c6e6c6a73e..62fbcc4d50 100644
--- a/intl/msg_hash_fr.h
+++ b/intl/msg_hash_fr.h
@@ -2118,6 +2118,10 @@ MSG_HASH(
    MENU_ENUM_SUBLABEL_DUMMY_ON_CORE_SHUTDOWN,
    "Some cores might have a shutdown feature. If enabled, it will prevent the core from shutting RetroArch down. Instead, it loads a dummy core."
    )
+MSG_HASH(
+   MENU_ENUM_SUBLABEL_CHECK_FOR_MISSING_FIRMWARE,
+   "Check if all the required firmware is present before attempting to load content."
+   )
 MSG_HASH(
    MENU_ENUM_SUBLABEL_VIDEO_REFRESH_RATE,
    "Vertical refresh rate of your monitor. Used to calculate a suitable audio input rate. NOTE: This will be ignored if 'Threaded Video' is enabled."
diff --git a/intl/msg_hash_ja.c b/intl/msg_hash_ja.c
index cbeca862ac..c837e53cbd 100644
--- a/intl/msg_hash_ja.c
+++ b/intl/msg_hash_ja.c
@@ -354,6 +354,16 @@ int menu_hash_get_help_jp_enum(enum msg_hash_enums msg, char *s, size_t len)
                "inside the menu and RetroArch won't \n"
                "shutdown.");
          break;
+      case MENU_ENUM_LABEL_CHECK_FOR_MISSING_FIRMWARE:
+         snprintf(s, len,
+               "Some cores might need \n"
+               "firmware or bios files. \n"
+               " \n"
+               "If this option is disabled, \n"
+               "it will try to load even if such \n"
+               "firmware is missing. \n"
+               "down. \n");
+         break;
       case MENU_ENUM_LABEL_PARENT_DIRECTORY:
          snprintf(s, len,
                "Go back to the parent directory.");
diff --git a/intl/msg_hash_ja.h b/intl/msg_hash_ja.h
index c0134c711a..e06ed3f55e 100644
--- a/intl/msg_hash_ja.h
+++ b/intl/msg_hash_ja.h
@@ -2144,6 +2144,10 @@ MSG_HASH(
    MENU_ENUM_SUBLABEL_DUMMY_ON_CORE_SHUTDOWN,
    "Some cores might have a shutdown feature. If enabled, it will prevent the core from shutting RetroArch down. Instead, it loads a dummy core."
    )
+MSG_HASH(
+   MENU_ENUM_SUBLABEL_CHECK_FOR_MISSING_FIRMWARE,
+   "Check if all the required firmware is present before attempting to load content."
+   )
 MSG_HASH(
    MENU_ENUM_SUBLABEL_VIDEO_REFRESH_RATE,
    "Vertical refresh rate of your monitor. Used to calculate a suitable audio input rate. NOTE: This will be ignored if 'Threaded Video' is enabled."
diff --git a/intl/msg_hash_lbl.h b/intl/msg_hash_lbl.h
index 58ff4d78dc..a553a2e312 100644
--- a/intl/msg_hash_lbl.h
+++ b/intl/msg_hash_lbl.h
@@ -328,6 +328,8 @@ MSG_HASH(MENU_ENUM_LABEL_DPI_OVERRIDE_VALUE,
       "dpi_override_value")
 MSG_HASH(MENU_ENUM_LABEL_DRIVER_SETTINGS,
       "driver_settings")
+MSG_HASH(MENU_ENUM_LABEL_CHECK_FOR_MISSING_FIRMWARE,
+      "check_for_missing_firmware")
 MSG_HASH(MENU_ENUM_LABEL_DUMMY_ON_CORE_SHUTDOWN,
       "dummy_on_core_shutdown")
 MSG_HASH(MENU_ENUM_LABEL_DYNAMIC_WALLPAPER,
diff --git a/intl/msg_hash_nl.h b/intl/msg_hash_nl.h
index a82c44b7a1..fbbba7b8d1 100644
--- a/intl/msg_hash_nl.h
+++ b/intl/msg_hash_nl.h
@@ -2152,6 +2152,10 @@ MSG_HASH(
    MENU_ENUM_SUBLABEL_DUMMY_ON_CORE_SHUTDOWN,
    "Some cores might have a shutdown feature. If enabled, it will prevent the core from shutting RetroArch down. Instead, it loads a dummy core."
    )
+MSG_HASH(
+   MENU_ENUM_SUBLABEL_CHECK_FOR_MISSING_FIRMWARE,
+   "Check if all the required firmware is present before attempting to load content."
+   )
 MSG_HASH(
    MENU_ENUM_SUBLABEL_VIDEO_REFRESH_RATE,
    "Vertical refresh rate of your monitor. Used to calculate a suitable audio input rate. NOTE: This will be ignored if 'Threaded Video' is enabled."
diff --git a/intl/msg_hash_ru.h b/intl/msg_hash_ru.h
index 26f1dc3c97..8fc44eeefa 100644
--- a/intl/msg_hash_ru.h
+++ b/intl/msg_hash_ru.h
@@ -2146,6 +2146,10 @@ MSG_HASH(
    MENU_ENUM_SUBLABEL_DUMMY_ON_CORE_SHUTDOWN,
    "Some cores might have a shutdown feature. If enabled, it will prevent the core from shutting RetroArch down. Instead, it loads a dummy core."
    )
+MSG_HASH(
+   MENU_ENUM_SUBLABEL_CHECK_FOR_MISSING_FIRMWARE,
+   "Check if all the required firmware is present before attempting to load content."
+   )
 MSG_HASH(
    MENU_ENUM_SUBLABEL_VIDEO_REFRESH_RATE,
    "Vertical refresh rate of your monitor. Used to calculate a suitable audio input rate. NOTE: This will be ignored if 'Threaded Video' is enabled."
diff --git a/intl/msg_hash_us.c b/intl/msg_hash_us.c
index d5abdde020..1379a72a7d 100644
--- a/intl/msg_hash_us.c
+++ b/intl/msg_hash_us.c
@@ -355,6 +355,16 @@ int menu_hash_get_help_us_enum(enum msg_hash_enums msg, char *s, size_t len)
                "inside the menu and RetroArch won't \n"
                "shutdown.");
          break;
+      case MENU_ENUM_LABEL_CHECK_FOR_MISSING_FIRMWARE:
+         snprintf(s, len,
+               "Some cores might need \n"
+               "firmware or bios files. \n"
+               " \n"
+               "If this option is disabled, \n"
+               "it will try to load even if such \n"
+               "firmware is missing. \n"
+               "down. \n");
+         break;
       case MENU_ENUM_LABEL_PARENT_DIRECTORY:
          snprintf(s, len,
                "Go back to the parent directory.");
diff --git a/intl/msg_hash_us.h b/intl/msg_hash_us.h
index 9bc408784a..41c5878965 100644
--- a/intl/msg_hash_us.h
+++ b/intl/msg_hash_us.h
@@ -522,6 +522,8 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_DRIVER_SETTINGS,
       "Driver")
 MSG_HASH(MENU_ENUM_LABEL_VALUE_DUMMY_ON_CORE_SHUTDOWN,
       "Load Dummy on Core Shutdown")
+MSG_HASH(MENU_ENUM_LABEL_VALUE_CHECK_FOR_MISSING_FIRMWARE,
+      "Check for Missing Firmware Before Loading")
 MSG_HASH(MENU_ENUM_LABEL_VALUE_DYNAMIC_WALLPAPER,
       "Dynamic Wallpaper")
 MSG_HASH(MENU_ENUM_LABEL_VALUE_DYNAMIC_WALLPAPERS_DIRECTORY,
@@ -2152,6 +2154,10 @@ MSG_HASH(
    MENU_ENUM_SUBLABEL_DUMMY_ON_CORE_SHUTDOWN,
    "Some cores might have a shutdown feature. If enabled, it will prevent the core from shutting RetroArch down. Instead, it loads a dummy core."
    )
+MSG_HASH(
+   MENU_ENUM_SUBLABEL_CHECK_FOR_MISSING_FIRMWARE,
+   "Check if all the required firmware is present before attempting to load content."
+   )
 MSG_HASH(
    MENU_ENUM_SUBLABEL_VIDEO_REFRESH_RATE,
    "Vertical refresh rate of your monitor. Used to calculate a suitable audio input rate. NOTE: This will be ignored if 'Threaded Video' is enabled."
diff --git a/intl/msg_hash_vn.c b/intl/msg_hash_vn.c
index 27fc34a523..ae666a994a 100644
--- a/intl/msg_hash_vn.c
+++ b/intl/msg_hash_vn.c
@@ -355,6 +355,16 @@ int menu_hash_get_help_vn_enum(enum msg_hash_enums msg, char *s, size_t len)
                "inside the menu and RetroArch won't \n"
                "shutdown.");
          break;
+      case MENU_ENUM_LABEL_CHECK_FOR_MISSING_FIRMWARE:
+         snprintf(s, len,
+               "Some cores might need \n"
+               "firmware or bios files. \n"
+               " \n"
+               "If this option is disabled, \n"
+               "it will try to load even if such \n"
+               "firmware is missing. \n"
+               "down. \n");
+         break;
       case MENU_ENUM_LABEL_PARENT_DIRECTORY:
          snprintf(s, len,
                "Go back to the parent thư mục.");
diff --git a/menu/cbs/menu_cbs_sublabel.c b/menu/cbs/menu_cbs_sublabel.c
index 7a5a65789a..f6ba1bb147 100644
--- a/menu/cbs/menu_cbs_sublabel.c
+++ b/menu/cbs/menu_cbs_sublabel.c
@@ -101,6 +101,7 @@ default_sublabel_macro(action_bind_sublabel_input_duty_cycle,              MENU_
 default_sublabel_macro(action_bind_sublabel_video_vertical_sync,           MENU_ENUM_SUBLABEL_VIDEO_VSYNC)
 default_sublabel_macro(action_bind_sublabel_core_allow_rotate,             MENU_ENUM_SUBLABEL_VIDEO_ALLOW_ROTATE)
 default_sublabel_macro(action_bind_sublabel_dummy_on_core_shutdown,        MENU_ENUM_SUBLABEL_DUMMY_ON_CORE_SHUTDOWN)
+default_sublabel_macro(action_bind_sublabel_dummy_check_missing_firmware,  MENU_ENUM_SUBLABEL_CHECK_FOR_MISSING_FIRMWARE)
 default_sublabel_macro(action_bind_sublabel_video_refresh_rate,            MENU_ENUM_SUBLABEL_VIDEO_REFRESH_RATE)
 default_sublabel_macro(action_bind_sublabel_audio_enable,                  MENU_ENUM_SUBLABEL_AUDIO_ENABLE)
 default_sublabel_macro(action_bind_sublabel_audio_max_timing_skew,         MENU_ENUM_SUBLABEL_AUDIO_MAX_TIMING_SKEW)
@@ -157,6 +158,9 @@ int menu_cbs_init_bind_sublabel(menu_file_list_cbs_t *cbs,
          case MENU_ENUM_LABEL_DUMMY_ON_CORE_SHUTDOWN:
             BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_dummy_on_core_shutdown);
             break;
+         case MENU_ENUM_LABEL_CHECK_FOR_MISSING_FIRMWARE:
+            BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_dummy_check_missing_firmware);
+            break;
          case MENU_ENUM_LABEL_VIDEO_ALLOW_ROTATE:
             BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_core_allow_rotate);
             break;
diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c
index 2a3868681f..f3975acdaa 100644
--- a/menu/menu_displaylist.c
+++ b/menu/menu_displaylist.c
@@ -5243,6 +5243,9 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, void *data)
          menu_displaylist_parse_settings_enum(menu, info,
                MENU_ENUM_LABEL_DUMMY_ON_CORE_SHUTDOWN,
                PARSE_ONLY_BOOL, false);
+         menu_displaylist_parse_settings_enum(menu, info,
+               MENU_ENUM_LABEL_CHECK_FOR_MISSING_FIRMWARE,
+               PARSE_ONLY_BOOL, false);
          menu_displaylist_parse_settings_enum(menu, info,
                MENU_ENUM_LABEL_VIDEO_ALLOW_ROTATE,
                PARSE_ONLY_BOOL, false);
diff --git a/menu/menu_setting.c b/menu/menu_setting.c
index 651f4a2aa5..6f334610ac 100644
--- a/menu/menu_setting.c
+++ b/menu/menu_setting.c
@@ -2712,7 +2712,7 @@ static bool setting_append_list(
       case SETTINGS_LIST_CORE:
          {
             unsigned i;
-            struct bool_entry bool_entries[4];
+            struct bool_entry bool_entries[5];
 
             START_GROUP(list, list_info, &group_info,
                   msg_hash_to_str(MENU_ENUM_LABEL_VALUE_CORE_SETTINGS), parent_group);
@@ -2743,12 +2743,18 @@ static bool setting_append_list(
             bool_entries[2].default_value  = true;
             bool_entries[2].flags          = SD_FLAG_ADVANCED;
 
-            bool_entries[3].target         = &settings->video.allow_rotate; 
-            bool_entries[3].name_enum_idx  = MENU_ENUM_LABEL_VIDEO_ALLOW_ROTATE;
-            bool_entries[3].SHORT_enum_idx = MENU_ENUM_LABEL_VALUE_VIDEO_ALLOW_ROTATE;
-            bool_entries[3].default_value  = allow_rotate;
+            bool_entries[3].target         = &settings->check_firmware_before_loading;
+            bool_entries[3].name_enum_idx  = MENU_ENUM_LABEL_CHECK_FOR_MISSING_FIRMWARE;
+            bool_entries[3].SHORT_enum_idx = MENU_ENUM_LABEL_VALUE_CHECK_FOR_MISSING_FIRMWARE;
+            bool_entries[3].default_value  = true;
             bool_entries[3].flags          = SD_FLAG_ADVANCED;
 
+            bool_entries[4].target         = &settings->video.allow_rotate;
+            bool_entries[4].name_enum_idx  = MENU_ENUM_LABEL_VIDEO_ALLOW_ROTATE;
+            bool_entries[4].SHORT_enum_idx = MENU_ENUM_LABEL_VALUE_VIDEO_ALLOW_ROTATE;
+            bool_entries[4].default_value  = allow_rotate;
+            bool_entries[4].flags          = SD_FLAG_ADVANCED;
+
             for (i = 0; i < ARRAY_SIZE(bool_entries); i++)
             {
                CONFIG_BOOL(
diff --git a/msg_hash.h b/msg_hash.h
index 4e074ab52b..0ba1f8f489 100644
--- a/msg_hash.h
+++ b/msg_hash.h
@@ -1144,6 +1144,7 @@ enum msg_hash_enums
    MENU_ENUM_LABEL_NETWORK_REMOTE_USER_LAST_ENABLE = MENU_ENUM_LABEL_NETWORK_REMOTE_USER_1_ENABLE + MAX_USERS,
 
    MENU_LABEL(DUMMY_ON_CORE_SHUTDOWN),
+   MENU_LABEL(CHECK_FOR_MISSING_FIRMWARE),
 
    MENU_LABEL(DETECT_CORE_LIST_OK),
    MENU_LABEL(DETECT_CORE_LIST),
diff --git a/tasks/task_content.c b/tasks/task_content.c
index b15dc86236..d4e7ad90e3 100644
--- a/tasks/task_content.c
+++ b/tasks/task_content.c
@@ -1037,6 +1037,7 @@ bool task_push_content_load_default(
       void *user_data)
 {
    bool loading_from_menu = false;
+   settings_t *settings   = config_get_ptr();
 
    if (!content_info)
       return false;
@@ -1242,7 +1243,8 @@ bool task_push_content_load_default(
       case CONTENT_MODE_LOAD_CONTENT_WITH_FFMPEG_CORE_FROM_MENU:
       case CONTENT_MODE_LOAD_CONTENT_WITH_IMAGEVIEWER_CORE_FROM_MENU:
          update_firmware_status();
-         if(runloop_ctl(RUNLOOP_CTL_IS_MISSING_BIOS, NULL))
+         if(runloop_ctl(RUNLOOP_CTL_IS_MISSING_BIOS, NULL) && 
+            settings->check_firmware_before_loading)
             goto skip;
          if (!task_load_content(content_info, loading_from_menu, mode))
             goto error;
@@ -1295,7 +1297,7 @@ error:
 
 skip:
    runloop_msg_queue_push(msg_hash_to_str(MSG_FIRMWARE), 100, 500, true);
-   RARCH_LOG(msg_hash_to_str(MSG_FIRMWARE));
+   RARCH_LOG("Load content blocked. Reason:  %s\n", msg_hash_to_str(MSG_FIRMWARE));
 
    return true;
 }

From 7f62fee3750937540f4864b696ca27e748351530 Mon Sep 17 00:00:00 2001
From: radius <andres.430@gmail.com>
Date: Tue, 29 Nov 2016 23:46:07 -0500
Subject: [PATCH 2/2] fix close content after loading has been blocked

---
 tasks/task_content.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/tasks/task_content.c b/tasks/task_content.c
index d4e7ad90e3..6092f5611e 100644
--- a/tasks/task_content.c
+++ b/tasks/task_content.c
@@ -1221,11 +1221,13 @@ bool task_push_content_load_default(
       default:
          break;
    }
-
    /* Load content */
    switch (mode)
    {
       case CONTENT_MODE_LOAD_NOTHING_WITH_DUMMY_CORE:
+         if (!task_load_content(content_info, loading_from_menu, mode))
+            goto error;
+         break;
       case CONTENT_MODE_LOAD_FROM_CLI:
 #if defined(HAVE_NETWORKING) && defined(HAVE_NETWORKGAMEPAD)
       case CONTENT_MODE_LOAD_NOTHING_WITH_NET_RETROPAD_CORE_FROM_MENU:
@@ -1244,8 +1246,9 @@ bool task_push_content_load_default(
       case CONTENT_MODE_LOAD_CONTENT_WITH_IMAGEVIEWER_CORE_FROM_MENU:
          update_firmware_status();
          if(runloop_ctl(RUNLOOP_CTL_IS_MISSING_BIOS, NULL) && 
-            settings->check_firmware_before_loading)
-            goto skip;
+               settings->check_firmware_before_loading)
+               goto skip;
+
          if (!task_load_content(content_info, loading_from_menu, mode))
             goto error;
          break;